All of lore.kernel.org
 help / color / mirror / Atom feed
From: 박경민 <kyungmin.park@samsung.com>
To: linux-omap-open-source@linux.omap.com
Subject: [review] OMAP2 USB device DMA support
Date: Fri, 10 Nov 2006 05:18:10 +0000 (GMT)	[thread overview]
Message-ID: <31432157.389061163135914340.JavaMail.weblogic@ep_ml21> (raw)

[-- Attachment #1: Type: text/plain, Size: 7595 bytes --]

Hi,

I need to help with USB device DMA.

After some work, I can use DMA with minor problem.

After loading g_file_stroage, I got messages below.
It only displays once, after detection it works well.

So I think we have a problem with protocol with windows.
In fact, I don't know file storage protocol with windows.

Do you have any idea?

Any comments are welcome.

Thank you,
Kyungmin Park

P.S., I also attached the usb dma patch.

/ # insmod /usb/g_file_storage.ko-2.6.19 file=/dev/stl6
Using /usb/g_file_storage.ko-2.6.19
g_file_storage gadget: File-backed Storage Gadget, version: 28 November 2005
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, file: /dev/stl6
/ # udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1
g_file_storage gadget: error in submission: ep2out-bulk --> -90
udc: USB reset done, gadget g_file_storage
udc: USB reset done, gadget g_file_storage
g_file_storage gadget: full speed config #1

--


diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 31df02e..5cb3198 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -63,7 +63,7 @@
 
 /* FIXME: OMAP2 currently has some problem in DMA mode */
 #ifdef CONFIG_ARCH_OMAP2
-#undef USE_DMA
+//#undef USE_DMA
 #endif
 
 /* ISO too */
@@ -74,6 +74,7 @@
 
 #define	DMA_ADDR_INVALID	(~(dma_addr_t)0)
 
+#define OMAP2_DMA_CH(ch)	(((ch) - 1) << 1)
 
 /*
  * The OMAP UDC needs _very_ early endpoint setup:  before enabling the
@@ -620,20 +621,25 @@ static void next_in_dma(struct omap_ep *
 	const int	sync_mode = cpu_is_omap15xx()
 				? OMAP_DMA_SYNC_FRAME
 				: OMAP_DMA_SYNC_ELEMENT;
+	int		dma_trigger = 0;
+
+	if (cpu_is_omap24xx())
+		dma_trigger = OMAP24XX_DMA_USB_W2FC_TX0 + OMAP2_DMA_CH(ep->dma_channel);
 
 	/* measure length in either bytes or packets */
 	if ((cpu_is_omap16xx() && length <= UDC_TXN_TSC)
+			|| (cpu_is_omap24xx() && length <= ep->maxpacket)
 			|| (cpu_is_omap15xx() && length < ep->maxpacket)) {
 		txdma_ctrl = UDC_TXN_EOT | length;
 		omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8,
-				length, 1, sync_mode, 0, 0);
+				length, 1, sync_mode, dma_trigger, 0);
 	} else {
 		length = min(length / ep->maxpacket,
 				(unsigned) UDC_TXN_TSC + 1);
 		txdma_ctrl = length;
 		omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16,
 				ep->ep.maxpacket >> 1, length, sync_mode,
-				0, 0);
+				dma_trigger, 0);
 		length *= ep->maxpacket;
 	}
 	omap_set_dma_src_params(ep->lch, OMAP_DMA_PORT_EMIFF,
@@ -672,11 +678,15 @@ static void finish_in_dma(struct omap_ep
 static void next_out_dma(struct omap_ep *ep, struct omap_req *req)
 {
 	unsigned packets;
+	int dma_trigger = 0;
 
 	/* NOTE:  we filtered out "short reads" before, so we know
 	 * the buffer has only whole numbers of packets.
 	 */
 
+	if (cpu_is_omap24xx())
+		dma_trigger = OMAP24XX_DMA_USB_W2FC_RX0 + OMAP2_DMA_CH(ep->dma_channel);
+
 	/* set up this DMA transfer, enable the fifo, start */
 	packets = (req->req.length - req->req.actual) / ep->ep.maxpacket;
 	packets = min(packets, (unsigned)UDC_RXN_TC + 1);
@@ -684,7 +694,7 @@ static void next_out_dma(struct omap_ep 
 	omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16,
 			ep->ep.maxpacket >> 1, packets,
 			OMAP_DMA_SYNC_ELEMENT,
-			0, 0);
+			dma_trigger, 0);
 	omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF,
 		OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual,
 		0, 0);
@@ -792,6 +802,7 @@ static void dma_channel_claim(struct oma
 {
 	u16	reg;
 	int	status, restart, is_in;
+	int	dma_channel;
 
 	is_in = ep->bEndpointAddress & USB_DIR_IN;
 	if (is_in)
@@ -818,11 +829,15 @@ static void dma_channel_claim(struct oma
 	ep->dma_channel = channel;
 
 	if (is_in) {
-		status = omap_request_dma(OMAP_DMA_USB_W2FC_TX0 - 1 + channel,
+		if (cpu_is_omap24xx())
+			dma_channel = OMAP24XX_DMA_USB_W2FC_TX0 + OMAP2_DMA_CH(channel);
+		else
+			dma_channel = OMAP_DMA_USB_W2FC_TX0 - 1 + channel;
+		status = omap_request_dma(dma_channel,
 			ep->ep.name, dma_error, ep, &ep->lch);
 		if (status == 0) {
 			UDC_TXDMA_CFG_REG = reg;
-			/* EMIFF */
+			/* EMIFF or SDRC*/
 			omap_set_dma_src_burst_mode(ep->lch,
 						OMAP_DMA_DATA_BURST_4);
 			omap_set_dma_src_data_pack(ep->lch, 1);
@@ -834,7 +849,11 @@ static void dma_channel_claim(struct oma
 				0, 0);
 		}
 	} else {
-		status = omap_request_dma(OMAP_DMA_USB_W2FC_RX0 - 1 + channel,
+		if (cpu_is_omap24xx())
+			dma_channel = OMAP24XX_DMA_USB_W2FC_RX0 + OMAP2_DMA_CH(channel);
+		else
+			dma_channel = OMAP_DMA_USB_W2FC_RX0 - 1 + channel;
+		status = omap_request_dma(dma_channel,
 			ep->ep.name, dma_error, ep, &ep->lch);
 		if (status == 0) {
 			UDC_RXDMA_CFG_REG = reg;
@@ -844,7 +863,7 @@ static void dma_channel_claim(struct oma
 				OMAP_DMA_AMODE_CONSTANT,
 				(unsigned long) io_v2p((u32)&UDC_DATA_DMA_REG),
 				0, 0);
-			/* EMIFF */
+			/* EMIFF or SDRC */
 			omap_set_dma_dest_burst_mode(ep->lch,
 						OMAP_DMA_DATA_BURST_4);
 			omap_set_dma_dest_data_pack(ep->lch, 1);
@@ -857,7 +876,7 @@ static void dma_channel_claim(struct oma
 		omap_disable_dma_irq(ep->lch, OMAP_DMA_BLOCK_IRQ);
 
 		/* channel type P: hw synch (fifo) */
-		if (!cpu_is_omap15xx())
+		if (cpu_class_is_omap1() && !cpu_is_omap15xx())
 			OMAP1_DMA_LCH_CTRL_REG(ep->lch) = 2;
 	}
 
@@ -2579,7 +2598,7 @@ omap_ep_setup(char *name, u8 addr, u8 ty
 		 * (for more reliable behavior)
 		 */
 		if ((!use_dma && (addr & USB_DIR_IN))
-				|| machine_is_omap_apollon()
+				|| (!use_dma && machine_is_omap_apollon())
 				|| cpu_is_omap15xx())
 			dbuf = 0;
 


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



                 reply	other threads:[~2006-11-10  5:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31432157.389061163135914340.JavaMail.weblogic@ep_ml21 \
    --to=kyungmin.park@samsung.com \
    --cc=linux-omap-open-source@linux.omap.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.