Dan Murphy | 8cffe5b | 2014-01-16 11:23:30 -0600 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2014 |
| 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_mmc.c |
| 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <spl.h> |
| 14 | #include <asm/u-boot.h> |
| 15 | #include <usb.h> |
| 16 | #include <fat.h> |
| 17 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | #ifdef CONFIG_USB_STORAGE |
| 21 | static int usb_stor_curr_dev = -1; /* current device */ |
| 22 | #endif |
| 23 | |
| 24 | void spl_usb_load_image(void) |
| 25 | { |
| 26 | int err; |
| 27 | block_dev_desc_t *stor_dev; |
| 28 | |
| 29 | usb_stop(); |
| 30 | err = usb_init(); |
| 31 | if (err) { |
| 32 | #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT |
| 33 | printf("%s: usb init failed: err - %d\n", __func__, err); |
| 34 | #endif |
| 35 | hang(); |
| 36 | } |
| 37 | |
| 38 | #ifdef CONFIG_USB_STORAGE |
| 39 | /* try to recognize storage devices immediately */ |
| 40 | usb_stor_curr_dev = usb_stor_scan(1); |
| 41 | stor_dev = usb_stor_get_dev(usb_stor_curr_dev); |
| 42 | #endif |
| 43 | |
| 44 | debug("boot mode - FAT\n"); |
| 45 | |
| 46 | #ifdef CONFIG_SPL_OS_BOOT |
| 47 | if (spl_start_uboot() || spl_load_image_fat_os(stor_dev, |
| 48 | CONFIG_SYS_USB_FAT_BOOT_PARTITION)) |
| 49 | #endif |
| 50 | err = spl_load_image_fat(stor_dev, |
| 51 | CONFIG_SYS_USB_FAT_BOOT_PARTITION, |
Guillaume GARDET | 205b4f3 | 2014-10-15 17:53:11 +0200 | [diff] [blame^] | 52 | CONFIG_SPL_FS_LOAD_PAYLOAD_NAME); |
Dan Murphy | 8cffe5b | 2014-01-16 11:23:30 -0600 | [diff] [blame] | 53 | |
| 54 | if (err) { |
| 55 | puts("Error loading USB device\n"); |
| 56 | hang(); |
| 57 | } |
| 58 | } |