From patchwork Tue Jan 28 00:39:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3544781 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 A2909C02DC for ; Tue, 28 Jan 2014 01:16:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C54862011E for ; Tue, 28 Jan 2014 01:16:48 +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 C48A120109 for ; Tue, 28 Jan 2014 01:16:47 +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 1W7xIA-0004t5-47; Tue, 28 Jan 2014 01:16:42 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W7xI7-0007UN-N1; Tue, 28 Jan 2014 01:16:39 +0000 Received: from mail-ee0-x22d.google.com ([2a00:1450:4013:c00::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W7xI4-0007Ti-9R for linux-arm-kernel@lists.infradead.org; Tue, 28 Jan 2014 01:16:37 +0000 Received: by mail-ee0-f45.google.com with SMTP id b15so2560956eek.18 for ; Mon, 27 Jan 2014 17:16:14 -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=wFqGaIEkKIDfxKNtXhA+8D3gNMao/Ep8MxtlaYZsATk=; b=JceDSQTBrHBzR3HxDGIJ/iDL2u8hjWXJtEroMcG4aoYSHa3t9WzkVZXWtkmKLxJZK1 2Fo+JtsWoJXceNa4SMLDCK5Kd8LCLcnoFk9pMirAfOmzbfF60zPTyb6xLvkklbHS8Loa 9Ff+1Mbxp5Syl9Tdwd1suy8HmmZZaF/w/bXuvx4kmKUmEFhqLeFxVoiPNvWOWQExaRkV KWc9ciXiQkovyVANKOp5yRWAnOVOoCfoVHM5ya7FQRCNkhmb/sqt2EYQSS+mzmPhSTjJ vBYttdR0THpKq14dqCVNmbKs1Sh5D9LynwYmHZ5fDMd6FWE1o9Bg2zwWMPk7MKbdE5Vl FQ3A== X-Received: by 10.14.6.5 with SMTP id 5mr98283eem.51.1390871774224; Mon, 27 Jan 2014 17:16:14 -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 z49sm49072020eeo.10.2014.01.27.17.16.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jan 2014 17:16:13 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v2 15/21] pinctrl: mvebu: dove: request additional resources Date: Tue, 28 Jan 2014 01:39:27 +0100 Message-Id: <1390869573-27624-16-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1390869573-27624-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1390674856-4993-1-git-send-email-sebastian.hesselbarth@gmail.com> <1390869573-27624-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140127_201636_464408_B1A1B19B X-CRM114-Status: GOOD ( 15.61 ) X-Spam-Score: -2.0 (--) Cc: Thomas Petazzoni , 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 --- Changelog: v1->v2: - add FW_BUG to WARN message Cc: Jason Cooper Cc: Andrew Lunn Cc: Gregory Clement Cc: Thomas Petazzoni Cc: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/pinctrl/mvebu/pinctrl-dove.c | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index 98f8cae72ace..bb7ff396ddd1 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) @@ -56,6 +61,8 @@ #define CONFIG_PMU BIT(4) static void __iomem *mpp_base; +static void __iomem *mpp4_base; +static void __iomem *pmu_base; static int dove_mpp_ctrl_get(struct mvebu_mpp_ctrl *ctrl, unsigned long *config) @@ -802,13 +809,43 @@ 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 *mpp_res; + 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); + + /* Warn on any missing DT resource */ + WARN(res_fallback.start, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n"); + pdev->dev.platform_data = (void *)match->data; /*