devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabrizio Castro <fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
To: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Wim Van Sebroeck <wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org>,
	Russell King <linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>,
	Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>,
	Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
	Michael Turquette
	<mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>,
	Stephen Boyd <sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Simon Horman <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>,
	Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Geert Uytterhoeven
	<geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>,
	Wolfram Sang
	<wsa+renesas-jBu1N2QxHDJrcw3mvpCnnVaTQe2KTcn/@public.gmane.org>
Cc: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>,
	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
	<Chris.Paterson2-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>,
	Biju Das <biju.das-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>,
	Fabrizio Castro
	<fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>,
	Ramesh Shanmugasundaram
	<ramesh.shanmugasundaram-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
Subject: [RFC v3 11/25] watchdog: renesas_wdt: Add R-Car Gen2 support
Date: Tue, 30 Jan 2018 20:22:44 +0000	[thread overview]
Message-ID: <1517343778-27902-12-git-send-email-fabrizio.castro@bp.renesas.com> (raw)
In-Reply-To: <1517343778-27902-1-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>

On R-Car Gen2 and RZ/G1 the rwdt clock needs to be always ON, therefore
when suspending to RAM we need to explicitly disable the counting by
clearing TME from RWTCSRA.
Also, on some systems RWDT is the only piece of HW that allows the SoC
to be restarted, therefore this patch implements the restart callback.

Signed-off-by: Fabrizio Castro <fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
Signed-off-by: Ramesh Shanmugasundaram <ramesh.shanmugasundaram-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
---
Wolfram, was the restart callback implementation missing for a reason?
Is its implementation going to break any Gen3 platform?

v1->v3:
* unified Gen2 and Gen3 drivers.

 drivers/watchdog/renesas_wdt.c | 61 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 56 insertions(+), 5 deletions(-)

diff --git a/drivers/watchdog/renesas_wdt.c b/drivers/watchdog/renesas_wdt.c
index 831ef83..eedb016 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)
@@ -203,13 +222,42 @@ static int rwdt_remove(struct platform_device *pdev)
 	return 0;
 }
 
-/*
- * This driver does also fit for R-Car Gen2 (r8a779[0-4]) WDT. However, for SMP
- * to work there, one also needs a RESET (RST) driver which does not exist yet
- * due to HW issues. This needs to be solved before adding compatibles here.
- */
+#ifdef CONFIG_PM
+static int rwdt_suspend(struct device *dev)
+{
+	struct platform_device *pdev;
+	struct rwdt_priv *priv;
+
+	pdev = to_platform_device(dev);
+	priv = platform_get_drvdata(pdev);
+	if (watchdog_active(&priv->wdev)) {
+		rwdt_write(priv, priv->cks, RWTCSRA);
+	}
+	return 0;
+}
+
+static int rwdt_resume(struct device *dev)
+{
+	struct platform_device *pdev;
+	struct rwdt_priv *priv;
+
+	pdev = to_platform_device(dev);
+	priv = platform_get_drvdata(pdev);
+	if (watchdog_active(&priv->wdev)) {
+		rwdt_write(priv, priv->cks | RWTCSRA_TME, RWTCSRA);
+	}
+	return 0;
+}
+
+static const struct dev_pm_ops rwdt_pm = {
+	.suspend = rwdt_suspend,
+	.resume = rwdt_resume,
+};
+#endif
+
 static const struct of_device_id rwdt_ids[] = {
 	{ .compatible = "renesas,rcar-gen3-wdt", },
+	{ .compatible = "renesas,rcar-gen2-wdt", },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, rwdt_ids);
@@ -218,6 +266,9 @@ static struct platform_driver rwdt_driver = {
 	.driver = {
 		.name = "renesas_wdt",
 		.of_match_table = rwdt_ids,
+#ifdef CONFIG_PM
+		.pm = &rwdt_pm,
+#endif
 	},
 	.probe = rwdt_probe,
 	.remove = rwdt_remove,
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2018-01-30 20:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30 20:22 [RFC v3 00/25] Fix watchdog on Renesas R-Car Gen2 and RZ/G1 Fabrizio Castro
2018-01-30 20:22 ` [RFC v3 03/25] ARM: dts: r8a7745: Adjust SMP routine size Fabrizio Castro
     [not found]   ` <1517343778-27902-4-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
2018-01-31  8:42     ` Geert Uytterhoeven
2018-01-30 20:22 ` [RFC v3 06/25] ARM: dts: r8a7792: " Fabrizio Castro
2018-01-31  8:43   ` Geert Uytterhoeven
2018-01-30 20:22 ` [RFC v3 12/25] ARM: shmobile: rcar-gen2: Add watchdog support Fabrizio Castro
     [not found] ` <1517343778-27902-1-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
2018-01-30 20:22   ` [RFC v3 01/25] ARM: shmobile: " Fabrizio Castro
2018-01-30 20:22   ` [RFC v3 02/25] ARM: dts: r8a7743: Adjust SMP routine size Fabrizio Castro
     [not found]     ` <1517343778-27902-3-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
2018-01-31  8:42       ` Geert Uytterhoeven
2018-01-30 20:22   ` [RFC v3 04/25] ARM: dts: r8a7790: " Fabrizio Castro
     [not found]     ` <1517343778-27902-5-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
2018-01-31  8:43       ` Geert Uytterhoeven
2018-01-30 20:22   ` [RFC v3 05/25] ARM: dts: r8a7791: " Fabrizio Castro
     [not found]     ` <1517343778-27902-6-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
2018-01-31  8:43       ` Geert Uytterhoeven
2018-01-30 20:22   ` [RFC v3 07/25] ARM: dts: r8a7793: " Fabrizio Castro
     [not found]     ` <1517343778-27902-8-git-send-email-fabrizio.castro-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org>
2018-01-31  8:43       ` Geert Uytterhoeven
2018-01-30 20:22   ` [RFC v3 08/25] ARM: dts: r8a7794: " Fabrizio Castro
2018-01-31  8:44     ` Geert Uytterhoeven
2018-01-30 20:22   ` [RFC v3 09/25] soc: renesas: rcar-rst: Enable watchdog as reset trigger for Gen2 Fabrizio Castro
2018-01-30 20:22   ` [RFC v3 10/25] dt-bindings: watchdog: renesas-wdt: Add R-Car Gen2 support Fabrizio Castro
2018-01-31  8:46     ` Geert Uytterhoeven
     [not found]       ` <CAMuHMdXkHF9R0XfcG++s0RRup+Mdtam5p=FXw26z86wAOJhZfQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-01-31 10:27         ` Fabrizio Castro
2018-01-30 20:22   ` Fabrizio Castro [this message]
2018-01-30 22:05     ` [RFC v3 11/25] watchdog: renesas_wdt: " Guenter Roeck
     [not found]       ` <20180130220504.GA16709-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2018-01-31 10:47         ` Fabrizio Castro
     [not found]           ` <TY1PR06MB0895ECB2936323F9D281C1EFC0FB0-/PRLmSCtZ16EeHdvShrxA20DtJ1/0DrXvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-01-31 12:13             ` Geert Uytterhoeven
2018-01-31 13:58               ` Fabrizio Castro
2018-01-31 14:48               ` Guenter Roeck
2018-01-31 15:27                 ` Fabrizio Castro
     [not found]                 ` <007dd1e3-70fd-69ad-fd02-4719e958b41c-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2018-01-31 15:37                   ` Geert Uytterhoeven
2018-01-30 20:22   ` [RFC v3 13/25] ARM: shmobile: defconfig: Enable CONFIG_RENESAS_WDT Fabrizio Castro
2018-01-30 20:22   ` [RFC v3 14/25] clk: renesas: r8a7743: Add rwdt clock Fabrizio Castro
2018-01-30 20:22   ` [RFC v3 15/25] clk: renesas: r8a7745: " Fabrizio Castro
2018-01-30 20:22   ` [RFC v3 16/25] clk: renesas: r8a7790: " Fabrizio Castro
2018-01-30 20:22   ` [RFC v3 20/25] ARM: dts: r8a7745: Add watchdog support to SoC dtsi Fabrizio Castro
2018-01-30 20:22   ` [RFC v3 21/25] ARM: dts: r8a7790: " Fabrizio Castro
2018-01-30 20:22 ` [RFC v3 17/25] clk: renesas: r8a7791/r8a7793: Add rwdt clock Fabrizio Castro
2018-01-30 20:22 ` [RFC v3 18/25] clk: renesas: r8a7794: " Fabrizio Castro
2018-01-30 20:22 ` [RFC v3 19/25] ARM: dts: r8a7743: Add watchdog support to SoC dtsi Fabrizio Castro
2018-01-30 20:22 ` [RFC v3 22/25] ARM: dts: r8a7791: " Fabrizio Castro
2018-01-30 20:22 ` [RFC v3 23/25] ARM: dts: r8a7794: " Fabrizio Castro
2018-01-30 20:22 ` [RFC v3 24/25] ARM: dts: iwg20m: Add watchdog support to SoM dtsi Fabrizio Castro
2018-01-30 20:22 ` [RFC v3 25/25] ARM: dts: iwg22m: " Fabrizio Castro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517343778-27902-12-git-send-email-fabrizio.castro@bp.renesas.com \
    --to=fabrizio.castro-ktt6de0ptrh9uiusa/gsgq@public.gmane.org \
    --cc=Chris.Paterson2-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org \
    --cc=biju.das-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org \
    --cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org \
    --cc=horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org \
    --cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
    --cc=linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=mturquette-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
    --cc=p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=ramesh.shanmugasundaram-kTT6dE0pTRh9uiUsa/gSgQ@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
    --cc=wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org \
    --cc=wsa+renesas-jBu1N2QxHDJrcw3mvpCnnVaTQe2KTcn/@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).