drivers/watchdog/ftwdt010_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/ftwdt010_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/ftwdt010_wdt.c- Extension
.c- Size
- 5706 bytes
- Lines
- 243
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bitops.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/slab.hlinux/watchdog.h
Detected Declarations
struct ftwdt010_wdtfunction ftwdt010_enablefunction ftwdt010_wdt_startfunction ftwdt010_wdt_stopfunction ftwdt010_wdt_pingfunction ftwdt010_wdt_set_timeoutfunction ftwdt010_wdt_restartfunction ftwdt010_wdt_interruptfunction ftwdt010_wdt_probefunction ftwdt010_wdt_suspendfunction ftwdt010_wdt_resume
Annotated Snippet
struct ftwdt010_wdt {
struct watchdog_device wdd;
struct device *dev;
void __iomem *base;
bool has_irq;
};
static inline
struct ftwdt010_wdt *to_ftwdt010_wdt(struct watchdog_device *wdd)
{
return container_of(wdd, struct ftwdt010_wdt, wdd);
}
static void ftwdt010_enable(struct ftwdt010_wdt *gwdt,
unsigned int timeout,
bool need_irq)
{
u32 enable;
writel(timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD);
writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART);
/* set clock before enabling */
enable = WDCR_CLOCK_5MHZ | WDCR_SYS_RST;
writel(enable, gwdt->base + FTWDT010_WDCR);
if (need_irq)
enable |= WDCR_WDINTR;
enable |= WDCR_ENABLE;
writel(enable, gwdt->base + FTWDT010_WDCR);
}
static int ftwdt010_wdt_start(struct watchdog_device *wdd)
{
struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd);
ftwdt010_enable(gwdt, wdd->timeout, gwdt->has_irq);
return 0;
}
static int ftwdt010_wdt_stop(struct watchdog_device *wdd)
{
struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd);
writel(0, gwdt->base + FTWDT010_WDCR);
return 0;
}
static int ftwdt010_wdt_ping(struct watchdog_device *wdd)
{
struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd);
writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART);
return 0;
}
static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd,
unsigned int timeout)
{
wdd->timeout = timeout;
if (watchdog_active(wdd))
ftwdt010_wdt_start(wdd);
return 0;
}
static int ftwdt010_wdt_restart(struct watchdog_device *wdd,
unsigned long action, void *data)
{
ftwdt010_enable(to_ftwdt010_wdt(wdd), 0, false);
return 0;
}
static irqreturn_t ftwdt010_wdt_interrupt(int irq, void *data)
{
struct ftwdt010_wdt *gwdt = data;
watchdog_notify_pretimeout(&gwdt->wdd);
return IRQ_HANDLED;
}
static const struct watchdog_ops ftwdt010_wdt_ops = {
.start = ftwdt010_wdt_start,
.stop = ftwdt010_wdt_stop,
.ping = ftwdt010_wdt_ping,
.set_timeout = ftwdt010_wdt_set_timeout,
.restart = ftwdt010_wdt_restart,
.owner = THIS_MODULE,
};
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`.
- Detected declarations: `struct ftwdt010_wdt`, `function ftwdt010_enable`, `function ftwdt010_wdt_start`, `function ftwdt010_wdt_stop`, `function ftwdt010_wdt_ping`, `function ftwdt010_wdt_set_timeout`, `function ftwdt010_wdt_restart`, `function ftwdt010_wdt_interrupt`, `function ftwdt010_wdt_probe`, `function ftwdt010_wdt_suspend`.
- Atlas domain: Driver Families / drivers/watchdog.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.