drivers: silabs: Convert silabs drivers to new DT_INST macros
Convert older DT_INST_ macro use in silab 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:
parent
33928f18ae
commit
4cb0a5d992
9 changed files with 323 additions and 304 deletions
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT silabs_gecko_rtcc
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -356,32 +358,32 @@ ISR_DIRECT_DECLARE(counter_gecko_isr_0)
|
|||
return 1;
|
||||
}
|
||||
|
||||
BUILD_ASSERT((DT_INST_0_SILABS_GECKO_RTCC_PRESCALER > 0U) &&
|
||||
(DT_INST_0_SILABS_GECKO_RTCC_PRESCALER <= 32768U));
|
||||
BUILD_ASSERT((DT_INST_PROP(0, prescaler) > 0U) &&
|
||||
(DT_INST_PROP(0, prescaler) <= 32768U));
|
||||
|
||||
static void counter_gecko_0_irq_config(void)
|
||||
{
|
||||
IRQ_DIRECT_CONNECT(DT_INST_0_SILABS_GECKO_RTCC_IRQ_0,
|
||||
DT_INST_0_SILABS_GECKO_RTCC_IRQ_0_PRIORITY,
|
||||
IRQ_DIRECT_CONNECT(DT_INST_IRQN(0),
|
||||
DT_INST_IRQ(0, priority),
|
||||
counter_gecko_isr_0, 0);
|
||||
irq_enable(DT_INST_0_SILABS_GECKO_RTCC_IRQ_0);
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
}
|
||||
|
||||
static const struct counter_gecko_config counter_gecko_0_config = {
|
||||
.info = {
|
||||
.max_top_value = RTCC_MAX_VALUE,
|
||||
.freq = DT_INST_0_SILABS_GECKO_RTCC_CLOCK_FREQUENCY /
|
||||
DT_INST_0_SILABS_GECKO_RTCC_PRESCALER,
|
||||
.freq = DT_INST_PROP(0, clock_frequency) /
|
||||
DT_INST_PROP(0, prescaler),
|
||||
.flags = COUNTER_CONFIG_INFO_COUNT_UP,
|
||||
.channels = RTCC_ALARM_NUM,
|
||||
},
|
||||
.irq_config = counter_gecko_0_irq_config,
|
||||
.prescaler = DT_INST_0_SILABS_GECKO_RTCC_PRESCALER,
|
||||
.prescaler = DT_INST_PROP(0, prescaler),
|
||||
};
|
||||
|
||||
static struct counter_gecko_data counter_gecko_0_data;
|
||||
|
||||
DEVICE_AND_API_INIT(counter_gecko_0, DT_INST_0_SILABS_GECKO_RTCC_LABEL,
|
||||
DEVICE_AND_API_INIT(counter_gecko_0, DT_INST_LABEL(0),
|
||||
counter_gecko_init, &counter_gecko_0_data, &counter_gecko_0_config,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&counter_gecko_driver_api);
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT silabs_gecko_ethernet
|
||||
|
||||
/* Silicon Labs EFM32 Giant Gecko 11 Ethernet driver.
|
||||
* Limitations:
|
||||
* - no link monitoring through PHY interrupt
|
||||
|
@ -438,20 +440,20 @@ static void eth_init_pins(struct device *dev)
|
|||
eth->ROUTELOC1 = 0;
|
||||
eth->ROUTEPEN = 0;
|
||||
|
||||
#if defined(DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII)
|
||||
#if DT_INST_NODE_HAS_PROP(0, location_rmii)
|
||||
for (idx = 0; idx < ARRAY_SIZE(cfg->pin_list->rmii); idx++)
|
||||
soc_gpio_configure(&cfg->pin_list->rmii[idx]);
|
||||
|
||||
eth->ROUTELOC1 |= (DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII <<
|
||||
eth->ROUTELOC1 |= (DT_INST_PROP(0, location_rmii) <<
|
||||
_ETH_ROUTELOC1_RMIILOC_SHIFT);
|
||||
eth->ROUTEPEN |= ETH_ROUTEPEN_RMIIPEN;
|
||||
#endif
|
||||
|
||||
#if defined(DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_MDIO)
|
||||
#if DT_INST_NODE_HAS_PROP(0, location_mdio)
|
||||
for (idx = 0; idx < ARRAY_SIZE(cfg->pin_list->mdio); idx++)
|
||||
soc_gpio_configure(&cfg->pin_list->mdio[idx]);
|
||||
|
||||
eth->ROUTELOC1 |= (DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_MDIO <<
|
||||
eth->ROUTELOC1 |= (DT_INST_PROP(0, location_mdio) <<
|
||||
_ETH_ROUTELOC1_MDIOLOC_SHIFT);
|
||||
eth->ROUTEPEN |= ETH_ROUTEPEN_MDIOPEN;
|
||||
#endif
|
||||
|
@ -472,7 +474,7 @@ static int eth_init(struct device *dev)
|
|||
/* Connect pins to peripheral */
|
||||
eth_init_pins(dev);
|
||||
|
||||
#if defined(DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII)
|
||||
#if DT_INST_NODE_HAS_PROP(0, location_rmii)
|
||||
/* Enable global clock and RMII operation */
|
||||
eth->CTRL = ETH_CTRL_GBLCLKEN | ETH_CTRL_MIISEL_RMII;
|
||||
#endif
|
||||
|
@ -653,10 +655,10 @@ static struct device DEVICE_NAME_GET(eth_gecko);
|
|||
|
||||
static void eth0_irq_config(void)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_0_SILABS_GECKO_ETHERNET_IRQ_0,
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_IRQ_0_PRIORITY, eth_isr,
|
||||
IRQ_CONNECT(DT_INST_IRQN(0),
|
||||
DT_INST_IRQ(0, priority), eth_isr,
|
||||
DEVICE_GET(eth_gecko), 0);
|
||||
irq_enable(DT_INST_0_SILABS_GECKO_ETHERNET_IRQ_0);
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
}
|
||||
|
||||
static const struct eth_gecko_pin_list pins_eth0 = {
|
||||
|
@ -666,14 +668,14 @@ static const struct eth_gecko_pin_list pins_eth0 = {
|
|||
|
||||
static const struct eth_gecko_dev_cfg eth0_config = {
|
||||
.regs = (ETH_TypeDef *)
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_BASE_ADDRESS,
|
||||
DT_INST_REG_ADDR(0),
|
||||
.pin_list = &pins_eth0,
|
||||
.pin_list_size = ARRAY_SIZE(pins_eth0.mdio) +
|
||||
ARRAY_SIZE(pins_eth0.rmii),
|
||||
.config_func = eth0_irq_config,
|
||||
.phy = { (ETH_TypeDef *)
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_BASE_ADDRESS,
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_PHY_ADDRESS },
|
||||
DT_INST_REG_ADDR(0),
|
||||
DT_INST_PROP(0, phy_address) },
|
||||
};
|
||||
|
||||
static struct eth_gecko_dev_data eth0_data = {
|
||||
|
|
|
@ -101,43 +101,43 @@ struct eth_gecko_dev_data {
|
|||
((struct eth_gecko_dev_data *)(dev)->driver_data)
|
||||
|
||||
/* PHY Management pins */
|
||||
#define PIN_PHY_MDC {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_PHY_MDC_1, \
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_PHY_MDC_2, gpioModePushPull,\
|
||||
#define PIN_PHY_MDC {DT_INST_PROP_BY_IDX(0, location_phy_mdc, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_phy_mdc, 2), gpioModePushPull,\
|
||||
0}
|
||||
#define PIN_PHY_MDIO {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_PHY_MDIO_1, \
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_PHY_MDIO_2, gpioModePushPull,\
|
||||
#define PIN_PHY_MDIO {DT_INST_PROP_BY_IDX(0, location_phy_mdio, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_phy_mdio, 2), gpioModePushPull,\
|
||||
0}
|
||||
|
||||
#define PIN_LIST_PHY {PIN_PHY_MDC, PIN_PHY_MDIO}
|
||||
|
||||
/* RMII pins excluding reference clock, handled by board.c */
|
||||
#define PIN_RMII_CRSDV {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_CRS_DV_1,\
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_CRS_DV_2, gpioModeInput, 0}
|
||||
#define PIN_RMII_CRSDV {DT_INST_PROP_BY_IDX(0, location_rmii_crs_dv, 1),\
|
||||
DT_INST_PROP_BY_IDX(0, location_rmii_crs_dv, 2), gpioModeInput, 0}
|
||||
|
||||
#define PIN_RMII_TXD0 {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_TXD0_1,\
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_TXD0_2, gpioModePushPull, 0}
|
||||
#define PIN_RMII_TXD0 {DT_INST_PROP_BY_IDX(0, location_rmii_txd0, 1),\
|
||||
DT_INST_PROP_BY_IDX(0, location_rmii_txd0, 2), gpioModePushPull, 0}
|
||||
|
||||
#define PIN_RMII_TXD1 {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_TXD1_1,\
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_TXD1_2, gpioModePushPull, 0}
|
||||
#define PIN_RMII_TXD1 {DT_INST_PROP_BY_IDX(0, location_rmii_txd1, 1),\
|
||||
DT_INST_PROP_BY_IDX(0, location_rmii_txd1, 2), gpioModePushPull, 0}
|
||||
|
||||
#define PIN_RMII_TX_EN {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_TX_EN_1,\
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_TX_EN_2, gpioModePushPull, 0}
|
||||
#define PIN_RMII_TX_EN {DT_INST_PROP_BY_IDX(0, location_rmii_tx_en, 1),\
|
||||
DT_INST_PROP_BY_IDX(0, location_rmii_tx_en, 2), gpioModePushPull, 0}
|
||||
|
||||
#define PIN_RMII_RXD0 {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_RXD0_1,\
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_RXD0_2, gpioModeInput, 0}
|
||||
#define PIN_RMII_RXD0 {DT_INST_PROP_BY_IDX(0, location_rmii_rxd0, 1),\
|
||||
DT_INST_PROP_BY_IDX(0, location_rmii_rxd0, 2), gpioModeInput, 0}
|
||||
|
||||
#define PIN_RMII_RXD1 {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_RXD1_1,\
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_RXD1_2, gpioModeInput, 0}
|
||||
#define PIN_RMII_RXD1 {DT_INST_PROP_BY_IDX(0, location_rmii_rxd1, 1),\
|
||||
DT_INST_PROP_BY_IDX(0, location_rmii_rxd1, 2), gpioModeInput, 0}
|
||||
|
||||
#define PIN_RMII_RX_ER {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_RX_ER_1,\
|
||||
DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_RX_ER_2, gpioModeInput, 0}
|
||||
#define PIN_RMII_RX_ER {DT_INST_PROP_BY_IDX(0, location_rmii_rx_er, 1),\
|
||||
DT_INST_PROP_BY_IDX(0, location_rmii_rx_er, 2), gpioModeInput, 0}
|
||||
|
||||
#define PIN_LIST_RMII {PIN_RMII_CRSDV, PIN_RMII_TXD0, PIN_RMII_TXD1, \
|
||||
PIN_RMII_TX_EN, PIN_RMII_RXD0, PIN_RMII_RXD1, PIN_RMII_RX_ER}
|
||||
|
||||
/* RMII reference clock is not included in RMII pin set
|
||||
* #define PIN_RMII_REFCLK {DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_REFCLK_1,\
|
||||
* DT_INST_0_SILABS_GECKO_ETHERNET_LOCATION_RMII_REFCLK_2, gpioModePushPull, 0}
|
||||
* #define PIN_RMII_REFCLK {DT_INST_PROP_BY_IDX(0, location_rmii_refclk, 1),\
|
||||
* DT_INST_PROP_BY_IDX(0, location_rmii_refclk, 2), gpioModePushPull, 0}
|
||||
*/
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_GECKO_PRIV_H_ */
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT soc_nv_flash
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -162,8 +164,8 @@ static int erase_flash_block(off_t offset, size_t size)
|
|||
#if CONFIG_FLASH_PAGE_LAYOUT
|
||||
static const struct flash_pages_layout flash_gecko_0_pages_layout = {
|
||||
.pages_count = (CONFIG_FLASH_SIZE * 1024) /
|
||||
DT_INST_0_SOC_NV_FLASH_ERASE_BLOCK_SIZE,
|
||||
.pages_size = DT_INST_0_SOC_NV_FLASH_ERASE_BLOCK_SIZE,
|
||||
DT_INST_PROP(0, erase_block_size),
|
||||
.pages_size = DT_INST_PROP(0, erase_block_size),
|
||||
};
|
||||
|
||||
void flash_gecko_page_layout(struct device *dev,
|
||||
|
@ -199,7 +201,7 @@ static const struct flash_driver_api flash_gecko_driver_api = {
|
|||
#ifdef CONFIG_FLASH_PAGE_LAYOUT
|
||||
.page_layout = flash_gecko_page_layout,
|
||||
#endif
|
||||
.write_block_size = DT_INST_0_SOC_NV_FLASH_WRITE_BLOCK_SIZE,
|
||||
.write_block_size = DT_INST_PROP(0, write_block_size),
|
||||
};
|
||||
|
||||
static struct flash_gecko_data flash_gecko_0_data;
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT silabs_gecko_i2c
|
||||
|
||||
#include <errno.h>
|
||||
#include <drivers/i2c.h>
|
||||
#include <sys/util.h>
|
||||
|
@ -183,70 +185,70 @@ static const struct i2c_driver_api i2c_gecko_driver_api = {
|
|||
.transfer = i2c_gecko_transfer,
|
||||
};
|
||||
|
||||
#ifdef DT_INST_0_SILABS_GECKO_I2C
|
||||
#if DT_HAS_DRV_INST(0)
|
||||
|
||||
#define PIN_I2C_0_SDA {DT_INST_0_SILABS_GECKO_I2C_LOCATION_SDA_1, \
|
||||
DT_INST_0_SILABS_GECKO_I2C_LOCATION_SDA_2, gpioModeWiredAnd, 1}
|
||||
#define PIN_I2C_0_SCL {DT_INST_0_SILABS_GECKO_I2C_LOCATION_SCL_1, \
|
||||
DT_INST_0_SILABS_GECKO_I2C_LOCATION_SCL_2, gpioModeWiredAnd, 1}
|
||||
#define PIN_I2C_0_SDA {DT_INST_PROP_BY_IDX(0, location_sda, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_sda, 2), gpioModeWiredAnd, 1}
|
||||
#define PIN_I2C_0_SCL {DT_INST_PROP_BY_IDX(0, location_scl, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_scl, 2), gpioModeWiredAnd, 1}
|
||||
|
||||
static struct i2c_gecko_config i2c_gecko_config_0 = {
|
||||
.base = (I2C_TypeDef *)DT_INST_0_SILABS_GECKO_I2C_BASE_ADDRESS,
|
||||
.base = (I2C_TypeDef *)DT_INST_REG_ADDR(0),
|
||||
.clock = cmuClock_I2C0,
|
||||
.i2cInit = I2C_INIT_DEFAULT,
|
||||
.pin_sda = PIN_I2C_0_SDA,
|
||||
.pin_scl = PIN_I2C_0_SCL,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_sda = DT_INST_0_SILABS_GECKO_I2C_LOCATION_SDA_0,
|
||||
.loc_scl = DT_INST_0_SILABS_GECKO_I2C_LOCATION_SCL_0,
|
||||
.loc_sda = DT_INST_PROP_BY_IDX(0, location_sda, 0),
|
||||
.loc_scl = DT_INST_PROP_BY_IDX(0, location_scl, 0),
|
||||
#else
|
||||
#if DT_INST_0_SILABS_GECKO_I2C_LOCATION_SDA_0 \
|
||||
!= DT_INST_0_SILABS_GECKO_I2C_LOCATION_SCL_0
|
||||
#if DT_INST_PROP_BY_IDX(0, location_sda, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(0, location_scl, 0)
|
||||
#error I2C_0 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_0_SILABS_GECKO_I2C_LOCATION_SCL_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(0, location_scl, 0),
|
||||
#endif
|
||||
.bitrate = DT_INST_0_SILABS_GECKO_I2C_CLOCK_FREQUENCY,
|
||||
.bitrate = DT_INST_PROP(0, clock_frequency),
|
||||
};
|
||||
|
||||
static struct i2c_gecko_data i2c_gecko_data_0;
|
||||
|
||||
DEVICE_AND_API_INIT(i2c_gecko_0, DT_INST_0_SILABS_GECKO_I2C_LABEL,
|
||||
DEVICE_AND_API_INIT(i2c_gecko_0, DT_INST_LABEL(0),
|
||||
&i2c_gecko_init, &i2c_gecko_data_0, &i2c_gecko_config_0,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&i2c_gecko_driver_api);
|
||||
#endif /* DT_INST_0_SILABS_GECKO_I2C */
|
||||
#endif /* DT_HAS_DRV_INST(0) */
|
||||
|
||||
#ifdef DT_INST_1_SILABS_GECKO_I2C
|
||||
#if DT_HAS_DRV_INST(1)
|
||||
|
||||
#define PIN_I2C_1_SDA {DT_INST_1_SILABS_GECKO_I2C_LOCATION_SDA_1, \
|
||||
DT_INST_1_SILABS_GECKO_I2C_LOCATION_SDA_2, gpioModeWiredAnd, 1}
|
||||
#define PIN_I2C_1_SCL {DT_INST_1_SILABS_GECKO_I2C_LOCATION_SCL_1, \
|
||||
DT_INST_1_SILABS_GECKO_I2C_LOCATION_SCL_2, gpioModeWiredAnd, 1}
|
||||
#define PIN_I2C_1_SDA {DT_INST_PROP_BY_IDX(1, location_sda, 1), \
|
||||
DT_INST_PROP_BY_IDX(1, location_sda, 2), gpioModeWiredAnd, 1}
|
||||
#define PIN_I2C_1_SCL {DT_INST_PROP_BY_IDX(1, location_scl, 1), \
|
||||
DT_INST_PROP_BY_IDX(1, location_scl, 2), gpioModeWiredAnd, 1}
|
||||
|
||||
static struct i2c_gecko_config i2c_gecko_config_1 = {
|
||||
.base = (I2C_TypeDef *)DT_INST_1_SILABS_GECKO_I2C_BASE_ADDRESS,
|
||||
.base = (I2C_TypeDef *)DT_INST_REG_ADDR(1),
|
||||
.clock = cmuClock_I2C1,
|
||||
.i2cInit = I2C_INIT_DEFAULT,
|
||||
.pin_sda = PIN_I2C_1_SDA,
|
||||
.pin_scl = PIN_I2C_1_SCL,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_sda = DT_INST_1_SILABS_GECKO_I2C_LOCATION_SDA_0,
|
||||
.loc_scl = DT_INST_1_SILABS_GECKO_I2C_LOCATION_SCL_0,
|
||||
.loc_sda = DT_INST_PROP_BY_IDX(1, location_sda, 0),
|
||||
.loc_scl = DT_INST_PROP_BY_IDX(1, location_scl, 0),
|
||||
#else
|
||||
#if DT_INST_1_SILABS_GECKO_I2C_LOCATION_SDA_0 \
|
||||
!= DT_INST_1_SILABS_GECKO_I2C_LOCATION_SCL_0
|
||||
#if DT_INST_PROP_BY_IDX(1, location_sda, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(1, location_scl, 0)
|
||||
#error I2C_1 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_1_SILABS_GECKO_I2C_LOCATION_SCL_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(1, location_scl, 0),
|
||||
#endif
|
||||
.bitrate = DT_INST_1_SILABS_GECKO_I2C_CLOCK_FREQUENCY,
|
||||
.bitrate = DT_INST_PROP(1, clock_frequency),
|
||||
};
|
||||
|
||||
static struct i2c_gecko_data i2c_gecko_data_1;
|
||||
|
||||
DEVICE_AND_API_INIT(i2c_gecko_1, DT_INST_1_SILABS_GECKO_I2C_LABEL,
|
||||
DEVICE_AND_API_INIT(i2c_gecko_1, DT_INST_LABEL(1),
|
||||
&i2c_gecko_init, &i2c_gecko_data_1, &i2c_gecko_config_1,
|
||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&i2c_gecko_driver_api);
|
||||
#endif /* DT_INST_1_SILABS_GECKO_I2C */
|
||||
#endif /* DT_HAS_DRV_INST(1) */
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT silabs_gecko_leuart
|
||||
|
||||
#include <errno.h>
|
||||
#include <drivers/uart.h>
|
||||
#include <em_leuart.h>
|
||||
|
@ -315,32 +317,32 @@ static const struct uart_driver_api leuart_gecko_driver_api = {
|
|||
#endif
|
||||
};
|
||||
|
||||
#ifdef DT_INST_0_SILABS_GECKO_LEUART
|
||||
#if DT_HAS_DRV_INST(0)
|
||||
|
||||
#define PIN_LEUART_0_RXD {DT_INST_0_SILABS_GECKO_LEUART_LOCATION_RX_1, \
|
||||
DT_INST_0_SILABS_GECKO_LEUART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_LEUART_0_TXD {DT_INST_0_SILABS_GECKO_LEUART_LOCATION_TX_1, \
|
||||
DT_INST_0_SILABS_GECKO_LEUART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#define PIN_LEUART_0_RXD {DT_INST_PROP_BY_IDX(0, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_LEUART_0_TXD {DT_INST_PROP_BY_IDX(0, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void leuart_gecko_config_func_0(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct leuart_gecko_config leuart_gecko_0_config = {
|
||||
.base = (LEUART_TypeDef *)DT_INST_0_SILABS_GECKO_LEUART_BASE_ADDRESS,
|
||||
.clock = CLOCK_LEUART(DT_INST_0_SILABS_GECKO_LEUART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_0_SILABS_GECKO_LEUART_CURRENT_SPEED,
|
||||
.base = (LEUART_TypeDef *)DT_INST_REG_ADDR(0),
|
||||
.clock = CLOCK_LEUART(DT_INST_PROP(0, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(0, current_speed),
|
||||
.pin_rx = PIN_LEUART_0_RXD,
|
||||
.pin_tx = PIN_LEUART_0_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_0_SILABS_GECKO_LEUART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_0_SILABS_GECKO_LEUART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(0, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(0, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_0_SILABS_GECKO_LEUART_LOCATION_RX_0 \
|
||||
!= DT_INST_0_SILABS_GECKO_LEUART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(0, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(0, location_tx, 0)
|
||||
#error LEUART_0 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_0_SILABS_GECKO_LEUART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(0, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = leuart_gecko_config_func_0,
|
||||
|
@ -349,7 +351,7 @@ static const struct leuart_gecko_config leuart_gecko_0_config = {
|
|||
|
||||
static struct leuart_gecko_data leuart_gecko_0_data;
|
||||
|
||||
DEVICE_AND_API_INIT(leuart_0, DT_INST_0_SILABS_GECKO_LEUART_LABEL,
|
||||
DEVICE_AND_API_INIT(leuart_0, DT_INST_LABEL(0),
|
||||
&leuart_gecko_init, &leuart_gecko_0_data,
|
||||
&leuart_gecko_0_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
|
@ -358,42 +360,42 @@ DEVICE_AND_API_INIT(leuart_0, DT_INST_0_SILABS_GECKO_LEUART_LABEL,
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void leuart_gecko_config_func_0(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_0_SILABS_GECKO_LEUART_IRQ_0,
|
||||
DT_INST_0_SILABS_GECKO_LEUART_IRQ_0_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQN(0),
|
||||
DT_INST_IRQ(0, priority),
|
||||
leuart_gecko_isr, DEVICE_GET(leuart_0), 0);
|
||||
|
||||
irq_enable(DT_INST_0_SILABS_GECKO_LEUART_IRQ_0);
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_0_SILABS_GECKO_LEUART */
|
||||
#endif /* DT_HAS_DRV_INST(0) */
|
||||
|
||||
#ifdef DT_INST_1_SILABS_GECKO_LEUART
|
||||
#if DT_HAS_DRV_INST(1)
|
||||
|
||||
#define PIN_LEUART_1_RXD {DT_INST_1_SILABS_GECKO_LEUART_LOCATION_RX_1, \
|
||||
DT_INST_1_SILABS_GECKO_LEUART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_LEUART_1_TXD {DT_INST_1_SILABS_GECKO_LEUART_LOCATION_TX_1, \
|
||||
DT_INST_1_SILABS_GECKO_LEUART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#define PIN_LEUART_1_RXD {DT_INST_PROP_BY_IDX(1, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(1, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_LEUART_1_TXD {DT_INST_PROP_BY_IDX(1, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(1, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void leuart_gecko_config_func_1(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct leuart_gecko_config leuart_gecko_1_config = {
|
||||
.base = (LEUART_TypeDef *)DT_INST_1_SILABS_GECKO_LEUART_BASE_ADDRESS,
|
||||
.clock = CLOCK_LEUART(DT_INST_1_SILABS_GECKO_LEUART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_1_SILABS_GECKO_LEUART_CURRENT_SPEED,
|
||||
.base = (LEUART_TypeDef *)DT_INST_REG_ADDR(1),
|
||||
.clock = CLOCK_LEUART(DT_INST_PROP(1, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(1, current_speed),
|
||||
.pin_rx = PIN_LEUART_1_RXD,
|
||||
.pin_tx = PIN_LEUART_1_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_1_SILABS_GECKO_LEUART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_1_SILABS_GECKO_LEUART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(1, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(1, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_1_SILABS_GECKO_LEUART_LOCATION_RX_0 \
|
||||
!= DT_INST_1_SILABS_GECKO_LEUART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(1, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(1, location_tx, 0)
|
||||
#error LEUART_1 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_1_SILABS_GECKO_LEUART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(1, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = leuart_gecko_config_func_1,
|
||||
|
@ -402,7 +404,7 @@ static const struct leuart_gecko_config leuart_gecko_1_config = {
|
|||
|
||||
static struct leuart_gecko_data leuart_gecko_1_data;
|
||||
|
||||
DEVICE_AND_API_INIT(leuart_1, DT_INST_1_SILABS_GECKO_LEUART_LABEL,
|
||||
DEVICE_AND_API_INIT(leuart_1, DT_INST_LABEL(1),
|
||||
&leuart_gecko_init, &leuart_gecko_1_data,
|
||||
&leuart_gecko_1_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
|
@ -411,12 +413,12 @@ DEVICE_AND_API_INIT(leuart_1, DT_INST_1_SILABS_GECKO_LEUART_LABEL,
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void leuart_gecko_config_func_1(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_1_SILABS_GECKO_LEUART_IRQ_0,
|
||||
DT_INST_1_SILABS_GECKO_LEUART_IRQ_0_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQN(1),
|
||||
DT_INST_IRQ(1, priority),
|
||||
leuart_gecko_isr, DEVICE_GET(leuart_1), 0);
|
||||
|
||||
irq_enable(DT_INST_1_SILABS_GECKO_LEUART_IRQ_0);
|
||||
irq_enable(DT_INST_IRQN(1));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_1_SILABS_GECKO_LEUART */
|
||||
#endif /* DT_HAS_DRV_INST(1) */
|
||||
|
|
|
@ -301,32 +301,34 @@ static const struct uart_driver_api uart_gecko_driver_api = {
|
|||
#endif
|
||||
};
|
||||
|
||||
#ifdef DT_INST_0_SILABS_GECKO_UART
|
||||
#define DT_DRV_COMPAT silabs_gecko_uart
|
||||
|
||||
#define PIN_UART0_RXD {DT_INST_0_SILABS_GECKO_UART_LOCATION_RX_1, \
|
||||
DT_INST_0_SILABS_GECKO_UART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_UART0_TXD {DT_INST_0_SILABS_GECKO_UART_LOCATION_TX_1, \
|
||||
DT_INST_0_SILABS_GECKO_UART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#if DT_HAS_DRV_INST(0)
|
||||
|
||||
#define PIN_UART0_RXD {DT_INST_PROP_BY_IDX(0, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_UART0_TXD {DT_INST_PROP_BY_IDX(0, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_gecko_config_func_0(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_gecko_config uart_gecko_0_config = {
|
||||
.base = (USART_TypeDef *)DT_INST_0_SILABS_GECKO_UART_BASE_ADDRESS,
|
||||
.clock = CLOCK_UART(DT_INST_0_SILABS_GECKO_UART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_0_SILABS_GECKO_UART_CURRENT_SPEED,
|
||||
.base = (USART_TypeDef *)DT_INST_REG_ADDR(0),
|
||||
.clock = CLOCK_UART(DT_INST_PROP(0, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(0, current_speed),
|
||||
.pin_rx = PIN_UART0_RXD,
|
||||
.pin_tx = PIN_UART0_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_0_SILABS_GECKO_UART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_0_SILABS_GECKO_UART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(0, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(0, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_0_SILABS_GECKO_UART_LOCATION_RX_0 \
|
||||
!= DT_INST_0_SILABS_GECKO_UART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(0, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(0, location_tx, 0)
|
||||
#error UART_0 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_0_SILABS_GECKO_UART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(0, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = uart_gecko_config_func_0,
|
||||
|
@ -335,53 +337,53 @@ static const struct uart_gecko_config uart_gecko_0_config = {
|
|||
|
||||
static struct uart_gecko_data uart_gecko_0_data;
|
||||
|
||||
DEVICE_AND_API_INIT(uart_0, DT_INST_0_SILABS_GECKO_UART_LABEL, &uart_gecko_init,
|
||||
DEVICE_AND_API_INIT(uart_0, DT_INST_LABEL(0), &uart_gecko_init,
|
||||
&uart_gecko_0_data, &uart_gecko_0_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &uart_gecko_driver_api);
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_gecko_config_func_0(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_0_SILABS_GECKO_UART_IRQ_RX,
|
||||
DT_INST_0_SILABS_GECKO_UART_IRQ_RX_PRIORITY, uart_gecko_isr,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, rx, irq),
|
||||
DT_INST_IRQ_BY_NAME(0, rx, priority), uart_gecko_isr,
|
||||
DEVICE_GET(uart_0), 0);
|
||||
IRQ_CONNECT(DT_INST_0_SILABS_GECKO_UART_IRQ_TX,
|
||||
DT_INST_0_SILABS_GECKO_UART_IRQ_TX_PRIORITY, uart_gecko_isr,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, tx, irq),
|
||||
DT_INST_IRQ_BY_NAME(0, tx, priority), uart_gecko_isr,
|
||||
DEVICE_GET(uart_0), 0);
|
||||
|
||||
irq_enable(DT_INST_0_SILABS_GECKO_UART_IRQ_RX);
|
||||
irq_enable(DT_INST_0_SILABS_GECKO_UART_IRQ_TX);
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(0, rx, irq));
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(0, tx, irq));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_0_SILABS_GECKO_UART */
|
||||
#endif /* DT_HAS_DRV_INST(0) */
|
||||
|
||||
#ifdef DT_INST_1_SILABS_GECKO_UART
|
||||
#if DT_HAS_DRV_INST(1)
|
||||
|
||||
#define PIN_UART1_RXD {DT_INST_1_SILABS_GECKO_UART_LOCATION_RX_1, \
|
||||
DT_INST_1_SILABS_GECKO_UART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_UART1_TXD {DT_INST_1_SILABS_GECKO_UART_LOCATION_TX_1, \
|
||||
DT_INST_1_SILABS_GECKO_UART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#define PIN_UART1_RXD {DT_INST_PROP_BY_IDX(1, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(1, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_UART1_TXD {DT_INST_PROP_BY_IDX(1, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(1, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_gecko_config_func_1(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_gecko_config uart_gecko_1_config = {
|
||||
.base = (USART_TypeDef *)DT_INST_1_SILABS_GECKO_UART_BASE_ADDRESS,
|
||||
.clock = CLOCK_UART(DT_INST_1_SILABS_GECKO_UART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_1_SILABS_GECKO_UART_CURRENT_SPEED,
|
||||
.base = (USART_TypeDef *)DT_INST_REG_ADDR(1),
|
||||
.clock = CLOCK_UART(DT_INST_PROP(1, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(1, current_speed),
|
||||
.pin_rx = PIN_UART1_RXD,
|
||||
.pin_tx = PIN_UART1_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_1_SILABS_GECKO_UART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_1_SILABS_GECKO_UART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(1, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(1, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_1_SILABS_GECKO_UART_LOCATION_RX_0 \
|
||||
!= DT_INST_1_SILABS_GECKO_UART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(1, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(1, location_tx, 0)
|
||||
#error UART_1 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_1_SILABS_GECKO_UART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(1, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = uart_gecko_config_func_1,
|
||||
|
@ -390,53 +392,56 @@ static const struct uart_gecko_config uart_gecko_1_config = {
|
|||
|
||||
static struct uart_gecko_data uart_gecko_1_data;
|
||||
|
||||
DEVICE_AND_API_INIT(uart_1, DT_INST_1_SILABS_GECKO_UART_LABEL, &uart_gecko_init,
|
||||
DEVICE_AND_API_INIT(uart_1, DT_INST_LABEL(1), &uart_gecko_init,
|
||||
&uart_gecko_1_data, &uart_gecko_1_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &uart_gecko_driver_api);
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_gecko_config_func_1(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_1_SILABS_GECKO_UART_IRQ_RX,
|
||||
DT_INST_1_SILABS_GECKO_UART_IRQ_RX_PRIORITY, uart_gecko_isr,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(1, rx, irq),
|
||||
DT_INST_IRQ_BY_NAME(1, rx, priority), uart_gecko_isr,
|
||||
DEVICE_GET(uart_1), 0);
|
||||
IRQ_CONNECT(DT_INST_1_SILABS_GECKO_UART_IRQ_TX,
|
||||
DT_INST_1_SILABS_GECKO_UART_IRQ_TX_PRIORITY, uart_gecko_isr,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(1, tx, irq),
|
||||
DT_INST_IRQ_BY_NAME(1, tx, priority), uart_gecko_isr,
|
||||
DEVICE_GET(uart_1), 0);
|
||||
|
||||
irq_enable(DT_INST_1_SILABS_GECKO_UART_IRQ_RX);
|
||||
irq_enable(DT_INST_1_SILABS_GECKO_UART_IRQ_TX);
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(1, rx, irq));
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(1, tx, irq));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_1_SILABS_GECKO_UART */
|
||||
#endif /* DT_HAS_DRV_INST(1) */
|
||||
|
||||
#ifdef DT_INST_0_SILABS_GECKO_USART
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT silabs_gecko_usart
|
||||
|
||||
#define PIN_USART0_RXD {DT_INST_0_SILABS_GECKO_USART_LOCATION_RX_1, \
|
||||
DT_INST_0_SILABS_GECKO_USART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_USART0_TXD {DT_INST_0_SILABS_GECKO_USART_LOCATION_TX_1, \
|
||||
DT_INST_0_SILABS_GECKO_USART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#if DT_HAS_DRV_INST(0)
|
||||
|
||||
#define PIN_USART0_RXD {DT_INST_PROP_BY_IDX(0, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_USART0_TXD {DT_INST_PROP_BY_IDX(0, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(0, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_0(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_gecko_config usart_gecko_0_config = {
|
||||
.base = (USART_TypeDef *)DT_INST_0_SILABS_GECKO_USART_BASE_ADDRESS,
|
||||
.clock = CLOCK_USART(DT_INST_0_SILABS_GECKO_USART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_0_SILABS_GECKO_USART_CURRENT_SPEED,
|
||||
.base = (USART_TypeDef *)DT_INST_REG_ADDR(0),
|
||||
.clock = CLOCK_USART(DT_INST_PROP(0, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(0, current_speed),
|
||||
.pin_rx = PIN_USART0_RXD,
|
||||
.pin_tx = PIN_USART0_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_0_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_0_SILABS_GECKO_USART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(0, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(0, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_0_SILABS_GECKO_USART_LOCATION_RX_0 \
|
||||
!= DT_INST_0_SILABS_GECKO_USART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(0, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(0, location_tx, 0)
|
||||
#error USART_0 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_0_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(0, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = usart_gecko_config_func_0,
|
||||
|
@ -445,7 +450,7 @@ static const struct uart_gecko_config usart_gecko_0_config = {
|
|||
|
||||
static struct uart_gecko_data usart_gecko_0_data;
|
||||
|
||||
DEVICE_AND_API_INIT(usart_0, DT_INST_0_SILABS_GECKO_USART_LABEL,
|
||||
DEVICE_AND_API_INIT(usart_0, DT_INST_LABEL(0),
|
||||
&uart_gecko_init, &usart_gecko_0_data,
|
||||
&usart_gecko_0_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &uart_gecko_driver_api);
|
||||
|
@ -453,46 +458,46 @@ DEVICE_AND_API_INIT(usart_0, DT_INST_0_SILABS_GECKO_USART_LABEL,
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_0(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_0_SILABS_GECKO_USART_IRQ_RX,
|
||||
DT_INST_0_SILABS_GECKO_USART_IRQ_RX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, rx, irq),
|
||||
DT_INST_IRQ_BY_NAME(0, rx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_0), 0);
|
||||
IRQ_CONNECT(DT_INST_0_SILABS_GECKO_USART_IRQ_TX,
|
||||
DT_INST_0_SILABS_GECKO_USART_IRQ_TX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, tx, irq),
|
||||
DT_INST_IRQ_BY_NAME(0, tx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_0), 0);
|
||||
|
||||
irq_enable(DT_INST_0_SILABS_GECKO_USART_IRQ_RX);
|
||||
irq_enable(DT_INST_0_SILABS_GECKO_USART_IRQ_TX);
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(0, rx, irq));
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(0, tx, irq));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_0_SILABS_GECKO_USART */
|
||||
#endif /* DT_HAS_DRV_INST(0) */
|
||||
|
||||
#ifdef DT_INST_1_SILABS_GECKO_USART
|
||||
#if DT_HAS_DRV_INST(1)
|
||||
|
||||
#define PIN_USART1_RXD {DT_INST_1_SILABS_GECKO_USART_LOCATION_RX_1, \
|
||||
DT_INST_1_SILABS_GECKO_USART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_USART1_TXD {DT_INST_1_SILABS_GECKO_USART_LOCATION_TX_1, \
|
||||
DT_INST_1_SILABS_GECKO_USART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#define PIN_USART1_RXD {DT_INST_PROP_BY_IDX(1, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(1, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_USART1_TXD {DT_INST_PROP_BY_IDX(1, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(1, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_1(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_gecko_config usart_gecko_1_config = {
|
||||
.base = (USART_TypeDef *)DT_INST_1_SILABS_GECKO_USART_BASE_ADDRESS,
|
||||
.clock = CLOCK_USART(DT_INST_1_SILABS_GECKO_USART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_1_SILABS_GECKO_USART_CURRENT_SPEED,
|
||||
.base = (USART_TypeDef *)DT_INST_REG_ADDR(1),
|
||||
.clock = CLOCK_USART(DT_INST_PROP(1, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(1, current_speed),
|
||||
.pin_rx = PIN_USART1_RXD,
|
||||
.pin_tx = PIN_USART1_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_1_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_1_SILABS_GECKO_USART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(1, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(1, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_1_SILABS_GECKO_USART_LOCATION_RX_0 \
|
||||
!= DT_INST_1_SILABS_GECKO_USART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(1, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(1, location_tx, 0)
|
||||
#error USART_1 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_1_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(1, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = usart_gecko_config_func_1,
|
||||
|
@ -501,7 +506,7 @@ static const struct uart_gecko_config usart_gecko_1_config = {
|
|||
|
||||
static struct uart_gecko_data usart_gecko_1_data;
|
||||
|
||||
DEVICE_AND_API_INIT(usart_1, DT_INST_1_SILABS_GECKO_USART_LABEL,
|
||||
DEVICE_AND_API_INIT(usart_1, DT_INST_LABEL(1),
|
||||
&uart_gecko_init, &usart_gecko_1_data,
|
||||
&usart_gecko_1_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &uart_gecko_driver_api);
|
||||
|
@ -509,46 +514,46 @@ DEVICE_AND_API_INIT(usart_1, DT_INST_1_SILABS_GECKO_USART_LABEL,
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_1(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_1_SILABS_GECKO_USART_IRQ_RX,
|
||||
DT_INST_1_SILABS_GECKO_USART_IRQ_RX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(1, rx, irq),
|
||||
DT_INST_IRQ_BY_NAME(1, rx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_1), 0);
|
||||
IRQ_CONNECT(DT_INST_1_SILABS_GECKO_USART_IRQ_TX,
|
||||
DT_INST_1_SILABS_GECKO_USART_IRQ_TX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(1, tx, irq),
|
||||
DT_INST_IRQ_BY_NAME(1, tx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_1), 0);
|
||||
|
||||
irq_enable(DT_INST_1_SILABS_GECKO_USART_IRQ_RX);
|
||||
irq_enable(DT_INST_1_SILABS_GECKO_USART_IRQ_TX);
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(1, rx, irq));
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(1, tx, irq));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_1_SILABS_GECKO_USART */
|
||||
#endif /* DT_HAS_DRV_INST(1) */
|
||||
|
||||
#ifdef DT_INST_2_SILABS_GECKO_USART
|
||||
#if DT_HAS_DRV_INST(2)
|
||||
|
||||
#define PIN_USART2_RXD {DT_INST_2_SILABS_GECKO_USART_LOCATION_RX_1, \
|
||||
DT_INST_2_SILABS_GECKO_USART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_USART2_TXD {DT_INST_2_SILABS_GECKO_USART_LOCATION_TX_1, \
|
||||
DT_INST_2_SILABS_GECKO_USART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#define PIN_USART2_RXD {DT_INST_PROP_BY_IDX(2, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(2, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_USART2_TXD {DT_INST_PROP_BY_IDX(2, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(2, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_2(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_gecko_config usart_gecko_2_config = {
|
||||
.base = (USART_TypeDef *)DT_INST_2_SILABS_GECKO_USART_BASE_ADDRESS,
|
||||
.clock = CLOCK_USART(DT_INST_2_SILABS_GECKO_USART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_2_SILABS_GECKO_USART_CURRENT_SPEED,
|
||||
.base = (USART_TypeDef *)DT_INST_REG_ADDR(2),
|
||||
.clock = CLOCK_USART(DT_INST_PROP(2, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(2, current_speed),
|
||||
.pin_rx = PIN_USART2_RXD,
|
||||
.pin_tx = PIN_USART2_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_2_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_2_SILABS_GECKO_USART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(2, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(2, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_2_SILABS_GECKO_USART_LOCATION_RX_0 \
|
||||
!= DT_INST_2_SILABS_GECKO_USART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(2, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(2, location_tx, 0)
|
||||
#error USART_2 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_2_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(2, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = usart_gecko_config_func_2,
|
||||
|
@ -557,7 +562,7 @@ static const struct uart_gecko_config usart_gecko_2_config = {
|
|||
|
||||
static struct uart_gecko_data usart_gecko_2_data;
|
||||
|
||||
DEVICE_AND_API_INIT(usart_2, DT_INST_2_SILABS_GECKO_USART_LABEL,
|
||||
DEVICE_AND_API_INIT(usart_2, DT_INST_LABEL(2),
|
||||
&uart_gecko_init, &usart_gecko_2_data,
|
||||
&usart_gecko_2_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &uart_gecko_driver_api);
|
||||
|
@ -565,46 +570,46 @@ DEVICE_AND_API_INIT(usart_2, DT_INST_2_SILABS_GECKO_USART_LABEL,
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_2(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_2_SILABS_GECKO_USART_IRQ_RX,
|
||||
DT_INST_2_SILABS_GECKO_USART_IRQ_RX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(2, rx, irq),
|
||||
DT_INST_IRQ_BY_NAME(2, rx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_2), 0);
|
||||
IRQ_CONNECT(DT_INST_2_SILABS_GECKO_USART_IRQ_TX,
|
||||
DT_INST_2_SILABS_GECKO_USART_IRQ_TX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(2, tx, irq),
|
||||
DT_INST_IRQ_BY_NAME(2, tx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_2), 0);
|
||||
|
||||
irq_enable(DT_INST_2_SILABS_GECKO_USART_IRQ_RX);
|
||||
irq_enable(DT_INST_2_SILABS_GECKO_USART_IRQ_TX);
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(2, rx, irq));
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(2, tx, irq));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_2_SILABS_GECKO_USART */
|
||||
#endif /* DT_HAS_DRV_INST(2) */
|
||||
|
||||
#ifdef DT_INST_3_SILABS_GECKO_USART
|
||||
#if DT_HAS_DRV_INST(3)
|
||||
|
||||
#define PIN_USART3_RXD {DT_INST_3_SILABS_GECKO_USART_LOCATION_RX_1, \
|
||||
DT_INST_3_SILABS_GECKO_USART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_USART3_TXD {DT_INST_3_SILABS_GECKO_USART_LOCATION_TX_1, \
|
||||
DT_INST_3_SILABS_GECKO_USART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#define PIN_USART3_RXD {DT_INST_PROP_BY_IDX(3, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(3, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_USART3_TXD {DT_INST_PROP_BY_IDX(3, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(3, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_3(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_gecko_config usart_gecko_3_config = {
|
||||
.base = (USART_TypeDef *)DT_INST_3_SILABS_GECKO_USART_BASE_ADDRESS,
|
||||
.clock = CLOCK_USART(DT_INST_3_SILABS_GECKO_USART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_3_SILABS_GECKO_USART_CURRENT_SPEED,
|
||||
.base = (USART_TypeDef *)DT_INST_REG_ADDR(3),
|
||||
.clock = CLOCK_USART(DT_INST_PROP(3, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(3, current_speed),
|
||||
.pin_rx = PIN_USART3_RXD,
|
||||
.pin_tx = PIN_USART3_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_3_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_3_SILABS_GECKO_USART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(3, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(3, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_3_SILABS_GECKO_USART_LOCATION_RX_0 \
|
||||
!= DT_INST_3_SILABS_GECKO_USART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(3, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(3, location_tx, 0)
|
||||
#error USART_3 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_3_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(3, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = usart_gecko_config_func_3,
|
||||
|
@ -613,7 +618,7 @@ static const struct uart_gecko_config usart_gecko_3_config = {
|
|||
|
||||
static struct uart_gecko_data usart_gecko_3_data;
|
||||
|
||||
DEVICE_AND_API_INIT(usart_3, DT_INST_3_SILABS_GECKO_USART_LABEL,
|
||||
DEVICE_AND_API_INIT(usart_3, DT_INST_LABEL(3),
|
||||
&uart_gecko_init, &usart_gecko_3_data,
|
||||
&usart_gecko_3_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &uart_gecko_driver_api);
|
||||
|
@ -621,46 +626,46 @@ DEVICE_AND_API_INIT(usart_3, DT_INST_3_SILABS_GECKO_USART_LABEL,
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_3(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_3_SILABS_GECKO_USART_IRQ_RX,
|
||||
DT_INST_3_SILABS_GECKO_USART_IRQ_RX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(3, rx, irq),
|
||||
DT_INST_IRQ_BY_NAME(3, rx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_3), 0);
|
||||
IRQ_CONNECT(DT_INST_3_SILABS_GECKO_USART_IRQ_TX,
|
||||
DT_INST_3_SILABS_GECKO_USART_IRQ_TX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(3, tx, irq),
|
||||
DT_INST_IRQ_BY_NAME(3, tx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_3), 0);
|
||||
|
||||
irq_enable(DT_INST_3_SILABS_GECKO_USART_IRQ_RX);
|
||||
irq_enable(DT_INST_3_SILABS_GECKO_USART_IRQ_TX);
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(3, rx, irq));
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(3, tx, irq));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_3_SILABS_GECKO_USART */
|
||||
#endif /* DT_HAS_DRV_INST(3) */
|
||||
|
||||
#ifdef DT_INST_4_SILABS_GECKO_USART
|
||||
#if DT_HAS_DRV_INST(4)
|
||||
|
||||
#define PIN_USART4_RXD {DT_INST_4_SILABS_GECKO_USART_LOCATION_RX_1, \
|
||||
DT_INST_4_SILABS_GECKO_USART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_USART4_TXD {DT_INST_4_SILABS_GECKO_USART_LOCATION_TX_1, \
|
||||
DT_INST_4_SILABS_GECKO_USART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#define PIN_USART4_RXD {DT_INST_PROP_BY_IDX(4, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(4, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_USART4_TXD {DT_INST_PROP_BY_IDX(4, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(4, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_4(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_gecko_config usart_gecko_4_config = {
|
||||
.base = (USART_TypeDef *)DT_INST_4_SILABS_GECKO_USART_BASE_ADDRESS,
|
||||
.clock = CLOCK_USART(DT_INST_4_SILABS_GECKO_USART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_4_SILABS_GECKO_USART_CURRENT_SPEED,
|
||||
.base = (USART_TypeDef *)DT_INST_REG_ADDR(4),
|
||||
.clock = CLOCK_USART(DT_INST_PROP(4, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(4, current_speed),
|
||||
.pin_rx = PIN_USART4_RXD,
|
||||
.pin_tx = PIN_USART4_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_4_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_4_SILABS_GECKO_USART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(4, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(4, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_4_SILABS_GECKO_USART_LOCATION_RX_0 \
|
||||
!= DT_INST_4_SILABS_GECKO_USART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(4, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(4, location_tx, 0)
|
||||
#error USART_4 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_4_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(4, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = usart_gecko_config_func_4,
|
||||
|
@ -669,7 +674,7 @@ static const struct uart_gecko_config usart_gecko_4_config = {
|
|||
|
||||
static struct uart_gecko_data usart_gecko_4_data;
|
||||
|
||||
DEVICE_AND_API_INIT(usart_4, DT_INST_4_SILABS_GECKO_USART_LABEL,
|
||||
DEVICE_AND_API_INIT(usart_4, DT_INST_LABEL(4),
|
||||
&uart_gecko_init, &usart_gecko_4_data,
|
||||
&usart_gecko_4_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &uart_gecko_driver_api);
|
||||
|
@ -677,46 +682,46 @@ DEVICE_AND_API_INIT(usart_4, DT_INST_4_SILABS_GECKO_USART_LABEL,
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_4(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_4_SILABS_GECKO_USART_IRQ_RX,
|
||||
DT_INST_4_SILABS_GECKO_USART_IRQ_RX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(4, rx, irq),
|
||||
DT_INST_IRQ_BY_NAME(4, rx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_4), 0);
|
||||
IRQ_CONNECT(DT_INST_4_SILABS_GECKO_USART_IRQ_TX,
|
||||
DT_INST_4_SILABS_GECKO_USART_IRQ_TX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(4, tx, irq),
|
||||
DT_INST_IRQ_BY_NAME(4, tx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_4), 0);
|
||||
|
||||
irq_enable(DT_INST_4_SILABS_GECKO_USART_IRQ_RX);
|
||||
irq_enable(DT_INST_4_SILABS_GECKO_USART_IRQ_TX);
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(4, rx, irq));
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(4, tx, irq));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_4_SILABS_GECKO_USART */
|
||||
#endif /* DT_HAS_DRV_INST(4) */
|
||||
|
||||
#ifdef DT_INST_5_SILABS_GECKO_USART
|
||||
#if DT_HAS_DRV_INST(5)
|
||||
|
||||
#define PIN_USART5_RXD {DT_INST_5_SILABS_GECKO_USART_LOCATION_RX_1, \
|
||||
DT_INST_5_SILABS_GECKO_USART_LOCATION_RX_2, gpioModeInput, 1}
|
||||
#define PIN_USART5_TXD {DT_INST_5_SILABS_GECKO_USART_LOCATION_TX_1, \
|
||||
DT_INST_5_SILABS_GECKO_USART_LOCATION_TX_2, gpioModePushPull, 1}
|
||||
#define PIN_USART5_RXD {DT_INST_PROP_BY_IDX(5, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(5, location_rx, 2), gpioModeInput, 1}
|
||||
#define PIN_USART5_TXD {DT_INST_PROP_BY_IDX(5, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(5, location_tx, 2), gpioModePushPull, 1}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_5(struct device *dev);
|
||||
#endif
|
||||
|
||||
static const struct uart_gecko_config usart_gecko_5_config = {
|
||||
.base = (USART_TypeDef *)DT_INST_5_SILABS_GECKO_USART_BASE_ADDRESS,
|
||||
.clock = CLOCK_USART(DT_INST_5_SILABS_GECKO_USART_PERIPHERAL_ID),
|
||||
.baud_rate = DT_INST_5_SILABS_GECKO_USART_CURRENT_SPEED,
|
||||
.base = (USART_TypeDef *)DT_INST_REG_ADDR(5),
|
||||
.clock = CLOCK_USART(DT_INST_PROP(5, peripheral_id)),
|
||||
.baud_rate = DT_INST_PROP(5, current_speed),
|
||||
.pin_rx = PIN_USART5_RXD,
|
||||
.pin_tx = PIN_USART5_TXD,
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
.loc_rx = DT_INST_5_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc_tx = DT_INST_5_SILABS_GECKO_USART_LOCATION_TX_0,
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(5, location_rx, 0),
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(5, location_tx, 0),
|
||||
#else
|
||||
#if DT_INST_5_SILABS_GECKO_USART_LOCATION_RX_0 \
|
||||
!= DT_INST_5_SILABS_GECKO_USART_LOCATION_TX_0
|
||||
#if DT_INST_PROP_BY_IDX(5, location_rx, 0) \
|
||||
!= DT_INST_PROP_BY_IDX(5, location_tx, 0)
|
||||
#error USART_5 DTS location-* properties must have identical value
|
||||
#endif
|
||||
.loc = DT_INST_5_SILABS_GECKO_USART_LOCATION_RX_0,
|
||||
.loc = DT_INST_PROP_BY_IDX(5, location_rx, 0),
|
||||
#endif
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = usart_gecko_config_func_5,
|
||||
|
@ -725,7 +730,7 @@ static const struct uart_gecko_config usart_gecko_5_config = {
|
|||
|
||||
static struct uart_gecko_data usart_gecko_5_data;
|
||||
|
||||
DEVICE_AND_API_INIT(usart_5, DT_INST_5_SILABS_GECKO_USART_LABEL,
|
||||
DEVICE_AND_API_INIT(usart_5, DT_INST_LABEL(5),
|
||||
&uart_gecko_init, &usart_gecko_5_data,
|
||||
&usart_gecko_5_config, PRE_KERNEL_1,
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &uart_gecko_driver_api);
|
||||
|
@ -733,16 +738,16 @@ DEVICE_AND_API_INIT(usart_5, DT_INST_5_SILABS_GECKO_USART_LABEL,
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void usart_gecko_config_func_5(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_5_SILABS_GECKO_USART_IRQ_RX,
|
||||
DT_INST_5_SILABS_GECKO_USART_IRQ_RX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(5, rx, irq),
|
||||
DT_INST_IRQ_BY_NAME(5, rx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_5), 0);
|
||||
IRQ_CONNECT(DT_INST_5_SILABS_GECKO_USART_IRQ_TX,
|
||||
DT_INST_5_SILABS_GECKO_USART_IRQ_TX_PRIORITY,
|
||||
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(5, tx, irq),
|
||||
DT_INST_IRQ_BY_NAME(5, tx, priority),
|
||||
uart_gecko_isr, DEVICE_GET(usart_5), 0);
|
||||
|
||||
irq_enable(DT_INST_5_SILABS_GECKO_USART_IRQ_RX);
|
||||
irq_enable(DT_INST_5_SILABS_GECKO_USART_IRQ_TX);
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(5, rx, irq));
|
||||
irq_enable(DT_INST_IRQ_BY_NAME(5, tx, irq));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DT_INST_5_SILABS_GECKO_USART */
|
||||
#endif /* DT_HAS_DRV_INST(5) */
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT silabs_gecko_spi_usart
|
||||
|
||||
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_REGISTER(spi_gecko);
|
||||
|
@ -291,23 +293,23 @@ static struct spi_driver_api spi_gecko_api = {
|
|||
}; \
|
||||
static struct spi_gecko_config spi_gecko_cfg_##n = { \
|
||||
.base = (USART_TypeDef *) \
|
||||
DT_INST_##n##_SILABS_GECKO_SPI_USART_BASE_ADDRESS, \
|
||||
DT_INST_REG_ADDR(n), \
|
||||
.clock = CLOCK_USART(usart), \
|
||||
.pin_rx = { DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_RX_1, \
|
||||
DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_RX_2, \
|
||||
.pin_rx = { DT_INST_PROP_BY_IDX(n, location_rx, 1), \
|
||||
DT_INST_PROP_BY_IDX(n, location_rx, 2), \
|
||||
gpioModeInput, 1}, \
|
||||
.pin_tx = { DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_TX_1, \
|
||||
DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_TX_2, \
|
||||
.pin_tx = { DT_INST_PROP_BY_IDX(n, location_tx, 1), \
|
||||
DT_INST_PROP_BY_IDX(n, location_tx, 2), \
|
||||
gpioModePushPull, 1}, \
|
||||
.pin_clk = { DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_CLK_1, \
|
||||
DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_CLK_2, \
|
||||
.pin_clk = { DT_INST_PROP_BY_IDX(n, location_clk, 1), \
|
||||
DT_INST_PROP_BY_IDX(n, location_clk, 2), \
|
||||
gpioModePushPull, 1}, \
|
||||
.loc_rx = DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_RX_0, \
|
||||
.loc_tx = DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_TX_0, \
|
||||
.loc_clk = DT_INST_##n##_SILABS_GECKO_SPI_USART_LOCATION_CLK_0, \
|
||||
.loc_rx = DT_INST_PROP_BY_IDX(n, location_rx, 0), \
|
||||
.loc_tx = DT_INST_PROP_BY_IDX(n, location_tx, 0), \
|
||||
.loc_clk = DT_INST_PROP_BY_IDX(n, location_clk, 0), \
|
||||
}; \
|
||||
DEVICE_AND_API_INIT(spi_##n, \
|
||||
DT_INST_##n##_SILABS_GECKO_SPI_USART_LABEL, \
|
||||
DT_INST_LABEL(n), \
|
||||
spi_gecko_init, \
|
||||
&spi_gecko_data_##n, \
|
||||
&spi_gecko_cfg_##n, \
|
||||
|
@ -315,30 +317,30 @@ static struct spi_driver_api spi_gecko_api = {
|
|||
CONFIG_SPI_INIT_PRIORITY, \
|
||||
&spi_gecko_api)
|
||||
|
||||
#define SPI_ID(n) DT_INST_##n##_SILABS_GECKO_SPI_USART_PERIPHERAL_ID
|
||||
#define SPI_ID(n) DT_INST_PROP(n, peripheral_id)
|
||||
|
||||
#define SPI_INIT(n) SPI_INIT2(n, SPI_ID(n))
|
||||
|
||||
#ifdef DT_INST_0_SILABS_GECKO_SPI_USART_LABEL
|
||||
#if DT_INST_NODE_HAS_PROP(0, label)
|
||||
|
||||
SPI_INIT(0);
|
||||
|
||||
#endif /* DT_INST_0_SILABS_GECKO_SPI_USART_LABEL */
|
||||
#endif /* DT_INST_NODE_HAS_PROP(0, label) */
|
||||
|
||||
#ifdef DT_INST_1_SILABS_GECKO_SPI_USART_LABEL
|
||||
#if DT_INST_NODE_HAS_PROP(1, label)
|
||||
|
||||
SPI_INIT(1);
|
||||
|
||||
#endif /* DT_INST_1_SILABS_GECKO_SPI_USART_LABEL */
|
||||
#endif /* DT_INST_NODE_HAS_PROP(1, label) */
|
||||
|
||||
#ifdef DT_INST_2_SILABS_GECKO_SPI_USART_LABEL
|
||||
#if DT_INST_NODE_HAS_PROP(2, label)
|
||||
|
||||
SPI_INIT(2);
|
||||
|
||||
#endif /* DT_INST_2_SILABS_GECKO_SPI_USART_LABEL */
|
||||
#endif /* DT_INST_NODE_HAS_PROP(2, label) */
|
||||
|
||||
#ifdef DT_INST_3_SILABS_GECKO_SPI_USART_LABEL
|
||||
#if DT_INST_NODE_HAS_PROP(3, label)
|
||||
|
||||
SPI_INIT(3);
|
||||
|
||||
#endif /* DT_INST_3_SILABS_GECKO_SPI_USART_LABEL */
|
||||
#endif /* DT_INST_NODE_HAS_PROP(3, label) */
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT silabs_gecko_wdog
|
||||
|
||||
#include <soc.h>
|
||||
#include <drivers/watchdog.h>
|
||||
#include <em_wdog.h>
|
||||
|
@ -271,13 +273,13 @@ static const struct wdt_driver_api wdt_gecko_driver_api = {
|
|||
\
|
||||
static const struct wdt_gecko_cfg wdt_gecko_cfg_##index = { \
|
||||
.base = (WDOG_TypeDef *) \
|
||||
DT_INST_##index##_SILABS_GECKO_WDOG_BASE_ADDRESS,\
|
||||
DT_INST_REG_ADDR(index),\
|
||||
.irq_cfg_func = wdt_gecko_cfg_func_##index, \
|
||||
}; \
|
||||
static struct wdt_gecko_data wdt_gecko_data_##index; \
|
||||
\
|
||||
DEVICE_AND_API_INIT(wdt_##index, \
|
||||
DT_INST_##index##_SILABS_GECKO_WDOG_LABEL,\
|
||||
DT_INST_LABEL(index),\
|
||||
&wdt_gecko_init, &wdt_gecko_data_##index,\
|
||||
&wdt_gecko_cfg_##index, POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
||||
|
@ -285,16 +287,16 @@ static const struct wdt_driver_api wdt_gecko_driver_api = {
|
|||
\
|
||||
static void wdt_gecko_cfg_func_##index(void) \
|
||||
{ \
|
||||
IRQ_CONNECT(DT_INST_##index##_SILABS_GECKO_WDOG_IRQ_0, \
|
||||
DT_INST_##index##_SILABS_GECKO_WDOG_IRQ_0_PRIORITY,\
|
||||
IRQ_CONNECT(DT_INST_IRQN(index), \
|
||||
DT_INST_IRQ(index, priority),\
|
||||
wdt_gecko_isr, DEVICE_GET(wdt_##index), 0); \
|
||||
irq_enable(DT_INST_##index##_SILABS_GECKO_WDOG_IRQ_0); \
|
||||
irq_enable(DT_INST_IRQN(index)); \
|
||||
}
|
||||
|
||||
#ifdef DT_INST_0_SILABS_GECKO_WDOG
|
||||
#if DT_HAS_DRV_INST(0)
|
||||
GECKO_WDT_INIT(0)
|
||||
#endif /* DT_INST_0_SILABS_GECKO_WDOG */
|
||||
#endif /* DT_HAS_DRV_INST(0) */
|
||||
|
||||
#ifdef DT_INST_1_SILABS_GECKO_WDOG
|
||||
#if DT_HAS_DRV_INST(1)
|
||||
GECKO_WDT_INIT(1)
|
||||
#endif /* DT_INST_1_SILABS_GECKO_WDOG */
|
||||
#endif /* DT_HAS_DRV_INST(1) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue