cmd_fastboot.c 948 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright 2008 - 2009 Windriver, <www.windriver.com>
 * Author: Tom Rix <Tom.Rix@windriver.com>
 *
 * (C) Copyright 2014 Linaro, Ltd.
 * Rob Herring <robh@kernel.org>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */
#include <common.h>
#include <command.h>
#include <g_dnl.h>

static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
	int ret;

18
	g_dnl_clear_detach();
19 20 21 22
	ret = g_dnl_register("usb_dnl_fastboot");
	if (ret)
		return ret;

23 24 25
	if (!g_dnl_board_usb_cable_connected()) {
		puts("\rUSB cable not detected.\n" \
		     "Command exit.\n");
26 27
		g_dnl_unregister();
		g_dnl_clear_detach();
28 29 30
		return CMD_RET_FAILURE;
	}

31
	while (1) {
32 33
		if (g_dnl_detach())
			break;
34 35
		if (ctrlc())
			break;
36
		usb_gadget_handle_interrupts(0);
37 38 39
	}

	g_dnl_unregister();
40
	g_dnl_clear_detach();
41 42 43 44
	return CMD_RET_SUCCESS;
}

U_BOOT_CMD(
45 46 47 48
	fastboot,	1,	0,	do_fastboot,
	"use USB Fastboot protocol",
	"\n"
	"    - run as a fastboot usb device"
49
);