Sebastian Siewior | 9d4471e | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 1 | /* |
| 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 | |
| 14 | static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
| 15 | { |
| 16 | int ret; |
| 17 | |
Rob Herring | 5aba398 | 2014-12-10 14:43:04 -0600 | [diff] [blame] | 18 | g_dnl_clear_detach(); |
Sebastian Siewior | 9d4471e | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 19 | ret = g_dnl_register("usb_dnl_fastboot"); |
| 20 | if (ret) |
| 21 | return ret; |
| 22 | |
Rob Herring | ce9d8ee | 2015-01-26 15:14:41 -0600 | [diff] [blame] | 23 | if (!g_dnl_board_usb_cable_connected()) { |
| 24 | puts("\rUSB cable not detected.\n" \ |
| 25 | "Command exit.\n"); |
Paul Kocialkowski | 8672ada | 2015-03-28 18:22:49 +0100 | [diff] [blame] | 26 | g_dnl_unregister(); |
| 27 | g_dnl_clear_detach(); |
Rob Herring | ce9d8ee | 2015-01-26 15:14:41 -0600 | [diff] [blame] | 28 | return CMD_RET_FAILURE; |
| 29 | } |
| 30 | |
Sebastian Siewior | 9d4471e | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 31 | while (1) { |
Rob Herring | 5aba398 | 2014-12-10 14:43:04 -0600 | [diff] [blame] | 32 | if (g_dnl_detach()) |
| 33 | break; |
Sebastian Siewior | 9d4471e | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 34 | if (ctrlc()) |
| 35 | break; |
Kishon Vijay Abraham I | 4763e16 | 2015-02-23 18:40:23 +0530 | [diff] [blame] | 36 | usb_gadget_handle_interrupts(0); |
Sebastian Siewior | 9d4471e | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | g_dnl_unregister(); |
Rob Herring | 5aba398 | 2014-12-10 14:43:04 -0600 | [diff] [blame] | 40 | g_dnl_clear_detach(); |
Sebastian Siewior | 9d4471e | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 41 | return CMD_RET_SUCCESS; |
| 42 | } |
| 43 | |
| 44 | U_BOOT_CMD( |
Steve Rae | 56ad792 | 2014-08-26 11:47:29 -0700 | [diff] [blame] | 45 | fastboot, 1, 0, do_fastboot, |
| 46 | "use USB Fastboot protocol", |
| 47 | "\n" |
| 48 | " - run as a fastboot usb device" |
Sebastian Siewior | 9d4471e | 2014-05-05 15:08:10 -0500 | [diff] [blame] | 49 | ); |