From patchwork Wed Jan 22 18:01:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 313350 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5C47E2C00A8 for ; Thu, 23 Jan 2014 05:01:36 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W627C-0003Sx-7H; Wed, 22 Jan 2014 18:01:26 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6279-0006kq-Nv; Wed, 22 Jan 2014 18:01:23 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6276-0006jR-P2 for linux-arm-kernel@lists.infradead.org; Wed, 22 Jan 2014 18:01:21 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 792827FA; Wed, 22 Jan 2014 19:00:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.3.2 Received: from localhost (unknown [190.2.98.212]) by mail.free-electrons.com (Postfix) with ESMTPSA id 373B47AE; Wed, 22 Jan 2014 19:00:41 +0100 (CET) Date: Wed, 22 Jan 2014 15:01:01 -0300 From: Ezequiel Garcia To: Arnd Bergmann , Jason Gunthorpe Subject: Re: [PATCH v2 05/15] watchdog: orion: Make RSTOUT register a separate resource Message-ID: <20140122180100.GE27273@localhost> References: <1390295561-3466-1-git-send-email-ezequiel.garcia@free-electrons.com> <1390295561-3466-6-git-send-email-ezequiel.garcia@free-electrons.com> <20140121233321.GR18269@obsidianresearch.com> <3176358.2QFcJHj0fv@wuerfel> <20140122162136.GA27273@localhost> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140122162136.GA27273@localhost> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140122_130120_991227_B501684A X-CRM114-Status: GOOD ( 19.16 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Lior Amsalem , devicetree@vger.kernel.org, linux-watchdog@vger.kernel.org, Tawfik Bayouk , Andrew Lunn , Jason Cooper , Wim Van Sebroeck , Gregory Clement , Thomas Petazzoni , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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 #include +/* 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;