Skip to content

Device deinit driver support #2987

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 11 commits into
base: main
Choose a base branch
from

Conversation

bjarki-andreasen
Copy link
Contributor

Device deinit driver support

@bjarki-andreasen
Copy link
Contributor Author

The change request is regarding a commit adding stuff to the zephyr release notes, this commit is not cherry picked, so merge with superpowers should be ok :)

The usage of nrf_gpio_port_retain_disable/_enable, in cases where
the soc pins support retention, every pin must be
retained/unretained regardless of what power domain the pad is in.

This patch ensures retain is applied to all pins in all domains by
the gpio_nrfx device driver, not only pins specifically in the
fast_active_1 domain. Without this patch, pinctrl will correctly
retain pins, while gpio_nrfx will fail to unretain them when
again.

We no longer check the output state either, which was passed with
the flags arg of gpio_nrfx_gpd_retain_set() so this arg has been
removed.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit 691b3356f8fceb5d58600e43140dba55dbe1581d)
Pins can be configured to retain their config even when the power
domain they belong to is suspended. Update pinctrl_nrf to enable
retain only if the pin has been configured and is not in use
(pincnf is low-power/sleep), disable retain otherwise.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit 652635fab9d41d763716cd188414b45f4049c7a9)
Add DEVICE_DEINIT variants of SPI_DEVICE_ macros. These include

- SPI_DEVICE_DT_DEINIT_DEFINE()
- SPI_DEVICE_DT_INST_DEINIT_DEFINE()

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit 1663253de65a9c0196581685c53de1f4b4e244a5)
Implement device deinit for nRF SPIM device driver.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit 2609cfbf4a9558146d6970cf3222dde7480cb4ad)
Introduce test for device_deinit() which deinitializes the spi
bus, then configures miso as input, mosi as output using gpio,
utilizing the loopback to test directly controlling the pins.
Then reinit the spi device.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit ecb5457898d748dbd906778044d058df2a15b53c)
…h miso/mosi

Add miso-gpios and mosi-gpios to nrf overlays required for
device_deinit testing.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit 160c196435b4e38dc97d49ad4fd64b1505915a61)
Add device deinit variants of the I2C_DEVICE_DT_*_DEFINE macros.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit 8a928ea1d7f57880a63693619cac99a6e673d18f)
Implement device deinit for the nRF TWIM device drivers.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit bd73c739b4d22fcb2bc6d09bc988941d8b962568)
Implement device deinit hooks for nRF TWIS device driver.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit f22ffee5c3e48dddeb2f0631ffe84e0d6c988770)
…t case

Add device_deinit test case which, in case there are two devices
using gpio loopbacks, deinits both controller and target devices,
then uses gpio to configure and toggle the pins of the bus, then
reinitializes both devices.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit db1f14e79a8bd427b7873f85ddb4b9981b3d889e)
…ith bus gpios

Add bus gpios to zephyr,user node in nrf overlays to enable testing
device_deinit test case.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit e0fa444b8dbff03a05a7942825dca8c5bd0109a9)
@bjarki-andreasen bjarki-andreasen force-pushed the device-deinit-driver-support branch from 8bdb2ed to c6effa3 Compare June 27, 2025 10:04
Copy link

@bjarki-andreasen
Copy link
Contributor Author

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.

1 participant