[U-Boot] [PATCH 4/5] x86: Support PCI UART in the x86_serial driver

Bin Meng bmeng.cn at gmail.com
Fri Dec 19 08:19:27 CET 2014


Newer x86 Platform Controller Hub chipset starts to integrate NS16550
compatible PCI UART devices. The board configuration file needs to
supply the PCI UART vendor ID and device ID via CONFIG_PCI_UART_DEV
if we want to use the PCI UART as the U-Boot serial console.

Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
---

 drivers/serial/serial_x86.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/serial/serial_x86.c b/drivers/serial/serial_x86.c
index e81e035..7ddd596 100644
--- a/drivers/serial/serial_x86.c
+++ b/drivers/serial/serial_x86.c
@@ -8,6 +8,17 @@
 #include <dm.h>
 #include <ns16550.h>
 #include <serial.h>
+#include <asm/pci.h>
+#include <errno.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_PCI_UART
+static struct pci_device_id uart_supported[] = {
+	CONFIG_PCI_UART_DEV,
+	{ }
+};
+#endif
 
 static const struct udevice_id x86_serial_ids[] = {
 	{ .compatible = "x86-uart" },
@@ -17,6 +28,9 @@ static const struct udevice_id x86_serial_ids[] = {
 static int x86_serial_ofdata_to_platdata(struct udevice *dev)
 {
 	struct ns16550_platdata *plat = dev_get_platdata(dev);
+#ifdef CONFIG_PCI_UART
+	pci_dev_t devbusfn;
+#endif
 	int ret;
 
 	ret = ns16550_serial_ofdata_to_platdata(dev);
@@ -24,6 +38,22 @@ static int x86_serial_ofdata_to_platdata(struct udevice *dev)
 		return ret;
 	plat->clock = 1843200;
 
+#ifdef CONFIG_PCI_UART
+	/*
+	 * Newer x86 Platform Controller Hub chipset starts to integrate
+	 * NS16550 compatible PCI UART devices. The board configuration
+	 * file needs to supply the PCI UART vendor ID and device ID via
+	 * CONFIG_PCI_UART_DEV if we want to use the PCI UART as the U-Boot
+	 * serial console.
+	 */
+	devbusfn = pci_early_find_devices(uart_supported, 0);
+	if (devbusfn == -1)
+		return -ENODEV;
+
+	/* override the register base here for PCI UART */
+	plat->base = pci_read_bar32(gd->arch.hose, devbusfn, 0);
+#endif
+
 	return 0;
 }
 U_BOOT_DRIVER(serial_ns16550) = {
-- 
1.8.2.1



More information about the U-Boot mailing list