Lines Matching +full:jz4740 +full:- +full:watchdog
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * JZ4740 Watchdog driver
7 #include <linux/mfd/ingenic-tcu.h>
13 #include <linux/watchdog.h>
29 "Watchdog cannot be stopped once started (default="
35 "Watchdog heartbeat period in seconds from 1 to "
50 regmap_write(drvdata->map, TCU_REG_WDT_TCNT, 0); in jz4740_wdt_ping()
59 u16 timeout_value = (u16)(drvdata->clk_rate * new_timeout); in jz4740_wdt_set_timeout()
62 regmap_read(drvdata->map, TCU_REG_WDT_TCER, &tcer); in jz4740_wdt_set_timeout()
63 regmap_write(drvdata->map, TCU_REG_WDT_TCER, 0); in jz4740_wdt_set_timeout()
65 regmap_write(drvdata->map, TCU_REG_WDT_TDR, timeout_value); in jz4740_wdt_set_timeout()
66 regmap_write(drvdata->map, TCU_REG_WDT_TCNT, 0); in jz4740_wdt_set_timeout()
69 regmap_write(drvdata->map, TCU_REG_WDT_TCER, TCU_WDT_TCER_TCEN); in jz4740_wdt_set_timeout()
71 wdt_dev->timeout = new_timeout; in jz4740_wdt_set_timeout()
81 ret = clk_prepare_enable(drvdata->clk); in jz4740_wdt_start()
85 regmap_read(drvdata->map, TCU_REG_WDT_TCER, &tcer); in jz4740_wdt_start()
87 jz4740_wdt_set_timeout(wdt_dev, wdt_dev->timeout); in jz4740_wdt_start()
89 /* Start watchdog if it wasn't started already */ in jz4740_wdt_start()
91 regmap_write(drvdata->map, TCU_REG_WDT_TCER, TCU_WDT_TCER_TCEN); in jz4740_wdt_start()
100 regmap_write(drvdata->map, TCU_REG_WDT_TCER, 0); in jz4740_wdt_stop()
101 clk_disable_unprepare(drvdata->clk); in jz4740_wdt_stop()
109 wdt_dev->timeout = 0; in jz4740_wdt_restart()
116 .identity = "jz4740 Watchdog",
130 { .compatible = "ingenic,jz4740-watchdog", },
131 { .compatible = "ingenic,jz4780-watchdog", },
139 struct device *dev = &pdev->dev; in jz4740_wdt_probe()
148 return -ENOMEM; in jz4740_wdt_probe()
150 drvdata->clk = devm_clk_get(&pdev->dev, "wdt"); in jz4740_wdt_probe()
151 if (IS_ERR(drvdata->clk)) { in jz4740_wdt_probe()
152 dev_err(&pdev->dev, "cannot find WDT clock\n"); in jz4740_wdt_probe()
153 return PTR_ERR(drvdata->clk); in jz4740_wdt_probe()
157 rate = clk_round_rate(drvdata->clk, 1); in jz4740_wdt_probe()
161 ret = clk_set_rate(drvdata->clk, rate); in jz4740_wdt_probe()
165 drvdata->clk_rate = rate; in jz4740_wdt_probe()
166 jz4740_wdt = &drvdata->wdt; in jz4740_wdt_probe()
167 jz4740_wdt->info = &jz4740_wdt_info; in jz4740_wdt_probe()
168 jz4740_wdt->ops = &jz4740_wdt_ops; in jz4740_wdt_probe()
169 jz4740_wdt->min_timeout = 1; in jz4740_wdt_probe()
170 jz4740_wdt->max_timeout = 0xffff / rate; in jz4740_wdt_probe()
171 jz4740_wdt->timeout = clamp(heartbeat, in jz4740_wdt_probe()
172 jz4740_wdt->min_timeout, in jz4740_wdt_probe()
173 jz4740_wdt->max_timeout); in jz4740_wdt_probe()
174 jz4740_wdt->parent = dev; in jz4740_wdt_probe()
178 drvdata->map = device_node_to_regmap(dev->parent->of_node); in jz4740_wdt_probe()
179 if (!drvdata->map) { in jz4740_wdt_probe()
181 return -EINVAL; in jz4740_wdt_probe()
184 return devm_watchdog_register_device(dev, &drvdata->wdt); in jz4740_wdt_probe()
190 .name = "jz4740-wdt",
198 MODULE_DESCRIPTION("jz4740 Watchdog Driver");
200 MODULE_ALIAS("platform:jz4740-wdt");