[U-Boot] [PATCH 4/7] pinctrl: uniphier: support per-pin configuration via DT

Masahiro Yamada yamada.masahiro at socionext.com
Sat May 5 10:53:54 UTC 2018


Currently, the UniPhier pinctrl drivers expose only the pin-group
interface to device tree.

Provide .get_pins_count, .get_pin_name, .pinconf_set hooks to support
pin configuration via 'pins' DT property.

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

 drivers/pinctrl/uniphier/pinctrl-uniphier-core.c | 37 ++++++++++++++++++++++--
 drivers/pinctrl/uniphier/pinctrl-uniphier.h      |  3 +-
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
index ac6c82d..03103b3 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
@@ -22,6 +22,34 @@
 
 static const char *uniphier_pinctrl_dummy_name = "_dummy";
 
+static int uniphier_pinctrl_get_pins_count(struct udevice *dev)
+{
+	struct uniphier_pinctrl_priv *priv = dev_get_priv(dev);
+	const struct uniphier_pinctrl_pin *pins = priv->socdata->pins;
+	int pins_count = priv->socdata->pins_count;
+
+	/*
+	 * We do not list all pins in the pin table to save memory footprint.
+	 * Report the max pin number + 1 to fake the framework.
+	 */
+	return pins[pins_count - 1].number + 1;
+}
+
+static const char *uniphier_pinctrl_get_pin_name(struct udevice *dev,
+						 unsigned int selector)
+{
+	struct uniphier_pinctrl_priv *priv = dev_get_priv(dev);
+	const struct uniphier_pinctrl_pin *pins = priv->socdata->pins;
+	int pins_count = priv->socdata->pins_count;
+	int i;
+
+	for (i = 0; i < pins_count; i++)
+		if (pins[i].number == selector)
+			return pins[i].name;
+
+	return uniphier_pinctrl_dummy_name;
+}
+
 static int uniphier_pinctrl_get_groups_count(struct udevice *dev)
 {
 	struct uniphier_pinctrl_priv *priv = dev_get_priv(dev);
@@ -158,8 +186,8 @@ static int uniphier_pinconf_bias_set(struct udevice *dev, unsigned int pin,
 	return 0;
 }
 
-static int uniphier_pinconf_set_one(struct udevice *dev, unsigned int pin,
-				    unsigned int param, unsigned int arg)
+static int uniphier_pinconf_set(struct udevice *dev, unsigned int pin,
+				unsigned int param, unsigned int arg)
 {
 	int ret;
 
@@ -191,7 +219,7 @@ static int uniphier_pinconf_group_set(struct udevice *dev,
 	int i, ret;
 
 	for (i = 0; i < grp->num_pins; i++) {
-		ret = uniphier_pinconf_set_one(dev, grp->pins[i], param, arg);
+		ret = uniphier_pinconf_set(dev, grp->pins[i], param, arg);
 		if (ret)
 			return ret;
 	}
@@ -269,6 +297,8 @@ static int uniphier_pinmux_group_set(struct udevice *dev,
 }
 
 const struct pinctrl_ops uniphier_pinctrl_ops = {
+	.get_pins_count = uniphier_pinctrl_get_pins_count,
+	.get_pin_name = uniphier_pinctrl_get_pin_name,
 	.get_groups_count = uniphier_pinctrl_get_groups_count,
 	.get_group_name = uniphier_pinctrl_get_group_name,
 	.get_functions_count = uniphier_pinmux_get_functions_count,
@@ -277,6 +307,7 @@ const struct pinctrl_ops uniphier_pinctrl_ops = {
 #if CONFIG_IS_ENABLED(PINCONF)
 	.pinconf_num_params = ARRAY_SIZE(uniphier_pinconf_params),
 	.pinconf_params = uniphier_pinconf_params,
+	.pinconf_set = uniphier_pinconf_set,
 	.pinconf_group_set = uniphier_pinconf_group_set,
 #endif
 	.set_state = pinctrl_generic_set_state,
diff --git a/drivers/pinctrl/uniphier/pinctrl-uniphier.h b/drivers/pinctrl/uniphier/pinctrl-uniphier.h
index 40e5ad7..8884b08 100644
--- a/drivers/pinctrl/uniphier/pinctrl-uniphier.h
+++ b/drivers/pinctrl/uniphier/pinctrl-uniphier.h
@@ -28,7 +28,8 @@ static inline unsigned int uniphier_pin_get_iectrl(unsigned long data)
  */
 struct uniphier_pinctrl_pin {
 	unsigned number;
-	unsigned long data;
+	const char *name;
+	unsigned int data;
 };
 
 /**
-- 
2.7.4



More information about the U-Boot mailing list