spl_net.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. DECLARE_GLOBAL_DATA_PTR;
  15. #if defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)
  16. static int spl_net_load_image(struct spl_image_info *spl_image,
  17. struct spl_boot_device *bootdev)
  18. {
  19. int rv;
  20. env_init();
  21. env_relocate();
  22. setenv("autoload", "yes");
  23. load_addr = CONFIG_SYS_TEXT_BASE - sizeof(struct image_header);
  24. rv = eth_initialize();
  25. if (rv == 0) {
  26. printf("No Ethernet devices found\n");
  27. return -ENODEV;
  28. }
  29. if (bootdev->boot_device_name)
  30. setenv("ethact", bootdev->boot_device_name);
  31. rv = net_loop(BOOTP);
  32. if (rv < 0) {
  33. printf("Problem booting with BOOTP\n");
  34. return rv;
  35. }
  36. return spl_parse_image_header(spl_image,
  37. (struct image_header *)load_addr);
  38. }
  39. #endif
  40. #ifdef CONFIG_SPL_ETH_SUPPORT
  41. int spl_net_load_image_cpgmac(struct spl_image_info *spl_image,
  42. struct spl_boot_device *bootdev)
  43. {
  44. #ifdef CONFIG_SPL_ETH_DEVICE
  45. bootdev->boot_device_name = CONFIG_SPL_ETH_DEVICE;
  46. #endif
  47. return spl_net_load_image(spl_image, bootdev);
  48. }
  49. SPL_LOAD_IMAGE_METHOD("eth device", 0, BOOT_DEVICE_CPGMAC,
  50. spl_net_load_image_cpgmac);
  51. #endif
  52. #ifdef CONFIG_SPL_USBETH_SUPPORT
  53. int spl_net_load_image_usb(struct spl_image_info *spl_image,
  54. struct spl_boot_device *bootdev)
  55. {
  56. bootdev->boot_device_name = "usb_ether";
  57. return spl_net_load_image(spl_image, bootdev);
  58. }
  59. SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);
  60. #endif