Lines Matching +full:hw +full:- +full:timeout +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-only OR MIT
22 * This HW block has three separate watchdogs. WD0 resets the machine
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()
100 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_set_timeout()
102 actual = min(s, wdd->max_hw_heartbeat_ms / 1000); in apple_wdt_set_timeout()
103 writel_relaxed(wdt->clk_rate * actual, wdt->regs + APPLE_WDT_WD1_BITE_TIME); in apple_wdt_set_timeout()
105 wdd->timeout = s; in apple_wdt_set_timeout()
115 cur_time = readl_relaxed(wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_get_timeleft()
116 reset_time = readl_relaxed(wdt->regs + APPLE_WDT_WD1_BITE_TIME); in apple_wdt_get_timeleft()
118 return (reset_time - cur_time) / wdt->clk_rate; in apple_wdt_get_timeleft()
126 writel_relaxed(APPLE_WDT_CTRL_RESET_EN, wdt->regs + APPLE_WDT_WD1_CTRL); in apple_wdt_restart()
127 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_BITE_TIME); in apple_wdt_restart()
128 writel_relaxed(0, wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_restart()
133 * can take up to ~120-125ms until the SoC is actually reset. Just in apple_wdt_restart()
134 * wait 150ms here to be safe. in apple_wdt_restart()
136 (void)readl(wdt->regs + APPLE_WDT_WD1_CUR_TIME); in apple_wdt_restart()
159 struct device *dev = &pdev->dev; in apple_wdt_probe()
166 return -ENOMEM; in apple_wdt_probe()
168 wdt->regs = devm_platform_ioremap_resource(pdev, 0); in apple_wdt_probe()
169 if (IS_ERR(wdt->regs)) in apple_wdt_probe()
170 return PTR_ERR(wdt->regs); in apple_wdt_probe()
175 wdt->clk_rate = clk_get_rate(clk); in apple_wdt_probe()
176 if (!wdt->clk_rate) in apple_wdt_probe()
177 return -EINVAL; in apple_wdt_probe()
181 wdt->wdd.ops = &apple_wdt_ops; in apple_wdt_probe()
182 wdt->wdd.info = &apple_wdt_info; in apple_wdt_probe()
183 wdt->wdd.max_hw_heartbeat_ms = U32_MAX / wdt->clk_rate * 1000; in apple_wdt_probe()
184 wdt->wdd.timeout = APPLE_WDT_TIMEOUT_DEFAULT; in apple_wdt_probe()
186 wdt_ctrl = readl_relaxed(wdt->regs + APPLE_WDT_WD1_CTRL); in apple_wdt_probe()
188 set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); in apple_wdt_probe()
190 watchdog_init_timeout(&wdt->wdd, 0, dev); in apple_wdt_probe()
191 apple_wdt_set_timeout(&wdt->wdd, wdt->wdd.timeout); in apple_wdt_probe()
192 watchdog_stop_on_unregister(&wdt->wdd); in apple_wdt_probe()
193 watchdog_set_restart_priority(&wdt->wdd, 128); in apple_wdt_probe()
195 return devm_watchdog_register_device(dev, &wdt->wdd); in apple_wdt_probe()
202 if (watchdog_active(&wdt->wdd) || watchdog_hw_running(&wdt->wdd)) in apple_wdt_resume()
203 apple_wdt_start(&wdt->wdd); in apple_wdt_resume()
212 if (watchdog_active(&wdt->wdd) || watchdog_hw_running(&wdt->wdd)) in apple_wdt_suspend()
213 apple_wdt_stop(&wdt->wdd); in apple_wdt_suspend()
228 .name = "apple-watchdog",