From bae9f85ddbd2e62af1b47169cbfeb10b06d45e04 Mon Sep 17 00:00:00 2001
From: Duncan Laurie <dlaurie@google.com>
Date: Mon, 7 May 2018 14:18:13 -0700
Subject: devicetree: Add USB device type

This commit adds support for describing USB ports in devicetree.cb.
It allows a USB port location to be described in the tree with
configuration information, and ACPI code to be generated that
provides this information to the OS.

A new scan_usb_bus() is added that will scan bridges for devices so
a tree of ports and hubs can be created.

The device address is computed with a 'port type' and a 'port id'
which is flexible for SOC to handle depending on their specific USB
setup and allows USB2 and USB3 ports to be described separately.

For example a board may have devices on two ports, one with a USB2
device and one with a USB3 device, both of which are connected to an
xHCI controller with a root hub:

     xHCI
       |
    RootHub
    |     |
USB2[0]  USB3[2]

device pci 14.0 on
  chip drivers/usb/acpi
    register "name" = ""Root Hub""
    device usb 0.0 on
      chip drivers/usb/acpi
        register "name" = ""USB 2.0 Port 0""
        device usb 2.0 on end
      end
      chip drivers/usb/acpi
        register "name" = ""USB 3.0 Port 2""
        device usb 3.2 on end
      end
    end
  end
end

Change-Id: I64e6eba503cdab49be393465b535e139a8c90ef4
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://review.coreboot.org/26169
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
---
 src/include/device/device.h | 2 ++
 src/include/device/path.h   | 8 ++++++++
 2 files changed, 10 insertions(+)

(limited to 'src/include')

diff --git a/src/include/device/device.h b/src/include/device/device.h
index 744836d9ed..f3afd60b2c 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -27,6 +27,7 @@ struct i2c_bus_operations;
 struct smbus_bus_operations;
 struct pnp_mode_ops;
 struct spi_bus_operations;
+struct usb_bus_operations;
 
 /* Chip operations */
 struct chip_operations {
@@ -276,6 +277,7 @@ void scan_smbus(struct device *bus);
 void scan_generic_bus(struct device *bus);
 void scan_static_bus(struct device *bus);
 void scan_lpc_bus(struct device *bus);
+void scan_usb_bus(struct device *bus);
 
 #endif /* !defined(__ROMCC__) */
 
diff --git a/src/include/device/path.h b/src/include/device/path.h
index eaa9cc7d67..067a507166 100644
--- a/src/include/device/path.h
+++ b/src/include/device/path.h
@@ -15,6 +15,7 @@ enum device_path_type {
 	DEVICE_PATH_IOAPIC,
 	DEVICE_PATH_GENERIC,
 	DEVICE_PATH_SPI,
+	DEVICE_PATH_USB,
 	DEVICE_PATH_MMIO,
 
 	/*
@@ -37,6 +38,7 @@ enum device_path_type {
 		"DEVICE_PATH_IOAPIC",		\
 		"DEVICE_PATH_GENERIC",		\
 		"DEVICE_PATH_SPI",		\
+		"DEVICE_PATH_USB",		\
 		"DEVICE_PATH_MMIO",		\
 }
 
@@ -91,6 +93,11 @@ struct generic_path {
 	unsigned int subid;
 };
 
+struct usb_path {
+	unsigned int port_type;
+	unsigned int port_id;
+};
+
 struct mmio_path {
 	uintptr_t addr;
 };
@@ -109,6 +116,7 @@ struct device_path {
 		struct cpu_bus_path	cpu_bus;
 		struct generic_path	generic;
 		struct spi_path		spi;
+		struct usb_path		usb;
 		struct mmio_path	mmio;
 	};
 };
-- 
cgit v1.2.3