[5/5] musb: dma: use optimal transfer element for sdma
diff mbox

Message ID 1273664979-493-5-git-send-email-ajay.gupta@ti.com
State New, archived
Headers show

Commit Message

Ajay Kumar Gupta May 12, 2010, 11:49 a.m. UTC
None

Patch
diff mbox

diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 6118d5f..a0da178 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -230,6 +230,8 @@  static void configure_channel(struct dma_channel *channel,
 	u8 buffer_is_aligned = (dma_addr & 0x3) ? 0 : 1;
 	u8 use_sdma = (musb_channel->sysdma_channel == -1) ? 0 : 1;
 	u16 csr = 0;
+	u16 frame = len;
+	int data_type = OMAP_DMA_DATA_TYPE_S8;
 
 	DBG(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n",
 			channel, packet_sz, dma_addr, len, mode);
@@ -238,13 +240,38 @@  static void configure_channel(struct dma_channel *channel,
 			(musb->hwvers >= MUSB_HWVERS_1800))
 		use_sdma = 0;
 
+	if (use_sdma) {
+		switch (dma_addr & 0x3) {
+		case 0:
+			if ((len % 4) == 0) {
+				data_type = OMAP_DMA_DATA_TYPE_S32;
+				frame = len / 4;
+				break;
+			}
+			/* FALLTHROUGH */
+		case 2:
+			if ((len % 2) == 0) {
+				data_type = OMAP_DMA_DATA_TYPE_S16;
+				frame = len / 2;
+				break;
+			}
+			/* FALLTHROUGH */
+		case 1:
+		case 3:
+		default:
+			data_type = OMAP_DMA_DATA_TYPE_S8;
+			frame = len;
+			break;
+		}
+	}
+
 	if (use_sdma &&	!musb_channel->transmit) {
 		/* System DMA */
 		/* RX: set src = FIFO */
 		omap_set_dma_transfer_params(musb_channel->sysdma_channel,
-					OMAP_DMA_DATA_TYPE_S8,
-					len ? len : 1, 1, /* One frame */
-					OMAP_DMA_SYNC_ELEMENT,
+					data_type,
+					len ? frame : 1, 1, /* One frame */
+					OMAP_DMA_SYNC_FRAME,
 					OMAP24XX_DMA_NO_DEVICE,
 					0); /* Src Sync */
 
@@ -268,9 +295,9 @@  static void configure_channel(struct dma_channel *channel,
 		/* System DMA */
 		/* TX: set dst = FIFO */
 		omap_set_dma_transfer_params(musb_channel->sysdma_channel,
-					OMAP_DMA_DATA_TYPE_S8,
-					len ? len : 1, 1, /* One frame */
-					OMAP_DMA_SYNC_ELEMENT,
+					data_type,
+					len ? frame : 1, 1, /* One frame */
+					OMAP_DMA_SYNC_FRAME,
 					OMAP24XX_DMA_NO_DEVICE,
 					0); /* Src Sync */