drivers/watchdog/ts72xx_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/ts72xx_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/ts72xx_wdt.c- Extension
.c- Size
- 4381 bytes
- Lines
- 184
- 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/platform_device.hlinux/mod_devicetable.hlinux/module.hlinux/watchdog.hlinux/io.h
Detected Declarations
struct ts72xx_wdt_privfunction ts72xx_wdt_startfunction ts72xx_wdt_stopfunction ts72xx_wdt_pingfunction ts72xx_wdt_settimeoutfunction ts72xx_wdt_probe
Annotated Snippet
struct ts72xx_wdt_priv {
void __iomem *control_reg;
void __iomem *feed_reg;
struct watchdog_device wdd;
unsigned char regval;
};
static int ts72xx_wdt_start(struct watchdog_device *wdd)
{
struct ts72xx_wdt_priv *priv = watchdog_get_drvdata(wdd);
writeb(TS72XX_WDT_FEED_VAL, priv->feed_reg);
writeb(priv->regval, priv->control_reg);
return 0;
}
static int ts72xx_wdt_stop(struct watchdog_device *wdd)
{
struct ts72xx_wdt_priv *priv = watchdog_get_drvdata(wdd);
writeb(TS72XX_WDT_FEED_VAL, priv->feed_reg);
writeb(TS72XX_WDT_CTRL_DISABLE, priv->control_reg);
return 0;
}
static int ts72xx_wdt_ping(struct watchdog_device *wdd)
{
struct ts72xx_wdt_priv *priv = watchdog_get_drvdata(wdd);
writeb(TS72XX_WDT_FEED_VAL, priv->feed_reg);
return 0;
}
static int ts72xx_wdt_settimeout(struct watchdog_device *wdd, unsigned int to)
{
struct ts72xx_wdt_priv *priv = watchdog_get_drvdata(wdd);
if (to == 1) {
priv->regval = TS72XX_WDT_CTRL_1SEC;
} else if (to == 2) {
priv->regval = TS72XX_WDT_CTRL_2SEC;
} else if (to <= 4) {
priv->regval = TS72XX_WDT_CTRL_4SEC;
to = 4;
} else {
priv->regval = TS72XX_WDT_CTRL_8SEC;
if (to <= 8)
to = 8;
}
wdd->timeout = to;
if (watchdog_active(wdd)) {
ts72xx_wdt_stop(wdd);
ts72xx_wdt_start(wdd);
}
return 0;
}
static const struct watchdog_info ts72xx_wdt_ident = {
.options = WDIOF_KEEPALIVEPING |
WDIOF_SETTIMEOUT |
WDIOF_MAGICCLOSE,
.firmware_version = 1,
.identity = "TS-72XX WDT",
};
static const struct watchdog_ops ts72xx_wdt_ops = {
.owner = THIS_MODULE,
.start = ts72xx_wdt_start,
.stop = ts72xx_wdt_stop,
.ping = ts72xx_wdt_ping,
.set_timeout = ts72xx_wdt_settimeout,
};
static int ts72xx_wdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct ts72xx_wdt_priv *priv;
struct watchdog_device *wdd;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/watchdog.h`, `linux/io.h`.
- Detected declarations: `struct ts72xx_wdt_priv`, `function ts72xx_wdt_start`, `function ts72xx_wdt_stop`, `function ts72xx_wdt_ping`, `function ts72xx_wdt_settimeout`, `function ts72xx_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.