[21/33] spi: stm32: ignore the cs-gpios polarity flags

Message ID 20261104085036.4012238-22-dario.binacchi@amarulasolutions.com
State New
Headers
Series Add Engicam MicroGEA-STM32MP257D-RMM board support |

Commit Message

Dario Binacchi Nov. 4, 2026, 8:49 a.m. UTC
As in Linux, clear the GPIOD_ACTIVE_LOW flag of the chip select GPIOs,
so that their polarity is given by the SPI_CS_HIGH mode only. Otherwise,
a chip select described as GPIO_ACTIVE_LOW, as on the Engicam
MicroGEA-STM32MP257D-RMM board, is never asserted:

  cs-gpios = <&gpioh 8 GPIO_ACTIVE_LOW>, <&gpioh 3 GPIO_ACTIVE_HIGH>;

Fixes: a2a89b2e21db ("spi: stm32: Add Serial Peripheral Interface driver for STM32MP")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

 drivers/spi/stm32_spi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

-- 
2.43.0
  

Patch

diff --git a/drivers/spi/stm32_spi.c b/drivers/spi/stm32_spi.c
index c93a749cd5bf..776d88736a42 100644
--- a/drivers/spi/stm32_spi.c
+++ b/drivers/spi/stm32_spi.c
@@ -624,8 +624,13 @@  static int stm32_spi_probe(struct udevice *dev)
 		if (!dm_gpio_is_valid(&plat->cs_gpios[i]))
 			continue;
 
-		dm_gpio_set_dir_flags(&plat->cs_gpios[i],
-				      GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
+		/*
+		 * As in Linux, the chip select polarity is given by the
+		 * SPI_CS_HIGH mode only, the cs-gpios flags are ignored.
+		 */
+		dm_gpio_clrset_flags(&plat->cs_gpios[i],
+				     GPIOD_MASK_DIR | GPIOD_ACTIVE_LOW,
+				     GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
 	}
 
 	/* Ensure I2SMOD bit is kept cleared */