drivers: pinctrl: stm32: Ignore NO_REMAP pins when handling AFIO remaps

Some peripherals (e.g. ethernet) have remaps only on some of the pins.
Pins without remaps do not conflict and must be ignored to correctly
process the remaps.

Signed-off-by: Vegard Storheil Eriksen <zyp@jvnv.net>
This commit is contained in:
Vegard Storheil Eriksen 2025-01-03 00:01:06 +01:00 committed by Benjamin Cabé
commit 3dc60a68c4

View file

@ -169,19 +169,23 @@ static int stm32_pins_remap(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt)
uint32_t reg_val; uint32_t reg_val;
uint16_t remap; uint16_t remap;
remap = (uint16_t)STM32_DT_PINMUX_REMAP(pins[0].pinmux); remap = NO_REMAP;
for (size_t i = 0U; i < pin_cnt; i++) {
if (remap == NO_REMAP) {
remap = STM32_DT_PINMUX_REMAP(pins[i].pinmux);
} else if (STM32_DT_PINMUX_REMAP(pins[i].pinmux) == NO_REMAP) {
continue;
} else if (STM32_DT_PINMUX_REMAP(pins[i].pinmux) != remap) {
return -EINVAL;
}
}
/* not remappable */ /* not remappable */
if (remap == NO_REMAP) { if (remap == NO_REMAP) {
return 0; return 0;
} }
for (size_t i = 1U; i < pin_cnt; i++) {
if (STM32_DT_PINMUX_REMAP(pins[i].pinmux) != remap) {
return -EINVAL;
}
}
/* A valid remapping configuration is available */ /* A valid remapping configuration is available */
/* Apply remapping before proceeding with pin configuration */ /* Apply remapping before proceeding with pin configuration */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_AFIO); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_AFIO);