]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
7ac2fe2d IY |
2 | /* |
3 | * (C) Copyright 2000-2004 | |
4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
5 | * | |
6 | * (C) Copyright 2012 | |
7 | * Ilya Yanok <ilya.yanok@gmail.com> | |
7ac2fe2d | 8 | */ |
d678a59d | 9 | #include <common.h> |
4bfd1f5d | 10 | #include <env.h> |
36afd451 | 11 | #include <errno.h> |
4d72caa5 | 12 | #include <image.h> |
f7ae49fc | 13 | #include <log.h> |
7ac2fe2d | 14 | #include <spl.h> |
2e5476b5 | 15 | #include <spl_load.h> |
7ac2fe2d | 16 | #include <net.h> |
b08c8c48 | 17 | #include <linux/libfdt.h> |
7ac2fe2d | 18 | |
f2d7a36e | 19 | #if defined(CONFIG_SPL_ETH) || defined(CONFIG_SPL_USB_ETHER) |
6dca5e8a AD |
20 | static ulong spl_net_load_read(struct spl_load_info *load, ulong sector, |
21 | ulong count, void *buf) | |
22 | { | |
23 | debug("%s: sector %lx, count %lx, buf %lx\n", | |
24 | __func__, sector, count, (ulong)buf); | |
b02c4e94 | 25 | memcpy(buf, map_sysmem(image_load_addr + sector, count), count); |
6dca5e8a AD |
26 | return count; |
27 | } | |
28 | ||
2a2ee2ac SG |
29 | static int spl_net_load_image(struct spl_image_info *spl_image, |
30 | struct spl_boot_device *bootdev) | |
7ac2fe2d | 31 | { |
2e5476b5 | 32 | struct spl_load_info load; |
7ac2fe2d IY |
33 | int rv; |
34 | ||
35 | env_init(); | |
36 | env_relocate(); | |
382bee57 | 37 | env_set("autoload", "yes"); |
d2eaec60 | 38 | rv = eth_initialize(); |
7ac2fe2d IY |
39 | if (rv == 0) { |
40 | printf("No Ethernet devices found\n"); | |
36afd451 | 41 | return -ENODEV; |
7ac2fe2d | 42 | } |
ecdfd69a | 43 | if (bootdev->boot_device_name) |
382bee57 | 44 | env_set("ethact", bootdev->boot_device_name); |
bc0571fc | 45 | rv = net_loop(BOOTP); |
7ac2fe2d IY |
46 | if (rv < 0) { |
47 | printf("Problem booting with BOOTP\n"); | |
36afd451 | 48 | return rv; |
7ac2fe2d | 49 | } |
6dca5e8a | 50 | |
2e5476b5 SA |
51 | spl_set_bl_len(&load, 1); |
52 | load.read = spl_net_load_read; | |
53 | return spl_load(spl_image, bootdev, &load, 0, 0); | |
7ac2fe2d | 54 | } |
7ec03893 SG |
55 | #endif |
56 | ||
f2d7a36e | 57 | #ifdef CONFIG_SPL_ETH |
2a2ee2ac SG |
58 | int spl_net_load_image_cpgmac(struct spl_image_info *spl_image, |
59 | struct spl_boot_device *bootdev) | |
7ec03893 SG |
60 | { |
61 | #ifdef CONFIG_SPL_ETH_DEVICE | |
62 | bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE; | |
63 | #endif | |
64 | ||
2a2ee2ac | 65 | return spl_net_load_image(spl_image, bootdev); |
7ec03893 | 66 | } |
ebc4ef61 SG |
67 | SPL_LOAD_IMAGE_METHOD("eth device", 0, BOOT_DEVICE_CPGMAC, |
68 | spl_net_load_image_cpgmac); | |
7ec03893 SG |
69 | #endif |
70 | ||
b432b1eb | 71 | #ifdef CONFIG_SPL_USB_ETHER |
2a2ee2ac SG |
72 | int spl_net_load_image_usb(struct spl_image_info *spl_image, |
73 | struct spl_boot_device *bootdev) | |
7ec03893 SG |
74 | { |
75 | bootdev->boot_device_name = "usb_ether"; | |
0f46fb58 JJH |
76 | #if CONFIG_IS_ENABLED(DM_USB_GADGET) |
77 | usb_ether_init(); | |
78 | #endif | |
2a2ee2ac | 79 | return spl_net_load_image(spl_image, bootdev); |
7ec03893 | 80 | } |
ebc4ef61 | 81 | SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb); |
7ec03893 | 82 | #endif |