drivers/watchdog/bd96801_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/bd96801_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/bd96801_wdt.c- Extension
.c- Size
- 10243 bytes
- Lines
- 418
- 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/interrupt.hlinux/kernel.hlinux/mfd/rohm-bd96801.hlinux/mfd/rohm-generic.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/reboot.hlinux/regmap.hlinux/watchdog.h
Detected Declarations
struct wdtbd96801function bd96801_wdt_pingfunction bd96801_wdt_startfunction bd96801_wdt_stopfunction find_closest_fastfunction find_closest_slow_by_fastfunction find_closest_slowfunction bd96801_set_wdt_modefunction bd96801_set_heartbeat_from_hwfunction init_wdg_hwfunction bd96801_irq_hndfunction bd96801_wdt_probe
Annotated Snippet
struct wdtbd96801 {
struct device *dev;
struct regmap *regmap;
struct watchdog_device wdt;
};
static int bd96801_wdt_ping(struct watchdog_device *wdt)
{
struct wdtbd96801 *w = watchdog_get_drvdata(wdt);
return regmap_update_bits(w->regmap, BD96801_REG_WD_FEED,
BD96801_WD_FEED_MASK, BD96801_WD_FEED);
}
static int bd96801_wdt_start(struct watchdog_device *wdt)
{
struct wdtbd96801 *w = watchdog_get_drvdata(wdt);
return regmap_update_bits(w->regmap, BD96801_REG_WD_CONF,
BD96801_WD_EN_MASK, BD96801_WD_IF_EN);
}
static int bd96801_wdt_stop(struct watchdog_device *wdt)
{
struct wdtbd96801 *w = watchdog_get_drvdata(wdt);
return regmap_update_bits(w->regmap, BD96801_REG_WD_CONF,
BD96801_WD_EN_MASK, BD96801_WD_DISABLE);
}
static const struct watchdog_info bd96801_wdt_info = {
.options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING |
WDIOF_SETTIMEOUT,
.identity = "BD96801 Watchdog",
};
static const struct watchdog_ops bd96801_wdt_ops = {
.start = bd96801_wdt_start,
.stop = bd96801_wdt_stop,
.ping = bd96801_wdt_ping,
};
static int find_closest_fast(unsigned int target, int *sel, unsigned int *val)
{
unsigned int window = FASTNG_MIN;
int i;
for (i = 0; i < 8 && window < target; i++)
window <<= 1;
if (i == 8)
return -EINVAL;
*val = window;
*sel = i;
return 0;
}
static int find_closest_slow_by_fast(unsigned int fast_val, unsigned int *target,
int *slowsel)
{
static const int multipliers[] = {2, 4, 8, 16};
int sel;
for (sel = 0; sel < ARRAY_SIZE(multipliers) &&
multipliers[sel] * fast_val < *target; sel++)
;
if (sel == ARRAY_SIZE(multipliers))
return -EINVAL;
*slowsel = sel;
*target = multipliers[sel] * fast_val;
return 0;
}
static int find_closest_slow(unsigned int *target, int *slow_sel, int *fast_sel)
{
static const int multipliers[] = {2, 4, 8, 16};
unsigned int window = FASTNG_MIN;
unsigned int val = 0;
int i, j;
for (i = 0; i < 8; i++) {
for (j = 0; j < ARRAY_SIZE(multipliers); j++) {
unsigned int slow;
slow = window * multipliers[j];
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mfd/rohm-bd96801.h`, `linux/mfd/rohm-generic.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `struct wdtbd96801`, `function bd96801_wdt_ping`, `function bd96801_wdt_start`, `function bd96801_wdt_stop`, `function find_closest_fast`, `function find_closest_slow_by_fast`, `function find_closest_slow`, `function bd96801_set_wdt_mode`, `function bd96801_set_heartbeat_from_hw`, `function init_wdg_hw`.
- 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.