"Das U-Boot" Source Tree
at master 80 lines 2.0 kB view raw
1// SPDX-License-Identifier: GPL-2.0+ 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> 8 */ 9#include <env.h> 10#include <errno.h> 11#include <image.h> 12#include <log.h> 13#include <spl.h> 14#include <spl_load.h> 15#include <net.h> 16#include <linux/libfdt.h> 17 18#if defined(CONFIG_SPL_ETH) || defined(CONFIG_SPL_USB_ETHER) 19static ulong spl_net_load_read(struct spl_load_info *load, ulong sector, 20 ulong count, void *buf) 21{ 22 debug("%s: sector %lx, count %lx, buf %lx\n", 23 __func__, sector, count, (ulong)buf); 24 memcpy(buf, map_sysmem(image_load_addr + sector, count), count); 25 return count; 26} 27 28static int spl_net_load_image(struct spl_image_info *spl_image, 29 struct spl_boot_device *bootdev) 30{ 31 struct spl_load_info load; 32 int rv; 33 34 env_init(); 35 env_relocate(); 36 env_set("autoload", "yes"); 37 rv = eth_initialize(); 38 if (rv == 0) { 39 printf("No Ethernet devices found\n"); 40 return -ENODEV; 41 } 42 if (bootdev->boot_device_name) 43 env_set("ethact", bootdev->boot_device_name); 44 rv = net_loop(BOOTP); 45 if (rv < 0) { 46 printf("Problem booting with BOOTP\n"); 47 return rv; 48 } 49 50 spl_load_init(&load, spl_net_load_read, NULL, 1); 51 return spl_load(spl_image, bootdev, &load, 0, 0); 52} 53#endif 54 55#ifdef CONFIG_SPL_ETH 56int spl_net_load_image_cpgmac(struct spl_image_info *spl_image, 57 struct spl_boot_device *bootdev) 58{ 59#ifdef CONFIG_SPL_ETH_DEVICE 60 bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE; 61#endif 62 63 return spl_net_load_image(spl_image, bootdev); 64} 65SPL_LOAD_IMAGE_METHOD("eth device", 0, BOOT_DEVICE_CPGMAC, 66 spl_net_load_image_cpgmac); 67#endif 68 69#ifdef CONFIG_SPL_USB_ETHER 70int spl_net_load_image_usb(struct spl_image_info *spl_image, 71 struct spl_boot_device *bootdev) 72{ 73 bootdev->boot_device_name = "usb_ether"; 74#if CONFIG_IS_ENABLED(DM_USB_GADGET) 75 usb_ether_init(); 76#endif 77 return spl_net_load_image(spl_image, bootdev); 78} 79SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb); 80#endif