drivers/watchdog/imx_sc_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/imx_sc_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/imx_sc_wdt.c- Extension
.c- Size
- 6546 bytes
- Lines
- 259
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/arm-smccc.hlinux/firmware/imx/sci.hlinux/io.hlinux/kernel.hlinux/module.hlinux/moduleparam.hlinux/of.hlinux/platform_device.hlinux/watchdog.h
Detected Declarations
struct imx_sc_wdt_devicefunction imx_sc_wdt_pingfunction imx_sc_wdt_is_runningfunction imx_sc_wdt_startfunction imx_sc_wdt_stopfunction imx_sc_wdt_set_timeoutfunction imx_sc_wdt_set_pretimeoutfunction imx_sc_wdt_notifyfunction imx_sc_wdt_actionfunction imx_sc_wdt_probe
Annotated Snippet
struct imx_sc_wdt_device {
struct watchdog_device wdd;
struct notifier_block wdt_notifier;
};
static int imx_sc_wdt_ping(struct watchdog_device *wdog)
{
struct arm_smccc_res res;
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_PING_WDOG,
0, 0, 0, 0, 0, 0, &res);
return 0;
}
static bool imx_sc_wdt_is_running(void)
{
struct arm_smccc_res res;
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_START_WDOG,
0, 0, 0, 0, 0, 0, &res);
/* Already enabled (SC_TIMER_ERR_BUSY)? */
if (res.a0 == SC_TIMER_ERR_BUSY)
return true;
/* Undo only if that was us who has (successfully) enabled the WDT */
if (!res.a0)
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_STOP_WDOG,
0, 0, 0, 0, 0, 0, &res);
return false;
}
static int imx_sc_wdt_start(struct watchdog_device *wdog)
{
struct arm_smccc_res res;
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_START_WDOG,
0, 0, 0, 0, 0, 0, &res);
/* Ignore if already enabled(SC_TIMER_ERR_BUSY) */
if (res.a0 && res.a0 != SC_TIMER_ERR_BUSY)
return -EACCES;
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_SET_WDOG_ACT,
SC_TIMER_WDOG_ACTION_PARTITION,
0, 0, 0, 0, 0, &res);
return res.a0 ? -EACCES : 0;
}
static int imx_sc_wdt_stop(struct watchdog_device *wdog)
{
struct arm_smccc_res res;
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_STOP_WDOG,
0, 0, 0, 0, 0, 0, &res);
return res.a0 ? -EACCES : 0;
}
static int imx_sc_wdt_set_timeout(struct watchdog_device *wdog,
unsigned int timeout)
{
struct arm_smccc_res res;
wdog->timeout = timeout;
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_SET_TIMEOUT_WDOG,
timeout * 1000, 0, 0, 0, 0, 0, &res);
return res.a0 ? -EACCES : 0;
}
static int imx_sc_wdt_set_pretimeout(struct watchdog_device *wdog,
unsigned int pretimeout)
{
struct arm_smccc_res res;
/*
* SCU firmware calculates pretimeout based on current time
* stamp instead of watchdog timeout stamp, need to convert
* the pretimeout to SCU firmware's timeout value.
*/
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_SET_PRETIME_WDOG,
(wdog->timeout - pretimeout) * 1000, 0, 0, 0,
0, 0, &res);
if (res.a0)
return -EACCES;
wdog->pretimeout = pretimeout;
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/firmware/imx/sci.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct imx_sc_wdt_device`, `function imx_sc_wdt_ping`, `function imx_sc_wdt_is_running`, `function imx_sc_wdt_start`, `function imx_sc_wdt_stop`, `function imx_sc_wdt_set_timeout`, `function imx_sc_wdt_set_pretimeout`, `function imx_sc_wdt_notify`, `function imx_sc_wdt_action`, `function imx_sc_wdt_probe`.
- 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.