From patchwork Fri Jun 12 17:57:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 483721 X-Patchwork-Delegate: l.majewski@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 62080140497 for ; Sat, 13 Jun 2015 03:58:11 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2D6554B6DA; Fri, 12 Jun 2015 19:57:59 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Fup1lBh63jDJ; Fri, 12 Jun 2015 19:57:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D875E4B6B3; Fri, 12 Jun 2015 19:57:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6DF054B68A for ; Fri, 12 Jun 2015 19:57:43 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O_9j6L9bFa5v for ; Fri, 12 Jun 2015 19:57:43 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from gagarine.paulk.fr (gagarine.paulk.fr [109.190.93.129]) by theia.denx.de (Postfix) with ESMTPS id 381764B691 for ; Fri, 12 Jun 2015 19:57:43 +0200 (CEST) Received: by gagarine.paulk.fr (Postfix, from userid 65534) id A8F931FE6F; Fri, 12 Jun 2015 19:57:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on gagarine.paulk.fr X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=RDNS_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from localhost.localdomain (unknown [192.168.1.22]) by gagarine.paulk.fr (Postfix) with ESMTP id AFB031FE5D; Fri, 12 Jun 2015 19:57:21 +0200 (CEST) From: Paul Kocialkowski To: u-boot@lists.denx.de Date: Fri, 12 Jun 2015 19:57:00 +0200 Message-Id: <1434131821-7641-3-git-send-email-contact@paulk.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434131821-7641-1-git-send-email-contact@paulk.fr> References: <1434131821-7641-1-git-send-email-contact@paulk.fr> Cc: Tom Rini , Przemyslaw Marczak , Dileep Katta Subject: [U-Boot] [PATCH v2 3/4] usb: board_usb_init and board_usb_cleanup calls in the fastboot command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Each USB download function command calls board_usb_init before registering the USB gadget and board_usb_cleanup after de-registering it. On devices currently using fasboot, musb-new is usually initialized earlier, but some other boards might need the board_usb_init call to properly initialize musb-new. This requires adding an argument (the USB controller index) to the fastboot command, as it is currently done with other USB download gadget functions. Signed-off-by: Paul Kocialkowski --- common/cmd_fastboot.c | 31 +++++++++++++++++++++++++------ include/configs/ti_omap5_common.h | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c index d52ccfb..86fbddf 100644 --- a/common/cmd_fastboot.c +++ b/common/cmd_fastboot.c @@ -10,11 +10,26 @@ #include #include #include +#include static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { + int controller_index; + char *usb_controller; int ret; + if (argc < 2) + return CMD_RET_USAGE; + + usb_controller = argv[1]; + controller_index = simple_strtoul(usb_controller, NULL, 0); + + ret = board_usb_init(controller_index, USB_INIT_DEVICE); + if (ret) { + error("USB init failed: %d", ret); + return CMD_RET_FAILURE; + } + g_dnl_clear_detach(); ret = g_dnl_register("usb_dnl_fastboot"); if (ret) @@ -23,9 +38,8 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) if (!g_dnl_board_usb_cable_connected()) { puts("\rUSB cable not detected.\n" \ "Command exit.\n"); - g_dnl_unregister(); - g_dnl_clear_detach(); - return CMD_RET_FAILURE; + ret = CMD_RET_FAILURE; + goto exit; } while (1) { @@ -36,14 +50,19 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) usb_gadget_handle_interrupts(0); } + ret = CMD_RET_SUCCESS; + +exit: g_dnl_unregister(); g_dnl_clear_detach(); - return CMD_RET_SUCCESS; + board_usb_cleanup(controller_index, USB_INIT_DEVICE); + + return ret; } U_BOOT_CMD( - fastboot, 1, 0, do_fastboot, + fastboot, 2, 1, do_fastboot, "use USB Fastboot protocol", - "\n" + "\n" " - run as a fastboot usb device" ); diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h index 4faffef..4fd5669 100644 --- a/include/configs/ti_omap5_common.h +++ b/include/configs/ti_omap5_common.h @@ -137,7 +137,7 @@ "if test ${dofastboot} -eq 1; then " \ "echo Boot fastboot requested, resetting dofastboot ...;" \ "setenv dofastboot 0; saveenv;" \ - "echo Booting into fastboot ...; fastboot;" \ + "echo Booting into fastboot ...; fastboot 0;" \ "fi;" \ "run findfdt; " \ "run mmcboot;" \