1 // SPDX-License-Identifier: GPL-2.0+
4 * Texas Instruments, <www.ti.com>
8 * Derived work from spl_mmc.c
17 static int usb_stor_curr_dev = -1; /* current device */
19 int spl_usb_load(struct spl_image_info *spl_image,
20 struct spl_boot_device *bootdev, int partition,
24 struct blk_desc *stor_dev;
25 static bool usb_init_pending = true;
27 if (usb_init_pending) {
30 usb_init_pending = false;
34 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
35 printf("%s: usb init failed: err - %d\n", __func__, err);
40 /* try to recognize storage devices immediately */
41 usb_stor_curr_dev = usb_stor_scan(1);
42 stor_dev = blk_get_devnum_by_uclass_id(UCLASS_USB, usb_stor_curr_dev);
46 debug("boot mode - FAT\n");
48 #if CONFIG_IS_ENABLED(OS_BOOT)
49 if (spl_start_uboot() ||
50 spl_load_image_fat_os(spl_image, bootdev, stor_dev, partition))
53 err = spl_load_image_fat(spl_image, bootdev, stor_dev, partition, filename);
57 puts("Error loading from USB device\n");
64 static int spl_usb_load_image(struct spl_image_info *spl_image,
65 struct spl_boot_device *bootdev)
67 return spl_usb_load(spl_image, bootdev,
68 CONFIG_SYS_USB_FAT_BOOT_PARTITION,
69 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
71 SPL_LOAD_IMAGE_METHOD("USB", 0, BOOT_DEVICE_USB, spl_usb_load_image);