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

NXP LPSPI: Fix some regressions #86156

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

decsny
Copy link
Member

@decsny decsny commented Feb 21, 2025

Fixes #86148
Fixes #86145

One patch on this PR is from @Raymond0225

@decsny decsny force-pushed the fix/lpspi_regressions branch from 3426ac4 to 5f99b79 Compare February 21, 2025 16:24
while ((base->CR & LPSPI_CR_MEN_MASK) != 0U) {
/* Wait until LPSPI is disabled. Datasheet:
* After writing 0, MEN (Module Enable) remains set until the LPSPI has
* completed the current transfer and is idle.
*/
}

base->CR |= LPSPI_CR_RST_MASK;
base->CR |= LPSPI_CR_RRF_MASK | LPSPI_CR_RTF_MASK;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove these lines as they have already initialized in LPSPI_MasterInit

Copy link
Member Author

@decsny decsny Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, I just realized, they are still in the wrong place, the purpose of this was to fix S32 silicon errata

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Raymond0225 I updated the PR to do an alternative workaround but I still need to test on S32 hardware, so it will remain on draft still

The LPSPI FIFOs on this platform are 8 words long, not 16.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
@decsny decsny force-pushed the fix/lpspi_regressions branch from 5f99b79 to 3e8c52e Compare February 21, 2025 17:21
decsny and others added 2 commits February 21, 2025 11:23
No need to reconfigure SPI if already configured with same
configuration. This reduces latency of some transfers that
re-use the same spi_cfg.

Also, a slightly related change is to remove the setting of the CONTC
bit in the init. This was a mistake to have because there was no
intention to do a continuing command and could cause some problem, or at
least cause confusion to readers of the driver code.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Co-authored-by: Raymond Lei <raymond.lei@nxp.com>
On some of the platforms, the module doesn't get clocked until the
SDK Init call, causing the control register (CR) write to fault.

The reason for this code in the first place was to avoid S32 chip errata
that caused fifos to need internal logic reset. Since we want to avoid
reconfiguring, and a module reset would require that, there is one other
documented workaround which is to just read the RX fifo register to
update the internal hardware pointer. For the TX fifo the fix is to wait
for transfer completion which should be done by the point of starting a
new one.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
@decsny decsny force-pushed the fix/lpspi_regressions branch from 3e8c52e to 4b63265 Compare February 21, 2025 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants