[RFC 5/7] dm: implement get_dp_node for USB mass storage devices
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Sun Mar 26 19:27:41 CEST 2023
Generate a Usb() node for USB mass storage devices.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
common/usb_storage.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/common/usb_storage.c b/common/usb_storage.c
index ac64275773..03bc136156 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -37,6 +37,7 @@
#include <bootdev.h>
#include <command.h>
#include <dm.h>
+#include <efi_loader.h>
#include <errno.h>
#include <log.h>
#include <mapmem.h>
@@ -1534,6 +1535,35 @@ static int usb_mass_storage_probe(struct udevice *dev)
return ret;
}
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+struct efi_device_path *usb_storage_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_mass_storage_ids[] = {
{ .compatible = "usb-mass-storage" },
{ }
@@ -1552,6 +1582,9 @@ U_BOOT_DRIVER(usb_mass_storage) = {
UCLASS_DRIVER(usb_mass_storage) = {
.id = UCLASS_MASS_STORAGE,
.name = "usb_mass_storage",
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+ .get_dp_node = usb_storage_get_dp_node,
+#endif
};
static const struct usb_device_id mass_storage_id_table[] = {
--
2.39.2
More information about the U-Boot
mailing list