devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
To: Shawn Guo <shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Wim Van Sebroeck <wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>,
	Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [RFC PATCH 1/2] watchdog: imx2: fix hang-up on boot for i.MX21, i.MX27 and i.MX31 SoCs
Date: Mon, 26 Sep 2016 03:39:20 +0300	[thread overview]
Message-ID: <1474850361-20884-2-git-send-email-vz@mleia.com> (raw)
In-Reply-To: <1474850361-20884-1-git-send-email-vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>

Power down counter enable/disable bit switch is located in WMCR
register, but watchdog controllers found on legacy i.MX21, i.MX27 and
i.MX31 SoCs don't have this register. As a result of writing data to
the non-existing register on driver probe the SoC hangs up, to fix the
problem add more OF compatible strings and on this basis get
information about availability of the WMCR register.

Fixes: 5fe65ce7ccbb ("watchdog: imx2_wdt: Disable power down counter on boot")
Signed-off-by: Vladimir Zapolskiy <vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
---
 drivers/watchdog/imx2_wdt.c | 47 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index 62f346b..b6763e0 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -29,6 +29,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/watchdog.h>
@@ -57,6 +58,10 @@
 
 #define WDOG_SEC_TO_COUNT(s)	((s * 2 - 1) << 8)
 
+struct imx2_wdt_data {
+	bool has_pdc;
+};
+
 struct imx2_wdt_device {
 	struct clk *clk;
 	struct regmap *regmap;
@@ -64,6 +69,8 @@ struct imx2_wdt_device {
 	bool ext_reset;
 };
 
+static const struct of_device_id imx2_wdt_dt_ids[];
+
 static bool nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, bool, 0);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
@@ -200,10 +207,13 @@ static const struct regmap_config imx2_wdt_regmap_config = {
 
 static int __init imx2_wdt_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *of_id;
+	const struct imx2_wdt_data *data;
 	struct imx2_wdt_device *wdev;
 	struct watchdog_device *wdog;
 	struct resource *res;
 	void __iomem *base;
+	bool has_pdc;
 	int ret;
 	u32 val;
 
@@ -261,12 +271,24 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
 		set_bit(WDOG_HW_RUNNING, &wdog->status);
 	}
 
+	if (pdev->dev.of_node) {
+		of_id = of_match_device(imx2_wdt_dt_ids, &pdev->dev);
+		if (!of_id)
+			return -ENODEV;
+
+		data = of_id->data;
+		has_pdc = data->has_pdc;
+	} else {
+		has_pdc = false;
+	}
+
 	/*
 	 * Disable the watchdog power down counter at boot. Otherwise the power
 	 * down counter will pull down the #WDOG interrupt line for one clock
 	 * cycle.
 	 */
-	regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0);
+	if (has_pdc)
+		regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0);
 
 	ret = watchdog_register_device(wdog);
 	if (ret) {
@@ -363,8 +385,29 @@ static int imx2_wdt_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend,
 			 imx2_wdt_resume);
 
+static const struct imx2_wdt_data imx21_wdt_data = {
+	.has_pdc = false,
+};
+
+static const struct imx2_wdt_data imx25_wdt_data = {
+	.has_pdc = true,
+};
+
 static const struct of_device_id imx2_wdt_dt_ids[] = {
-	{ .compatible = "fsl,imx21-wdt", },
+	{ .compatible = "fsl,imx21-wdt",  .data = &imx21_wdt_data },
+	{ .compatible = "fsl,imx25-wdt",  .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx27-wdt",  .data = &imx21_wdt_data },
+	{ .compatible = "fsl,imx31-wdt",  .data = &imx21_wdt_data },
+	{ .compatible = "fsl,imx35-wdt",  .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx50-wdt",  .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx51-wdt",  .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx53-wdt",  .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx6q-wdt",  .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx6sl-wdt", .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx6sx-wdt", .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx6ul-wdt", .data = &imx25_wdt_data },
+	{ .compatible = "fsl,imx7d-wdt",  .data = &imx25_wdt_data },
+	{ .compatible = "fsl,vf610-wdt",  .data = &imx25_wdt_data },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids);
-- 
2.8.1

--
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

  parent reply	other threads:[~2016-09-26  0:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26  0:39 [RFC PATCH 0/2] watchdog: imx2+: fix hangup during watchdog initialization Vladimir Zapolskiy
     [not found] ` <1474850361-20884-1-git-send-email-vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2016-09-26  0:39   ` Vladimir Zapolskiy [this message]
     [not found]     ` <1474850361-20884-2-git-send-email-vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2016-09-26 13:02       ` [RFC PATCH 1/2] watchdog: imx2: fix hang-up on boot for i.MX21, i.MX27 and i.MX31 SoCs Guenter Roeck
     [not found]         ` <ebece25b-7a3b-3fdf-d117-dd0a3a2975b7-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2016-12-10 19:28           ` Magnus Lilja
     [not found]             ` <CAM=E1R6hzob5ZzyTLmrLL5s-6=vbZQbCig1sLHMSLChJEz9YgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-10 20:14               ` Guenter Roeck
2016-12-10 22:37               ` Vladimir Zapolskiy
2016-09-26  0:39   ` [RFC PATCH 2/2] ARM: i.MX: dts: add fsl,imx25-wdt compatible to all relevant watchdog nodes Vladimir Zapolskiy
     [not found]     ` <1474850361-20884-3-git-send-email-vz-ChpfBGZJDbMAvxtiuMwx3w@public.gmane.org>
2016-09-26  4:34       ` [RFC PATCH 2/2] ARM: i.MX: dts: add fsl, imx25-wdt " Baruch Siach
2016-09-26  6:27       ` Uwe Kleine-König
     [not found]         ` <20160926062759.3eoezyezog6clz6x-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-12-11  9:40           ` Uwe Kleine-König

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=1474850361-20884-2-git-send-email-vz@mleia.com \
    --to=vz-chpfbgzjdbmavxtiumwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=fabio.estevam-3arQi8VN3Tc@public.gmane.org \
    --cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=wim-IQzOog9fTRqzQB+pC5nmwQ@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).