From patchwork Sat Jan 25 18:34:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3538651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F127BC02DC for ; Sat, 25 Jan 2014 18:36:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 378C02014A for ; Sat, 25 Jan 2014 18:36:14 +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 1BA74200E6 for ; Sat, 25 Jan 2014 18:36:13 +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 1W784o-0005AZ-5I; Sat, 25 Jan 2014 18:35:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W784g-00064E-CG; Sat, 25 Jan 2014 18:35:22 +0000 Received: from mail-ea0-x22e.google.com ([2a00:1450:4013:c01::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W784A-0005yC-24 for linux-arm-kernel@lists.infradead.org; Sat, 25 Jan 2014 18:34:53 +0000 Received: by mail-ea0-f174.google.com with SMTP id b10so1557777eae.19 for ; Sat, 25 Jan 2014 10:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jw2fDCad9vLCYvv3OUBQcNBRAtuV7HnRjTm4LXJ5Nas=; b=XomHOGwSxeo7qcqqXJrtd5eu83mHWSczLO1Rlflx7W54BEmcw2JAFFjDo0mPBFIPoS 3D47paAdooQcbXS5FF5TbFIKu/4BQlIvvnruLcjebCSgQovB382OoVoo6Dknqlphq8wp hrxHy3Bz9QkCiozlmzuaAt2uV3nv8yFj+5V9M/pzgs2scOjR5YtMc39Z4bSmezJhY4lj LUBLgAAGPs+5mXWf0iTwpyru9P6Z+OJtdhcaJPQGWoKhFzMX7g2vaIk7ZkK/ujvJ568b 8/4bXYv3n8bfQpazhcQVS/psBeOD7PC7sV+YjJ2Q4CvNlN+gmGsjrZICzOzRBdivKUaU yLkQ== X-Received: by 10.15.22.2 with SMTP id e2mr34051eeu.116.1390674871634; Sat, 25 Jan 2014 10:34:31 -0800 (PST) Received: from topkick.lan (dslc-082-083-251-183.pools.arcor-ip.net. [82.83.251.183]) by mx.google.com with ESMTPSA id z49sm18902695eeo.10.2014.01.25.10.34.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Jan 2014 10:34:31 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH 06/11] pinctrl: mvebu: dove: request additional resources Date: Sat, 25 Jan 2014 19:34:11 +0100 Message-Id: <1390674856-4993-7-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1390674856-4993-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1390674856-4993-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140125_133450_397275_693CFE46 X-CRM114-Status: GOOD ( 14.55 ) X-Spam-Score: -2.0 (--) Cc: Andrew Lunn , Jason Cooper , Linus Walleij , linux-kernel@vger.kernel.org, Gregory Clement , linux-arm-kernel@lists.infradead.org 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-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dove pinctrl also requires additional registers to control all pins. This patch requests resources for mpp4 and pmu-mpp register ranges. As this changes DT to driver requirements, fallback to hardcoded resources, if the corresponding DT regs have not been set. Also, WARN about old DT binding usage to encourage users to update their DTBs. Signed-off-by: Sebastian Hesselbarth --- Cc: Jason Cooper Cc: Andrew Lunn Cc: Gregory Clement Cc: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/pinctrl/mvebu/pinctrl-dove.c | 52 +++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index f4141e60a52b..3f34975c441f 100644 --- a/drivers/pinctrl/mvebu/pinctrl-dove.c +++ b/drivers/pinctrl/mvebu/pinctrl-dove.c @@ -22,6 +22,11 @@ #include "pinctrl-mvebu.h" +/* Internal registers can be configured at any 1 MiB aligned address */ +#define INT_REGS_MASK ~(SZ_1M - 1) +#define MPP4_REGS_OFFS 0xd0440 +#define PMU_REGS_OFFS 0xd802c + #define DOVE_SB_REGS_VIRT_BASE IOMEM(0xfde00000) #define DOVE_MPP_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xd0200) #define DOVE_PMU_MPP_GENERAL_CTRL (DOVE_MPP_VIRT_BASE + 0x10) @@ -55,6 +60,10 @@ #define CONFIG_PMU BIT(4) +static void __iomem *mpp_base; +static void __iomem *mpp4_base; +static void __iomem *pmu_base; + static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl, unsigned long *config) { @@ -776,13 +785,42 @@ static int dove_pinctrl_probe(struct platform_device *pdev) { const struct of_device_id *match = of_match_device(dove_pinctrl_of_match, &pdev->dev); - struct resource *res; - void __iomem *base; + struct resource *mpp_res, *res; + struct resource res_fallback; + + mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + mpp_base = devm_ioremap_resource(&pdev->dev, mpp_res); + if (IS_ERR(mpp_base)) + return PTR_ERR(mpp_base); + + /* prepare fallback resource */ + memcpy(&res_fallback, mpp_res, sizeof(struct resource)); + res_fallback.start = 0; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (!res) { + dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n"); + adjust_resource(&res_fallback, + (mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4); + res = &res_fallback; + } + mpp4_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(mpp4_base)) + return PTR_ERR(mpp4_base); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 2); + if (!res) { + dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n"); + adjust_resource(&res_fallback, + (mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8); + res = &res_fallback; + } + pmu_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(pmu_base)) + return PTR_ERR(pmu_base); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + /* Warn on any missing DT resource */ + WARN(res_fallback.start, "Missing pinctrl regs in DTB. Please update your firmware.\n"); pdev->dev.platform_data = (void *)match->data; @@ -797,7 +835,7 @@ static int dove_pinctrl_probe(struct platform_device *pdev) } clk_prepare_enable(clk); - return mvebu_pinctrl_probe(pdev, base); + return mvebu_pinctrl_probe(pdev, mpp_base); } static int dove_pinctrl_remove(struct platform_device *pdev)