diff mbox series

[v2,08/10] gpio: rockchip: Add request() ops

Message ID 20240802225705.2640999-9-jonas@kwiboo.se
State Accepted
Delegated to: Kever Yang
Headers show
Series rockchip: pinctrl: Add support for pinmux status cmd | expand

Commit Message

Jonas Karlman Aug. 2, 2024, 10:56 p.m. UTC
Add a request() ops that call pinctrl_gpio_request() when the required
gpio-ranges prop has been defined to signal pinctrl driver to use gpio
pinmux.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
v2: New patch from "rockchip: Add gpio request() ops" series
---
 drivers/gpio/rk_gpio.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Quentin Schulz Aug. 7, 2024, 10:12 a.m. UTC | #1
Hi Jonas,

On 8/3/24 12:56 AM, Jonas Karlman wrote:
> Add a request() ops that call pinctrl_gpio_request() when the required
> gpio-ranges prop has been defined to signal pinctrl driver to use gpio
> pinmux.
> 
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> ---
> v2: New patch from "rockchip: Add gpio request() ops" series
> ---
>   drivers/gpio/rk_gpio.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
> index 5972f7f8612d..65811dbc78d6 100644
> --- a/drivers/gpio/rk_gpio.c
> +++ b/drivers/gpio/rk_gpio.c
> @@ -126,6 +126,15 @@ static int rockchip_gpio_get_function(struct udevice *dev, unsigned offset)
>   	return (data & mask) ? GPIOF_OUTPUT : GPIOF_INPUT;
>   }
>   
> +static int rockchip_gpio_request(struct udevice *dev, unsigned offset,
> +				 const char *label)
> +{
> +	if (CONFIG_IS_ENABLED(PINCTRL) && dev_read_bool(dev, "gpio-ranges"))

I assume we check for gpio-ranges property because 
pinctrl_gpio_get_pinctrl_and_offset called by pinctrl_gpio_request will 
return an error if the property isn't there?

I see that you're adding the gpio-ranges to Rockchip SoCs that are 
missing them (as well as the aliases), wouldn't it make more sense to 
move this commit after that commit and remove the dependency on 
gpio-ranges property and let pinctrl_gpio_request fail if it isn't there?

Cheers,
Quentin
Kever Yang Aug. 9, 2024, 9:38 a.m. UTC | #2
On 2024/8/3 06:56, Jonas Karlman wrote:
> Add a request() ops that call pinctrl_gpio_request() when the required
> gpio-ranges prop has been defined to signal pinctrl driver to use gpio
> pinmux.
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
> v2: New patch from "rockchip: Add gpio request() ops" series
> ---
>   drivers/gpio/rk_gpio.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
> index 5972f7f8612d..65811dbc78d6 100644
> --- a/drivers/gpio/rk_gpio.c
> +++ b/drivers/gpio/rk_gpio.c
> @@ -126,6 +126,15 @@ static int rockchip_gpio_get_function(struct udevice *dev, unsigned offset)
>   	return (data & mask) ? GPIOF_OUTPUT : GPIOF_INPUT;
>   }
>   
> +static int rockchip_gpio_request(struct udevice *dev, unsigned offset,
> +				 const char *label)
> +{
> +	if (CONFIG_IS_ENABLED(PINCTRL) && dev_read_bool(dev, "gpio-ranges"))
> +		return pinctrl_gpio_request(dev, offset, label);
> +
> +	return 0;
> +}
> +
>   /* Simple SPL interface to GPIOs */
>   #ifdef CONFIG_SPL_BUILD
>   
> @@ -229,6 +238,7 @@ static int rockchip_gpio_probe(struct udevice *dev)
>   }
>   
>   static const struct dm_gpio_ops gpio_rockchip_ops = {
> +	.request		= rockchip_gpio_request,
>   	.direction_input	= rockchip_gpio_direction_input,
>   	.direction_output	= rockchip_gpio_direction_output,
>   	.get_value		= rockchip_gpio_get_value,
diff mbox series

Patch

diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
index 5972f7f8612d..65811dbc78d6 100644
--- a/drivers/gpio/rk_gpio.c
+++ b/drivers/gpio/rk_gpio.c
@@ -126,6 +126,15 @@  static int rockchip_gpio_get_function(struct udevice *dev, unsigned offset)
 	return (data & mask) ? GPIOF_OUTPUT : GPIOF_INPUT;
 }
 
+static int rockchip_gpio_request(struct udevice *dev, unsigned offset,
+				 const char *label)
+{
+	if (CONFIG_IS_ENABLED(PINCTRL) && dev_read_bool(dev, "gpio-ranges"))
+		return pinctrl_gpio_request(dev, offset, label);
+
+	return 0;
+}
+
 /* Simple SPL interface to GPIOs */
 #ifdef CONFIG_SPL_BUILD
 
@@ -229,6 +238,7 @@  static int rockchip_gpio_probe(struct udevice *dev)
 }
 
 static const struct dm_gpio_ops gpio_rockchip_ops = {
+	.request		= rockchip_gpio_request,
 	.direction_input	= rockchip_gpio_direction_input,
 	.direction_output	= rockchip_gpio_direction_output,
 	.get_value		= rockchip_gpio_get_value,