Skip to content

Commit 4a08fe5

Browse files
committed
Merge tag 'linux-watchdog-5.5-rc1' of git://www.linux-watchdog.org/linux-watchdog
Pull watchdog updates from Wim Van Sebroeck: - support for NCT6116D - several small fixes and improvements * tag 'linux-watchdog-5.5-rc1' of git://www.linux-watchdog.org/linux-watchdog: (24 commits) watchdog: jz4740: Drop dependency on MACH_JZ47xx watchdog: jz4740: Use regmap provided by TCU driver watchdog: jz4740: Use WDT clock provided by TCU driver dt-bindings: watchdog: sama5d4_wdt: add microchip,sam9x60-wdt compatible watchdog: sama5d4_wdt: cleanup the bit definitions watchdog: sprd: Fix the incorrect pointer getting from driver data watchdog: aspeed: Fix clock behaviour for ast2600 watchdog: imx7ulp: Fix reboot hang watchdog: make nowayout sysfs file writable watchdog: prevent deferral of watchdogd wakeup on RT watchdog: imx7ulp: Use definitions instead of magic values watchdog: imx7ulp: Remove inline annotations watchdog: imx7ulp: Remove unused structure member watchdog: imx7ulp: Pass the wdog instance inimx7ulp_wdt_enable() watchdog: wdat_wdt: Spelling s/configrable/configurable/ watchdog: bd70528: Trivial function documentation fix watchdog: cadence: Do not show error in case of deferred probe watchdog: Fix the race between the release of watchdog_core_data and cdev watchdog: sbc7240_wdt: Fix yet another -Wimplicit-fallthrough warning watchdog: intel-mid_wdt: Add WATCHDOG_NOWAYOUT support ...
2 parents 99a0d9f + 33c26ab commit 4a08fe5

File tree

16 files changed

+214
-169
lines changed

16 files changed

+214
-169
lines changed

Documentation/ABI/testing/sysfs-class-watchdog

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ What: /sys/class/watchdog/watchdogn/nowayout
1717
Date: August 2015
1818
Contact: Wim Van Sebroeck <[email protected]>
1919
Description:
20-
It is a read only file. While reading, it gives '1' if that
21-
device supports nowayout feature else, it gives '0'.
20+
It is a read/write file. While reading, it gives '1'
21+
if the device has the nowayout feature set, otherwise
22+
it gives '0'. Writing a '1' to the file enables the
23+
nowayout feature. Once set, the nowayout feature
24+
cannot be disabled, so writing a '0' either has no
25+
effect (if the feature was already disabled) or
26+
results in a permission error.
2227

2328
What: /sys/class/watchdog/watchdogn/state
2429
Date: August 2015

Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
* Atmel SAMA5D4 Watchdog Timer (WDT) Controller
22

33
Required properties:
4-
- compatible: "atmel,sama5d4-wdt"
4+
- compatible: "atmel,sama5d4-wdt" or "microchip,sam9x60-wdt"
55
- reg: base physical address and length of memory mapped region.
66

77
Optional properties:

drivers/watchdog/Kconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,7 @@ config W83627HF_WDT
14851485
NCT6791
14861486
NCT6792
14871487
NCT6102D/04D/06D
1488+
NCT6116D
14881489

14891490
This watchdog simply watches your kernel to make sure it doesn't
14901491
freeze, and if it does, it reboots your computer after a certain
@@ -1641,8 +1642,10 @@ config INDYDOG
16411642

16421643
config JZ4740_WDT
16431644
tristate "Ingenic jz4740 SoC hardware watchdog"
1644-
depends on MACH_JZ4740 || MACH_JZ4780
1645+
depends on MIPS
1646+
depends on COMMON_CLK
16451647
select WATCHDOG_CORE
1648+
select MFD_SYSCON
16461649
help
16471650
Hardware driver for the built-in watchdog timer on Ingenic jz4740 SoCs.
16481651

drivers/watchdog/aspeed_wdt.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,6 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
258258
if (IS_ERR(wdt->base))
259259
return PTR_ERR(wdt->base);
260260

261-
/*
262-
* The ast2400 wdt can run at PCLK, or 1MHz. The ast2500 only
263-
* runs at 1MHz. We chose to always run at 1MHz, as there's no
264-
* good reason to have a faster watchdog counter.
265-
*/
266261
wdt->wdd.info = &aspeed_wdt_info;
267262
wdt->wdd.ops = &aspeed_wdt_ops;
268263
wdt->wdd.max_hw_heartbeat_ms = WDT_MAX_TIMEOUT_MS;
@@ -278,7 +273,16 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
278273
return -EINVAL;
279274
config = ofdid->data;
280275

281-
wdt->ctrl = WDT_CTRL_1MHZ_CLK;
276+
/*
277+
* On clock rates:
278+
* - ast2400 wdt can run at PCLK, or 1MHz
279+
* - ast2500 only runs at 1MHz, hard coding bit 4 to 1
280+
* - ast2600 always runs at 1MHz
281+
*
282+
* Set the ast2400 to run at 1MHz as it simplifies the driver.
283+
*/
284+
if (of_device_is_compatible(np, "aspeed,ast2400-wdt"))
285+
wdt->ctrl = WDT_CTRL_1MHZ_CLK;
282286

283287
/*
284288
* Control reset on a per-device basis to ensure the

drivers/watchdog/at91sam9_wdt.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,37 @@
44
*
55
* Copyright (C) 2007 Andrew Victor
66
* Copyright (C) 2007 Atmel Corporation.
7+
* Copyright (C) 2019 Microchip Technology Inc. and its subsidiaries
78
*
89
* Watchdog Timer (WDT) - System peripherals regsters.
910
* Based on AT91SAM9261 datasheet revision D.
11+
* Based on SAM9X60 datasheet.
1012
*
1113
*/
1214

1315
#ifndef AT91_WDT_H
1416
#define AT91_WDT_H
1517

18+
#include <linux/bits.h>
19+
1620
#define AT91_WDT_CR 0x00 /* Watchdog Control Register */
17-
#define AT91_WDT_WDRSTT (1 << 0) /* Restart */
18-
#define AT91_WDT_KEY (0xa5 << 24) /* KEY Password */
21+
#define AT91_WDT_WDRSTT BIT(0) /* Restart */
22+
#define AT91_WDT_KEY (0xa5UL << 24) /* KEY Password */
1923

2024
#define AT91_WDT_MR 0x04 /* Watchdog Mode Register */
21-
#define AT91_WDT_WDV (0xfff << 0) /* Counter Value */
22-
#define AT91_WDT_SET_WDV(x) ((x) & AT91_WDT_WDV)
23-
#define AT91_WDT_WDFIEN (1 << 12) /* Fault Interrupt Enable */
24-
#define AT91_WDT_WDRSTEN (1 << 13) /* Reset Processor */
25-
#define AT91_WDT_WDRPROC (1 << 14) /* Timer Restart */
26-
#define AT91_WDT_WDDIS (1 << 15) /* Watchdog Disable */
27-
#define AT91_WDT_WDD (0xfff << 16) /* Delta Value */
28-
#define AT91_WDT_SET_WDD(x) (((x) << 16) & AT91_WDT_WDD)
29-
#define AT91_WDT_WDDBGHLT (1 << 28) /* Debug Halt */
30-
#define AT91_WDT_WDIDLEHLT (1 << 29) /* Idle Halt */
25+
#define AT91_WDT_WDV (0xfffUL << 0) /* Counter Value */
26+
#define AT91_WDT_SET_WDV(x) ((x) & AT91_WDT_WDV)
27+
#define AT91_WDT_WDFIEN BIT(12) /* Fault Interrupt Enable */
28+
#define AT91_WDT_WDRSTEN BIT(13) /* Reset Processor */
29+
#define AT91_WDT_WDRPROC BIT(14) /* Timer Restart */
30+
#define AT91_WDT_WDDIS BIT(15) /* Watchdog Disable */
31+
#define AT91_WDT_WDD (0xfffUL << 16) /* Delta Value */
32+
#define AT91_WDT_SET_WDD(x) (((x) << 16) & AT91_WDT_WDD)
33+
#define AT91_WDT_WDDBGHLT BIT(28) /* Debug Halt */
34+
#define AT91_WDT_WDIDLEHLT BIT(29) /* Idle Halt */
3135

32-
#define AT91_WDT_SR 0x08 /* Watchdog Status Register */
33-
#define AT91_WDT_WDUNF (1 << 0) /* Watchdog Underflow */
34-
#define AT91_WDT_WDERR (1 << 1) /* Watchdog Error */
36+
#define AT91_WDT_SR 0x08 /* Watchdog Status Register */
37+
#define AT91_WDT_WDUNF BIT(0) /* Watchdog Underflow */
38+
#define AT91_WDT_WDERR BIT(1) /* Watchdog Error */
3539

3640
#endif

drivers/watchdog/bd70528_wdt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ EXPORT_SYMBOL(bd70528_wdt_set);
9797
/**
9898
* bd70528_wdt_lock - take WDT lock
9999
*
100-
* @bd70528: device data for the PMIC instance we want to operate on
100+
* @data: device data for the PMIC instance we want to operate on
101101
*
102102
* Lock WDT for arming/disarming in order to avoid race condition caused
103103
* by WDT state changes initiated by WDT and RTC drivers.
@@ -114,7 +114,7 @@ EXPORT_SYMBOL(bd70528_wdt_lock);
114114
/**
115115
* bd70528_wdt_unlock - unlock WDT lock
116116
*
117-
* @bd70528: device data for the PMIC instance we want to operate on
117+
* @data: device data for the PMIC instance we want to operate on
118118
*
119119
* Unlock WDT lock which has previously been taken by call to
120120
* bd70528_wdt_lock.

drivers/watchdog/cadence_wdt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,10 @@ static int cdns_wdt_probe(struct platform_device *pdev)
335335

336336
wdt->clk = devm_clk_get(dev, NULL);
337337
if (IS_ERR(wdt->clk)) {
338-
dev_err(dev, "input clock not found\n");
339-
return PTR_ERR(wdt->clk);
338+
ret = PTR_ERR(wdt->clk);
339+
if (ret != -EPROBE_DEFER)
340+
dev_err(dev, "input clock not found\n");
341+
return ret;
340342
}
341343

342344
ret = clk_prepare_enable(wdt->clk);

drivers/watchdog/imx2_wdt.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ module_param(nowayout, bool, 0);
7272
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
7373
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
7474

75-
7675
static unsigned timeout;
7776
module_param(timeout, uint, 0);
7877
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default="
@@ -247,30 +246,31 @@ static const struct regmap_config imx2_wdt_regmap_config = {
247246

248247
static int __init imx2_wdt_probe(struct platform_device *pdev)
249248
{
249+
struct device *dev = &pdev->dev;
250250
struct imx2_wdt_device *wdev;
251251
struct watchdog_device *wdog;
252252
void __iomem *base;
253253
int ret;
254254
u32 val;
255255

256-
wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
256+
wdev = devm_kzalloc(dev, sizeof(*wdev), GFP_KERNEL);
257257
if (!wdev)
258258
return -ENOMEM;
259259

260260
base = devm_platform_ioremap_resource(pdev, 0);
261261
if (IS_ERR(base))
262262
return PTR_ERR(base);
263263

264-
wdev->regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base,
264+
wdev->regmap = devm_regmap_init_mmio_clk(dev, NULL, base,
265265
&imx2_wdt_regmap_config);
266266
if (IS_ERR(wdev->regmap)) {
267-
dev_err(&pdev->dev, "regmap init failed\n");
267+
dev_err(dev, "regmap init failed\n");
268268
return PTR_ERR(wdev->regmap);
269269
}
270270

271-
wdev->clk = devm_clk_get(&pdev->dev, NULL);
271+
wdev->clk = devm_clk_get(dev, NULL);
272272
if (IS_ERR(wdev->clk)) {
273-
dev_err(&pdev->dev, "can't get Watchdog clock\n");
273+
dev_err(dev, "can't get Watchdog clock\n");
274274
return PTR_ERR(wdev->clk);
275275
}
276276

@@ -280,12 +280,12 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
280280
wdog->min_timeout = 1;
281281
wdog->timeout = IMX2_WDT_DEFAULT_TIME;
282282
wdog->max_hw_heartbeat_ms = IMX2_WDT_MAX_TIME * 1000;
283-
wdog->parent = &pdev->dev;
283+
wdog->parent = dev;
284284

285285
ret = platform_get_irq(pdev, 0);
286286
if (ret > 0)
287-
if (!devm_request_irq(&pdev->dev, ret, imx2_wdt_isr, 0,
288-
dev_name(&pdev->dev), wdog))
287+
if (!devm_request_irq(dev, ret, imx2_wdt_isr, 0,
288+
dev_name(dev), wdog))
289289
wdog->info = &imx2_wdt_pretimeout_info;
290290

291291
ret = clk_prepare_enable(wdev->clk);
@@ -295,13 +295,13 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
295295
regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val);
296296
wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
297297

298-
wdev->ext_reset = of_property_read_bool(pdev->dev.of_node,
298+
wdev->ext_reset = of_property_read_bool(dev->of_node,
299299
"fsl,ext-reset-output");
300300
platform_set_drvdata(pdev, wdog);
301301
watchdog_set_drvdata(wdog, wdev);
302302
watchdog_set_nowayout(wdog, nowayout);
303303
watchdog_set_restart_priority(wdog, 128);
304-
watchdog_init_timeout(wdog, timeout, &pdev->dev);
304+
watchdog_init_timeout(wdog, timeout, dev);
305305

306306
if (imx2_wdt_is_running(wdev)) {
307307
imx2_wdt_set_timeout(wdog, wdog->timeout);
@@ -319,7 +319,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
319319
if (ret)
320320
goto disable_clk;
321321

322-
dev_info(&pdev->dev, "timeout %d sec (nowayout=%d)\n",
322+
dev_info(dev, "timeout %d sec (nowayout=%d)\n",
323323
wdog->timeout, nowayout);
324324

325325
return 0;
@@ -359,9 +359,8 @@ static void imx2_wdt_shutdown(struct platform_device *pdev)
359359
}
360360
}
361361

362-
#ifdef CONFIG_PM_SLEEP
363362
/* Disable watchdog if it is active or non-active but still running */
364-
static int imx2_wdt_suspend(struct device *dev)
363+
static int __maybe_unused imx2_wdt_suspend(struct device *dev)
365364
{
366365
struct watchdog_device *wdog = dev_get_drvdata(dev);
367366
struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
@@ -382,7 +381,7 @@ static int imx2_wdt_suspend(struct device *dev)
382381
}
383382

384383
/* Enable watchdog and configure it if necessary */
385-
static int imx2_wdt_resume(struct device *dev)
384+
static int __maybe_unused imx2_wdt_resume(struct device *dev)
386385
{
387386
struct watchdog_device *wdog = dev_get_drvdata(dev);
388387
struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
@@ -407,7 +406,6 @@ static int imx2_wdt_resume(struct device *dev)
407406

408407
return 0;
409408
}
410-
#endif
411409

412410
static SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend,
413411
imx2_wdt_resume);

drivers/watchdog/imx7ulp_wdt.c

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#define WDOG_CS_CMD32EN BIT(13)
1818
#define WDOG_CS_ULK BIT(11)
1919
#define WDOG_CS_RCS BIT(10)
20+
#define LPO_CLK 0x1
21+
#define LPO_CLK_SHIFT 8
22+
#define WDOG_CS_CLK (LPO_CLK << LPO_CLK_SHIFT)
2023
#define WDOG_CS_EN BIT(7)
2124
#define WDOG_CS_UPDATE BIT(5)
2225

@@ -41,24 +44,25 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
4144
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
4245

4346
struct imx7ulp_wdt_device {
44-
struct notifier_block restart_handler;
4547
struct watchdog_device wdd;
4648
void __iomem *base;
4749
struct clk *clk;
4850
};
4951

50-
static inline void imx7ulp_wdt_enable(void __iomem *base, bool enable)
52+
static void imx7ulp_wdt_enable(struct watchdog_device *wdog, bool enable)
5153
{
52-
u32 val = readl(base + WDOG_CS);
54+
struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog);
5355

54-
writel(UNLOCK, base + WDOG_CNT);
56+
u32 val = readl(wdt->base + WDOG_CS);
57+
58+
writel(UNLOCK, wdt->base + WDOG_CNT);
5559
if (enable)
56-
writel(val | WDOG_CS_EN, base + WDOG_CS);
60+
writel(val | WDOG_CS_EN, wdt->base + WDOG_CS);
5761
else
58-
writel(val & ~WDOG_CS_EN, base + WDOG_CS);
62+
writel(val & ~WDOG_CS_EN, wdt->base + WDOG_CS);
5963
}
6064

61-
static inline bool imx7ulp_wdt_is_enabled(void __iomem *base)
65+
static bool imx7ulp_wdt_is_enabled(void __iomem *base)
6266
{
6367
u32 val = readl(base + WDOG_CS);
6468

@@ -76,18 +80,15 @@ static int imx7ulp_wdt_ping(struct watchdog_device *wdog)
7680

7781
static int imx7ulp_wdt_start(struct watchdog_device *wdog)
7882
{
79-
struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog);
8083

81-
imx7ulp_wdt_enable(wdt->base, true);
84+
imx7ulp_wdt_enable(wdog, true);
8285

8386
return 0;
8487
}
8588

8689
static int imx7ulp_wdt_stop(struct watchdog_device *wdog)
8790
{
88-
struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog);
89-
90-
imx7ulp_wdt_enable(wdt->base, false);
91+
imx7ulp_wdt_enable(wdog, false);
9192

9293
return 0;
9394
}
@@ -106,12 +107,28 @@ static int imx7ulp_wdt_set_timeout(struct watchdog_device *wdog,
106107
return 0;
107108
}
108109

110+
static int imx7ulp_wdt_restart(struct watchdog_device *wdog,
111+
unsigned long action, void *data)
112+
{
113+
struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog);
114+
115+
imx7ulp_wdt_enable(wdt->base, true);
116+
imx7ulp_wdt_set_timeout(&wdt->wdd, 1);
117+
118+
/* wait for wdog to fire */
119+
while (true)
120+
;
121+
122+
return NOTIFY_DONE;
123+
}
124+
109125
static const struct watchdog_ops imx7ulp_wdt_ops = {
110126
.owner = THIS_MODULE,
111127
.start = imx7ulp_wdt_start,
112128
.stop = imx7ulp_wdt_stop,
113129
.ping = imx7ulp_wdt_ping,
114130
.set_timeout = imx7ulp_wdt_set_timeout,
131+
.restart = imx7ulp_wdt_restart,
115132
};
116133

117134
static const struct watchdog_info imx7ulp_wdt_info = {
@@ -120,7 +137,7 @@ static const struct watchdog_info imx7ulp_wdt_info = {
120137
WDIOF_MAGICCLOSE,
121138
};
122139

123-
static inline void imx7ulp_wdt_init(void __iomem *base, unsigned int timeout)
140+
static void imx7ulp_wdt_init(void __iomem *base, unsigned int timeout)
124141
{
125142
u32 val;
126143

@@ -131,7 +148,7 @@ static inline void imx7ulp_wdt_init(void __iomem *base, unsigned int timeout)
131148
/* set an initial timeout value in TOVAL */
132149
writel(timeout, base + WDOG_TOVAL);
133150
/* enable 32bit command sequence and reconfigure */
134-
val = BIT(13) | BIT(8) | BIT(5);
151+
val = WDOG_CS_CMD32EN | WDOG_CS_CLK | WDOG_CS_UPDATE;
135152
writel(val, base + WDOG_CS);
136153
}
137154

drivers/watchdog/intel-mid_wdt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ static int mid_wdt_probe(struct platform_device *pdev)
134134
wdt_dev->timeout = MID_WDT_DEFAULT_TIMEOUT;
135135
wdt_dev->parent = dev;
136136

137+
watchdog_set_nowayout(wdt_dev, WATCHDOG_NOWAYOUT);
137138
watchdog_set_drvdata(wdt_dev, dev);
138139

139140
ret = devm_request_irq(dev, pdata->irq, mid_wdt_irq,

0 commit comments

Comments
 (0)