2020-10-28 02:19 AM
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?
2020-10-29 02:08 AM
Hi,
please note that SPI Chip-Select is managed differently depending on the subsystem used:
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.
2020-10-30 06:00 AM
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.
2020-11-02 01:29 AM
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
2020-11-02 02:07 AM
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>;
2020-11-04 12:28 AM
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.