[U-Boot] [PATCH v3 7/9] pinctrl: stm32: Add get_pin_muxing() ops

Simon Glass sjg at chromium.org
Fri Oct 19 03:25:06 UTC 2018


Hi Patrice,

On 9 October 2018 at 07:31, Patrice Chotard <patrice.chotard at st.com> wrote:
> Add get_pin_muxing() ops to obtain the pin muxing description
> a given pin index.
>
> Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  drivers/pinctrl/pinctrl_stm32.c | 77 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 77 insertions(+)
>
> diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
> index e0bee4b97bd5..588efda8df4b 100644
> --- a/drivers/pinctrl/pinctrl_stm32.c
> +++ b/drivers/pinctrl/pinctrl_stm32.c
> @@ -27,8 +27,34 @@ struct stm32_gpio_bank {
>
>  #define MAX_PIN_PER_BANK               16
>
> +#define MAX_PIN_MUX_LEN                        40
> +static char pin_mux[MAX_PIN_MUX_LEN];
> +
>  #define MAX_PIN_NAME_LEN               12
>  static char pin_name[MAX_PIN_NAME_LEN];
> +#define PINMUX_MODE_COUNT              5
> +static const char * const pinmux_mode[PINMUX_MODE_COUNT] = {
> +       "gpio input",
> +       "gpio output",
> +       "analog",
> +       "unknown",
> +       "alt function",
> +};
> +
> +static int stm32_pinctrl_get_af(struct udevice *dev, unsigned int offset)
> +{
> +       struct stm32_gpio_priv *priv = dev_get_priv(dev);
> +       struct stm32_gpio_regs *regs = priv->regs;
> +       u32 af;
> +       u32 alt_shift = (offset % 8) * 4;
> +       u32 alt_index =  offset / 8;
> +
> +       af = (readl(&regs->afr[alt_index]) &
> +             GENMASK(alt_shift + 3, alt_shift)) >> alt_shift;
> +
> +       return af;
> +}
> +
>  static int stm32_pinctrl_get_pins_count(struct udevice *dev)
>  {
>         struct stm32_pinctrl_priv *priv = dev_get_priv(dev);
> @@ -97,6 +123,56 @@ static const char *stm32_pinctrl_get_pin_name(struct udevice *dev,
>
>         return pin_name;
>  }
> +
> +static const char *stm32_pinctrl_get_pin_muxing(struct udevice *dev,
> +                                               unsigned int selector)

Again I think this should be passed a buffer to write into.

Regards,
Simon


More information about the U-Boot mailing list