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 <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-03-24 15:34:46 -05:00 committed by Kumar Gala
commit e7df99d4ee
5 changed files with 32 additions and 22 deletions

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT ti_cc13xx_cc26xx_trng
#include <kernel.h>
#include <device.h>
#include <drivers/entropy.h>
@ -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);

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT ti_cc13xx_cc26xx_gpio
#include <zephyr/types.h>
#include <sys/__assert.h>
#include <device.h>
@ -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,

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT ti_cc13xx_cc26xx_i2c
#include <kernel.h>
#include <drivers/i2c.h>
#include <power/power.h>
@ -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);

View file

@ -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 <logging/log.h>
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 = {

View file

@ -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;
}