* [PATCH 0/1 v2] mx31: Fix usb otg host initialisation
@ 2010-05-11 14:14 Philippe Rétornaz
2010-05-11 14:14 ` [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG " Philippe Rétornaz
0 siblings, 1 reply; 9+ messages in thread
From: Philippe Rétornaz @ 2010-05-11 14:14 UTC (permalink / raw)
To: linux-arm-kernel
Hello
This patch fix the usb otg host initialisation on imx31 platform.
The ULPI access had timeout problem. This try to fix them by resetting
the host controller before accessing the PHY.
With a such reset the configuration registers need to be rewritten after
the ULPI access.
Tested on 3 different board with an imx31.
The v2 try to integrate all the comments. It defines new functions
to reset the host and to poll the differents bits with a timeout but
it should not change the general behavior of the code.
Regards,
Philippe
Philippe R?tornaz (1):
ehci-mxc: Fix mx31 OTG host initialisation
drivers/usb/host/ehci-mxc.c | 98 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 87 insertions(+), 11 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG host initialisation
2010-05-11 14:14 [PATCH 0/1 v2] mx31: Fix usb otg host initialisation Philippe Rétornaz
@ 2010-05-11 14:14 ` Philippe Rétornaz
2010-05-11 23:38 ` Greg KH
0 siblings, 1 reply; 9+ messages in thread
From: Philippe Rétornaz @ 2010-05-11 14:14 UTC (permalink / raw)
To: linux-arm-kernel
On mx31 the OTG host initialisation fails if you need to have
an ULPI transfert to initialize the PHY.
In order to be able to communicate with the PHY a complete reset
of the usb host is needed. After the PHY initialization the host
usb configuration registers need to be rewritten to avoid a host
controller lockup.
Signed-off-by: Philippe R?tornaz <philippe.retornaz@epfl.ch>
---
drivers/usb/host/ehci-mxc.c | 98 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 87 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index 544ccfd..488a171 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -29,6 +29,11 @@
#define PORTSC_OFFSET 0x184
#define USBMODE_OFFSET 0x1a8
#define USBMODE_CM_HOST 3
+#define USBCMD_OFFSET 0x140
+#define USBCMD_RS (1 << 0)
+#define USBCMD_RST (1 << 1)
+#define USBSTS_OFFSET 0x144
+#define USBSTS_HCH (1 << 12)
struct ehci_mxc_priv {
struct clk *usbclk, *ahbclk;
@@ -112,12 +117,73 @@ static const struct hc_driver ehci_mxc_hc_driver = {
.port_handed_over = ehci_port_handed_over,
};
+static int ehci_mxc_poll(void __iomem *ptr, u32 mask, u32 done, int usec)
+{
+ int i;
+
+ for (i = 0; i < usec; i++) {
+ if ((readl(ptr) & mask) == done)
+ return 0;
+ udelay(1);
+ }
+ return -ETIMEDOUT;
+}
+
+#define MXC_POLL_TIMEOUT 10000
+static int ehci_mxc_reset(struct usb_hcd *hcd)
+{
+ int ret;
+ int temp;
+
+ /* Wait for the controller to go idle */
+ ret = ehci_mxc_poll(hcd->regs + USBSTS_OFFSET,
+ USBSTS_HCH, USBSTS_HCH, MXC_POLL_TIMEOUT);
+ if (ret < 0)
+ return ret;
+
+ /* Stop the usb controller */
+ temp = readl(hcd->regs + USBCMD_OFFSET);
+ writel(temp & (~USBCMD_RS), hcd->regs + USBCMD_OFFSET);
+
+ ret = ehci_mxc_poll(hcd->regs + USBCMD_OFFSET, USBCMD_RS, 0,
+ MXC_POLL_TIMEOUT);
+ if (ret < 0)
+ return ret;
+
+ /* Reset the usb controller */
+ temp = readl(hcd->regs + USBCMD_OFFSET);
+ writel(temp | USBCMD_RST, hcd->regs + USBCMD_OFFSET);
+
+ ret = ehci_mxc_poll(hcd->regs + USBCMD_OFFSET, USBCMD_RST, 0,
+ MXC_POLL_TIMEOUT);
+
+ return ret;
+}
+
+static int ehci_mxc_setup_host_mode(struct platform_device *pdev,
+ struct usb_hcd *hcd)
+{
+ struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;
+ int temp;
+
+ /* set USBMODE to host mode */
+ temp = readl(hcd->regs + USBMODE_OFFSET);
+ writel(temp | USBMODE_CM_HOST, hcd->regs + USBMODE_OFFSET);
+
+ /* set up the PORTSCx register */
+ writel(pdata->portsc, hcd->regs + PORTSC_OFFSET);
+ mdelay(10);
+
+ /* setup specific usb hw */
+ return mxc_initialize_usb_hw(pdev->id, pdata->flags);
+}
+
static int ehci_mxc_drv_probe(struct platform_device *pdev)
{
struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;
struct usb_hcd *hcd;
struct resource *res;
- int irq, ret, temp;
+ int irq, ret;
struct ehci_mxc_priv *priv;
struct device *dev = &pdev->dev;
@@ -191,19 +257,20 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
clk_enable(priv->ahbclk);
}
- /* set USBMODE to host mode */
- temp = readl(hcd->regs + USBMODE_OFFSET);
- writel(temp | USBMODE_CM_HOST, hcd->regs + USBMODE_OFFSET);
-
- /* set up the PORTSCx register */
- writel(pdata->portsc, hcd->regs + PORTSC_OFFSET);
- mdelay(10);
-
- /* setup specific usb hw */
- ret = mxc_initialize_usb_hw(pdev->id, pdata->flags);
+ ret = ehci_mxc_setup_host_mode(pdev, hcd);
if (ret < 0)
goto err_init;
+ /* i.Mx31 OTG host has a bug, if you don't do a reset, then ULPI
+ * transfers timeout. */
+ if (cpu_is_mx31() && pdev->id == 0) {
+ ret = ehci_mxc_reset(hcd);
+ if (ret < 0) {
+ dev_err(dev, "Unable to reset USB controller");
+ goto err_init;
+ }
+ }
+
/* Initialize the transceiver */
if (pdata->otg) {
pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET;
@@ -213,6 +280,15 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
dev_err(dev, "unable to enable vbus on transceiver\n");
}
+ /* i.Mx31 OTG host has a bug, if you do an ULPI transfer then the host
+ * controller stays busy. Rewriting the register is enough to make it
+ * working */
+ if (cpu_is_mx31() && pdev->id == 0) {
+ ret = ehci_mxc_setup_host_mode(pdev, hcd);
+ if (ret < 0)
+ goto err_init;
+ }
+
priv->hcd = hcd;
platform_set_drvdata(pdev, priv);
--
1.6.3.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG host initialisation
2010-05-11 14:14 ` [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG " Philippe Rétornaz
@ 2010-05-11 23:38 ` Greg KH
2010-05-12 7:23 ` Philippe Rétornaz
0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2010-05-11 23:38 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, May 11, 2010 at 04:14:34PM +0200, Philippe R?tornaz wrote:
> On mx31 the OTG host initialisation fails if you need to have
> an ULPI transfert to initialize the PHY.
>
> In order to be able to communicate with the PHY a complete reset
> of the usb host is needed. After the PHY initialization the host
> usb configuration registers need to be rewritten to avoid a host
> controller lockup.
>
> Signed-off-by: Philippe R?tornaz <philippe.retornaz@epfl.ch>
> ---
> drivers/usb/host/ehci-mxc.c | 98 ++++++++++++++++++++++++++++++++++++++-----
This patch doesn't apply anymore, can you redo it against the linux-next
tree?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG host initialisation
2010-05-11 23:38 ` Greg KH
@ 2010-05-12 7:23 ` Philippe Rétornaz
2010-05-12 18:50 ` Greg KH
2010-05-20 17:32 ` Philippe Rétornaz
0 siblings, 2 replies; 9+ messages in thread
From: Philippe Rétornaz @ 2010-05-12 7:23 UTC (permalink / raw)
To: linux-arm-kernel
Le mercredi, 12 mai 2010 01.38:12, Greg KH a ?crit :
> On Tue, May 11, 2010 at 04:14:34PM +0200, Philippe R?tornaz wrote:
> > On mx31 the OTG host initialisation fails if you need to have
> > an ULPI transfert to initialize the PHY.
> >
> > In order to be able to communicate with the PHY a complete reset
> > of the usb host is needed. After the PHY initialization the host
> > usb configuration registers need to be rewritten to avoid a host
> > controller lockup.
> >
> > Signed-off-by: Philippe R?tornaz <philippe.retornaz@epfl.ch>
> > ---
> > drivers/usb/host/ehci-mxc.c | 98
> > ++++++++++++++++++++++++++++++++++++++-----
>
> This patch doesn't apply anymore, can you redo it against the linux-next
> tree?
>
It apply cleanly on next-20100512.
It needs commit 5a25ad84e01173bb225285eb50f9af48ed1a7598 to apply, but this
one is in linux-next now.
Regards,
Philippe
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG host initialisation
2010-05-12 7:23 ` Philippe Rétornaz
@ 2010-05-12 18:50 ` Greg KH
2010-05-13 17:04 ` Philippe Rétornaz
2010-05-20 17:32 ` Philippe Rétornaz
1 sibling, 1 reply; 9+ messages in thread
From: Greg KH @ 2010-05-12 18:50 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, May 12, 2010 at 09:23:48AM +0200, Philippe R?tornaz wrote:
> Le mercredi, 12 mai 2010 01.38:12, Greg KH a ?crit :
> > On Tue, May 11, 2010 at 04:14:34PM +0200, Philippe R?tornaz wrote:
> > > On mx31 the OTG host initialisation fails if you need to have
> > > an ULPI transfert to initialize the PHY.
> > >
> > > In order to be able to communicate with the PHY a complete reset
> > > of the usb host is needed. After the PHY initialization the host
> > > usb configuration registers need to be rewritten to avoid a host
> > > controller lockup.
> > >
> > > Signed-off-by: Philippe R?tornaz <philippe.retornaz@epfl.ch>
> > > ---
> > > drivers/usb/host/ehci-mxc.c | 98
> > > ++++++++++++++++++++++++++++++++++++++-----
> >
> > This patch doesn't apply anymore, can you redo it against the linux-next
> > tree?
> >
>
> It apply cleanly on next-20100512.
>
> It needs commit 5a25ad84e01173bb225285eb50f9af48ed1a7598 to apply, but this
> one is in linux-next now.
Where is that patch from? Some other tree?
confused,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG host initialisation
2010-05-12 18:50 ` Greg KH
@ 2010-05-13 17:04 ` Philippe Rétornaz
0 siblings, 0 replies; 9+ messages in thread
From: Philippe Rétornaz @ 2010-05-13 17:04 UTC (permalink / raw)
To: linux-arm-kernel
Le mercredi, 12 mai 2010 20.50:05, Greg KH a ?crit :
> On Wed, May 12, 2010 at 09:23:48AM +0200, Philippe R?tornaz wrote:
> > Le mercredi, 12 mai 2010 01.38:12, Greg KH a ?crit :
> > > On Tue, May 11, 2010 at 04:14:34PM +0200, Philippe R?tornaz wrote:
> > > > On mx31 the OTG host initialisation fails if you need to have
> > > > an ULPI transfert to initialize the PHY.
> > > >
> > > > In order to be able to communicate with the PHY a complete reset
> > > > of the usb host is needed. After the PHY initialization the host
> > > > usb configuration registers need to be rewritten to avoid a host
> > > > controller lockup.
> > > >
> > > > Signed-off-by: Philippe R?tornaz <philippe.retornaz@epfl.ch>
> > > > ---
> > > > drivers/usb/host/ehci-mxc.c | 98
> > > > ++++++++++++++++++++++++++++++++++++++-----
> > >
> > > This patch doesn't apply anymore, can you redo it against the
> > > linux-next tree?
> >
> > It apply cleanly on next-20100512.
> >
> > It needs commit 5a25ad84e01173bb225285eb50f9af48ed1a7598 to apply, but
> > this one is in linux-next now.
>
> Where is that patch from? Some other tree?
Yes, it looks like it's from the mxc-master tree:
http://git.pengutronix.de/?p=imx/linux-2.6.git;a=commitdiff;h=5a25ad84e01173bb225285eb50f9af48ed1a7598
Which has been merged inside linux-next.
Regards,
Philippe
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG host initialisation
2010-05-12 7:23 ` Philippe Rétornaz
2010-05-12 18:50 ` Greg KH
@ 2010-05-20 17:32 ` Philippe Rétornaz
2010-05-20 18:18 ` Greg KH
1 sibling, 1 reply; 9+ messages in thread
From: Philippe Rétornaz @ 2010-05-20 17:32 UTC (permalink / raw)
To: linux-arm-kernel
Hello
Any news on this patch ? Will it be merged in 2.6.35 ?
Regards,
Philippe
Le mercredi, 12 mai 2010 09.23:48, Philippe R?tornaz a ?crit :
> Le mercredi, 12 mai 2010 01.38:12, Greg KH a ?crit :
> > On Tue, May 11, 2010 at 04:14:34PM +0200, Philippe R?tornaz wrote:
> > > On mx31 the OTG host initialisation fails if you need to have
> > > an ULPI transfert to initialize the PHY.
> > >
> > > In order to be able to communicate with the PHY a complete reset
> > > of the usb host is needed. After the PHY initialization the host
> > > usb configuration registers need to be rewritten to avoid a host
> > > controller lockup.
> > >
> > > Signed-off-by: Philippe R?tornaz <philippe.retornaz@epfl.ch>
> > > ---
> > > drivers/usb/host/ehci-mxc.c | 98
> > > ++++++++++++++++++++++++++++++++++++++-----
> >
> > This patch doesn't apply anymore, can you redo it against the linux-next
> > tree?
>
> It apply cleanly on next-20100512.
>
> It needs commit 5a25ad84e01173bb225285eb50f9af48ed1a7598 to apply, but this
> one is in linux-next now.
>
> Regards,
>
> Philippe
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG host initialisation
2010-05-20 17:32 ` Philippe Rétornaz
@ 2010-05-20 18:18 ` Greg KH
2010-05-20 18:29 ` Philippe Rétornaz
0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2010-05-20 18:18 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, May 20, 2010 at 07:32:48PM +0200, Philippe R?tornaz wrote:
> Hello
>
> Any news on this patch ? Will it be merged in 2.6.35 ?
I don't have it in my tree, sorry. Is it somewhere else? Last I
recall, I couldn't apply it as it depended on some other tree, right?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG host initialisation
2010-05-20 18:18 ` Greg KH
@ 2010-05-20 18:29 ` Philippe Rétornaz
0 siblings, 0 replies; 9+ messages in thread
From: Philippe Rétornaz @ 2010-05-20 18:29 UTC (permalink / raw)
To: linux-arm-kernel
Le jeudi, 20 mai 2010 20.18:12, Greg KH a ?crit :
> On Thu, May 20, 2010 at 07:32:48PM +0200, Philippe R?tornaz wrote:
> > Hello
> >
> > Any news on this patch ? Will it be merged in 2.6.35 ?
>
> I don't have it in my tree, sorry. Is it somewhere else? Last I
> recall, I couldn't apply it as it depended on some other tree, right?
Yes, it depend on Sascha tree. Maybe Sascha should merge it by his tree ?
Thanks,
Philippe
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-05-20 18:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-11 14:14 [PATCH 0/1 v2] mx31: Fix usb otg host initialisation Philippe Rétornaz
2010-05-11 14:14 ` [PATCH 1/1 v2] ehci-mxc: Fix mx31 OTG " Philippe Rétornaz
2010-05-11 23:38 ` Greg KH
2010-05-12 7:23 ` Philippe Rétornaz
2010-05-12 18:50 ` Greg KH
2010-05-13 17:04 ` Philippe Rétornaz
2010-05-20 17:32 ` Philippe Rétornaz
2010-05-20 18:18 ` Greg KH
2010-05-20 18:29 ` Philippe Rétornaz
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).