spl_sata.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. int spl_sata_load_image(void)
  21. {
  22. int err;
  23. block_dev_desc_t *stor_dev;
  24. err = init_sata(CONFIG_SPL_SATA_BOOT_DEVICE);
  25. if (err) {
  26. #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
  27. printf("spl: sata init failed: err - %d\n", err);
  28. #endif
  29. return err;
  30. } else {
  31. /* try to recognize storage devices immediately */
  32. scsi_scan(0);
  33. stor_dev = scsi_get_dev(0);
  34. if (!stor_dev)
  35. return -ENODEV;
  36. }
  37. #ifdef CONFIG_SPL_OS_BOOT
  38. if (spl_start_uboot() || spl_load_image_fat_os(stor_dev,
  39. CONFIG_SYS_SATA_FAT_BOOT_PARTITION))
  40. #endif
  41. err = spl_load_image_fat(stor_dev,
  42. CONFIG_SYS_SATA_FAT_BOOT_PARTITION,
  43. CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
  44. if (err) {
  45. puts("Error loading sata device\n");
  46. return err;
  47. }
  48. return 0;
  49. }