From 857b8508d05e169747440cc6dfbcf8f0d9dfae47 Mon Sep 17 00:00:00 2001 From: Mark Wang Date: Mon, 24 May 2021 12:49:53 +0800 Subject: [PATCH] drivers: serial: NXP: Enable flow control for uart_mcux_lpuart add flow_ctrl filed and give it initialized value based on hw_flow_control. Initialize mcux lpuart based on flow_ctrl Signed-off-by: Mark Wang --- drivers/serial/uart_mcux_lpuart.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/serial/uart_mcux_lpuart.c b/drivers/serial/uart_mcux_lpuart.c index f9836d0b3d4..55018c4cd8c 100644 --- a/drivers/serial/uart_mcux_lpuart.c +++ b/drivers/serial/uart_mcux_lpuart.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, NXP + * Copyright (c) 2017,2021 NXP * Copyright (c) 2020 Softube * * SPDX-License-Identifier: Apache-2.0 @@ -19,6 +19,7 @@ struct mcux_lpuart_config { const struct device *clock_dev; clock_control_subsys_t clock_subsys; uint32_t baud_rate; + uint8_t flow_ctrl; #ifdef CONFIG_UART_INTERRUPT_DRIVEN void (*irq_config_func)(const struct device *dev); #endif @@ -357,7 +358,7 @@ static int mcux_lpuart_init(const struct device *dev) uart_api_config->parity = UART_CFG_PARITY_NONE; uart_api_config->stop_bits = UART_CFG_STOP_BITS_1; uart_api_config->data_bits = UART_CFG_DATA_BITS_8; - uart_api_config->flow_ctrl = UART_CFG_FLOW_CTRL_NONE; + uart_api_config->flow_ctrl = config->flow_ctrl; /* set initial configuration */ mcux_lpuart_configure_init(dev, uart_api_config); @@ -430,6 +431,8 @@ static const struct mcux_lpuart_config mcux_lpuart_##n##_config = { \ .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ .clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\ .baud_rate = DT_INST_PROP(n, current_speed), \ + .flow_ctrl = DT_INST_PROP(n, hw_flow_control) ? \ + UART_CFG_FLOW_CTRL_RTS_CTS : UART_CFG_FLOW_CTRL_NONE,\ IRQ_FUNC_INIT \ }