From 328f02596a27fb38f46979afac04d00aaa16b8d9 Mon Sep 17 00:00:00 2001 From: Steffen Trumtrar Date: Mon, 22 May 2017 10:51:39 +0200 Subject: [PATCH] BACKPORT: watchdog: dw_wdt: get reset lines from dt The dw_wdt has an external reset line, that can keep the device in reset and therefore rendering it useless and also is the only way of stopping the watchdog once it was started. Get the reset lines for this core from the devicetree. As these lines are optional, use devm_reset_control_get_optional_shared. If the reset line is not specified in the devicetree, the reset framework will just skip deasserting and continue. This way all users of the driver will continue to function without any harm, even if the reset line is not specified in the devicetree. Signed-off-by: Steffen Trumtrar Cc: linux-watchdog@vger.kernel.org Reviewed-by: Philipp Zabel Reviewed-by: Guenter Roeck Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck (cherry picked from commit 65a3b6935d920a37820226864eb607467e49ba50) Conflicts: drivers/watchdog/dw_wdt.c Change-Id: Iffbc95931869a5d595a348b6c08ee7da5a1e64e4 Signed-off-by: Ziyuan Xu --- drivers/watchdog/dw_wdt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c index cbe58aac5d8c..8c2021a79708 100644 --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +70,7 @@ static struct { struct timer_list timer; int expect_close; struct notifier_block restart_handler; + struct reset_control *rst; /* Save/restore */ u32 control; u32 timeout; @@ -367,6 +369,13 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) goto out_disable_clk; } + dw_wdt.rst = devm_reset_control_get(&pdev->dev, "reset"); + if (IS_ERR(dw_wdt.rst)) + dev_warn(&pdev->dev, "Should better to setup a \'resets\' " + "property in dt, that must been named with reset\n"); + else + reset_control_deassert(dw_wdt.rst); + ret = misc_register(&dw_wdt_miscdev); if (ret) goto out_disable_clk; @@ -394,7 +403,8 @@ static int dw_wdt_drv_remove(struct platform_device *pdev) unregister_restart_handler(&dw_wdt.restart_handler); misc_deregister(&dw_wdt_miscdev); - + if (!IS_ERR(dw_wdt.rst)) + reset_control_assert(dw_wdt.rst); clk_disable_unprepare(dw_wdt.clk); return 0;