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 06/10] pinctrl: mvebu: dove: request syscon regmap for global registers
Date: Mon, 24 Feb 2014 09:42:58 +0100	[thread overview]
Message-ID: <1393231382-11078-7-git-send-email-sebastian.hesselbarth@gmail.com> (raw)
In-Reply-To: <1393231382-11078-1-git-send-email-sebastian.hesselbarth@gmail.com>

Dove pinctrl uses some global config registers to control pins.
This patch requests a syscon regmap for those registers. As this
changes DT to driver requirements, fallback to a self-registered
regmap with hardcoded resources, if the corresponding syscon DT
node is missing. 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/Kconfig        |  1 +
 drivers/pinctrl/mvebu/pinctrl-dove.c | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/drivers/pinctrl/mvebu/Kconfig b/drivers/pinctrl/mvebu/Kconfig
index a22b0302922d..cc298fade93a 100644
--- a/drivers/pinctrl/mvebu/Kconfig
+++ b/drivers/pinctrl/mvebu/Kconfig
@@ -8,6 +8,7 @@ config PINCTRL_MVEBU
 config PINCTRL_DOVE
 	bool
 	select PINCTRL_MVEBU
+	select MFD_SYSCON
 
 config PINCTRL_KIRKWOOD
 	bool
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index 8d57d4bc1f0c..e4f954a78b15 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -18,7 +18,9 @@
 #include <linux/clk.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/mfd/syscon.h>
 #include <linux/pinctrl/pinctrl.h>
+#include <linux/regmap.h>
 
 #include "pinctrl-mvebu.h"
 
@@ -26,6 +28,7 @@
 #define INT_REGS_MASK		~(SZ_1M - 1)
 #define MPP4_REGS_OFFS		0xd0440
 #define PMU_REGS_OFFS		0xd802c
+#define GC_REGS_OFFS		0xe802c
 
 #define DOVE_SB_REGS_VIRT_BASE		IOMEM(0xfde00000)
 #define DOVE_MPP_VIRT_BASE		(DOVE_SB_REGS_VIRT_BASE + 0xd0200)
@@ -59,6 +62,7 @@
 static void __iomem *mpp_base;
 static void __iomem *mpp4_base;
 static void __iomem *pmu_base;
+static struct regmap *gconfmap;
 
 static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config)
 {
@@ -756,6 +760,13 @@ static struct of_device_id dove_pinctrl_of_match[] = {
 	{ }
 };
 
+static struct regmap_config gc_regmap_config = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.max_register = 5,
+};
+
 static int dove_pinctrl_probe(struct platform_device *pdev)
 {
 	struct resource *res, *mpp_res;
@@ -808,6 +819,22 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
 	if (IS_ERR(pmu_base))
 		return PTR_ERR(pmu_base);
 
+	gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config");
+	if (IS_ERR(gconfmap)) {
+		void __iomem *gc_base;
+
+		dev_warn(&pdev->dev, "falling back to hardcoded global registers\n");
+		adjust_resource(&fb_res,
+			(mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14);
+		gc_base = devm_ioremap_resource(&pdev->dev, &fb_res);
+		if (IS_ERR(gc_base))
+			return PTR_ERR(gc_base);
+		gconfmap = devm_regmap_init_mmio(&pdev->dev,
+						 gc_base, &gc_regmap_config);
+		if (IS_ERR(gconfmap))
+			return PTR_ERR(gconfmap);
+	}
+
 	/* Warn on any missing DT resource */
 	WARN(fb_res.start, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
 
-- 
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 ` [PATCH 05/10] pinctrl: mvebu: dove: request additional resources Sebastian Hesselbarth
2014-02-24  8:42 ` Sebastian Hesselbarth [this message]
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-7-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).