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 DECLARE_GLOBAL_DATA_PTR;
21 #ifdef CONFIG_USB_STORAGE
22 static int usb_stor_curr_dev = -1; /* current device */
25 static int spl_usb_load_image(struct spl_boot_device *bootdev)
28 struct blk_desc *stor_dev;
33 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
34 printf("%s: usb init failed: err - %d\n", __func__, err);
39 #ifdef CONFIG_USB_STORAGE
40 /* try to recognize storage devices immediately */
41 usb_stor_curr_dev = usb_stor_scan(1);
42 stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, usb_stor_curr_dev);
47 debug("boot mode - FAT\n");
49 #ifdef CONFIG_SPL_OS_BOOT
50 if (spl_start_uboot() || spl_load_image_fat_os(stor_dev,
51 CONFIG_SYS_USB_FAT_BOOT_PARTITION))
53 err = spl_load_image_fat(stor_dev,
54 CONFIG_SYS_USB_FAT_BOOT_PARTITION,
55 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
58 puts("Error loading from USB device\n");
64 SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_USB, spl_usb_load_image);