From 4bba08dda402172727c14d8e363a3dda38293548 Mon Sep 17 00:00:00 2001 From: George Cherian Date: Tue, 10 Jun 2014 10:10:06 +0530 Subject: watchdog: dw_wdt: Remove the un-necessary check after platform_get_resource() devm_ioremap_resource() checks for valid resource. Remove the un-necessary check after platform_get_resource(). Signed-off-by: George Cherian Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/dw_wdt.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c index ee4f86ba83ec..9f210299de24 100644 --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c @@ -296,9 +296,6 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) int ret; struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem) - return -EINVAL; - dw_wdt.regs = devm_ioremap_resource(&pdev->dev, mem); if (IS_ERR(dw_wdt.regs)) return PTR_ERR(dw_wdt.regs); -- cgit v1.2.3 From 37f152915fba723de7e5bf43ade3bd971977b724 Mon Sep 17 00:00:00 2001 From: George Cherian Date: Tue, 10 Jun 2014 10:10:07 +0530 Subject: watchdog: lantiq_wdt: Remove the un-necessary check of resource after platform_get_resource() devm_ioremap_resource() checks for valid resource. Remove the un-necessary check after platform_get_resource(). Signed-off-by: George Cherian Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/lantiq_wdt.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/watchdog/lantiq_wdt.c b/drivers/watchdog/lantiq_wdt.c index 3b3148c764a3..021e84eb88eb 100644 --- a/drivers/watchdog/lantiq_wdt.c +++ b/drivers/watchdog/lantiq_wdt.c @@ -192,11 +192,6 @@ ltq_wdt_probe(struct platform_device *pdev) struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); struct clk *clk; - if (!res) { - dev_err(&pdev->dev, "cannot obtain I/O memory region"); - return -ENOENT; - } - ltq_wdt_membase = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(ltq_wdt_membase)) return PTR_ERR(ltq_wdt_membase); -- cgit v1.2.3 From 2cdf25bb574c20efde0340ffa90f08d1609ef97c Mon Sep 17 00:00:00 2001 From: George Cherian Date: Tue, 10 Jun 2014 10:10:08 +0530 Subject: watchdog: shwdt: Remove the unnecessary check of resource after platform_get_resource() devm_ioremap_resource check for a valid resource. Remove the unnecessary check. Also group platform_get_resource and devm_ioremap_resource together for better readability. Signed-off-by: George Cherian Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/shwdt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c index 061756e36cf8..fa89bb30d004 100644 --- a/drivers/watchdog/shwdt.c +++ b/drivers/watchdog/shwdt.c @@ -230,10 +230,6 @@ static int sh_wdt_probe(struct platform_device *pdev) if (pdev->id != -1) return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (unlikely(!res)) - return -EINVAL; - wdt = devm_kzalloc(&pdev->dev, sizeof(struct sh_wdt), GFP_KERNEL); if (unlikely(!wdt)) return -ENOMEM; @@ -249,6 +245,7 @@ static int sh_wdt_probe(struct platform_device *pdev) wdt->clk = NULL; } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt->base = devm_ioremap_resource(wdt->dev, res); if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); -- cgit v1.2.3 From f728f4bfc495a588abda4661c09595112677be25 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Tue, 3 Jun 2014 10:45:14 +0800 Subject: watchdog: imx2_wdt: adds big endianness support. This watchdog driver will be working on IMX2+, Vybrid, LS1, LS2+ platforms, and will be in different endianness mode in those SoCs: SoCs WDT endian mode ------------------------------------ IMX2+ LE Vybird LE LS1 BE LS2 LE Signed-off-by: Xiubo Li Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt | 5 +++++ drivers/watchdog/imx2_wdt.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt b/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt index 2144af1a5264..e52ba2da868c 100644 --- a/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt +++ b/Documentation/devicetree/bindings/watchdog/fsl-imx-wdt.txt @@ -5,10 +5,15 @@ Required properties: - reg : Should contain WDT registers location and length - interrupts : Should contain WDT interrupt +Optional property: +- big-endian: If present the watchdog device's registers are implemented + in big endian mode, otherwise in little mode. + Examples: wdt@73f98000 { compatible = "fsl,imx51-wdt", "fsl,imx21-wdt"; reg = <0x73f98000 0x4000>; interrupts = <58>; + big-endian; }; diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index 9d4874f09948..68c3d379ffa8 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -190,10 +191,12 @@ static struct regmap_config imx2_wdt_regmap_config = { static int __init imx2_wdt_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct imx2_wdt_device *wdev; struct watchdog_device *wdog; struct resource *res; void __iomem *base; + bool big_endian; int ret; u32 val; @@ -201,6 +204,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) if (!wdev) return -ENOMEM; + big_endian = of_property_read_bool(np, "big-endian"); + if (big_endian) + imx2_wdt_regmap_config.val_format_endian = REGMAP_ENDIAN_BIG; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) -- cgit v1.2.3 From 5be876cf7e6feeca6dc2bbdb3f1fa0167e13621d Mon Sep 17 00:00:00 2001 From: Sangjung Woo Date: Wed, 30 Jul 2014 09:56:21 +0900 Subject: Documentation: fix two typos in watchdog-api.txt This patch changes 'go of' to 'go off' and 'pretimout' to 'pretimeout'. Signed-off-by: Sangjung Woo Acked-by: Randy Dunlap Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- Documentation/watchdog/watchdog-api.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/watchdog/watchdog-api.txt b/Documentation/watchdog/watchdog-api.txt index eb7132ed8bbc..b3a701f48118 100644 --- a/Documentation/watchdog/watchdog-api.txt +++ b/Documentation/watchdog/watchdog-api.txt @@ -118,7 +118,7 @@ resets. Note that the pretimeout is the number of seconds before the time when the timeout will go off. It is not the number of seconds until the pretimeout. So, for instance, if you set the timeout to 60 seconds -and the pretimeout to 10 seconds, the pretimout will go of in 50 +and the pretimeout to 10 seconds, the pretimeout will go off in 50 seconds. Setting a pretimeout to zero disables it. There is also a get function for getting the pretimeout: -- cgit v1.2.3 From 440e96bc770eb98b17a763defb9641c77f9a7755 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 6 May 2014 21:44:19 -0500 Subject: wdt: sunxi: Move restart code to the watchdog driver Most of the watchdog code is duplicated between the machine restart code and the watchdog driver. Add the restart hook to the watchdog driver, to be able to remove it from the machine code eventually. Signed-off-by: Maxime Ripard Acked-by: Arnd Bergmann Reviewed-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/sunxi_wdt.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c index 693b9d2c6e39..60deb9d304c0 100644 --- a/drivers/watchdog/sunxi_wdt.c +++ b/drivers/watchdog/sunxi_wdt.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -22,9 +23,12 @@ #include #include #include +#include #include #include +#include + #define WDT_MAX_TIMEOUT 16 #define WDT_MIN_TIMEOUT 1 #define WDT_MODE_TIMEOUT(n) ((n) << 3) @@ -70,6 +74,26 @@ static const int wdt_timeout_map[] = { [16] = 0xB, /* 16s */ }; +static void __iomem *reboot_wdt_base; + +static void sun4i_wdt_restart(enum reboot_mode mode, const char *cmd) +{ + /* Enable timer and set reset bit in the watchdog */ + writel(WDT_MODE_EN | WDT_MODE_RST_EN, reboot_wdt_base + WDT_MODE); + + /* + * Restart the watchdog. The default (and lowest) interval + * value for the watchdog is 0.5s. + */ + writel(WDT_CTRL_RELOAD, reboot_wdt_base + WDT_CTRL); + + while (1) { + mdelay(5); + writel(WDT_MODE_EN | WDT_MODE_RST_EN, + reboot_wdt_base + WDT_MODE); + } +} + static int sunxi_wdt_ping(struct watchdog_device *wdt_dev) { struct sunxi_wdt_dev *sunxi_wdt = watchdog_get_drvdata(wdt_dev); @@ -181,6 +205,9 @@ static int sunxi_wdt_probe(struct platform_device *pdev) if (unlikely(err)) return err; + reboot_wdt_base = sunxi_wdt->wdt_base; + arm_pm_restart = sun4i_wdt_restart; + dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", sunxi_wdt->wdt_dev.timeout, nowayout); @@ -191,6 +218,8 @@ static int sunxi_wdt_remove(struct platform_device *pdev) { struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev); + arm_pm_restart = NULL; + watchdog_unregister_device(&sunxi_wdt->wdt_dev); watchdog_set_drvdata(&sunxi_wdt->wdt_dev, NULL); -- cgit v1.2.3