]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pinctrl: pinctrl_stm32: Add slew rate support for stm32_pinctrl_get_pin_muxing()
authorPatrice Chotard <patrice.chotard@foss.st.com>
Mon, 27 Mar 2023 07:46:41 +0000 (09:46 +0200)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Wed, 19 Apr 2023 07:50:32 +0000 (09:50 +0200)
For debug purpose, it should be useful to indicate the slew rate for
each pins.
Add ospeed register information for pins which are configured in
either alternate function or gpio output.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
drivers/pinctrl/pinctrl_stm32.c

index b755fa42b4f70155ab8ba60ec2babc6291d82597..b06da50b2cd54bc0b819b2b06c292b42406fe2a8 100644 (file)
@@ -61,6 +61,13 @@ static const char * const pinmux_otype[] = {
        [STM32_GPIO_OTYPE_OD] = "open-drain",
 };
 
+static const char * const pinmux_speed[] = {
+       [STM32_GPIO_SPEED_2M] = "Low speed",
+       [STM32_GPIO_SPEED_25M] = "Medium speed",
+       [STM32_GPIO_SPEED_50M] = "High speed",
+       [STM32_GPIO_SPEED_100M] = "Very-high speed",
+};
+
 static int stm32_pinctrl_get_af(struct udevice *dev, unsigned int offset)
 {
        struct stm32_gpio_priv *priv = dev_get_priv(dev);
@@ -201,6 +208,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
        int af_num;
        unsigned int gpio_idx;
        u32 pupd, otype;
+       u8 speed;
 
        /* look up for the bank which owns the requested pin */
        gpio_dev = stm32_pinctrl_get_gpio_dev(dev, selector, &gpio_idx);
@@ -214,6 +222,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
        priv = dev_get_priv(gpio_dev);
        pupd = (readl(&priv->regs->pupdr) >> (gpio_idx * 2)) & PUPD_MASK;
        otype = (readl(&priv->regs->otyper) >> gpio_idx) & OTYPE_MSK;
+       speed = (readl(&priv->regs->ospeedr) >> gpio_idx * 2) & OSPEED_MASK;
 
        switch (mode) {
        case GPIOF_UNKNOWN:
@@ -222,13 +231,15 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice *dev,
                break;
        case GPIOF_FUNC:
                af_num = stm32_pinctrl_get_af(gpio_dev, gpio_idx);
-               snprintf(buf, size, "%s %d %s %s", pinmux_mode[mode], af_num,
-                        pinmux_otype[otype], pinmux_bias[pupd]);
+               snprintf(buf, size, "%s %d %s %s %s", pinmux_mode[mode], af_num,
+                        pinmux_otype[otype], pinmux_bias[pupd],
+                        pinmux_speed[speed]);
                break;
        case GPIOF_OUTPUT:
-               snprintf(buf, size, "%s %s %s %s",
+               snprintf(buf, size, "%s %s %s %s %s",
                         pinmux_mode[mode], pinmux_otype[otype],
-                        pinmux_bias[pupd], label ? label : "");
+                        pinmux_bias[pupd], label ? label : "",
+                        pinmux_speed[speed]);
                break;
        case GPIOF_INPUT:
                snprintf(buf, size, "%s %s %s", pinmux_mode[mode],