From 603fd9ead634d51ed54dd7cb90bf15a35a06b52b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 5 May 2018 19:53:54 +0900 Subject: [PATCH] pinctrl: uniphier: support per-pin configuration via DT 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 --- .../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 601a42d909..916d051911 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier-core.c @@ -21,6 +21,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); @@ -157,8 +185,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; @@ -190,7 +218,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; } @@ -268,6 +296,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, @@ -276,6 +306,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 55f2b1a4d5..b3257f430d 100644 --- a/drivers/pinctrl/uniphier/pinctrl-uniphier.h +++ b/drivers/pinctrl/uniphier/pinctrl-uniphier.h @@ -27,7 +27,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.39.5