spl_sata.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * (C) Copyright 2013
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * Dan Murphy <dmurphy@ti.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. *
  9. * Derived work from spl_usb.c
  10. */
  11. #include <common.h>
  12. #include <spl.h>
  13. #include <asm/u-boot.h>
  14. #include <sata.h>
  15. #include <scsi.h>
  16. #include <errno.h>
  17. #include <fat.h>
  18. #include <image.h>
  19. DECLARE_GLOBAL_DATA_PTR;
  20. static int spl_sata_load_image(struct spl_image_info *spl_image,
  21. struct spl_boot_device *bootdev)
  22. {
  23. int err;
  24. struct blk_desc *stor_dev;
  25. err = init_sata(CONFIG_SPL_SATA_BOOT_DEVICE);
  26. if (err) {
  27. #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
  28. printf("spl: sata init failed: err - %d\n", err);
  29. #endif
  30. return err;
  31. } else {
  32. /* try to recognize storage devices immediately */
  33. scsi_scan(0);
  34. stor_dev = blk_get_devnum_by_type(IF_TYPE_SCSI, 0);
  35. if (!stor_dev)
  36. return -ENODEV;
  37. }
  38. #ifdef CONFIG_SPL_OS_BOOT
  39. if (spl_start_uboot() ||
  40. spl_load_image_fat_os(spl_image, stor_dev,
  41. CONFIG_SYS_SATA_FAT_BOOT_PARTITION))
  42. #endif
  43. {
  44. err = spl_load_image_fat(spl_image, stor_dev,
  45. CONFIG_SYS_SATA_FAT_BOOT_PARTITION,
  46. CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
  47. }
  48. if (err) {
  49. puts("Error loading sata device\n");
  50. return err;
  51. }
  52. return 0;
  53. }
  54. SPL_LOAD_IMAGE_METHOD("SATA", 0, BOOT_DEVICE_SATA, spl_sata_load_image);