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