1 // SPDX-License-Identifier: GPL-2.0+
4 * Texas Instruments, <www.ti.com>
6 * Dan Murphy <dmurphy@ti.com>
8 * Derived work from spl_usb.c
13 #include <asm/u-boot.h>
20 #ifndef CONFIG_SYS_SATA_FAT_BOOT_PARTITION
21 #define CONFIG_SYS_SATA_FAT_BOOT_PARTITION 1
24 #ifndef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
25 #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img"
28 static int spl_sata_load_image(struct spl_image_info *spl_image,
29 struct spl_boot_device *bootdev)
32 struct blk_desc *stor_dev;
34 #if !defined(CONFIG_DM_SCSI) && !defined(CONFIG_AHCI)
35 err = init_sata(CONFIG_SPL_SATA_BOOT_DEVICE);
38 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
39 printf("spl: sata init failed: err - %d\n", err);
43 /* try to recognize storage devices immediately */
45 stor_dev = blk_get_devnum_by_type(IF_TYPE_SCSI, 0);
50 #ifdef CONFIG_SPL_OS_BOOT
51 if (spl_start_uboot() ||
52 spl_load_image_fat_os(spl_image, stor_dev,
53 CONFIG_SYS_SATA_FAT_BOOT_PARTITION))
58 if (IS_ENABLED(CONFIG_SPL_FS_FAT)) {
59 err = spl_load_image_fat(spl_image, stor_dev,
60 CONFIG_SYS_SATA_FAT_BOOT_PARTITION,
61 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
65 puts("Error loading sata device\n");
71 SPL_LOAD_IMAGE_METHOD("SATA", 0, BOOT_DEVICE_SATA, spl_sata_load_image);