drivers/watchdog/gxp-wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/gxp-wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/gxp-wdt.c- Extension
.c- Size
- 4558 bytes
- Lines
- 174
- 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/delay.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/types.hlinux/watchdog.h
Detected Declarations
struct gxp_wdtfunction gxp_wdt_enable_reloadfunction gxp_wdt_startfunction gxp_wdt_stopfunction gxp_wdt_set_timeoutfunction gxp_wdt_get_timeleftfunction gxp_wdt_pingfunction gxp_restartfunction gxp_wdt_probe
Annotated Snippet
struct gxp_wdt {
void __iomem *base;
struct watchdog_device wdd;
};
static void gxp_wdt_enable_reload(struct gxp_wdt *drvdata)
{
u8 val;
val = readb(drvdata->base + GXP_WDT_CTRL_OFS);
val |= (MASK_WDGCS_ENABLE | MASK_WDGCS_RELOAD);
writeb(val, drvdata->base + GXP_WDT_CTRL_OFS);
}
static int gxp_wdt_start(struct watchdog_device *wdd)
{
struct gxp_wdt *drvdata = watchdog_get_drvdata(wdd);
writew(SECS_TO_WDOG_TICKS(wdd->timeout), drvdata->base + GXP_WDT_CNT_OFS);
gxp_wdt_enable_reload(drvdata);
return 0;
}
static int gxp_wdt_stop(struct watchdog_device *wdd)
{
struct gxp_wdt *drvdata = watchdog_get_drvdata(wdd);
u8 val;
val = readb_relaxed(drvdata->base + GXP_WDT_CTRL_OFS);
val &= ~MASK_WDGCS_ENABLE;
writeb(val, drvdata->base + GXP_WDT_CTRL_OFS);
return 0;
}
static int gxp_wdt_set_timeout(struct watchdog_device *wdd,
unsigned int timeout)
{
struct gxp_wdt *drvdata = watchdog_get_drvdata(wdd);
u32 actual;
wdd->timeout = timeout;
actual = min(timeout * 100, wdd->max_hw_heartbeat_ms / 10);
writew(actual, drvdata->base + GXP_WDT_CNT_OFS);
return 0;
}
static unsigned int gxp_wdt_get_timeleft(struct watchdog_device *wdd)
{
struct gxp_wdt *drvdata = watchdog_get_drvdata(wdd);
u32 val = readw(drvdata->base + GXP_WDT_CNT_OFS);
return WDOG_TICKS_TO_SECS(val);
}
static int gxp_wdt_ping(struct watchdog_device *wdd)
{
struct gxp_wdt *drvdata = watchdog_get_drvdata(wdd);
gxp_wdt_enable_reload(drvdata);
return 0;
}
static int gxp_restart(struct watchdog_device *wdd, unsigned long action,
void *data)
{
struct gxp_wdt *drvdata = watchdog_get_drvdata(wdd);
writew(1, drvdata->base + GXP_WDT_CNT_OFS);
gxp_wdt_enable_reload(drvdata);
mdelay(100);
return 0;
}
static const struct watchdog_ops gxp_wdt_ops = {
.owner = THIS_MODULE,
.start = gxp_wdt_start,
.stop = gxp_wdt_stop,
.ping = gxp_wdt_ping,
.set_timeout = gxp_wdt_set_timeout,
.get_timeleft = gxp_wdt_get_timeleft,
.restart = gxp_restart,
};
static const struct watchdog_info gxp_wdt_info = {
.options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
.identity = "HPE GXP Watchdog timer",
};
static int gxp_wdt_probe(struct platform_device *pdev)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/io.h`, `linux/module.h`, `linux/platform_device.h`, `linux/types.h`, `linux/watchdog.h`.
- Detected declarations: `struct gxp_wdt`, `function gxp_wdt_enable_reload`, `function gxp_wdt_start`, `function gxp_wdt_stop`, `function gxp_wdt_set_timeout`, `function gxp_wdt_get_timeleft`, `function gxp_wdt_ping`, `function gxp_restart`, `function gxp_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.