[v2,21/35] spi: stm32: ignore the cs-gpios polarity flags

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

Commit Message

Dario Binacchi Nov. 7, 2026, 2:32 p.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>
---

(no changes since v1)

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

-- 
2.43.0
  

Comments

Patrice CHOTARD Nov. 16, 2026, 10:45 a.m. UTC | #1
On 11/7/26 15:32, Dario Binacchi wrote:
> 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>
> ---
> 
> (no changes since v1)
> 
>  drivers/spi/stm32_spi.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> 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 */

Hi Dario

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
  
Patrice CHOTARD Nov. 26, 2026, 7:46 a.m. UTC | #2
On 11/16/26 11:45, Patrice CHOTARD wrote:
> 
> 
> On 11/7/26 15:32, Dario Binacchi wrote:
>> 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>
>> ---
>>
>> (no changes since v1)
>>
>>  drivers/spi/stm32_spi.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> 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 */
> 
> Hi Dario
> 
> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
> 
> Thanks
> Patrice
> 

Applied to u-boot-stm32/main

Thanks
Patrice

> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32@st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
  

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 */