summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@google.com>2018-05-07 14:18:13 -0700
committerPatrick Georgi <pgeorgi@google.com>2018-05-11 08:59:51 +0000
commitbae9f85ddbd2e62af1b47169cbfeb10b06d45e04 (patch)
tree7d02393aa9a757ffaaf33fd4ffc841ddc239e4a7 /src/device
parent57df0888169a2622e37dfad3694e3de544b8b6fb (diff)
downloadcoreboot-bae9f85ddbd2e62af1b47169cbfeb10b06d45e04.tar.xz
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>
Diffstat (limited to 'src/device')
-rw-r--r--src/device/device_util.c11
-rw-r--r--src/device/root_device.c15
2 files changed, 26 insertions, 0 deletions
diff --git a/src/device/device_util.c b/src/device/device_util.c
index a64b63ae23..aad3b4ba26 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -256,6 +256,9 @@ u32 dev_path_encode(const struct device *dev)
case DEVICE_PATH_SPI:
ret |= dev->path.spi.cs;
break;
+ case DEVICE_PATH_USB:
+ ret |= dev->path.usb.port_type << 8 || dev->path.usb.port_id;
+ break;
case DEVICE_PATH_NONE:
case DEVICE_PATH_MMIO: /* don't care */
default:
@@ -333,6 +336,10 @@ const char *dev_path(const struct device *dev)
snprintf(buffer, sizeof (buffer), "SPI: %02x",
dev->path.spi.cs);
break;
+ case DEVICE_PATH_USB:
+ snprintf(buffer, sizeof (buffer), "USB%u port %u",
+ dev->path.usb.port_type, dev->path.usb.port_id);
+ break;
case DEVICE_PATH_MMIO:
snprintf(buffer, sizeof (buffer), "MMIO: %08x",
dev->path.mmio.addr);
@@ -411,6 +418,10 @@ int path_eq(struct device_path *path1, struct device_path *path2)
case DEVICE_PATH_SPI:
equal = (path1->spi.cs == path2->spi.cs);
break;
+ case DEVICE_PATH_USB:
+ equal = (path1->usb.port_type == path2->usb.port_type) &&
+ (path1->usb.port_id == path2->usb.port_id);
+ break;
case DEVICE_PATH_MMIO:
equal = (path1->mmio.addr == path2->mmio.addr);
break;
diff --git a/src/device/root_device.c b/src/device/root_device.c
index a19028d43d..b0b6712ebb 100644
--- a/src/device/root_device.c
+++ b/src/device/root_device.c
@@ -72,6 +72,21 @@ void scan_lpc_bus(struct device *bus)
printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus));
}
+void scan_usb_bus(struct device *bus)
+{
+ struct bus *link;
+
+ printk(BIOS_SPEW, "%s for %s\n", __func__, dev_path(bus));
+
+ scan_static_bus(bus);
+
+ /* Scan bridges in case this device is a hub */
+ for (link = bus->link_list; link; link = link->next)
+ scan_bridges(link);
+
+ printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus));
+}
+
void scan_generic_bus(struct device *bus)
{
struct device *child;