The SPI-Py API allows the user to choose one of the four major SPI
modes. It does so using the SPI_IOC_WR_MODE ioctl, which gives access
to the bottom 8 bits of the mode property of the spidev instance, but
unfortunately it just sets its preferred value, zeroing any higher bits
that might have been set,
A change to the spi-bcm2835 driver in Linux 5.4 [1] converts it to use
GPIO descriptors, which as a side effect enables SPI_CS_HIGH mode
(presumably to avoid a negation somewhere). This change appears to work
as expected, but its reliance on the SPI_CS_HIGH bit means that using
SPI-Py breaks it in a way which persists after the SPI-Py client
application exits.
Fix the problem by preserving the upper mode bits.
The SPI-Py API allows the user to choose one of the four major SPI modes. It does so using the SPI_IOC_WR_MODE ioctl, which gives access to the bottom 8 bits of the mode property of the spidev instance, but unfortunately it just sets its preferred value, zeroing any higher bits that might have been set,
A change to the spi-bcm2835 driver in Linux 5.4 [1] converts it to use GPIO descriptors, which as a side effect enables SPI_CS_HIGH mode (presumably to avoid a negation somewhere). This change appears to work as expected, but its reliance on the SPI_CS_HIGH bit means that using SPI-Py breaks it in a way which persists after the SPI-Py client application exits.
Fix the problem by preserving the upper mode bits.
Signed-off-by: Phil Elwell phil@raspberrypi.org
[1] 3bd158c56a56 ("spi: bcm2835: Convert to use CS GPIO descriptors")