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
The following commit(s) were added to refs/heads/master by this push:
new 53d757f0815 serial/pci: support wildcard UART selection
53d757f0815 is described below
commit 53d757f08155bd06b8fe045a64878ad947eaba53
Author: raiden00pl <[email protected]>
AuthorDate: Thu Aug 20 18:16:57 2026 +0200
serial/pci: support wildcard UART selection
Treat PCI_ANY_ID in a configured UART slot as a wildcard while
still limiting probes to devices supported by the PCI 16550 driver.
This lets one console configuration select QEMU PCI serial or
the real PCI card at runtime.
Signed-off-by: raiden00pl <[email protected]>
Assisted-by: OpenAI Codex:gpt-5
---
drivers/serial/Kconfig-pci | 24 ++++++++++++++++--------
drivers/serial/uart_pci_16550.c | 9 +++++++--
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/drivers/serial/Kconfig-pci b/drivers/serial/Kconfig-pci
index ed4cf5d9190..3c5d7bb4780 100644
--- a/drivers/serial/Kconfig-pci
+++ b/drivers/serial/Kconfig-pci
@@ -41,12 +41,14 @@ if 16550_PCI_UART0
config 16550_PCI_UART0_VENDOR
hex "16550 UART0 PCI vendor"
---help---
- PCI vendor number that will be associated with UART0
+ PCI vendor number that will be associated with UART0. Set this
+ to 0xffff to match any device supported by the PCI 16550 driver.
config 16550_PCI_UART0_DEVICE
hex "16550 UART0 PCI device"
---help---
- PCI device number that will be associated with UART0
+ PCI device number that will be associated with UART0. Set this
+ to 0xffff to match any device supported by the PCI 16550 driver.
config 16550_PCI_UART0_PORT
int "16550 UART0 PCI port"
@@ -101,13 +103,15 @@ config 16550_PCI_UART1_VENDOR
hex "16550 UART1 PCI vendor"
default 16550_PCI_UART0_VENDOR
---help---
- PCI vendor number that will be associated with UART1
+ PCI vendor number that will be associated with UART1. Set this
+ to 0xffff to match any device supported by the PCI 16550 driver.
config 16550_PCI_UART1_DEVICE
hex "16550 UART1 PCI device"
default 16550_PCI_UART0_DEVICE
---help---
- PCI device number that will be associated with UART1
+ PCI device number that will be associated with UART1. Set this
+ to 0xffff to match any device supported by the PCI 16550 driver.
config 16550_PCI_UART1_PORT
int "16550 UART1 PCI port"
@@ -163,13 +167,15 @@ config 16550_PCI_UART2_VENDOR
hex "16550 UART2 PCI vendor"
default 16550_PCI_UART1_VENDOR
---help---
- PCI vendor number that will be associated with UART2
+ PCI vendor number that will be associated with UART2. Set this
+ to 0xffff to match any device supported by the PCI 16550 driver.
config 16550_PCI_UART2_DEVICE
hex "16550 UART2 PCI device"
default 16550_PCI_UART1_DEVICE
---help---
- PCI device number that will be associated with UART2
+ PCI device number that will be associated with UART2. Set this
+ to 0xffff to match any device supported by the PCI 16550 driver.
config 16550_PCI_UART2_PORT
int "16550 UART2 PCI port"
@@ -225,13 +231,15 @@ config 16550_PCI_UART3_VENDOR
hex "16550 UART3 PCI vendor"
default 16550_PCI_UART2_VENDOR
---help---
- PCI vendor number that will be associated with UART3
+ PCI vendor number that will be associated with UART3. Set this
+ to 0xffff to match any device supported by the PCI 16550 driver.
config 16550_PCI_UART3_DEVICE
hex "16550 UART3 PCI device"
default 16550_PCI_UART2_DEVICE
---help---
- PCI device number that will be associated with UART3
+ PCI device number that will be associated with UART3. Set this
+ to 0xffff to match any device supported by the PCI 16550 driver.
config 16550_PCI_UART3_PORT
int "16550 UART3 PCI port"
diff --git a/drivers/serial/uart_pci_16550.c b/drivers/serial/uart_pci_16550.c
index 52b6e44d28c..7df9a272290 100644
--- a/drivers/serial/uart_pci_16550.c
+++ b/drivers/serial/uart_pci_16550.c
@@ -716,12 +716,17 @@ static int pci_u16550_probe(FAR struct pci_device_s *dev)
udev = g_pci_u16550_dev[i];
priv = (FAR struct pci_u16550_priv_s *)udev->priv;
- if (priv->vendor == dev->vendor &&
- priv->device == dev->device &&
+ if ((priv->vendor == PCI_ANY_ID ||
+ priv->vendor == dev->vendor) &&
+ (priv->device == PCI_ANY_ID ||
+ priv->device == dev->device) &&
priv->port == port)
{
break;
}
+
+ udev = NULL;
+ priv = NULL;
}
/* Not found */