drivers/watchdog/menz69_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/menz69_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/menz69_wdt.c- Extension
.c- Size
- 4051 bytes
- Lines
- 167
- 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/io.hlinux/kernel.hlinux/mcb.hlinux/module.hlinux/watchdog.h
Detected Declarations
struct men_z069_drvfunction men_z069_wdt_startfunction men_z069_wdt_stopfunction men_z069_wdt_pingfunction men_z069_wdt_set_timeoutfunction men_z069_probefunction men_z069_remove
Annotated Snippet
struct men_z069_drv {
struct watchdog_device wdt;
void __iomem *base;
struct resource *mem;
};
#define MEN_Z069_WTR 0x10
#define MEN_Z069_WTR_WDEN BIT(15)
#define MEN_Z069_WTR_WDET_MASK 0x7fff
#define MEN_Z069_WVR 0x14
#define MEN_Z069_TIMER_FREQ 500 /* 500 Hz */
#define MEN_Z069_WDT_COUNTER_MIN 1
#define MEN_Z069_WDT_COUNTER_MAX 0x7fff
#define MEN_Z069_DEFAULT_TIMEOUT 30
static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
static int men_z069_wdt_start(struct watchdog_device *wdt)
{
struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
u16 val;
val = readw(drv->base + MEN_Z069_WTR);
val |= MEN_Z069_WTR_WDEN;
writew(val, drv->base + MEN_Z069_WTR);
return 0;
}
static int men_z069_wdt_stop(struct watchdog_device *wdt)
{
struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
u16 val;
val = readw(drv->base + MEN_Z069_WTR);
val &= ~MEN_Z069_WTR_WDEN;
writew(val, drv->base + MEN_Z069_WTR);
return 0;
}
static int men_z069_wdt_ping(struct watchdog_device *wdt)
{
struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
u16 val;
/* The watchdog trigger value toggles between 0x5555 and 0xaaaa */
val = readw(drv->base + MEN_Z069_WVR);
val ^= 0xffff;
writew(val, drv->base + MEN_Z069_WVR);
return 0;
}
static int men_z069_wdt_set_timeout(struct watchdog_device *wdt,
unsigned int timeout)
{
struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
u16 reg, val, ena;
wdt->timeout = timeout;
val = timeout * MEN_Z069_TIMER_FREQ;
reg = readw(drv->base + MEN_Z069_WTR);
ena = reg & MEN_Z069_WTR_WDEN;
reg = ena | val;
writew(reg, drv->base + MEN_Z069_WTR);
return 0;
}
static const struct watchdog_info men_z069_info = {
.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
.identity = "MEN z069 Watchdog",
};
static const struct watchdog_ops men_z069_ops = {
.owner = THIS_MODULE,
.start = men_z069_wdt_start,
.stop = men_z069_wdt_stop,
.ping = men_z069_wdt_ping,
.set_timeout = men_z069_wdt_set_timeout,
};
static int men_z069_probe(struct mcb_device *dev,
const struct mcb_device_id *id)
Annotation
- Immediate include surface: `linux/io.h`, `linux/kernel.h`, `linux/mcb.h`, `linux/module.h`, `linux/watchdog.h`.
- Detected declarations: `struct men_z069_drv`, `function men_z069_wdt_start`, `function men_z069_wdt_stop`, `function men_z069_wdt_ping`, `function men_z069_wdt_set_timeout`, `function men_z069_probe`, `function men_z069_remove`.
- 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.