linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sebastian.hesselbarth@gmail.com (Sebastian Hesselbarth)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/10] pinctrl: mvebu: dove: request additional resources
Date: Mon, 24 Feb 2014 09:42:57 +0100	[thread overview]
Message-ID: <1393231382-11078-6-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1393231382-11078-1-git-send-email-sebastian.hesselbarth@gmail.com>

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 <sebastian.hesselbarth@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@free-electrons.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-kernel at vger.kernel.org
---
 drivers/pinctrl/mvebu/pinctrl-dove.c | 45 +++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index da9ca26360fd..8d57d4bc1f0c 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)
@@ -52,6 +57,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(unsigned pid, unsigned long *config)
 {
@@ -751,7 +758,8 @@ static struct of_device_id dove_pinctrl_of_match[] = {
 
 static int dove_pinctrl_probe(struct platform_device *pdev)
 {
-	struct resource *res;
+	struct resource *res, *mpp_res;
+	struct resource fb_res;
 	const struct of_device_id *match =
 		of_match_device(dove_pinctrl_of_match, &pdev->dev);
 	pdev->dev.platform_data = (void *)match->data;
@@ -767,11 +775,42 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
 	}
 	clk_prepare_enable(clk);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	mpp_base = devm_ioremap_resource(&pdev->dev, res);
+	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(&fb_res, mpp_res, sizeof(struct resource));
+	fb_res.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(&fb_res,
+			(mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4);
+		res = &fb_res;
+	}
+
+	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(&fb_res,
+			(mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8);
+		res = &fb_res;
+	}
+
+	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(fb_res.start, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
+
 	return mvebu_pinctrl_probe(pdev);
 }
 
-- 
1.8.5.3

  parent reply	other threads:[~2014-02-24  8:42 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-24  8:42 [PATCH 00/10] pinctrl: mvebu: remove hard-coded addresses from Dove pinctrl Sebastian Hesselbarth
2014-02-24  8:42 ` [PATCH 01/10] devicetree: bindings: add missing Marvell Dove SoC documentation Sebastian Hesselbarth
2014-02-24  8:42 ` [PATCH 02/10] devicetree: bindings: update MVEBU pinctrl binding documentation Sebastian Hesselbarth
2014-02-24  8:42 ` [PATCH 03/10] ARM: dove: add additional pinctrl registers Sebastian Hesselbarth
2014-02-24  8:42 ` [PATCH 04/10] ARM: dove: add global-config register node Sebastian Hesselbarth
2014-02-24  8:42 ` Sebastian Hesselbarth [this message]
2014-02-24  8:42 ` [PATCH 06/10] pinctrl: mvebu: dove: request syscon regmap for global registers Sebastian Hesselbarth
2014-02-24  8:42 ` [PATCH 07/10] pinctrl: mvebu: dove: use remapped mpp base registers Sebastian Hesselbarth
2014-02-24  8:43 ` [PATCH 08/10] pinctrl: mvebu: dove: use remapped mpp4 register Sebastian Hesselbarth
2014-02-24  8:43 ` [PATCH 09/10] pinctrl: mvebu: dove: use remapped pmu_mpp registers Sebastian Hesselbarth
2014-02-24  8:43 ` [PATCH 10/10] pinctrl: mvebu: dove: use global register regmap Sebastian Hesselbarth
2014-02-24 10:17 ` [PATCH 00/10] pinctrl: mvebu: remove hard-coded addresses from Dove pinctrl Linus Walleij
2014-02-24 10:20   ` Sebastian Hesselbarth
2014-02-24 11:50     ` Linus Walleij
2014-02-24 18:10 ` Jason Cooper
2014-02-25  9:36   ` Linus Walleij
2014-02-25 15:16     ` Jason Cooper
2014-02-25 15:30       ` Sebastian Hesselbarth
2014-02-25 15:43         ` Jason Cooper
2014-02-25 19:23           ` Sebastian Hesselbarth
2014-02-25 20:04             ` Jason Cooper
2014-02-25 20:34               ` Sebastian Hesselbarth
2014-02-27 13:38               ` Ezequiel Garcia
2014-02-27 15:14                 ` Jason Cooper
2014-02-26  0:09     ` Jason Cooper
2014-02-26  9:43       ` Linus Walleij
2014-02-26 14:53         ` Jason Cooper
2014-03-07  1:26           ` Linus Walleij
2014-03-07  2:16             ` Jason Cooper
2014-03-07  2:57               ` Yoshiyuki Ito
2014-03-07  3:03                 ` Jason Cooper
2014-03-07  3:08                   ` YOSHIYUKI ITO
2014-03-07  3:47               ` Jason Cooper
2014-03-07  3:54                 ` Linus Walleij

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=1393231382-11078-6-git-send-email-sebastian.hesselbarth@gmail.com \
    --to=sebastian.hesselbarth@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).