forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
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>
....@@ -161,7 +152,7 @@
161152 timeleft += readl(gwdt->control_base + SBSA_GWDT_WOR);
162153
163154 timeleft += lo_hi_readq(gwdt->control_base + SBSA_GWDT_WCV) -
164
- arch_counter_get_cntvct();
155
+ arch_timer_read_counter();
165156
166157 do_div(timeleft, gwdt->clk);
167158
....@@ -231,7 +222,6 @@
231222 struct device *dev = &pdev->dev;
232223 struct watchdog_device *wdd;
233224 struct sbsa_gwdt *gwdt;
234
- struct resource *res;
235225 int ret, irq;
236226 u32 status;
237227
....@@ -240,13 +230,11 @@
240230 return -ENOMEM;
241231 platform_set_drvdata(pdev, gwdt);
242232
243
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
244
- cf_base = devm_ioremap_resource(dev, res);
233
+ cf_base = devm_platform_ioremap_resource(pdev, 0);
245234 if (IS_ERR(cf_base))
246235 return PTR_ERR(cf_base);
247236
248
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
249
- rf_base = devm_ioremap_resource(dev, res);
237
+ rf_base = devm_platform_ioremap_resource(pdev, 1);
250238 if (IS_ERR(rf_base))
251239 return PTR_ERR(rf_base);
252240
....@@ -313,29 +301,14 @@
313301 */
314302 sbsa_gwdt_set_timeout(wdd, wdd->timeout);
315303
316
- ret = watchdog_register_device(wdd);
304
+ watchdog_stop_on_reboot(wdd);
305
+ ret = devm_watchdog_register_device(dev, wdd);
317306 if (ret)
318307 return ret;
319308
320309 dev_info(dev, "Initialized with %ds timeout @ %u Hz, action=%d.%s\n",
321310 wdd->timeout, gwdt->clk, action,
322311 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);
339312
340313 return 0;
341314 }
....@@ -385,8 +358,6 @@
385358 .of_match_table = sbsa_gwdt_of_match,
386359 },
387360 .probe = sbsa_gwdt_probe,
388
- .remove = sbsa_gwdt_remove,
389
- .shutdown = sbsa_gwdt_shutdown,
390361 .id_table = sbsa_gwdt_pdev_match,
391362 };
392363