Skip to content

Conversation

@nika-nordic
Copy link
Contributor

@nika-nordic nika-nordic commented Oct 15, 2025

Align GPIOTE shim to changes in nrfx instantiation.

Draft PR before pulling the trigger on the approach in nrfx.

Upstream PR: zephyrproject-rtos/zephyr#98527

@nika-nordic nika-nordic force-pushed the nrfx_gpiote_extract_cb_sdkzephyr branch from 17612bd to d3b73fd Compare October 28, 2025 17:17
@nika-nordic nika-nordic marked this pull request as ready for review October 28, 2025 17:21
@nika-nordic nika-nordic changed the title drivers: gpio: nrf: align to nrfx_gpiote extracted control block [collab-nrfx-4.0] drivers: gpio: nrf: align to nrfx_gpiote extracted control block Oct 28, 2025
@nika-nordic nika-nordic changed the title [collab-nrfx-4.0] drivers: gpio: nrf: align to nrfx_gpiote extracted control block [collab-nrfx-4.0] drivers: gpio: nrf: align to nrfx_gpiote extracted cb Oct 28, 2025
};

static nrfx_gpiote_t gpiote_nrfx[] = {
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpiote, GPIOTE_NRFX_INST)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if those instances should not be created in soc file? What about cases where gpiote is used without CONFIG_GPIO=y? Unless we assume that it is required to enable GPIO driver to use gpiote.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then we would need to have a software component (like dmm.c ) to create and own the nrfx_gpiote instances, and some nordic-soc-level API to extract those instances, correct? Then both gpio shim and non-shim users could use that to obtain given nrfx_gpiote instance.

I wonder if this is worth the hassle - if any code runs with CONFIG_GPIO=n it means no one is the owner of GPIOTE instance so its the application responsibility to manage nrfx_gpiote instance.

I can try the suggested approach, however I am afraid it might be problematic when it comes to IRQ_CONNECT macro in gpio shim which expects the arguments to be constant. I guess with suggested approach the instance would need to be obtained in run-time? Alternatively via linker magic and global variables, but it won't be pretty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nordic-krch I have extracted nrfx_gpiote instances into new gpiote_nrfx.c component in soc/common + macrology to allow to obtain any nrfx_gpiote via global variable. This should ease the nrfx_gpiote instances sharing across the system as well as CONFIG_GPIO=n variant.

A big plus of this approach is quite small impact on nrfx_gpiote users - instead of creating NRFX_GPIOTE_INSTANCE macrology needs to be used to obtain reference to global nrfx_gpiote instance.

Please take a look if this is what you had in mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

I had in mind something like that. Imo, it's better to have one approach for gpiote instantiation otherwise it would become cumbersome for modules that use gpiote instance (like PPI trace). It would need to use 2 APIs for getting the instance depending on CONFIG_GPIO. Not to mention that user would need to create gpiote instance in application code with GPIO is not used.

@nika-nordic nika-nordic force-pushed the nrfx_gpiote_extract_cb_sdkzephyr branch from d3b73fd to 3391840 Compare October 29, 2025 20:21
@nika-nordic nika-nordic requested a review from anangl October 30, 2025 07:07
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't interrupt be connected here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point, however I suggest to keep it as it is now, as current approach is aligned with what we have in main branch (i.e. IRQ installed by gpio shim when CONFIG_GPIO=y )

@nika-nordic nika-nordic force-pushed the nrfx_gpiote_extract_cb_sdkzephyr branch from 3391840 to 6fe974a Compare October 30, 2025 12:43
@nika-nordic nika-nordic force-pushed the nrfx_gpiote_extract_cb_sdkzephyr branch from 6fe974a to 139641f Compare October 30, 2025 21:30
…extraction

Analogously to existing macro for extracting GPIOTE instance property.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
…ponent

GPIOTE driver instances are no longer defined within nrfx.
Add a component supplementing missing functionality,
as GPIOTE driver instances are often shared across the system.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
…trol block

Align GPIOTE shim to changes in nrfx instantiation.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
… control block

GPIOTE driver instances are no longer defined within nrfx.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
…tracted cb

GPIOTE driver instances are no longer defined within nrfx.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
… with extracted cb

GPIOTE driver instances are no longer defined within nrfx.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
…with extracted cb

GPIOTE driver instances are no longer defined within nrfx.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
…xtracted cb

GPIOTE driver instances are no longer defined within nrfx.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
…th extracted cb

GPIOTE driver instances are no longer defined within nrfx.

Upstream PR #: 98527

Signed-off-by: Nikodem Kastelik <[email protected]>
Errno codes are returned now.

Upstream PR #: 98569

Signed-off-by: Nikodem Kastelik <[email protected]>
@nika-nordic nika-nordic force-pushed the nrfx_gpiote_extract_cb_sdkzephyr branch from abd7e9d to fd6783b Compare October 31, 2025 13:05
@masz-nordic masz-nordic merged commit d482a7d into nrfconnect:collab-nrfx-4.0 Oct 31, 2025
11 of 13 checks passed
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.

4 participants