Browse Source

[TEMP]jh7100: remove "depends on DM_ETH || !NET" in EFI_LOADER

This patch reverses some part of change in:
        commit eac6e0b7979440b889703196f383191c335e7599
        Author: Simon Glass <sjg@chromium.org>
        Date:   Fri Sep 24 18:30:17 2021 -0600
        efi_loader: Drop code that doesn't work with driver model
        ...
Since JH7100 ETH driver haven't supported DM yet.
Tekkaman Ninja 2 years ago
parent
commit
7b51fc59d4
2 changed files with 23 additions and 2 deletions
  1. 1 1
      lib/efi_loader/Kconfig
  2. 22 1
      lib/efi_loader/efi_device_path.c

+ 1 - 1
lib/efi_loader/Kconfig

@@ -11,7 +11,7 @@ config EFI_LOADER
 	# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
 	depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
 	depends on BLK
-	depends on DM_ETH || !NET
+	#depends on DM_ETH || !NET
 	depends on !EFI_APP
 	default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
 	select LIB_UUID

+ 22 - 1
lib/efi_loader/efi_device_path.c

@@ -587,7 +587,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
 		*vdp = ROOT;
 		return &vdp[1];
 	}
-#ifdef CONFIG_NET
+#ifdef CONFIG_DM_ETH
 	case UCLASS_ETH: {
 		struct efi_device_path_mac_addr *dp =
 			dp_fill(buf, dev->parent);
@@ -1018,18 +1018,39 @@ struct efi_device_path *efi_dp_from_uart(void)
 #ifdef CONFIG_NET
 struct efi_device_path *efi_dp_from_eth(void)
 {
+#ifndef CONFIG_DM_ETH
+	struct efi_device_path_mac_addr *ndp;
+#endif
 	void *buf, *start;
 	unsigned dpsize = 0;
 
 	assert(eth_get_dev());
 
+#ifdef CONFIG_DM_ETH
 	dpsize += dp_size(eth_get_dev());
+#else
+	dpsize += sizeof(ROOT);
+	dpsize += sizeof(*ndp);
+#endif
 
 	start = buf = dp_alloc(dpsize + sizeof(END));
 	if (!buf)
 		return NULL;
 
+#ifdef CONFIG_DM_ETH
 	buf = dp_fill(buf, eth_get_dev());
+#else
+	memcpy(buf, &ROOT, sizeof(ROOT));
+	buf += sizeof(ROOT);
+
+	ndp = buf;
+	ndp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
+	ndp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR;
+	ndp->dp.length = sizeof(*ndp);
+	ndp->if_type = 1; /* Ethernet */
+	memcpy(ndp->mac.addr, eth_get_ethaddr(), ARP_HLEN);
+	buf = &ndp[1];
+#endif
 
 	*((struct efi_device_path *)buf) = END;