diff mbox series

[U-Boot,3/5] pinctrl: renesas: Implement gpio_request_enable/gpio_disable_free

Message ID 20190421222021.22494-3-marek.vasut+renesas@gmail.com
State Accepted
Commit 89ba7c5a8cf3cdef34f5acef4184f35e63439759
Delegated to: Marek Vasut
Headers show
Series [U-Boot,1/5] pinctrl: gpio: Add callback for configuring pin as GPIO | expand

Commit Message

Marek Vasut April 21, 2019, 10:20 p.m. UTC
Implement the gpio_request_enable/gpio_disable_free callbacks to let
the GPIO driver call the pin control framework and let it reconfigure
pins as GPIOs.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Alex Kiernan <alex.kiernan@gmail.com>
Cc: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Cc: Eugeniu Rosca <roscaeugeniu@gmail.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick DELAUNAY <patrick.delaunay@st.com>
Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Cc: Simon Glass <sjg@chromium.org>
---
 drivers/pinctrl/renesas/pfc.c | 40 ++++++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

Comments

Eugeniu Rosca April 26, 2019, 12:58 p.m. UTC | #1
On Mon, Apr 22, 2019 at 12:20 AM Marek Vasut <marek.vasut@gmail.com> wrote:
[..]
> -int sh_pfc_config_mux_for_gpio(struct udevice *dev, unsigned pin_selector)
> +static int sh_pfc_gpio_request_enable(struct udevice *dev,
> +                                     unsigned pin_selector)

FTR, checkpatch is not happy about bare usage of 'unsigned'. It seems
to be a global issue in U-Boot.

Reviewed-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Tested-by: Eugeniu Rosca <erosca@de.adit-jv.com>
diff mbox series

Patch

diff --git a/drivers/pinctrl/renesas/pfc.c b/drivers/pinctrl/renesas/pfc.c
index 59dc4af702..52c486ebc2 100644
--- a/drivers/pinctrl/renesas/pfc.c
+++ b/drivers/pinctrl/renesas/pfc.c
@@ -459,7 +459,8 @@  static const char *sh_pfc_pinctrl_get_function_name(struct udevice *dev,
 	return priv->pfc.info->functions[selector].name;
 }
 
-int sh_pfc_config_mux_for_gpio(struct udevice *dev, unsigned pin_selector)
+static int sh_pfc_gpio_request_enable(struct udevice *dev,
+				      unsigned pin_selector)
 {
 	struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
 	struct sh_pfc_pinctrl *pmx = &priv->pmx;
@@ -494,6 +495,40 @@  int sh_pfc_config_mux_for_gpio(struct udevice *dev, unsigned pin_selector)
 	return 0;
 }
 
+static int sh_pfc_gpio_disable_free(struct udevice *dev,
+				    unsigned pin_selector)
+{
+	struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
+	struct sh_pfc_pinctrl *pmx = &priv->pmx;
+	struct sh_pfc *pfc = &priv->pfc;
+	struct sh_pfc_pin_config *cfg;
+	const struct sh_pfc_pin *pin = NULL;
+	int i, idx;
+
+	for (i = 1; i < pfc->info->nr_pins; i++) {
+		if (priv->pfc.info->pins[i].pin != pin_selector)
+			continue;
+
+		pin = &priv->pfc.info->pins[i];
+		break;
+	}
+
+	if (!pin)
+		return -EINVAL;
+
+	idx = sh_pfc_get_pin_index(pfc, pin->pin);
+	cfg = &pmx->configs[idx];
+
+	cfg->type = PINMUX_TYPE_NONE;
+
+	return 0;
+}
+
+int sh_pfc_config_mux_for_gpio(struct udevice *dev, unsigned pin_selector)
+{
+	return sh_pfc_gpio_request_enable(dev, pin_selector);
+}
+
 static int sh_pfc_pinctrl_pin_set(struct udevice *dev, unsigned pin_selector,
 				  unsigned func_selector)
 {
@@ -752,6 +787,9 @@  static struct pinctrl_ops sh_pfc_pinctrl_ops = {
 	.pinmux_set		= sh_pfc_pinctrl_pin_set,
 	.pinmux_group_set	= sh_pfc_pinctrl_group_set,
 	.set_state		= pinctrl_generic_set_state,
+
+	.gpio_request_enable	= sh_pfc_gpio_request_enable,
+	.gpio_disable_free	= sh_pfc_gpio_disable_free,
 };
 
 static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)