spl_sata.c 1000 B

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