Skip to content

NXP LPSPI: Add support for Peripheral (slave) mode #87144

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

decsny
Copy link
Member

@decsny decsny commented Mar 14, 2025

This PR adds support for Peripheral mode into the NXP LPSPI interrupt-based driver.

So far, it is only tested on MCXA156, but this is a great start because due to the small fifo, it is probably the most difficult to enable on.

decsny

This comment was marked as resolved.

decsny added 5 commits March 18, 2025 12:10
If there are HAL definitions available, do these two things:

Ungate the clock for the device from the zephyr driver. Eventually it
would be better to have a clocks property in the LPSPI DT node and get
the resources from there rather than the HAL.

Some platforms require the peripheral to be reset at system level, add
code to do this. Eventually it would be more ideal to have Zephyr
reset drivers for all of the NXP platforms and use DT to describe the
reset resources, but for now we can just do this to get the LPSPI
supported.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Optimize the TX fill algorithm to have less interrupts by filling the TX
fifo as much as possible during each interrupt handle.

Before, the algorithm was just a very simple, fill the TX fifo with as
much from only the current buffer as possible, then send it and wait for
the next interrupt. Now the algorithm is to fill the TX fifo as much as
possible, even if it means reading from multiple buffers during the
interrupt.

This has the advantage from master mode of having less interrupts. And
it is very important for slave mode because the slave mode does not
control the pacing of the transfer and so therefore should fill as much
as possible whenever possible in order not to miss a deadline.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add basic support for basic peripheral mode operation.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add overlay for a reworked board that breaks out LPSPI1 to the arduino
header.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add an overlay to the spi_controller_peripheral test for the
frdm_mcxa156. Since this IP has multiple CS, need to introduce a way to
configure the correct CS to the test; just going to use zephyr,user for
now instead of refactoring to be less nordic-specific, keeping the usage
optional.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
@decsny decsny force-pushed the feature/lpspi_slave branch from 8ee79a0 to 513dc46 Compare March 18, 2025 17:22
@@ -9,6 +9,49 @@ LOG_MODULE_REGISTER(spi_mcux_lpspi_common, CONFIG_SPI_LOG_LEVEL);

#include "spi_nxp_lpspi_priv.h"

#if defined(LPSPI_RSTS) || defined(LPSPI_CLOCKS)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What file would these be defined in?

Copy link
Member Author

@decsny decsny Mar 20, 2025

Choose a reason for hiding this comment

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

in fsl_clock.h and fsl_reset.h in the HAL, eventually long term want to use DT instead of HAL driver definitions

@decsny decsny added the DNM This PR should not be merged (Do Not Merge) label Mar 20, 2025
@decsny
Copy link
Member Author

decsny commented Mar 20, 2025

put DNM because there are some timing issues with CPHA=0, need to debug

peripheral-cs = <1>;
};
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be useful for testing if you could include the connection setup in a comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: SPI SPI bus DNM This PR should not be merged (Do Not Merge) platform: NXP Drivers NXP Semiconductors, drivers platform: NXP NXP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants