Lines Matching +full:watchdog +full:- +full:timeout +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-only OR MIT
3 * Apple SoC Watchdog driver
17 #include <linux/watchdog.h>
20 * Apple Watchdog MMIO registers
71 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_start()
72 writel_relaxed(APPLE_WDT_CTRL_RESET_EN, wdt->regs + APPLE_WDT_WD1_CTRL); in apple_wdt_start()
81 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CTRL); in apple_wdt_stop()
90 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_ping()
99 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_set_timeout()
100 writel_relaxed(wdt->clk_rate * s, wdt->regs + APPLE_WDT_WD1_BITE_TIME); in apple_wdt_set_timeout()
102 wdd->timeout = s; in apple_wdt_set_timeout()
112 cur_time = readl_relaxed(wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_get_timeleft()
113 reset_time = readl_relaxed(wdt->regs + APPLE_WDT_WD1_BITE_TIME); in apple_wdt_get_timeleft()
115 return (reset_time - cur_time) / wdt->clk_rate; in apple_wdt_get_timeleft()
123 writel_relaxed(APPLE_WDT_CTRL_RESET_EN, wdt->regs + APPLE_WDT_WD1_CTRL); in apple_wdt_restart()
124 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_BITE_TIME); in apple_wdt_restart()
125 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_restart()
130 * can take up to ~20-25ms until the SoC is actually reset. Just wait in apple_wdt_restart()
131 * 50ms here to be safe. in apple_wdt_restart()
133 (void)readl(wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_restart()
150 .identity = "Apple SoC Watchdog",
156 struct device *dev = &pdev->dev; in apple_wdt_probe()
163 return -ENOMEM; in apple_wdt_probe()
165 wdt->regs = devm_platform_ioremap_resource(pdev, 0); in apple_wdt_probe()
166 if (IS_ERR(wdt->regs)) in apple_wdt_probe()
167 return PTR_ERR(wdt->regs); in apple_wdt_probe()
172 wdt->clk_rate = clk_get_rate(clk); in apple_wdt_probe()
173 if (!wdt->clk_rate) in apple_wdt_probe()
174 return -EINVAL; in apple_wdt_probe()
176 wdt->wdd.ops = &apple_wdt_ops; in apple_wdt_probe()
177 wdt->wdd.info = &apple_wdt_info; in apple_wdt_probe()
178 wdt->wdd.max_timeout = U32_MAX / wdt->clk_rate; in apple_wdt_probe()
179 wdt->wdd.timeout = APPLE_WDT_TIMEOUT_DEFAULT; in apple_wdt_probe()
181 wdt_ctrl = readl_relaxed(wdt->regs + APPLE_WDT_WD1_CTRL); in apple_wdt_probe()
183 set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); in apple_wdt_probe()
185 watchdog_init_timeout(&wdt->wdd, 0, dev); in apple_wdt_probe()
186 apple_wdt_set_timeout(&wdt->wdd, wdt->wdd.timeout); in apple_wdt_probe()
187 watchdog_stop_on_unregister(&wdt->wdd); in apple_wdt_probe()
188 watchdog_set_restart_priority(&wdt->wdd, 128); in apple_wdt_probe()
190 return devm_watchdog_register_device(dev, &wdt->wdd); in apple_wdt_probe()
201 .name = "apple-watchdog",
208 MODULE_DESCRIPTION("Apple SoC watchdog driver");