]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_usb_mass_storage.c
2 * Copyright (C) 2011 Samsung Electronics
3 * Lukasz Majewski <l.majewski@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
13 #include <usb_mass_storage.h>
15 int do_usb_mass_storage(cmd_tbl_t
*cmdtp
, int flag
,
16 int argc
, char * const argv
[])
21 const char *usb_controller
= argv
[1];
22 const char *mmc_devstring
= argv
[2];
24 unsigned int dev_num
= simple_strtoul(mmc_devstring
, NULL
, 0);
26 struct ums
*ums
= ums_init(dev_num
);
28 return CMD_RET_FAILURE
;
30 unsigned int controller_index
= (unsigned int)(simple_strtoul(
31 usb_controller
, NULL
, 0));
32 if (board_usb_init(controller_index
, USB_INIT_DEVICE
)) {
33 error("Couldn't init USB controller.");
34 return CMD_RET_FAILURE
;
37 int rc
= fsg_init(ums
);
39 error("fsg_init failed");
40 return CMD_RET_FAILURE
;
43 g_dnl_register("ums");
45 /* Timeout unit: seconds */
46 int cable_ready_timeout
= UMS_CABLE_READY_TIMEOUT
;
48 if (!usb_cable_connected()) {
49 puts("Please connect USB cable.\n");
51 while (!usb_cable_connected()) {
53 puts("\rCTRL+C - Operation aborted.\n");
56 if (!cable_ready_timeout
) {
57 puts("\rUSB cable not detected.\n" \
62 printf("\rAuto exit in: %.2d s.", cable_ready_timeout
);
64 cable_ready_timeout
--;
70 usb_gadget_handle_interrupts();
72 rc
= fsg_main_thread(NULL
);
76 printf("\rCheck USB cable connection\n");
80 printf("\rCTRL+C - Operation aborted\n");
87 return CMD_RET_SUCCESS
;
90 U_BOOT_CMD(ums
, CONFIG_SYS_MAXARGS
, 1, do_usb_mass_storage
,
91 "Use the UMS [User Mass Storage]",
92 "ums <USB_controller> <mmc_dev> e.g. ums 0 0"