drivers/watchdog/intel-mid_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/intel-mid_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/intel-mid_wdt.c- Extension
.c- Size
- 5189 bytes
- Lines
- 211
- 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/bitops.hlinux/device.hlinux/errno.hlinux/interrupt.hlinux/math.hlinux/module.hlinux/panic.hlinux/platform_device.hlinux/types.hlinux/watchdog.hlinux/platform_data/x86/intel-mid_wdt.hlinux/platform_data/x86/intel_scu_ipc.h
Detected Declarations
struct mid_wdtstruct ipc_wd_startfunction wdt_commandfunction wdt_startfunction wdt_pingfunction wdt_stopfunction mid_wdt_irqfunction mid_wdt_probe
Annotated Snippet
struct mid_wdt {
struct watchdog_device wd;
struct device *dev;
struct intel_scu_ipc_dev *scu;
};
static inline int
wdt_command(struct mid_wdt *mid, int sub, const void *in, size_t inlen, size_t size)
{
struct intel_scu_ipc_dev *scu = mid->scu;
return intel_scu_ipc_dev_command_with_size(scu, IPC_WATCHDOG, sub, in,
inlen, size, NULL, 0);
}
static int wdt_start(struct watchdog_device *wd)
{
struct mid_wdt *mid = watchdog_get_drvdata(wd);
int ret, in_size;
int timeout = wd->timeout;
struct ipc_wd_start {
u32 pretimeout;
u32 timeout;
} ipc_wd_start = { timeout - MID_WDT_PRETIMEOUT, timeout };
/*
* SCU expects the input size for watchdog IPC to be 2 which is the
* size of the structure in dwords. SCU IPC normally takes bytes
* but this is a special case where we specify size to be different
* than inlen.
*/
in_size = DIV_ROUND_UP(sizeof(ipc_wd_start), 4);
ret = wdt_command(mid, SCU_WATCHDOG_START, &ipc_wd_start,
sizeof(ipc_wd_start), in_size);
if (ret)
dev_crit(mid->dev, "error starting watchdog: %d\n", ret);
return ret;
}
static int wdt_ping(struct watchdog_device *wd)
{
struct mid_wdt *mid = watchdog_get_drvdata(wd);
int ret;
ret = wdt_command(mid, SCU_WATCHDOG_KEEPALIVE, NULL, 0, 0);
if (ret)
dev_crit(mid->dev, "Error executing keepalive: %d\n", ret);
return ret;
}
static int wdt_stop(struct watchdog_device *wd)
{
struct mid_wdt *mid = watchdog_get_drvdata(wd);
int ret;
ret = wdt_command(mid, SCU_WATCHDOG_STOP, NULL, 0, 0);
if (ret)
dev_crit(mid->dev, "Error stopping watchdog: %d\n", ret);
return ret;
}
static irqreturn_t mid_wdt_irq(int irq, void *dev_id)
{
panic("Kernel Watchdog");
/* This code should not be reached */
return IRQ_HANDLED;
}
static const struct watchdog_info mid_wdt_info = {
.identity = "Intel MID SCU watchdog",
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
};
static const struct watchdog_ops mid_wdt_ops = {
.owner = THIS_MODULE,
.start = wdt_start,
.stop = wdt_stop,
.ping = wdt_ping,
};
static int mid_wdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct watchdog_device *wdt_dev;
struct intel_mid_wdt_pdata *pdata = dev_get_platdata(dev);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/device.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/math.h`, `linux/module.h`, `linux/panic.h`, `linux/platform_device.h`.
- Detected declarations: `struct mid_wdt`, `struct ipc_wd_start`, `function wdt_command`, `function wdt_start`, `function wdt_ping`, `function wdt_stop`, `function mid_wdt_irq`, `function mid_wdt_probe`.
- 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.