]>
Commit | Line | Data |
---|---|---|
7ac2fe2d IY |
1 | /* |
2 | * (C) Copyright 2000-2004 | |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
4 | * | |
5 | * (C) Copyright 2012 | |
6 | * Ilya Yanok <ilya.yanok@gmail.com> | |
7 | * | |
1a459660 | 8 | * SPDX-License-Identifier: GPL-2.0+ |
7ac2fe2d IY |
9 | */ |
10 | #include <common.h> | |
36afd451 | 11 | #include <errno.h> |
7ac2fe2d IY |
12 | #include <spl.h> |
13 | #include <net.h> | |
14 | ||
15 | DECLARE_GLOBAL_DATA_PTR; | |
16 | ||
7ec03893 | 17 | #if defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT) |
2a2ee2ac SG |
18 | static int spl_net_load_image(struct spl_image_info *spl_image, |
19 | struct spl_boot_device *bootdev) | |
7ac2fe2d IY |
20 | { |
21 | int rv; | |
22 | ||
23 | env_init(); | |
24 | env_relocate(); | |
25 | setenv("autoload", "yes"); | |
26 | load_addr = CONFIG_SYS_TEXT_BASE - sizeof(struct image_header); | |
d2eaec60 | 27 | rv = eth_initialize(); |
7ac2fe2d IY |
28 | if (rv == 0) { |
29 | printf("No Ethernet devices found\n"); | |
36afd451 | 30 | return -ENODEV; |
7ac2fe2d | 31 | } |
ecdfd69a SG |
32 | if (bootdev->boot_device_name) |
33 | setenv("ethact", bootdev->boot_device_name); | |
bc0571fc | 34 | rv = net_loop(BOOTP); |
7ac2fe2d IY |
35 | if (rv < 0) { |
36 | printf("Problem booting with BOOTP\n"); | |
36afd451 | 37 | return rv; |
7ac2fe2d | 38 | } |
2a2ee2ac | 39 | return spl_parse_image_header(spl_image, |
71316c1d | 40 | (struct image_header *)load_addr); |
7ac2fe2d | 41 | } |
7ec03893 SG |
42 | #endif |
43 | ||
44 | #ifdef CONFIG_SPL_ETH_SUPPORT | |
2a2ee2ac SG |
45 | int spl_net_load_image_cpgmac(struct spl_image_info *spl_image, |
46 | struct spl_boot_device *bootdev) | |
7ec03893 SG |
47 | { |
48 | #ifdef CONFIG_SPL_ETH_DEVICE | |
49 | bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE; | |
50 | #endif | |
51 | ||
2a2ee2ac | 52 | return spl_net_load_image(spl_image, bootdev); |
7ec03893 | 53 | } |
ebc4ef61 SG |
54 | SPL_LOAD_IMAGE_METHOD("eth device", 0, BOOT_DEVICE_CPGMAC, |
55 | spl_net_load_image_cpgmac); | |
7ec03893 SG |
56 | #endif |
57 | ||
58 | #ifdef CONFIG_SPL_USBETH_SUPPORT | |
2a2ee2ac SG |
59 | int spl_net_load_image_usb(struct spl_image_info *spl_image, |
60 | struct spl_boot_device *bootdev) | |
7ec03893 SG |
61 | { |
62 | bootdev->boot_device_name = "usb_ether"; | |
63 | ||
2a2ee2ac | 64 | return spl_net_load_image(spl_image, bootdev); |
7ec03893 | 65 | } |
ebc4ef61 | 66 | SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb); |
7ec03893 | 67 | #endif |