From patchwork Tue Jan 20 22:42:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 431276 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 52AB41401D0 for ; Wed, 21 Jan 2015 09:41:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C22BC4B628; Tue, 20 Jan 2015 23:41:31 +0100 (CET) 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 F12ldDBhttxl; Tue, 20 Jan 2015 23:41:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9520E4B61D; Tue, 20 Jan 2015 23:41:30 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 910CF4B61A for ; Tue, 20 Jan 2015 23:41:25 +0100 (CET) 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 FmTWsqgS6jPs for ; Tue, 20 Jan 2015 23:41:25 +0100 (CET) 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 mail-gw3-out.broadcom.com (mail-gw3-out.broadcom.com [216.31.210.64]) by theia.denx.de (Postfix) with ESMTP id E49104B615 for ; Tue, 20 Jan 2015 23:41:24 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.09,437,1418112000"; d="scan'208";a="55081271" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw3-out.broadcom.com with ESMTP; 20 Jan 2015 14:57:57 -0800 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 20 Jan 2015 14:41:20 -0800 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.174.1; Tue, 20 Jan 2015 14:42:27 -0800 Received: from mail.broadcom.com (lbrmn-vmlnx03.ric.broadcom.com [10.136.4.105]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 4B13B40FE8; Tue, 20 Jan 2015 14:40:30 -0800 (PST) From: Steve Rae To: Date: Tue, 20 Jan 2015 14:42:07 -0800 Message-ID: <1421793730-8179-2-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1421793730-8179-1-git-send-email-srae@broadcom.com> References: <1421793730-8179-1-git-send-email-srae@broadcom.com> MIME-Version: 1.0 Cc: Marek Vasut , Rob Herring , Steve Rae , Jeroen Hofstee , Tom Rini Subject: [U-Boot] [PATCH 1/4] usb: gadget: fastboot: add CONFIG_FASTBOOT_NO_GADGET support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Implement fastboot_func_init() which provides a minimalistic setup of the USB endpoints and requests required by the fastboot gadget. Signed-off-by: Steve Rae --- drivers/usb/gadget/f_fastboot.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 6d3f05b..455f768 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -47,15 +47,18 @@ struct f_fastboot { struct usb_request *in_req, *out_req; }; +#ifndef CONFIG_FASTBOOT_NO_GADGET static inline struct f_fastboot *func_to_fastboot(struct usb_function *f) { return container_of(f, struct f_fastboot, usb_function); } +#endif static struct f_fastboot *fastboot_func; static unsigned int download_size; static unsigned int download_bytes; +#ifndef CONFIG_FASTBOOT_NO_GADGET static struct usb_endpoint_descriptor fs_ep_in = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, @@ -120,6 +123,7 @@ static struct usb_gadget_strings *fastboot_strings[] = { &stringtab_fastboot, NULL, }; +#endif static void rx_handler_command(struct usb_ep *ep, struct usb_request *req); @@ -131,6 +135,7 @@ static void fastboot_complete(struct usb_ep *ep, struct usb_request *req) printf("status: %d ep '%s' trans: %d\n", status, ep->name, req->actual); } +#ifndef CONFIG_FASTBOOT_NO_GADGET static int fastboot_bind(struct usb_configuration *c, struct usb_function *f) { int id; @@ -293,6 +298,7 @@ static int fastboot_add(struct usb_configuration *c) return status; } DECLARE_GADGET_BIND_CALLBACK(usb_dnl_fastboot, fastboot_add); +#endif static int fastboot_tx_write(const char *buffer, unsigned int buffer_size) { @@ -576,3 +582,36 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) usb_ep_queue(ep, req, 0); } } + +#ifdef CONFIG_FASTBOOT_NO_GADGET +void fastboot_func_init(struct usb_ep *in_ep, struct usb_ep *out_ep, + struct usb_request *in_req, struct usb_request *out_req) +{ + struct f_fastboot *f_fb = fastboot_func; + + /* see above: fastboot_add() */ + if (!f_fb) { + f_fb = memalign(CONFIG_SYS_CACHELINE_SIZE, sizeof(*f_fb)); + if (!f_fb) { + printf("%s: fatal!\n", __func__); + return; + } + + fastboot_func = f_fb; + memset(f_fb, 0, sizeof(*f_fb)); + } + + /* initialize IN/OUT EP's and corresponding requests */ + f_fb->in_ep = in_ep; + f_fb->out_ep = out_ep; + f_fb->in_req = in_req; + f_fb->out_req = out_req; + + /* initialize 'complete' handlers */ + f_fb->in_req->complete = fastboot_complete; + f_fb->out_req->complete = rx_handler_command; + + /* initialize data */ + f_fb->out_req->length = EP_BUFFER_SIZE; +} +#endif