serial: introduce CONFIG_UART_USE_RUNTIME_CONFIGURE

This kconfig option enables runtime configuration of UART
controllers. This allows application to call uart_configure()
to configure the UART controllers and calling uart_config_get()
to retrieve configuration. If this is disabled, UART controllers
rely on UART driver's initialization function to properly
configure the controller. The main use of this option is mainly
code size reduction.

Fixes #16231

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2021-05-26 12:33:37 -07:00 committed by Carles Cufí
commit 4e1692f85a
15 changed files with 77 additions and 1 deletions

View file

@ -319,6 +319,7 @@ static int mcux_lpuart_configure_init(const struct device *dev,
return 0;
}
#ifdef CONFIG_UART_USE_RUNTIME_CONFIGURE
static int mcux_lpuart_config_get(const struct device *dev, struct uart_config *cfg)
{
struct mcux_lpuart_data *data = dev->data;
@ -344,6 +345,7 @@ static int mcux_lpuart_configure(const struct device *dev,
return 0;
}
#endif /* CONFIG_UART_USE_RUNTIME_CONFIGURE */
static int mcux_lpuart_init(const struct device *dev)
{
@ -371,8 +373,10 @@ static const struct uart_driver_api mcux_lpuart_driver_api = {
.poll_in = mcux_lpuart_poll_in,
.poll_out = mcux_lpuart_poll_out,
.err_check = mcux_lpuart_err_check,
#ifdef CONFIG_UART_USE_RUNTIME_CONFIGURE
.configure = mcux_lpuart_configure,
.config_get = mcux_lpuart_config_get,
#endif
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
.fifo_fill = mcux_lpuart_fifo_fill,
.fifo_read = mcux_lpuart_fifo_read,