drivers/watchdog/asm9260_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/asm9260_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/asm9260_wdt.c- Extension
.c- Size
- 8636 bytes
- Lines
- 377
- 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/clk.hlinux/delay.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/reset.hlinux/watchdog.h
Detected Declarations
struct asm9260_wdt_privenum asm9260_wdt_modefunction asm9260_wdt_feedfunction asm9260_wdt_gettimeleftfunction asm9260_wdt_updatetimeoutfunction asm9260_wdt_enablefunction asm9260_wdt_disablefunction asm9260_wdt_settimeoutfunction asm9260_wdt_sys_resetfunction asm9260_wdt_irqfunction asm9260_restartfunction asm9260_clk_disable_unpreparefunction asm9260_wdt_get_dt_clksfunction asm9260_wdt_get_dt_modefunction asm9260_wdt_probe
Annotated Snippet
struct asm9260_wdt_priv {
struct device *dev;
struct watchdog_device wdd;
struct clk *clk;
struct clk *clk_ahb;
struct reset_control *rst;
void __iomem *iobase;
int irq;
unsigned long wdt_freq;
enum asm9260_wdt_mode mode;
};
static int asm9260_wdt_feed(struct watchdog_device *wdd)
{
struct asm9260_wdt_priv *priv = watchdog_get_drvdata(wdd);
iowrite32(0xaa, priv->iobase + HW_WDFEED);
iowrite32(0x55, priv->iobase + HW_WDFEED);
return 0;
}
static unsigned int asm9260_wdt_gettimeleft(struct watchdog_device *wdd)
{
struct asm9260_wdt_priv *priv = watchdog_get_drvdata(wdd);
u32 counter;
counter = ioread32(priv->iobase + HW_WDTV);
return counter / priv->wdt_freq;
}
static int asm9260_wdt_updatetimeout(struct watchdog_device *wdd)
{
struct asm9260_wdt_priv *priv = watchdog_get_drvdata(wdd);
u32 counter;
counter = wdd->timeout * priv->wdt_freq;
iowrite32(counter, priv->iobase + HW_WDTC);
return 0;
}
static int asm9260_wdt_enable(struct watchdog_device *wdd)
{
struct asm9260_wdt_priv *priv = watchdog_get_drvdata(wdd);
u32 mode = 0;
if (priv->mode == HW_RESET)
mode = BM_MOD_WDRESET;
iowrite32(BM_MOD_WDEN | mode, priv->iobase + HW_WDMOD);
asm9260_wdt_updatetimeout(wdd);
asm9260_wdt_feed(wdd);
return 0;
}
static int asm9260_wdt_disable(struct watchdog_device *wdd)
{
struct asm9260_wdt_priv *priv = watchdog_get_drvdata(wdd);
/* The only way to disable WD is to reset it. */
reset_control_assert(priv->rst);
reset_control_deassert(priv->rst);
return 0;
}
static int asm9260_wdt_settimeout(struct watchdog_device *wdd, unsigned int to)
{
wdd->timeout = to;
asm9260_wdt_updatetimeout(wdd);
return 0;
}
static void asm9260_wdt_sys_reset(struct asm9260_wdt_priv *priv)
{
/* init WD if it was not started */
iowrite32(BM_MOD_WDEN | BM_MOD_WDRESET, priv->iobase + HW_WDMOD);
iowrite32(0xff, priv->iobase + HW_WDTC);
/* first pass correct sequence */
asm9260_wdt_feed(&priv->wdd);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct asm9260_wdt_priv`, `enum asm9260_wdt_mode`, `function asm9260_wdt_feed`, `function asm9260_wdt_gettimeleft`, `function asm9260_wdt_updatetimeout`, `function asm9260_wdt_enable`, `function asm9260_wdt_disable`, `function asm9260_wdt_settimeout`, `function asm9260_wdt_sys_reset`, `function asm9260_wdt_irq`.
- 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.