drivers/watchdog/mtk_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/mtk_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/mtk_wdt.c- Extension
.c- Size
- 13667 bytes
- Lines
- 535
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
dt-bindings/reset/mt2712-resets.hdt-bindings/reset/mediatek,mt6735-wdt.hdt-bindings/reset/mediatek,mt6795-resets.hdt-bindings/reset/mt7986-resets.hdt-bindings/reset/mt8183-resets.hdt-bindings/reset/mt8186-resets.hdt-bindings/reset/mt8188-resets.hdt-bindings/reset/mt8192-resets.hdt-bindings/reset/mt8195-resets.hlinux/delay.hlinux/err.hlinux/init.hlinux/io.hlinux/kernel.hlinux/module.hlinux/moduleparam.hlinux/of.hlinux/platform_device.hlinux/reset-controller.hlinux/types.hlinux/watchdog.hlinux/interrupt.h
Detected Declarations
struct mtk_wdt_devstruct mtk_wdt_datafunction toprgu_reset_sw_en_unlockedfunction toprgu_reset_updatefunction toprgu_reset_assertfunction toprgu_reset_deassertfunction toprgu_resetfunction toprgu_register_reset_controllerfunction mtk_wdt_restartfunction mtk_wdt_pingfunction mtk_wdt_set_timeoutfunction mtk_wdt_initfunction mtk_wdt_stopfunction mtk_wdt_startfunction mtk_wdt_set_pretimeoutfunction mtk_wdt_isrfunction mtk_wdt_probefunction mtk_wdt_suspendfunction mtk_wdt_resume
Annotated Snippet
struct mtk_wdt_dev {
struct watchdog_device wdt_dev;
void __iomem *wdt_base;
spinlock_t lock; /* protects WDT_SWSYSRST reg */
struct reset_controller_dev rcdev;
bool disable_wdt_extrst;
bool reset_by_toprgu;
bool has_swsysrst_en;
};
struct mtk_wdt_data {
int toprgu_sw_rst_num;
bool has_swsysrst_en;
};
static const struct mtk_wdt_data mt2712_data = {
.toprgu_sw_rst_num = MT2712_TOPRGU_SW_RST_NUM,
};
static const struct mtk_wdt_data mt6735_data = {
.toprgu_sw_rst_num = MT6735_TOPRGU_RST_NUM,
};
static const struct mtk_wdt_data mt6795_data = {
.toprgu_sw_rst_num = MT6795_TOPRGU_SW_RST_NUM,
};
static const struct mtk_wdt_data mt7986_data = {
.toprgu_sw_rst_num = MT7986_TOPRGU_SW_RST_NUM,
};
static const struct mtk_wdt_data mt7988_data = {
.toprgu_sw_rst_num = MT7988_TOPRGU_SW_RST_NUM,
.has_swsysrst_en = true,
};
static const struct mtk_wdt_data mt8183_data = {
.toprgu_sw_rst_num = MT8183_TOPRGU_SW_RST_NUM,
};
static const struct mtk_wdt_data mt8186_data = {
.toprgu_sw_rst_num = MT8186_TOPRGU_SW_RST_NUM,
};
static const struct mtk_wdt_data mt8188_data = {
.toprgu_sw_rst_num = MT8188_TOPRGU_SW_RST_NUM,
};
static const struct mtk_wdt_data mt8192_data = {
.toprgu_sw_rst_num = MT8192_TOPRGU_SW_RST_NUM,
};
static const struct mtk_wdt_data mt8195_data = {
.toprgu_sw_rst_num = MT8195_TOPRGU_SW_RST_NUM,
};
/**
* toprgu_reset_sw_en_unlocked() - enable/disable software control for reset bit
* @data: Pointer to instance of driver data.
* @id: Bit number identifying the reset to be enabled or disabled.
* @enable: If true, enable software control for that bit, disable otherwise.
*
* Context: The caller must hold lock of struct mtk_wdt_dev.
*/
static void toprgu_reset_sw_en_unlocked(struct mtk_wdt_dev *data,
unsigned long id, bool enable)
{
u32 tmp;
tmp = readl(data->wdt_base + WDT_SWSYSRST_EN);
if (enable)
tmp |= BIT(id);
else
tmp &= ~BIT(id);
writel(tmp, data->wdt_base + WDT_SWSYSRST_EN);
}
static int toprgu_reset_update(struct reset_controller_dev *rcdev,
unsigned long id, bool assert)
{
unsigned int tmp;
unsigned long flags;
struct mtk_wdt_dev *data =
container_of(rcdev, struct mtk_wdt_dev, rcdev);
spin_lock_irqsave(&data->lock, flags);
if (assert && data->has_swsysrst_en)
toprgu_reset_sw_en_unlocked(data, id, true);
Annotation
- Immediate include surface: `dt-bindings/reset/mt2712-resets.h`, `dt-bindings/reset/mediatek,mt6735-wdt.h`, `dt-bindings/reset/mediatek,mt6795-resets.h`, `dt-bindings/reset/mt7986-resets.h`, `dt-bindings/reset/mt8183-resets.h`, `dt-bindings/reset/mt8186-resets.h`, `dt-bindings/reset/mt8188-resets.h`, `dt-bindings/reset/mt8192-resets.h`.
- Detected declarations: `struct mtk_wdt_dev`, `struct mtk_wdt_data`, `function toprgu_reset_sw_en_unlocked`, `function toprgu_reset_update`, `function toprgu_reset_assert`, `function toprgu_reset_deassert`, `function toprgu_reset`, `function toprgu_register_reset_controller`, `function mtk_wdt_restart`, `function mtk_wdt_ping`.
- Atlas domain: Driver Families / drivers/watchdog.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.