Merge tag 'v2022.04-rc5' into next
[platform/kernel/u-boot.git] / common / spl / spl_net.c
index b6967ff..a853e6a 100644 (file)
@@ -7,25 +7,28 @@
  * Ilya Yanok <ilya.yanok@gmail.com>
  */
 #include <common.h>
+#include <env.h>
 #include <errno.h>
+#include <image.h>
+#include <log.h>
 #include <spl.h>
 #include <net.h>
 #include <linux/libfdt.h>
 
-#if defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USB_ETHER)
+#if defined(CONFIG_SPL_ETH) || defined(CONFIG_SPL_USB_ETHER)
 static ulong spl_net_load_read(struct spl_load_info *load, ulong sector,
                               ulong count, void *buf)
 {
        debug("%s: sector %lx, count %lx, buf %lx\n",
              __func__, sector, count, (ulong)buf);
-       memcpy(buf, (void *)(load_addr + sector), count);
+       memcpy(buf, (void *)(image_load_addr + sector), count);
        return count;
 }
 
 static int spl_net_load_image(struct spl_image_info *spl_image,
                              struct spl_boot_device *bootdev)
 {
-       struct image_header *header = (struct image_header *)load_addr;
+       struct image_header *header = (struct image_header *)image_load_addr;
        int rv;
 
        env_init();
@@ -55,7 +58,7 @@ static int spl_net_load_image(struct spl_image_info *spl_image,
        } else {
                debug("Legacy image\n");
 
-               rv = spl_parse_image_header(spl_image, header);
+               rv = spl_parse_image_header(spl_image, bootdev, header);
                if (rv)
                        return rv;
 
@@ -66,7 +69,7 @@ static int spl_net_load_image(struct spl_image_info *spl_image,
 }
 #endif
 
-#ifdef CONFIG_SPL_ETH_SUPPORT
+#ifdef CONFIG_SPL_ETH
 int spl_net_load_image_cpgmac(struct spl_image_info *spl_image,
                              struct spl_boot_device *bootdev)
 {
@@ -85,7 +88,9 @@ int spl_net_load_image_usb(struct spl_image_info *spl_image,
                           struct spl_boot_device *bootdev)
 {
        bootdev->boot_device_name = "usb_ether";
-
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
+       usb_ether_init();
+#endif
        return spl_net_load_image(spl_image, bootdev);
 }
 SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);