From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrizio Castro Subject: [RFC v4 13/26] watchdog: renesas_wdt: Add restart handler Date: Wed, 31 Jan 2018 18:24:17 +0000 Message-ID: <1517423070-24236-14-git-send-email-fabrizio.castro@bp.renesas.com> References: <1517423070-24236-1-git-send-email-fabrizio.castro@bp.renesas.com> Return-path: In-Reply-To: <1517423070-24236-1-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Philipp Zabel , Rob Herring , Mark Rutland , Wim Van Sebroeck , Russell King , Catalin Marinas , Will Deacon , Michael Turquette , Stephen Boyd , Simon Horman , Magnus Damm , Geert Uytterhoeven , Wolfram Sang Cc: Guenter Roeck , devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Chris Paterson , Biju Das , Fabrizio Castro , Ramesh Shanmugasundaram List-Id: devicetree@vger.kernel.org On iWave's boards iwg20d and iwg22d the only way to reboot the system is by means of the watchdog. This patch adds a restart handler to rwdt_ops, and also makes sure we keep its priority to a medium level, in order to not override other more effective handlers. Signed-off-by: Fabrizio Castro Signed-off-by: Ramesh Shanmugasundaram --- v3->v4: * New patch spawn out from patch 12/16. The restart handler on Gen3 is controversial, hopefully this patch will help finalizing the discussion. drivers/watchdog/renesas_wdt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c index 0a1a402..6d1c4b9 100644 --- a/drivers/watchdog/renesas_wdt.c +++ b/drivers/watchdog/renesas_wdt.c @@ -107,6 +107,24 @@ static unsigned int rwdt_get_timeleft(struct watchdog_device *wdev) return DIV_BY_CLKS_PER_SEC(priv, 65536 - val); } +static int rwdt_restart(struct watchdog_device *wdev, unsigned long action, + void *data) +{ + struct rwdt_priv *priv = watchdog_get_drvdata(wdev); + + pm_runtime_get_sync(wdev->parent); + + rwdt_write(priv, 0x00, RWTCSRB); + rwdt_write(priv, 0x00, RWTCSRA); + rwdt_write(priv, 0xffff, RWTCNT); + + while (readb_relaxed(priv->base + RWTCSRA) & RWTCSRA_WRFLG) + cpu_relax(); + + rwdt_write(priv, 0x80, RWTCSRA); + return 0; +} + static const struct watchdog_info rwdt_ident = { .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, .identity = "Renesas WDT Watchdog", @@ -118,6 +136,7 @@ static const struct watchdog_ops rwdt_ops = { .stop = rwdt_stop, .ping = rwdt_init_timeout, .get_timeleft = rwdt_get_timeleft, + .restart = rwdt_restart, }; static int rwdt_probe(struct platform_device *pdev) @@ -176,6 +195,7 @@ static int rwdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); watchdog_set_drvdata(&priv->wdev, priv); watchdog_set_nowayout(&priv->wdev, nowayout); + watchdog_set_restart_priority(&priv->wdev, 128); /* This overrides the default timeout only if DT configuration was found */ ret = watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relmlor2.renesas.com ([210.160.252.172]:15863 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751747AbeAaS0D (ORCPT ); Wed, 31 Jan 2018 13:26:03 -0500 From: Fabrizio Castro To: Philipp Zabel , Rob Herring , Mark Rutland , Wim Van Sebroeck , Russell King , Catalin Marinas , Will Deacon , Michael Turquette , Stephen Boyd , Simon Horman , Magnus Damm , Geert Uytterhoeven , Wolfram Sang Cc: Guenter Roeck , devicetree@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, Chris Paterson , Biju Das , Fabrizio Castro , Ramesh Shanmugasundaram Subject: [RFC v4 13/26] watchdog: renesas_wdt: Add restart handler Date: Wed, 31 Jan 2018 18:24:17 +0000 Message-Id: <1517423070-24236-14-git-send-email-fabrizio.castro@bp.renesas.com> In-Reply-To: <1517423070-24236-1-git-send-email-fabrizio.castro@bp.renesas.com> References: <1517423070-24236-1-git-send-email-fabrizio.castro@bp.renesas.com> Sender: linux-watchdog-owner@vger.kernel.org List-Id: linux-watchdog@vger.kernel.org On iWave's boards iwg20d and iwg22d the only way to reboot the system is by means of the watchdog. This patch adds a restart handler to rwdt_ops, and also makes sure we keep its priority to a medium level, in order to not override other more effective handlers. Signed-off-by: Fabrizio Castro Signed-off-by: Ramesh Shanmugasundaram --- v3->v4: * New patch spawn out from patch 12/16. The restart handler on Gen3 is controversial, hopefully this patch will help finalizing the discussion. drivers/watchdog/renesas_wdt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c index 0a1a402..6d1c4b9 100644 --- a/drivers/watchdog/renesas_wdt.c +++ b/drivers/watchdog/renesas_wdt.c @@ -107,6 +107,24 @@ static unsigned int rwdt_get_timeleft(struct watchdog_device *wdev) return DIV_BY_CLKS_PER_SEC(priv, 65536 - val); } +static int rwdt_restart(struct watchdog_device *wdev, unsigned long action, + void *data) +{ + struct rwdt_priv *priv = watchdog_get_drvdata(wdev); + + pm_runtime_get_sync(wdev->parent); + + rwdt_write(priv, 0x00, RWTCSRB); + rwdt_write(priv, 0x00, RWTCSRA); + rwdt_write(priv, 0xffff, RWTCNT); + + while (readb_relaxed(priv->base + RWTCSRA) & RWTCSRA_WRFLG) + cpu_relax(); + + rwdt_write(priv, 0x80, RWTCSRA); + return 0; +} + static const struct watchdog_info rwdt_ident = { .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, .identity = "Renesas WDT Watchdog", @@ -118,6 +136,7 @@ static const struct watchdog_ops rwdt_ops = { .stop = rwdt_stop, .ping = rwdt_init_timeout, .get_timeleft = rwdt_get_timeleft, + .restart = rwdt_restart, }; static int rwdt_probe(struct platform_device *pdev) @@ -176,6 +195,7 @@ static int rwdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); watchdog_set_drvdata(&priv->wdev, priv); watchdog_set_nowayout(&priv->wdev, nowayout); + watchdog_set_restart_priority(&priv->wdev, 128); /* This overrides the default timeout only if DT configuration was found */ ret = watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: fabrizio.castro@bp.renesas.com (Fabrizio Castro) Date: Wed, 31 Jan 2018 18:24:17 +0000 Subject: [RFC v4 13/26] watchdog: renesas_wdt: Add restart handler In-Reply-To: <1517423070-24236-1-git-send-email-fabrizio.castro@bp.renesas.com> References: <1517423070-24236-1-git-send-email-fabrizio.castro@bp.renesas.com> Message-ID: <1517423070-24236-14-git-send-email-fabrizio.castro@bp.renesas.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On iWave's boards iwg20d and iwg22d the only way to reboot the system is by means of the watchdog. This patch adds a restart handler to rwdt_ops, and also makes sure we keep its priority to a medium level, in order to not override other more effective handlers. Signed-off-by: Fabrizio Castro Signed-off-by: Ramesh Shanmugasundaram --- v3->v4: * New patch spawn out from patch 12/16. The restart handler on Gen3 is controversial, hopefully this patch will help finalizing the discussion. drivers/watchdog/renesas_wdt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c index 0a1a402..6d1c4b9 100644 --- a/drivers/watchdog/renesas_wdt.c +++ b/drivers/watchdog/renesas_wdt.c @@ -107,6 +107,24 @@ static unsigned int rwdt_get_timeleft(struct watchdog_device *wdev) return DIV_BY_CLKS_PER_SEC(priv, 65536 - val); } +static int rwdt_restart(struct watchdog_device *wdev, unsigned long action, + void *data) +{ + struct rwdt_priv *priv = watchdog_get_drvdata(wdev); + + pm_runtime_get_sync(wdev->parent); + + rwdt_write(priv, 0x00, RWTCSRB); + rwdt_write(priv, 0x00, RWTCSRA); + rwdt_write(priv, 0xffff, RWTCNT); + + while (readb_relaxed(priv->base + RWTCSRA) & RWTCSRA_WRFLG) + cpu_relax(); + + rwdt_write(priv, 0x80, RWTCSRA); + return 0; +} + static const struct watchdog_info rwdt_ident = { .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, .identity = "Renesas WDT Watchdog", @@ -118,6 +136,7 @@ static const struct watchdog_ops rwdt_ops = { .stop = rwdt_stop, .ping = rwdt_init_timeout, .get_timeleft = rwdt_get_timeleft, + .restart = rwdt_restart, }; static int rwdt_probe(struct platform_device *pdev) @@ -176,6 +195,7 @@ static int rwdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); watchdog_set_drvdata(&priv->wdev, priv); watchdog_set_nowayout(&priv->wdev, nowayout); + watchdog_set_restart_priority(&priv->wdev, 128); /* This overrides the default timeout only if DT configuration was found */ ret = watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); -- 2.7.4