[PATCH 11/11] pinctrl: scmi: select the GPIO function on GPIO requests

Cristian Marussi cristian.marussi at arm.com
Tue Nov 10 05:49:25 PST 2026


On Fri, Oct 30, 2026 at 04:58:42PM +0100, Clément Le Goffic wrote:
> On a GPIO request, select the GPIO function of the pin, on the pin for a
> pin-only function or on its single-pin group. Without a GPIO function the
> mux is left as it is.
> 
> Signed-off-by: Clément Le Goffic <clegoffic at baylibre.com>
> ---
>  drivers/pinctrl/pinctrl-scmi.c | 64 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
> index 6f44e8c0fee6..ba649304638e 100644
> --- a/drivers/pinctrl/pinctrl-scmi.c
> +++ b/drivers/pinctrl/pinctrl-scmi.c
> @@ -74,6 +74,69 @@ static int pinctrl_scmi_free(struct pinctrl_dev *pctldev, unsigned int offset)
>  	return pinctrl_ops->pin_free(pmx->ph, offset);
>  }
>  
> +static int pinctrl_scmi_gpio_mux_set(struct scmi_pinctrl *pmx, unsigned int pin)
> +{
> +	const unsigned int *elems, *pins;
> +	unsigned int nr_elems, nr_pins, i;
> +	bool pin_only, gpio;
> +	int nr_functions, func, ret;

Beside nr_functions, cannot all of these variable definitions be moved
inside the scope in which they are exclusively used, i.e. down inside
the for-loop ?

> +
> +	nr_functions = pinctrl_ops->count_get(pmx->ph, FUNCTION_TYPE);
> +	for (func = 0; func < nr_functions; func++) {
> +		ret = pinctrl_ops->function_flags_get(pmx->ph, func, &pin_only,
> +						      &gpio);
> +		if (ret)
> +			return ret;
> +
> +		if (!gpio)
> +			continue;
> +
> +		ret = pinctrl_ops->function_groups_get(pmx->ph, func, &nr_elems,
> +						       &elems);
> +		if (ret)
> +			return ret;
> +
> +		for (i = 0; i < nr_elems; i++) {
> +			if (pin_only) {
> +				if (elems[i] != pin)
> +					continue;
> +
> +				return pinctrl_ops->pin_mux_set(pmx->ph, func,
> +								pin);
> +			}
> +
> +			ret = pinctrl_ops->group_pins_get(pmx->ph, elems[i],
> +							  &pins, &nr_pins);
> +			if (ret)
> +				return ret;
> +
> +			if (nr_pins == 1 && pins[0] == pin)
> +				return pinctrl_ops->mux_set(pmx->ph, func,
> +							    elems[i]);
> +		}

So it is a possibility that in the above loops nothing is set..and it is
fine should AFAIU...but should we log/debug something in both cases to ease
troubleshooting ? (maybe just a stupid question ...)

Thanks,
Cristian




More information about the linux-arm-kernel mailing list