linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Cc: linux-arm-kernel@lists.infradead.org,
	Lior Amsalem <alior@marvell.com>,
	devicetree@vger.kernel.org, linux-watchdog@vger.kernel.org,
	Tawfik Bayouk <tawfik@marvell.com>, Andrew Lunn <andrew@lunn.ch>,
	Wim Van Sebroeck <wim@iguana.be>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Jason Cooper <jason@lakedaemon.net>
Subject: Re: [PATCH v2 05/15] watchdog: orion: Make RSTOUT register a separate resource
Date: Wed, 22 Jan 2014 15:01:01 -0300	[thread overview]
Message-ID: <20140122180100.GE27273@localhost> (raw)
In-Reply-To: <20140122162136.GA27273@localhost>

On Wed, Jan 22, 2014 at 01:21:36PM -0300, Ezequiel Garcia wrote:
> > I don't see a good way out that would preserve backwards compatibility,
> > other than hardcoding the physical address in the driver, which seems
> > just as bad as breaking compatibility. That said, it is always the
> > same constant (0xf1000000 + 0x20000 + 0x0108) on Dove, Kirkwood and
> > Orion5x (not on mv78xx0, but that doesn't use the wdt), so hardcoding
> > a fallback would technically work, but we should print a fat warning at
> > boot time if we actually fall back to that.
> > 
> 
> Yes, I was thinking just about this. Namely:
> 
[..]

How about something like this?

diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c
index a861b88..0014d23 100644
--- a/drivers/watchdog/orion_wdt.c
+++ b/drivers/watchdog/orion_wdt.c
@@ -26,6 +26,9 @@
 #include <linux/of.h>
 #include <mach/bridge-regs.h>
 
+/* RSTOUT mask register physical address for Orion5x, Kirkwood and Dove */
+#define ORION_RSTOUT_MASK	0xf1020108
+
 /*
  * Watchdog timer block registers.
  */
@@ -119,6 +122,30 @@ static irqreturn_t orion_wdt_irq(int irq, void *devid)
 	return IRQ_HANDLED;
 }
 
+/*
+ * The original devicetree binding for this driver specified only
+ * one memory resource, so in order to keep DT backwards compatibility
+ * we try to fallback to a hardcoded register address, if the resource
+ * is missing from the devicetree.
+ */
+static void __iomem * try_compat_rstout_ioremap(struct platform_device *pdev)
+{
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res)
+		return devm_ioremap(&pdev->dev, res->start,
+				    resource_size(res));
+
+	/* This workaround works only for "orion-wdt", DT-enabled */
+	if (!of_device_is_compatible(pdev->dev.of_node, "marvell,orion-wdt"))
+		return NULL;
+
+	dev_warn(&pdev->dev, "falling back to harcoded RSTOUT reg 0x%x\n",
+		 ORION_RSTOUT_MASK);
+	return devm_ioremap(&pdev->dev, ORION_RSTOUT_MASK, 0x4);
+}
+
 static int orion_wdt_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -139,10 +166,7 @@ static int orion_wdt_probe(struct platform_device *pdev)
 	if (!wdt_reg)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (!res)
-		return -ENODEV;
-	wdt_rstout = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+	wdt_rstout = try_compat_rstout_ioremap(pdev);
 	if (!wdt_rstout)
 		return -ENOMEM;
 
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-01-22 18:00 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21  9:12 [PATCH v2 00/15] Armada 370/XP watchdog support Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 01/15] ARM: Introduce atomic MMIO modify Ezequiel Garcia
2014-01-21  9:45   ` Arnd Bergmann
2014-01-21 10:46     ` Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 02/15] clocksource: orion: Use atomic access for shared registers Ezequiel Garcia
2014-01-21  9:46   ` Arnd Bergmann
2014-01-21  9:58     ` Sebastian Hesselbarth
2014-01-21 10:54       ` Arnd Bergmann
2014-01-21 11:02         ` Andrew Lunn
2014-01-21  9:57   ` Daniel Lezcano
2014-01-21 10:53     ` Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 03/15] watchdog: " Ezequiel Garcia
2014-01-21  9:19   ` Fabio Estevam
2014-01-21  9:42     ` Ezequiel Garcia
2014-01-21  9:54   ` Arnd Bergmann
2014-01-21 10:13     ` Andrew Lunn
2014-01-21  9:12 ` [PATCH v2 04/15] watchdog: orion: Handle IRQ Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 05/15] watchdog: orion: Make RSTOUT register a separate resource Ezequiel Garcia
2014-01-21 23:33   ` Jason Gunthorpe
2014-01-22  9:48     ` Arnd Bergmann
2014-01-22 16:21       ` Ezequiel Garcia
2014-01-22 18:01         ` Ezequiel Garcia [this message]
2014-01-22 18:14           ` Jason Gunthorpe
2014-01-22 18:21             ` Arnd Bergmann
2014-01-22 18:29             ` Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 06/15] watchdog: orion: Remove unneeded BRIDGE_CAUSE clear Ezequiel Garcia
2014-01-21 23:35   ` Jason Gunthorpe
2014-01-22 16:49     ` Ezequiel Garcia
2014-01-22 17:34       ` Jason Gunthorpe
2014-01-22 17:45         ` Ezequiel Garcia
2014-01-22 17:50           ` Jason Gunthorpe
2014-01-22 18:03             ` Ezequiel Garcia
2014-01-22 20:31         ` Sebastian Hesselbarth
2014-01-22 20:52           ` Jason Gunthorpe
2014-01-22 22:12             ` Ezequiel Garcia
2014-01-22 22:31               ` Jason Gunthorpe
2014-01-22 22:56                 ` Ezequiel Garcia
2014-01-23  0:03                 ` Sebastian Hesselbarth
2014-01-23  0:19                   ` Jason Gunthorpe
2014-01-23  0:35                     ` Sebastian Hesselbarth
2014-01-23 12:04                     ` Ezequiel Garcia
2014-01-22 23:49             ` Sebastian Hesselbarth
2014-01-23 11:10               ` Ezequiel Garcia
2014-01-23 11:54                 ` Ezequiel Garcia
2014-01-23 21:15                   ` Sebastian Hesselbarth
2014-01-21  9:12 ` [PATCH v2 07/15] watchdog: orion: Introduce an orion_watchdog device structure Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 08/15] watchdog: orion: Introduce per-compatible of_device_id data Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 09/15] watchdog: orion: Add per-compatible clock initialization Ezequiel Garcia
2014-01-21  9:18   ` Fabio Estevam
2014-01-21  9:43     ` Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 10/15] watchdog: orion: Add per-compatible watchdog start implementation Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 11/15] watchdog: orion: Add support for Armada 370 and Armada XP SoC Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 12/15] ARM: mvebu: Enable Armada 370/XP watchdog in the devicetree Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 13/15] ARM: kirkwood: Add RSTOUT 'reg' entry to devicetree Ezequiel Garcia
2014-01-21  9:12 ` [PATCH v2 14/15] watchdog: orion: Allow to build on any Orion platform Ezequiel Garcia
2014-01-21  9:41   ` Sebastian Hesselbarth
2014-01-21  9:45     ` Andrew Lunn
2014-01-21 10:04       ` Ezequiel Garcia
2014-01-21 11:06     ` Removing PLAT_ORION dependency from ARCH_MVEBU (Was Re: [PATCH v2 14/15] watchdog: orion: Allow to build on any Orion platform) Ezequiel Garcia
2014-01-21 11:44       ` Sebastian Hesselbarth
2014-01-21  9:12 ` [PATCH v2 15/15] ARM: mvebu: Enable watchdog support in defconfig Ezequiel Garcia
2014-01-21 12:47   ` Jason Cooper
2014-01-21 12:53     ` Andrew Lunn
2014-01-21 12:57       ` Jason Cooper

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=20140122180100.GE27273@localhost \
    --to=ezequiel.garcia@free-electrons.com \
    --cc=alior@marvell.com \
    --cc=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=tawfik@marvell.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=wim@iguana.be \
    /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).