Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 9 additions & 20 deletions drivers/counter/counter_nrfx_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,11 @@
#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)
#define COUNTER_ANY_FAST 1
#endif
#if NRF_DT_INST_ANY_IS_FAST && CONFIG_CLOCK_CONTROL
#define COUNTER_IS_FAST(idx) NRF_DT_INST_IS_FAST(idx)
#define COUNTER_ANY_FAST
#else
#define COUNTER_IS_FAST(idx) 0
#endif

struct counter_nrfx_data {
Expand Down Expand Up @@ -474,13 +463,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(COUNTER_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(COUNTER_IS_FAST(idx), \

Check notice on line 472 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:472 -#define TIMER_INIT_LEVEL(idx) \ - COND_CODE_1(COUNTER_IS_FAST(idx), (POST_KERNEL), (PRE_KERNEL_1)) +#define TIMER_INIT_LEVEL(idx) COND_CODE_1(COUNTER_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,8 +525,8 @@
}, \
.ch_data = counter##idx##_ch_data, \
.timer = (NRF_TIMER_Type *)DT_INST_REG_ADDR(idx), \
IF_ENABLED(INSTANCE_IS_FAST(idx), \
(.clk_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_DRV_INST(idx))), \
IF_ENABLED(COUNTER_IS_FAST(idx), \

Check notice on line 528 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:528 -#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_OR_NULL(DT_CLOCKS_CTLR(DT_DRV_INST(idx))), \
.clk_spec = { \
.frequency = NRF_PERIPH_GET_FREQUENCY(DT_DRV_INST(idx)), \
.accuracy = 0, \
Expand All @@ -553,5 +542,5 @@
&nrfx_counter_##idx##_config.info, \
TIMER_INIT_LEVEL(idx), TIMER_INIT_PRIO(idx), \
&counter_nrfx_driver_api);

Check notice on line 545 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:545 - )) \ - 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)
75 changes: 17 additions & 58 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 GPIO_HAS_PAD_GROUP 1
#else
#define GPIO_HAS_PAD_GROUP 0
#endif

#define GPIOTE_PHANDLE(id) DT_INST_PHANDLE(id, gpiote_instance)
Expand Down Expand Up @@ -56,8 +58,8 @@
#if defined(GPIOTE_FEATURE_FLAG)
uint32_t flags;
#endif
#ifdef CONFIG_SOC_NRF54H20_GPD
uint8_t pad_pd;
#if GPIO_HAS_PAD_GROUP
const struct device *pad_group;
#endif
};

Expand Down Expand Up @@ -87,30 +89,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 All @@ -122,6 +100,7 @@
nrfx_gpiote_pin_t abs_pin = NRF_GPIO_PIN_MAP(cfg->port_num, pin);
nrf_gpio_pin_pull_t pull = get_pull(flags);
nrf_gpio_pin_drive_t drive;
int pm_ret;

switch (flags & (NRF_GPIO_DRIVE_MSK | GPIO_OPEN_DRAIN)) {
case NRF_GPIO_DRIVE_S0S1:
Expand Down Expand Up @@ -157,8 +136,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 @@ -246,8 +223,7 @@
}

end:
gpio_nrfx_gpd_retain_set(port, BIT(pin));
int pm_ret = pm_device_runtime_put(port);
pm_ret = pm_device_runtime_put(port);

return (ret != 0) ? ret : pm_ret;
}
Expand Down Expand Up @@ -349,10 +325,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 @@ -367,9 +341,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 @@ -384,9 +356,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 @@ -404,10 +374,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 @@ -614,14 +582,10 @@

static int gpio_nrfx_pm_suspend(const struct device *port)
{
#ifdef CONFIG_SOC_NRF54H20_GPD
#if 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 @@ -630,14 +594,10 @@

static int gpio_nrfx_pm_resume(const struct device *port)
{
#ifdef CONFIG_SOC_NRF54H20_GPD
#if 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 @@ -727,12 +687,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 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 @@ -753,7 +712,7 @@
(DT_PROP_OR(GPIOTE_PHANDLE(id), fixed_channels_supported, 0) ? \
GPIOTE_FLAG_FIXED_CHAN : 0),) \
) \
PAD_PD(id) \
GPIO_NRF_PAD_GROUP_INIT(id) \
}; \
\
static struct gpio_nrfx_data gpio_nrfx_p##id##_data; \
Expand All @@ -767,5 +726,5 @@
PRE_KERNEL_1, \
CONFIG_GPIO_INIT_PRIORITY, \
&gpio_nrfx_drv_api_funcs);

Check notice on line 729 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:729 -#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), \ +#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), \ IF_ENABLED(GPIOTE_FEATURE_FLAG, \ (.flags = \ (DT_PROP_OR(GPIOTE_PHANDLE(id), no_port_event, 0) ? \ GPIOTE_FLAG_NO_PORT_EVT : 0) | \ (DT_PROP_OR(GPIOTE_PHANDLE(id), fixed_channels_supported, 0) ? \ GPIOTE_FLAG_FIXED_CHAN : 0),) \ - ) \ - 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); + ) \ + 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