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 <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-04-15 06:31:24 -05:00 committed by Kumar Gala
commit f72bfda53c

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#define DT_DRV_COMPAT nordic_nrf_sw_pwm
#include <soc.h> #include <soc.h>
#include <drivers/pwm.h> #include <drivers/pwm.h>
@ -14,13 +16,13 @@
LOG_MODULE_REGISTER(pwm_nrf5_sw); LOG_MODULE_REGISTER(pwm_nrf5_sw);
/* One compare channel is needed to set the PWM period, hence +1. */ /* 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( \
_CONCAT(TIMER, DT_INST_0_NORDIC_NRF_SW_PWM_TIMER_INSTANCE), \ _CONCAT(TIMER, DT_INST_PROP(0, timer_instance)), \
_CC_NUM))) _CC_NUM)))
#error "Invalid number of PWM channels configured." #error "Invalid number of PWM channels configured."
#endif #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 { struct pwm_config {
NRF_TIMER_Type *timer; 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 = { static const struct pwm_config pwm_nrf5_sw_0_config = {
.timer = _CONCAT(NRF_TIMER, DT_INST_0_NORDIC_NRF_SW_PWM_TIMER_INSTANCE), .timer = _CONCAT(NRF_TIMER, DT_INST_PROP(0, timer_instance)),
.ppi_base = DT_INST_0_NORDIC_NRF_SW_PWM_PPI_BASE, .ppi_base = DT_INST_PROP(0, ppi_base),
.gpiote_base = DT_INST_0_NORDIC_NRF_SW_PWM_GPIOTE_BASE, .gpiote_base = DT_INST_PROP(0, gpiote_base),
.map_size = PWM_0_MAP_SIZE, .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; static struct pwm_data pwm_nrf5_sw_0_data;
DEVICE_AND_API_INIT(pwm_nrf5_sw_0, 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_init,
&pwm_nrf5_sw_0_data, &pwm_nrf5_sw_0_data,
&pwm_nrf5_sw_0_config, &pwm_nrf5_sw_0_config,