From patchwork Tue Jan 12 15:42:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vikram pandita X-Patchwork-Id: 72400 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0CFcMbA021194 for ; Tue, 12 Jan 2010 15:38:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753533Ab0ALPiQ (ORCPT ); Tue, 12 Jan 2010 10:38:16 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752335Ab0ALPiQ (ORCPT ); Tue, 12 Jan 2010 10:38:16 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:57998 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750951Ab0ALPiP (ORCPT ); Tue, 12 Jan 2010 10:38:15 -0500 Received: from dlep36.itg.ti.com ([157.170.170.91]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o0CFcBag022426 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 Jan 2010 09:38:11 -0600 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id o0CFc7aW016986; Tue, 12 Jan 2010 09:38:07 -0600 (CST) Received: from vip-tid (lta0307903-128247075087.am.dhcp.ti.com [128.247.75.87]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id o0CFc6Z18466; Tue, 12 Jan 2010 09:38:06 -0600 (CST) Received: from vip-tid (localhost.localdomain [127.0.0.1]) by vip-tid (Postfix) with ESMTP id 19B7729C94E; Tue, 12 Jan 2010 09:42:19 -0600 (CST) Received: (from vikram@localhost) by vip-tid (8.14.3/8.14.3/Submit) id o0CFgJ5p007282; Tue, 12 Jan 2010 09:42:19 -0600 X-Authentication-Warning: vip-tid: vikram set sender to vikram.pandita@ti.com using -f From: Vikram Pandita To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, Vikram Pandita , Anand Gadiyar , Maulik Mankad , Nilkesh Patra , Felipe Balbi Subject: [PATCH] USB: musb: allow unaligned memory data transfers Date: Tue, 12 Jan 2010 09:42:17 -0600 Message-Id: <1263310937-7249-1-git-send-email-vikram.pandita@ti.com> X-Mailer: git-send-email 1.6.6.rc0.66.ge160d Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index cbcf14a..7ad3571 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -681,8 +681,15 @@ static void rxstate(struct musb *musb, struct musb_request *req) transfer_size); } - if (use_dma) + if (use_dma) { return; + } else { + /* Need to clear DMAENAB for the + * backup PIO mode transfer to work + */ + csr &= ~MUSB_RXCSR_DMAENAB; + musb_writew(epio, MUSB_RXCSR, csr); + } } #endif /* Mentor's DMA */ diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c index a237550..f118ae2 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c @@ -166,6 +166,8 @@ static int dma_channel_program(struct dma_channel *channel, dma_addr_t dma_addr, u32 len) { struct musb_dma_channel *musb_channel = channel->private_data; + struct musb_dma_controller *controller = musb_channel->controller; + struct musb *musb = controller->private_data; DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n", musb_channel->epnum, @@ -175,6 +177,15 @@ static int dma_channel_program(struct dma_channel *channel, BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN || channel->status == MUSB_DMA_STATUS_BUSY); + /* On MUSB:RTL1.8 and above, DMA has to be word aligned */ + if ((dma_addr % 4) && + (musb->hwvers >= MUSB_HWVERS_1800)) { + /* Fail DMA for unaligned buffers: + * Use PIO for such buffers + */ + return false; + } + channel->actual_len = 0; musb_channel->start_addr = dma_addr; musb_channel->len = len;