From c7e8fd43a4677150087daed5c94f6c8d2b7b7eb3 Mon Sep 17 00:00:00 2001 From: p-szafonimateusz Date: Mon, 18 Mar 2024 17:52:50 +0100 Subject: [PATCH] drivers/uart_16550: configure MCR_OUT2 bit from Kconfig move MCR_OUT2 configuration from qemu-intel64/src/qemu_boot.c to common code also leave this option disabled for qemu-intel64 as it's not required Signed-off-by: p-szafonimateusz --- boards/x86_64/intel64/qemu-intel64/src/qemu_boot.c | 8 -------- drivers/serial/Kconfig-16550 | 6 ++++++ drivers/serial/uart_16550.c | 10 +++++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/boards/x86_64/intel64/qemu-intel64/src/qemu_boot.c b/boards/x86_64/intel64/qemu-intel64/src/qemu_boot.c index 32cdcb33ec..2ec202247c 100644 --- a/boards/x86_64/intel64/qemu-intel64/src/qemu_boot.c +++ b/boards/x86_64/intel64/qemu-intel64/src/qemu_boot.c @@ -58,14 +58,6 @@ void x86_64_boardinitialize(void) { -#if defined(CONFIG_16550_UART0) && (CONFIG_16550_UART0_BASE == 0x3f8) - uart_putreg(CONFIG_16550_UART0_BASE, UART_MCR_OFFSET, UART_MCR_OUT2); -#endif - -#if defined(CONFIG_16550_UART1) && (CONFIG_16550_UART1_BASE == 0x3f8) - uart_putreg(CONFIG_16550_UART1_BASE, UART_MCR_OFFSET, UART_MCR_OUT2); -#endif - /* Configure on-board LEDs if LED support has been selected. */ #ifdef CONFIG_ARCH_LEDS diff --git a/drivers/serial/Kconfig-16550 b/drivers/serial/Kconfig-16550 index a5510beb2c..aeb19cd6c5 100644 --- a/drivers/serial/Kconfig-16550 +++ b/drivers/serial/Kconfig-16550 @@ -548,4 +548,10 @@ 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 n + ---help--- + Some platforms require OUT2 of MCR being set for interrupt to be triggered + endif # 16550_UART diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c index 89822e06eb..b0d1c2223c 100644 --- a/drivers/serial/uart_16550.c +++ b/drivers/serial/uart_16550.c @@ -754,7 +754,8 @@ static int u16550_setup(FAR struct uart_dev_s *dev) FAR struct u16550_s *priv = (FAR struct u16550_s *)dev->priv; uint16_t div; uint32_t lcr; -#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL) +#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL) || \ + defined(CONFIG_16550_SET_MCR_OUT2) uint32_t mcr; #endif @@ -845,6 +846,13 @@ static int u16550_setup(FAR struct uart_dev_s *dev) UART_FCR_TXRST | UART_FCR_RXRST | UART_FCR_FIFOEN)); +#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 the auto flow control */ #if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)