From 9178065856efd855c5def645b6430f20abaf6fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bainczyk?= Date: Wed, 1 Oct 2025 11:02:37 +0200 Subject: [PATCH 1/3] [nrf fromlist] drivers: pwm: pwm_nrfx: use standard instantiation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use API for standard instantiation and replace nrfx_err_t error values with errno. Upstream PR #: 96843 Signed-off-by: Michał Bainczyk --- drivers/pwm/pwm_nrfx.c | 179 +++++++++++++++++++++-------------------- 1 file changed, 91 insertions(+), 88 deletions(-) diff --git a/drivers/pwm/pwm_nrfx.c b/drivers/pwm/pwm_nrfx.c index 8565fd1187a..9fdb7a9ee67 100644 --- a/drivers/pwm/pwm_nrfx.c +++ b/drivers/pwm/pwm_nrfx.c @@ -3,6 +3,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ + +#define DT_DRV_COMPAT nordic_nrf_pwm + #include #include #include @@ -33,10 +36,7 @@ LOG_MODULE_REGISTER(pwm_nrfx, CONFIG_PWM_LOG_LEVEL); #define ANOMALY_109_EGU_IRQ_CONNECT(idx) #endif -#define PWM(dev_idx) DT_NODELABEL(pwm##dev_idx) -#define PWM_PROP(dev_idx, prop) DT_PROP(PWM(dev_idx), prop) -#define PWM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(PWM(idx), prop) -#define PWM_NRFX_IS_FAST(idx) NRF_DT_IS_FAST(PWM(idx)) +#define PWM_NRFX_IS_FAST(inst) NRF_DT_IS_FAST(DT_DRV_INST(inst)) #if NRF_DT_INST_ANY_IS_FAST #define PWM_NRFX_FAST_PRESENT 1 @@ -57,7 +57,6 @@ BUILD_ASSERT(!IS_ENABLED(CONFIG_PM_DEVICE_SYSTEM_MANAGED)); (compare_value | (inverted ? 0 : PWM_NRFX_CH_POLARITY_MASK)) struct pwm_nrfx_config { - nrfx_pwm_t pwm; nrfx_pwm_config_t initial_config; nrf_pwm_sequence_t seq; const struct pinctrl_dev_config *pcfg; @@ -72,6 +71,7 @@ struct pwm_nrfx_config { }; struct pwm_nrfx_data { + nrfx_pwm_t pwm; uint32_t period_cycles; /* Bit mask indicating channels that need the PWM generation. */ uint8_t pwm_needed; @@ -145,7 +145,7 @@ static bool pwm_period_check_and_set(const struct device *dev, data->period_cycles = period_cycles; data->prescaler = prescaler; - nrf_pwm_configure(config->pwm.p_reg, + nrf_pwm_configure(data->pwm.p_reg, data->prescaler, config->initial_config.count_mode, (uint16_t)countertop); @@ -160,10 +160,9 @@ static bool pwm_period_check_and_set(const struct device *dev, return false; } -static bool channel_psel_get(uint32_t channel, uint32_t *psel, - const struct pwm_nrfx_config *config) +static bool channel_psel_get(uint32_t channel, uint32_t *psel, struct pwm_nrfx_data *data) { - *psel = nrf_pwm_pin_get(config->pwm.p_reg, (uint8_t)channel); + *psel = nrf_pwm_pin_get(data->pwm.p_reg, (uint8_t)channel); return (((*psel & PWM_PSEL_OUT_CONNECT_Msk) >> PWM_PSEL_OUT_CONNECT_Pos) == PWM_PSEL_OUT_CONNECT_Connected); @@ -171,15 +170,15 @@ static bool channel_psel_get(uint32_t channel, uint32_t *psel, static int stop_pwm(const struct device *dev) { - const struct pwm_nrfx_config *config = dev->config; + struct pwm_nrfx_data *data = dev->data; /* Don't wait here for the peripheral to actually stop. Instead, - * ensure it is stopped before starting the next playback. - */ - nrfx_pwm_stop(&config->pwm, false); + * ensure it is stopped before starting the next playback. + */ + nrfx_pwm_stop(&data->pwm, false); #if PWM_NRFX_USE_CLOCK_CONTROL - struct pwm_nrfx_data *data = dev->data; + const struct pwm_nrfx_config *config = dev->config; if (data->clock_requested) { int ret = nrf_clock_control_release(config->clk_dev, &config->clk_spec); @@ -268,7 +267,7 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel, if (!needs_pwm) { uint32_t psel; - if (channel_psel_get(channel, &psel, config)) { + if (channel_psel_get(channel, &psel, data)) { uint32_t out_level = (pulse_cycles == 0) ? 0 : 1; if (inverted) { @@ -323,7 +322,7 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel, * and till that moment, it ignores any start requests, * so ensure here that it is stopped. */ - while (!nrfx_pwm_stopped_check(&config->pwm)) { + while (!nrfx_pwm_stopped_check(&data->pwm)) { } } @@ -346,7 +345,7 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel, data->clock_requested = true; } #endif - nrfx_pwm_simple_playback(&config->pwm, &config->seq, 1, + nrfx_pwm_simple_playback(&data->pwm, &config->seq, 1, NRFX_PWM_FLAG_NO_EVT_FINISHED); } @@ -371,6 +370,8 @@ static DEVICE_API(pwm, pwm_nrfx_drv_api_funcs) = { static int pwm_resume(const struct device *dev) { const struct pwm_nrfx_config *config = dev->config; + struct pwm_nrfx_data *data = dev->data; + uint8_t initially_inverted = 0; (void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); @@ -378,7 +379,7 @@ static int pwm_resume(const struct device *dev) for (size_t i = 0; i < NRF_PWM_CHANNEL_COUNT; i++) { uint32_t psel; - if (channel_psel_get(i, &psel, config)) { + if (channel_psel_get(i, &psel, data)) { /* Mark channels as inverted according to what initial * state of their outputs has been set by pinctrl (high * idle state means that the channel is inverted). @@ -400,6 +401,7 @@ static int pwm_resume(const struct device *dev) static int pwm_suspend(const struct device *dev) { const struct pwm_nrfx_config *config = dev->config; + struct pwm_nrfx_data *data = dev->data; int ret = stop_pwm(dev); @@ -408,7 +410,7 @@ static int pwm_suspend(const struct device *dev) return ret; } - while (!nrfx_pwm_stopped_check(&config->pwm)) { + while (!nrfx_pwm_stopped_check(&data->pwm)) { } memset(dev->data, 0, sizeof(struct pwm_nrfx_data)); @@ -434,7 +436,9 @@ static int pwm_nrfx_pm_action(const struct device *dev, static int pwm_nrfx_init(const struct device *dev) { const struct pwm_nrfx_config *config = dev->config; - nrfx_err_t err; + struct pwm_nrfx_data *data = dev->data; + + int err; ANOMALY_109_EGU_IRQ_CONNECT(NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE); @@ -442,26 +446,26 @@ static int pwm_nrfx_init(const struct device *dev) (void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP); } - err = nrfx_pwm_init(&config->pwm, &config->initial_config, pwm_handler, dev->data); - if (err != NRFX_SUCCESS) { + err = nrfx_pwm_init(&data->pwm, &config->initial_config, pwm_handler, dev->data); + if (err < 0) { LOG_ERR("Failed to initialize device: %s", dev->name); - return -EBUSY; + return err; } return pm_device_driver_init(dev, pwm_nrfx_pm_action); } -#define PWM_MEM_REGION(idx) DT_PHANDLE(PWM(idx), memory_regions) +#define PWM_MEM_REGION(inst) DT_PHANDLE(DT_DRV_INST(inst), memory_regions) -#define PWM_MEMORY_SECTION(idx) \ - COND_CODE_1(PWM_HAS_PROP(idx, memory_regions), \ +#define PWM_MEMORY_SECTION(inst) \ + COND_CODE_1(DT_NODE_HAS_PROP(inst, memory_regions), \ (__attribute__((__section__(LINKER_DT_NODE_REGION_NAME( \ - PWM_MEM_REGION(idx)))))), \ + PWM_MEM_REGION(inst)))))), \ ()) -#define PWM_GET_MEM_ATTR(idx) \ - COND_CODE_1(PWM_HAS_PROP(idx, memory_regions), \ - (DT_PROP_OR(PWM_MEM_REGION(idx), zephyr_memory_attr, 0)), (0)) +#define PWM_GET_MEM_ATTR(inst) \ + COND_CODE_1(DT_NODE_HAS_PROP(inst, memory_regions), \ + (DT_PROP_OR(PWM_MEM_REGION(inst), zephyr_memory_attr, 0)), (0)) /* Fast instances depend on the global HSFLL clock controller (as they need * to request the highest frequency from it to operate correctly), so they @@ -470,66 +474,65 @@ static int pwm_nrfx_init(const struct device *dev) */ #if defined(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY) && \ CONFIG_PWM_INIT_PRIORITY < CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY -#define PWM_INIT_PRIORITY(idx) \ - COND_CODE_1(PWM_NRFX_IS_FAST(idx), \ +#define PWM_INIT_PRIORITY(inst) \ + COND_CODE_1(PWM_NRFX_IS_FAST(inst), \ (UTIL_INC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY)), \ (CONFIG_PWM_INIT_PRIORITY)) #else -#define PWM_INIT_PRIORITY(idx) CONFIG_PWM_INIT_PRIORITY +#define PWM_INIT_PRIORITY(inst) CONFIG_PWM_INIT_PRIORITY #endif -#define PWM_NRFX_DEVICE(idx) \ - NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(PWM(idx)); \ - NRF_DT_CHECK_NODE_HAS_REQUIRED_MEMORY_REGIONS(PWM(idx)); \ - static struct pwm_nrfx_data pwm_nrfx_##idx##_data; \ - static uint16_t pwm_##idx##_seq_values[NRF_PWM_CHANNEL_COUNT] \ - PWM_MEMORY_SECTION(idx); \ - PINCTRL_DT_DEFINE(PWM(idx)); \ - static const struct pwm_nrfx_config pwm_nrfx_##idx##_config = { \ - .pwm = NRFX_PWM_INSTANCE(idx), \ - .initial_config = { \ - .skip_gpio_cfg = true, \ - .skip_psel_cfg = true, \ - .base_clock = NRF_PWM_CLK_1MHz, \ - .count_mode = (PWM_PROP(idx, center_aligned) \ - ? NRF_PWM_MODE_UP_AND_DOWN \ - : NRF_PWM_MODE_UP), \ - .top_value = 1000, \ - .load_mode = NRF_PWM_LOAD_INDIVIDUAL, \ - .step_mode = NRF_PWM_STEP_TRIGGERED, \ - }, \ - .seq.values.p_raw = pwm_##idx##_seq_values, \ - .seq.length = NRF_PWM_CHANNEL_COUNT, \ - .pcfg = PINCTRL_DT_DEV_CONFIG_GET(PWM(idx)), \ - .clock_freq = COND_CODE_1(DT_CLOCKS_HAS_IDX(PWM(idx), 0), \ - (DT_PROP(DT_CLOCKS_CTLR(PWM(idx)), clock_frequency)), \ - (16ul * 1000ul * 1000ul)), \ - IF_ENABLED(CONFIG_DCACHE, \ - (.mem_attr = PWM_GET_MEM_ATTR(idx),)) \ - IF_ENABLED(PWM_NRFX_USE_CLOCK_CONTROL, \ - (.clk_dev = PWM_NRFX_IS_FAST(idx) \ - ? DEVICE_DT_GET(DT_CLOCKS_CTLR(PWM(idx))) \ - : NULL, \ - .clk_spec = { \ - .frequency = \ - NRF_PERIPH_GET_FREQUENCY(PWM(idx)), \ - },)) \ - }; \ - static int pwm_nrfx_init##idx(const struct device *dev) \ - { \ - IRQ_CONNECT(DT_IRQN(PWM(idx)), DT_IRQ(PWM(idx), priority), \ - nrfx_isr, nrfx_pwm_##idx##_irq_handler, 0); \ - return pwm_nrfx_init(dev); \ - }; \ - PM_DEVICE_DT_DEFINE(PWM(idx), pwm_nrfx_pm_action); \ - DEVICE_DT_DEFINE(PWM(idx), \ - pwm_nrfx_init##idx, PM_DEVICE_DT_GET(PWM(idx)), \ - &pwm_nrfx_##idx##_data, \ - &pwm_nrfx_##idx##_config, \ - POST_KERNEL, PWM_INIT_PRIORITY(idx), \ - &pwm_nrfx_drv_api_funcs) - -#define COND_PWM_NRFX_DEVICE(unused, prefix, i, _) \ - IF_ENABLED(CONFIG_HAS_HW_NRF_PWM##prefix##i, (PWM_NRFX_DEVICE(prefix##i);)) - -NRFX_FOREACH_PRESENT(PWM, COND_PWM_NRFX_DEVICE, (), (), _) +#define PWM_NRFX_DEFINE(inst) \ + NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(DT_DRV_INST(inst)); \ + NRF_DT_CHECK_NODE_HAS_REQUIRED_MEMORY_REGIONS(DT_DRV_INST(inst)); \ + static struct pwm_nrfx_data pwm_nrfx_##inst##_data = { \ + .pwm = NRFX_PWM_INSTANCE(DT_INST_REG_ADDR(inst)), \ + }; \ + static uint16_t pwm_##inst##_seq_values[NRF_PWM_CHANNEL_COUNT] \ + PWM_MEMORY_SECTION(inst); \ + PINCTRL_DT_INST_DEFINE(inst); \ + static const struct pwm_nrfx_config pwm_nrfx_##inst##_config = { \ + .initial_config = { \ + .skip_gpio_cfg = true, \ + .skip_psel_cfg = true, \ + .base_clock = NRF_PWM_CLK_1MHz, \ + .count_mode = (DT_INST_PROP(inst, center_aligned) \ + ? NRF_PWM_MODE_UP_AND_DOWN \ + : NRF_PWM_MODE_UP), \ + .top_value = 1000, \ + .load_mode = NRF_PWM_LOAD_INDIVIDUAL, \ + .step_mode = NRF_PWM_STEP_TRIGGERED, \ + }, \ + .seq.values.p_raw = pwm_##inst##_seq_values, \ + .seq.length = NRF_PWM_CHANNEL_COUNT, \ + .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \ + .clock_freq = COND_CODE_1(DT_INST_CLOCKS_HAS_IDX(inst, 0), \ + (DT_PROP(DT_INST_CLOCKS_CTLR(inst), clock_frequency)), \ + (16ul * 1000ul * 1000ul)), \ + IF_ENABLED(CONFIG_DCACHE, \ + (.mem_attr = PWM_GET_MEM_ATTR(inst),)) \ + IF_ENABLED(PWM_NRFX_USE_CLOCK_CONTROL, \ + (.clk_dev = PWM_NRFX_IS_FAST(inst) \ + ? DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(inst)) \ + : NULL, \ + .clk_spec = { \ + .frequency = \ + NRF_PERIPH_GET_FREQUENCY(DT_DRV_INST(inst)), \ + },)) \ + }; \ + static int pwm_nrfx_init##inst(const struct device *dev) \ + { \ + IRQ_CONNECT(DT_INST_IRQN(inst), DT_INST_IRQ(inst, priority), \ + nrfx_pwm_irq_handler, &pwm_nrfx_##inst##_data.pwm, 0); \ + return pwm_nrfx_init(dev); \ + }; \ + PM_DEVICE_DT_INST_DEFINE(inst, pwm_nrfx_pm_action); \ + DEVICE_DT_INST_DEINIT_DEFINE(inst, \ + pwm_nrfx_init##inst, NULL, \ + PM_DEVICE_DT_INST_GET(inst), \ + &pwm_nrfx_##inst##_data, \ + &pwm_nrfx_##inst##_config, \ + POST_KERNEL, PWM_INIT_PRIORITY(inst), \ + &pwm_nrfx_drv_api_funcs) + +DT_INST_FOREACH_STATUS_OKAY(PWM_NRFX_DEFINE) From 68bd5b2e0a8fd97f9d5201196e6503264ca194ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bainczyk?= Date: Wed, 1 Oct 2025 11:09:41 +0200 Subject: [PATCH 2/3] [nrf fromlist] modules: hal_nordic: remove PWM symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove Kconfig symbols for each PWM instance which are no longer needed. Upstream PR #: 96843 Signed-off-by: Michał Bainczyk --- drivers/pwm/Kconfig.nrfx | 13 +----- modules/hal_nordic/nrfx/Kconfig | 60 -------------------------- modules/hal_nordic/nrfx/nrfx_kconfig.h | 36 ---------------- soc/nordic/common/Kconfig.peripherals | 36 ---------------- 4 files changed, 1 insertion(+), 144 deletions(-) diff --git a/drivers/pwm/Kconfig.nrfx b/drivers/pwm/Kconfig.nrfx index d99b5aaf3ab..7bb3881ffc4 100644 --- a/drivers/pwm/Kconfig.nrfx +++ b/drivers/pwm/Kconfig.nrfx @@ -5,18 +5,7 @@ config PWM_NRFX bool "nRF PWM nrfx driver" default y depends on DT_HAS_NORDIC_NRF_PWM_ENABLED - select NRFX_PWM0 if HAS_HW_NRF_PWM0 - select NRFX_PWM1 if HAS_HW_NRF_PWM1 - select NRFX_PWM2 if HAS_HW_NRF_PWM2 - select NRFX_PWM3 if HAS_HW_NRF_PWM3 - select NRFX_PWM20 if HAS_HW_NRF_PWM20 - select NRFX_PWM21 if HAS_HW_NRF_PWM21 - select NRFX_PWM22 if HAS_HW_NRF_PWM22 - select NRFX_PWM120 if HAS_HW_NRF_PWM120 - select NRFX_PWM130 if HAS_HW_NRF_PWM130 - select NRFX_PWM131 if HAS_HW_NRF_PWM131 - select NRFX_PWM132 if HAS_HW_NRF_PWM132 - select NRFX_PWM133 if HAS_HW_NRF_PWM133 + select NRFX_PWM select PINCTRL help Enable support for nrfx Hardware PWM driver for nRF52 MCU series. diff --git a/modules/hal_nordic/nrfx/Kconfig b/modules/hal_nordic/nrfx/Kconfig index 523931be649..e81a04e2f17 100644 --- a/modules/hal_nordic/nrfx/Kconfig +++ b/modules/hal_nordic/nrfx/Kconfig @@ -370,66 +370,6 @@ config NRFX_PPIB30 config NRFX_PWM bool -config NRFX_PWM0 - bool "PWM0 driver instance" - depends on $(dt_nodelabel_exists,pwm0) - select NRFX_PWM - -config NRFX_PWM1 - bool "PWM1 driver instance" - depends on $(dt_nodelabel_exists,pwm1) - select NRFX_PWM - -config NRFX_PWM2 - bool "PWM2 driver instance" - depends on $(dt_nodelabel_exists,pwm2) - select NRFX_PWM - -config NRFX_PWM3 - bool "PWM3 driver instance" - depends on $(dt_nodelabel_exists,pwm3) - select NRFX_PWM - -config NRFX_PWM20 - bool "PWM20 driver instance" - depends on $(dt_nodelabel_exists,pwm20) - select NRFX_PWM - -config NRFX_PWM21 - bool "PWM21 driver instance" - depends on $(dt_nodelabel_exists,pwm21) - select NRFX_PWM - -config NRFX_PWM22 - bool "PWM22 driver instance" - depends on $(dt_nodelabel_exists,pwm22) - select NRFX_PWM - -config NRFX_PWM120 - bool "PWM120 driver instance" - depends on $(dt_nodelabel_exists,pwm120) - select NRFX_PWM - -config NRFX_PWM130 - bool "PWM130 driver instance" - depends on $(dt_nodelabel_exists,pwm130) - select NRFX_PWM - -config NRFX_PWM131 - bool "PWM131 driver instance" - depends on $(dt_nodelabel_exists,pwm131) - select NRFX_PWM - -config NRFX_PWM132 - bool "PWM132 driver instance" - depends on $(dt_nodelabel_exists,pwm132) - select NRFX_PWM - -config NRFX_PWM133 - bool "PWM133 driver instance" - depends on $(dt_nodelabel_exists,pwm133) - select NRFX_PWM - config NRFX_QDEC bool diff --git a/modules/hal_nordic/nrfx/nrfx_kconfig.h b/modules/hal_nordic/nrfx/nrfx_kconfig.h index 4f0d594a212..38280beddeb 100644 --- a/modules/hal_nordic/nrfx/nrfx_kconfig.h +++ b/modules/hal_nordic/nrfx/nrfx_kconfig.h @@ -355,42 +355,6 @@ #ifdef CONFIG_NRFX_PWM_LOG #define NRFX_PWM_CONFIG_LOG_ENABLED 1 #endif -#ifdef CONFIG_NRFX_PWM0 -#define NRFX_PWM0_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM1 -#define NRFX_PWM1_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM2 -#define NRFX_PWM2_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM3 -#define NRFX_PWM3_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM20 -#define NRFX_PWM20_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM21 -#define NRFX_PWM21_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM22 -#define NRFX_PWM22_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM120 -#define NRFX_PWM120_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM130 -#define NRFX_PWM130_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM131 -#define NRFX_PWM131_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM132 -#define NRFX_PWM132_ENABLED 1 -#endif -#ifdef CONFIG_NRFX_PWM133 -#define NRFX_PWM133_ENABLED 1 -#endif #ifdef CONFIG_NRFX_QDEC #define NRFX_QDEC_ENABLED 1 diff --git a/soc/nordic/common/Kconfig.peripherals b/soc/nordic/common/Kconfig.peripherals index fa7fd2a411a..72db868103b 100644 --- a/soc/nordic/common/Kconfig.peripherals +++ b/soc/nordic/common/Kconfig.peripherals @@ -144,42 +144,6 @@ config HAS_HW_NRF_POWER config HAS_HW_NRF_PPI def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_PPI)) -config HAS_HW_NRF_PWM0 - def_bool $(dt_nodelabel_enabled_with_compat,pwm0,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM1 - def_bool $(dt_nodelabel_enabled_with_compat,pwm1,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM2 - def_bool $(dt_nodelabel_enabled_with_compat,pwm2,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM3 - def_bool $(dt_nodelabel_enabled_with_compat,pwm3,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM20 - def_bool $(dt_nodelabel_enabled_with_compat,pwm20,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM21 - def_bool $(dt_nodelabel_enabled_with_compat,pwm21,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM22 - def_bool $(dt_nodelabel_enabled_with_compat,pwm22,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM120 - def_bool $(dt_nodelabel_enabled_with_compat,pwm120,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM130 - def_bool $(dt_nodelabel_enabled_with_compat,pwm130,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM131 - def_bool $(dt_nodelabel_enabled_with_compat,pwm131,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM132 - def_bool $(dt_nodelabel_enabled_with_compat,pwm132,$(DT_COMPAT_NORDIC_NRF_PWM)) - -config HAS_HW_NRF_PWM133 - def_bool $(dt_nodelabel_enabled_with_compat,pwm133,$(DT_COMPAT_NORDIC_NRF_PWM)) - config HAS_HW_NRF_QDEC0 def_bool $(dt_nodelabel_enabled_with_compat,qdec0,$(DT_COMPAT_NORDIC_NRF_QDEC)) From cbe971972a850ef849f8f8b47d6fc9c8cd56df8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bainczyk?= Date: Wed, 1 Oct 2025 11:22:21 +0200 Subject: [PATCH 3/3] [nrf fromlist] modules: hal_nordic: add new errno error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add macro for translating new errno error codes to strings. Upstream PR #: 96843 Signed-off-by: Michał Bainczyk --- modules/hal_nordic/nrfx/nrfx_glue.c | 22 ++++++++++++++++++++++ modules/hal_nordic/nrfx/nrfx_log.h | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/modules/hal_nordic/nrfx/nrfx_glue.c b/modules/hal_nordic/nrfx/nrfx_glue.c index 4e7fc94e11d..dd972ee039d 100644 --- a/modules/hal_nordic/nrfx/nrfx_glue.c +++ b/modules/hal_nordic/nrfx/nrfx_glue.c @@ -45,3 +45,25 @@ char const *nrfx_error_string_get(nrfx_err_t code) default: return "unknown"; } } + +char const *nrfx_new_error_string_get(int code) +{ + #define NRFX_NEW_ERROR_STRING_CASE(code) case code: return #code + switch (-code) + { + NRFX_NEW_ERROR_STRING_CASE(0); + NRFX_NEW_ERROR_STRING_CASE(ECANCELED); + NRFX_NEW_ERROR_STRING_CASE(ENOMEM); + NRFX_NEW_ERROR_STRING_CASE(ENOTSUP); + NRFX_NEW_ERROR_STRING_CASE(EINVAL); + NRFX_NEW_ERROR_STRING_CASE(EINPROGRESS); + NRFX_NEW_ERROR_STRING_CASE(E2BIG); + NRFX_NEW_ERROR_STRING_CASE(ETIMEDOUT); + NRFX_NEW_ERROR_STRING_CASE(EPERM); + NRFX_NEW_ERROR_STRING_CASE(EFAULT); + NRFX_NEW_ERROR_STRING_CASE(EACCES); + NRFX_NEW_ERROR_STRING_CASE(EBUSY); + NRFX_NEW_ERROR_STRING_CASE(EALREADY); + default: return "unknown"; + } +} diff --git a/modules/hal_nordic/nrfx/nrfx_log.h b/modules/hal_nordic/nrfx/nrfx_log.h index 682388d7dd1..973ca672b53 100644 --- a/modules/hal_nordic/nrfx/nrfx_log.h +++ b/modules/hal_nordic/nrfx/nrfx_log.h @@ -128,6 +128,16 @@ LOG_MODULE_REGISTER(NRFX_MODULE_PREFIX, NRFX_MODULE_LOG_LEVEL); #define NRFX_LOG_ERROR_STRING_GET(error_code) nrfx_error_string_get(error_code) extern char const *nrfx_error_string_get(nrfx_err_t code); +/** + * @brief Macro for getting the textual representation of a given errno error code. + * + * @param[in] error_code Errno error code. + * + * @return String containing the textual representation of the errno error code. + */ +#define NRFX_NEW_LOG_ERROR_STRING_GET(error_code) nrfx_new_error_string_get(error_code) +extern char const *nrfx_new_error_string_get(int code); + /** @} */ #ifdef __cplusplus