Skip to content

Commit 580b8e2

Browse files
linuswWim Van Sebroeck
authored andcommitted
watchdog: ixp4xx: Rewrite driver to use core
This rewrites the IXP4xx watchdog driver as follows: - Spawn the watchdog driver as a platform device from the timer driver. It's one device in the hardware, and the fact that Linux splits the handling into two different devices is a Linux pecularity, and thus it becomes a Linux pecularity to spawn a separate watchdog driver. - Spawn the watchdog driver from the timer driver at probe(). This is well after the timer driver as actually registered and started and we know the register base is available. - Instead of looping back callbacks to the timer drivers for all watchdog calls, pass the register base to the watchdog driver and manage the registers there. The two drivers aren't even interested in the same register so the spinlock is totally surplus, delete it. - Replace pretty much all of the content in the watchdog driver with a simple, modern watchdog driver utilizing the watchdog core instead of registering its own misc device and ioctl() handling. - Drop module parameters as the same already exist in the watchdog core. What remains is a slim elegant (IMO) watchdog driver using the watchdog core, spawning from device tree or boardfile alike. Cc: Daniel Lezcano <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Acked-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent dbe80cf commit 580b8e2

File tree

3 files changed

+155
-177
lines changed

3 files changed

+155
-177
lines changed

drivers/clocksource/timer-ixp4xx.c

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/delay.h>
1919
#include <linux/of_address.h>
2020
#include <linux/of_irq.h>
21+
#include <linux/platform_device.h>
2122
/* Goes away with OF conversion */
2223
#include <linux/platform_data/timer-ixp4xx.h>
2324

@@ -29,9 +30,6 @@
2930
#define IXP4XX_OSRT1_OFFSET 0x08 /* Timer 1 Reload */
3031
#define IXP4XX_OST2_OFFSET 0x0C /* Timer 2 Timestamp */
3132
#define IXP4XX_OSRT2_OFFSET 0x10 /* Timer 2 Reload */
32-
#define IXP4XX_OSWT_OFFSET 0x14 /* Watchdog Timer */
33-
#define IXP4XX_OSWE_OFFSET 0x18 /* Watchdog Enable */
34-
#define IXP4XX_OSWK_OFFSET 0x1C /* Watchdog Key */
3533
#define IXP4XX_OSST_OFFSET 0x20 /* Timer Status */
3634

3735
/*
@@ -45,17 +43,10 @@
4543
#define IXP4XX_OSST_TIMER_1_PEND 0x00000001
4644
#define IXP4XX_OSST_TIMER_2_PEND 0x00000002
4745
#define IXP4XX_OSST_TIMER_TS_PEND 0x00000004
48-
#define IXP4XX_OSST_TIMER_WDOG_PEND 0x00000008
49-
#define IXP4XX_OSST_TIMER_WARM_RESET 0x00000010
50-
51-
#define IXP4XX_WDT_KEY 0x0000482E
52-
#define IXP4XX_WDT_RESET_ENABLE 0x00000001
53-
#define IXP4XX_WDT_IRQ_ENABLE 0x00000002
54-
#define IXP4XX_WDT_COUNT_ENABLE 0x00000004
46+
/* Remaining registers are for the watchdog and defined in the watchdog driver */
5547

5648
struct ixp4xx_timer {
5749
void __iomem *base;
58-
unsigned int tick_rate;
5950
u32 latch;
6051
struct clock_event_device clkevt;
6152
#ifdef CONFIG_ARM
@@ -181,7 +172,6 @@ static __init int ixp4xx_timer_register(void __iomem *base,
181172
if (!tmr)
182173
return -ENOMEM;
183174
tmr->base = base;
184-
tmr->tick_rate = timer_freq;
185175

186176
/*
187177
* The timer register doesn't allow to specify the two least
@@ -239,6 +229,40 @@ static __init int ixp4xx_timer_register(void __iomem *base,
239229
return 0;
240230
}
241231

232+
static struct platform_device ixp4xx_watchdog_device = {
233+
.name = "ixp4xx-watchdog",
234+
.id = -1,
235+
};
236+
237+
/*
238+
* This probe gets called after the timer is already up and running. The main
239+
* function on this platform is to spawn the watchdog device as a child.
240+
*/
241+
static int ixp4xx_timer_probe(struct platform_device *pdev)
242+
{
243+
struct device *dev = &pdev->dev;
244+
245+
/* Pass the base address as platform data and nothing else */
246+
ixp4xx_watchdog_device.dev.platform_data = local_ixp4xx_timer->base;
247+
ixp4xx_watchdog_device.dev.parent = dev;
248+
return platform_device_register(&ixp4xx_watchdog_device);
249+
}
250+
251+
static const struct of_device_id ixp4xx_timer_dt_id[] = {
252+
{ .compatible = "intel,ixp4xx-timer", },
253+
{ /* sentinel */ },
254+
};
255+
256+
static struct platform_driver ixp4xx_timer_driver = {
257+
.probe = ixp4xx_timer_probe,
258+
.driver = {
259+
.name = "ixp4xx-timer",
260+
.of_match_table = ixp4xx_timer_dt_id,
261+
.suppress_bind_attrs = true,
262+
},
263+
};
264+
builtin_platform_driver(ixp4xx_timer_driver);
265+
242266
/**
243267
* ixp4xx_timer_setup() - Timer setup function to be called from boardfiles
244268
* @timerbase: physical base of timer block

drivers/watchdog/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ config FTWDT010_WATCHDOG
475475
config IXP4XX_WATCHDOG
476476
tristate "IXP4xx Watchdog"
477477
depends on ARCH_IXP4XX
478+
select WATCHDOG_CORE
478479
help
479480
Say Y here if to include support for the watchdog timer
480481
in the Intel IXP4xx network processors. This driver can

0 commit comments

Comments
 (0)