drivers/watchdog/mt7621_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/mt7621_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/mt7621_wdt.c- Extension
.c- Size
- 5834 bytes
- Lines
- 230
- 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/clk.hlinux/reset.hlinux/module.hlinux/kernel.hlinux/watchdog.hlinux/moduleparam.hlinux/platform_device.hlinux/mod_devicetable.hlinux/mfd/syscon.hlinux/regmap.h
Detected Declarations
struct mt7621_wdt_datafunction rt_wdt_w32function rt_wdt_r32function mt7621_wdt_pingfunction mt7621_wdt_set_timeoutfunction mt7621_wdt_startfunction mt7621_wdt_stopfunction mt7621_wdt_bootcausefunction mt7621_wdt_is_runningfunction mt7621_wdt_probefunction mt7621_wdt_shutdown
Annotated Snippet
struct mt7621_wdt_data {
void __iomem *base;
struct reset_control *rst;
struct regmap *sysc;
struct watchdog_device wdt;
};
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 inline void rt_wdt_w32(void __iomem *base, unsigned int reg, u32 val)
{
iowrite32(val, base + reg);
}
static inline u32 rt_wdt_r32(void __iomem *base, unsigned int reg)
{
return ioread32(base + reg);
}
static int mt7621_wdt_ping(struct watchdog_device *w)
{
struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w);
rt_wdt_w32(drvdata->base, TIMER_REG_TMRSTAT, TMR1CTL_RESTART);
return 0;
}
static int mt7621_wdt_set_timeout(struct watchdog_device *w, unsigned int t)
{
struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w);
w->timeout = t;
rt_wdt_w32(drvdata->base, TIMER_REG_TMR1LOAD, t * 1000);
mt7621_wdt_ping(w);
return 0;
}
static int mt7621_wdt_start(struct watchdog_device *w)
{
struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w);
u32 t;
/* set the prescaler to 1ms == 1000us */
rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, 1000 << TMR1CTL_PRESCALE_SHIFT);
mt7621_wdt_set_timeout(w, w->timeout);
t = rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL);
t |= TMR1CTL_ENABLE;
rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, t);
return 0;
}
static int mt7621_wdt_stop(struct watchdog_device *w)
{
struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w);
u32 t;
mt7621_wdt_ping(w);
t = rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL);
t &= ~TMR1CTL_ENABLE;
rt_wdt_w32(drvdata->base, TIMER_REG_TMR1CTL, t);
return 0;
}
static int mt7621_wdt_bootcause(struct mt7621_wdt_data *d)
{
u32 val;
regmap_read(d->sysc, SYSC_RSTSTAT, &val);
if (val & WDT_RST_CAUSE)
return WDIOF_CARDRESET;
return 0;
}
static int mt7621_wdt_is_running(struct watchdog_device *w)
{
struct mt7621_wdt_data *drvdata = watchdog_get_drvdata(w);
return !!(rt_wdt_r32(drvdata->base, TIMER_REG_TMR1CTL) & TMR1CTL_ENABLE);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/reset.h`, `linux/module.h`, `linux/kernel.h`, `linux/watchdog.h`, `linux/moduleparam.h`, `linux/platform_device.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct mt7621_wdt_data`, `function rt_wdt_w32`, `function rt_wdt_r32`, `function mt7621_wdt_ping`, `function mt7621_wdt_set_timeout`, `function mt7621_wdt_start`, `function mt7621_wdt_stop`, `function mt7621_wdt_bootcause`, `function mt7621_wdt_is_running`, `function mt7621_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.