2 * cmd_dfu.c -- dfu command
4 * Copyright (C) 2012 Samsung Electronics
5 * authors: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
6 * Lukasz Majewski <l.majewski@samsung.com>
8 * SPDX-License-Identifier: GPL-2.0+
16 static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
18 bool dfu_reset = false;
23 char *usb_controller = argv[1];
24 char *interface = argv[2];
25 char *devstring = argv[3];
29 ret = dfu_init_env_entities(interface, devstring);
33 ret = CMD_RET_SUCCESS;
34 if (argc > 4 && strcmp(argv[4], "list") == 0) {
39 int controller_index = simple_strtoul(usb_controller, NULL, 0);
40 board_usb_init(controller_index, USB_INIT_DEVICE);
42 g_dnl_register("usb_dnl_dfu");
46 * Check if USB bus reset is performed after detach,
47 * which indicates that -R switch has been passed to
48 * dfu-util. In this case reboot the device
50 if (dfu_usb_get_reset()) {
56 * This extra number of usb_gadget_handle_interrupts()
57 * calls is necessary to assure correct transmission
58 * completion with dfu-util
67 usb_gadget_handle_interrupts();
75 run_command("reset", 0);
82 U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
83 "Device Firmware Upgrade",
84 "<USB_controller> <interface> <dev> [list]\n"
85 " - device firmware upgrade via <USB_controller>\n"
86 " on device <dev>, attached to interface\n"
88 " [list] - list available alt settings\n"