3 * Texas Instruments, <www.ti.com>
5 * Dan Murphy <dmurphy@ti.com>
7 * SPDX-License-Identifier: GPL-2.0+
9 * Derived work from spl_mmc.c
14 #include <asm/u-boot.h>
19 #ifdef CONFIG_USB_STORAGE
20 static int usb_stor_curr_dev = -1; /* current device */
23 static int spl_usb_load_image(struct spl_image_info *spl_image,
24 struct spl_boot_device *bootdev)
27 struct blk_desc *stor_dev;
32 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
33 printf("%s: usb init failed: err - %d\n", __func__, err);
38 #ifdef CONFIG_USB_STORAGE
39 /* try to recognize storage devices immediately */
40 usb_stor_curr_dev = usb_stor_scan(1);
41 stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, usb_stor_curr_dev);
46 debug("boot mode - FAT\n");
48 #ifdef CONFIG_SPL_OS_BOOT
49 if (spl_start_uboot() ||
50 spl_load_image_fat_os(spl_image, stor_dev,
51 CONFIG_SYS_USB_FAT_BOOT_PARTITION))
54 err = spl_load_image_fat(spl_image, stor_dev,
55 CONFIG_SYS_USB_FAT_BOOT_PARTITION,
56 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
60 puts("Error loading from USB device\n");
66 SPL_LOAD_IMAGE_METHOD("USB", 0, BOOT_DEVICE_USB, spl_usb_load_image);