Skip to content

Commit 4fe19a1

Browse files
committed
Pull watchdog updates from Wim Van Sebroeck: "This includes some fixes and code improvements (like clk_prepare_enable and clk_disable_unprepare), conversion from the omap_wdt and twl4030_wdt drivers to the watchdog framework, addition of the SB8x0 chipset support and the DA9055 Watchdog driver and some OF support for the davinci_wdt driver." * git://www.linux-watchdog.org/linux-watchdog: (22 commits) watchdog: mei: avoid oops in watchdog unregister code path watchdog: Orion: Fix possible null-deference in orion_wdt_probe watchdog: sp5100_tco: Add SB8x0 chipset support watchdog: davinci_wdt: add OF support watchdog: da9052: Fix invalid free of devm_ allocated data watchdog: twl4030_wdt: Change TWL4030_MODULE_PM_RECEIVER to TWL_MODULE_PM_RECEIVER watchdog: remove depends on CONFIG_EXPERIMENTAL watchdog: Convert dev_printk(KERN_<LEVEL> to dev_<level>( watchdog: DA9055 Watchdog driver watchdog: omap_wdt: eliminate goto watchdog: omap_wdt: delete redundant platform_set_drvdata() calls watchdog: omap_wdt: convert to devm_ functions watchdog: omap_wdt: convert to new watchdog core watchdog: WatchDog Timer Driver Core: fix comment watchdog: s3c2410_wdt: use clk_prepare_enable and clk_disable_unprepare watchdog: imx2_wdt: Select the driver via ARCH_MXC watchdog: cpu5wdt.c: add missing del_timer call watchdog: hpwdt.c: Increase version string watchdog: Convert twl4030_wdt to watchdog core davinci_wdt: preparation for switch to common clock framework ...
2 parents 769cb85 + d692170 commit 4fe19a1

File tree

19 files changed

+738
-445
lines changed

19 files changed

+738
-445
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
DaVinci Watchdog Timer (WDT) Controller
2+
3+
Required properties:
4+
- compatible : Should be "ti,davinci-wdt"
5+
- reg : Should contain WDT registers location and length
6+
7+
Examples:
8+
9+
wdt: wdt@2320000 {
10+
compatible = "ti,davinci-wdt";
11+
reg = <0x02320000 0x80>;
12+
};

drivers/misc/mei/wd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ void mei_watchdog_register(struct mei_device *dev)
370370

371371
void mei_watchdog_unregister(struct mei_device *dev)
372372
{
373-
if (test_bit(WDOG_UNREGISTERED, &amt_wd_dev.status))
373+
if (watchdog_get_drvdata(&amt_wd_dev) == NULL)
374374
return;
375375

376376
watchdog_set_drvdata(&amt_wd_dev, NULL);

drivers/watchdog/Kconfig

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ config DA9052_WATCHDOG
7676
Alternatively say M to compile the driver as a module,
7777
which will be called da9052_wdt.
7878

79+
config DA9055_WATCHDOG
80+
tristate "Dialog Semiconductor DA9055 Watchdog"
81+
depends on MFD_DA9055
82+
help
83+
If you say yes here you get support for watchdog on the Dialog
84+
Semiconductor DA9055 PMIC.
85+
86+
This driver can also be built as a module. If so, the module
87+
will be called da9055_wdt.
88+
7989
config WM831X_WATCHDOG
8090
tristate "WM831x watchdog"
8191
depends on MFD_WM831X
@@ -232,6 +242,7 @@ config EP93XX_WATCHDOG
232242
config OMAP_WATCHDOG
233243
tristate "OMAP Watchdog"
234244
depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
245+
select WATCHDOG_CORE
235246
help
236247
Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. Say 'Y'
237248
here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog timer.
@@ -300,6 +311,7 @@ config COH901327_WATCHDOG
300311
config TWL4030_WATCHDOG
301312
tristate "TWL4030 Watchdog"
302313
depends on TWL4030_CORE
314+
select WATCHDOG_CORE
303315
help
304316
Support for TI TWL4030 watchdog. Say 'Y' here to enable the
305317
watchdog timer support for TWL4030 chips.
@@ -342,7 +354,7 @@ config MAX63XX_WATCHDOG
342354

343355
config IMX2_WDT
344356
tristate "IMX2+ Watchdog"
345-
depends on IMX_HAVE_PLATFORM_IMX2_WDT
357+
depends on ARCH_MXC
346358
help
347359
This is the driver for the hardware watchdog
348360
on the Freescale IMX2 and later processors.
@@ -431,7 +443,7 @@ config ALIM7101_WDT
431443

432444
config F71808E_WDT
433445
tristate "Fintek F71808E, F71862FG, F71869, F71882FG and F71889FG Watchdog"
434-
depends on X86 && EXPERIMENTAL
446+
depends on X86
435447
help
436448
This is the driver for the hardware watchdog on the Fintek
437449
F71808E, F71862FG, F71869, F71882FG and F71889FG Super I/O controllers.
@@ -622,7 +634,7 @@ config IT8712F_WDT
622634

623635
config IT87_WDT
624636
tristate "IT87 Watchdog Timer"
625-
depends on X86 && EXPERIMENTAL
637+
depends on X86
626638
---help---
627639
This is the driver for the hardware watchdog on the ITE IT8702,
628640
IT8712, IT8716, IT8718, IT8720, IT8721, IT8726 and IT8728

drivers/watchdog/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o
164164

165165
# Architecture Independent
166166
obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o
167+
obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o
167168
obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o
168169
obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o
169170
obj-$(CONFIG_MAX63XX_WATCHDOG) += max63xx_wdt.o

drivers/watchdog/ath79_wdt.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ static void ath97_wdt_shutdown(struct platform_device *pdev)
284284
}
285285

286286
static struct platform_driver ath79_wdt_driver = {
287+
.probe = ath79_wdt_probe,
287288
.remove = ath79_wdt_remove,
288289
.shutdown = ath97_wdt_shutdown,
289290
.driver = {
@@ -292,17 +293,7 @@ static struct platform_driver ath79_wdt_driver = {
292293
},
293294
};
294295

295-
static int __init ath79_wdt_init(void)
296-
{
297-
return platform_driver_probe(&ath79_wdt_driver, ath79_wdt_probe);
298-
}
299-
module_init(ath79_wdt_init);
300-
301-
static void __exit ath79_wdt_exit(void)
302-
{
303-
platform_driver_unregister(&ath79_wdt_driver);
304-
}
305-
module_exit(ath79_wdt_exit);
296+
module_platform_driver(ath79_wdt_driver);
306297

307298
MODULE_DESCRIPTION("Atheros AR71XX/AR724X/AR913X hardware watchdog driver");
308299
MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org");

drivers/watchdog/cpu5wdt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ static void cpu5wdt_exit(void)
266266
if (cpu5wdt_device.queue) {
267267
cpu5wdt_device.queue = 0;
268268
wait_for_completion(&cpu5wdt_device.stop);
269+
del_timer(&cpu5wdt_device.timer);
269270
}
270271

271272
misc_deregister(&cpu5wdt_misc);

drivers/watchdog/da9052_wdt.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ static const struct {
5353

5454
static void da9052_wdt_release_resources(struct kref *r)
5555
{
56-
struct da9052_wdt_data *driver_data =
57-
container_of(r, struct da9052_wdt_data, kref);
58-
59-
kfree(driver_data);
6056
}
6157

6258
static int da9052_wdt_set_timeout(struct watchdog_device *wdt_dev,

drivers/watchdog/da9055_wdt.c

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
/*
2+
* System monitoring driver for DA9055 PMICs.
3+
*
4+
* Copyright(c) 2012 Dialog Semiconductor Ltd.
5+
*
6+
* Author: David Dajun Chen <dchen@diasemi.com>
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
*/
14+
15+
#include <linux/module.h>
16+
#include <linux/types.h>
17+
#include <linux/kernel.h>
18+
#include <linux/slab.h>
19+
#include <linux/platform_device.h>
20+
#include <linux/watchdog.h>
21+
#include <linux/delay.h>
22+
23+
#include <linux/mfd/da9055/core.h>
24+
#include <linux/mfd/da9055/reg.h>
25+
26+
static bool nowayout = WATCHDOG_NOWAYOUT;
27+
module_param(nowayout, bool, 0);
28+
MODULE_PARM_DESC(nowayout,
29+
"Watchdog cannot be stopped once started (default="
30+
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
31+
32+
#define DA9055_DEF_TIMEOUT 4
33+
#define DA9055_TWDMIN 256
34+
35+
struct da9055_wdt_data {
36+
struct watchdog_device wdt;
37+
struct da9055 *da9055;
38+
struct kref kref;
39+
};
40+
41+
static const struct {
42+
u8 reg_val;
43+
int user_time; /* In seconds */
44+
} da9055_wdt_maps[] = {
45+
{ 0, 0 },
46+
{ 1, 2 },
47+
{ 2, 4 },
48+
{ 3, 8 },
49+
{ 4, 16 },
50+
{ 5, 32 },
51+
{ 5, 33 }, /* Actual time 32.768s so included both 32s and 33s */
52+
{ 6, 65 },
53+
{ 6, 66 }, /* Actual time 65.536s so include both, 65s and 66s */
54+
{ 7, 131 },
55+
};
56+
57+
static int da9055_wdt_set_timeout(struct watchdog_device *wdt_dev,
58+
unsigned int timeout)
59+
{
60+
struct da9055_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev);
61+
struct da9055 *da9055 = driver_data->da9055;
62+
int ret, i;
63+
64+
for (i = 0; i < ARRAY_SIZE(da9055_wdt_maps); i++)
65+
if (da9055_wdt_maps[i].user_time == timeout)
66+
break;
67+
68+
if (i == ARRAY_SIZE(da9055_wdt_maps))
69+
ret = -EINVAL;
70+
else
71+
ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_B,
72+
DA9055_TWDSCALE_MASK,
73+
da9055_wdt_maps[i].reg_val <<
74+
DA9055_TWDSCALE_SHIFT);
75+
if (ret < 0)
76+
dev_err(da9055->dev,
77+
"Failed to update timescale bit, %d\n", ret);
78+
79+
wdt_dev->timeout = timeout;
80+
81+
return ret;
82+
}
83+
84+
static int da9055_wdt_ping(struct watchdog_device *wdt_dev)
85+
{
86+
struct da9055_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev);
87+
struct da9055 *da9055 = driver_data->da9055;
88+
int ret;
89+
90+
/*
91+
* We have a minimum time for watchdog window called TWDMIN. A write
92+
* to the watchdog before this elapsed time will cause an error.
93+
*/
94+
mdelay(DA9055_TWDMIN);
95+
96+
/* Reset the watchdog timer */
97+
ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_E,
98+
DA9055_WATCHDOG_MASK, 1);
99+
100+
return ret;
101+
}
102+
103+
static void da9055_wdt_release_resources(struct kref *r)
104+
{
105+
struct da9055_wdt_data *driver_data =
106+
container_of(r, struct da9055_wdt_data, kref);
107+
108+
kfree(driver_data);
109+
}
110+
111+
static void da9055_wdt_ref(struct watchdog_device *wdt_dev)
112+
{
113+
struct da9055_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev);
114+
115+
kref_get(&driver_data->kref);
116+
}
117+
118+
static void da9055_wdt_unref(struct watchdog_device *wdt_dev)
119+
{
120+
struct da9055_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev);
121+
122+
kref_put(&driver_data->kref, da9055_wdt_release_resources);
123+
}
124+
125+
static int da9055_wdt_start(struct watchdog_device *wdt_dev)
126+
{
127+
return da9055_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
128+
}
129+
130+
static int da9055_wdt_stop(struct watchdog_device *wdt_dev)
131+
{
132+
return da9055_wdt_set_timeout(wdt_dev, 0);
133+
}
134+
135+
static struct watchdog_info da9055_wdt_info = {
136+
.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
137+
.identity = "DA9055 Watchdog",
138+
};
139+
140+
static const struct watchdog_ops da9055_wdt_ops = {
141+
.owner = THIS_MODULE,
142+
.start = da9055_wdt_start,
143+
.stop = da9055_wdt_stop,
144+
.ping = da9055_wdt_ping,
145+
.set_timeout = da9055_wdt_set_timeout,
146+
.ref = da9055_wdt_ref,
147+
.unref = da9055_wdt_unref,
148+
};
149+
150+
static int da9055_wdt_probe(struct platform_device *pdev)
151+
{
152+
struct da9055 *da9055 = dev_get_drvdata(pdev->dev.parent);
153+
struct da9055_wdt_data *driver_data;
154+
struct watchdog_device *da9055_wdt;
155+
int ret;
156+
157+
driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data),
158+
GFP_KERNEL);
159+
if (!driver_data) {
160+
dev_err(da9055->dev, "Failed to allocate watchdog device\n");
161+
return -ENOMEM;
162+
}
163+
164+
driver_data->da9055 = da9055;
165+
166+
da9055_wdt = &driver_data->wdt;
167+
168+
da9055_wdt->timeout = DA9055_DEF_TIMEOUT;
169+
da9055_wdt->info = &da9055_wdt_info;
170+
da9055_wdt->ops = &da9055_wdt_ops;
171+
watchdog_set_nowayout(da9055_wdt, nowayout);
172+
watchdog_set_drvdata(da9055_wdt, driver_data);
173+
174+
kref_init(&driver_data->kref);
175+
176+
ret = da9055_wdt_stop(da9055_wdt);
177+
if (ret < 0) {
178+
dev_err(&pdev->dev, "Failed to stop watchdog, %d\n", ret);
179+
goto err;
180+
}
181+
182+
dev_set_drvdata(&pdev->dev, driver_data);
183+
184+
ret = watchdog_register_device(&driver_data->wdt);
185+
if (ret != 0)
186+
dev_err(da9055->dev, "watchdog_register_device() failed: %d\n",
187+
ret);
188+
189+
err:
190+
return ret;
191+
}
192+
193+
static int da9055_wdt_remove(struct platform_device *pdev)
194+
{
195+
struct da9055_wdt_data *driver_data = dev_get_drvdata(&pdev->dev);
196+
197+
watchdog_unregister_device(&driver_data->wdt);
198+
kref_put(&driver_data->kref, da9055_wdt_release_resources);
199+
200+
return 0;
201+
}
202+
203+
static struct platform_driver da9055_wdt_driver = {
204+
.probe = da9055_wdt_probe,
205+
.remove = da9055_wdt_remove,
206+
.driver = {
207+
.name = "da9055-watchdog",
208+
},
209+
};
210+
211+
module_platform_driver(da9055_wdt_driver);
212+
213+
MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
214+
MODULE_DESCRIPTION("DA9055 watchdog");
215+
MODULE_LICENSE("GPL");
216+
MODULE_ALIAS("platform:da9055-watchdog");

drivers/watchdog/davinci_wdt.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static int davinci_wdt_probe(struct platform_device *pdev)
208208
if (WARN_ON(IS_ERR(wdt_clk)))
209209
return PTR_ERR(wdt_clk);
210210

211-
clk_enable(wdt_clk);
211+
clk_prepare_enable(wdt_clk);
212212

213213
if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
214214
heartbeat = DEFAULT_HEARTBEAT;
@@ -256,16 +256,23 @@ static int davinci_wdt_remove(struct platform_device *pdev)
256256
wdt_mem = NULL;
257257
}
258258

259-
clk_disable(wdt_clk);
259+
clk_disable_unprepare(wdt_clk);
260260
clk_put(wdt_clk);
261261

262262
return 0;
263263
}
264264

265+
static const struct of_device_id davinci_wdt_of_match[] = {
266+
{ .compatible = "ti,davinci-wdt", },
267+
{},
268+
};
269+
MODULE_DEVICE_TABLE(of, davinci_wdt_of_match);
270+
265271
static struct platform_driver platform_wdt_driver = {
266272
.driver = {
267273
.name = "watchdog",
268274
.owner = THIS_MODULE,
275+
.of_match_table = davinci_wdt_of_match,
269276
},
270277
.probe = davinci_wdt_probe,
271278
.remove = davinci_wdt_remove,

drivers/watchdog/hpwdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#endif /* CONFIG_HPWDT_NMI_DECODING */
4040
#include <asm/nmi.h>
4141

42-
#define HPWDT_VERSION "1.3.0"
42+
#define HPWDT_VERSION "1.3.1"
4343
#define SECS_TO_TICKS(secs) ((secs) * 1000 / 128)
4444
#define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000)
4545
#define HPWDT_MAX_TIMER TICKS_TO_SECS(65535)

0 commit comments

Comments
 (0)