hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/watchdog/sbsa_gwdt.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * SBSA(Server Base System Architecture) Generic Watchdog driver
34 *
....@@ -6,15 +7,6 @@
67 * Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
78 * Al Stone <al.stone@linaro.org>
89 * Timur Tabi <timur@codeaurora.org>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License 2 as published
12
- * by the Free Software Foundation.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
1810 *
1911 * ARM SBSA Generic Watchdog has two stage timeouts:
2012 * the first signal (WS0) is for alerting the system by interrupt,
....@@ -46,7 +38,6 @@
4638 * by WOR, in the single stage mode, the timeout is (WOR * 2); in the two
4739 * stages mode, the timeout is WOR. The maximum timeout in the two stages mode
4840 * is half of that in the single stage mode.
49
- *
5041 */
5142
5243 #include <linux/io.h>
....@@ -130,6 +121,7 @@
130121 struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd);
131122
132123 wdd->timeout = timeout;
124
+ timeout = clamp_t(unsigned int, timeout, 1, wdd->max_hw_heartbeat_ms / 1000);
133125
134126 if (action)
135127 writel(gwdt->clk * timeout,
....@@ -161,7 +153,7 @@
161153 timeleft += readl(gwdt->control_base + SBSA_GWDT_WOR);
162154
163155 timeleft += lo_hi_readq(gwdt->control_base + SBSA_GWDT_WCV) -
164
- arch_counter_get_cntvct();
156
+ arch_timer_read_counter();
165157
166158 do_div(timeleft, gwdt->clk);
167159
....@@ -231,7 +223,6 @@
231223 struct device *dev = &pdev->dev;
232224 struct watchdog_device *wdd;
233225 struct sbsa_gwdt *gwdt;
234
- struct resource *res;
235226 int ret, irq;
236227 u32 status;
237228
....@@ -240,13 +231,11 @@
240231 return -ENOMEM;
241232 platform_set_drvdata(pdev, gwdt);
242233
243
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
244
- cf_base = devm_ioremap_resource(dev, res);
234
+ cf_base = devm_platform_ioremap_resource(pdev, 0);
245235 if (IS_ERR(cf_base))
246236 return PTR_ERR(cf_base);
247237
248
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
249
- rf_base = devm_ioremap_resource(dev, res);
238
+ rf_base = devm_platform_ioremap_resource(pdev, 1);
250239 if (IS_ERR(rf_base))
251240 return PTR_ERR(rf_base);
252241
....@@ -313,29 +302,14 @@
313302 */
314303 sbsa_gwdt_set_timeout(wdd, wdd->timeout);
315304
316
- ret = watchdog_register_device(wdd);
305
+ watchdog_stop_on_reboot(wdd);
306
+ ret = devm_watchdog_register_device(dev, wdd);
317307 if (ret)
318308 return ret;
319309
320310 dev_info(dev, "Initialized with %ds timeout @ %u Hz, action=%d.%s\n",
321311 wdd->timeout, gwdt->clk, action,
322312 status & SBSA_GWDT_WCS_EN ? " [enabled]" : "");
323
-
324
- return 0;
325
-}
326
-
327
-static void sbsa_gwdt_shutdown(struct platform_device *pdev)
328
-{
329
- struct sbsa_gwdt *gwdt = platform_get_drvdata(pdev);
330
-
331
- sbsa_gwdt_stop(&gwdt->wdd);
332
-}
333
-
334
-static int sbsa_gwdt_remove(struct platform_device *pdev)
335
-{
336
- struct sbsa_gwdt *gwdt = platform_get_drvdata(pdev);
337
-
338
- watchdog_unregister_device(&gwdt->wdd);
339313
340314 return 0;
341315 }
....@@ -385,8 +359,6 @@
385359 .of_match_table = sbsa_gwdt_of_match,
386360 },
387361 .probe = sbsa_gwdt_probe,
388
- .remove = sbsa_gwdt_remove,
389
- .shutdown = sbsa_gwdt_shutdown,
390362 .id_table = sbsa_gwdt_pdev_match,
391363 };
392364