From patchwork Mon May 17 11:08:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar Gupta X-Patchwork-Id: 100092 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4HB8aox025594 for ; Mon, 17 May 2010 11:08:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753312Ab0EQLIT (ORCPT ); Mon, 17 May 2010 07:08:19 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:39661 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751321Ab0EQLIS (ORCPT ); Mon, 17 May 2010 07:08:18 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o4HB8BLc032479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 17 May 2010 06:08:14 -0500 Received: from psplinux050.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o4HB8AfS026215; Mon, 17 May 2010 16:38:10 +0530 (IST) Received: from psplinux050.india.ti.com (localhost [127.0.0.1]) by psplinux050.india.ti.com (8.13.1/8.13.1) with ESMTP id o4HB89jm016002; Mon, 17 May 2010 16:38:09 +0530 Received: (from a0393629@localhost) by psplinux050.india.ti.com (8.13.1/8.13.1/Submit) id o4HB89qT015999; Mon, 17 May 2010 16:38:09 +0530 From: Ajay Kumar Gupta To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, felipe.balbi@nokia.com, Ajay Kumar Gupta Subject: [PATCH 5/6] musb: gadget: fix tx transfer path for mode0 operation Date: Mon, 17 May 2010 16:38:07 +0530 Message-Id: <1274094488-15925-5-git-send-email-ajay.gupta@ti.com> X-Mailer: git-send-email 1.6.2.4 In-Reply-To: <1274094488-15925-4-git-send-email-ajay.gupta@ti.com> References: <1274094488-15925-1-git-send-email-ajay.gupta@ti.com> <1274094488-15925-2-git-send-email-ajay.gupta@ti.com> <1274094488-15925-3-git-send-email-ajay.gupta@ti.com> <1274094488-15925-4-git-send-email-ajay.gupta@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 17 May 2010 11:08:37 +0000 (UTC) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 6fca870..9ac45e4 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -317,6 +317,22 @@ static void txstate(struct musb *musb, struct musb_request *req) else musb_ep->dma->desired_mode = 1; + /* + * Use system dma for unaligned buffers on RTL >= 1.8 + * for Inventra DMA. As system DMA can work only in + * mode-0 so update the desired_mode and request_size. + */ + if (is_inventra_dma_enabled() && + ((request->dma + request->actual) & 0x3) && + (musb->hwvers >= MUSB_HWVERS_1800)) { + + request_size = min_t(size_t, + musb_ep->hw_ep->max_packet_sz_tx, + request->length - request->actual); + + musb_ep->dma->desired_mode = 0; + } + use_dma = use_dma && c->channel_program( musb_ep->dma, musb_ep->packet_sz, musb_ep->dma->desired_mode, @@ -463,7 +479,6 @@ void musb_g_tx(struct musb *musb, u8 epnum) u8 is_dma = 0; if (dma && (csr & MUSB_TXCSR_DMAENAB)) { - is_dma = 1; csr |= MUSB_TXCSR_P_WZC_BITS; csr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_P_UNDERRUN | MUSB_TXCSR_TXPKTRDY); @@ -471,6 +486,10 @@ void musb_g_tx(struct musb *musb, u8 epnum) /* Ensure writebuffer is empty. */ csr = musb_readw(epio, MUSB_TXCSR); request->actual += musb_ep->dma->actual_len; + + if (request->actual == request->length) + is_dma = 1; + DBG(4, "TXCSR%d %04x, DMA off, len %zu, req %p\n", epnum, csr, musb_ep->dma->actual_len, request); }