watchdog: add support for the Synopsys DesignWare WDT
PATCH 1/1 watchdog: add support for the Synopsys DesignWare WDT
The Synopsys DesignWare watchdog is found in several ARM based systems and provides a choice of 16 timeout periods depending on the clock input. The watchdog cannot be disabled once started.
If the platform does not provide a clk for the watchdog then the user can specify the input frequency with the struct dw_wdt_platform_data in <linux/platform_data/dw_wdt.h>
v4:
- cleanups as suggested by Viresh Kumar and Wim
- provide a mechanism to handle NULL clks and allow platform_data to specify the clk_rate
- provide open-once protection
v3:
- convert pm to dev_pm_ops
- use devres for resource allocation
v2:
- constify fops
- request_mem_region() before ioremap()
- disable clk if misc_register() fails
---
Viresh, Russell, Wim - thanks for your feedback.
include/linux/platform_data is used for the platform data as suggested by Greg K-H in [1].
1. https://lkml.org/lkml/2011/1/7/323
drivers/watchdog/Kconfig | 9 + drivers/watchdog/Makefile | 1 + drivers/watchdog/dw_wdt.c | 329 ++++++++++++++++++++++++++++++++++ include/linux/platform_data/dw_wdt.h | 27 +++ 4 files changed, 366 insertions(+), 0 deletions(-) create mode 100644 drivers/watchdog/dw_wdt.c create mode 100644 include/linux/platform_data/dw_wdt.h
drivers/watchdog/Kconfig +9 -0
@@ -331,6 +331,15 @@ config IMX2_WDT To compile this driver as a module, choose M here: the module will be called imx2_wdt. +config DW_WATCHDOG + tristate "Synopsys DesignWare watchdog" + select WATCHDOG_NOWAYOUT + help + Say Y here if to include support for the Synopsys DesignWare + watchdog timer found in many ARM chips. + To compile this driver as a module, choose M here: the + module will be called dw_wdt. + # AVR32 Architecture config AT32AP700X_WDT
drivers/watchdog/Makefile +1 -0
@@ -49,6 +49,7 @@ obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o obj-$(CONFIG_ADX_WATCHDOG) += adx_wdt.o obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o +obj-$(CONFIG_DW_WATCHDOG) += dw_wdt.o # AVR32 Architecture obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
drivers/watchdog/dw_wdt.c new file +329 -0
329 lines not on this page · raw message
include/linux/platform_data/dw_wdt.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright 2010 Picochip Ltd., Jamie Iles +* http://www.picochip.com +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +* +* This file implements a driver for the Synopsys DesignWare watchdog device +* in the many ARM subsystems. The watchdog has 16 different timeout periods +* and these are a function of the input clock frequency. +*/ +#ifndef __DW_WDT_H__ +#define __DW_WDT_H__ + +/** +* struct dw_wdt_platform_data - DesignWare WDT platform data +* +* @clk_rate: The frequency (HZ) at which the watchdog is driven. The timeout +* periods are derived from this frequency. +*/ +struct dw_wdt_platform_data { +unsigned long clk_rate; +}; + +#endif /* __DW_WDT_H__ */
Signature · 1 line
1.7.3.4
PATCH 1/1 watchdog: add support for the Synopsys DesignWare WDT
Hi Jamie,
Quoted 10 lines
drivers/watchdog/Kconfig +2
-0@@ -331,6 +331,15 @@ config IMX2_WDT To compile this driver as a module, choose M here: the module will be called imx2_wdt. +config DW_WATCHDOG + tristate "Synopsys DesignWare watchdog"
drivers/watchdog/Kconfig config IMX2_WDT · line 345
Quoted 10 lines
drivers/watchdog/Kconfig +7
-0+ select WATCHDOG_NOWAYOUT + help + Say Y here if to include support for the Synopsys DesignWare + watchdog timer found in many ARM chips. + To compile this driver as a module, choose M here: the + module will be called dw_wdt. + # AVR32 Architecture config AT32AP700X_WDT
Could you add the correct dependancy also in Kconfig?
Thanks in advance,
Wim.
PATCH 1/1 watchdog: add support for the Synopsys DesignWare WDT
Quoted 21 lines · Wim Van Sebroeck
Hi Jamie,
Quoted 19 lines
drivers/watchdog/Kconfig +9
-0@@ -331,6 +331,15 @@ config IMX2_WDT To compile this driver as a module, choose M here: the module will be called imx2_wdt. +config DW_WATCHDOG + tristate "Synopsys DesignWare watchdog" + select WATCHDOG_NOWAYOUT + help + Say Y here if to include support for the Synopsys DesignWare + watchdog timer found in many ARM chips. + To compile this driver as a module, choose M here: the + module will be called dw_wdt. + # AVR32 Architecture
Quoted 3 lines
drivers/watchdog/Kconfig config IMX2_WDT · line 345
Quoted 1 line
drivers/watchdog/Kconfig +0
-0config AT32AP700X_WDTCould you add the correct dependancy also in
Kconfig?
Sure, updated patch below with a dependency on ARM.
Jamie
8<----------------------------------------------------------------------
PATCH 1/1 watchdog: add support for the Synopsys DesignWare WDT
In reply to Jamie IlesHi Jamie,
drivers/watchdog/Kconfig config IMX2_WDT · line 336
Quoted 3 lines
drivers/watchdog/Kconfig +3
-0+config DW_WATCHDOG + tristate "Synopsys DesignWare watchdog" + select WATCHDOG_NOWAYOUT
I overlooked something: If your watchdog driver cannot be stopped once it's started, then it's best to add a comment about that in your code. Selecting the WATCHDOG_NOWAYOUT feauture (which is overall for all drivers) is not the way to do it properly. What you should do is add a timer that ticks the watchdog if /dev/watchdog is closed. Examples for this functionality can be found in at91sam9_wdt.c, pika_wdt.c, ...
Sorry,
Wim.