Lines Matching +full:wdt +full:- +full:timeout
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Watchdog driver for TS-4800 based boards
5 * Copyright (c) 2015 - Savoir-faire Linux
36 * TS-4800 supports the following timeout values:
39 * ---------------------
45 * Keep the regmap/timeout map ordered by timeout
48 const int timeout; member
55 #define MAX_TIMEOUT_INDEX (ARRAY_SIZE(ts4800_wdt_map) - 1)
57 static void ts4800_write_feed(struct ts4800_wdt *wdt, u32 val) in ts4800_write_feed() argument
59 regmap_write(wdt->regmap, wdt->feed_offset, val); in ts4800_write_feed()
64 struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd); in ts4800_wdt_start() local
66 ts4800_write_feed(wdt, wdt->feed_val); in ts4800_wdt_start()
72 struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd); in ts4800_wdt_stop() local
74 ts4800_write_feed(wdt, TS4800_WDT_DISABLE); in ts4800_wdt_stop()
79 unsigned int timeout) in ts4800_wdt_set_timeout() argument
81 struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd); in ts4800_wdt_set_timeout() local
85 if (ts4800_wdt_map[i].timeout >= timeout) in ts4800_wdt_set_timeout()
89 wdd->timeout = ts4800_wdt_map[i].timeout; in ts4800_wdt_set_timeout()
90 wdt->feed_val = ts4800_wdt_map[i].regval; in ts4800_wdt_set_timeout()
104 .identity = "TS-4800 Watchdog",
109 struct device *dev = &pdev->dev; in ts4800_wdt_probe()
110 struct device_node *np = dev->of_node; in ts4800_wdt_probe()
113 struct ts4800_wdt *wdt; in ts4800_wdt_probe() local
120 return -ENODEV; in ts4800_wdt_probe()
131 wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); in ts4800_wdt_probe()
132 if (!wdt) { in ts4800_wdt_probe()
134 return -ENOMEM; in ts4800_wdt_probe()
138 wdt->feed_offset = reg; in ts4800_wdt_probe()
139 wdt->regmap = syscon_node_to_regmap(syscon_np); in ts4800_wdt_probe()
141 if (IS_ERR(wdt->regmap)) { in ts4800_wdt_probe()
143 return PTR_ERR(wdt->regmap); in ts4800_wdt_probe()
147 wdd = &wdt->wdd; in ts4800_wdt_probe()
148 wdd->parent = dev; in ts4800_wdt_probe()
149 wdd->info = &ts4800_wdt_info; in ts4800_wdt_probe()
150 wdd->ops = &ts4800_wdt_ops; in ts4800_wdt_probe()
151 wdd->min_timeout = ts4800_wdt_map[0].timeout; in ts4800_wdt_probe()
152 wdd->max_timeout = ts4800_wdt_map[MAX_TIMEOUT_INDEX].timeout; in ts4800_wdt_probe()
154 watchdog_set_drvdata(wdd, wdt); in ts4800_wdt_probe()
160 * must be called to initialize timeout and feed_val with valid values. in ts4800_wdt_probe()
161 * Default to maximum timeout if none, or an invalid one, is provided in in ts4800_wdt_probe()
164 if (!wdd->timeout) in ts4800_wdt_probe()
165 wdd->timeout = wdd->max_timeout; in ts4800_wdt_probe()
166 ts4800_wdt_set_timeout(wdd, wdd->timeout); in ts4800_wdt_probe()
169 * The feed register is write-only, so it is not possible to determine in ts4800_wdt_probe()
178 platform_set_drvdata(pdev, wdt); in ts4800_wdt_probe()
180 dev_info(dev, "initialized (timeout = %d sec, nowayout = %d)\n", in ts4800_wdt_probe()
181 wdd->timeout, nowayout); in ts4800_wdt_probe()
187 { .compatible = "technologic,ts4800-wdt", },
203 MODULE_DESCRIPTION("Watchdog driver for TS-4800 based boards");