uart_sam0: don't consume CONFIG_UART_ASYNC_API directly.
There are situations in which the async API for uart can be provided by another driver (case in point, uart_rtt), and thus there is no valid DMA controller for the uart_sam0 driver to talk with. By separating the configuration, there's no need to exclude samd20-based boards (that have no DMA peripheral) from the uart_async_api tests. Signed-off-by: Diego Elio Pettenò <flameeyes@meta.com> Co-authored-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
parent
3b3528cd90
commit
4cada3ecaf
3 changed files with 19 additions and 33 deletions
|
@ -9,8 +9,12 @@ config UART_SAM0
|
||||||
depends on DT_HAS_ATMEL_SAM0_UART_ENABLED
|
depends on DT_HAS_ATMEL_SAM0_UART_ENABLED
|
||||||
select SERIAL_HAS_DRIVER
|
select SERIAL_HAS_DRIVER
|
||||||
select SERIAL_SUPPORT_INTERRUPT
|
select SERIAL_SUPPORT_INTERRUPT
|
||||||
# the ASYNC implementation requires a DMA controller
|
|
||||||
select SERIAL_SUPPORT_ASYNC if DT_HAS_ATMEL_SAM0_DMAC_ENABLED
|
select SERIAL_SUPPORT_ASYNC if DT_HAS_ATMEL_SAM0_DMAC_ENABLED
|
||||||
select DMA if UART_ASYNC_API
|
|
||||||
help
|
help
|
||||||
This option enables the SERCOMx USART driver for Atmel SAM0 MCUs.
|
This option enables the SERCOMx USART driver for Atmel SAM0 MCUs.
|
||||||
|
|
||||||
|
config UART_SAM0_ASYNC
|
||||||
|
bool "Async UART support for Atmel SAM0 series."
|
||||||
|
depends on DMA_SAM0
|
||||||
|
depends on UART_SAM0
|
||||||
|
depends on UART_ASYNC_API
|
||||||
|
|
|
@ -43,10 +43,10 @@ struct uart_sam0_dev_cfg {
|
||||||
uint32_t pm_apbcmask;
|
uint32_t pm_apbcmask;
|
||||||
uint16_t gclk_clkctrl_id;
|
uint16_t gclk_clkctrl_id;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_SAM0_ASYNC
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_SAM0_ASYNC
|
||||||
const struct device *dma_dev;
|
const struct device *dma_dev;
|
||||||
uint8_t tx_dma_request;
|
uint8_t tx_dma_request;
|
||||||
uint8_t tx_dma_channel;
|
uint8_t tx_dma_channel;
|
||||||
|
@ -64,7 +64,7 @@ struct uart_sam0_dev_data {
|
||||||
void *cb_data;
|
void *cb_data;
|
||||||
uint8_t txc_cache;
|
uint8_t txc_cache;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_SAM0_ASYNC
|
||||||
const struct device *dev;
|
const struct device *dev;
|
||||||
const struct uart_sam0_dev_cfg *cfg;
|
const struct uart_sam0_dev_cfg *cfg;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ static int uart_sam0_set_baudrate(SercomUsart *const usart, uint32_t baudrate,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_SAM0_ASYNC
|
||||||
|
|
||||||
static void uart_sam0_dma_tx_done(const struct device *dma_dev, void *arg,
|
static void uart_sam0_dma_tx_done(const struct device *dma_dev, void *arg,
|
||||||
uint32_t id, int error_code)
|
uint32_t id, int error_code)
|
||||||
|
@ -565,11 +565,11 @@ static int uart_sam0_init(const struct device *dev)
|
||||||
}
|
}
|
||||||
dev_data->config_cache.baudrate = cfg->baudrate;
|
dev_data->config_cache.baudrate = cfg->baudrate;
|
||||||
|
|
||||||
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_SAM0_ASYNC
|
||||||
cfg->irq_config_func(dev);
|
cfg->irq_config_func(dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_UART_ASYNC_API
|
#ifdef CONFIG_UART_SAM0_ASYNC
|
||||||
dev_data->dev = dev;
|
dev_data->dev = dev;
|
||||||
dev_data->cfg = cfg;
|
dev_data->cfg = cfg;
|
||||||
if (!device_is_ready(cfg->dma_dev)) {
|
if (!device_is_ready(cfg->dma_dev)) {
|
||||||
|
@ -705,7 +705,7 @@ static int uart_sam0_err_check(const struct device *dev)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_SAM0_ASYNC
|
||||||
|
|
||||||
static void uart_sam0_isr(const struct device *dev)
|
static void uart_sam0_isr(const struct device *dev)
|
||||||
{
|
{
|
||||||
|
@ -717,7 +717,7 @@ static void uart_sam0_isr(const struct device *dev)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_SAM0_ASYNC
|
||||||
const struct uart_sam0_dev_cfg *const cfg = dev->config;
|
const struct uart_sam0_dev_cfg *const cfg = dev->config;
|
||||||
SercomUsart * const regs = cfg->regs;
|
SercomUsart * const regs = cfg->regs;
|
||||||
|
|
||||||
|
@ -936,14 +936,14 @@ static void uart_sam0_irq_callback_set(const struct device *dev,
|
||||||
dev_data->cb = cb;
|
dev_data->cb = cb;
|
||||||
dev_data->cb_data = cb_data;
|
dev_data->cb_data = cb_data;
|
||||||
|
|
||||||
#if defined(CONFIG_UART_EXCLUSIVE_API_CALLBACKS)
|
#if defined(CONFIG_UART_SAM0_ASYNC) && defined(CONFIG_UART_EXCLUSIVE_API_CALLBACKS)
|
||||||
dev_data->async_cb = NULL;
|
dev_data->async_cb = NULL;
|
||||||
dev_data->async_cb_data = NULL;
|
dev_data->async_cb_data = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_UART_ASYNC_API
|
#ifdef CONFIG_UART_SAM0_ASYNC
|
||||||
|
|
||||||
static int uart_sam0_callback_set(const struct device *dev,
|
static int uart_sam0_callback_set(const struct device *dev,
|
||||||
uart_callback_t callback,
|
uart_callback_t callback,
|
||||||
|
@ -1205,7 +1205,7 @@ static const struct uart_driver_api uart_sam0_driver_api = {
|
||||||
.irq_update = uart_sam0_irq_update,
|
.irq_update = uart_sam0_irq_update,
|
||||||
.irq_callback_set = uart_sam0_irq_callback_set,
|
.irq_callback_set = uart_sam0_irq_callback_set,
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_SAM0_ASYNC
|
||||||
.callback_set = uart_sam0_callback_set,
|
.callback_set = uart_sam0_callback_set,
|
||||||
.tx = uart_sam0_tx,
|
.tx = uart_sam0_tx,
|
||||||
.tx_abort = uart_sam0_tx_abort,
|
.tx_abort = uart_sam0_tx_abort,
|
||||||
|
@ -1215,7 +1215,7 @@ static const struct uart_driver_api uart_sam0_driver_api = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_SAM0_ASYNC
|
||||||
|
|
||||||
#define SAM0_UART_IRQ_CONNECT(n, m) \
|
#define SAM0_UART_IRQ_CONNECT(n, m) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -1253,7 +1253,7 @@ static void uart_sam0_irq_config_##n(const struct device *dev) \
|
||||||
#define UART_SAM0_IRQ_HANDLER(n)
|
#define UART_SAM0_IRQ_HANDLER(n)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_UART_ASYNC_API
|
#if CONFIG_UART_SAM0_ASYNC
|
||||||
#define UART_SAM0_DMA_CHANNELS(n) \
|
#define UART_SAM0_DMA_CHANNELS(n) \
|
||||||
.dma_dev = DEVICE_DT_GET(ATMEL_SAM0_DT_INST_DMA_CTLR(n, tx)), \
|
.dma_dev = DEVICE_DT_GET(ATMEL_SAM0_DT_INST_DMA_CTLR(n, tx)), \
|
||||||
.tx_dma_request = ATMEL_SAM0_DT_INST_DMA_TRIGSRC(n, tx), \
|
.tx_dma_request = ATMEL_SAM0_DT_INST_DMA_TRIGSRC(n, tx), \
|
||||||
|
|
|
@ -1,26 +1,8 @@
|
||||||
common:
|
common:
|
||||||
platform_exclude:
|
platform_exclude:
|
||||||
- seeeduino_xiao
|
|
||||||
- serpente
|
|
||||||
- arduino_nano_33_iot
|
|
||||||
- atsamr21_xpro
|
|
||||||
- adafruit_itsybitsy_m4_express
|
|
||||||
- atsame54_xpro
|
|
||||||
- atsamc21n_xpro
|
|
||||||
- adafruit_trinket_m0
|
|
||||||
- arduino_nano_33_iot
|
|
||||||
- arduino_zero
|
|
||||||
- atsamd21_xpro
|
|
||||||
- adafruit_feather_m0_basic_proto
|
|
||||||
- adafruit_feather_m0_lora
|
|
||||||
- arduino_mkrzero
|
|
||||||
- atsaml21_xpro
|
|
||||||
- atsamr34_xpro
|
|
||||||
- stamp_c3
|
- stamp_c3
|
||||||
- wio_terminal
|
- wio_terminal
|
||||||
- xiao_esp32c3
|
- xiao_esp32c3
|
||||||
- atsamd20_xpro
|
|
||||||
- ev11l78a
|
|
||||||
tags:
|
tags:
|
||||||
- drivers
|
- drivers
|
||||||
- uart
|
- uart
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue