[U-Boot] [PATCH 08/10] pinctrl: uniphier: support per-pin input enable quirk for new SoCs

Masahiro Yamada yamada.masahiro at socionext.com
Thu Mar 24 14:32:45 CET 2016


Upcoming new pinctrl drivers of PH1-LD11/LD20 support input signal
gating for each pin.  (While, existing ones only support it per pin
group.)  This commit prepares the core part for that.

Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
---

 drivers/pinctrl/uniphier/pinctrl-uniphier-core.c | 28 +++++++++++++++++++++++-
 drivers/pinctrl/uniphier/pinctrl-uniphier.h      |  2 ++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
index 7a6c95c..5e7ff02 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
@@ -44,7 +44,23 @@ static const char *uniphier_pinmux_get_function_name(struct udevice *dev,
 	return priv->socdata->functions[selector];
 }
 
-static void uniphier_pinconf_input_enable(struct udevice *dev, unsigned pin)
+static void uniphier_pinconf_input_enable_perpin(struct udevice *dev,
+						 unsigned pin)
+{
+	struct uniphier_pinctrl_priv *priv = dev_get_priv(dev);
+	unsigned reg;
+	u32 mask, tmp;
+
+	reg = UNIPHIER_PINCTRL_IECTRL + pin / 32 * 4;
+	mask = BIT(pin % 32);
+
+	tmp = readl(priv->base + reg);
+	tmp |= mask;
+	writel(tmp, priv->base + reg);
+}
+
+static void uniphier_pinconf_input_enable_legacy(struct udevice *dev,
+						 unsigned pin)
 {
 	struct uniphier_pinctrl_priv *priv = dev_get_priv(dev);
 	int pins_count = priv->socdata->pins_count;
@@ -64,6 +80,16 @@ static void uniphier_pinconf_input_enable(struct udevice *dev, unsigned pin)
 	}
 }
 
+static void uniphier_pinconf_input_enable(struct udevice *dev, unsigned pin)
+{
+	struct uniphier_pinctrl_priv *priv = dev_get_priv(dev);
+
+	if (priv->socdata->quirks & UNIPHIER_PINCTRL_PERPIN_IECTRL)
+		uniphier_pinconf_input_enable_perpin(dev, pin);
+	else
+		uniphier_pinconf_input_enable_legacy(dev, pin);
+}
+
 static void uniphier_pinmux_set_one(struct udevice *dev, unsigned pin,
 				    unsigned muxval)
 {
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier.h b/drivers/pinctrl/uniphier/pinctrl-uniphier.h
index e622d93..0134d06 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier.h
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier.h
@@ -7,6 +7,7 @@
 #ifndef __PINCTRL_UNIPHIER_H__
 #define __PINCTRL_UNIPHIER_H__
 
+#include <linux/bitops.h>
 #include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -69,6 +70,7 @@ struct uniphier_pinctrl_socdata {
 	const char * const *functions;
 	int functions_count;
 	unsigned quirks;
+#define UNIPHIER_PINCTRL_PERPIN_IECTRL		BIT(1)
 #define UNIPHIER_PINCTRL_DBGMUX_SEPARATE	BIT(0)
 };
 
-- 
1.9.1



More information about the U-Boot mailing list