Skip to content

Commit 1757607

Browse files
committed
drivers: serial: add support for uart_line_ctrl_set()
- For MCUX LPUART driver, added support to control RTS line High/Low from other driver/app code. - This control is required to wakeup other device which is in sleep and configured its wakeup-source as UART-CTS line. Signed-off-by: Nirav Agrawal <[email protected]>
1 parent c0f76d9 commit 1757607

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

drivers/serial/uart_mcux_lpuart.c

+39-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017,2021,2023-2024 NXP
2+
* Copyright 2017,2021,2023-2025 NXP
33
* Copyright (c) 2020 Softube
44
*
55
* SPDX-License-Identifier: Apache-2.0
@@ -1179,6 +1179,40 @@ static int mcux_lpuart_configure(const struct device *dev,
11791179
}
11801180
#endif /* CONFIG_UART_USE_RUNTIME_CONFIGURE */
11811181

1182+
#if CONFIG_UART_LINE_CTRL && \
1183+
defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
1184+
static int mcux_lpuart_line_ctrl_set(const struct device *dev,
1185+
uint32_t ctrl, uint32_t val)
1186+
{
1187+
const struct mcux_lpuart_config *config = dev->config;
1188+
int ret = 0;
1189+
1190+
switch (ctrl) {
1191+
case UART_LINE_CTRL_RTS:
1192+
/* Disable Transmitter and Receiver */
1193+
config->base->CTRL &= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);
1194+
1195+
if (val >= 1U) {
1196+
/* Reset TXRTS to set RXRTSE bit, this provides high-level on RTS line */
1197+
config->base->MODIR &= ~(LPUART_MODIR_TXRTSPOL_MASK |
1198+
LPUART_MODIR_TXRTSE_MASK);
1199+
config->base->MODIR |= LPUART_MODIR_RXRTSE_MASK;
1200+
} else {
1201+
/* Set TXRTSE to reset RXRTSE bit,this provide low-level on RTS line*/
1202+
config->base->MODIR &= ~(LPUART_MODIR_RXRTSE_MASK);
1203+
config->base->MODIR |= (LPUART_MODIR_TXRTSPOL_MASK |
1204+
LPUART_MODIR_TXRTSE_MASK);
1205+
}
1206+
break;
1207+
1208+
default:
1209+
ret = -ENODEV;
1210+
}
1211+
1212+
return ret;
1213+
}
1214+
#endif /* CONFIG_UART_LINE_CTRL */
1215+
11821216
static int mcux_lpuart_init(const struct device *dev)
11831217
{
11841218
const struct mcux_lpuart_config *config = dev->config;
@@ -1257,6 +1291,10 @@ static DEVICE_API(uart, mcux_lpuart_driver_api) = {
12571291
.rx_buf_rsp = mcux_lpuart_rx_buf_rsp,
12581292
.rx_disable = mcux_lpuart_rx_disable,
12591293
#endif /* CONFIG_UART_ASYNC_API */
1294+
#if CONFIG_UART_LINE_CTRL && \
1295+
defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
1296+
.line_ctrl_set = mcux_lpuart_line_ctrl_set,
1297+
#endif /* CONFIG_UART_LINE_CTRL */
12601298
};
12611299

12621300

0 commit comments

Comments
 (0)