drivers: use DT_INST_ENUM_IDX(_OR) macros
Replace `DT_ENUM_IDX(_OR)(DT_DRV_INST(...),` pattern with `DT_INST_ENUM_IDX(_OR)(...,`. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
1832d68e01
commit
c759a35d08
|
@ -95,7 +95,7 @@ static const struct dac_driver_api api_sam0_driver_api = {
|
|||
|
||||
#define SAM0_DAC_REFSEL(n) \
|
||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(n, reference), \
|
||||
(DT_ENUM_IDX(DT_DRV_INST(n), reference)), (0))
|
||||
(DT_INST_ENUM_IDX(n, reference)), (0))
|
||||
|
||||
#define SAM0_DAC_INIT(n) \
|
||||
static const struct dac_sam0_cfg dac_sam0_cfg_##n = { \
|
||||
|
|
|
@ -1107,7 +1107,7 @@ static int gmac_init(Gmac *gmac, uint32_t gmac_ncfgr_val)
|
|||
/* Setup Network Configuration Register */
|
||||
gmac->GMAC_NCFGR = gmac_ncfgr_val | mck_divisor;
|
||||
|
||||
gmac->GMAC_UR = DT_ENUM_IDX(DT_DRV_INST(0), phy_connection_type);
|
||||
gmac->GMAC_UR = DT_INST_ENUM_IDX(0, phy_connection_type);
|
||||
|
||||
#if defined(CONFIG_PTP_CLOCK_SAM_GMAC)
|
||||
/* Initialize PTP Clock Registers */
|
||||
|
|
|
@ -403,7 +403,7 @@ static const struct ethphy_driver_api phy_mii_driver_api = {
|
|||
static const struct phy_mii_dev_config phy_mii_dev_config_##n = { \
|
||||
.phy_addr = DT_PROP(DT_DRV_INST(n), address), \
|
||||
.fixed = IS_FIXED_LINK(n), \
|
||||
.fixed_speed = DT_ENUM_IDX_OR(DT_DRV_INST(n), fixed_link, 0), \
|
||||
.fixed_speed = DT_INST_ENUM_IDX_OR(n, fixed_link, 0), \
|
||||
.mdio = UTIL_AND(UTIL_NOT(IS_FIXED_LINK(n)), \
|
||||
DEVICE_DT_GET(DT_PHANDLE(DT_DRV_INST(n), mdio)))\
|
||||
};
|
||||
|
|
|
@ -593,8 +593,6 @@ static const struct i2c_driver_api i2c_sam_twim_driver_api = {
|
|||
.transfer = i2c_sam_twim_transfer,
|
||||
};
|
||||
|
||||
#define DT_INST_ENUM_IDX(inst, prop) DT_ENUM_IDX(DT_DRV_INST(inst), prop)
|
||||
|
||||
#define I2C_TWIM_SAM_SLEW_REGS(n) \
|
||||
.std_clk_slew_lim = DT_INST_ENUM_IDX(n, std_clk_slew_lim), \
|
||||
.std_clk_strength_low = DT_INST_ENUM_IDX(n, std_clk_strength_low),\
|
||||
|
|
|
@ -135,7 +135,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(semtech_sx1272) +
|
|||
#define SX127X_PA_OUTPUT(power) SX127X_PA_BOOST
|
||||
#elif DT_INST_NODE_HAS_PROP(0, power_amplifier_output)
|
||||
#define SX127X_PA_OUTPUT(power) \
|
||||
DT_ENUM_IDX(DT_DRV_INST(0), power_amplifier_output)
|
||||
DT_INST_ENUM_IDX(0, power_amplifier_output)
|
||||
#else
|
||||
BUILD_ASSERT(0, "None of rfo-enable-gpios, pa-boost-enable-gpios and "
|
||||
"power-amplifier-output has been specified. "
|
||||
|
|
|
@ -131,7 +131,7 @@ static const struct mdio_driver_api mdio_sam_driver_api = {
|
|||
#define MDIO_SAM_CONFIG(n) \
|
||||
static const struct mdio_sam_dev_config mdio_sam_dev_config_##n = { \
|
||||
.regs = (Gmac *)DT_REG_ADDR(DT_PARENT(DT_DRV_INST(n))), \
|
||||
.protocol = DT_ENUM_IDX(DT_DRV_INST(n), protocol), \
|
||||
.protocol = DT_INST_ENUM_IDX(n, protocol), \
|
||||
};
|
||||
|
||||
#define MDIO_SAM_DEVICE(n) \
|
||||
|
|
|
@ -710,15 +710,15 @@ static int bmp388_init(const struct device *dev)
|
|||
|
||||
#define BMP388_INST(inst) \
|
||||
static struct bmp388_data bmp388_data_##inst = { \
|
||||
.odr = DT_ENUM_IDX(DT_DRV_INST(inst), odr), \
|
||||
.osr_pressure = DT_ENUM_IDX(DT_DRV_INST(inst), osr_press), \
|
||||
.osr_temp = DT_ENUM_IDX(DT_DRV_INST(inst), osr_temp), \
|
||||
.odr = DT_INST_ENUM_IDX(inst, odr), \
|
||||
.osr_pressure = DT_INST_ENUM_IDX(inst, osr_press), \
|
||||
.osr_temp = DT_INST_ENUM_IDX(inst, osr_temp), \
|
||||
}; \
|
||||
static const struct bmp388_config bmp388_config_##inst = { \
|
||||
.bus = DEVICE_DT_GET(DT_INST_BUS(inst)), \
|
||||
BMP388_BUS_CFG(inst), \
|
||||
BMP388_INT_CFG(inst) \
|
||||
.iir_filter = DT_ENUM_IDX(DT_DRV_INST(inst), iir_filter), \
|
||||
.iir_filter = DT_INST_ENUM_IDX(inst, iir_filter), \
|
||||
}; \
|
||||
DEVICE_DT_INST_DEFINE( \
|
||||
inst, \
|
||||
|
|
|
@ -1014,9 +1014,9 @@ static int fdc2x1x_init(const struct device *dev)
|
|||
.active_channel = DT_INST_PROP(n, active_channel), \
|
||||
.deglitch = DT_INST_PROP(n, deglitch), \
|
||||
.sensor_activate_sel = \
|
||||
DT_ENUM_IDX(DT_DRV_INST(n), sensor_activate_sel), \
|
||||
.clk_src = DT_ENUM_IDX(DT_DRV_INST(n), ref_clk_src), \
|
||||
.current_drv = DT_ENUM_IDX(DT_DRV_INST(n), current_drive), \
|
||||
DT_INST_ENUM_IDX(n, sensor_activate_sel), \
|
||||
.clk_src = DT_INST_ENUM_IDX(n, ref_clk_src), \
|
||||
.current_drv = DT_INST_ENUM_IDX(n, current_drive), \
|
||||
.output_gain = DT_INST_PROP(n, output_gain), \
|
||||
.ch_cfg = ch_cfg_##n, \
|
||||
.num_channels = ARRAY_SIZE(fdc2x1x_sample_buf_##n), \
|
||||
|
|
|
@ -457,8 +457,8 @@ static const struct sensor_driver_api icm42605_driver_api = {
|
|||
.gpio_dt_flags = DT_INST_SPI_DEV_CS_GPIOS_FLAGS(index), \
|
||||
.accel_hz = DT_INST_PROP(index, accel_hz), \
|
||||
.gyro_hz = DT_INST_PROP(index, gyro_hz), \
|
||||
.accel_fs = DT_ENUM_IDX(DT_DRV_INST(index), accel_fs), \
|
||||
.gyro_fs = DT_ENUM_IDX(DT_DRV_INST(index), gyro_fs), \
|
||||
.accel_fs = DT_INST_ENUM_IDX(index, accel_fs), \
|
||||
.gyro_fs = DT_INST_ENUM_IDX(index, gyro_fs), \
|
||||
}
|
||||
|
||||
#define ICM42605_INIT(index) \
|
||||
|
|
|
@ -242,8 +242,8 @@ static int shtcx_init(const struct device *dev)
|
|||
{ \
|
||||
.bus = DEVICE_DT_GET(DT_INST_BUS(inst)), \
|
||||
.base_address = DT_INST_REG_ADDR(inst), \
|
||||
.chip = DT_ENUM_IDX(DT_DRV_INST(inst), chip), \
|
||||
.measure_mode = DT_ENUM_IDX(DT_DRV_INST(inst), measure_mode), \
|
||||
.chip = DT_INST_ENUM_IDX(inst, chip), \
|
||||
.measure_mode = DT_INST_ENUM_IDX(inst, measure_mode), \
|
||||
.clock_stretching = DT_INST_PROP(inst, clock_stretching) \
|
||||
}
|
||||
|
||||
|
|
|
@ -354,11 +354,11 @@ static const struct vcnl4040_config vcnl4040_config = {
|
|||
.gpio_flags = 0,
|
||||
#endif
|
||||
#endif
|
||||
.led_i = DT_ENUM_IDX(DT_DRV_INST(0), led_current),
|
||||
.led_dc = DT_ENUM_IDX(DT_DRV_INST(0), led_duty_cycle),
|
||||
.als_it = DT_ENUM_IDX(DT_DRV_INST(0), als_it),
|
||||
.proxy_it = DT_ENUM_IDX(DT_DRV_INST(0), proximity_it),
|
||||
.proxy_type = DT_ENUM_IDX(DT_DRV_INST(0), proximity_trigger),
|
||||
.led_i = DT_INST_ENUM_IDX(0, led_current),
|
||||
.led_dc = DT_INST_ENUM_IDX(0, led_duty_cycle),
|
||||
.als_it = DT_INST_ENUM_IDX(0, als_it),
|
||||
.proxy_it = DT_INST_ENUM_IDX(0, proximity_it),
|
||||
.proxy_type = DT_INST_ENUM_IDX(0, proximity_trigger),
|
||||
};
|
||||
|
||||
static struct vcnl4040_data vcnl4040_data;
|
||||
|
|
|
@ -397,8 +397,8 @@ static const struct itds_device_config itds_config_##idx = { \
|
|||
.gpio_port = DT_INST_GPIO_LABEL(idx, int_gpios), \
|
||||
.int_pin = DT_INST_GPIO_PIN(idx, int_gpios), \
|
||||
.int_flags = DT_INST_GPIO_FLAGS(idx, int_gpios), \
|
||||
.def_odr = DT_ENUM_IDX(DT_DRV_INST(idx), odr), \
|
||||
.def_op_mode = DT_ENUM_IDX(DT_DRV_INST(idx), op_mode), \
|
||||
.def_odr = DT_INST_ENUM_IDX(idx, odr), \
|
||||
.def_op_mode = DT_INST_ENUM_IDX(idx, op_mode), \
|
||||
}; \
|
||||
\
|
||||
DEVICE_DT_INST_DEFINE(idx, itds_init, NULL, \
|
||||
|
|
|
@ -332,7 +332,7 @@ static const struct mcux_flexcomm_config mcux_flexcomm_##n##_config = { \
|
|||
.clock_subsys = \
|
||||
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
|
||||
.baud_rate = DT_INST_PROP(n, current_speed), \
|
||||
.parity = DT_ENUM_IDX_OR(DT_DRV_INST(n), parity, UART_CFG_PARITY_NONE), \
|
||||
.parity = DT_INST_ENUM_IDX_OR(n, parity, UART_CFG_PARITY_NONE), \
|
||||
IRQ_FUNC_INIT \
|
||||
}
|
||||
|
||||
|
|
|
@ -1603,7 +1603,7 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
|||
.enr = DT_INST_CLOCKS_CELL(index, bits) \
|
||||
}, \
|
||||
.hw_flow_control = DT_INST_PROP(index, hw_flow_control), \
|
||||
.parity = DT_ENUM_IDX_OR(DT_DRV_INST(index), parity, UART_CFG_PARITY_NONE), \
|
||||
.parity = DT_INST_ENUM_IDX_OR(index, parity, UART_CFG_PARITY_NONE), \
|
||||
STM32_UART_POLL_IRQ_HANDLER_FUNC(index) \
|
||||
.pinctrl_list = uart_pins_##index, \
|
||||
.pinctrl_list_size = ARRAY_SIZE(uart_pins_##index), \
|
||||
|
|
|
@ -463,7 +463,7 @@ static struct spi_driver_api spi_b91_api = {
|
|||
}; \
|
||||
\
|
||||
static struct spi_b91_cfg spi_b91_cfg_##inst = { \
|
||||
.peripheral_id = DT_ENUM_IDX(DT_DRV_INST(inst), peripheral_id), \
|
||||
.peripheral_id = DT_INST_ENUM_IDX(inst, peripheral_id), \
|
||||
.cs_pin[0] = DT_STRING_TOKEN(DT_DRV_INST(inst), cs0_pin), \
|
||||
.cs_pin[1] = DT_STRING_TOKEN(DT_DRV_INST(inst), cs1_pin), \
|
||||
.cs_pin[2] = DT_STRING_TOKEN(DT_DRV_INST(inst), cs2_pin), \
|
||||
|
|
|
@ -699,7 +699,7 @@ int usb_dc_attach(void)
|
|||
/* Select the speed with pads detached */
|
||||
regval = USBC_UDCON_DETACH;
|
||||
|
||||
switch (DT_ENUM_IDX(DT_DRV_INST(0), maximum_speed)) {
|
||||
switch (DT_INST_ENUM_IDX(0, maximum_speed)) {
|
||||
case 1:
|
||||
WRITE_BIT(regval, USBC_UDCON_LS_Pos, 0);
|
||||
break;
|
||||
|
|
|
@ -47,7 +47,7 @@ LOG_MODULE_REGISTER(usb_dc_sam_usbhs);
|
|||
|
||||
#define NUM_OF_EP_MAX DT_INST_PROP(0, num_bidir_endpoints)
|
||||
#if DT_INST_NODE_HAS_PROP(0, maximum_speed)
|
||||
#define USB_MAXIMUM_SPEED DT_ENUM_IDX(DT_DRV_INST(0), maximum_speed)
|
||||
#define USB_MAXIMUM_SPEED DT_INST_ENUM_IDX(0, maximum_speed)
|
||||
#else
|
||||
#define USB_MAXIMUM_SPEED 2 /* Default to high-speed */
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue