-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
spi: sam: Fix gpio chip select usage #57130
Conversation
drivers/spi/spi_sam.c
Outdated
@@ -128,7 +128,11 @@ static int spi_sam_configure(const struct device *dev, | |||
* select mode. | |||
*/ | |||
spi_mr |= (SPI_MR_MSTR | SPI_MR_MODFDIS); | |||
spi_mr |= SPI_MR_PCS(spi_slave_to_mr_pcs(config->slave)); | |||
if (config->cs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a ternary operator?
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
drivers/spi/spi_sam.c
Outdated
if (spi_cs_is_gpio(config)) { | ||
spi_mr |= SPI_MR_PCS(spi_slave_to_mr_pcs(0)); | ||
} else { | ||
spi_mr |= SPI_MR_PCS(spi_slave_to_mr_pcs(config->slave)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still fail to understand why it wouldn't work without this change, but in any case you can shorten the statement:
if (spi_cs_is_gpio(config)) { | |
spi_mr |= SPI_MR_PCS(spi_slave_to_mr_pcs(0)); | |
} else { | |
spi_mr |= SPI_MR_PCS(spi_slave_to_mr_pcs(config->slave)); | |
} | |
spi_mr |= SPI_MR_PCS(spi_slave_to_mr_pcs(spi_cs_is_gpio(config) ? 0 : config->slave)); |
Same for the CSR
.
EDIT: I guess the explanation here makes sense
When using gpio chip select the clock line seems to get stuck low after some transactions. When attempting to use other SPI_CSR registers the peripheral fails to work as expected. Always using SPI_CSR[0] when using gpio chip selects resolves the issue. Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
Once zephyrproject-rtos#57130 merges this will not be needed. Signed-off-by: Yuval Peress <peress@google.com>
When using gpio chip select the clock line seems to get stuck low after some transactions. When attempting to use other SPI_CSR registers the peripheral fails to work as expected.
Always using SPI_CSR[0] when using gpio chip selects resolves the issue.