drivers/watchdog/stmp3xxx_rtc_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/stmp3xxx_rtc_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/stmp3xxx_rtc_wdt.c- Extension
.c- Size
- 3864 bytes
- Lines
- 153
- Domain
- Driver Families
- Bucket
- drivers/watchdog
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/watchdog.hlinux/platform_device.hlinux/stmp3xxx_rtc_wdt.hlinux/notifier.hlinux/reboot.h
Detected Declarations
function wdt_startfunction wdt_stopfunction wdt_set_timeoutfunction wdt_notify_sysfunction stmp3xxx_wdt_probefunction stmp3xxx_wdt_removefunction stmp3xxx_wdt_suspendfunction stmp3xxx_wdt_resume
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Watchdog driver for the RTC based watchdog in STMP3xxx and i.MX23/28
*
* Author: Wolfram Sang <kernel@pengutronix.de>
*
* Copyright (C) 2011-12 Wolfram Sang, Pengutronix
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/watchdog.h>
#include <linux/platform_device.h>
#include <linux/stmp3xxx_rtc_wdt.h>
#include <linux/notifier.h>
#include <linux/reboot.h>
#define WDOG_TICK_RATE 1000 /* 1 kHz clock */
#define STMP3XXX_DEFAULT_TIMEOUT 19
#define STMP3XXX_MAX_TIMEOUT (UINT_MAX / WDOG_TICK_RATE)
static int heartbeat = STMP3XXX_DEFAULT_TIMEOUT;
module_param(heartbeat, uint, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat period in seconds from 1 to "
__MODULE_STRING(STMP3XXX_MAX_TIMEOUT) ", default "
__MODULE_STRING(STMP3XXX_DEFAULT_TIMEOUT));
static int wdt_start(struct watchdog_device *wdd)
{
struct device *dev = watchdog_get_drvdata(wdd);
struct stmp3xxx_wdt_pdata *pdata = dev_get_platdata(dev);
pdata->wdt_set_timeout(dev->parent, wdd->timeout * WDOG_TICK_RATE);
return 0;
}
static int wdt_stop(struct watchdog_device *wdd)
{
struct device *dev = watchdog_get_drvdata(wdd);
struct stmp3xxx_wdt_pdata *pdata = dev_get_platdata(dev);
pdata->wdt_set_timeout(dev->parent, 0);
return 0;
}
static int wdt_set_timeout(struct watchdog_device *wdd, unsigned new_timeout)
{
wdd->timeout = new_timeout;
return wdt_start(wdd);
}
static const struct watchdog_info stmp3xxx_wdt_ident = {
.options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
.identity = "STMP3XXX RTC Watchdog",
};
static const struct watchdog_ops stmp3xxx_wdt_ops = {
.owner = THIS_MODULE,
.start = wdt_start,
.stop = wdt_stop,
.set_timeout = wdt_set_timeout,
};
static struct watchdog_device stmp3xxx_wdd = {
.info = &stmp3xxx_wdt_ident,
.ops = &stmp3xxx_wdt_ops,
.min_timeout = 1,
.max_timeout = STMP3XXX_MAX_TIMEOUT,
.status = WATCHDOG_NOWAYOUT_INIT_STATUS,
};
static int wdt_notify_sys(struct notifier_block *nb, unsigned long code,
void *unused)
{
switch (code) {
case SYS_DOWN: /* keep enabled, system might crash while going down */
break;
case SYS_HALT: /* allow the system to actually halt */
case SYS_POWER_OFF:
wdt_stop(&stmp3xxx_wdd);
break;
}
return NOTIFY_DONE;
}
static struct notifier_block wdt_notifier = {
.notifier_call = wdt_notify_sys,
};
static int stmp3xxx_wdt_probe(struct platform_device *pdev)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/watchdog.h`, `linux/platform_device.h`, `linux/stmp3xxx_rtc_wdt.h`, `linux/notifier.h`, `linux/reboot.h`.
- Detected declarations: `function wdt_start`, `function wdt_stop`, `function wdt_set_timeout`, `function wdt_notify_sys`, `function stmp3xxx_wdt_probe`, `function stmp3xxx_wdt_remove`, `function stmp3xxx_wdt_suspend`, `function stmp3xxx_wdt_resume`.
- Atlas domain: Driver Families / drivers/watchdog.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.