Dan Murphy | fff40a7 | 2014-02-03 06:59:01 -0600 | [diff] [blame] | 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 | |
| 12 | #include <common.h> |
| 13 | #include <spl.h> |
| 14 | #include <asm/u-boot.h> |
| 15 | #include <sata.h> |
| 16 | #include <fat.h> |
| 17 | #include <version.h> |
| 18 | #include <image.h> |
| 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
| 22 | void spl_sata_load_image(void) |
| 23 | { |
| 24 | int err; |
| 25 | block_dev_desc_t *stor_dev; |
| 26 | |
| 27 | err = init_sata(CONFIG_SPL_SATA_BOOT_DEVICE); |
| 28 | if (err) { |
| 29 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
| 30 | printf("spl: sata init failed: err - %d\n", err); |
| 31 | #endif |
| 32 | hang(); |
| 33 | } else { |
| 34 | /* try to recognize storage devices immediately */ |
Roger Quadros | 76300c0 | 2014-09-23 18:07:04 +0300 | [diff] [blame] | 35 | scsi_scan(0); |
Dan Murphy | fff40a7 | 2014-02-03 06:59:01 -0600 | [diff] [blame] | 36 | stor_dev = scsi_get_dev(0); |
| 37 | } |
| 38 | |
| 39 | #ifdef CONFIG_SPL_OS_BOOT |
| 40 | if (spl_start_uboot() || spl_load_image_fat_os(stor_dev, |
| 41 | CONFIG_SYS_SATA_FAT_BOOT_PARTITION)) |
| 42 | #endif |
| 43 | err = spl_load_image_fat(stor_dev, |
| 44 | CONFIG_SYS_SATA_FAT_BOOT_PARTITION, |
| 45 | CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME); |
| 46 | if (err) { |
| 47 | puts("Error loading sata device\n"); |
| 48 | hang(); |
| 49 | } |
| 50 | } |