drivers/watchdog/renesas_wwdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/renesas_wwdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/renesas_wwdt.c- Extension
.c- Size
- 4084 bytes
- Lines
- 164
- 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/bitfield.hlinux/clk.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/watchdog.h
Detected Declarations
struct wwdt_privfunction wwdt_startfunction wwdt_error_irqfunction wwdt_pretimeout_irqfunction wwdt_probe
Annotated Snippet
struct wwdt_priv {
void __iomem *base;
struct watchdog_device wdev;
};
static int wwdt_start(struct watchdog_device *wdev)
{
struct wwdt_priv *priv = container_of(wdev, struct wwdt_priv, wdev);
writeb(WDTA0RUN | WDTA0_KEY, priv->base + WDTA0WDTE);
return 0;
}
static const struct watchdog_info wwdt_ident = {
.options = WDIOF_KEEPALIVEPING | WDIOF_ALARMONLY,
.identity = "Renesas Window Watchdog",
};
static const struct watchdog_ops wwdt_ops = {
.owner = THIS_MODULE,
.start = wwdt_start,
};
static irqreturn_t wwdt_error_irq(int irq, void *dev_id)
{
struct device *dev = dev_id;
dev_warn(dev, "Watchdog timed out\n");
return IRQ_HANDLED;
}
static irqreturn_t wwdt_pretimeout_irq(int irq, void *dev_id)
{
struct watchdog_device *wdev = dev_id;
watchdog_notify_pretimeout(wdev);
return IRQ_HANDLED;
}
static int wwdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct wwdt_priv *priv;
struct watchdog_device *wdev;
struct clk *clk;
unsigned long rate;
unsigned int interval, window_size;
int ret;
u8 val;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
clk = devm_clk_get(dev, "cnt");
if (IS_ERR(clk))
return PTR_ERR(clk);
rate = clk_get_rate(clk);
if (!rate)
return -EINVAL;
wdev = &priv->wdev;
val = readb(priv->base + WDTA0WDTE);
if (val & WDTA0RUN)
set_bit(WDOG_HW_RUNNING, &wdev->status);
val = readb(priv->base + WDTA0MD);
interval = 1 << (9 + WDTA0OVF(val));
/* size of the closed(!) window per mille */
window_size = 250 * (3 - WDTA0WS(val));
wdev->info = &wwdt_ident;
wdev->ops = &wwdt_ops;
wdev->parent = dev;
wdev->min_hw_heartbeat_ms = window_size * interval / rate;
wdev->max_hw_heartbeat_ms = 1000 * interval / rate;
wdev->timeout = DIV_ROUND_UP(wdev->max_hw_heartbeat_ms, 1000);
watchdog_set_nowayout(wdev, true);
if (!(val & WDTA0ERM)) {
ret = platform_get_irq_byname(pdev, "error");
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct wwdt_priv`, `function wwdt_start`, `function wwdt_error_irq`, `function wwdt_pretimeout_irq`, `function wwdt_probe`.
- 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.