Skip to content

[TEST ONLY] BACKPORT SPIM to 3.7.99-ncs3-branch #2951

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

Conversation

bjarki-andreasen
Copy link
Contributor

PR which backports a ton of NRFX SPI and GPIO driver commits

@bjarki-andreasen bjarki-andreasen changed the title BACKPORT SPIM to 3.7.99-ncs3-branch [TEST ONLY] BACKPORT SPIM to 3.7.99-ncs3-branch Jun 11, 2025
gmarull and others added 17 commits June 11, 2025 18:07
…able

Instead of raw register access.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
(cherry picked from commit fa46eec)
So that pin configuration can be queried.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
(cherry picked from commit bea0a06)
…t_config

The nRF GPIO hardware does not store the initial output value
set resulting from gpio_pin_configure() and thus, when
gpio_get_config() is used, the initial value is not returned.

This commit just reads the output value and sets the INIT
value to match in gpio_get_config().

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
(cherry picked from commit 0826996)
Implement PM_DEVICE_RUNTIME for gpio_nrfx.c

PM is required to request/release the GPD domain if such exists
for a given GPIO instance. Without this, every single API call
will result in a requesting the GPD domain, which makes it slow
and unusable from ISRs, given GPD requires IPC. Now, user can
simply get the GPIO before using it, and put it once done,
calling the APIs from ISR while resumed.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
(cherry picked from commit c4d475c)
…is set to no-connect

Fixes a bug in nrfx spi when used in modes where only MOSI is needed such
as driving a WS2812. In this mode NRFX_ASSERT() is triggered when sck pin
is configured as no-connect.

Signed-off-by: Anthony Williams <anthony289478@gmail.com>
(cherry picked from commit 291a688)
Add compile time detection if fast SPIM instances are used
and system managed device PM is enabled. This configuration is
not supported.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
(cherry picked from commit d8dc241)
… SPIM instances

Add FOREACH macro which iterates over all SPIM instances and creates
device instances for each enabled instance.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
(cherry picked from commit 9d59e03)
…odes

Instead of explicitly defining the SPIM instances that need it.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
(cherry picked from commit a068709)
…ut_all

Implement calling spi_context_cs_get_all() and
spi_context_cs_put_all() in line with pm resume/suspend.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
(cherry picked from commit acbed8a)
The nrxf_spim driver currently resumes itself for the duration of
a transfer, however, in case SPI_LOCK_ON is used, the driver needs
to keep itself resumed until spi_release() is called. Currently,
this results in unbalanced suspend as the bus puts itself both
after transaction is done, and when spi_release() is called.

This patch makes the driver check if SPI_LOCK_ON is set once
transaction is complete, if yes, selv get one more time to
account for the two puts which will follow.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
(cherry picked from commit 8cf519d)
Make clear in the include/ header that data frame size
is the same thing as word size for the context of this API.

Also, add some comments to the spi_context to make it easier
for driver writers to understand how to use the functions,
by noting the meaning of the dfs and len parameters to the update
functions. Otherwise it takes some time to understand what they mean.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
(cherry picked from commit ca829e1)
Extract the lock condition to a dedicated variable to make future
changes clearer.

Signed-off-by: Jordan Yates <jordan@embeint.com>
(cherry picked from commit ebc2ca5)
Update the context state parameters when the context is already locked.
This allows changing the callback information for asynchronous
operations while the context is locked.

Signed-off-by: Jordan Yates <jordan@embeint.com>
(cherry picked from commit 13df3b9)
Add functions to get remaining length in the transfer. Refactor a bit to
avoid duplicate code for the for loop that is the same as in the total
length function.

The difference between the total length and left length function is that
the current buffer total length is counted in the former and the current
buffer remaining length is counted in the latter.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
(cherry picked from commit 0bb7ccb)
Personally I found this file hard to understand at first,
but since now it is clear to me, I decided to put these comments
with my understanding to help anyone else who needs to use these.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
(cherry picked from commit 0b843be)
Introduce spi_context_cs_get() and spi_context_cs_put() which shall
be used from drivers to get/put the GPIO port the CS GPIO belongs to
before and after a transaction, in line with the SPI drivers pm
action hook being called.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
(cherry picked from commit cbd9535)
TEST ONLY

This commit adds cs-gpios and zephyr,pm-device-runtime-auto;
to spi instances used for the loopback test. PORT 7 PIN 0
is used for CS. It also ups the SPI freq to 10MHz.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Copy link

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.

7 participants