This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit eb11fc06cc68a6270735d0d000faca3d77584738 Author: ouyangxiangzhen <[email protected]> AuthorDate: Thu Sep 3 16:44:17 2026 +0800 drivers/serial: always set MCR OUT2 in 16550 setup Some platforms, e.g. ACRN Hypervisor, do not generate the serial interrupt unless the OUT2 bit of MCR is set. Windows and Linux enable MCR OUT2 by default, so drop the 16550_SET_MCR_OUT2 option and set OUT2 unconditionally in u16550_setup(), merging the duplicated MCR read-modify-write into a single one. This also makes the x86_64 uart_putreg() workaround, which stuck OUT2 at 1 on every MCR write, redundant, so remove it to simplify the implementation. Signed-off-by: ouyangxiangzhen <[email protected]> --- arch/x86_64/src/intel64/intel64_serial.c | 9 --------- drivers/serial/Kconfig-16550 | 6 ------ drivers/serial/uart_16550.c | 18 ++++++------------ 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/arch/x86_64/src/intel64/intel64_serial.c b/arch/x86_64/src/intel64/intel64_serial.c index fe963abf376..d42cd989a65 100644 --- a/arch/x86_64/src/intel64/intel64_serial.c +++ b/arch/x86_64/src/intel64/intel64_serial.c @@ -63,15 +63,6 @@ uart_datawidth_t uart_getreg(struct u16550_s *priv, unsigned int offset) void uart_putreg(struct u16550_s *priv, unsigned int offset, uart_datawidth_t value) { - /* Intel x86 platform require OUT2 of MCR being set - * for interrupt to be triggered. We make sure that bit is stuck at 1. - */ - - if (offset == UART_MCR_OFFSET) - { - value |= UART_MCR_OUT2; - } - outb(value, priv->uartbase + offset); } diff --git a/drivers/serial/Kconfig-16550 b/drivers/serial/Kconfig-16550 index f7d78fda3be..375a486a89c 100644 --- a/drivers/serial/Kconfig-16550 +++ b/drivers/serial/Kconfig-16550 @@ -560,12 +560,6 @@ config 16550_WAIT_LCR will trigger spurious interrupts when setting the LCR without waiting. Default: n -config 16550_SET_MCR_OUT2 - bool "Set MCR OUT2 bit high" - default y - ---help--- - Some platforms require OUT2 of MCR being set for interrupt to be triggered - config 16550_DLF_SIZE int "DLF(Divisor Latch Fraction) size of DesignWare APB UART" default 0 diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c index e95c6cf6727..4dd8d69cd6e 100644 --- a/drivers/serial/uart_16550.c +++ b/drivers/serial/uart_16550.c @@ -795,10 +795,7 @@ static int u16550_setup(FAR struct uart_dev_s *dev) FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv; uint32_t div; uint32_t lcr; -#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL) || \ - defined(CONFIG_16550_SET_MCR_OUT2) uint32_t mcr; -#endif if (priv->uartbase == 0) { @@ -898,17 +895,14 @@ static int u16550_setup(FAR struct uart_dev_s *dev) UART_FCR_FIFOEN | (priv->rxtrigger << UART_FCR_RXTRIGGER_SHIFT)); -#ifdef CONFIG_16550_SET_MCR_OUT2 - /* Set OUT2 bit in MCR register */ - - mcr = u16550_serialin(priv, UART_MCR_OFFSET); - u16550_serialout(priv, UART_MCR_OFFSET, mcr | UART_MCR_OUT2); -#endif + /* Set up MCR: always set OUT2 so the UART can drive its interrupt + * output, following the default behavior of Windows and Linux, then + * set up the auto flow control. + */ - /* Set up the auto flow control */ + mcr = u16550_serialin(priv, UART_MCR_OFFSET) | UART_MCR_OUT2; #if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL) - mcr = u16550_serialin(priv, UART_MCR_OFFSET); if (priv->flow) { mcr |= UART_MCR_AFCE; @@ -919,9 +913,9 @@ static int u16550_setup(FAR struct uart_dev_s *dev) } mcr |= UART_MCR_RTS; +#endif /* defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL) */ u16550_serialout(priv, UART_MCR_OFFSET, mcr); -#endif /* defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL) */ /* Reconfigure DMA Rx timeout value */
