Re: [U-Boot] [PATCH 1/6] omap4: usb: Add omap-ehci support

2011-12-15 Thread Govindraj
Hi Tom,

On Wed, Dec 14, 2011 at 9:30 PM, Tom Rini  wrote:
> On Wed, Dec 14, 2011 at 5:09 AM, Govindraj.R  wrote:
>> From: "Govindraj.R" 
> [snip]
>> +/* TLL Register Set */
>> +#define        OMAP_USBTLL_SYSCONFIG_SIDLEMODE                 (1 << 3)
>
> Globally, please fix all #define to #define.
>
>> +#define        OMAP_USBTLL_SYSCONFIG_AUTOIDLE                  (1 << 0)
>> +#define        OMAP_USBTLL_SYSSTATUS_RESETDONE                 (1 << 0)
>
> Just use '1' not '(1 << 0)', globally.
>
> [snip]
>> +++ b/drivers/usb/host/ehci-omap.c
> [snip]
>> +       reg = ULPI_FUNC_CTRL_RESET
>> +               /* FUNCTION_CTRL_SET register */
>> +               | (ULPI_SET(ULPI_FUNC_CTRL) << 
>> EHCI_INSNREG05_ULPI_REGADD_SHIFT)
>> +               /* Write */
>> +               | (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT)
>> +               /* PORTn */
>> +               | ((port + 1) << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT)
>> +               /* start ULPI access*/
>> +               | (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT);
>
> Can you please re-write this as:
> /*
>  * What these values are doing...
>  */
> reg = A | (B << B_SHIFT) | ...
>
> [snip]
>> +       /* Wait for ULPI access completion */
>> +       while ((readl(&ehci->insreg05_utmi_ulpi)
>> +               & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT)))
>> +               if (get_timer(init) > CONFIG_SYS_HZ) {
>
> Perhaps gmail is getting the indentation wrong here but it seems not
> right and the norm is to not start the newline with '&' or '|' or
> similar.
>

Thanks for the comments will fix and re-post a new version.

> [snip]
>> +       /*
>> +        * An undocumented "feature" in the OMAP3 EHCI controller,
>> +        * causes suspended ports to be taken out of suspend when
>> +        * the USBCMD.Run/Stop bit is cleared (for example when
>> +        * we do ehci_bus_suspend).
>> +        * This breaks suspend-resume if the root-hub is allowed
>> +        * to suspend. Writing 1 to this undocumented register bit
>> +        * disables this feature and restores normal behavior.
>> +        */
>
> Thank you for clearly commenting on an undocumented "feature"!
>
> Even 'tho there's changes requested already I've moved this to Remy in
> patchwork because I want his comments as the USB maintainer as well.
> Thanks!

Yes fine, I will CC him the next version,
in case if  there are no comments until I post v2.

--
Thanks,
Govindraj.R
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/6] omap4: usb: Add omap-ehci support

2011-12-14 Thread Tom Rini
On Wed, Dec 14, 2011 at 5:09 AM, Govindraj.R  wrote:
> From: "Govindraj.R" 
[snip]
> +/* TLL Register Set */
> +#define        OMAP_USBTLL_SYSCONFIG_SIDLEMODE                 (1 << 3)

Globally, please fix all #define to #define.

> +#define        OMAP_USBTLL_SYSCONFIG_AUTOIDLE                  (1 << 0)
> +#define        OMAP_USBTLL_SYSSTATUS_RESETDONE                 (1 << 0)

Just use '1' not '(1 << 0)', globally.

[snip]
> +++ b/drivers/usb/host/ehci-omap.c
[snip]
> +       reg = ULPI_FUNC_CTRL_RESET
> +               /* FUNCTION_CTRL_SET register */
> +               | (ULPI_SET(ULPI_FUNC_CTRL) << 
> EHCI_INSNREG05_ULPI_REGADD_SHIFT)
> +               /* Write */
> +               | (2 << EHCI_INSNREG05_ULPI_OPSEL_SHIFT)
> +               /* PORTn */
> +               | ((port + 1) << EHCI_INSNREG05_ULPI_PORTSEL_SHIFT)
> +               /* start ULPI access*/
> +               | (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT);

Can you please re-write this as:
/*
 * What these values are doing...
 */
reg = A | (B << B_SHIFT) | ...

[snip]
> +       /* Wait for ULPI access completion */
> +       while ((readl(&ehci->insreg05_utmi_ulpi)
> +               & (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT)))
> +               if (get_timer(init) > CONFIG_SYS_HZ) {

Perhaps gmail is getting the indentation wrong here but it seems not
right and the norm is to not start the newline with '&' or '|' or
similar.

[snip]
> +       /*
> +        * An undocumented "feature" in the OMAP3 EHCI controller,
> +        * causes suspended ports to be taken out of suspend when
> +        * the USBCMD.Run/Stop bit is cleared (for example when
> +        * we do ehci_bus_suspend).
> +        * This breaks suspend-resume if the root-hub is allowed
> +        * to suspend. Writing 1 to this undocumented register bit
> +        * disables this feature and restores normal behavior.
> +        */

Thank you for clearly commenting on an undocumented "feature"!

Even 'tho there's changes requested already I've moved this to Remy in
patchwork because I want his comments as the USB maintainer as well.
Thanks!

-- 
Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/6] omap4: usb: Add omap-ehci support

2011-12-14 Thread Govindraj
Hi Chris,

On Wed, Dec 14, 2011 at 7:08 PM, Chris Lalancette  wrote:
> On Wed, Dec 14, 2011 at 7:09 AM, Govindraj.R  wrote:
>> From: "Govindraj.R" 
>>
>> Adds ehci-omap and two funcs omap_ehci_hcd_init/omap_ehci_hcd_stop
>> Which can be called from any board file implementing the ehci_hcd_init/reset.
>> One can pass the port modes from board file and configure the usb host
>> to ulpi-phy mode or hsic mode.
>>
>> Signed-off-by: Govindraj.R 
>> ---
>>  arch/arm/include/asm/ehci-omap.h |  168 +++
>>  drivers/usb/host/Makefile        |    1 +
>>  drivers/usb/host/ehci-omap.c     |  202 
>> ++
>>  3 files changed, 371 insertions(+), 0 deletions(-)
>>  create mode 100644 arch/arm/include/asm/ehci-omap.h
>>  create mode 100644 drivers/usb/host/ehci-omap.c
>>
>> diff --git a/arch/arm/include/asm/ehci-omap.h 
>> b/arch/arm/include/asm/ehci-omap.h
>> new file mode 100644
>> index 000..c1af798
>> --- /dev/null
>> +++ b/arch/arm/include/asm/ehci-omap.h
>> @@ -0,0 +1,168 @@
> ...
>> +/* Alt CLK SRC FOR AUX CLK 3 to USB3220C external PHY */
>> +#define SCRM_ALTCLKSRC 0x4a30A110UL
>> +#define SCRM_AUXCLK3   0x4A30A31CUL
>
> I'll just point out here that the patch I recently posted to enable
> the USB hub on panda
> (http://lists.denx.de/pipermail/u-boot/2011-December/113194.html) adds
> an scrm structure that also has these registers.  Depending on which
> order the patches go in, you might want to re-use that.
>

Yes I have used your patch.

(Refer to cover letter added this series depends on your patch
http://www.mail-archive.com/u-boot@lists.denx.de/msg72797.html
)

But during cleanup forgot to remove from the header file.

Will remove this,

Thanks for pointing this out.

--
Regards,
Govindraj.R
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/6] omap4: usb: Add omap-ehci support

2011-12-14 Thread Chris Lalancette
On Wed, Dec 14, 2011 at 7:09 AM, Govindraj.R  wrote:
> From: "Govindraj.R" 
>
> Adds ehci-omap and two funcs omap_ehci_hcd_init/omap_ehci_hcd_stop
> Which can be called from any board file implementing the ehci_hcd_init/reset.
> One can pass the port modes from board file and configure the usb host
> to ulpi-phy mode or hsic mode.
>
> Signed-off-by: Govindraj.R 
> ---
>  arch/arm/include/asm/ehci-omap.h |  168 +++
>  drivers/usb/host/Makefile        |    1 +
>  drivers/usb/host/ehci-omap.c     |  202 
> ++
>  3 files changed, 371 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/include/asm/ehci-omap.h
>  create mode 100644 drivers/usb/host/ehci-omap.c
>
> diff --git a/arch/arm/include/asm/ehci-omap.h 
> b/arch/arm/include/asm/ehci-omap.h
> new file mode 100644
> index 000..c1af798
> --- /dev/null
> +++ b/arch/arm/include/asm/ehci-omap.h
> @@ -0,0 +1,168 @@
...
> +/* Alt CLK SRC FOR AUX CLK 3 to USB3220C external PHY */
> +#define SCRM_ALTCLKSRC 0x4a30A110UL
> +#define SCRM_AUXCLK3   0x4A30A31CUL

I'll just point out here that the patch I recently posted to enable
the USB hub on panda
(http://lists.denx.de/pipermail/u-boot/2011-December/113194.html) adds
an scrm structure that also has these registers.  Depending on which
order the patches go in, you might want to re-use that.

Chris Lalancette
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/6] omap4: usb: Add omap-ehci support

2011-12-14 Thread Govindraj.R
From: "Govindraj.R" 

Adds ehci-omap and two funcs omap_ehci_hcd_init/omap_ehci_hcd_stop
Which can be called from any board file implementing the ehci_hcd_init/reset.
One can pass the port modes from board file and configure the usb host
to ulpi-phy mode or hsic mode.

Signed-off-by: Govindraj.R 
---
 arch/arm/include/asm/ehci-omap.h |  168 +++
 drivers/usb/host/Makefile|1 +
 drivers/usb/host/ehci-omap.c |  202 ++
 3 files changed, 371 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/ehci-omap.h
 create mode 100644 drivers/usb/host/ehci-omap.c

diff --git a/arch/arm/include/asm/ehci-omap.h b/arch/arm/include/asm/ehci-omap.h
new file mode 100644
index 000..c1af798
--- /dev/null
+++ b/arch/arm/include/asm/ehci-omap.h
@@ -0,0 +1,168 @@
+/*
+ * OMAP EHCI port support
+ * Based on LINUX KERNEL
+ * drivers/usb/host/ehci-omap.c and drivers/mfd/omap-usb-host.c
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com*
+ * Author: Govindraj R 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef EHCI_H
+#define EHCI_H
+
+#define OMAP_EHCI_BASE (OMAP44XX_L4_CORE_BASE + 0x64C00)
+#define OMAP_UHH_BASE (OMAP44XX_L4_CORE_BASE + 0x64000)
+#define OMAP_TLL_BASE (OMAP44XX_L4_CORE_BASE + 0x62000)
+
+/* Alt CLK SRC FOR AUX CLK 3 to USB3220C external PHY */
+#define SCRM_ALTCLKSRC 0x4a30A110UL
+#define SCRM_AUXCLK3   0x4A30A31CUL
+
+/* UHH, TLL and opt clocks */
+#define CM_L3INIT_HSUSBHOST_CLKCTRL0x4A009358UL
+
+#define HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK  (1 << 24)
+
+/* ULPI */
+#define ULPI_SET(a)(a + 1)
+#define ULPI_CLR(a)(a + 2)
+
+#define ULPI_FUNC_CTRL 0x04
+
+#define ULPI_FUNC_CTRL_RESET   (1 << 5)
+
+/* TLL Register Set */
+#defineOMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
+#defineOMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
+#defineOMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
+#defineOMAP_USBTLL_SYSCONFIG_AUTOIDLE  (1 << 0)
+#defineOMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
+
+#define OMAP_REV2_TLL_CHANNEL_COUNT2
+
+#define OMAP_TLL_CHANNEL_CONF(num)  (0x004 * num)
+#define OMAP_TLL_CHANNEL_CONF_DRVVBUS   (1 << 16)
+#define OMAP_TLL_CHANNEL_CONF_CHRGVBUS  (1 << 15)
+#define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF(1 << 11)
+#define OMAP_TLL_CHANNEL_CONF_CHANMODE_TRANSPARENT_UTMI (2 << 1)
+#define OMAP_TLL_CHANNEL_CONF_CHANEN(1 << 0)
+
+/* UHH Register Set */
+#define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
+#define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
+#define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN(1 << 4)
+#define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
+#define OMAP_UHH_HOSTCONFIG_APP_START_CLK  (1 << 31)
+
+#define OMAP_UHH_SYSCONFIG_SOFTRESET   (1 << 0)
+#define OMAP_UHH_SYSCONFIG_IDLEMODE_CLEAR  (3 << 2)
+#define OMAP_UHH_SYSCONFIG_NOIDLE  (1 << 2)
+
+#define OMAP_UHH_SYSCONFIG_STDBYMODE_CLEAR (3 << 4)
+#define OMAP_UHH_SYSCONFIG_NOSTDBY (1 << 4)
+#define OMAP_UHH_SYSCONFIG_SOFTRESET   (1 << 0)
+#define OMAP_UHH_SYSSTATUS_EHCI_RESETDONE  (1 << 2)
+
+#define OMAP_P1_MODE_CLEAR (3 << 16)
+#define OMAP_P1_MODE_TLL   (1 << 16)
+#define OMAP_P1_MODE_HSIC  (3 << 16)
+#define OMAP_P2_MODE_CLEAR (3 << 18)
+#define OMAP_P2_MODE_TLL   (1 << 18)
+#define OMAP_P2_MODE_HSIC  (3 << 18)
+
+/* EHCI Register Set */
+#define EHCI_INSNREG04_DISABLE_UNSUSPEND   (1 << 5)
+#defineEHCI_INSNREG05_ULPI_CONTROL_SHIFT   31
+#defineEHCI_INSNREG05_ULPI_PORTSEL_SHIFT   24
+#defineEHCI_INSNREG05_ULPI_OPSEL_SHIFT 22
+#defineEHCI_INSNREG05_ULPI_REGADD_SHIFT16
+
+enum usbhs_omap_port_mode {
+   OMAP_USBHS_PORT_MODE_UNUSED,
+   OMAP_EHCI_PORT_MODE_PHY,
+   OMAP_EHCI_PORT_MODE_TLL,
+   OMAP_EHCI_PORT_MODE_HSIC,
+}

[U-Boot] [PATCH 1/6] omap4: usb: Add omap-ehci support

2011-12-14 Thread Govindraj.R
From: "Govindraj.R" 

Adds ehci-omap and two funcs omap_ehci_hcd_init/omap_ehci_hcd_stop
Which can be called from any board file implementing the ehci_hcd_init/reset.
One can pass the port modes from board file and configure the usb host
to ulpi-phy mode or hsic mode.

Signed-off-by: Govindraj.R 
---
 arch/arm/include/asm/ehci-omap.h |  168 +++
 drivers/usb/host/Makefile|1 +
 drivers/usb/host/ehci-omap.c |  202 ++
 3 files changed, 371 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/ehci-omap.h
 create mode 100644 drivers/usb/host/ehci-omap.c

diff --git a/arch/arm/include/asm/ehci-omap.h b/arch/arm/include/asm/ehci-omap.h
new file mode 100644
index 000..c1af798
--- /dev/null
+++ b/arch/arm/include/asm/ehci-omap.h
@@ -0,0 +1,168 @@
+/*
+ * OMAP EHCI port support
+ * Based on LINUX KERNEL
+ * drivers/usb/host/ehci-omap.c and drivers/mfd/omap-usb-host.c
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com*
+ * Author: Govindraj R 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef EHCI_H
+#define EHCI_H
+
+#define OMAP_EHCI_BASE (OMAP44XX_L4_CORE_BASE + 0x64C00)
+#define OMAP_UHH_BASE (OMAP44XX_L4_CORE_BASE + 0x64000)
+#define OMAP_TLL_BASE (OMAP44XX_L4_CORE_BASE + 0x62000)
+
+/* Alt CLK SRC FOR AUX CLK 3 to USB3220C external PHY */
+#define SCRM_ALTCLKSRC 0x4a30A110UL
+#define SCRM_AUXCLK3   0x4A30A31CUL
+
+/* UHH, TLL and opt clocks */
+#define CM_L3INIT_HSUSBHOST_CLKCTRL0x4A009358UL
+
+#define HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK  (1 << 24)
+
+/* ULPI */
+#define ULPI_SET(a)(a + 1)
+#define ULPI_CLR(a)(a + 2)
+
+#define ULPI_FUNC_CTRL 0x04
+
+#define ULPI_FUNC_CTRL_RESET   (1 << 5)
+
+/* TLL Register Set */
+#defineOMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3)
+#defineOMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2)
+#defineOMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1)
+#defineOMAP_USBTLL_SYSCONFIG_AUTOIDLE  (1 << 0)
+#defineOMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0)
+
+#define OMAP_REV2_TLL_CHANNEL_COUNT2
+
+#define OMAP_TLL_CHANNEL_CONF(num)  (0x004 * num)
+#define OMAP_TLL_CHANNEL_CONF_DRVVBUS   (1 << 16)
+#define OMAP_TLL_CHANNEL_CONF_CHRGVBUS  (1 << 15)
+#define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF(1 << 11)
+#define OMAP_TLL_CHANNEL_CONF_CHANMODE_TRANSPARENT_UTMI (2 << 1)
+#define OMAP_TLL_CHANNEL_CONF_CHANEN(1 << 0)
+
+/* UHH Register Set */
+#define OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN (1 << 2)
+#define OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN (1 << 3)
+#define OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN(1 << 4)
+#define OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN (1 << 5)
+#define OMAP_UHH_HOSTCONFIG_APP_START_CLK  (1 << 31)
+
+#define OMAP_UHH_SYSCONFIG_SOFTRESET   (1 << 0)
+#define OMAP_UHH_SYSCONFIG_IDLEMODE_CLEAR  (3 << 2)
+#define OMAP_UHH_SYSCONFIG_NOIDLE  (1 << 2)
+
+#define OMAP_UHH_SYSCONFIG_STDBYMODE_CLEAR (3 << 4)
+#define OMAP_UHH_SYSCONFIG_NOSTDBY (1 << 4)
+#define OMAP_UHH_SYSCONFIG_SOFTRESET   (1 << 0)
+#define OMAP_UHH_SYSSTATUS_EHCI_RESETDONE  (1 << 2)
+
+#define OMAP_P1_MODE_CLEAR (3 << 16)
+#define OMAP_P1_MODE_TLL   (1 << 16)
+#define OMAP_P1_MODE_HSIC  (3 << 16)
+#define OMAP_P2_MODE_CLEAR (3 << 18)
+#define OMAP_P2_MODE_TLL   (1 << 18)
+#define OMAP_P2_MODE_HSIC  (3 << 18)
+
+/* EHCI Register Set */
+#define EHCI_INSNREG04_DISABLE_UNSUSPEND   (1 << 5)
+#defineEHCI_INSNREG05_ULPI_CONTROL_SHIFT   31
+#defineEHCI_INSNREG05_ULPI_PORTSEL_SHIFT   24
+#defineEHCI_INSNREG05_ULPI_OPSEL_SHIFT 22
+#defineEHCI_INSNREG05_ULPI_REGADD_SHIFT16
+
+enum usbhs_omap_port_mode {
+   OMAP_USBHS_PORT_MODE_UNUSED,
+   OMAP_EHCI_PORT_MODE_PHY,
+   OMAP_EHCI_PORT_MODE_TLL,
+   OMAP_EHCI_PORT_MODE_HSIC,
+}