cancel
Showing results for 
Search instead for 
Did you mean: 

SPI chip/slave select issue STM32MP157

Ronte.1
Associate II

I have troubles in setting the polarity of the SPI chip select i/o for an external chip.

I noticed In the reference manual that it should be changeable with SPI configuration register 2 (SSIOP bit 28) :

Bit 28 SSIOP: SS input/output polarity

0: low level is active for SS signal

1: high level is active for SS signal

However the SPI presentation STM32MP1 (1.0) says: "The Slave Select signal can operate as an input or as an output depending on the SSIOP control bit. "

Which one is right?

5 REPLIES 5
PatrickF
ST Employee

Hi,

please note that SPI Chip-Select is managed differently depending on the subsystem used:

  • When using Cortex-M4 CubeMP1, the HW Chip-Select as described in Refrence Manual is used, so it is managed by the SPI IP using HAL configuration. CS is then only available on few pins according to AFMUX description in product datasheet
  • When using Cortex-A7 OpenSTLinux, the Chip-Select is fully managed by SW driver and could use any GPIO. The HW Chip Select of the SPI IP is not used. This is according to existing Linux drivers way of working.

I understand from https://community.st.com/s/question/0D53W00000LEqI4SAL/good-afternoon-im-trying-to-use-tsc2046-based-touchscreen-device-on-a-stm32mp157cdk2-based-custom-board-i-get-spi-transfer-timeout-when-touching-the-screen-does-anyone-have-a-similar-problem- that you have an issue with the second case when using Device Tree and OpenSTLinux.

I escalated this to the development team for further analysis.

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
PatrickF
ST Employee

After investigation, we did not see any issue with polarity settings with Linux (wich was your concern).

Please refer to https://wiki.st.com/stm32mpu-ecosystem-v1/wiki/How_to_use_SPI_from_Linux_userland_with_spidev

Hope this help.

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Ronte.1
Associate II

Hi,

Yes the second case is what I'm using.

If I leave the third parameter out cs-gpios = (..) from dts ; , I get an error " no CS gpios available" and the touchscreen driver doesn't load.

If I use GPIO_ACTIVE_LOW or 1 the driver is loaded.

What I have noticed is that the Linux spi driver uses active high CS internally? I changed the ads7846 driver probe function by adding the high flag:

spi->mode = SPI_MODE_0 | SPI_CS_HIGH;

This way I got some progress, the cs line works now as I thought it should work, active low when transfering data. Still some trouble with reading correct data from the touchscreen and those timeouts still there from time to time.

Regards

Meanwhile, I got confirmation that I was slightly wrong in my answer.

You should use a 2nd dummy parameter (not used, but needed to be present), e.g. cs-gpios = <&gpioX YY 0>;

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

If I use a second parameter 0(=GPIO_ACTIVE_HIGH) , instead of 1 (=GPIO_ACTIVE_LOW) I get information on boot : "tsc2046@0 enforce active low on chipselect handle". However internally spi driver mode is spi_cs_high even then and if I use touchscreen driver as it is by default, I get wrong polarity at the chip pin.