Lines Matching +full:wdt +full:- +full:enable +full:- +full:once
1 // SPDX-License-Identifier: GPL-2.0
7 * Copyright (C) 2006-2013 Texas Instruments.
24 #define MODULE_NAME "DAVINCI-WDT: "
59 * struct to hold data for each WDT device
60 * @base - base io address of WD device
61 * @clk - source clock of WDT
62 * @wdd - hold watchdog device as is in WDT core
77 wdt_freq = clk_get_rate(davinci_wdt->clk); in davinci_wdt_start()
80 iowrite32(0, davinci_wdt->base + TCR); in davinci_wdt_start()
81 /* reset timer, set mode to 64-bit watchdog, and unreset */ in davinci_wdt_start()
82 iowrite32(0, davinci_wdt->base + TGCR); in davinci_wdt_start()
84 iowrite32(tgcr, davinci_wdt->base + TGCR); in davinci_wdt_start()
86 iowrite32(0, davinci_wdt->base + TIM12); in davinci_wdt_start()
87 iowrite32(0, davinci_wdt->base + TIM34); in davinci_wdt_start()
89 timer_margin = (((u64)wdd->timeout * wdt_freq) & 0xffffffff); in davinci_wdt_start()
90 iowrite32(timer_margin, davinci_wdt->base + PRD12); in davinci_wdt_start()
91 timer_margin = (((u64)wdd->timeout * wdt_freq) >> 32); in davinci_wdt_start()
92 iowrite32(timer_margin, davinci_wdt->base + PRD34); in davinci_wdt_start()
93 /* enable run continuously */ in davinci_wdt_start()
94 iowrite32(ENAMODE12_PERIODIC, davinci_wdt->base + TCR); in davinci_wdt_start()
95 /* Once the WDT is in pre-active state write to in davinci_wdt_start()
99 /* put watchdog in pre-active state */ in davinci_wdt_start()
100 iowrite32(WDKEY_SEQ0 | WDEN, davinci_wdt->base + WDTCR); in davinci_wdt_start()
102 iowrite32(WDKEY_SEQ1 | WDEN, davinci_wdt->base + WDTCR); in davinci_wdt_start()
111 iowrite32(WDKEY_SEQ0, davinci_wdt->base + WDTCR); in davinci_wdt_ping()
113 iowrite32(WDKEY_SEQ1, davinci_wdt->base + WDTCR); in davinci_wdt_ping()
125 val = ioread32(davinci_wdt->base + WDTCR); in davinci_wdt_get_timeleft()
129 freq = clk_get_rate(davinci_wdt->clk); in davinci_wdt_get_timeleft()
134 timer_counter = ioread32(davinci_wdt->base + TIM12); in davinci_wdt_get_timeleft()
135 timer_counter |= ((u64)ioread32(davinci_wdt->base + TIM34) << 32); in davinci_wdt_get_timeleft()
139 return wdd->timeout - timer_counter; in davinci_wdt_get_timeleft()
149 iowrite32(0, davinci_wdt->base + TCR); in davinci_wdt_restart()
151 /* reset timer, set mode to 64-bit watchdog, and unreset */ in davinci_wdt_restart()
153 iowrite32(tgcr, davinci_wdt->base + TGCR); in davinci_wdt_restart()
155 iowrite32(tgcr, davinci_wdt->base + TGCR); in davinci_wdt_restart()
158 iowrite32(0, davinci_wdt->base + TIM12); in davinci_wdt_restart()
159 iowrite32(0, davinci_wdt->base + TIM34); in davinci_wdt_restart()
160 iowrite32(0, davinci_wdt->base + PRD12); in davinci_wdt_restart()
161 iowrite32(0, davinci_wdt->base + PRD34); in davinci_wdt_restart()
163 /* put watchdog in pre-active state */ in davinci_wdt_restart()
165 iowrite32(wdtcr, davinci_wdt->base + WDTCR); in davinci_wdt_restart()
169 iowrite32(wdtcr, davinci_wdt->base + WDTCR); in davinci_wdt_restart()
173 iowrite32(wdtcr, davinci_wdt->base + WDTCR); in davinci_wdt_restart()
194 struct device *dev = &pdev->dev; in davinci_wdt_probe()
200 return -ENOMEM; in davinci_wdt_probe()
202 davinci_wdt->clk = devm_clk_get_enabled(dev, NULL); in davinci_wdt_probe()
203 if (IS_ERR(davinci_wdt->clk)) in davinci_wdt_probe()
204 return dev_err_probe(dev, PTR_ERR(davinci_wdt->clk), in davinci_wdt_probe()
209 wdd = &davinci_wdt->wdd; in davinci_wdt_probe()
210 wdd->info = &davinci_wdt_info; in davinci_wdt_probe()
211 wdd->ops = &davinci_wdt_ops; in davinci_wdt_probe()
212 wdd->min_timeout = 1; in davinci_wdt_probe()
213 wdd->max_timeout = MAX_HEARTBEAT; in davinci_wdt_probe()
214 wdd->timeout = DEFAULT_HEARTBEAT; in davinci_wdt_probe()
215 wdd->parent = dev; in davinci_wdt_probe()
219 dev_info(dev, "heartbeat %d sec\n", wdd->timeout); in davinci_wdt_probe()
225 davinci_wdt->base = devm_platform_ioremap_resource(pdev, 0); in davinci_wdt_probe()
226 if (IS_ERR(davinci_wdt->base)) in davinci_wdt_probe()
227 return PTR_ERR(davinci_wdt->base); in davinci_wdt_probe()
233 { .compatible = "ti,davinci-wdt", },
240 .name = "davinci-wdt",
258 MODULE_ALIAS("platform:davinci-wdt");