mx31: Fix usb otg host initialisation
Subsystems (3)
v2 cover mx31: Fix usb otg host initialisation
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(-)
PATCH v2 1/1 ehci-mxc: Fix mx31 OTG host initialisation
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.
--- drivers/usb/host/ehci-mxc.c | 98 ++++++++++++++++++++++++++++++++++++++----- 1 files changed, 87 insertions(+), 11 deletions(-)
drivers/usb/host/ehci-mxc.c +87 -11
@@ -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);
Signature · 1 line
1.6.3.3
PATCH v2 1/1 ehci-mxc: Fix mx31 OTG host initialisation
Quoted 11 lines · Philippe R?tornaz
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 <[email protected]>--- 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
PATCH v2 1/1 ehci-mxc: Fix mx31 OTG host initialisation
Le mercredi, 12 mai 2010 01.38:12, Greg KH a ?crit :
Quoted 9 lines · Philippe R?tornaz
Quoted 8 lines
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.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Philippe R?tornaz <[email protected]>--- 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
PATCH v2 1/1 ehci-mxc: Fix mx31 OTG host initialisation
Quoted 15 lines · Philippe R?tornaz
Le mercredi, 12 mai 2010 01.38:12, Greg KH a ?crit :
Quoted 14 lines · Philippe R?tornaz
Quoted 12 lines
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 <[email protected]>--- drivers/usb/host/ehci-mxc.c | 98++++++++++++++++++++++++++++++++++++++-----
Quoted 8 lines
Quoted 3 lines
This patch doesn't apply anymore, can you redo it against the linux-next tree?
It apply cleanly on next-20100512.
It needs commit
5a25ad84e01173bb225285eb50f9af48ed1a7598to apply, but this one is in linux-next now.
Where is that patch from? Some other tree?
confused,
greg k-h
PATCH v2 1/1 ehci-mxc: Fix mx31 OTG host initialisation
Le mercredi, 12 mai 2010 20.50:05, Greg KH a ?crit :
Quoted 19 lines · Philippe R?tornaz
Quoted 18 lines
Le mercredi, 12 mai 2010 01.38:12, Greg KH a ?crit :
Quoted 16 lines · Philippe R?tornaz
Quoted 8 lines
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.
Quoted 4 lines
Signed-off-by Philippe R?tornaz <[email protected]>--- drivers/usb/host/ehci-mxc.c | 98++++++++++++++++++++++++++++++++++++++-----
This patch doesn't apply anymore, can you redo it against the linux-next tree?
Quoted 6 lines
Quoted 4 lines
It apply cleanly on next-20100512.
It needs commit
5a25ad84e01173bb225285eb50f9af48ed1a7598to 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
PATCH v2 1/1 ehci-mxc: Fix mx31 OTG host initialisation
In reply to Philippe RétornazHello
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 :
Quoted 32 lines
Le mercredi, 12 mai 2010 01.38:12, Greg KH a ?crit :
Quoted 9 lines · Philippe R?tornaz
Quoted 8 lines
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.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Philippe R?tornaz <[email protected]>--- 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
5a25ad84e01173bb225285eb50f9af48ed1a7598to 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
PATCH v2 1/1 ehci-mxc: Fix mx31 OTG host initialisation
Quoted 3 lines · Philippe R?tornaz
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
PATCH v2 1/1 ehci-mxc: Fix mx31 OTG host initialisation
Le jeudi, 20 mai 2010 20.18:12, Greg KH a ?crit :
Quoted 7 lines · Philippe R?tornaz
Quoted 3 lines
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