linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ajay Kumar Gupta <ajay.gupta@ti.com>
To: linux-usb@vger.kernel.org
Cc: linux-omap@vger.kernel.org, felipe.balbi@nokia.com,
	Ajay Kumar Gupta <ajay.gupta@ti.com>
Subject: [PATCH resend 3/3] musb: AM35x: Workaround for fifo read issue
Date: Fri,  2 Jul 2010 12:27:59 +0530	[thread overview]
Message-ID: <1278053879-6850-3-git-send-email-ajay.gupta@ti.com> (raw)
In-Reply-To: <1278053879-6850-2-git-send-email-ajay.gupta@ti.com>

AM35x supports only 32bit read operations so we need to have
workaround for 8bit and 16bit read operations.

Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
---
 drivers/usb/musb/am35x.c     |   30 ++++++++++++++++++++++++++++++
 drivers/usb/musb/musb_core.c |    2 ++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 0cdc6bf..cdcd6f3 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -517,3 +517,33 @@ void musb_platform_restore_context(struct musb *musb,
 	phy_on();
 }
 #endif
+
+/* AM35x supports only 32bit read operation */
+void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
+{
+	void __iomem *fifo = hw_ep->fifo;
+	u32		val;
+	int		i;
+
+	/* Read for 32bit-aligned destination address */
+	if (likely((0x03 & (unsigned long) dst) == 0) && len >= 4) {
+		readsl(fifo, dst, len >> 2);
+		dst += len & ~0x03;
+		len &= 0x03;
+	}
+	/*
+	 * Now read the rest 1 to 3 bytes or complete length if
+	 * unaligned address.
+	 */
+	if (len > 4) {
+		for (i = 0; i < (len >> 2); i++) {
+			*(u32 *) dst = musb_readl(fifo, 0);
+			dst += 4;
+		}
+		len %= 4;
+	}
+	if (len > 0) {
+		val = musb_readl(fifo, 0);
+		memcpy(dst, &val, len);
+	}
+}
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 3b795c5..e22e98b 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -272,6 +272,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
 	}
 }
 
+#if !defined(CONFIG_ARCH_AM35x)
 /*
  * Unload an endpoint's FIFO
  */
@@ -309,6 +310,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
 		readsb(fifo, dst, len);
 	}
 }
+#endif
 
 #endif	/* normal PIO */
 
-- 
1.6.2.4


  reply	other threads:[~2010-07-02  6:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-02  6:57 [PATCH resend 1/3] AM35x: Add musb support Ajay Kumar Gupta
2010-07-02  6:57 ` [PATCH resend 2/3] musb: add musb support for AM35x Ajay Kumar Gupta
2010-07-02  6:57   ` Ajay Kumar Gupta [this message]
2010-07-02 12:21   ` Sergei Shtylyov
2010-07-03  3:24     ` Gupta, Ajay Kumar
     [not found]       ` <19F8576C6E063C45BE387C64729E7394044EAAD82A-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2010-07-03 13:04         ` Sergei Shtylyov
2010-07-05 11:46           ` Gupta, Ajay Kumar
2010-07-05  9:50 ` [PATCH resend 1/3] AM35x: Add musb support Tony Lindgren
2010-07-05 10:02   ` Sergei Shtylyov
     [not found]     ` <4C31ADCA.40607-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2010-07-05 10:23       ` Tony Lindgren
     [not found]         ` <20100705102322.GR15951-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2010-07-05 10:34           ` Sergei Shtylyov
     [not found]             ` <4C31B54F.6040109-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2010-07-05 10:48               ` Tony Lindgren
2010-07-05 11:54                 ` Gupta, Ajay Kumar
     [not found]                   ` <19F8576C6E063C45BE387C64729E7394044EAAD8F6-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2010-07-05 13:45                     ` Tony Lindgren
     [not found]                       ` <20100705134552.GD15951-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2010-07-05 14:50                         ` Sergei Shtylyov
2010-07-06  7:23                           ` Gupta, Ajay Kumar
2010-07-06  7:57                             ` Tony Lindgren
     [not found]                               ` <20100706075707.GC3192-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2010-07-06  8:46                                 ` Felipe Balbi
     [not found]                                   ` <20100706084603.GA3035-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-07-06  9:51                                     ` Tony Lindgren
2010-07-06 22:46                                   ` Gadiyar, Anand
2010-07-07  7:53                                     ` Felipe Balbi

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=1278053879-6850-3-git-send-email-ajay.gupta@ti.com \
    --to=ajay.gupta@ti.com \
    --cc=felipe.balbi@nokia.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).