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 * 8 * SPDX-License-Identifier: GPL-2.0+ 9 */ 10 #include <common.h> 11 #include <errno.h> 12 #include <spl.h> 13 #include <net.h> 14 15 DECLARE_GLOBAL_DATA_PTR; 16 17 #if defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT) 18 static int spl_net_load_image(struct spl_image_info *spl_image, 19 struct spl_boot_device *bootdev) 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); 27 rv = eth_initialize(); 28 if (rv == 0) { 29 printf("No Ethernet devices found\n"); 30 return -ENODEV; 31 } 32 if (bootdev->boot_device_name) 33 setenv("ethact", bootdev->boot_device_name); 34 rv = net_loop(BOOTP); 35 if (rv < 0) { 36 printf("Problem booting with BOOTP\n"); 37 return rv; 38 } 39 return spl_parse_image_header(spl_image, 40 (struct image_header *)load_addr); 41 } 42 #endif 43 44 #ifdef CONFIG_SPL_ETH_SUPPORT 45 int spl_net_load_image_cpgmac(struct spl_image_info *spl_image, 46 struct spl_boot_device *bootdev) 47 { 48 #ifdef CONFIG_SPL_ETH_DEVICE 49 bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE; 50 #endif 51 52 return spl_net_load_image(spl_image, bootdev); 53 } 54 SPL_LOAD_IMAGE_METHOD("eth device", 0, BOOT_DEVICE_CPGMAC, 55 spl_net_load_image_cpgmac); 56 #endif 57 58 #ifdef CONFIG_SPL_USBETH_SUPPORT 59 int spl_net_load_image_usb(struct spl_image_info *spl_image, 60 struct spl_boot_device *bootdev) 61 { 62 bootdev->boot_device_name = "usb_ether"; 63 64 return spl_net_load_image(spl_image, bootdev); 65 } 66 SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb); 67 #endif 68