From e7df99d4eea4b368dcd6a58d999c507f117978e4 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 24 Mar 2020 15:34:46 -0500 Subject: [PATCH] drivers: cc13xx_cc26xx: Convert drivers to new DT_INST macros Convert older DT_INST_ macro use in cc13xx_cc26xx drivers to the new include/devicetree.h DT_INST macro APIs. Signed-off-by: Kumar Gala --- drivers/entropy/entropy_cc13xx_cc26xx.c | 10 ++++++---- drivers/gpio/gpio_cc13xx_cc26xx.c | 12 +++++++----- drivers/i2c/i2c_cc13xx_cc26xx.c | 20 +++++++++++--------- drivers/spi/spi_cc13xx_cc26xx.c | 4 +++- drivers/timer/cc13x2_cc26x2_rtc_timer.c | 8 +++++--- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/entropy/entropy_cc13xx_cc26xx.c b/drivers/entropy/entropy_cc13xx_cc26xx.c index bba3805b113..70cffc0f213 100644 --- a/drivers/entropy/entropy_cc13xx_cc26xx.c +++ b/drivers/entropy/entropy_cc13xx_cc26xx.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define DT_DRV_COMPAT ti_cc13xx_cc26xx_trng + #include #include #include @@ -146,11 +148,11 @@ static int entropy_cc13xx_cc26xx_init(struct device *dev) TRNGEnable(); TRNGIntEnable(TRNG_NUMBER_READY | TRNG_FRO_SHUTDOWN); - IRQ_CONNECT(DT_INST_0_TI_CC13XX_CC26XX_TRNG_IRQ_0, - DT_INST_0_TI_CC13XX_CC26XX_TRNG_IRQ_0_PRIORITY, + IRQ_CONNECT(DT_INST_IRQN(0), + DT_INST_IRQ(0, priority), entropy_cc13xx_cc26xx_isr, DEVICE_GET(entropy_cc13xx_cc26xx), 0); - irq_enable(DT_INST_0_TI_CC13XX_CC26XX_TRNG_IRQ_0); + irq_enable(DT_INST_IRQN(0)); return 0; } @@ -164,7 +166,7 @@ static struct entropy_cc13xx_cc26xx_data entropy_cc13xx_cc26xx_data = { .sync = Z_SEM_INITIALIZER(entropy_cc13xx_cc26xx_data.sync, 0, 1), }; -DEVICE_AND_API_INIT(entropy_cc13xx_cc26xx, DT_INST_0_TI_CC13XX_CC26XX_TRNG_LABEL, +DEVICE_AND_API_INIT(entropy_cc13xx_cc26xx, DT_INST_LABEL(0), entropy_cc13xx_cc26xx_init, &entropy_cc13xx_cc26xx_data, NULL, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &entropy_cc13xx_cc26xx_driver_api); diff --git a/drivers/gpio/gpio_cc13xx_cc26xx.c b/drivers/gpio/gpio_cc13xx_cc26xx.c index 758e70630fa..c56daee1151 100644 --- a/drivers/gpio/gpio_cc13xx_cc26xx.c +++ b/drivers/gpio/gpio_cc13xx_cc26xx.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define DT_DRV_COMPAT ti_cc13xx_cc26xx_gpio + #include #include #include @@ -38,7 +40,7 @@ struct gpio_cc13xx_cc26xx_data { static struct gpio_cc13xx_cc26xx_data gpio_cc13xx_cc26xx_data_0; static const struct gpio_driver_config gpio_cc13xx_cc26xx_cfg_0 = { - .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_0_TI_CC13XX_CC26XX_GPIO_NGPIOS), + .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_PROP(0, ngpios)), }; static int gpio_cc13xx_cc26xx_port_set_bits_raw(struct device *port, @@ -259,10 +261,10 @@ static int gpio_cc13xx_cc26xx_init(struct device *dev) AON_EVENT_MCUWUSEL_WU1_EV_PAD; /* Enable IRQ */ - IRQ_CONNECT(DT_INST_0_TI_CC13XX_CC26XX_GPIO_IRQ_0, - DT_INST_0_TI_CC13XX_CC26XX_GPIO_IRQ_0_PRIORITY, + IRQ_CONNECT(DT_INST_IRQN(0), + DT_INST_IRQ(0, priority), gpio_cc13xx_cc26xx_isr, DEVICE_GET(gpio_cc13xx_cc26xx), 0); - irq_enable(DT_INST_0_TI_CC13XX_CC26XX_GPIO_IRQ_0); + irq_enable(DT_INST_IRQN(0)); /* Disable callbacks */ data->pin_callback_enables = 0; @@ -290,7 +292,7 @@ static const struct gpio_driver_api gpio_cc13xx_cc26xx_driver_api = { .get_pending_int = gpio_cc13xx_cc26xx_get_pending_int }; -DEVICE_AND_API_INIT(gpio_cc13xx_cc26xx, DT_INST_0_TI_CC13XX_CC26XX_GPIO_LABEL, +DEVICE_AND_API_INIT(gpio_cc13xx_cc26xx, DT_INST_LABEL(0), gpio_cc13xx_cc26xx_init, &gpio_cc13xx_cc26xx_data_0, &gpio_cc13xx_cc26xx_cfg_0, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, diff --git a/drivers/i2c/i2c_cc13xx_cc26xx.c b/drivers/i2c/i2c_cc13xx_cc26xx.c index 6f167c12be7..11bc7704aaf 100644 --- a/drivers/i2c/i2c_cc13xx_cc26xx.c +++ b/drivers/i2c/i2c_cc13xx_cc26xx.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define DT_DRV_COMPAT ti_cc13xx_cc26xx_i2c + #include #include #include @@ -427,16 +429,16 @@ static int i2c_cc13xx_cc26xx_init(struct device *dev) } #endif - IRQ_CONNECT(DT_INST_0_TI_CC13XX_CC26XX_I2C_IRQ_0, - DT_INST_0_TI_CC13XX_CC26XX_I2C_IRQ_0_PRIORITY, + IRQ_CONNECT(DT_INST_IRQN(0), + DT_INST_IRQ(0, priority), i2c_cc13xx_cc26xx_isr, DEVICE_GET(i2c_cc13xx_cc26xx), 0); - irq_enable(DT_INST_0_TI_CC13XX_CC26XX_I2C_IRQ_0); + irq_enable(DT_INST_IRQN(0)); /* Configure IOC module to route SDA and SCL signals */ IOCPinTypeI2c(get_dev_config(dev)->base, get_dev_config(dev)->sda_pin, get_dev_config(dev)->scl_pin); - cfg = i2c_map_dt_bitrate(DT_INST_0_TI_CC13XX_CC26XX_I2C_CLOCK_FREQUENCY); + cfg = i2c_map_dt_bitrate(DT_INST_PROP(0, clock_frequency)); err = i2c_cc13xx_cc26xx_configure(dev, cfg | I2C_MODE_MASTER); if (err) { LOG_ERR("Failed to configure"); @@ -454,9 +456,9 @@ static const struct i2c_driver_api i2c_cc13xx_cc26xx_driver_api = { }; static const struct i2c_cc13xx_cc26xx_config i2c_cc13xx_cc26xx_config = { - .base = DT_INST_0_TI_CC13XX_CC26XX_I2C_BASE_ADDRESS, - .sda_pin = DT_INST_0_TI_CC13XX_CC26XX_I2C_SDA_PIN, - .scl_pin = DT_INST_0_TI_CC13XX_CC26XX_I2C_SCL_PIN + .base = DT_INST_REG_ADDR(0), + .sda_pin = DT_INST_PROP(0, sda_pin), + .scl_pin = DT_INST_PROP(0, scl_pin) }; static struct i2c_cc13xx_cc26xx_data i2c_cc13xx_cc26xx_data = { @@ -466,14 +468,14 @@ static struct i2c_cc13xx_cc26xx_data i2c_cc13xx_cc26xx_data = { }; #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -DEVICE_DEFINE(i2c_cc13xx_cc26xx, DT_INST_0_TI_CC13XX_CC26XX_I2C_LABEL, +DEVICE_DEFINE(i2c_cc13xx_cc26xx, DT_INST_LABEL(0), i2c_cc13xx_cc26xx_init, i2c_cc13xx_cc26xx_pm_control, &i2c_cc13xx_cc26xx_data, &i2c_cc13xx_cc26xx_config, POST_KERNEL, CONFIG_I2C_INIT_PRIORITY, &i2c_cc13xx_cc26xx_driver_api); #else -DEVICE_AND_API_INIT(i2c_cc13xx_cc26xx, DT_INST_0_TI_CC13XX_CC26XX_I2C_LABEL, +DEVICE_AND_API_INIT(i2c_cc13xx_cc26xx, DT_INST_LABEL(0), i2c_cc13xx_cc26xx_init, &i2c_cc13xx_cc26xx_data, &i2c_cc13xx_cc26xx_config, POST_KERNEL, CONFIG_I2C_INIT_PRIORITY, &i2c_cc13xx_cc26xx_driver_api); diff --git a/drivers/spi/spi_cc13xx_cc26xx.c b/drivers/spi/spi_cc13xx_cc26xx.c index da52c518fb3..19104836f4d 100644 --- a/drivers/spi/spi_cc13xx_cc26xx.c +++ b/drivers/spi/spi_cc13xx_cc26xx.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define DT_DRV_COMPAT ti_cc13xx_cc26xx_spi + #define LOG_LEVEL CONFIG_SPI_LOG_LEVEL #include LOG_MODULE_REGISTER(spi_cc13xx_cc26xx); @@ -327,7 +329,7 @@ static const struct spi_cc13xx_cc26xx_config spi_cc13xx_cc26xx_config_0 = { .cs_pin = DT_TI_CC13XX_CC26XX_SPI_40000000_CS_PIN, #else .cs_pin = IOID_UNUSED, -#endif /* DT_INST_0_TI_CC13XX_CC26XX_SPI_CS_PIN */ +#endif }; static struct spi_cc13xx_cc26xx_data spi_cc13xx_cc26xx_data_0 = { diff --git a/drivers/timer/cc13x2_cc26x2_rtc_timer.c b/drivers/timer/cc13x2_cc26x2_rtc_timer.c index 1d1eb22532f..65197c6c9d9 100644 --- a/drivers/timer/cc13x2_cc26x2_rtc_timer.c +++ b/drivers/timer/cc13x2_cc26x2_rtc_timer.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define DT_DRV_COMPAT ti_cc13xx_cc26xx_rtc + /* * TI SimpleLink CC13X2/CC26X2 RTC-based system timer * @@ -191,10 +193,10 @@ int z_clock_driver_init(struct device *device) startDevice(); /* Enable RTC interrupt. */ - IRQ_CONNECT(DT_INST_0_TI_CC13XX_CC26XX_RTC_IRQ_0, - DT_INST_0_TI_CC13XX_CC26XX_RTC_IRQ_0_PRIORITY, + IRQ_CONNECT(DT_INST_IRQN(0), + DT_INST_IRQ(0, priority), rtc_isr, 0, 0); - irq_enable(DT_INST_0_TI_CC13XX_CC26XX_RTC_IRQ_0); + irq_enable(DT_INST_IRQN(0)); return 0; }