Skip to contentSkip to conversation

Clean up ehci-omap and extend support for omap3/4 socs

PATCH Superseded Govindraj.R 5 participants 20 messages Feb 3, 2012 – Feb 9, 2012

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Clean up ehci-omap and extend support for omap3/4 socs

From: "Govindraj.R" <[email protected]>

Clean up ehci-omap added and make it generic to extend support for omap4 socs. Adds omap-ulpi-viewport for ulpi access from ehci-omap.
Adds ehci support for omap4-panda.

Based on latest denx master branch commit:

	137703b811502dfea364650fb3e17f20b4c21333

Changes from v2:
---------------
* Added omap-ulpi-viepwort for ulpi access.
* Fixed comments as in this thread

	http://lists.denx.de/pipermail/u-boot/2012-January/115310.html
	http://lists.denx.de/pipermail/u-boot/2012-January/116185.html

This patch series long with above dependent patch is avialable at:

	git://gitorious.org/denx_u-boot/denx_uboot_omap.git
	v3_ehci_omap4

Dependent Patch:
----------------

	http://patchwork.ozlabs.org/patch/138844/
	(omap4 boot will fail without this patch)

Govindraj.R (6):
ehci-omap: Clean up added ehci-omap.c
OMAP3+: Clock: Adding ehci clock enabling
OMAP4: clock-common: Move the usb dppl configuration to new func OMAP3+: ehci-omap: enable usb host ports for beagle/panda
usb: ulpi: Extend the existing ulpi framework.
usb: ulpi: Add omap-ulpi-view port support

Ilya Yanok (1):
ehci-omap: driver for EHCI host on OMAP3

 arch/arm/cpu/armv7/omap-common/clocks-common.c |   52 +++--
 arch/arm/cpu/armv7/omap3/board.c               |    4 +
 arch/arm/cpu/armv7/omap3/clock.c               |   20 ++
 arch/arm/cpu/armv7/omap4/clocks.c              |    5 +
 arch/arm/include/asm/arch-omap3/ehci.h         |   55 +++++
 arch/arm/include/asm/arch-omap3/ehci_omap3.h   |   58 ------
 arch/arm/include/asm/arch-omap3/sys_proto.h    |    1 +
 arch/arm/include/asm/arch-omap4/ehci.h         |   49 +++++
 arch/arm/include/asm/ehci-omap.h               |  148 ++++++++++++++
 board/efikamx/efikamx-usb.c                    |   24 ++-
 board/ti/beagle/beagle.c                       |  111 ++---------
 board/ti/panda/panda.c                         |   41 ++++
 board/ti/panda/panda_mux_data.h                |   16 +-
 doc/README.omap-ulpi-viewport                  |   27 +++
 drivers/usb/host/Makefile                      |    1 +
 drivers/usb/host/ehci-omap.c                   |  256 ++++++++++++++++++++++++
 drivers/usb/ulpi/Makefile                      |    1 +
 drivers/usb/ulpi/omap-ulpi-viewport.c          |  105 ++++++++++
 drivers/usb/ulpi/ulpi-viewport.c               |   30 ++--
 drivers/usb/ulpi/ulpi.c                        |   54 +++---
 include/configs/omap3_beagle.h                 |    6 +
 include/configs/omap4_panda.h                  |   25 +++-
 include/usb/ulpi.h                             |   36 +++-
 23 files changed, 884 insertions(+), 241 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-omap3/ehci.h
 delete mode 100644 arch/arm/include/asm/arch-omap3/ehci_omap3.h
 create mode 100644 arch/arm/include/asm/arch-omap4/ehci.h
 create mode 100644 arch/arm/include/asm/ehci-omap.h
 create mode 100644 doc/README.omap-ulpi-viewport
 create mode 100644 drivers/usb/host/ehci-omap.c
 create mode 100644 drivers/usb/ulpi/omap-ulpi-viewport.c
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH v3 1/7 ehci-omap: driver for EHCI host on OMAP3

From: Ilya Yanok <[email protected]>

Taken from Beagle code. Tested on mcx board (AM3517-based).

---
 board/ti/beagle/beagle.c       |  101 --------------------------
 drivers/usb/host/Makefile      |    1 +
 drivers/usb/host/ehci-omap.c   |  156 ++++++++++++++++++++++++++++++++++++++++
 include/configs/omap3_beagle.h |    3 +
 4 files changed, 160 insertions(+), 101 deletions(-)
 create mode 100644 drivers/usb/host/ehci-omap.c
board/ti/beagle/beagle.c +0 -101
index 5c04b34..98548ab 100644
@@ -42,15 +42,6 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/gpio.h>
 #include <asm/mach-types.h>
-#ifdef CONFIG_USB_EHCI
-#include <usb.h>
-#include <asm/arch/clocks.h>
-#include <asm/arch/clocks_omap3.h>
-#include <asm/arch/ehci_omap3.h>
-/* from drivers/usb/host/ehci-core.h */
-extern struct ehci_hccr *hccr;
-extern volatile struct ehci_hcor *hcor;
-#endif
 #include "beagle.h"
 #include <command.h>
 
@@ -445,104 +436,12 @@ int board_mmc_init(bd_t *bis)
 #endif
 
 #ifdef CONFIG_USB_EHCI
-
-#define GPIO_PHY_RESET 147
-
-/* Reset is needed otherwise the kernel-driver will throw an error. */
-int ehci_hcd_stop(void)
-{
-	pr_debug("Resetting OMAP3 EHCI\n");
-	gpio_set_value(GPIO_PHY_RESET, 0);
-	writel(OMAP_UHH_SYSCONFIG_SOFTRESET, OMAP3_UHH_BASE + OMAP_UHH_SYSCONFIG);
-	/* disable USB clocks */
-	struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
-	sr32(&prcm_base->iclken_usbhost, 0, 1, 0);
-	sr32(&prcm_base->fclken_usbhost, 0, 2, 0);
-	sr32(&prcm_base->iclken3_core, 2, 1, 0);
-	sr32(&prcm_base->fclken3_core, 2, 1, 0);
-	return 0;
-}
-
 /* Call usb_stop() before starting the kernel */
 void show_boot_progress(int val)
 {
 	if(val == 15)
 		usb_stop();
 }
-
-/*
- * Initialize the OMAP3 EHCI controller and PHY on the BeagleBoard.
- * Based on "drivers/usb/host/ehci-omap.c" from Linux 2.6.37.
- * See there for additional Copyrights.
- */
-int ehci_hcd_init(void)
-{
-	pr_debug("Initializing OMAP3 ECHI\n");
-
-	/* Put the PHY in RESET */
-	gpio_request(GPIO_PHY_RESET, "");
-	gpio_direction_output(GPIO_PHY_RESET, 0);
-	gpio_set_value(GPIO_PHY_RESET, 0);
-
-	/* Hold the PHY in RESET for enough time till DIR is high */
-	/* Refer: ISSUE1 */
-	udelay(10);
-
-	struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
-	/* Enable USBHOST_L3_ICLK (USBHOST_MICLK) */
-	sr32(&prcm_base->iclken_usbhost, 0, 1, 1);
-	/*
-	 * Enable USBHOST_48M_FCLK (USBHOST_FCLK1)
-	 * and USBHOST_120M_FCLK (USBHOST_FCLK2)
-	 */
-	sr32(&prcm_base->fclken_usbhost, 0, 2, 3);
-	/* Enable USBTTL_ICLK */
-	sr32(&prcm_base->iclken3_core, 2, 1, 1);
-	/* Enable USBTTL_FCLK */
-	sr32(&prcm_base->fclken3_core, 2, 1, 1);
-	pr_debug("USB clocks enabled\n");
-
-	/* perform TLL soft reset, and wait until reset is complete */
-	writel(OMAP_USBTLL_SYSCONFIG_SOFTRESET,
-		OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSCONFIG);
-	/* Wait for TLL reset to complete */
-	while (!(readl(OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSSTATUS)
-			& OMAP_USBTLL_SYSSTATUS_RESETDONE));
-	pr_debug("TLL reset done\n");
-
-	writel(OMAP_USBTLL_SYSCONFIG_ENAWAKEUP |
-		OMAP_USBTLL_SYSCONFIG_SIDLEMODE |
-		OMAP_USBTLL_SYSCONFIG_CACTIVITY,
-		OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSCONFIG);
-
-	/* Put UHH in NoIdle/NoStandby mode */
-	writel(OMAP_UHH_SYSCONFIG_ENAWAKEUP
-		| OMAP_UHH_SYSCONFIG_SIDLEMODE
-		| OMAP_UHH_SYSCONFIG_CACTIVITY
-		| OMAP_UHH_SYSCONFIG_MIDLEMODE,
-		OMAP3_UHH_BASE + OMAP_UHH_SYSCONFIG);
-
-	/* setup burst configurations */
-	writel(OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
-		| OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
-		| OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN,
-		OMAP3_UHH_BASE + OMAP_UHH_HOSTCONFIG);
-
-	/*
-	 * Refer ISSUE1:
-	 * Hold the PHY in RESET for enough time till
-	 * PHY is settled and ready
-	 */
-	udelay(10);
-	gpio_set_value(GPIO_PHY_RESET, 1);
-
-	hccr = (struct ehci_hccr *)(OMAP3_EHCI_BASE);
-	hcor = (struct ehci_hcor *)(OMAP3_EHCI_BASE + 0x10);
-
-	pr_debug("OMAP3 EHCI init done\n");
-	return 0;
-}
-
 #endif /* CONFIG_USB_EHCI */
 
 #ifndef CONFIG_SPL_BUILD
drivers/usb/host/Makefile +1 -0
index 77e217f..975c3e5 100644
@@ -43,6 +43,7 @@ endif
 COBJS-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
 COBJS-$(CONFIG_USB_EHCI_MXS) += ehci-mxs.o
 COBJS-$(CONFIG_USB_EHCI_MX5) += ehci-mx5.o
+COBJS-$(CONFIG_USB_EHCI_OMAP) += ehci-omap.o
 COBJS-$(CONFIG_USB_EHCI_PPC4XX) += ehci-ppc4xx.o
 COBJS-$(CONFIG_USB_EHCI_IXP4XX) += ehci-ixp.o
 COBJS-$(CONFIG_USB_EHCI_KIRKWOOD) += ehci-kirkwood.o
drivers/usb/host/ehci-omap.c new file +156 -0

156 lines not on this page · raw message

include/configs/omap3_beagle.h +3 -0
index 91af8a0..b4d6443 100644
@@ -129,6 +129,9 @@
 /* USB EHCI */
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_OMAP
+/*#define CONFIG_EHCI_DCACHE*/ /* leave it disabled for now */
+#define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO	147
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
 #define CONFIG_USB_HOST_ETHER
 #define CONFIG_USB_ETHER_SMSC95XX
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH v3 2/7 ehci-omap: Clean up added ehci-omap.c

In reply to Govindraj.R

From: "Govindraj.R" <[email protected]>

Clean up added ehci-omap.c and make it generic for re-use across omap-soc having same ehci ip block. Also pass the modes to be configured from board file and configure the ports accordingly. All usb layers are not cache aligned, till then keep cache off for usb ops as ehci will use internally dma for all usb ops.

* Add a generic common header ehci-omap.h having common ip block data and reg shifts.
* Rename and modify ehci-omap3 to ehci.h retain only conflicting sysc reg shifts remove others and move to common header file.

---
 arch/arm/include/asm/arch-omap3/ehci.h       |   55 +++++++
 arch/arm/include/asm/arch-omap3/ehci_omap3.h |   58 -------
 arch/arm/include/asm/arch-omap4/ehci.h       |   49 ++++++
 arch/arm/include/asm/ehci-omap.h             |  148 ++++++++++++++++++
 drivers/usb/host/ehci-omap.c                 |  212 +++++++++++++++++++-------
 5 files changed, 408 insertions(+), 114 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-omap3/ehci.h
 delete mode 100644 arch/arm/include/asm/arch-omap3/ehci_omap3.h
 create mode 100644 arch/arm/include/asm/arch-omap4/ehci.h
 create mode 100644 arch/arm/include/asm/ehci-omap.h
arch/arm/include/asm/arch-omap3/ehci.h new file +55 -0
new file mode 100644
index 0000000..0f73d20
@@ -0,0 +1,55 @@
+/*
+ * (C) Copyright 2011
+ * Alexander Holler <[email protected]>
+ *
+ * Based on "drivers/usb/host/ehci-omap.c" from Linux 2.6.37
+ *
+ * See there for additional Copyrights.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+#ifndef _OMAP3_EHCI_H_
+#define _OMAP3_EHCI_H_
+
+/* USB/EHCI registers */
+#define OMAP_USBTLL_BASE				0x48062000UL
+#define OMAP_UHH_BASE					0x48064000UL
+#define OMAP_EHCI_BASE					0x48064800UL
+
+/* TLL Register Set */
+#define OMAP_USBTLL_SYSCONFIG_SOFTRESET			(1 << 1)
+#define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP			(1 << 2)
+#define OMAP_USBTLL_SYSCONFIG_SIDLEMODE			(1 << 3)
+#define OMAP_USBTLL_SYSCONFIG_CACTIVITY			(1 << 8)
+#define OMAP_USBTLL_SYSSTATUS_RESETDONE			1
+
+/* UHH Register Set */
+#define OMAP_UHH_SYSCONFIG_SOFTRESET			(1 << 1)
+#define OMAP_UHH_SYSCONFIG_CACTIVITY			(1 << 8)
+#define OMAP_UHH_SYSCONFIG_SIDLEMODE			(1 << 3)
+#define OMAP_UHH_SYSCONFIG_ENAWAKEUP			(1 << 2)
+#define OMAP_UHH_SYSCONFIG_MIDLEMODE			(1 << 12)
+#define OMAP_UHH_SYSSTATUS_EHCI_RESETDONE		(1 << 2)
+
+#define OMAP_UHH_SYSCONFIG_VAL		(OMAP_UHH_SYSCONFIG_CACTIVITY | \
+					OMAP_UHH_SYSCONFIG_SIDLEMODE | \
+					OMAP_UHH_SYSCONFIG_ENAWAKEUP | \
+					OMAP_UHH_SYSCONFIG_MIDLEMODE)
+
+#endif /* _OMAP3_EHCI_H_ */
arch/arm/include/asm/arch-omap3/ehci_omap3.h deleted +0 -58

58 lines not on this page · raw message

arch/arm/include/asm/arch-omap4/ehci.h new file +49 -0

49 lines not on this page · raw message

arch/arm/include/asm/ehci-omap.h new file +148 -0

148 lines not on this page · raw message

drivers/usb/host/ehci-omap.c +156 -56

253 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#3 lore raw

PATCH v3 2/7 ehci-omap: Clean up added ehci-omap.c

Quoted 8 lines · Govindraj.R

From: "Govindraj.R" <[email protected]>

Clean up added ehci-omap.c and make it generic for re-use across omap-soc having same ehci ip block. Also pass the modes to be configured from board file and configure the ports accordingly. All usb layers are not cache aligned, till then keep cache off for usb ops as ehci will use internally dma for all usb ops.

Quoted 6 lines

* Add a generic common header ehci-omap.h having common ip block data and reg shifts.
* Rename and modify ehci-omap3 to ehci.h retain only conflicting sysc reg shifts remove others and move to common header file.

Some final neats below, otherwise:

Quoted 11 lines
---
 arch/arm/include/asm/arch-omap3/ehci.h       |   55 +++++++
 arch/arm/include/asm/arch-omap3/ehci_omap3.h |   58 -------
 arch/arm/include/asm/arch-omap4/ehci.h       |   49 ++++++
 arch/arm/include/asm/ehci-omap.h             |  148 ++++++++++++++++++
 drivers/usb/host/ehci-omap.c                 |  212 +++++++++++++++++++-------
 5 files changed, 408 insertions(+), 114 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-omap3/ehci.h
 delete mode 100644 arch/arm/include/asm/arch-omap3/ehci_omap3.h
 create mode 100644 arch/arm/include/asm/arch-omap4/ehci.h
 create mode 100644 arch/arm/include/asm/ehci-omap.h

[...]

Quoted 5 lines
arch/arm/include/asm/ehci-omap.h new file +0 -0
new file mode 100644
index 0000000..c99ac20

[...]

arch/arm/include/asm/ehci-omap.h line 87

Quoted 6 lines
arch/arm/include/asm/ehci-omap.h new file +6 -0
+
+/* 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)

The above should be removed as it is not used anymore.

arch/arm/include/asm/ehci-omap.h line 96

Quoted 9 lines
arch/arm/include/asm/ehci-omap.h new file +9 -0
+
+struct omap_usbhs_board_data {
+	enum usbhs_omap_port_mode port_mode[OMAP_HS_USB_PORTS];
+};
+
+struct omap_usbtll {
+	u32 rev;		/* 0x00 */
+	u32 hwinfo;		/* 0x04 */
+	u8 reserved1[0x8];

Are you sure you want this to be an array of bytes instead of register (u32) wide fields?
IMO,
u32 reserved1[2];

looks much better than:
u8 reserved1[0x8];

and does not have alignment issues, but if you think u8 is better, I will not object.

Quoted 52 lines
arch/arm/include/asm/ehci-omap.h new file +52 -0
+	u32 sysc;		/* 0x10 */
+	u32 syss;		/* 0x14 */
+	u32 irqst;		/* 0x18 */
+	u32 irqen;		/* 0x1c */
+	u8 reserved2[0x10];
+	u32 shared_conf;	/* 0x30 */
+	u8 reserved3[0xc];
+	u32 channel_conf;	/* 0x40 */
+};
+
+struct omap_uhh {
+	u32 rev;	/* 0x00 */
+	u32 hwinfo;	/* 0x04 */
+	u8 reserved1[0x8];
+	u32 sysc;	/* 0x10 */
+	u32 syss;	/* 0x14 */
+	u8 reserved2[0x28];
+	u32 hostconfig;	/* 0x40 */
+	u32 debugcsr;	/* 0x44 */
+};
+
+struct omap_ehci {
+	u32 hccapbase;		/* 0x00 */
+	u32 hcsparams;		/* 0x04 */
+	u32 hccparams;		/* 0x08 */
+	u8 reserved1[0x04];
+	u32 usbcmd;		/* 0x10 */
+	u32 usbsts;		/* 0x14 */
+	u32 usbintr;		/* 0x18 */
+	u32 frindex;		/* 0x1c */
+	u32 ctrldssegment;	/* 0x20 */
+	u32 periodiclistbase;	/* 0x24 */
+	u32 asysnclistaddr;	/* 0x28 */
+	u8 reserved2[0x24];
+	u32 configflag;		/* 0x50 */
+	u32 portsc_i;		/* 0x54 */
+	u8 reserved3[0x38];
+	u32 insreg00;		/* 0x90 */
+	u32 insreg01;		/* 0x94 */
+	u32 insreg02;		/* 0x98 */
+	u32 insreg03;		/* 0x9c */
+	u32 insreg04;		/* 0xa0 */
+	u32 insreg05_utmi_ulpi;	/* 0xa4 */
+	u32 insreg06;		/* 0xa8 */
+	u32 insreg07;		/* 0xac */
+	u32 insreg08;		/* 0xb0 */
+};
+
+int omap_ehci_hcd_init(struct omap_usbhs_board_data *usbhs_pdata);
+int omap_ehci_hcd_stop(void);
+
+#endif /* _OMAP_COMMON_EHCI_H_ */

[...]

Quoted 4 lines
drivers/usb/host/ehci-omap.c +0 -0
index 93d3bb7..89c3c3a 100644

[...]

drivers/usb/host/ehci-omap.c line 100

Quoted 9 lines
drivers/usb/host/ehci-omap.c +9 -0
+static void omap_ehci_soft_phy_reset(int port)
+{
+	struct ulpi_viewport ulpi_vp;
+
+	ulpi_vp.viewport_addr = (u32)&ehci->insreg05_utmi_ulpi;
+	ulpi_vp.port_num = port;
+
+	ulpi_reset(&ulpi_vp);
+

no need for the empty line here

Quoted 2 lines
drivers/usb/host/ehci-omap.c +2 -0
+}
+

[...]

drivers/usb/host/ehci-omap.c static inline void omap_ehci_phy_reset(int on, int delay) · line 162

Quoted 13 lines

/*
- * Initialize the OMAP3 EHCI controller and PHY.
- * Based on "drivers/usb/host/ehci-omap.c" from Linux 2.6.37.
+ * Initialize the OMAP EHCI controller and PHY.
+ * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1
* See there for additional Copyrights.
*/

drivers/usb/host/ehci-omap.c +3 -2
-int ehci_hcd_init(void)
+int omap_ehci_hcd_init(struct omap_usbhs_board_data *usbhs_pdata)
 {
-	int ret;
+	int ret = 0;
+	unsigned int i, reg = 0, rev = 0;

no need to initialize ret here, it is done below.

Quoted 6 lines
drivers/usb/host/ehci-omap.c +1 -1
-	debug("Initializing OMAP3 EHCI\n");
+	debug("Initializing OMAP EHCI\n");
 
 	ret = board_usb_init();
 	if (ret < 0)

[...]

Signature · 2 lines
Regards,
Igor.
#4 lore raw

PATCH v3 3/7 OMAP3+: Clock: Adding ehci clock enabling

In reply to Govindraj.R

From: "Govindraj.R" <[email protected]>

Adding ehci clock enabling mechanism part of clock framework. When essential clocks are enabled during init phase usb host clocks can also be enabled from clock framework.

---
 arch/arm/cpu/armv7/omap3/board.c            |    4 ++++
 arch/arm/cpu/armv7/omap3/clock.c            |   20 ++++++++++++++++++++
 arch/arm/cpu/armv7/omap4/clocks.c           |    5 +++++
 arch/arm/include/asm/arch-omap3/sys_proto.h |    1 +
 4 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/omap3/board.c +4 -0
index 871aa37..054e9c4 100644
@@ -228,6 +228,10 @@ void s_init(void)
 
 	per_clocks_enable();
 
+#ifdef CONFIG_USB_EHCI_OMAP
+	ehci_clocks_enable();
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 	preloader_console_init();
 
arch/arm/cpu/armv7/omap3/clock.c +20 -0
index e0d65c7..567817e 100644
@@ -626,6 +626,26 @@ void prcm_init(void)
 	sdelay(5000);
 }
 
+/*
+ * Enable usb ehci uhh, tll clocks
+ */
+void ehci_clocks_enable(void)
+{
+	struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
+
+	/* Enable USBHOST_L3_ICLK (USBHOST_MICLK) */
+	sr32(&prcm_base->iclken_usbhost, 0, 1, 1);
+	/*
+	 * Enable USBHOST_48M_FCLK (USBHOST_FCLK1)
+	 * and USBHOST_120M_FCLK (USBHOST_FCLK2)
+	 */
+	sr32(&prcm_base->fclken_usbhost, 0, 2, 3);
+	/* Enable USBTTL_ICLK */
+	sr32(&prcm_base->iclken3_core, 2, 1, 1);
+	/* Enable USBTTL_FCLK */
+	sr32(&prcm_base->fclken3_core, 2, 1, 1);
+}
+
 /******************************************************************************
  * peripheral_enable() - Enable the clks & power for perifs (GPT2, UART1,...)
  *****************************************************************************/
arch/arm/cpu/armv7/omap4/clocks.c +5 -0
index 0886f92..12e283a 100644
@@ -342,6 +342,9 @@ void enable_basic_clocks(void)
 		&prcm->cm_l4per_gpio4_clkctrl,
 		&prcm->cm_l4per_gpio5_clkctrl,
 		&prcm->cm_l4per_gpio6_clkctrl,
+		&prcm->cm_l3init_usbphy_clkctrl,
+		&prcm->cm_clksel_usb_60mhz,
+		&prcm->cm_l3init_hsusbtll_clkctrl,
 		0
 	};
 
@@ -352,6 +355,8 @@ void enable_basic_clocks(void)
 		&prcm->cm_l4per_gptimer2_clkctrl,
 		&prcm->cm_wkup_wdtimer2_clkctrl,
 		&prcm->cm_l4per_uart3_clkctrl,
+		&prcm->cm_l3init_fsusb_clkctrl,
+		&prcm->cm_l3init_hsusbhost_clkctrl,
 		0
 	};
 
arch/arm/include/asm/arch-omap3/sys_proto.h +1 -0
index e5031d5..2a89e56 100644
@@ -34,6 +34,7 @@ struct emu_hal_params {
 
 void prcm_init(void);
 void per_clocks_enable(void);
+void ehci_clocks_enable(void);
 
 void memif_init(void);
 void sdrc_init(void);
Signature · 1 line
1.7.5.4
#5 lore raw

PATCH v3 3/7 OMAP3+: Clock: Adding ehci clock enabling

Quoted 7 lines · Govindraj.R

From: "Govindraj.R" <[email protected]>

Adding ehci clock enabling mechanism part of clock framework. When essential clocks are enabled during init phase usb host clocks can also be enabled from clock framework.

Quoted 12 lines
---
 arch/arm/cpu/armv7/omap3/board.c            |    4 ++++
 arch/arm/cpu/armv7/omap3/clock.c            |   20 ++++++++++++++++++++
 arch/arm/cpu/armv7/omap4/clocks.c           |    5 +++++
 arch/arm/include/asm/arch-omap3/sys_proto.h |    1 +
 4 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/omap3/board.c +0 -0
index 871aa37..054e9c4 100644

arch/arm/cpu/armv7/omap3/board.c void s_init(void) · line 233

Quoted 6 lines
arch/arm/cpu/armv7/omap3/board.c +3 -0
@@ -228,6 +228,10 @@ void s_init(void)
 
 	per_clocks_enable();
 
+#ifdef CONFIG_USB_EHCI_OMAP
+	ehci_clocks_enable();
+#endif

Just a question (not blocking):
I would really like to see this being a part of "usb start" call some day... Can't this be called from omap_ehci_hcd_init()?

Quoted 70 lines
arch/arm/cpu/armv7/omap3/board.c +1 -0
+
 #ifdef CONFIG_SPL_BUILD
 	preloader_console_init();
 
arch/arm/cpu/armv7/omap3/clock.c +20 -0
index e0d65c7..567817e 100644
@@ -626,6 +626,26 @@ void prcm_init(void)
 	sdelay(5000);
 }
 
+/*
+ * Enable usb ehci uhh, tll clocks
+ */
+void ehci_clocks_enable(void)
+{
+	struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
+
+	/* Enable USBHOST_L3_ICLK (USBHOST_MICLK) */
+	sr32(&prcm_base->iclken_usbhost, 0, 1, 1);
+	/*
+	 * Enable USBHOST_48M_FCLK (USBHOST_FCLK1)
+	 * and USBHOST_120M_FCLK (USBHOST_FCLK2)
+	 */
+	sr32(&prcm_base->fclken_usbhost, 0, 2, 3);
+	/* Enable USBTTL_ICLK */
+	sr32(&prcm_base->iclken3_core, 2, 1, 1);
+	/* Enable USBTTL_FCLK */
+	sr32(&prcm_base->fclken3_core, 2, 1, 1);
+}
+
 /******************************************************************************
  * peripheral_enable() - Enable the clks & power for perifs (GPT2, UART1,...)
  *****************************************************************************/
arch/arm/cpu/armv7/omap4/clocks.c +5 -0
index 0886f92..12e283a 100644
@@ -342,6 +342,9 @@ void enable_basic_clocks(void)
 		&prcm->cm_l4per_gpio4_clkctrl,
 		&prcm->cm_l4per_gpio5_clkctrl,
 		&prcm->cm_l4per_gpio6_clkctrl,
+		&prcm->cm_l3init_usbphy_clkctrl,
+		&prcm->cm_clksel_usb_60mhz,
+		&prcm->cm_l3init_hsusbtll_clkctrl,
 		0
 	};
 
@@ -352,6 +355,8 @@ void enable_basic_clocks(void)
 		&prcm->cm_l4per_gptimer2_clkctrl,
 		&prcm->cm_wkup_wdtimer2_clkctrl,
 		&prcm->cm_l4per_uart3_clkctrl,
+		&prcm->cm_l3init_fsusb_clkctrl,
+		&prcm->cm_l3init_hsusbhost_clkctrl,
 		0
 	};
 
arch/arm/include/asm/arch-omap3/sys_proto.h +1 -0
index e5031d5..2a89e56 100644
@@ -34,6 +34,7 @@ struct emu_hal_params {
 
 void prcm_init(void);
 void per_clocks_enable(void);
+void ehci_clocks_enable(void);
 
 void memif_init(void);
 void sdrc_init(void);
Signature · 2 lines
Regards,
Igor.
#6 lore raw

PATCH v3 3/7 OMAP3+: Clock: Adding ehci clock enabling

Quoted 26 lines · Igor Grinberg
Quoted 7 lines · Govindraj.R

From: "Govindraj.R" <[email protected]>

Adding ehci clock enabling mechanism part of clock framework. When essential clocks are enabled during init phase usb host clocks can also be enabled from clock framework.

Quoted 15 lines

---

?arch/arm/cpu/armv7/omap3/board.c ? ? ? ? ? ?| ? ?4 ++++
?arch/arm/cpu/armv7/omap3/clock.c ? ? ? ? ? ?| ? 20 ++++++++++++++++++++
?arch/arm/cpu/armv7/omap4/clocks.c ? ? ? ? ? | ? ?5 +++++
?arch/arm/include/asm/arch-omap3/sys_proto.h | ? ?1 +

?4 files changed, 30 insertions(+), 0 deletions(-)

arch/arm/cpu/armv7/omap3/board.c +0 -0
index 871aa37..054e9c4 100644
@@ -228,6 +228,10 @@ void s_init(void)
 
 ? ? ? per_clocks_enable();
 
Quoted 7 lines

arch/arm/cpu/armv7/omap3/board.c void s_init(void) · line 233

Quoted 3 lines
arch/arm/cpu/armv7/omap3/board.c +3 -0
+#ifdef CONFIG_USB_EHCI_OMAP
+ ? ? ehci_clocks_enable();
+#endif

Just a question (not blocking):
I would really like to see this being a part of "usb start" call some day... Can't this be called from omap_ehci_hcd_init()?

But its better to have it part of clock framework.

on omap4 I have added this part of enabling essential clocks done part of clock framework.

"arch/arm/cpu/armv7/omap[4/5]/clocks.c" => "arch/arm/cpu/armv7/omap-common/clocks-common.c"

but on omap3 we don't seem to use clocks common. so I have just used this function.

on omap4/5 clocks.c makes things simpler for us. (re-use the same rather to complicate with our funcs)

--
Thanks,
Govindraj.R

#7 lore raw

PATCH v3 3/7 OMAP3+: Clock: Adding ehci clock enabling

Quoted 40 lines · Govindraj
Quoted 26 lines · Igor Grinberg
Quoted 7 lines · Govindraj.R

From: "Govindraj.R" <[email protected]>

Adding ehci clock enabling mechanism part of clock framework. When essential clocks are enabled during init phase usb host clocks can also be enabled from clock framework.

Quoted 15 lines
---
 arch/arm/cpu/armv7/omap3/board.c            |    4 ++++
 arch/arm/cpu/armv7/omap3/clock.c            |   20 ++++++++++++++++++++
 arch/arm/cpu/armv7/omap4/clocks.c           |    5 +++++
 arch/arm/include/asm/arch-omap3/sys_proto.h |    1 +
 4 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/omap3/board.c +0 -0
index 871aa37..054e9c4 100644
@@ -228,6 +228,10 @@ void s_init(void)
 
      per_clocks_enable();
 
Quoted 7 lines

arch/arm/cpu/armv7/omap3/board.c void s_init(void) · line 233

Quoted 3 lines
arch/arm/cpu/armv7/omap3/board.c +3 -0
+#ifdef CONFIG_USB_EHCI_OMAP
+     ehci_clocks_enable();
+#endif

Just a question (not blocking):
I would really like to see this being a part of "usb start" call some day... Can't this be called from omap_ehci_hcd_init()?

But its better to have it part of clock framework.

on omap4 I have added this part of enabling essential clocks done part of clock framework.

Quoted 8 lines

"arch/arm/cpu/armv7/omap[4/5]/clocks.c" => "arch/arm/cpu/armv7/omap-common/clocks-common.c"

but on omap3 we don't seem to use clocks common. so I have just used this function.

on omap4/5 clocks.c makes things simpler for us. (re-use the same rather to complicate with our funcs)

Yes, I understand, it is indeed simpler.
I'm trying also to see this from the final product POV, where things like power consumption and supermarket principle (pay only for what you buy) can meter.
Again, this is fine (I already acked the patch), just wanted to know how difficult would it be to get it fine tuned for "usb start/stop".

Thanks

Signature · 2 lines
Regards,
Igor.
#8 lore raw

PATCH v3 4/7 OMAP4: clock-common: Move the usb dppl configuration to new func

In reply to Govindraj.R

From: "Govindraj.R" <[email protected]>

usb dpll configuration is done only part of non-essential dppl configuration however if CONFIG_USB_EHCI_OMAP is defined we may have to configure usb dpll's for proper functioning of usb modules. So move the usb dppl configuration to a new func. and utilise the same during essential dpll configuration.

---
 arch/arm/cpu/armv7/omap-common/clocks-common.c |   52 ++++++++++++++---------
 1 files changed, 32 insertions(+), 20 deletions(-)
arch/arm/cpu/armv7/omap-common/clocks-common.c +32 -20
index 1da90a4..770ac19 100644
@@ -251,6 +251,33 @@ void configure_mpu_dpll(void)
 	debug("MPU DPLL locked\n");
 }
 
+static void setup_usb_dpll(void)
+{
+	const struct dpll_params *params;
+	u32 sys_clk_khz, sd_div, num, den;
+
+	sys_clk_khz = get_sys_clk_freq() / 1000;
+	/*
+	 * USB:
+	 * USB dpll is J-type. Need to set DPLL_SD_DIV for jitter correction
+	 * DPLL_SD_DIV = CEILING ([DPLL_MULT/(DPLL_DIV+1)]* CLKINP / 250)
+	 *      - where CLKINP is sys_clk in MHz
+	 * Use CLKINP in KHz and adjust the denominator accordingly so
+	 * that we have enough accuracy and at the same time no overflow
+	 */
+	params = get_usb_dpll_params();
+	num = params->m * sys_clk_khz;
+	den = (params->n + 1) * 250 * 1000;
+	num += den - 1;
+	sd_div = num / den;
+	clrsetbits_le32(&prcm->cm_clksel_dpll_usb,
+			CM_CLKSEL_DPLL_DPLL_SD_DIV_MASK,
+			sd_div << CM_CLKSEL_DPLL_DPLL_SD_DIV_SHIFT);
+
+	/* Now setup the dpll with the regular function */
+	do_setup_dpll(&prcm->cm_clkmode_dpll_usb, params, DPLL_LOCK, "usb");
+}
+
 static void setup_dplls(void)
 {
 	u32 temp;
@@ -282,13 +309,16 @@ static void setup_dplls(void)
 
 	/* MPU dpll */
 	configure_mpu_dpll();
+
+#ifdef CONFIG_USB_EHCI_OMAP
+	setup_usb_dpll();
+#endif
 }
 
 #ifdef CONFIG_SYS_CLOCKS_ENABLE_ALL
 static void setup_non_essential_dplls(void)
 {
 	u32 sys_clk_khz, abe_ref_clk;
-	u32 sd_div, num, den;
 	const struct dpll_params *params;
 
 	sys_clk_khz = get_sys_clk_freq() / 1000;
@@ -300,25 +330,7 @@ static void setup_non_essential_dplls(void)
 	params = get_iva_dpll_params();
 	do_setup_dpll(&prcm->cm_clkmode_dpll_iva, params, DPLL_LOCK, "iva");
 
-	/*
-	 * USB:
-	 * USB dpll is J-type. Need to set DPLL_SD_DIV for jitter correction
-	 * DPLL_SD_DIV = CEILING ([DPLL_MULT/(DPLL_DIV+1)]* CLKINP / 250)
-	 *      - where CLKINP is sys_clk in MHz
-	 * Use CLKINP in KHz and adjust the denominator accordingly so
-	 * that we have enough accuracy and at the same time no overflow
-	 */
-	params = get_usb_dpll_params();
-	num = params->m * sys_clk_khz;
-	den = (params->n + 1) * 250 * 1000;
-	num += den - 1;
-	sd_div = num / den;
-	clrsetbits_le32(&prcm->cm_clksel_dpll_usb,
-			CM_CLKSEL_DPLL_DPLL_SD_DIV_MASK,
-			sd_div << CM_CLKSEL_DPLL_DPLL_SD_DIV_SHIFT);
-
-	/* Now setup the dpll with the regular function */
-	do_setup_dpll(&prcm->cm_clkmode_dpll_usb, params, DPLL_LOCK, "usb");
+	setup_usb_dpll();
 
 	/* Configure ABE dpll */
 	params = get_abe_dpll_params();
Signature · 1 line
1.7.5.4
#9 lore raw

PATCH v3 5/7 OMAP3+: ehci-omap: enable usb host ports for beagle/panda

In reply to Govindraj.R

From: "Govindraj.R" <[email protected]>

For beagle and panda enable and use the ehci-omap.c generic api's added to configure usb host ports based on data passed from board file to configure in modes as specified from board data. For panda initialise the mux pins for ehci usage.

---
 board/ti/beagle/beagle.c        |   28 ++++++++++++++++++++++++++
 board/ti/panda/panda.c          |   41 +++++++++++++++++++++++++++++++++++++++
 board/ti/panda/panda_mux_data.h |   16 +++++++-------
 include/configs/omap4_panda.h   |   23 ++++++++++++++++++++-
 4 files changed, 99 insertions(+), 9 deletions(-)
board/ti/beagle/beagle.c +28 -0
index 98548ab..5031cf2 100644
@@ -45,6 +45,11 @@
 #include "beagle.h"
 #include <command.h>
 
+#ifdef CONFIG_USB_EHCI
+#include <usb.h>
+#include <asm/ehci-omap.h>
+#endif
+
 #define pr_debug(fmt, args...) debug(fmt, ##args)
 
 #define TWL4030_I2C_BUS			0
@@ -442,6 +447,29 @@ void show_boot_progress(int val)
 	if(val == 15)
 		usb_stop();
 }
+
+static struct omap_usbhs_board_data usbhs_bdata = {
+	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
+	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
+	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
+};
+
+int ehci_hcd_init(void)
+{
+	int ret = 0;
+
+	ret = omap_ehci_hcd_init(&usbhs_bdata);
+	return ret;
+}
+
+int ehci_hcd_stop(void)
+{
+	int ret;
+
+	ret = omap_ehci_hcd_stop();
+	return ret;
+}
+
 #endif /* CONFIG_USB_EHCI */
 
 #ifndef CONFIG_SPL_BUILD
board/ti/panda/panda.c +41 -0

56 lines not on this page · raw message

board/ti/panda/panda_mux_data.h +8 -8
index 2970ccd..5b66a14 100644
@@ -136,14 +136,14 @@ const struct pad_conf_entry core_padconf_array_non_essential[] = {
 	{CAM_SHUTTER, (OFF_EN | OFF_PD | OFF_OUT_PTD | M0)},		/* cam_shutter */
 	{CAM_STROBE, (OFF_EN | OFF_PD | OFF_OUT_PTD | M0)},		/* cam_strobe */
 	{CAM_GLOBALRESET, (PTD | OFF_EN | OFF_PD | OFF_OUT_PTD | M3)},	/* gpio_83 */
-	{USBB1_ULPITLL_CLK, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cawake */
-	{USBB1_ULPITLL_STP, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_cadata */
-	{USBB1_ULPITLL_DIR, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caflag */
-	{USBB1_ULPITLL_NXT, (OFF_EN | M1)},				/* hsi1_acready */
-	{USBB1_ULPITLL_DAT0, (OFF_EN | M1)},				/* hsi1_acwake */
-	{USBB1_ULPITLL_DAT1, (OFF_EN | M1)},				/* hsi1_acdata */
-	{USBB1_ULPITLL_DAT2, (OFF_EN | M1)},				/* hsi1_acflag */
-	{USBB1_ULPITLL_DAT3, (IEN | OFF_EN | OFF_IN | M1)},		/* hsi1_caready */
+	{USBB1_ULPITLL_CLK, (PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M4)},/* usbb1_ulpiphy_clk */
+	{USBB1_ULPITLL_STP, (OFF_EN | OFF_OUT_PTD | M4)},		/* usbb1_ulpiphy_stp */
+	{USBB1_ULPITLL_DIR, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_dir */
+	{USBB1_ULPITLL_NXT, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_nxt */
+	{USBB1_ULPITLL_DAT0, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_dat0 */
+	{USBB1_ULPITLL_DAT1, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_dat1 */
+	{USBB1_ULPITLL_DAT2, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_dat2 */
+	{USBB1_ULPITLL_DAT3, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_dat3 */
 	{USBB1_ULPITLL_DAT4, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_dat4 */
 	{USBB1_ULPITLL_DAT5, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_dat5 */
 	{USBB1_ULPITLL_DAT6, (IEN | OFF_EN | OFF_PD | OFF_IN | M4)},	/* usbb1_ulpiphy_dat6 */
include/configs/omap4_panda.h +22 -1
index e9ef2a3..23c0230 100644
@@ -31,9 +31,30 @@
 /*
  * High Level Configuration Options
  */
-#define CONFIG_PANDA		1	/* working with Panda */
+#define CONFIG_PANDA	/* working with Panda */
+
+/* USB UHH support options */
+#define CONFIG_CMD_USB
+#define CONFIG_USB_HOST
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_OMAP
+#define CONFIG_USB_STORAGE
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
+
+#define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO 1
+#define CONFIG_OMAP_EHCI_PHY2_RESET_GPIO 62
+
+/* USB Networking options */
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_SMSC95XX
+
+#define CONFIG_UBOOT_ENABLE_PADS_ALL
+
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_DHCP
 
 #include <configs/omap4_common.h>
+#define CONFIG_CMD_NET
 
 /* GPIO */
 #define CONFIG_CMD_GPIO
Signature · 1 line
1.7.5.4
#10 lore raw

PATCH v3 5/7 OMAP3+: ehci-omap: enable usb host ports for beagle/panda

Quoted 8 lines · Govindraj.R

From: "Govindraj.R" <[email protected]>

For beagle and panda enable and use the ehci-omap.c generic api's added to configure usb host ports based on data passed from board file to configure in modes as specified from board data. For panda initialise the mux pins for ehci usage.

Last neats and

Quoted 31 lines
---
 board/ti/beagle/beagle.c        |   28 ++++++++++++++++++++++++++
 board/ti/panda/panda.c          |   41 +++++++++++++++++++++++++++++++++++++++
 board/ti/panda/panda_mux_data.h |   16 +++++++-------
 include/configs/omap4_panda.h   |   23 ++++++++++++++++++++-
 4 files changed, 99 insertions(+), 9 deletions(-)
board/ti/beagle/beagle.c +9 -0
index 98548ab..5031cf2 100644
@@ -45,6 +45,11 @@
 #include "beagle.h"
 #include <command.h>
 
+#ifdef CONFIG_USB_EHCI
+#include <usb.h>
+#include <asm/ehci-omap.h>
+#endif
+
 #define pr_debug(fmt, args...) debug(fmt, ##args)
 
 #define TWL4030_I2C_BUS			0
@@ -442,6 +447,29 @@ void show_boot_progress(int val)
 	if(val == 15)
 		usb_stop();
 }
+
+static struct omap_usbhs_board_data usbhs_bdata = {
+	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
+	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,

board/ti/beagle/beagle.c void show_boot_progress(int val) · line 463

Quoted 10 lines
board/ti/beagle/beagle.c +10 -0
+	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
+};
+
+int ehci_hcd_init(void)
+{
+	int ret = 0;
+
+	ret = omap_ehci_hcd_init(&usbhs_bdata);
+	return ret;
+}

just:
return omap_ehci_hcd_init(&usbhs_bdata);

board/ti/beagle/beagle.c void show_boot_progress(int val) · line 471

Quoted 8 lines
board/ti/beagle/beagle.c +8 -0
+
+int ehci_hcd_stop(void)
+{
+	int ret;
+
+	ret = omap_ehci_hcd_stop();
+	return ret;
+}

same here:
return omap_ehci_hcd_stop();

Quoted 42 lines
board/ti/beagle/beagle.c +1 -0
+
 #endif /* CONFIG_USB_EHCI */
 
 #ifndef CONFIG_SPL_BUILD
board/ti/panda/panda.c +20 -0
index fc8c0b4..1f8509b 100644
@@ -26,9 +26,16 @@
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/clocks.h>
 #include <asm/arch/gpio.h>
+#include <asm/gpio.h>
 
 #include "panda_mux_data.h"
 
+#ifdef CONFIG_USB_EHCI
+#include <usb.h>
+#include <asm/arch/ehci.h>
+#include <asm/ehci-omap.h>
+#endif
+
 #define PANDA_ULPI_PHY_TYPE_GPIO       182
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -177,6 +184,40 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#ifdef CONFIG_USB_EHCI
+
+static struct omap_usbhs_board_data usbhs_bdata = {
+	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
+	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
+	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
+};
+
+int ehci_hcd_init(void)
+{
+	int ret;
+	unsigned int utmi_clk;
+

board/ti/panda/panda.c int board_mmc_init(bd_t *bis) · line 209

Quoted 10 lines
board/ti/panda/panda.c +10 -0
+	/* Now we can enable our port clocks */
+	utmi_clk = readl((void *)CM_L3INIT_HSUSBHOST_CLKCTRL);
+	utmi_clk |= HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK;
+	sr32((void *)CM_L3INIT_HSUSBHOST_CLKCTRL, 0, 32, utmi_clk);
+
+	ret = omap_ehci_hcd_init(&usbhs_bdata);
+	if (ret < 0)
+		return ret;
+
+	return 0;

return omap_ehci_hcd_init(&usbhs_bdata);
?

board/ti/panda/panda.c int board_mmc_init(bd_t *bis) · line 217

Quoted 8 lines
board/ti/panda/panda.c +8 -0
+}
+
+int ehci_hcd_stop(void)
+{
+	int ret;
+
+	ret = omap_ehci_hcd_stop();
+	return ret;

return omap_ehci_hcd_stop();

Quoted 2 lines
board/ti/panda/panda.c +2 -0
+}
+#endif

[...]

Signature · 2 lines
Regards,
Igor.
#11 lore raw

PATCH v3 6/7 usb: ulpi: Extend the existing ulpi framework.

In reply to Govindraj.R

From: "Govindraj.R" <[email protected]>

Extend the existing ulpi viewport framework
to pass the port number information for any ulpi
ops. Fix the usage of ulpi api's accordingly.

---
 board/efikamx/efikamx-usb.c      |   24 ++++++++++------
 drivers/usb/ulpi/ulpi-viewport.c |   30 ++++++++++----------
 drivers/usb/ulpi/ulpi.c          |   54 +++++++++++++++++++------------------
 include/usb/ulpi.h               |   36 +++++++++++++++++--------
 4 files changed, 82 insertions(+), 62 deletions(-)
board/efikamx/efikamx-usb.c +15 -9
index 840bd9a..ac2d2e9 100644
@@ -120,6 +120,7 @@ static void efika_ehci_init(struct usb_ehci *ehci, uint32_t stp_gpio,
 {
 	int ret;
 	struct ulpi_regs *ulpi = (struct ulpi_regs *)0;
+	struct ulpi_viewport ulpi_vp;
 
 	mxc_request_iomux(stp_gpio, alt0);
 	mxc_iomux_set_pad(stp_gpio, PAD_CTL_DRV_HIGH |
@@ -133,23 +134,26 @@ static void efika_ehci_init(struct usb_ehci *ehci, uint32_t stp_gpio,
 	mxc_iomux_set_pad(stp_gpio, USB_PAD_CONFIG);
 	udelay(10000);
 
-	ret = ulpi_init((u32)&ehci->ulpi_viewpoint);
+	ulpi_vp.viewport_addr = (u32)&ehci->ulpi_viewpoint;
+	ulpi_vp.port_num = 0;
+
+	ret = ulpi_init(&ulpi_vp);
 	if (ret) {
 		printf("Efika USB ULPI initialization failed\n");
 		return;
 	}
 
 	/* ULPI set flags */
-	ulpi_write((u32)&ehci->ulpi_viewpoint, &ulpi->otg_ctrl,
+	ulpi_write(&ulpi_vp, &ulpi->otg_ctrl,
 			ULPI_OTG_DP_PULLDOWN | ULPI_OTG_DM_PULLDOWN |
 			ULPI_OTG_EXTVBUSIND);
-	ulpi_write((u32)&ehci->ulpi_viewpoint, &ulpi->function_ctrl,
+	ulpi_write(&ulpi_vp, &ulpi->function_ctrl,
 			ULPI_FC_FULL_SPEED | ULPI_FC_OPMODE_NORMAL |
 			ULPI_FC_SUSPENDM);
-	ulpi_write((u32)&ehci->ulpi_viewpoint, &ulpi->iface_ctrl, 0);
+	ulpi_write(&ulpi_vp, &ulpi->iface_ctrl, 0);
 
 	/* Set VBus */
-	ulpi_write((u32)&ehci->ulpi_viewpoint, &ulpi->otg_ctrl_set,
+	ulpi_write(&ulpi_vp, &ulpi->otg_ctrl_set,
 			ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
 
 	/*
@@ -158,8 +162,7 @@ static void efika_ehci_init(struct usb_ehci *ehci, uint32_t stp_gpio,
 	 * NOTE: This violates USB specification, but otherwise, USB on Efika
 	 * doesn't work.
 	 */
-	ulpi_write((u32)&ehci->ulpi_viewpoint, &ulpi->otg_ctrl_set,
-			ULPI_OTG_CHRGVBUS);
+	ulpi_write(&ulpi_vp, &ulpi->otg_ctrl_set, ULPI_OTG_CHRGVBUS);
 }
 
 int board_ehci_hcd_init(int port)
@@ -177,9 +180,12 @@ void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
 	uint32_t port = OTG_BASE_ADDR + (0x200 * CONFIG_MXC_USB_PORT);
 	struct usb_ehci *ehci = (struct usb_ehci *)port;
 	struct ulpi_regs *ulpi = (struct ulpi_regs *)0;
+	struct ulpi_viewport ulpi_vp;
+
+	ulpi_vp.viewport_addr = (u32)&ehci->ulpi_viewpoint;
+	ulpi_vp.port_num = 0;
 
-	ulpi_write((u32)&ehci->ulpi_viewpoint, &ulpi->otg_ctrl_set,
-			ULPI_OTG_CHRGVBUS);
+	ulpi_write(&ulpi_vp, &ulpi->otg_ctrl_set, ULPI_OTG_CHRGVBUS);
 
 	wait_ms(50);
 
drivers/usb/ulpi/ulpi-viewport.c +15 -15
index 490fb0e..6f03f08 100644
@@ -40,13 +40,13 @@
  *
  * returns 0 on mask match, ULPI_ERROR on time out.
  */
-static int ulpi_wait(u32 ulpi_viewport, u32 mask)
+static int ulpi_wait(struct ulpi_viewport *ulpi_vp, u32 mask)
 {
 	int timeout = CONFIG_USB_ULPI_TIMEOUT;
 
 	/* Wait for the bits in mask to become zero. */
 	while (--timeout) {
-		if ((readl(ulpi_viewport) & mask) == 0)
+		if ((readl(ulpi_vp->viewport_addr) & mask) == 0)
 			return 0;
 
 		udelay(1);
@@ -60,16 +60,16 @@ static int ulpi_wait(u32 ulpi_viewport, u32 mask)
  *
  * returns 0 on success.
  */
-static int ulpi_wakeup(u32 ulpi_viewport)
+static int ulpi_wakeup(struct ulpi_viewport *ulpi_vp)
 {
 	int err;
 
-	if (readl(ulpi_viewport) & ULPI_SS)
+	if (readl(ulpi_vp->viewport_addr) & ULPI_SS)
 		return 0; /* already awake */
 
-	writel(ULPI_WU, ulpi_viewport);
+	writel(ULPI_WU, ulpi_vp->viewport_addr);
 
-	err = ulpi_wait(ulpi_viewport, ULPI_WU);
+	err = ulpi_wait(ulpi_vp, ULPI_WU);
 	if (err)
 		printf("ULPI wakeup timed out\n");
 
@@ -81,38 +81,38 @@ static int ulpi_wakeup(u32 ulpi_viewport)
  *
  * @value - the ULPI request
  */
-static int ulpi_request(u32 ulpi_viewport, u32 value)
+static int ulpi_request(struct ulpi_viewport *ulpi_vp, u32 value)
 {
 	int err;
 
-	err = ulpi_wakeup(ulpi_viewport);
+	err = ulpi_wakeup(ulpi_vp);
 	if (err)
 		return err;
 
-	writel(value, ulpi_viewport);
+	writel(value, ulpi_vp->viewport_addr);
 
-	err = ulpi_wait(ulpi_viewport, ULPI_RWRUN);
+	err = ulpi_wait(ulpi_vp, ULPI_RWRUN);
 	if (err)
 		printf("ULPI request timed out\n");
 
 	return err;
 }
 
-int ulpi_write(u32 ulpi_viewport, u8 *reg, u32 value)
+int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)
 {
 	u32 val = ULPI_RWRUN | ULPI_RWCTRL | ((u32)reg << 16) | (value & 0xff);
 
-	return ulpi_request(ulpi_viewport, val);
+	return ulpi_request(ulpi_vp, val);
 }
 
-u32 ulpi_read(u32 ulpi_viewport, u8 *reg)
+u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg)
 {
 	int err;
 	u32 val = ULPI_RWRUN | ((u32)reg << 16);
 
-	err = ulpi_request(ulpi_viewport, val);
+	err = ulpi_request(ulpi_vp, val);
 	if (err)
 		return err;
 
-	return (readl(ulpi_viewport) >> 8) & 0xff;
+	return (readl(ulpi_vp->viewport_addr) >> 8) & 0xff;
 }
drivers/usb/ulpi/ulpi.c +28 -26

168 lines not on this page · raw message

include/usb/ulpi.h +24 -12
index 802f077..a036bab 100644
@@ -28,12 +28,23 @@
 #endif
 
 /*
+ * ulpi view port address and
+ * Port_number that can be passed.
+ * Any additional data to be passed can
+ * be extended from this structure
+ */
+struct ulpi_viewport {
+	u32 viewport_addr;
+	u8 port_num;
+};
+
+/*
  * Initialize the ULPI transciever and check the interface integrity.
- * @ulpi_viewport -  the address of the ULPI viewport register.
+ * @ulpi_viewport -  structure containing ULPI viewport data
  *
  * returns 0 on success, ULPI_ERROR on failure.
  */
-int ulpi_init(u32 ulpi_viewport);
+int ulpi_init(struct ulpi_viewport *ulpi_vp);
 
 /*
  * Select transceiver speed.
@@ -41,7 +52,7 @@ int ulpi_init(u32 ulpi_viewport);
  *                ULPI_FC_LOW_SPEED,  ULPI_FC_FS4LS
  * returns 0 on success, ULPI_ERROR on failure.
  */
-int ulpi_select_transceiver(u32 ulpi_viewport, unsigned speed);
+int ulpi_select_transceiver(struct ulpi_viewport *ulpi_vp, unsigned speed);
 
 /*
  * Enable/disable VBUS.
@@ -50,14 +61,15 @@ int ulpi_select_transceiver(u32 ulpi_viewport, unsigned speed);
  *
  * returns 0 on success, ULPI_ERROR on failure.
  */
-int ulpi_enable_vbus(u32 ulpi_viewport, int on, int ext_power, int ext_ind);
+int ulpi_enable_vbus(struct ulpi_viewport *ulpi_vp,
+			int on, int ext_power, int ext_ind);
 
 /*
  * Enable/disable pull-down resistors on D+ and D- USB lines.
  *
  * returns 0 on success, ULPI_ERROR on failure.
  */
-int ulpi_set_pd(u32 ulpi_viewport, int enable);
+int ulpi_set_pd(struct ulpi_viewport *ulpi_vp, int enable);
 
 /*
  * Select OpMode.
@@ -66,7 +78,7 @@ int ulpi_set_pd(u32 ulpi_viewport, int enable);
  *
  * returns 0 on success, ULPI_ERROR on failure.
  */
-int ulpi_opmode_sel(u32 ulpi_viewport, unsigned opmode);
+int ulpi_opmode_sel(struct ulpi_viewport *ulpi_vp, unsigned opmode);
 
 /*
  * Switch to Serial Mode.
@@ -78,7 +90,7 @@ int ulpi_opmode_sel(u32 ulpi_viewport, unsigned opmode);
  * Switches immediately to Serial Mode.
  * To return from Serial Mode, STP line needs to be asserted.
  */
-int ulpi_serial_mode_enable(u32 ulpi_viewport, unsigned smode);
+int ulpi_serial_mode_enable(struct ulpi_viewport *ulpi_vp, unsigned smode);
 
 /*
  * Put PHY into low power mode.
@@ -89,14 +101,14 @@ int ulpi_serial_mode_enable(u32 ulpi_viewport, unsigned smode);
  * STP line must be driven low to keep the PHY in suspend.
  * To resume the PHY, STP line needs to be asserted.
  */
-int ulpi_suspend(u32 ulpi_viewport);
+int ulpi_suspend(struct ulpi_viewport *ulpi_vp);
 
 /*
  * Reset the transceiver. ULPI interface and registers are not affected.
  *
  * returns 0 on success, ULPI_ERROR on failure.
  */
-int ulpi_reset(u32 ulpi_viewport);
+int ulpi_reset(struct ulpi_viewport *ulpi_vp);
 
 
 /* ULPI access methods below must be implemented for each ULPI viewport. */
@@ -108,7 +120,7 @@ int ulpi_reset(u32 ulpi_viewport);
  *
  * returns 0 on success, ULPI_ERROR on failure.
  */
-int ulpi_write(u32 ulpi_viewport, u8 *reg, u32 value);
+int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value);
 
 /*
  * Read the ULPI PHY register content via the viewport.
@@ -116,14 +128,14 @@ int ulpi_write(u32 ulpi_viewport, u8 *reg, u32 value);
  *
  * returns register content on success, ULPI_ERROR on failure.
  */
-u32 ulpi_read(u32 ulpi_viewport, u8 *reg);
+u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg);
 
 /*
  * Wait for the reset to complete.
  * The Link must not attempt to access the PHY until the reset has
  * completed and DIR line is de-asserted.
  */
-int ulpi_reset_wait(u32 ulpi_viewport);
+int ulpi_reset_wait(struct ulpi_viewport *ulpi_vp);
 
 /* Access Extended Register Set (indicator) */
 #define ACCESS_EXT_REGS_OFFSET	0x2f	/* read-write */
Signature · 1 line
1.7.5.4
#12 lore raw

PATCH v3 6/7 usb: ulpi: Extend the existing ulpi framework.

Hi Govindraj,

I was about to ask Tom to reorder the patches while applying, but there are still several things to fix.
I'm also fine with fixing these by a follow up patch (after merging this).

There are several comments, you missed to fix from previous version [1]. Please, fix those.

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/123832

Quoted 8 lines · Govindraj.R

From: "Govindraj.R" <[email protected]>

Extend the existing ulpi viewport framework
to pass the port number information for any ulpi
ops. Fix the usage of ulpi api's accordingly.

After fixing the pointed issues:

Quoted 6 lines
---
 board/efikamx/efikamx-usb.c      |   24 ++++++++++------
 drivers/usb/ulpi/ulpi-viewport.c |   30 ++++++++++----------
 drivers/usb/ulpi/ulpi.c          |   54 +++++++++++++++++++------------------
 include/usb/ulpi.h               |   36 +++++++++++++++++--------
 4 files changed, 82 insertions(+), 62 deletions(-)

[...]

Quoted 4 lines
drivers/usb/ulpi/ulpi-viewport.c +0 -0
index 490fb0e..6f03f08 100644

[...]

drivers/usb/ulpi/ulpi-viewport.c static int ulpi_wakeup(u32 ulpi_viewport) · line 103

Quoted 4 lines
drivers/usb/ulpi/ulpi-viewport.c +1 -1
-int ulpi_write(u32 ulpi_viewport, u8 *reg, u32 value)
+int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)
 {
 	u32 val = ULPI_RWRUN | ULPI_RWCTRL | ((u32)reg << 16) | (value & 0xff);

You should utilize the port_num variable here, right? something like:
val |= (ulpi_vp->port_num & 0x7) << 24;

drivers/usb/ulpi/ulpi-viewport.c static int ulpi_wakeup(u32 ulpi_viewport) · line 111

Quoted 10 lines
drivers/usb/ulpi/ulpi-viewport.c +2 -2
-	return ulpi_request(ulpi_viewport, val);
+	return ulpi_request(ulpi_vp, val);
 }
 
-u32 ulpi_read(u32 ulpi_viewport, u8 *reg)
+u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg)
 {
 	int err;
 	u32 val = ULPI_RWRUN | ((u32)reg << 16);

same here

Quoted 9 lines
drivers/usb/ulpi/ulpi-viewport.c +2 -2
-	err = ulpi_request(ulpi_viewport, val);
+	err = ulpi_request(ulpi_vp, val);
 	if (err)
 		return err;
 
-	return (readl(ulpi_viewport) >> 8) & 0xff;
+	return (readl(ulpi_vp->viewport_addr) >> 8) & 0xff;
 }

[...]

Quoted 7 lines
include/usb/ulpi.h +0 -0
index 802f077..a036bab 100644
@@ -28,12 +28,23 @@
 #endif
 

include/usb/ulpi.h line 39

Quoted 10 lines
include/usb/ulpi.h +9 -0
 /*
+ * ulpi view port address and
+ * Port_number that can be passed.
+ * Any additional data to be passed can
+ * be extended from this structure
+ */
+struct ulpi_viewport {
+	u32 viewport_addr;
+	u8 port_num;
+};

haven't we aggreed, that this will be:
u32 port_num;
?

include/usb/ulpi.h line 43

Quoted 5 lines
include/usb/ulpi.h +3 -1
+
+/*
  * Initialize the ULPI transciever and check the interface integrity.
- * @ulpi_viewport -  the address of the ULPI viewport register.
+ * @ulpi_viewport -  structure containing ULPI viewport data

This is ulpi_vp now.

[...]

Signature · 2 lines
Regards,
Igor.
#13 lore raw

PATCH v3 6/7 usb: ulpi: Extend the existing ulpi framework.

Hi Igor,

Quoted 6 lines · Igor Grinberg

Hi Govindraj,

I was about to ask Tom to reorder the patches while applying, but there are still several things to fix.
I'm also fine with fixing these by a follow up patch (after merging this).

[...]

Quoted 10 lines

[...]

Quoted 4 lines
drivers/usb/ulpi/ulpi-viewport.c +0 -0
index 490fb0e..6f03f08 100644

[...]

Quoted 9 lines
Quoted 4 lines
drivers/usb/ulpi/ulpi-viewport.c +1 -1
-int ulpi_write(u32 ulpi_viewport, u8 *reg, u32 value)
+int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)

?{
? ? ? u32 val = ULPI_RWRUN | ULPI_RWCTRL | ((u32)reg << 16) | (value & 0xff);

You should utilize the port_num variable here, right? something like:
val |= (ulpi_vp->port_num & 0x7) << 24;

Yes correct, Shouldn't we add something like this

[...]

#ifndef CONFIG_ULPI_PORT_SHIFT && CONFIG_ULPI_PORT_MASK #define CONFIG_ULPI_PORT_SHIFT 24
#define CONFIG_ULPI_PORT_MASK 0x7
#endif

[...]

val |= (ulpi_vp->port_num & CONFIG_ULPI_PORT_MASK) <<

                    CONFIG_ULPI_PORT_SHIFT;
Quoted 32 lines
Quoted 10 lines

- ? ? return ulpi_request(ulpi_viewport, val);
+ ? ? return ulpi_request(ulpi_vp, val);
?}

drivers/usb/ulpi/ulpi-viewport.c +1 -1
-u32 ulpi_read(u32 ulpi_viewport, u8 *reg)
+u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg)

?{
? ? ? int err;
? ? ? u32 val = ULPI_RWRUN | ((u32)reg << 16);

same here

Quoted 9 lines

- ? ? err = ulpi_request(ulpi_viewport, val);
+ ? ? err = ulpi_request(ulpi_vp, val);
? ? ? if (err)
? ? ? ? ? ? ? return err;

- ? ? return (readl(ulpi_viewport) >> 8) & 0xff;
+ ? ? return (readl(ulpi_vp->viewport_addr) >> 8) & 0xff; ?}

[...]

Quoted 7 lines
include/usb/ulpi.h +0 -0
index 802f077..a036bab 100644
@@ -28,12 +28,23 @@

?#endif

Quoted 13 lines

include/usb/ulpi.h line 39

Quoted 10 lines

?/*
+ * ulpi view port address and
+ * Port_number that can be passed.
+ * Any additional data to be passed can
+ * be extended from this structure
+ */

include/usb/ulpi.h +4 -0
+struct ulpi_viewport {
+ ? ? u32 viewport_addr;
+ ? ? u8 port_num;
+};

haven't we aggreed, that this will be:
u32 port_num;

My bad I missed this will correct now.

Quoted 9 lines

?

Quoted 5 lines
include/usb/ulpi.h +2 -0
+
+/*

? * Initialize the ULPI transciever and check the interface integrity.
- * @ulpi_viewport - ?the address of the ULPI viewport register.
+ * @ulpi_viewport - ?structure containing ULPI viewport data

This is ulpi_vp now.

will correct this.

--
Thanks,
Govindraj.R

#14 lore raw

PATCH v3 6/7 usb: ulpi: Extend the existing ulpi framework.

Quoted 41 lines · Govindraj

Hi Igor,

Quoted 6 lines · Igor Grinberg

Hi Govindraj,

I was about to ask Tom to reorder the patches while applying, but there are still several things to fix.
I'm also fine with fixing these by a follow up patch (after merging this).

[...]

Quoted 10 lines

[...]

Quoted 4 lines
drivers/usb/ulpi/ulpi-viewport.c +0 -0
index 490fb0e..6f03f08 100644

[...]

Quoted 9 lines

drivers/usb/ulpi/ulpi-viewport.c static int ulpi_wakeup(u32 ulpi_viewport) · line 103

Quoted 4 lines
drivers/usb/ulpi/ulpi-viewport.c +1 -1
-int ulpi_write(u32 ulpi_viewport, u8 *reg, u32 value)
+int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)
 {
      u32 val = ULPI_RWRUN | ULPI_RWCTRL | ((u32)reg << 16) | (value & 0xff);

You should utilize the port_num variable here, right? something like:
val |= (ulpi_vp->port_num & 0x7) << 24;

Yes correct, Shouldn't we add something like this

[...]

#ifndef CONFIG_ULPI_PORT_SHIFT && CONFIG_ULPI_PORT_MASK #define CONFIG_ULPI_PORT_SHIFT 24
#define CONFIG_ULPI_PORT_MASK 0x7
#endif

Quoted 4 lines

[...]

val |= (ulpi_vp->port_num & CONFIG_ULPI_PORT_MASK) <<

                    CONFIG_ULPI_PORT_SHIFT;

We have already discussed this in the previous session [1] And the conclusion was to use plain values instead,
because otherwise, you should replace all other masks and shifts... and that will be a mess...
IMO,
(ulpi_vp->port_num & 0x7) << 24;
is really self explanatory and intuitive, so replacing it with defines just make the code look bad and split into multiple lines. Also the values are viewport specific and will not change, so there is no reason to make them a config option.

[1] http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/124222

Quoted 24 lines
Quoted 24 lines

drivers/usb/ulpi/ulpi-viewport.c static int ulpi_wakeup(u32 ulpi_viewport) · line 111

Quoted 12 lines
drivers/usb/ulpi/ulpi-viewport.c +2 -2
-     return ulpi_request(ulpi_viewport, val);
+     return ulpi_request(ulpi_vp, val);
 }
 
-u32 ulpi_read(u32 ulpi_viewport, u8 *reg)
+u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg)
 {
      int err;
      u32 val = ULPI_RWRUN | ((u32)reg << 16);

same here

Quoted 9 lines
drivers/usb/ulpi/ulpi-viewport.c +2 -2
-     err = ulpi_request(ulpi_viewport, val);
+     err = ulpi_request(ulpi_vp, val);
      if (err)
              return err;
 
-     return (readl(ulpi_viewport) >> 8) & 0xff;
+     return (readl(ulpi_vp->viewport_addr) >> 8) & 0xff;
 }

[...]

Signature · 2 lines
Regards,
Igor.
#15 lore raw

PATCH v3 6/7 usb: ulpi: Extend the existing ulpi framework.

In reply to Govindraj.R

Govindraj,
I have Gumstix overo board with OM3730 + USB 3326 USB PHY.I want to add EHCI
and ULPI support in u-boot.

Once we port the EHCI_OMAP EHCI driver How to test this driver functionality
under u-boot environment?
Is there any application/commands to test ULPI functionality under u-boot
environment?

Regards,
Subhashini

#16 lore raw

PATCH v3 6/7 usb: ulpi: Extend the existing ulpi framework.

Hi Subhashini,

Quoted 4 lines · SUBHASHINI MANNE

Govindraj,
?I have Gumstix overo board with OM3730 + USB 3326 USB PHY.I want to add EHCI and ULPI support in u-boot.

You can refer to the v4 patch series posted earlier:
http://www.mail-archive.com/u-boot at lists.denx.de/msg76860.html

This patch series adds support for omap4_panda using the ehci-omap framework, You can refer to panda board file change on how to do it.

Or you also refer to this patch adding support for OMAP3: TAM3517

http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/124645

Something similar needs to be done for your board file to support ehci.

Quoted 3 lines

?Once we port the EHCI_OMAP ?EHCI driver How to test this driver functionality under u-boot environment?

usb start;
usb info;
usb tree;

some commands to check if your downstream device is getting enumerated. refer to usb help in u-boot for usage.

you can also use fatls and other use case if you have a hub connected to you root port or you can also check for tftpboot if you have ethernet controller
over ehci (like in panda or beagle).

care to update your config file for usb ehci enabling (refer to v4 patch series as done for panda/beagle)

Quoted 3 lines

?Is there any application/commands to ?test ULPI functionality under u-boot environment?

what kind of ulpi functionality do you want to test omap-ulpi-viewport is basically for the ulpi phy access from INSNREG05_ULPI from ehci reg map to configure and debug phy interface.
(chapter 22.2.2.3 ULPI Interfaces from omap36xx TRM v1.x vW)

You can refer to OMAP TRM chapter 22.2 High-Speed USB Host Subsystem for reference.

--
Thanks,
Govindraj.R

#17 lore raw

PATCH v3 7/7 usb: ulpi: Add omap-ulpi-view port support

In reply to Govindraj.R

From: "Govindraj.R" <[email protected]>

Based on discussion from this thread [1].
Adding omap-view port that helps us in using the generic ulpi framework for any ulpi phy ops using the INSNREG05_ULPI viewport reg available on omap platform.

Currently ehci ports are available on omap3/4 platforms so enable the same for beagle and panda, patch is tested on the same boards.

Thanks to Igor Grinberg <[email protected]> for reviewing the omap-ehci patches and suggesting this approach.

[1]: http://www.mail-archive.com/u-boot at lists.denx.de/msg76076.html

---
 doc/README.omap-ulpi-viewport         |   27 +++++++++
 drivers/usb/ulpi/Makefile             |    1 +
 drivers/usb/ulpi/omap-ulpi-viewport.c |  105 +++++++++++++++++++++++++++++++++
 include/configs/omap3_beagle.h        |    3 +
 include/configs/omap4_panda.h         |    2 +
 5 files changed, 138 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.omap-ulpi-viewport
 create mode 100644 drivers/usb/ulpi/omap-ulpi-viewport.c
doc/README.omap-ulpi-viewport new file +27 -0
new file mode 100644
index 0000000..19feecd
@@ -0,0 +1,27 @@
+Reference code ""drivers/usb/ulpi/omap-ulpi-viewport.c"
+
+Contains the ulpi read write api's to perform
+any ulpi phy port access on omap platform.
+
+On omap ehci reg map contains INSNREG05_ULPI
+register which offers the ulpi phy access so
+any ulpi phy commands can be passsed using this
+register.
+
+omap-ulpi-viewport.c is a low level function
+implementation of "drivers/usb/ulpi/ulpi.c"
+
+To enable and use omap-ulpi-viewport.c
+we requires CONFIG_USB_ULPI_VIEWPORT_OMAP and
+CONFIG_USB_ULPI be enabled from config file.
+
+Any ulpi ops request can be done with ulpi.c
+and soc specific binding and usage is done with
+omap-ulpi-viewport implementation.
+
+Ex: scenario:
+omap-ehci driver code requests for ulpi phy reset if
+ehci is used in phy mode, which will call ulpi phy reset
+the ulpi phy reset does ulpi_read/write from viewport
+implementation which will do ulpi reset using the
+INSNREG05_ULPI register.
drivers/usb/ulpi/Makefile +1 -0
index d43b229..281eb1c 100644
@@ -24,6 +24,7 @@ LIB	:= $(obj)libusb_ulpi.o
 
 COBJS-$(CONFIG_USB_ULPI)		+= ulpi.o
 COBJS-$(CONFIG_USB_ULPI_VIEWPORT)	+= ulpi-viewport.o
+COBJS-$(CONFIG_USB_ULPI_VIEWPORT_OMAP)	+= omap-ulpi-viewport.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/usb/ulpi/omap-ulpi-viewport.c new file +105 -0

105 lines not on this page · raw message

include/configs/omap3_beagle.h +3 -0
index b4d6443..b3b5651 100644
@@ -130,6 +130,9 @@
 #define CONFIG_CMD_USB
 #define CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_OMAP
+#define CONFIG_USB_ULPI
+#define CONFIG_USB_ULPI_VIEWPORT_OMAP
+
 /*#define CONFIG_EHCI_DCACHE*/ /* leave it disabled for now */
 #define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO	147
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
include/configs/omap4_panda.h +2 -0
index 23c0230..0afcdd4 100644
@@ -38,6 +38,8 @@
 #define CONFIG_USB_HOST
 #define CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_OMAP
+#define CONFIG_USB_ULPI
+#define CONFIG_USB_ULPI_VIEWPORT_OMAP
 #define CONFIG_USB_STORAGE
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
 
Signature · 1 line
1.7.5.4
#18 lore raw

PATCH v3 7/7 usb: ulpi: Add omap-ulpi-view port support

Quoted 10 lines · Govindraj.R

From: "Govindraj.R" <[email protected]>

Based on discussion from this thread [1].
Adding omap-view port that helps us in using the generic ulpi framework for any ulpi phy ops using the INSNREG05_ULPI viewport reg available on omap platform.

Currently ehci ports are available on omap3/4 platforms so enable the same for beagle and panda, patch is tested on the same boards.

Quoted 7 lines

Thanks to Igor Grinberg <[email protected]> for reviewing the omap-ehci patches and suggesting this approach.

[1]: http://www.mail-archive.com/u-boot at lists.denx.de/msg76076.html

After fixing several neats below,

Quoted 16 lines
---
 doc/README.omap-ulpi-viewport         |   27 +++++++++
 drivers/usb/ulpi/Makefile             |    1 +
 drivers/usb/ulpi/omap-ulpi-viewport.c |  105 +++++++++++++++++++++++++++++++++
 include/configs/omap3_beagle.h        |    3 +
 include/configs/omap4_panda.h         |    2 +
 5 files changed, 138 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.omap-ulpi-viewport
 create mode 100644 drivers/usb/ulpi/omap-ulpi-viewport.c
doc/README.omap-ulpi-viewport new file +0 -0
new file mode 100644
index 0000000..19feecd

doc/README.omap-ulpi-viewport line 8

Quoted 8 lines
doc/README.omap-ulpi-viewport new file +8 -0
@@ -0,0 +1,27 @@
+Reference code ""drivers/usb/ulpi/omap-ulpi-viewport.c"
+
+Contains the ulpi read write api's to perform
+any ulpi phy port access on omap platform.
+
+On omap ehci reg map contains INSNREG05_ULPI
+register which offers the ulpi phy access so
+any ulpi phy commands can be passsed using this

should be passed ^^^

doc/README.omap-ulpi-viewport line 15

Quoted 7 lines
doc/README.omap-ulpi-viewport new file +7 -0
+register.
+
+omap-ulpi-viewport.c is a low level function
+implementation of "drivers/usb/ulpi/ulpi.c"
+
+To enable and use omap-ulpi-viewport.c
+we requires CONFIG_USB_ULPI_VIEWPORT_OMAP and

s/requires/require/

doc/README.omap-ulpi-viewport line 16

Quoted 1 line
doc/README.omap-ulpi-viewport new file +1 -0
+CONFIG_USB_ULPI be enabled from config file.

s/from/in/

Quoted 11 lines
doc/README.omap-ulpi-viewport new file +11 -0
+
+Any ulpi ops request can be done with ulpi.c
+and soc specific binding and usage is done with
+omap-ulpi-viewport implementation.
+
+Ex: scenario:
+omap-ehci driver code requests for ulpi phy reset if
+ehci is used in phy mode, which will call ulpi phy reset
+the ulpi phy reset does ulpi_read/write from viewport
+implementation which will do ulpi reset using the
+INSNREG05_ULPI register.

[...]

Quoted 5 lines
drivers/usb/ulpi/omap-ulpi-viewport.c new file +0 -0
new file mode 100644
index 0000000..66b1795

[...]

drivers/usb/ulpi/omap-ulpi-viewport.c line 89

Quoted 4 lines
drivers/usb/ulpi/omap-ulpi-viewport.c new file +4 -0
+int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value)
+{
+	u32 val = ((ulpi_vp->port_num & 0x7) << 24) |
+			OMAP_ULPI_WR_OPSEL | ((u32)reg << 16) | (value & 0xff);

On OMAP, port_num is 4 bits wide, therefore:
ulpi_vp->port_num & 0xf

drivers/usb/ulpi/omap-ulpi-viewport.c line 98

Quoted 9 lines
drivers/usb/ulpi/omap-ulpi-viewport.c new file +9 -0
+
+	return ulpi_request(ulpi_vp, val);
+}
+
+u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg)
+{
+	int err;
+	u32 val = ((ulpi_vp->port_num & 0x7) << 24) |
+			 OMAP_ULPI_WR_OPSEL | ((u32)reg << 16);

same here:
ulpi_vp->port_num & 0xf

Quoted 7 lines
drivers/usb/ulpi/omap-ulpi-viewport.c new file +7 -0
+
+	err = ulpi_request(ulpi_vp, val);
+	if (err)
+		return err;
+
+	return readl(ulpi_vp->viewport_addr) & 0xff;
+}

[...]

Signature · 2 lines
Regards,
Igor.
#19 lore raw

v3 cover Clean up ehci-omap and extend support for omap3/4 socs

In reply to Govindraj.R
Quoted 8 lines · Govindraj.R

From: "Govindraj.R" <[email protected]>

Clean up ehci-omap added and make it generic to extend support for omap4 socs. Adds omap-ulpi-viewport for ulpi access from ehci-omap.
Adds ehci support for omap4-panda.

Based on latest denx master branch commit:
? ? ? ?137703b811502dfea364650fb3e17f20b4c21333

This adds warnings for omap4_sdp4430 and omap5_evm, please re-spin with these not introduced.

Also, the order of the patches is wrong. Please use
https://github.com/dustin/bindir/blob/master/git-test-sequence to make sure that MAKEALL -s omap4 -s omap5 omap3_beagle still builds at each step. The ulpi commits are out of order currently and that breaks things.

Thanks!

Signature · 1 line
Tom