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

Merged
merged 3 commits into from
Jun 26, 2025

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.

Fixes #57747

decsny

This comment was marked as resolved.

EmilioCBen
EmilioCBen previously approved these changes Mar 20, 2025
@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.

Copy link
Member Author

@decsny decsny Jun 26, 2025

Choose a reason for hiding this comment

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

its in the board level dts , also its just the only two standard spi headers on the board which are labelled on silk screen, mikrobus and arduino

@decsny
Copy link
Member Author

decsny commented Jun 2, 2025

update: rebased on top of #90182 . Still WIP, so moved to draft

@decsny decsny force-pushed the feature/lpspi_slave branch from 205c571 to d10716a Compare June 5, 2025 23:22
@decsny decsny modified the milestone: v4.2.0 Jun 17, 2025
@decsny decsny force-pushed the feature/lpspi_slave branch from d10716a to decb325 Compare June 23, 2025 22:08
@decsny decsny marked this pull request as ready for review June 23, 2025 22:09
@decsny
Copy link
Member Author

decsny commented Jun 23, 2025

command : west build -b frdm_mcxa156 -p always tests/drivers/spi/spi_controller_peripheral/ -DCONFIG_SPI_NXP_LPSPI_DMA=n -DCONFIG_TESTED_SPI_MODE=3

connecting the lpspis used in the overlay, result:

TESTSUITE spi_controller_peripheral succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [spi_controller_peripheral]: pass = 14, fail = 0, skip = 0, total = 14 duration = 0.
154 seconds
 - PASS - [spi_controller_peripheral.test_basic] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_basic_async] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_basic_zero_len] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_basic_zero_len_async] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_only_rx] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_only_rx_async] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_only_rx_in_chunks] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_only_rx_in_chunks_async] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_only_tx] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_only_tx_async] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_only_tx_in_chunks] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_only_tx_in_chunks_async] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_short_rx] duration = 0.011 seconds
 - PASS - [spi_controller_peripheral.test_short_rx_async] duration = 0.011 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL

@decsny decsny removed the DNM This PR should not be merged (Do Not Merge) label Jun 24, 2025
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

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

The zephyr,user addition is fine I think

decsny added 3 commits June 26, 2025 14:56
Add rudimentary slave mode support to the interrupt based LPSPI driver.

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 decb325 to 057a46e Compare June 26, 2025 19:57
Copy link

@dkalowsk dkalowsk merged commit 6aa46f4 into zephyrproject-rtos:main Jun 26, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: SPI SPI bus platform: NXP Drivers NXP Semiconductors, drivers platform: NXP NXP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add slave support to spi_mcux_lpspi driver
8 participants