1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2017 Eddie Cai <eddie.cai.linux@gmail.com>
11 #include <asm/arch/f_rockusb.h>
13 static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
15 int controller_index, dev_index;
24 usb_controller = argv[1];
25 controller_index = simple_strtoul(usb_controller, NULL, 0);
33 dev_index = simple_strtoul(devnum, NULL, 0);
34 rockusb_dev_init(devtype, dev_index);
36 ret = board_usb_init(controller_index, USB_INIT_DEVICE);
38 printf("USB init failed: %d\n", ret);
39 return CMD_RET_FAILURE;
43 ret = g_dnl_register("usb_dnl_rockusb");
45 return CMD_RET_FAILURE;
47 if (!g_dnl_board_usb_cable_connected()) {
48 puts("\rUSB cable not detected, Command exit.\n");
49 ret = CMD_RET_FAILURE;
58 usb_gadget_handle_interrupts(controller_index);
60 ret = CMD_RET_SUCCESS;
65 board_usb_cleanup(controller_index, USB_INIT_DEVICE);
70 U_BOOT_CMD(rockusb, 4, 1, do_rockusb,
71 "use the rockusb protocol",
72 "<USB_controller> <devtype> <dev[:part]> e.g. rockusb 0 mmc 0\n"