watchdog: dt: add support for the timeout-sec dt property
Subsystems (5)
v9 cover watchdog: dt: add support for the timeout-sec dt property
Hi all,
this patchset add the timeout-sec property to the watchdog core, to the at91sam9_wdt driver and on all framework enabled watchdog driver with dt support.
The at91sam9_wdt is tested on evk-pr3,
the other drivers are compile tested only.
Hi Wim,
because the first two patches are fixes for the
patch 433bf8dc344c0eacb3ff5bbc1aea42f75b170a72 already included in watchdog-next feel free to squash them.
Best regards
Fabio Porcedda
changes:
v9:
- rebase over watchdog-next, so remove first and second patch and add two commit to fix the commit already present in watchdog-next
- add a commit for fixing coding style
v8:
- watchdog_is_valid_timeout(): export in watchdog.h
- watchdog_is_valid_timeout(): use in watchdog_set_timeout()
- watchdog_is_valid_timeout(): split patch
- watchdog_init_timeout(): return -EINVAL for out of range values.
- watchdog_init_timeout(): use struct device instead of struct device_node
v7:
- rebase over v3.8-rc2
- remove the patch already merged
v6:
- remove patch for function of_get_timeout_sec as aked by Rob Herring
- add Acked-by: Jason Cooper <[email protected]>
- add Acked-by: Nicolas Ferre <[email protected]>
v5:
- fix codestyle for compilance ti checkpatch.pl about
"ERROR: do not initialise statics to 0 or NULL"
for s3c2410_wdt.c:56 and at91sam9_wdt.c:63
v4:
- add of_get_timeout_sec
- add s3c2410_wdt driver
- split driver patch
- fixed watchdog_init_timeout handling of min_timeout and max_timeout
v3:
- rename watchdog_probe_dt_timeout -> watchdog_init_timeout
- move the watchdog_init_timeout function from inline to watchdog_core.c
- add timeout parameter handling code to watchdog_init_timeout
- add timeout-sec property to the pnx4008-wdt driver
- add two small commit for fixup and cleanup
v2:
- change "timeout" to "timeout-sec" as asked by Jean-Christophe
- at91sam9_wdt: use the new helper function
- at91sam9_wdt: add bounds checking
- watchdog.h: add bounds checking
Fabio Porcedda (8):
watchdog: core: add static to watchdog_check_min_max_timeout()
watchdog: core: fix watchdog_check_min_max_timeout() return value
watchdog: orion_wdt: add timeout-sec property binding
watchdog: pnx4008: add timeout-sec property binding
watchdog: s3c2410_wdt: add timeout-sec property binding
watchdog: at91sam9_wdt: add timeout-sec property binding
watchdog: orion_wdt: move the min_timeout initialization
watchdog: code: fix the alignement of some function declarations
.../devicetree/bindings/watchdog/atmel-wdt.txt | 4 ++++ Documentation/devicetree/bindings/watchdog/marvel.txt | 5 +++++ .../devicetree/bindings/watchdog/pnx4008-wdt.txt | 4 ++++ .../devicetree/bindings/watchdog/samsung-wdt.txt | 3 +++ drivers/watchdog/Kconfig | 1 + drivers/watchdog/at91sam9_wdt.c | 16 +++++++++++++--- drivers/watchdog/orion_wdt.c | 10 ++++------ drivers/watchdog/pnx4008_wdt.c | 7 +++---- drivers/watchdog/s3c2410_wdt.c | 6 ++++-- drivers/watchdog/watchdog_core.c | 16 +++++++++++----- drivers/watchdog/watchdog_dev.c | 17 ++++++----------- 11 files changed, 58 insertions(+), 31 deletions(-)
Signature · 1 line
1.8.1.1
PATCH v9 1/8 watchdog: core: add static to watchdog_check_min_max_timeout()
Because is an internal function is better to use static to help the compiler.
--- drivers/watchdog/watchdog_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/watchdog_core.c +1 -1
@@ -43,7 +43,7 @@static DEFINE_IDA (watchdog_ida);static struct class *watchdog_class; -void watchdog_check_min_max_timeout (struct watchdog_device *wdd) +static void watchdog_check_min_max_timeout (struct watchdog_device *wdd) {/* * Check that we have valid min and max timeout values, if
Signature · 1 line
1.8.1.1
PATCH v9 2/8 watchdog: core: fix watchdog_check_min_max_timeout() return value
In reply to Fabio PorceddaThe device tree support is not mandatory, so the function doesn't return error when is not used.
Return -EINVAL when the module parameter or
timeout-sec property is out of bounds.
--- drivers/watchdog/watchdog_core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/watchdog/watchdog_core.c +9 -3
@@ -73,22 +73,28 @@ int watchdog_init_timeout(struct watchdog_device *wdd, unsigned int timeout_parm, struct device *dev) { unsigned int t = 0; +int ret =0 ;watchdog_check_min_max_timeout (wdd);/* try to get the tiemout module parameter first */ if (!watchdog_timeout_invalid (wdd, timeout_parm)) { wdd->timeout = timeout_parm; -return 0 ; +return ret; } +if (timeout_parm) + ret = -EINVAL ;/* try to get the timeout_sec property */ if (dev ==NULL || dev->of_node ==NULL ) -return -EINVAL ; +return ret;of_property_read_u32 (dev->of_node,"timeout-sec" , &t);if (!watchdog_timeout_invalid (wdd, t)) wdd->timeout = t; -return 0 ; +else + ret = -EINVAL ; + +return ret; }EXPORT_SYMBOL_GPL (watchdog_init_timeout);
Signature · 1 line
1.8.1.1
PATCH v9 3/8 watchdog: orion_wdt: add timeout-sec property binding
In reply to Fabio PorceddaOnly compile tested.
--- Documentation/devicetree/bindings/watchdog/marvel.txt | 5 +++++ drivers/watchdog/orion_wdt.c | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/watchdog/marvel.txt +5 -0
@@ -5,10 +5,15 @@ Required Properties: - Compatibility : "marvell,orion-wdt" - reg : Address of the timer registers +Optional properties: + +- timeout-sec : Contains the watchdog timeout in seconds + Example: wdt at 20300 { compatible = "marvell,orion-wdt"; reg = <0x20300 0x28>; + timeout-sec = <10>; status = "okay"; };
drivers/watchdog/orion_wdt.c +3 -5
@@ -164,12 +164,10 @@ static int orion_wdt_probe(struct platform_device *pdev) wdt_max_duration =WDT_MAX_CYCLE_COUNT / wdt_tclk; -if ((heartbeat <1 ) || (heartbeat > wdt_max_duration)) - heartbeat = wdt_max_duration; - - orion_wdt.timeout = heartbeat; orion_wdt.min_timeout =1 ; + orion_wdt.timeout = wdt_max_duration; orion_wdt.max_timeout = wdt_max_duration; +watchdog_init_timeout (&orion_wdt, heartbeat, &pdev->dev);watchdog_set_nowayout (&orion_wdt, nowayout); ret =watchdog_register_device (&orion_wdt);
@@ -179,7 +177,7 @@ static int orion_wdt_probe(struct platform_device *pdev) }pr_info ("Initial timeout %d sec%s\n" , - heartbeat, nowayout ?", nowayout" :"" ); + orion_wdt.timeout, nowayout ?", nowayout" :"" );return 0 ; }
Signature · 1 line
1.8.1.1
PATCH v9 4/8 watchdog: pnx4008: add timeout-sec property binding
In reply to Fabio PorceddaOnly compile tested.
--- Documentation/devicetree/bindings/watchdog/pnx4008-wdt.txt | 4 ++++ drivers/watchdog/pnx4008_wdt.c | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/watchdog/pnx4008-wdt.txt +4 -0
@@ -5,9 +5,13 @@ Required properties: - reg: physical base address of the controller and length of memory mapped region. +Optional properties: +- timeout-sec: contains the watchdog timeout in seconds. + Example: watchdog at 4003C000 { compatible = "nxp,pnx4008-wdt"; reg = <0x4003C000 0x1000>; + timeout-sec = <10>; };
drivers/watchdog/pnx4008_wdt.c +3 -4
@@ -142,6 +142,7 @@ static const struct watchdog_ops pnx4008_wdt_ops = {static struct watchdog_device pnx4008_wdd = { .info = &pnx4008_wdt_ident, .ops = &pnx4008_wdt_ops, + .timeout =DEFAULT_HEARTBEAT , .min_timeout =1 , .max_timeout =MAX_HEARTBEAT , };
@@ -151,8 +152,7 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)struct resource *r;int ret =0 ; -if (heartbeat <1 || heartbeat >MAX_HEARTBEAT ) - heartbeat =DEFAULT_HEARTBEAT ; +watchdog_init_timeout (&pnx4008_wdd, heartbeat, &pdev->dev); r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); wdt_base =devm_request_and_ioremap (&pdev->dev, r);
@@ -167,7 +167,6 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)if (ret) goto out; - pnx4008_wdd.timeout = heartbeat; pnx4008_wdd.bootstatus = (readl (WDTIM_RES (wdt_base)) &WDOG_RESET ) ?WDIOF_CARDRESET :0 ;watchdog_set_nowayout (&pnx4008_wdd, nowayout);
@@ -181,7 +180,7 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) }dev_info (&pdev->dev,"PNX4008 Watchdog Timer: heartbeat %d sec\n" , - heartbeat); + pnx4008_wdd.timeout);return 0 ;
Signature · 1 line
1.8.1.1
PATCH v9 5/8 watchdog: s3c2410_wdt: add timeout-sec property binding
In reply to Fabio PorceddaOnly compile tested.
--- Documentation/devicetree/bindings/watchdog/samsung-wdt.txt | 3 +++ drivers/watchdog/s3c2410_wdt.c | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +3 -0
@@ -9,3 +9,6 @@ Required properties: - reg : base physical address of the controller and length of memory mapped region. - interrupts : interrupt number to the cpu. + +Optional properties: +- timeout-sec : contains the watchdog timeout in seconds.
drivers/watchdog/s3c2410_wdt.c +4 -2
@@ -53,7 +53,7 @@#define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME (15)static bool nowayout =WATCHDOG_NOWAYOUT ; -static int tmr_margin =CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME ; +static int tmr_margin;static int tmr_atboot =CONFIG_S3C2410_WATCHDOG_ATBOOT ;static int soft_noboot;static int debug;
@@ -226,6 +226,7 @@ static struct watchdog_ops s3c2410wdt_ops = {static struct watchdog_device s3c2410_wdd = { .info = &s3c2410_wdt_ident, .ops = &s3c2410wdt_ops, + .timeout =CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME , };/* interrupt handler code */
@@ -356,7 +357,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev)/* see if we can actually set the requested timer margin, and if * not, try the default value */ -if (s3c2410wdt_set_heartbeat (&s3c2410_wdd, tmr_margin)) { +watchdog_init_timeout (&s3c2410_wdd, tmr_margin, &pdev->dev); +if (s3c2410wdt_set_heartbeat (&s3c2410_wdd, s3c2410_wdd.timeout)) { started =s3c2410wdt_set_heartbeat (&s3c2410_wdd,CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME );
Signature · 1 line
1.8.1.1
PATCH v9 6/8 watchdog: at91sam9_wdt: add timeout-sec property binding
In reply to Fabio PorceddaTested on at91sam9260 board (evk-pro3).
--- Documentation/devicetree/bindings/watchdog/atmel-wdt.txt | 4 ++++ drivers/watchdog/Kconfig | 1 + drivers/watchdog/at91sam9_wdt.c | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/watchdog/atmel-wdt.txt +4 -0
@@ -7,9 +7,13 @@ Required properties: - reg: physical base address of the controller and length of memory mapped region. +Optional properties: +- timeout-sec: contains the watchdog timeout in seconds. + Example: watchdog at fffffd40 { compatible = "atmel,at91sam9260-wdt"; reg = <0xfffffd40 0x10>; + timeout-sec = <10>; };
drivers/watchdog/Kconfig +1 -0
@@ -125,6 +125,7 @@ config AT91RM9200_WATCHDOG config AT91SAM9X_WATCHDOG tristate "AT91SAM9X / AT91CAP9 watchdog" depends on ARCH_AT91 && !ARCH_AT91RM9200 + select WATCHDOG_CORE help Watchdog timer embedded into AT91SAM9X and AT91CAP9 chips. This will reboot your system when the timeout is reached.
drivers/watchdog/at91sam9_wdt.c +13 -3
@@ -57,8 +57,10 @@#define WDT_TIMEOUT (HZ/2)/* User land timeout */ +#define MIN_HEARTBEAT 1 +#define MAX_HEARTBEAT 16#define WDT_HEARTBEAT 15 -static int heartbeat =WDT_HEARTBEAT ; +static int heartbeat;module_param (heartbeat, int,0 ); MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. " "(default = " __MODULE_STRING(WDT_HEARTBEAT) ")");
@@ -255,6 +257,12 @@ static struct miscdevice at91wdt_miscdev = { .fops = &at91wdt_fops, }; +static struct watchdog_device at91wdt_wdd__initdata = { + .timeout =WDT_HEARTBEAT , + .min_timeout =MIN_HEARTBEAT , + .max_timeout =MAX_HEARTBEAT , +}; +static int __init at91wdt_probe (struct platform_device *pdev) {struct resource *r;
@@ -273,6 +281,8 @@ static int __init at91wdt_probe(struct platform_device *pdev)return -ENOMEM ; } +watchdog_init_timeout (&at91wdt_wdd, heartbeat, &pdev->dev); +/* Set watchdog */ res =at91_wdt_settimeout (ms_to_ticks (WDT_HW_TIMEOUT *1000 ));if (res)
@@ -282,12 +292,12 @@ static int __init at91wdt_probe(struct platform_device *pdev)if (res)return res; - at91wdt_private.next_heartbeat = jiffies + heartbeat *HZ ; + at91wdt_private.next_heartbeat = jiffies + at91wdt_wdd.timeout *HZ ;setup_timer (&at91wdt_private.timer, at91_ping,0 );mod_timer (&at91wdt_private.timer, jiffies +WDT_TIMEOUT );pr_info ("enabled (heartbeat=%d sec, nowayout=%d)\n" , - heartbeat, nowayout); + at91wdt_wdd.timeout, nowayout);return 0 ; }
Signature · 1 line
1.8.1.1
PATCH v9 7/8 watchdog: orion_wdt: move the min_timeout initialization
In reply to Fabio PorceddaMove the min_timeout initialization inside the orion_wdt definition.
Only compile tested.
--- drivers/watchdog/orion_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/orion_wdt.c +1 -1
@@ -140,6 +140,7 @@ static const struct watchdog_ops orion_wdt_ops = {static struct watchdog_device orion_wdt = { .info = &orion_wdt_info, .ops = &orion_wdt_ops, + .min_timeout =1 , };static int orion_wdt_probe (struct platform_device *pdev)
@@ -164,7 +165,6 @@ static int orion_wdt_probe(struct platform_device *pdev) wdt_max_duration =WDT_MAX_CYCLE_COUNT / wdt_tclk; - orion_wdt.min_timeout =1 ; orion_wdt.timeout = wdt_max_duration; orion_wdt.max_timeout = wdt_max_duration;watchdog_init_timeout (&orion_wdt, heartbeat, &pdev->dev);
Signature · 1 line
1.8.1.1
PATCH v9 8/8 watchdog: code: fix the alignement of some function declarations
In reply to Fabio Porcedda--- drivers/watchdog/watchdog_core.c | 2 +- drivers/watchdog/watchdog_dev.c | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-)
drivers/watchdog/watchdog_core.c +1 -1
@@ -70,7 +70,7 @@ static void watchdog_check_min_max_timeout(struct watchdog_device *wdd)* A zero is returned on success and -EINVAL for failure. */ int watchdog_init_timeout (struct watchdog_device *wdd, -unsigned int timeout_parm,struct device *dev) +unsigned int timeout_parm,struct device *dev) {unsigned int t =0 ;int ret =0 ;
drivers/watchdog/watchdog_dev.c +6 -11
@@ -162,8 +162,7 @@ out_stop:* Get the watchdog's status flags. */ -static int watchdog_get_status (struct watchdog_device *wddev, -unsigned int *status) +static int watchdog_get_status (struct watchdog_device *wddev,uint *status) {int err =0 ;
@@ -191,8 +190,7 @@ out_status:* @timeout: timeout to set in seconds */ -static int watchdog_set_timeout (struct watchdog_device *wddev, -unsigned int timeout) +static int watchdog_set_timeout (struct watchdog_device *wddev,uint timeout) {int err;
@@ -225,8 +223,7 @@ out_timeout:* Get the time before a watchdog will reboot (if not pinged). */ -static int watchdog_get_timeleft (struct watchdog_device *wddev, -unsigned int *timeleft) +static int watchdog_get_timeleft (struct watchdog_device *wddev,uint *timeleft) {int err =0 ;
@@ -255,8 +252,7 @@ out_timeleft:* @arg: argument pointer */ -static int watchdog_ioctl_op (struct watchdog_device *wddev,unsigned int cmd, -unsigned long arg) +static int watchdog_ioctl_op (struct watchdog_device *wddev,uint cmd,ulong arg) {int err;
@@ -290,7 +286,7 @@ out_ioctl:*/ static ssize_t watchdog_write (struct file *file,const char __user *data, -size_t len,loff_t *ppos) +size_t len,loff_t *ppos) {struct watchdog_device *wdd = file->private_data;size_t i;
@@ -329,8 +325,7 @@ static ssize_t watchdog_write(struct file *file, const char __user *data,* according to their available features. */ -static long watchdog_ioctl (struct file *file,unsigned int cmd, -unsigned long arg) +static long watchdog_ioctl (struct file *file,unsigned int cmd,ulong arg) {struct watchdog_device *wdd = file->private_data;void __user *argp = (void __user *)arg;
Signature · 1 line
1.8.1.1
A message that is not in the archive (sent off-list or not yet received): 1360829670-10418-1-git-send-email-fabio.porcedda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Hi Fabio,
Quoted 11 lines
Hi all,
this patchset add the timeout-sec property to the watchdog core, to theat91sam9_wdtdriver and on all framework enabled watchdog driver with dt support.
Theat91sam9_wdtis tested on evk-pr3,
the other drivers are compile tested only.Hi Wim,
because the first two patches are fixes for the
patch433bf8dc344c0eacb3ff5bbc1aea42f75b170a72already included in watchdog-next feel free to squash them.
added to linux-watchdog-next.
Kind regards,
Wim.