drivers/watchdog/iTCO_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/iTCO_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/iTCO_wdt.c- Extension
.c- Size
- 18152 bytes
- Lines
- 653
- 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 user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/acpi.hlinux/bits.hlinux/module.hlinux/moduleparam.hlinux/types.hlinux/errno.hlinux/kernel.hlinux/watchdog.hlinux/init.hlinux/fs.hlinux/platform_device.hlinux/pci.hlinux/ioport.hlinux/uaccess.hlinux/io.hlinux/platform_data/itco_wdt.hlinux/mfd/intel_pmc_bxt.h
Detected Declarations
struct iTCO_wdt_privatefunction seconds_to_ticksfunction ticks_to_secondsfunction no_reboot_bitfunction update_no_reboot_bit_deffunction update_no_reboot_bit_pcifunction update_no_reboot_bit_memfunction update_no_reboot_bit_cntfunction update_no_reboot_bit_pmcfunction iTCO_wdt_no_reboot_bit_setupfunction iTCO_wdt_startfunction iTCO_wdt_stopfunction iTCO_wdt_pingfunction iTCO_wdt_set_timeoutfunction iTCO_wdt_get_timeleftfunction iTCO_wdt_set_runningfunction iTCO_wdt_probefunction flagfunction need_suspendfunction need_suspendfunction iTCO_wdt_suspend_noirqfunction iTCO_wdt_resume_noirq
Annotated Snippet
struct iTCO_wdt_private {
struct watchdog_device wddev;
/* TCO version/generation */
unsigned int iTCO_version;
struct resource *tco_res;
struct resource *smi_res;
/*
* NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2),
* or memory-mapped PMC register bit 4 (TCO version 3).
*/
unsigned long __iomem *gcs_pmc;
/* the PCI-device */
struct pci_dev *pci_dev;
/* whether or not the watchdog has been suspended */
bool suspended;
/* no reboot API private data */
void *no_reboot_priv;
/* no reboot update function pointer */
int (*update_no_reboot_bit)(void *p, bool set);
};
/* module parameters */
#define WATCHDOG_TIMEOUT 30 /* 30 sec default heartbeat */
static int heartbeat = WATCHDOG_TIMEOUT; /* in seconds */
module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog timeout in seconds. "
"5..76 (TCO v1) or 3..614 (TCO v2), default="
__MODULE_STRING(WATCHDOG_TIMEOUT) ")");
static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
static int turn_SMI_watchdog_clear_off = 1;
module_param(turn_SMI_watchdog_clear_off, int, 0);
MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
"Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
/*
* Some TCO specific functions
*/
/*
* The iTCO v1 and v2's internal timer is stored as ticks which decrement
* every 0.6 seconds. v3's internal timer is stored as seconds (some
* datasheets incorrectly state 0.6 seconds).
*/
static inline unsigned int seconds_to_ticks(struct iTCO_wdt_private *p,
int secs)
{
return p->iTCO_version == 3 ? secs : (secs * 10) / 6;
}
static inline unsigned int ticks_to_seconds(struct iTCO_wdt_private *p,
int ticks)
{
return p->iTCO_version == 3 ? ticks : (ticks * 6) / 10;
}
static inline u32 no_reboot_bit(struct iTCO_wdt_private *p)
{
u32 enable_bit;
switch (p->iTCO_version) {
case 5:
case 3:
enable_bit = 0x00000010;
break;
case 2:
enable_bit = 0x00000020;
break;
case 4:
case 1:
default:
enable_bit = 0x00000002;
break;
}
return enable_bit;
}
static int update_no_reboot_bit_def(void *priv, bool set)
{
return 0;
}
static int update_no_reboot_bit_pci(void *priv, bool set)
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bits.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/types.h`, `linux/errno.h`, `linux/kernel.h`, `linux/watchdog.h`.
- Detected declarations: `struct iTCO_wdt_private`, `function seconds_to_ticks`, `function ticks_to_seconds`, `function no_reboot_bit`, `function update_no_reboot_bit_def`, `function update_no_reboot_bit_pci`, `function update_no_reboot_bit_mem`, `function update_no_reboot_bit_cnt`, `function update_no_reboot_bit_pmc`, `function iTCO_wdt_no_reboot_bit_setup`.
- Atlas domain: Driver Families / drivers/watchdog.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.