drivers/watchdog/ts4800_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/ts4800_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/ts4800_wdt.c- Extension
.c- Size
- 5066 bytes
- Lines
- 206
- 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/mfd/syscon.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/watchdog.h
Detected Declarations
struct ts4800_wdtfunction ts4800_write_feedfunction ts4800_wdt_startfunction ts4800_wdt_stopfunction ts4800_wdt_set_timeoutfunction ts4800_wdt_probe
Annotated Snippet
struct ts4800_wdt {
struct watchdog_device wdd;
struct regmap *regmap;
u32 feed_offset;
u32 feed_val;
};
/*
* TS-4800 supports the following timeout values:
*
* value desc
* ---------------------
* 0 feed for 338ms
* 1 feed for 2.706s
* 2 feed for 10.824s
* 3 disable watchdog
*
* Keep the regmap/timeout map ordered by timeout
*/
static const struct {
const int timeout;
const int regval;
} ts4800_wdt_map[] = {
{ 2, TS4800_WDT_FEED_2S },
{ 10, TS4800_WDT_FEED_10S },
};
#define MAX_TIMEOUT_INDEX (ARRAY_SIZE(ts4800_wdt_map) - 1)
static void ts4800_write_feed(struct ts4800_wdt *wdt, u32 val)
{
regmap_write(wdt->regmap, wdt->feed_offset, val);
}
static int ts4800_wdt_start(struct watchdog_device *wdd)
{
struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
ts4800_write_feed(wdt, wdt->feed_val);
return 0;
}
static int ts4800_wdt_stop(struct watchdog_device *wdd)
{
struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
ts4800_write_feed(wdt, TS4800_WDT_DISABLE);
return 0;
}
static int ts4800_wdt_set_timeout(struct watchdog_device *wdd,
unsigned int timeout)
{
struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
int i;
for (i = 0; i < MAX_TIMEOUT_INDEX; i++) {
if (ts4800_wdt_map[i].timeout >= timeout)
break;
}
wdd->timeout = ts4800_wdt_map[i].timeout;
wdt->feed_val = ts4800_wdt_map[i].regval;
return 0;
}
static const struct watchdog_ops ts4800_wdt_ops = {
.owner = THIS_MODULE,
.start = ts4800_wdt_start,
.stop = ts4800_wdt_stop,
.set_timeout = ts4800_wdt_set_timeout,
};
static const struct watchdog_info ts4800_wdt_info = {
.options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
.identity = "TS-4800 Watchdog",
};
static int ts4800_wdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct device_node *syscon_np;
struct watchdog_device *wdd;
struct ts4800_wdt *wdt;
u32 reg;
int ret;
syscon_np = of_parse_phandle(np, "syscon", 0);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/watchdog.h`.
- Detected declarations: `struct ts4800_wdt`, `function ts4800_write_feed`, `function ts4800_wdt_start`, `function ts4800_wdt_stop`, `function ts4800_wdt_set_timeout`, `function ts4800_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.