This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit a179b3a960518d13111be838845086e94295e5fb Author: Brijesh Thakkar <[email protected]> AuthorDate: Tue Oct 20 18:09:06 2026 +0530 drivers/serial/uart_16550: Always build the default ops g_u16550_ops was static and only built when one of the CONFIG_16550_UARTn ports was enabled, so a board that registers its own ports (or uses only the PCI driver) could not reuse the default getreg/putreg/isr. Build it unconditionally, export it as g_u16550_ops and declare it in uart_16550.h. The static ports still use it exactly as before. Assisted-by: Claude:claude-sonnet-5-5 Signed-off-by: Brijesh Thakkar <[email protected]> --- drivers/serial/uart_16550.c | 30 ++++++++++++++---------------- include/nuttx/serial/uart_16550.h | 8 ++++++++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c index 96f7019bd6c..a6a4a61832c 100644 --- a/drivers/serial/uart_16550.c +++ b/drivers/serial/uart_16550.c @@ -53,14 +53,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* Are any UARTs enabled? */ - -#undef HAVE_16550_UART -#if defined(CONFIG_16550_UART0) || defined(CONFIG_16550_UART1) \ - || defined(CONFIG_16550_UART2) || defined(CONFIG_16550_UART3) -# define HAVE_16550_UART 1 -#endif - /* Timeout for UART Busy Wait, in milliseconds */ #define UART_TIMEOUT_MS 100 @@ -115,23 +107,29 @@ static bool u16550_txready(FAR struct uart_dev_s *dev); static bool u16550_txempty(FAR struct uart_dev_s *dev); /**************************************************************************** - * Private Data + * Public Data ****************************************************************************/ -#ifdef HAVE_16550_UART -static const struct u16550_ops_s g_u16550_ops = +/* Default UART 16550 ops. These are built even when no static UART is + * enabled so that a board which defines its own ports can reuse them. + */ + +const struct u16550_ops_s g_u16550_ops = { .isr = u16550_interrupt, .getreg = u16550_getreg, .putreg = u16550_putreg, -# ifdef CONFIG_SERIAL_UART_ARCH_IOCTL +#ifdef CONFIG_SERIAL_UART_ARCH_IOCTL .ioctl = uart_ioctl, -# endif -# ifdef HAVE_16550_UART_DMA +#endif +#ifdef HAVE_16550_UART_DMA .dmachan = uart_dmachan, -# endif -}; #endif +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ static const struct uart_ops_s g_uart_ops = { diff --git a/include/nuttx/serial/uart_16550.h b/include/nuttx/serial/uart_16550.h index 7c4af0ce246..f88d0c75102 100644 --- a/include/nuttx/serial/uart_16550.h +++ b/include/nuttx/serial/uart_16550.h @@ -380,6 +380,14 @@ struct u16550_s spinlock_t lock; /* Spinlock */ }; +/* Default UART 16550 ops: getreg/putreg access the registers either through + * the memory mapping (CONFIG_SERIAL_UART_ARCH_MMIO) or through the + * uart_getreg()/uart_putreg() provided by the arch. A board that registers + * its own ports can point struct u16550_s::ops at this table. + */ + +extern const struct u16550_ops_s g_u16550_ops; + /**************************************************************************** * Public Functions Definitions ****************************************************************************/
