From: linux@roeck-us.net (Guenter Roeck) Date: Wed, 24 May 2017 17:58:33 -0700 Subject: [PATCH v4 2/3] watchdog: dw_wdt: get reset lines from dt In-Reply-To: <17fdba7aa0c8f356cfdc28792d228817030b152e.1495443015.git-series.s.trumtrar@pengutronix.de> References: <17fdba7aa0c8f356cfdc28792d228817030b152e.1495443015.git-series.s.trumtrar@pengutronix.de> Message-ID: <7f9bbdf3-46a5-0fa8-d13b-fb24d502d709@roeck-us.net> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 05/22/2017 01:51 AM, Steffen Trumtrar wrote: > 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: Wim Van Sebroeck > Cc: Guenter Roeck > Cc: linux-watchdog at vger.kernel.org > Reviewed-by: Philipp Zabel Reviewed-by: Guenter Roeck > --- > drivers/watchdog/dw_wdt.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c > index 914da3a4d334..36be987ff9ef 100644 > --- a/drivers/watchdog/dw_wdt.c > +++ b/drivers/watchdog/dw_wdt.c > @@ -29,6 +29,7 @@ > #include > #include > #include > +#include > #include > > #define WDOG_CONTROL_REG_OFFSET 0x00 > @@ -54,6 +55,7 @@ struct dw_wdt { > struct clk *clk; > unsigned long rate; > struct watchdog_device wdd; > + struct reset_control *rst; > }; > > #define to_dw_wdt(wdd) container_of(wdd, struct dw_wdt, wdd) > @@ -234,6 +236,14 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) > goto out_disable_clk; > } > > + dw_wdt->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL); > + if (IS_ERR(dw_wdt->rst)) { > + ret = PTR_ERR(dw_wdt->rst); > + goto out_disable_clk; > + } > + > + reset_control_deassert(dw_wdt->rst); > + > wdd = &dw_wdt->wdd; > wdd->info = &dw_wdt_ident; > wdd->ops = &dw_wdt_ops; > @@ -279,6 +289,7 @@ static int dw_wdt_drv_remove(struct platform_device *pdev) > struct dw_wdt *dw_wdt = platform_get_drvdata(pdev); > > watchdog_unregister_device(&dw_wdt->wdd); > + reset_control_assert(dw_wdt->rst); > clk_disable_unprepare(dw_wdt->clk); > > return 0; >