2 * (C) Copyright 2000-2004
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Ilya Yanok <ilya.yanok@gmail.com>
8 * SPDX-License-Identifier: GPL-2.0+
14 #include <linux/libfdt.h>
16 #if defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USB_ETHER)
17 static ulong spl_net_load_read(struct spl_load_info *load, ulong sector,
18 ulong count, void *buf)
20 debug("%s: sector %lx, count %lx, buf %lx\n",
21 __func__, sector, count, (ulong)buf);
22 memcpy(buf, (void *)(load_addr + sector), count);
26 static int spl_net_load_image(struct spl_image_info *spl_image,
27 struct spl_boot_device *bootdev)
29 struct image_header *header = (struct image_header *)load_addr;
34 env_set("autoload", "yes");
35 rv = eth_initialize();
37 printf("No Ethernet devices found\n");
40 if (bootdev->boot_device_name)
41 env_set("ethact", bootdev->boot_device_name);
44 printf("Problem booting with BOOTP\n");
48 if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
49 image_get_magic(header) == FDT_MAGIC) {
50 struct spl_load_info load;
54 load.read = spl_net_load_read;
55 rv = spl_load_simple_fit(spl_image, &load, 0, header);
57 debug("Legacy image\n");
59 rv = spl_parse_image_header(spl_image, header);
63 memcpy((void *)spl_image->load_addr, header, spl_image->size);
70 #ifdef CONFIG_SPL_ETH_SUPPORT
71 int spl_net_load_image_cpgmac(struct spl_image_info *spl_image,
72 struct spl_boot_device *bootdev)
74 #ifdef CONFIG_SPL_ETH_DEVICE
75 bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE;
78 return spl_net_load_image(spl_image, bootdev);
80 SPL_LOAD_IMAGE_METHOD("eth device", 0, BOOT_DEVICE_CPGMAC,
81 spl_net_load_image_cpgmac);
84 #ifdef CONFIG_SPL_USB_ETHER
85 int spl_net_load_image_usb(struct spl_image_info *spl_image,
86 struct spl_boot_device *bootdev)
88 bootdev->boot_device_name = "usb_ether";
90 return spl_net_load_image(spl_image, bootdev);
92 SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);