Skip to content

Commit 5602b0a

Browse files
committed
Merge tag 'linux-watchdog-5.7-rc1' of git://www.linux-watchdog.org/linux-watchdog
Pull watchdog updates from Wim Van Sebroeck: - add TI K3 RTI watchdog - add stop_on_reboot parameter to control reboot policy - wm831x_wdt: Remove GPIO handling - several small fixes, improvements and clean-ups * tag 'linux-watchdog-5.7-rc1' of git://www.linux-watchdog.org/linux-watchdog: watchdog: Add K3 RTI watchdog support dt-bindings: watchdog: Add support for TI K3 RTI watchdog watchdog: ziirave_wdt: change name to be more specific watchdog: orion: use 0 for unset heartbeat watchdog: npcm: remove whitespaces watchdog: reset last_hw_keepalive time at start watchdog: imx2_wdt: Drop .remove callback watchdog: Add stop_on_reboot parameter to control reboot policy watchdog: wm831x_wdt: Remove GPIO handling watchdog: imx7ulp: Remove unused include of init.h watchdog: imx_sc_wdt: Remove unused includes watchdog: qcom: Use irq flags from firmware watchdog: pm8916_wdt: Add system sleep callbacks watchdog: qcom-wdt: disable pretimeout on timer platform
2 parents 413a103 + 2d63908 commit 5602b0a

File tree

16 files changed

+412
-80
lines changed

16 files changed

+412
-80
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/watchdog/ti,rti-wdt.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Texas Instruments K3 SoC Watchdog Timer
8+
9+
maintainers:
10+
- Tero Kristo <[email protected]>
11+
12+
description:
13+
The TI K3 SoC watchdog timer is implemented via the RTI (Real Time
14+
Interrupt) IP module. This timer adds a support for windowed watchdog
15+
mode, which will signal an error if it is pinged outside the watchdog
16+
time window, meaning either too early or too late. The error signal
17+
generated can be routed to either interrupt a safety controller or
18+
to directly reset the SoC.
19+
20+
allOf:
21+
- $ref: "watchdog.yaml#"
22+
23+
properties:
24+
compatible:
25+
enum:
26+
- ti,j7-rti-wdt
27+
28+
reg:
29+
maxItems: 1
30+
31+
clocks:
32+
maxItems: 1
33+
34+
power-domains:
35+
maxItems: 1
36+
37+
assigned-clocks:
38+
maxItems: 1
39+
40+
assigned-clocks-parents:
41+
maxItems: 1
42+
43+
required:
44+
- compatible
45+
- reg
46+
- clocks
47+
- power-domains
48+
49+
examples:
50+
- |
51+
/*
52+
* RTI WDT in main domain on J721e SoC. Assigned clocks are used to
53+
* select the source clock for the watchdog, forcing it to tick with
54+
* a 32kHz clock in this case.
55+
*/
56+
#include <dt-bindings/soc/ti,sci_pm_domain.h>
57+
58+
watchdog0: rti@2200000 {
59+
compatible = "ti,rti-wdt";
60+
reg = <0x0 0x2200000 0x0 0x100>;
61+
clocks = <&k3_clks 252 1>;
62+
power-domains = <&k3_pds 252 TI_SCI_PD_EXCLUSIVE>;
63+
assigned-clocks = <&k3_clks 252 1>;
64+
assigned-clock-parents = <&k3_clks 252 5>;
65+
};

drivers/watchdog/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,14 @@ config DAVINCI_WATCHDOG
584584
NOTE: once enabled, this timer cannot be disabled.
585585
Say N if you are unsure.
586586

587+
config K3_RTI_WATCHDOG
588+
tristate "Texas Instruments K3 RTI watchdog"
589+
depends on ARCH_K3 || COMPILE_TEST
590+
select WATCHDOG_CORE
591+
help
592+
Say Y here if you want to include support for the K3 watchdog
593+
timer (RTI module) available in the K3 generation of processors.
594+
587595
config ORION_WATCHDOG
588596
tristate "Orion watchdog"
589597
depends on ARCH_ORION5X || ARCH_DOVE || MACH_DOVE || ARCH_MVEBU || (COMPILE_TEST && !ARCH_EBSA110)

drivers/watchdog/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
5757
obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
5858
obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o
5959
obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o
60+
obj-$(CONFIG_K3_RTI_WATCHDOG) += rti_wdt.o
6061
obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o
6162
obj-$(CONFIG_SUNXI_WATCHDOG) += sunxi_wdt.o
6263
obj-$(CONFIG_RN5T618_WATCHDOG) += rn5t618_wdt.o

drivers/watchdog/imx2_wdt.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = {
244244
.max_register = 0x8,
245245
};
246246

247+
static void imx2_wdt_action(void *data)
248+
{
249+
clk_disable_unprepare(data);
250+
}
251+
247252
static int __init imx2_wdt_probe(struct platform_device *pdev)
248253
{
249254
struct device *dev = &pdev->dev;
@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
292297
if (ret)
293298
return ret;
294299

300+
ret = devm_add_action_or_reset(dev, imx2_wdt_action, wdev->clk);
301+
if (ret)
302+
return ret;
303+
295304
regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val);
296305
wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
297306

@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
315324
*/
316325
regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0);
317326

318-
ret = watchdog_register_device(wdog);
319-
if (ret)
320-
goto disable_clk;
321-
322-
dev_info(dev, "timeout %d sec (nowayout=%d)\n",
323-
wdog->timeout, nowayout);
324-
325-
return 0;
326-
327-
disable_clk:
328-
clk_disable_unprepare(wdev->clk);
329-
return ret;
330-
}
331-
332-
static int __exit imx2_wdt_remove(struct platform_device *pdev)
333-
{
334-
struct watchdog_device *wdog = platform_get_drvdata(pdev);
335-
struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
336-
337-
watchdog_unregister_device(wdog);
338-
339-
if (imx2_wdt_is_running(wdev)) {
340-
imx2_wdt_ping(wdog);
341-
dev_crit(&pdev->dev, "Device removed: Expect reboot!\n");
342-
}
343-
return 0;
327+
return devm_watchdog_register_device(dev, wdog);
344328
}
345329

346330
static void imx2_wdt_shutdown(struct platform_device *pdev)
@@ -417,7 +401,6 @@ static const struct of_device_id imx2_wdt_dt_ids[] = {
417401
MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids);
418402

419403
static struct platform_driver imx2_wdt_driver = {
420-
.remove = __exit_p(imx2_wdt_remove),
421404
.shutdown = imx2_wdt_shutdown,
422405
.driver = {
423406
.name = DRIVER_NAME,

drivers/watchdog/imx7ulp_wdt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
#include <linux/clk.h>
7-
#include <linux/init.h>
87
#include <linux/io.h>
98
#include <linux/kernel.h>
109
#include <linux/module.h>

drivers/watchdog/imx_sc_wdt.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
#include <linux/arm-smccc.h>
77
#include <linux/firmware/imx/sci.h>
88
#include <linux/io.h>
9-
#include <linux/init.h>
109
#include <linux/kernel.h>
1110
#include <linux/module.h>
1211
#include <linux/moduleparam.h>
1312
#include <linux/of.h>
1413
#include <linux/platform_device.h>
15-
#include <linux/reboot.h>
1614
#include <linux/watchdog.h>
1715

1816
#define DEFAULT_TIMEOUT 60

drivers/watchdog/npcm_wdt.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,30 +103,29 @@ static int npcm_wdt_stop(struct watchdog_device *wdd)
103103
return 0;
104104
}
105105

106-
107106
static int npcm_wdt_set_timeout(struct watchdog_device *wdd,
108107
unsigned int timeout)
109108
{
110109
if (timeout < 2)
111110
wdd->timeout = 1;
112111
else if (timeout < 3)
113-
wdd->timeout = 2;
112+
wdd->timeout = 2;
114113
else if (timeout < 6)
115-
wdd->timeout = 5;
114+
wdd->timeout = 5;
116115
else if (timeout < 11)
117-
wdd->timeout = 10;
116+
wdd->timeout = 10;
118117
else if (timeout < 22)
119-
wdd->timeout = 21;
118+
wdd->timeout = 21;
120119
else if (timeout < 44)
121-
wdd->timeout = 43;
120+
wdd->timeout = 43;
122121
else if (timeout < 87)
123-
wdd->timeout = 86;
122+
wdd->timeout = 86;
124123
else if (timeout < 173)
125-
wdd->timeout = 172;
124+
wdd->timeout = 172;
126125
else if (timeout < 688)
127-
wdd->timeout = 687;
126+
wdd->timeout = 687;
128127
else
129-
wdd->timeout = 2750;
128+
wdd->timeout = 2750;
130129

131130
if (watchdog_active(wdd))
132131
npcm_wdt_start(wdd);

drivers/watchdog/orion_wdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#define WDT_A370_RATIO (1 << WDT_A370_RATIO_SHIFT)
5353

5454
static bool nowayout = WATCHDOG_NOWAYOUT;
55-
static int heartbeat = -1; /* module parameter (seconds) */
55+
static int heartbeat; /* module parameter (seconds) */
5656

5757
struct orion_watchdog;
5858

drivers/watchdog/pm8916_wdt.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,37 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
192192
wdt->wdev.timeout = PM8916_WDT_DEFAULT_TIMEOUT;
193193
wdt->wdev.pretimeout = 0;
194194
watchdog_set_drvdata(&wdt->wdev, wdt);
195+
platform_set_drvdata(pdev, wdt);
195196

196197
watchdog_init_timeout(&wdt->wdev, 0, dev);
197198
pm8916_wdt_configure_timers(&wdt->wdev);
198199

199200
return devm_watchdog_register_device(dev, &wdt->wdev);
200201
}
201202

203+
static int __maybe_unused pm8916_wdt_suspend(struct device *dev)
204+
{
205+
struct pm8916_wdt *wdt = dev_get_drvdata(dev);
206+
207+
if (watchdog_active(&wdt->wdev))
208+
return pm8916_wdt_stop(&wdt->wdev);
209+
210+
return 0;
211+
}
212+
213+
static int __maybe_unused pm8916_wdt_resume(struct device *dev)
214+
{
215+
struct pm8916_wdt *wdt = dev_get_drvdata(dev);
216+
217+
if (watchdog_active(&wdt->wdev))
218+
return pm8916_wdt_start(&wdt->wdev);
219+
220+
return 0;
221+
}
222+
223+
static SIMPLE_DEV_PM_OPS(pm8916_wdt_pm_ops, pm8916_wdt_suspend,
224+
pm8916_wdt_resume);
225+
202226
static const struct of_device_id pm8916_wdt_id_table[] = {
203227
{ .compatible = "qcom,pm8916-wdt" },
204228
{ }
@@ -210,6 +234,7 @@ static struct platform_driver pm8916_wdt_driver = {
210234
.driver = {
211235
.name = "pm8916-wdt",
212236
.of_match_table = of_match_ptr(pm8916_wdt_id_table),
237+
.pm = &pm8916_wdt_pm_ops,
213238
},
214239
};
215240
module_platform_driver(pm8916_wdt_driver);

drivers/watchdog/qcom-wdt.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ static const u32 reg_offset_data_kpss[] = {
4040
[WDT_BITE_TIME] = 0x14,
4141
};
4242

43+
struct qcom_wdt_match_data {
44+
const u32 *offset;
45+
bool pretimeout;
46+
};
47+
4348
struct qcom_wdt {
4449
struct watchdog_device wdd;
4550
unsigned long rate;
@@ -179,19 +184,29 @@ static void qcom_clk_disable_unprepare(void *data)
179184
clk_disable_unprepare(data);
180185
}
181186

187+
static const struct qcom_wdt_match_data match_data_apcs_tmr = {
188+
.offset = reg_offset_data_apcs_tmr,
189+
.pretimeout = false,
190+
};
191+
192+
static const struct qcom_wdt_match_data match_data_kpss = {
193+
.offset = reg_offset_data_kpss,
194+
.pretimeout = true,
195+
};
196+
182197
static int qcom_wdt_probe(struct platform_device *pdev)
183198
{
184199
struct device *dev = &pdev->dev;
185200
struct qcom_wdt *wdt;
186201
struct resource *res;
187202
struct device_node *np = dev->of_node;
188-
const u32 *regs;
203+
const struct qcom_wdt_match_data *data;
189204
u32 percpu_offset;
190205
int irq, ret;
191206
struct clk *clk;
192207

193-
regs = of_device_get_match_data(dev);
194-
if (!regs) {
208+
data = of_device_get_match_data(dev);
209+
if (!data) {
195210
dev_err(dev, "Unsupported QCOM WDT module\n");
196211
return -ENODEV;
197212
}
@@ -247,9 +262,8 @@ static int qcom_wdt_probe(struct platform_device *pdev)
247262

248263
/* check if there is pretimeout support */
249264
irq = platform_get_irq_optional(pdev, 0);
250-
if (irq > 0) {
251-
ret = devm_request_irq(dev, irq, qcom_wdt_isr,
252-
IRQF_TRIGGER_RISING,
265+
if (data->pretimeout && irq > 0) {
266+
ret = devm_request_irq(dev, irq, qcom_wdt_isr, 0,
253267
"wdt_bark", &wdt->wdd);
254268
if (ret)
255269
return ret;
@@ -267,7 +281,7 @@ static int qcom_wdt_probe(struct platform_device *pdev)
267281
wdt->wdd.min_timeout = 1;
268282
wdt->wdd.max_timeout = 0x10000000U / wdt->rate;
269283
wdt->wdd.parent = dev;
270-
wdt->layout = regs;
284+
wdt->layout = data->offset;
271285

272286
if (readl(wdt_addr(wdt, WDT_STS)) & 1)
273287
wdt->wdd.bootstatus = WDIOF_CARDRESET;
@@ -311,9 +325,9 @@ static int __maybe_unused qcom_wdt_resume(struct device *dev)
311325
static SIMPLE_DEV_PM_OPS(qcom_wdt_pm_ops, qcom_wdt_suspend, qcom_wdt_resume);
312326

313327
static const struct of_device_id qcom_wdt_of_table[] = {
314-
{ .compatible = "qcom,kpss-timer", .data = reg_offset_data_apcs_tmr },
315-
{ .compatible = "qcom,scss-timer", .data = reg_offset_data_apcs_tmr },
316-
{ .compatible = "qcom,kpss-wdt", .data = reg_offset_data_kpss },
328+
{ .compatible = "qcom,kpss-timer", .data = &match_data_apcs_tmr },
329+
{ .compatible = "qcom,scss-timer", .data = &match_data_apcs_tmr },
330+
{ .compatible = "qcom,kpss-wdt", .data = &match_data_kpss },
317331
{ },
318332
};
319333
MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);

0 commit comments

Comments
 (0)