Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SPI mode setting #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix SPI mode setting #25

wants to merge 1 commit into from

Conversation

pelwell
Copy link
Contributor

@pelwell pelwell commented Nov 29, 2019

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 [email protected]

[1] 3bd158c56a56 ("spi: bcm2835: Convert to use CS GPIO descriptors")

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 <[email protected]>

[1] 3bd158c56a56 ("spi: bcm2835: Convert to use CS GPIO descriptors")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant