drivers/watchdog/lantiq_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/lantiq_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/lantiq_wdt.c- Extension
.c- Size
- 7586 bytes
- Lines
- 290
- 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/module.hlinux/bitops.hlinux/watchdog.hlinux/of.hlinux/platform_device.hlinux/uaccess.hlinux/clk.hlinux/io.hlinux/regmap.hlinux/mfd/syscon.hlantiq_soc.h
Detected Declarations
struct ltq_wdt_hwstruct ltq_wdt_privfunction ltq_wdt_r32function ltq_wdt_w32function ltq_wdt_maskfunction ltq_wdt_startfunction ltq_wdt_stopfunction ltq_wdt_pingfunction ltq_wdt_get_timeleftfunction ltq_wdt_xrx_bootstatus_getfunction ltq_wdt_falcon_bootstatus_getfunction ltq_wdt_probe
Annotated Snippet
struct ltq_wdt_hw {
int (*bootstatus_get)(struct device *dev);
};
struct ltq_wdt_priv {
struct watchdog_device wdt;
void __iomem *membase;
unsigned long clk_rate;
};
static u32 ltq_wdt_r32(struct ltq_wdt_priv *priv, u32 offset)
{
return __raw_readl(priv->membase + offset);
}
static void ltq_wdt_w32(struct ltq_wdt_priv *priv, u32 val, u32 offset)
{
__raw_writel(val, priv->membase + offset);
}
static void ltq_wdt_mask(struct ltq_wdt_priv *priv, u32 clear, u32 set,
u32 offset)
{
u32 val = ltq_wdt_r32(priv, offset);
val &= ~(clear);
val |= set;
ltq_wdt_w32(priv, val, offset);
}
static struct ltq_wdt_priv *ltq_wdt_get_priv(struct watchdog_device *wdt)
{
return container_of(wdt, struct ltq_wdt_priv, wdt);
}
static struct watchdog_info ltq_wdt_info = {
.options = WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
WDIOF_CARDRESET,
.identity = "ltq_wdt",
};
static int ltq_wdt_start(struct watchdog_device *wdt)
{
struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt);
u32 timeout;
timeout = wdt->timeout * priv->clk_rate;
ltq_wdt_mask(priv, LTQ_WDT_CR_PW_MASK, LTQ_WDT_CR_PW1, LTQ_WDT_CR);
/* write the second magic plus the configuration and new timeout */
ltq_wdt_mask(priv, LTQ_WDT_CR_PW_MASK | LTQ_WDT_CR_MAX_TIMEOUT,
LTQ_WDT_CR_GEN | LTQ_WDT_CR_PWL | LTQ_WDT_CR_CLKDIV |
LTQ_WDT_CR_PW2 | timeout,
LTQ_WDT_CR);
return 0;
}
static int ltq_wdt_stop(struct watchdog_device *wdt)
{
struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt);
ltq_wdt_mask(priv, LTQ_WDT_CR_PW_MASK, LTQ_WDT_CR_PW1, LTQ_WDT_CR);
ltq_wdt_mask(priv, LTQ_WDT_CR_GEN | LTQ_WDT_CR_PW_MASK,
LTQ_WDT_CR_PW2, LTQ_WDT_CR);
return 0;
}
static int ltq_wdt_ping(struct watchdog_device *wdt)
{
struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt);
u32 timeout;
timeout = wdt->timeout * priv->clk_rate;
ltq_wdt_mask(priv, LTQ_WDT_CR_PW_MASK, LTQ_WDT_CR_PW1, LTQ_WDT_CR);
/* write the second magic plus the configuration and new timeout */
ltq_wdt_mask(priv, LTQ_WDT_CR_PW_MASK | LTQ_WDT_CR_MAX_TIMEOUT,
LTQ_WDT_CR_PW2 | timeout, LTQ_WDT_CR);
return 0;
}
static unsigned int ltq_wdt_get_timeleft(struct watchdog_device *wdt)
{
struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt);
u64 timeout;
timeout = ltq_wdt_r32(priv, LTQ_WDT_SR) & LTQ_WDT_SR_VALUE_MASK;
Annotation
- Immediate include surface: `linux/module.h`, `linux/bitops.h`, `linux/watchdog.h`, `linux/of.h`, `linux/platform_device.h`, `linux/uaccess.h`, `linux/clk.h`, `linux/io.h`.
- Detected declarations: `struct ltq_wdt_hw`, `struct ltq_wdt_priv`, `function ltq_wdt_r32`, `function ltq_wdt_w32`, `function ltq_wdt_mask`, `function ltq_wdt_start`, `function ltq_wdt_stop`, `function ltq_wdt_ping`, `function ltq_wdt_get_timeleft`, `function ltq_wdt_xrx_bootstatus_get`.
- 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.