Generate an SD() or eMMC() node for MMC devices.

Signed-off-by: Heinrich Schuchardt <heinrich.schucha...@canonical.com>
---
 drivers/mmc/mmc-uclass.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 01d9b0201f..4f85d80273 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <bootdev.h>
+#include <efi_loader.h>
 #include <log.h>
 #include <mmc.h>
 #include <dm.h>
@@ -505,6 +506,27 @@ static int mmc_blk_probe(struct udevice *dev)
        return 0;
 }
 
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+struct efi_device_path *mmc_get_dp_node(struct udevice *dev)
+{
+       struct efi_device_path_sd_mmc_path *dp;
+       struct mmc *mmc = mmc_get_mmc_dev(dev);
+
+       dp = efi_alloc(sizeof(struct efi_device_path_sd_mmc_path));
+       if (!dp)
+               return NULL;
+
+       dp->dp.type     = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
+       dp->dp.sub_type = IS_SD(mmc) ?
+                         DEVICE_PATH_SUB_TYPE_MSG_SD :
+                         DEVICE_PATH_SUB_TYPE_MSG_MMC;
+       dp->dp.length   = sizeof(*dp);
+       dp->slot_number = dev_seq(dev);
+
+       return &dp->dp;
+}
+#endif
+
 #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
     CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
     CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
@@ -547,4 +569,7 @@ UCLASS_DRIVER(mmc) = {
        .name           = "mmc",
        .flags          = DM_UC_FLAG_SEQ_ALIAS,
        .per_device_auto        = sizeof(struct mmc_uclass_priv),
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+       .get_dp_node    = mmc_get_dp_node,
+#endif
 };
-- 
2.39.2

Reply via email to