Generate a Usb() node for USB hub devices.

Signed-off-by: Heinrich Schuchardt <heinrich.schucha...@canonical.com>
---
 common/usb_hub.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
diff --git a/common/usb_hub.c b/common/usb_hub.c
index 85c0822d8b..ccf9e16023 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <command.h>
 #include <dm.h>
+#include <efi_loader.h>
 #include <env.h>
 #include <errno.h>
 #include <log.h>
@@ -939,6 +940,35 @@ static int usb_hub_post_probe(struct udevice *dev)
        return usb_hub_scan(dev);
 }
 
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+struct efi_device_path *usb_hub_get_dp_node(struct udevice *dev)
+{
+       struct efi_device_path_usb *dp;
+
+       dp = efi_alloc(sizeof(struct efi_device_path_usb));
+       if (!dp)
+               return NULL;
+
+       switch (device_get_uclass_id(dev->parent)) {
+       case UCLASS_USB_HUB: {
+               struct usb_device *udev = dev_get_parent_priv(dev);
+
+               dp->parent_port_number = udev->portnr;
+               break;
+       }
+       default:
+               dp->parent_port_number = 0;
+       }
+
+       dp->dp.type       = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
+       dp->dp.sub_type   = DEVICE_PATH_SUB_TYPE_MSG_USB;
+       dp->dp.length     = sizeof(*dp);
+       dp->usb_interface = 0;
+
+       return &dp->dp;
+}
+#endif
+
 static const struct udevice_id usb_hub_ids[] = {
        { .compatible = "usb-hub" },
        { }
@@ -960,6 +990,9 @@ UCLASS_DRIVER(usb_hub) = {
        .per_child_auto = sizeof(struct usb_device),
        .per_child_plat_auto    = sizeof(struct usb_dev_plat),
        .per_device_auto        = sizeof(struct usb_hub_device),
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+       .get_dp_node    = usb_hub_get_dp_node,
+#endif
 };
 
 static const struct usb_device_id hub_id_table[] = {
-- 
2.39.2

Reply via email to