From patchwork Sat Mar 15 18:17:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 3838131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1589E9F1CD for ; Sat, 15 Mar 2014 18:20:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5CEC202A1 for ; Sat, 15 Mar 2014 18:19:58 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C02622024D for ; Sat, 15 Mar 2014 18:19:57 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WOtB8-0003tr-KW; Sat, 15 Mar 2014 18:19: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 1WOtB1-0000re-JI; Sat, 15 Mar 2014 18:19:19 +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 1WOtAm-0000ol-2Z for linux-arm-kernel@lists.infradead.org; Sat, 15 Mar 2014 18:19:05 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 28FD985E; Sat, 15 Mar 2014 19:18:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (unknown [190.2.108.71]) by mail.free-electrons.com (Postfix) with ESMTPSA id 3DF4F7A8; Sat, 15 Mar 2014 19:18:37 +0100 (CET) From: Ezequiel Garcia To: , , Subject: [PATCH v4 2/9] watchdog: orion: Introduce a SoC-specific RSTOUT mapping Date: Sat, 15 Mar 2014 15:17:57 -0300 Message-Id: <1394907484-26002-3-git-send-email-ezequiel.garcia@free-electrons.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1394907484-26002-1-git-send-email-ezequiel.garcia@free-electrons.com> References: <1394907484-26002-1-git-send-email-ezequiel.garcia@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140315_141904_280142_870F755E X-CRM114-Status: GOOD ( 11.97 ) X-Spam-Score: -1.2 (-) Cc: Thomas Petazzoni , Andrew Lunn , Jason Cooper , Tawfik Bayouk , Jason Gunthorpe , Wim Van Sebroeck , Lior Amsalem , Ezequiel Garcia , Gregory Clement , Guenter Roeck , Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Separate the RSTOUT register mapping for the different compatible strings supported by the driver. This allows to use devm_ioremap on SoC variants that share the RSTOUT register, and devm_ioremap_resource (which requests the MMIO region) on SoCs that have a dedicated RSTOUT register. Reviewed-by: Guenter Roeck Signed-off-by: Ezequiel Garcia --- drivers/watchdog/orion_wdt.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c index b7d57bb..9b513e8 100644 --- a/drivers/watchdog/orion_wdt.c +++ b/drivers/watchdog/orion_wdt.c @@ -263,10 +263,6 @@ static void __iomem *orion_wdt_ioremap_rstout(struct platform_device *pdev, 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; - rstout = internal_regs + ORION_RSTOUT_MASK_OFFSET; WARN(1, FW_BUG "falling back to harcoded RSTOUT reg %pa\n", &rstout); @@ -317,6 +313,7 @@ MODULE_DEVICE_TABLE(of, orion_wdt_of_match_table); static int orion_wdt_get_regs(struct platform_device *pdev, struct orion_watchdog *dev) { + struct device_node *node = pdev->dev.of_node; struct resource *res; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -327,10 +324,26 @@ static int orion_wdt_get_regs(struct platform_device *pdev, if (!dev->reg) return -ENOMEM; - dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & - INTERNAL_REGS_MASK); - if (!dev->rstout) + /* Each supported compatible has some RSTOUT register quirk */ + if (of_device_is_compatible(node, "marvell,orion-wdt")) { + + dev->rstout = orion_wdt_ioremap_rstout(pdev, res->start & + INTERNAL_REGS_MASK); + if (!dev->rstout) + return -ENODEV; + + } else if (of_device_is_compatible(node, "marvell,armada-370-wdt") || + of_device_is_compatible(node, "marvell,armada-xp-wdt")) { + + /* Dedicated RSTOUT register, can be requested. */ + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + dev->rstout = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(dev->rstout)) + return PTR_ERR(dev->rstout); + + } else { return -ENODEV; + } return 0; }