zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.49k stars 6.42k forks source link

stm32: support the drive-strength pinctrl node property #77894

Closed cfriedt closed 1 week ago

cfriedt commented 1 week ago

Is your feature request related to a problem? Please describe.

This is not at all a bug, it's more of a "nice to have".

When using some peripheral alternate functions (e.g. i2c), it would be really nice to be able to configure the drive strength via Devicetree (as it's done for e.g. TI cc13xx-cc26xx)

I believe the GPIO drive strength is configured on ST parts using the following bits from stm32-pinctrl.h.

/* GPIO speed */
#define STM32_OSPEEDR_LOW_SPEED     (0x0 << STM32_OSPEEDR_SHIFT)
#define STM32_OSPEEDR_MEDIUM_SPEED  (0x1 << STM32_OSPEEDR_SHIFT)
#define STM32_OSPEEDR_HIGH_SPEED    (0x2 << STM32_OSPEEDR_SHIFT)
#define STM32_OSPEEDR_VERY_HIGH_SPEED   (0x3 << STM32_OSPEEDR_SHIFT)
#define STM32_OSPEEDR_MASK      0x3
#define STM32_OSPEEDR_SHIFT     7

Describe the solution you'd like The ability to specify high drive strength with 1 additional, generic devicetree property. Something like the following:

/* I2C_SCL */

/omit-if-no-ref/ i2c1_scl_pb6: i2c1_scl_pb6 {
    pinmux = <STM32_PINMUX('B', 6, AF4)>;
    bias-pull-up;
    drive-open-drain;
    drive-strength;
};

Describe alternatives you've considered I think the only way to do this currently is to create a custom pinmux with additional bits or'ed together.

/* I2C_SCL */

/omit-if-no-ref/ i2c1_scl_pb6: i2c1_scl_pb6 {
    pinmux = <(STM32_PINMUX('B', 6, AF4) | STM32_OSPEEDR_VERY_HIGH_SPEED)>;
    bias-pull-up;
    drive-open-drain;
};

Additional context

erwango commented 1 week ago

@cfriedt what about the existing binding slew-rate and already implemented in STM32 pinctrl:

slew-rate = "very-high-speed";
cfriedt commented 1 week ago

@erwango - oh wow - I just saw that. Would it make sense to change the TI one to use the same terminology?

cfriedt commented 1 week ago

@vaishnavachath - Was is already discussed at some point about using a common DT binding for drive strength / slew rate in Zephyr?

erwango commented 1 week ago

@erwango - oh wow - I just saw that. Would it make sense to change the TI one to use the same terminology?

Maybe. For the record, we've taken this from Linux.

cfriedt commented 1 week ago

If they are generic, that's probably the best solution then. I wonder if TI has custom bindings in Linux. Do you know, @vaishnavachath ?