From f72bfda53cf62b62b441c1f8aaad254352028379 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 15 Apr 2020 06:31:24 -0500 Subject: [PATCH] drivers: pwm: pwm_nrf5_sw: Convert to new DT_INST macros Convert older DT_INST_ macro use the new include/devicetree.h DT_INST macro APIs. Signed-off-by: Kumar Gala --- drivers/pwm/pwm_nrf5_sw.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/pwm/pwm_nrf5_sw.c b/drivers/pwm/pwm_nrf5_sw.c index bf9e6d488bd..0fad21c2651 100644 --- a/drivers/pwm/pwm_nrf5_sw.c +++ b/drivers/pwm/pwm_nrf5_sw.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define DT_DRV_COMPAT nordic_nrf_sw_pwm + #include #include @@ -14,13 +16,13 @@ LOG_MODULE_REGISTER(pwm_nrf5_sw); /* One compare channel is needed to set the PWM period, hence +1. */ -#if ((DT_INST_0_NORDIC_NRF_SW_PWM_CHANNEL_COUNT + 1) > \ +#if ((DT_INST_PROP(0, channel_count) + 1) > \ (_CONCAT( \ - _CONCAT(TIMER, DT_INST_0_NORDIC_NRF_SW_PWM_TIMER_INSTANCE), \ + _CONCAT(TIMER, DT_INST_PROP(0, timer_instance)), \ _CC_NUM))) #error "Invalid number of PWM channels configured." #endif -#define PWM_0_MAP_SIZE DT_INST_0_NORDIC_NRF_SW_PWM_CHANNEL_COUNT +#define PWM_0_MAP_SIZE DT_INST_PROP(0, channel_count) struct pwm_config { NRF_TIMER_Type *timer; @@ -251,17 +253,17 @@ static int pwm_nrf5_sw_init(struct device *dev) } static const struct pwm_config pwm_nrf5_sw_0_config = { - .timer = _CONCAT(NRF_TIMER, DT_INST_0_NORDIC_NRF_SW_PWM_TIMER_INSTANCE), - .ppi_base = DT_INST_0_NORDIC_NRF_SW_PWM_PPI_BASE, - .gpiote_base = DT_INST_0_NORDIC_NRF_SW_PWM_GPIOTE_BASE, + .timer = _CONCAT(NRF_TIMER, DT_INST_PROP(0, timer_instance)), + .ppi_base = DT_INST_PROP(0, ppi_base), + .gpiote_base = DT_INST_PROP(0, gpiote_base), .map_size = PWM_0_MAP_SIZE, - .prescaler = DT_INST_0_NORDIC_NRF_SW_PWM_CLOCK_PRESCALER, + .prescaler = DT_INST_PROP(0, clock_prescaler), }; static struct pwm_data pwm_nrf5_sw_0_data; DEVICE_AND_API_INIT(pwm_nrf5_sw_0, - DT_INST_0_NORDIC_NRF_SW_PWM_LABEL, + DT_INST_LABEL(0), pwm_nrf5_sw_init, &pwm_nrf5_sw_0_data, &pwm_nrf5_sw_0_config,