• Home
  • Raw
  • Download

Lines Matching +full:1000 +full:base +full:- +full:t

1 // SPDX-License-Identifier: GPL-2.0
5 * (c) Copyright 2019-2020 Texas Instruments Inc.
25 #define MAX_HEARTBEAT 1000
59 * @base - base io address of WD device
60 * @freq - source clock frequency of WDT
61 * @wdd - hold watchdog device as is in WDT core
64 void __iomem *base; member
75 ret = pm_runtime_resume_and_get(wdd->parent); in rti_wdt_start()
80 timer_margin = (u64)wdd->timeout * wdt->freq; in rti_wdt_start()
84 writel_relaxed(timer_margin, wdt->base + RTIDWDPRLD); in rti_wdt_start()
93 wdd->min_hw_heartbeat_ms = 500 * wdd->timeout; in rti_wdt_start()
96 writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); in rti_wdt_start()
99 writel_relaxed(RTIWWDSIZE_50P, wdt->base + RTIWWDSIZECTRL); in rti_wdt_start()
101 readl_relaxed(wdt->base + RTIWWDSIZECTRL); in rti_wdt_start()
104 writel_relaxed(WDENABLE_KEY, wdt->base + RTIDWDCTRL); in rti_wdt_start()
113 writel_relaxed(WDKEY_SEQ0, wdt->base + RTIWDKEY); in rti_wdt_ping()
115 writel_relaxed(WDKEY_SEQ1, wdt->base + RTIWDKEY); in rti_wdt_ping()
131 wdd->min_hw_heartbeat_ms = 500 * heartbeat; in rti_wdt_setup_hw_hb()
136 wdd->min_hw_heartbeat_ms = 750 * heartbeat; in rti_wdt_setup_hw_hb()
141 wdd->min_hw_heartbeat_ms = 875 * heartbeat; in rti_wdt_setup_hw_hb()
146 wdd->min_hw_heartbeat_ms = 935 * heartbeat; in rti_wdt_setup_hw_hb()
151 wdd->min_hw_heartbeat_ms = 969 * heartbeat; in rti_wdt_setup_hw_hb()
155 return -EINVAL; in rti_wdt_setup_hw_hb()
168 val = readl_relaxed(wdt->base + RTIWDSTATUS); in rti_wdt_get_timeleft_ms()
172 timer_counter = readl_relaxed(wdt->base + RTIDWDCNTR); in rti_wdt_get_timeleft_ms()
174 timer_counter *= 1000; in rti_wdt_get_timeleft_ms()
176 do_div(timer_counter, wdt->freq); in rti_wdt_get_timeleft_ms()
183 return rti_wdt_get_timeleft_ms(wdd) / 1000; in rti_wdt_get_timeleft()
201 struct device *dev = &pdev->dev; in rti_wdt_probe()
210 return -ENOMEM; in rti_wdt_probe()
216 wdt->freq = clk_get_rate(clk); in rti_wdt_probe()
220 if (!wdt->freq) { in rti_wdt_probe()
222 return -EINVAL; in rti_wdt_probe()
227 * Adjust frequency down in this case so that we don't pet in rti_wdt_probe()
230 if (wdt->freq < 32768) in rti_wdt_probe()
231 wdt->freq = wdt->freq * 9 / 10; in rti_wdt_probe()
237 pm_runtime_disable(&pdev->dev); in rti_wdt_probe()
243 wdd = &wdt->wdd; in rti_wdt_probe()
244 wdd->info = &rti_wdt_info; in rti_wdt_probe()
245 wdd->ops = &rti_wdt_ops; in rti_wdt_probe()
246 wdd->min_timeout = 1; in rti_wdt_probe()
247 wdd->max_hw_heartbeat_ms = (WDT_PRELOAD_MAX << WDT_PRELOAD_SHIFT) / in rti_wdt_probe()
248 wdt->freq * 1000; in rti_wdt_probe()
249 wdd->parent = dev; in rti_wdt_probe()
256 wdt->base = devm_ioremap_resource(dev, wdt_mem); in rti_wdt_probe()
257 if (IS_ERR(wdt->base)) { in rti_wdt_probe()
258 ret = PTR_ERR(wdt->base); in rti_wdt_probe()
262 if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) { in rti_wdt_probe()
267 set_bit(WDOG_HW_RUNNING, &wdd->status); in rti_wdt_probe()
269 heartbeat_ms = readl(wdt->base + RTIDWDPRLD); in rti_wdt_probe()
271 heartbeat_ms *= 1000; in rti_wdt_probe()
272 do_div(heartbeat_ms, wdt->freq); in rti_wdt_probe()
273 if (heartbeat_ms != heartbeat * 1000) in rti_wdt_probe()
277 heartbeat /= 1000; in rti_wdt_probe()
279 wsize = readl(wdt->base + RTIWWDSIZECTRL); in rti_wdt_probe()
286 last_ping = heartbeat_ms - time_left_ms; in rti_wdt_probe()
305 pm_runtime_put_sync(&pdev->dev); in rti_wdt_probe()
310 pm_runtime_put_sync(&pdev->dev); in rti_wdt_probe()
311 pm_runtime_disable(&pdev->dev); in rti_wdt_probe()
320 watchdog_unregister_device(&wdt->wdd); in rti_wdt_remove()
322 if (!pm_runtime_suspended(&pdev->dev)) in rti_wdt_remove()
323 pm_runtime_put(&pdev->dev); in rti_wdt_remove()
325 pm_runtime_disable(&pdev->dev); in rti_wdt_remove()
331 { .compatible = "ti,j7-rti-wdt", },
338 .name = "rti-wdt",
347 MODULE_AUTHOR("Tero Kristo <t-kristo@ti.com>");
357 MODULE_ALIAS("platform:rti-wdt");