drivers/watchdog/da9062_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/da9062_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/da9062_wdt.c- Extension
.c- Size
- 7602 bytes
- Lines
- 296
- 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/kernel.hlinux/module.hlinux/watchdog.hlinux/platform_device.hlinux/uaccess.hlinux/slab.hlinux/i2c.hlinux/delay.hlinux/jiffies.hlinux/mfd/da9062/registers.hlinux/mfd/da9062/core.hlinux/property.hlinux/regmap.hlinux/of.h
Detected Declarations
struct da9062_watchdogfunction da9062_wdt_read_timeoutfunction da9062_wdt_timeout_to_selfunction da9062_reset_watchdog_timerfunction da9062_wdt_update_timeout_registerfunction da9062_wdt_startfunction da9062_wdt_stopfunction da9062_wdt_pingfunction da9062_wdt_set_timeoutfunction da9062_wdt_restartfunction da9062_wdt_probefunction da9062_wdt_suspendfunction da9062_wdt_resume
Annotated Snippet
struct da9062_watchdog {
struct da9062 *hw;
struct watchdog_device wdtdev;
bool use_sw_pm;
};
static unsigned int da9062_wdt_read_timeout(struct da9062_watchdog *wdt)
{
unsigned int val;
regmap_read(wdt->hw->regmap, DA9062AA_CONTROL_D, &val);
return wdt_timeout[val & DA9062AA_TWDSCALE_MASK];
}
static unsigned int da9062_wdt_timeout_to_sel(unsigned int secs)
{
unsigned int i;
for (i = DA9062_TWDSCALE_MIN; i <= DA9062_TWDSCALE_MAX; i++) {
if (wdt_timeout[i] >= secs)
return i;
}
return DA9062_TWDSCALE_MAX;
}
static int da9062_reset_watchdog_timer(struct da9062_watchdog *wdt)
{
return regmap_update_bits(wdt->hw->regmap, DA9062AA_CONTROL_F,
DA9062AA_WATCHDOG_MASK,
DA9062AA_WATCHDOG_MASK);
}
static int da9062_wdt_update_timeout_register(struct da9062_watchdog *wdt,
unsigned int regval)
{
struct da9062 *chip = wdt->hw;
regmap_update_bits(chip->regmap,
DA9062AA_CONTROL_D,
DA9062AA_TWDSCALE_MASK,
DA9062_TWDSCALE_DISABLE);
usleep_range(150, 300);
return regmap_update_bits(chip->regmap,
DA9062AA_CONTROL_D,
DA9062AA_TWDSCALE_MASK,
regval);
}
static int da9062_wdt_start(struct watchdog_device *wdd)
{
struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd);
unsigned int selector;
int ret;
selector = da9062_wdt_timeout_to_sel(wdt->wdtdev.timeout);
ret = da9062_wdt_update_timeout_register(wdt, selector);
if (ret)
dev_err(wdt->hw->dev, "Watchdog failed to start (err = %d)\n",
ret);
return ret;
}
static int da9062_wdt_stop(struct watchdog_device *wdd)
{
struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd);
int ret;
ret = regmap_update_bits(wdt->hw->regmap,
DA9062AA_CONTROL_D,
DA9062AA_TWDSCALE_MASK,
DA9062_TWDSCALE_DISABLE);
if (ret)
dev_err(wdt->hw->dev, "Watchdog failed to stop (err = %d)\n",
ret);
return ret;
}
static int da9062_wdt_ping(struct watchdog_device *wdd)
{
struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd);
int ret;
/*
* Prevent pings from occurring late in system poweroff/reboot sequence
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/watchdog.h`, `linux/platform_device.h`, `linux/uaccess.h`, `linux/slab.h`, `linux/i2c.h`, `linux/delay.h`.
- Detected declarations: `struct da9062_watchdog`, `function da9062_wdt_read_timeout`, `function da9062_wdt_timeout_to_sel`, `function da9062_reset_watchdog_timer`, `function da9062_wdt_update_timeout_register`, `function da9062_wdt_start`, `function da9062_wdt_stop`, `function da9062_wdt_ping`, `function da9062_wdt_set_timeout`, `function da9062_wdt_restart`.
- 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.