blob: 346ab804541fd951316ca962ca3f5bb727f53244 [file] [log] [blame]
Sebastian Siewior3aab70a2014-05-05 15:08:10 -05001/*
2 * Copyright 2008 - 2009 Windriver, <www.windriver.com>
3 * Author: Tom Rix <Tom.Rix@windriver.com>
4 *
5 * (C) Copyright 2014 Linaro, Ltd.
6 * Rob Herring <robh@kernel.org>
7 *
8 * SPDX-License-Identifier: GPL-2.0+
9 */
10#include <common.h>
11#include <command.h>
12#include <g_dnl.h>
13
14static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
15{
16 int ret;
17
Rob Herring267abc62014-12-10 14:43:04 -060018 g_dnl_clear_detach();
Sebastian Siewior3aab70a2014-05-05 15:08:10 -050019 ret = g_dnl_register("usb_dnl_fastboot");
20 if (ret)
21 return ret;
22
Rob Herring7c23bcb2015-01-26 15:14:41 -060023 if (!g_dnl_board_usb_cable_connected()) {
24 puts("\rUSB cable not detected.\n" \
25 "Command exit.\n");
26 return CMD_RET_FAILURE;
27 }
28
Sebastian Siewior3aab70a2014-05-05 15:08:10 -050029 while (1) {
Rob Herring267abc62014-12-10 14:43:04 -060030 if (g_dnl_detach())
31 break;
Sebastian Siewior3aab70a2014-05-05 15:08:10 -050032 if (ctrlc())
33 break;
34 usb_gadget_handle_interrupts();
35 }
36
37 g_dnl_unregister();
Rob Herring267abc62014-12-10 14:43:04 -060038 g_dnl_clear_detach();
Sebastian Siewior3aab70a2014-05-05 15:08:10 -050039 return CMD_RET_SUCCESS;
40}
41
42U_BOOT_CMD(
Steve Rae593cbd92014-08-26 11:47:29 -070043 fastboot, 1, 0, do_fastboot,
44 "use USB Fastboot protocol",
45 "\n"
46 " - run as a fastboot usb device"
Sebastian Siewior3aab70a2014-05-05 15:08:10 -050047);