Skip to content

Nrf pinctrl power domain refactor #3042

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

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
06f2903
[nrf fromtree] drivers: power_domain: Power domain TISCI driver support
Kronosblaster May 23, 2025
4ee9f4f
[nrf fromlist] drivers: power_domain: introduce nrfs gdpwr
bjarki-andreasen Jul 2, 2025
e2a0dd0
[nrf fromlist] drivers: power_domain: introduce nrfs swext
bjarki-andreasen Jul 2, 2025
1edf01c
[nrf fromlist] drivers: power_domain: introduce nrf_gpio_pad_group
bjarki-andreasen Jul 2, 2025
d3972f9
Revert "[nrf noup] drivers: pinctrl: Add SDP MSPI pin configuration"
bjarki-andreasen Jul 10, 2025
aace7c7
Revert "[nrf noup] drivers: spi_dw: Bring back custom EXMIF periphera…
bjarki-andreasen Jul 10, 2025
72fc897
[nrf fromtree] spi: nrfx_spim: fix incorrect clock control logic
JordanYates May 2, 2025
30a3448
Revert "[nrf noup] tests: arm_irq_vector_table: Disable starting of S…
bjarki-andreasen Jul 10, 2025
0999033
Revert "[nrf noup] dts: Select SoftDevice Controller DTS binding as d…
bjarki-andreasen Jul 10, 2025
3420b2c
Revert "[nrf noup] dts: Add Bluetooth Controller to nRF54H20"
bjarki-andreasen Jul 10, 2025
3b99813
[nrf fromlist] soc: nordic: nrf54h: transition from gpd to zephyr pin…
bjarki-andreasen Jul 3, 2025
4061da0
[nrf fromlist] soc: nrf54h: remove deprecated gpd (global power domai…
bjarki-andreasen Jul 3, 2025
de2a674
[nrf noup] dts: Add Bluetooth Controller to nRF54H20
rugeGerritsen Jul 16, 2024
447d61a
[nrf noup] dts: Select SoftDevice Controller DTS binding as default
rugeGerritsen Sep 5, 2024
4124dae
[nrf noup] tests: arm_irq_vector_table: Disable starting of SSF client
anangl Jan 24, 2025
ccb2d5a
[nrf noup] drivers: pinctrl: Add SDP MSPI pin configuration
jaz1-nordic Nov 25, 2024
2b52ec2
[nrf noup] drivers: spi_dw: Bring back custom EXMIF peripheral handling
anangl Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions drivers/can/can_nrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/irq.h>

#ifdef CONFIG_SOC_NRF54H20_GPD
#include <nrf/gpd.h>
#endif

/* nRF CAN wrapper offsets */
#define CAN_TASKS_START offsetof(NRF_CAN_Type, TASKS_START)
#define CAN_EVENTS_CORE_0 offsetof(NRF_CAN_Type, EVENTS_CORE[0])
Expand Down Expand Up @@ -187,13 +183,6 @@ static int can_nrf_init(const struct device *dev)
sys_write32(CAN_INTEN_CORE0_Msk | CAN_INTEN_CORE1_Msk, config->wrapper + CAN_INTEN);
sys_write32(1U, config->wrapper + CAN_TASKS_START);

#ifdef CONFIG_SOC_NRF54H20_GPD
ret = nrf_gpd_retain_pins_set(config->pcfg, false);
if (ret < 0) {
return ret;
}
#endif

config->irq_configure();

ret = can_mcan_configure_mram(dev, config->mrba, config->mram);
Expand Down
22 changes: 4 additions & 18 deletions drivers/counter/counter_nrfx_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,9 @@
#define MAYBE_CONST_CONFIG const
#endif

#ifdef CONFIG_SOC_NRF54H20_GPD
#include <nrf/gpd.h>

#define NRF_CLOCKS_INSTANCE_IS_FAST(node) \
COND_CODE_1(DT_NODE_HAS_PROP(node, power_domains), \
(IS_EQ(DT_PHA(node, power_domains, id), NRF_GPD_FAST_ACTIVE1)), \
(0))

/* Macro must resolve to literal 0 or 1 */
#define INSTANCE_IS_FAST(idx) NRF_CLOCKS_INSTANCE_IS_FAST(DT_DRV_INST(idx))

#define INSTANCE_IS_FAST_OR(idx) INSTANCE_IS_FAST(idx) ||

#if (DT_INST_FOREACH_STATUS_OKAY(INSTANCE_IS_FAST_OR) 0)
#if NRF_DT_INST_ANY_IS_FAST
#define COUNTER_ANY_FAST 1
#endif
#endif

struct counter_nrfx_data {
counter_top_callback_t top_cb;
Expand Down Expand Up @@ -474,13 +460,13 @@
* which is using nrfs (IPC) are initialized later.
*/
#define TIMER_INIT_LEVEL(idx) \
COND_CODE_1(INSTANCE_IS_FAST(idx), (POST_KERNEL), (PRE_KERNEL_1))
COND_CODE_1(NRF_DT_INST_IS_FAST(idx), (POST_KERNEL), (PRE_KERNEL_1))

/* Get initialization priority of an instance. Instances that requires clock control
* which is using nrfs (IPC) are initialized later.
*/
#define TIMER_INIT_PRIO(idx) \
COND_CODE_1(INSTANCE_IS_FAST(idx), \
COND_CODE_1(NRF_DT_INST_IS_FAST(idx), \

Check notice on line 469 in drivers/counter/counter_nrfx_timer.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/counter/counter_nrfx_timer.c:469 -#define TIMER_INIT_LEVEL(idx) \ - COND_CODE_1(NRF_DT_INST_IS_FAST(idx), (POST_KERNEL), (PRE_KERNEL_1)) +#define TIMER_INIT_LEVEL(idx) COND_CODE_1(NRF_DT_INST_IS_FAST(idx), (POST_KERNEL), (PRE_KERNEL_1)) /* Get initialization priority of an instance. Instances that requires clock control * which is using nrfs (IPC) are initialized later. */ -#define TIMER_INIT_PRIO(idx) \ +#define TIMER_INIT_PRIO(idx) \
(UTIL_INC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY)), \
(CONFIG_COUNTER_INIT_PRIORITY))

Expand Down Expand Up @@ -536,7 +522,7 @@
}, \
.ch_data = counter##idx##_ch_data, \
.timer = (NRF_TIMER_Type *)DT_INST_REG_ADDR(idx), \
IF_ENABLED(INSTANCE_IS_FAST(idx), \
IF_ENABLED(NRF_DT_INST_IS_FAST(idx), \

Check notice on line 525 in drivers/counter/counter_nrfx_timer.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/counter/counter_nrfx_timer.c:525 -#define COUNTER_NRFX_TIMER_DEVICE(idx) \ - BUILD_ASSERT(DT_INST_PROP(idx, prescaler) <= \ - TIMER_PRESCALER_PRESCALER_Msk, \ - "TIMER prescaler out of range"); \ +#define COUNTER_NRFX_TIMER_DEVICE(idx) \ + BUILD_ASSERT(DT_INST_PROP(idx, prescaler) <= TIMER_PRESCALER_PRESCALER_Msk, \ + "TIMER prescaler out of range"); \ COND_CODE_1(DT_INST_PROP(idx, zli), ( \ ISR_DIRECT_DECLARE(counter_timer##idx##_isr_wrapper) \ { \ irq_handler(DEVICE_DT_INST_GET(idx)); \ /* No rescheduling, it shall not access zephyr primitives. */ \ return 0; \ - }), ()) \ - static int counter_##idx##_init(const struct device *dev) \ - { \ - TIMER_IRQ_CONNECT(idx); \ - static const struct counter_timer_config config = { \ - .prescaler = DT_INST_PROP(idx, prescaler), \ - .mode = NRF_TIMER_MODE_TIMER, \ - .bit_width = (DT_INST_PROP(idx, max_bit_width) == 32) ? \ - NRF_TIMER_BIT_WIDTH_32 : NRF_TIMER_BIT_WIDTH_16, \ - }; \ - return init_timer(dev, &config); \ - } \ - static struct counter_nrfx_data counter_##idx##_data; \ - static struct counter_nrfx_ch_data \ - counter##idx##_ch_data[CC_TO_ID(DT_INST_PROP(idx, cc_num))]; \ - LOG_INSTANCE_REGISTER(LOG_MODULE_NAME, idx, CONFIG_COUNTER_LOG_LEVEL); \ - static MAYBE_CONST_CONFIG struct counter_nrfx_config nrfx_counter_##idx##_config = { \ - .info = { \ - .max_top_value = (uint32_t)BIT64_MASK(DT_INST_PROP(idx, max_bit_width)),\ - .freq = NRF_PERIPH_GET_FREQUENCY(DT_DRV_INST(idx)) / \ - BIT(DT_INST_PROP(idx, prescaler)), \ - .flags = COUNTER_CONFIG_INFO_COUNT_UP, \ - .channels = CC_TO_ID(DT_INST_PROP(idx, cc_num)), \ - }, \ - .ch_data = counter##idx##_ch_data, \ - .timer = (NRF_TIMER_Type *)DT_INST_REG_ADDR(idx), \ + }), ()) \ + static int counter_##idx##_init(const struct device *dev) \ + { \ + TIMER_IRQ_CONNECT(idx); \ + static const struct counter_timer_config config = { \ + .prescaler = DT_INST_PROP(idx, prescaler), \ + .mode = NRF_TIMER_MODE_TIMER, \ + .bit_width = (DT_INST_PROP(idx, max_bit_width) == 32) \ + ? NRF_TIMER_BIT_WIDTH_32 \ + : NRF_TIMER_BIT_WIDTH_16, \ + }; \ + return init_timer(dev, &config); \ + } \ + static struct counter_nrfx_data counter_##idx##_data; \ + static struct counter_nrfx_ch_data \ + counter##idx##_ch_data[CC_TO_ID(DT_INST_PROP(idx, cc_num))]; \ + LOG_INSTANCE_REGISTER(LOG_MODULE_NAME, idx, CONFIG_COUNTER_LOG_LEVEL); \ + static MAYBE_CONST_CONFIG struct counter_nrfx_config nrfx_counter_##idx##_config = { \ + .info = \ + { \ + .max_top_value = \ + (uint32_t)BIT64_MASK(DT_INST_PROP(idx, max_bit_width)), \ + .freq = NRF_PERIPH_GET_FREQUENCY(DT_DRV_INST(idx)) / \ + BIT(DT_INST_PROP(idx, prescaler)), \ + .flags = COUNTER_CONFIG_INFO_COUNT_UP,
(.clk_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_DRV_INST(idx))), \
.clk_spec = { \
.frequency = NRF_PERIPH_GET_FREQUENCY(DT_DRV_INST(idx)), \
Expand All @@ -553,5 +539,5 @@
&nrfx_counter_##idx##_config.info, \
TIMER_INIT_LEVEL(idx), TIMER_INIT_PRIO(idx), \
&counter_nrfx_driver_api);

Check notice on line 542 in drivers/counter/counter_nrfx_timer.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/counter/counter_nrfx_timer.c:542 - )) \ - LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, idx) \ - }; \ - DEVICE_DT_INST_DEFINE(idx, \ - counter_##idx##_init, \ - NULL, \ - &counter_##idx##_data, \ - &nrfx_counter_##idx##_config.info, \ - TIMER_INIT_LEVEL(idx), TIMER_INIT_PRIO(idx), \ - &counter_nrfx_driver_api); + )) \ + LOG_INSTANCE_PTR_INIT(log, LOG_MODULE_NAME, \ + idx)}; \ + DEVICE_DT_INST_DEFINE(idx, counter_##idx##_init, NULL, &counter_##idx##_data, \ + &nrfx_counter_##idx##_config.info, TIMER_INIT_LEVEL(idx), \ + TIMER_INIT_PRIO(idx), &counter_nrfx_driver_api);
DT_INST_FOREACH_STATUS_OKAY(COUNTER_NRFX_TIMER_DEVICE)
72 changes: 15 additions & 57 deletions drivers/gpio/gpio_nrfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

#include <zephyr/drivers/gpio/gpio_utils.h>

#ifdef CONFIG_SOC_NRF54H20_GPD
#include <nrf/gpd.h>
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_gpio_pad_group)
#define NRF_GPIO_HAS_PAD_GROUP 1
#else
#define NRF_GPIO_HAS_PAD_GROUP 0
#endif

struct gpio_nrfx_data {
Expand All @@ -33,8 +35,8 @@
uint32_t edge_sense;
uint8_t port_num;
nrfx_gpiote_t gpiote;
#ifdef CONFIG_SOC_NRF54H20_GPD
uint8_t pad_pd;
#if NRF_GPIO_HAS_PAD_GROUP
const struct device *pad_group;
#endif
};

Expand Down Expand Up @@ -64,30 +66,6 @@
return NRF_GPIO_PIN_NOPULL;
}

static void gpio_nrfx_gpd_retain_set(const struct device *port, uint32_t mask)
{
#ifdef CONFIG_SOC_NRF54H20_GPD
const struct gpio_nrfx_cfg *cfg = get_port_cfg(port);

nrf_gpio_port_retain_enable(cfg->port, mask);
#else
ARG_UNUSED(port);
ARG_UNUSED(mask);
#endif
}

static void gpio_nrfx_gpd_retain_clear(const struct device *port, uint32_t mask)
{
#ifdef CONFIG_SOC_NRF54H20_GPD
const struct gpio_nrfx_cfg *cfg = get_port_cfg(port);

nrf_gpio_port_retain_disable(cfg->port, mask);
#else
ARG_UNUSED(port);
ARG_UNUSED(mask);
#endif
}

static int gpio_nrfx_pin_configure(const struct device *port, gpio_pin_t pin,
gpio_flags_t flags)
{
Expand Down Expand Up @@ -134,8 +112,6 @@
return ret;
}

gpio_nrfx_gpd_retain_clear(port, BIT(pin));

if (flags & GPIO_OUTPUT_INIT_HIGH) {
nrf_gpio_port_out_set(cfg->port, BIT(pin));
} else if (flags & GPIO_OUTPUT_INIT_LOW) {
Expand Down Expand Up @@ -216,7 +192,6 @@
}

end:
gpio_nrfx_gpd_retain_set(port, BIT(pin));
return pm_device_runtime_put(port);
}

Expand Down Expand Up @@ -317,10 +292,8 @@
return ret;
}

gpio_nrfx_gpd_retain_clear(port, mask);
nrf_gpio_port_out_set(reg, set_mask);
nrf_gpio_port_out_clear(reg, clear_mask);
gpio_nrfx_gpd_retain_set(port, mask);
return pm_device_runtime_put(port);
}

Expand All @@ -335,9 +308,7 @@
return ret;
}

gpio_nrfx_gpd_retain_clear(port, mask);
nrf_gpio_port_out_set(reg, mask);
gpio_nrfx_gpd_retain_set(port, mask);
return pm_device_runtime_put(port);
}

Expand All @@ -352,9 +323,7 @@
return ret;
}

gpio_nrfx_gpd_retain_clear(port, mask);
nrf_gpio_port_out_clear(reg, mask);
gpio_nrfx_gpd_retain_set(port, mask);
return pm_device_runtime_put(port);
}

Expand All @@ -372,10 +341,8 @@
return ret;
}

gpio_nrfx_gpd_retain_clear(port, mask);
nrf_gpio_port_out_set(reg, set_mask);
nrf_gpio_port_out_clear(reg, clear_mask);
gpio_nrfx_gpd_retain_set(port, mask);
return pm_device_runtime_put(port);
}

Expand Down Expand Up @@ -546,14 +513,10 @@

static int gpio_nrfx_pm_suspend(const struct device *port)
{
#ifdef CONFIG_SOC_NRF54H20_GPD
#if NRF_GPIO_HAS_PAD_GROUP
const struct gpio_nrfx_cfg *cfg = get_port_cfg(port);

if (cfg->pad_pd != NRF_GPD_FAST_ACTIVE1) {
return 0;
}

return nrf_gpd_release(NRF_GPD_FAST_ACTIVE1);
return pm_device_runtime_put(cfg->pad_group);
#else
ARG_UNUSED(port);
return 0;
Expand All @@ -562,14 +525,10 @@

static int gpio_nrfx_pm_resume(const struct device *port)
{
#ifdef CONFIG_SOC_NRF54H20_GPD
#if NRF_GPIO_HAS_PAD_GROUP
const struct gpio_nrfx_cfg *cfg = get_port_cfg(port);

if (cfg->pad_pd != NRF_GPD_FAST_ACTIVE1) {
return 0;
}

return nrf_gpd_request(NRF_GPD_FAST_ACTIVE1);
return pm_device_runtime_get(cfg->pad_group);
#else
ARG_UNUSED(port);
return 0;
Expand Down Expand Up @@ -660,12 +619,11 @@
"Please enable GPIOTE instance for used GPIO port!")), \
())

#ifdef CONFIG_SOC_NRF54H20_GPD
#define PAD_PD(inst) \
.pad_pd = DT_INST_PHA_BY_NAME_OR(inst, power_domains, pad, id, \
NRF_GPD_SLOW_MAIN),
#if NRF_GPIO_HAS_PAD_GROUP
#define GPIO_NRF_PAD_GROUP_INIT(id) \
.pad_group = DEVICE_DT_GET(DT_INST_CHILD(id, pad_group)),
#else
#define PAD_PD(inst)
#define GPIO_NRF_PAD_GROUP_INIT(id)
#endif

#define GPIO_NRF_DEVICE(id) \
Expand All @@ -679,7 +637,7 @@
.port_num = DT_INST_PROP(id, port), \
.edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \
.gpiote = GPIOTE_INSTANCE(id), \
PAD_PD(id) \
GPIO_NRF_PAD_GROUP_INIT(id) \
}; \
\
static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \
Expand All @@ -693,5 +651,5 @@
PRE_KERNEL_1, \
CONFIG_GPIO_INIT_PRIORITY, \
&gpio_nrfx_drv_api_funcs);

Check notice on line 654 in drivers/gpio/gpio_nrfx.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/gpio/gpio_nrfx.c:654 -#define GPIO_NRF_PAD_GROUP_INIT(id) \ - .pad_group = DEVICE_DT_GET(DT_INST_CHILD(id, pad_group)), +#define GPIO_NRF_PAD_GROUP_INIT(id) .pad_group = DEVICE_DT_GET(DT_INST_CHILD(id, pad_group)), #else #define GPIO_NRF_PAD_GROUP_INIT(id) #endif -#define GPIO_NRF_DEVICE(id) \ - GPIOTE_CHECK(id); \ - static const struct gpio_nrfx_cfg gpio_nrfx_p##id##_cfg = { \ - .common = { \ - .port_pin_mask = \ - GPIO_PORT_PIN_MASK_FROM_DT_INST(id), \ - }, \ - .port = _CONCAT(NRF_P, DT_INST_PROP(id, port)), \ - .port_num = DT_INST_PROP(id, port), \ - .edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \ - .gpiote = GPIOTE_INSTANCE(id), \ - GPIO_NRF_PAD_GROUP_INIT(id) \ - }; \ - \ - static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \ - \ - PM_DEVICE_DT_INST_DEFINE(id, gpio_nrfx_pm_hook); \ - \ - DEVICE_DT_INST_DEFINE(id, gpio_nrfx_init, \ - PM_DEVICE_DT_INST_GET(id), \ - &gpio_nrfx_p##id##_data, \ - &gpio_nrfx_p##id##_cfg, \ - PRE_KERNEL_1, \ - CONFIG_GPIO_INIT_PRIORITY, \ - &gpio_nrfx_drv_api_funcs); +#define GPIO_NRF_DEVICE(id) \ + GPIOTE_CHECK(id); \ + static const struct gpio_nrfx_cfg gpio_nrfx_p##id##_cfg = { \ + .common = \ + { \ + .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(id), \ + }, \ + .port = _CONCAT(NRF_P, DT_INST_PROP(id, port)), \ + .port_num = DT_INST_PROP(id, port), \ + .edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \ + .gpiote = GPIOTE_INSTANCE(id), \ + GPIO_NRF_PAD_GROUP_INIT(id)}; \ + \ + static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \ + \ + PM_DEVICE_DT_INST_DEFINE(id, gpio_nrfx_pm_hook); \ + \ + DEVICE_DT_INST_DEFINE(id, gpio_nrfx_init, PM_DEVICE_DT_INST_GET(id), \ + &gpio_nrfx_p##id##_data, &gpio_nrfx_p##id##_cfg, PRE_KERNEL_1, \ + CONFIG_GPIO_INIT_PRIORITY, &gpio_nrfx_drv_api_funcs);
DT_INST_FOREACH_STATUS_OKAY(GPIO_NRF_DEVICE)
Loading
Loading