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