+// SPDX-License-Identifier: GPL-2.0+
/*
* dfu.c -- dfu command
*
* Copyright (C) 2012 Samsung Electronics
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
+#include <command.h>
+#include <log.h>
#include <watchdog.h>
#include <dfu.h>
#include <console.h>
bool dfu_reset = false;
int ret, i = 0;
- ret = board_usb_init(usbctrl_index, USB_INIT_DEVICE);
+ ret = usb_gadget_initialize(usbctrl_index);
if (ret) {
- pr_err("board usb init failed\n");
+ pr_err("usb_gadget_initialize failed\n");
return CMD_RET_FAILURE;
}
g_dnl_clear_detach();
return CMD_RET_FAILURE;
}
+#ifdef CONFIG_DFU_TIMEOUT
+ unsigned long start_time = get_timer(0);
+#endif
+
while (1) {
if (g_dnl_detach()) {
/*
}
}
+#ifdef CONFIG_DFU_TIMEOUT
+ unsigned long wait_time = dfu_get_timeout();
+
+ if (wait_time) {
+ unsigned long current_time = get_timer(start_time);
+
+ if (current_time > wait_time) {
+ debug("Inactivity timeout, abort DFU\n");
+ goto exit;
+ }
+ }
+#endif
+
+ if (dfu_reinit_needed)
+ goto exit;
+
WATCHDOG_RESET();
usb_gadget_handle_interrupts(usbctrl_index);
}
exit:
g_dnl_unregister();
- board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE);
+ usb_gadget_release(usbctrl_index);
if (dfu_reset)
do_reset(NULL, 0, 0, NULL);