From patchwork Thu Oct 10 22:28:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 282482 X-Patchwork-Delegate: marek.vasut@gmail.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 D42602C00A6 for ; Fri, 11 Oct 2013 09:29:20 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A1424A0E8; Fri, 11 Oct 2013 00:29:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 1WaUryp21uUR; Fri, 11 Oct 2013 00:29:12 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 866744A0C1; Fri, 11 Oct 2013 00:28:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CCC674A09C for ; Fri, 11 Oct 2013 00:28:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 l1-NAOE4VdHb for ; Fri, 11 Oct 2013 00:28:29 +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 mail-pb0-f41.google.com (mail-pb0-f41.google.com [209.85.160.41]) by theia.denx.de (Postfix) with ESMTPS id 3A26B4A095 for ; Fri, 11 Oct 2013 00:28:15 +0200 (CEST) Received: by mail-pb0-f41.google.com with SMTP id rp2so3279369pbb.28 for ; Thu, 10 Oct 2013 15:28:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O1DH5n41AtK/2gx9l8LQRmzMyMT6R5YdzyvpctL40M0=; b=A2Nl3Vgp++0HN44Xvto9elaw0pFCUYo7qIdvePWBOxbT6e7CNMZgPnzqZQyUZfcz89 pa6vdH515QbotnjmLy99Tl8+weHn/FZzW9d+iTVF4u7hDammwvaojTO5Uw3746DFcbwt iQ6oB5vI32wKsQJDnJ8tXthB3E1Y3TrveELOQp/j2u49go7orLDCuF/q121zlTB9GLiA 9wVeF7txEgYaP8aBXxkOw79hVYJDd9+5mKJdwqujsodqMy2yAgVHKJdqKmJBfYN4133L 5rNPJS8rGixM59t6inxDFlp8p8nzHJiLB/oVDxgeD7ysv6WyhelIpLo9VbUsSMkjNkxm /hOQ== X-Gm-Message-State: ALoCoQndWbBlDt7QYf8Gh/syzzjm4muDCUcN1tsITEVnmPuVTLJyTdhqsJ4sObrKqI8AD0rHc0e5 X-Received: by 10.68.253.227 with SMTP id ad3mr72457pbd.189.1381444094054; Thu, 10 Oct 2013 15:28:14 -0700 (PDT) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPSA id py4sm55446459pbb.33.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Oct 2013 15:28:13 -0700 (PDT) Received: from tkisky by officeserver-2 with local (Exim 4.80) (envelope-from ) id 1VUOiY-0006L0-OM; Thu, 10 Oct 2013 15:28:26 -0700 From: Troy Kisky To: marek.vasut@gmail.com Date: Thu, 10 Oct 2013 15:28:00 -0700 Message-Id: <1381444084-24296-7-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1381444084-24296-1-git-send-email-troy.kisky@boundarydevices.com> References: <1381444084-24296-1-git-send-email-troy.kisky@boundarydevices.com> Cc: leiwen@marvell.com, fabio.estevam@freescale.com, otavio@ossystems.com.br, u-boot@lists.denx.de Subject: [U-Boot] [PATCH V6 06/10] usb: gadget: mv_udc: fix full speed connections X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Set maximum packet length in queue header to wMaxPacketSize of endpoint. Signed-off-by: Troy Kisky --- v4: no change v5: no change v6: no change --- drivers/usb/gadget/mv_udc.c | 48 ++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/mv_udc.c index 13f2d6d..08845de 100644 --- a/drivers/usb/gadget/mv_udc.c +++ b/drivers/usb/gadget/mv_udc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -207,7 +208,7 @@ static void mv_ep_free_request(struct usb_ep *ep, struct usb_request *_req) return; } -static void ep_enable(int num, int in) +static void ep_enable(int num, int in, int maxpacket) { struct ept_queue_head *head; struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor; @@ -221,7 +222,7 @@ static void ep_enable(int num, int in) n |= (CTRL_RXE | CTRL_RXR | CTRL_RXT_BULK); if (num != 0) { - head->config = CONFIG_MAX_PKT(EP_MAX_PACKET_SIZE) | CONFIG_ZLT; + head->config = CONFIG_MAX_PKT(maxpacket) | CONFIG_ZLT; mv_flush_qh(num); } writel(n, &udc->epctrl[num]); @@ -234,8 +235,21 @@ static int mv_ep_enable(struct usb_ep *ep, int num, in; num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; in = (desc->bEndpointAddress & USB_DIR_IN) != 0; - ep_enable(num, in); mv_ep->desc = desc; + + if (num) { + int max = get_unaligned_le16(&desc->wMaxPacketSize); + + if ((max > 64) && (controller.gadget.speed == USB_SPEED_FULL)) + max = 64; + if (ep->maxpacket != max) { + DBG("%s: from %d to %d\n", __func__, + ep->maxpacket, max); + ep->maxpacket = max; + } + } + ep_enable(num, in, ep->maxpacket); + DBG("%s: num=%d maxpacket=%d\n", __func__, num, ep->maxpacket); return 0; } @@ -410,14 +424,16 @@ static void handle_setup(void) if ((r.wValue == 0) && (r.wLength == 0)) { req->length = 0; for (i = 0; i < NUM_ENDPOINTS; i++) { - if (!controller.ep[i].desc) + struct mv_ep *ep = &controller.ep[i]; + + if (!ep->desc) continue; - num = controller.ep[i].desc->bEndpointAddress + num = ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; - in = (controller.ep[i].desc->bEndpointAddress + in = (ep->desc->bEndpointAddress & USB_DIR_IN) != 0; if ((num == _num) && (in == _in)) { - ep_enable(num, in); + ep_enable(num, in, ep->ep.maxpacket); usb_ep_queue(controller.gadget.ep0, req, 0); break; @@ -501,15 +517,19 @@ void udc_irq(void) DBG("-- suspend --\n"); if (n & STS_PCI) { - DBG("-- portchange --\n"); + int max = 64; + int speed = USB_SPEED_FULL; + bit = (readl(&udc->portsc) >> 26) & 3; + DBG("-- portchange %x %s\n", bit, (bit == 2) ? "High" : "Full"); if (bit == 2) { - controller.gadget.speed = USB_SPEED_HIGH; - for (i = 1; i < NUM_ENDPOINTS && n; i++) - if (controller.ep[i].desc) - controller.ep[i].ep.maxpacket = 512; - } else { - controller.gadget.speed = USB_SPEED_FULL; + speed = USB_SPEED_HIGH; + max = 512; + } + controller.gadget.speed = speed; + for (i = 1; i < NUM_ENDPOINTS; i++) { + if (controller.ep[i].ep.maxpacket > max) + controller.ep[i].ep.maxpacket = max; } }