]> Git Repo - J-u-boot.git/blame - common/spl/spl_usb.c
usb: Rename SPL_USB_SUPPORT to SPL_USB_STORAGE
[J-u-boot.git] / common / spl / spl_usb.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
8cffe5bd
DM
2/*
3 * (C) Copyright 2014
4 * Texas Instruments, <www.ti.com>
5 *
6 * Dan Murphy <[email protected]>
7 *
8cffe5bd
DM
8 * Derived work from spl_mmc.c
9 */
10
11#include <common.h>
12#include <spl.h>
13#include <asm/u-boot.h>
36afd451 14#include <errno.h>
8cffe5bd
DM
15#include <usb.h>
16#include <fat.h>
17
8cffe5bd 18static int usb_stor_curr_dev = -1; /* current device */
8cffe5bd 19
2a2ee2ac
SG
20static int spl_usb_load_image(struct spl_image_info *spl_image,
21 struct spl_boot_device *bootdev)
8cffe5bd
DM
22{
23 int err;
4101f687 24 struct blk_desc *stor_dev;
8cffe5bd
DM
25
26 usb_stop();
27 err = usb_init();
28 if (err) {
29#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
30 printf("%s: usb init failed: err - %d\n", __func__, err);
31#endif
36afd451 32 return err;
8cffe5bd
DM
33 }
34
8cffe5bd
DM
35 /* try to recognize storage devices immediately */
36 usb_stor_curr_dev = usb_stor_scan(1);
57ebf67b 37 stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, usb_stor_curr_dev);
36afd451
NK
38 if (!stor_dev)
39 return -ENODEV;
8cffe5bd
DM
40
41 debug("boot mode - FAT\n");
42
43#ifdef CONFIG_SPL_OS_BOOT
710e9ca5
SG
44 if (spl_start_uboot() ||
45 spl_load_image_fat_os(spl_image, stor_dev,
46 CONFIG_SYS_USB_FAT_BOOT_PARTITION))
8cffe5bd 47#endif
710e9ca5
SG
48 {
49 err = spl_load_image_fat(spl_image, stor_dev,
50 CONFIG_SYS_USB_FAT_BOOT_PARTITION,
51 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
52 }
8cffe5bd 53
36afd451
NK
54 if (err) {
55 puts("Error loading from USB device\n");
56 return err;
57 }
58
59 return 0;
8cffe5bd 60}
ebc4ef61 61SPL_LOAD_IMAGE_METHOD("USB", 0, BOOT_DEVICE_USB, spl_usb_load_image);
This page took 0.311748 seconds and 4 git commands to generate.