Commit 2b77f008 authored by Marcus Folkesson's avatar Marcus Folkesson Committed by Wim Van Sebroeck

watchdog: imx2_wdt: allow setting timeout in devicetree

By following best practice described in
Documentation/watchdog/watchdog-kernel-api.txt, it also let us to set
timout-sec property in devicetree.
Signed-off-by: default avatarMarcus Folkesson <marcus.folkesson@gmail.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 2b3d89b4
...@@ -11,6 +11,7 @@ Optional properties: ...@@ -11,6 +11,7 @@ Optional properties:
detail please see: Documentation/devicetree/bindings/regmap/regmap.txt. detail please see: Documentation/devicetree/bindings/regmap/regmap.txt.
- fsl,ext-reset-output: If present the watchdog device is configured to - fsl,ext-reset-output: If present the watchdog device is configured to
assert its external reset (WDOG_B) instead of issuing a software reset. assert its external reset (WDOG_B) instead of issuing a software reset.
- timeout-sec : Contains the watchdog timeout in seconds
Examples: Examples:
...@@ -19,4 +20,5 @@ wdt@73f98000 { ...@@ -19,4 +20,5 @@ wdt@73f98000 {
reg = <0x73f98000 0x4000>; reg = <0x73f98000 0x4000>;
interrupts = <58>; interrupts = <58>;
big-endian; big-endian;
timeout-sec = <20>;
}; };
...@@ -76,7 +76,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" ...@@ -76,7 +76,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
static unsigned timeout = IMX2_WDT_DEFAULT_TIME; static unsigned timeout;
module_param(timeout, uint, 0); module_param(timeout, uint, 0);
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=" MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default="
__MODULE_STRING(IMX2_WDT_DEFAULT_TIME) ")"); __MODULE_STRING(IMX2_WDT_DEFAULT_TIME) ")");
...@@ -281,6 +281,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) ...@@ -281,6 +281,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
wdog->info = &imx2_wdt_info; wdog->info = &imx2_wdt_info;
wdog->ops = &imx2_wdt_ops; wdog->ops = &imx2_wdt_ops;
wdog->min_timeout = 1; wdog->min_timeout = 1;
wdog->timeout = IMX2_WDT_DEFAULT_TIME;
wdog->max_hw_heartbeat_ms = IMX2_WDT_MAX_TIME * 1000; wdog->max_hw_heartbeat_ms = IMX2_WDT_MAX_TIME * 1000;
wdog->parent = &pdev->dev; wdog->parent = &pdev->dev;
...@@ -299,11 +300,6 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) ...@@ -299,11 +300,6 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
wdev->ext_reset = of_property_read_bool(pdev->dev.of_node, wdev->ext_reset = of_property_read_bool(pdev->dev.of_node,
"fsl,ext-reset-output"); "fsl,ext-reset-output");
wdog->timeout = clamp_t(unsigned, timeout, 1, IMX2_WDT_MAX_TIME);
if (wdog->timeout != timeout)
dev_warn(&pdev->dev, "Initial timeout out of range! Clamped from %u to %u\n",
timeout, wdog->timeout);
platform_set_drvdata(pdev, wdog); platform_set_drvdata(pdev, wdog);
watchdog_set_drvdata(wdog, wdev); watchdog_set_drvdata(wdog, wdev);
watchdog_set_nowayout(wdog, nowayout); watchdog_set_nowayout(wdog, nowayout);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment