linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver
@ 2013-01-10 16:51 Roger Quadros
  2013-01-10 16:51 ` [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data Roger Quadros
                   ` (13 more replies)
  0 siblings, 14 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

The OMAP's High Speed Host controller can interface to ULPI/UTMI
PHY's transparently i.e. whithout requiring the device drivers to
access the PHY [1]. However, the OS must ensure that the PHY has
the necessary resources (power/clock/reset) enabled before it is used.

Till now, the omap-ehci driver was managing the power and reset of the PHY
whereas, clock enabling was left to the bootloader or board files.

In this patchset we make the NOP PHY driver (nop-usb-xceiv.c) handle
all the PHY resources that are available so that it can be used by
platforms like OMAP.

The omap-ehci driver instantiates a PHY platform device for each port
that is in PHY mode. It then uses the USB PHY APIs to manage the PHY.

All this results in a much cleaner code and makes USB PHY resource management
work properly on OMAP.

NOTE: Only omap4panda board is adapted for the changes. So USB Host will
break for other boards. Once we have done a priliminary review, I can adapt
other boards as well.

This patchset depends on the series
https://lkml.org/lkml/2013/1/2/144
git://github.com/rogerq/linux.git arm-for-next-usbhost9-part

--
cheeer,
-roger

[1] - In practice we would need to access the PHY to work around Silicon Erratas
      in the OMAP's USB Host IP.

Roger Quadros (14):
  mfd: omap-usb-host: Consolidate OMAP USB-HS platform data
  usb: phy: Add new API usb_get_phy_from_dev()
  usb: xceiv: nop: Manage PHY clock
  usb: phy: nop: Handle power supply regulator for the PHY
  usb: phy: nop: Handle RESET for the PHY
  mfd: omap-usb-host: update nports in platform_data
  usb: ehci-omap: Instantiate PHY devices if required
  mfd: omap-usb-host: Remove PHY reset handling code
  usb: ehci-omap: Remove PHY reset handling code
  usb: ehci-omap: Remove PHY regulator handling code
  ARM: OMAP2+: omap4panda: Provide USB Host's PHY platform data
  ARM: OMAP2+: omap4panda: Adapt HUB power to regulator framework
  ARM: OMAP2+: omap4panda: Adapt HUB reset to regulator framework
  ARM: OMAP2+: omap4panda: Remove irrelevant USB host platform data

 arch/arm/mach-omap2/board-3430sdp.c        |    2 +-
 arch/arm/mach-omap2/board-3630sdp.c        |    2 +-
 arch/arm/mach-omap2/board-am3517crane.c    |    2 +-
 arch/arm/mach-omap2/board-am3517evm.c      |    2 +-
 arch/arm/mach-omap2/board-cm-t35.c         |    2 +-
 arch/arm/mach-omap2/board-cm-t3517.c       |    2 +-
 arch/arm/mach-omap2/board-devkit8000.c     |    2 +-
 arch/arm/mach-omap2/board-igep0020.c       |    4 +-
 arch/arm/mach-omap2/board-omap3beagle.c    |    2 +-
 arch/arm/mach-omap2/board-omap3evm.c       |    2 +-
 arch/arm/mach-omap2/board-omap3pandora.c   |    2 +-
 arch/arm/mach-omap2/board-omap3stalker.c   |    2 +-
 arch/arm/mach-omap2/board-omap3touchbook.c |    2 +-
 arch/arm/mach-omap2/board-omap4panda.c     |  117 +++++++++++++-----
 arch/arm/mach-omap2/board-overo.c          |    2 +-
 arch/arm/mach-omap2/board-zoom.c           |    2 +-
 arch/arm/mach-omap2/usb-host.c             |   30 +----
 arch/arm/mach-omap2/usb.h                  |   21 +---
 drivers/mfd/omap-usb-host.c                |   64 +---------
 drivers/mfd/omap-usb-tll.c                 |    8 +-
 drivers/usb/host/ehci-omap.c               |  182 ++++++++++++++--------------
 drivers/usb/otg/nop-usb-xceiv.c            |   86 +++++++++++++
 drivers/usb/otg/otg.c                      |   36 ++++++
 include/linux/platform_data/usb-omap.h     |   28 ++---
 include/linux/usb/nop-usb-xceiv.h          |    1 +
 include/linux/usb/phy.h                    |    6 +
 26 files changed, 345 insertions(+), 266 deletions(-)

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 23:45   ` Tony Lindgren
  2013-01-10 16:51 ` [PATCH 02/14] usb: phy: Add new API usb_get_phy_from_dev() Roger Quadros
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

Let's have a single platform data structure for the OMAP's High-Speed
USB host subsystem instead of having 3 separate ones i.e. one for
board data, one for USB Host (UHH) module and one for USB-TLL module.

This makes the code much simpler and avoids creating multiple copies of
platform data.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 arch/arm/mach-omap2/board-3430sdp.c        |    2 +-
 arch/arm/mach-omap2/board-3630sdp.c        |    2 +-
 arch/arm/mach-omap2/board-am3517crane.c    |    2 +-
 arch/arm/mach-omap2/board-am3517evm.c      |    2 +-
 arch/arm/mach-omap2/board-cm-t35.c         |    2 +-
 arch/arm/mach-omap2/board-cm-t3517.c       |    2 +-
 arch/arm/mach-omap2/board-devkit8000.c     |    2 +-
 arch/arm/mach-omap2/board-igep0020.c       |    4 +-
 arch/arm/mach-omap2/board-omap3beagle.c    |    2 +-
 arch/arm/mach-omap2/board-omap3evm.c       |    2 +-
 arch/arm/mach-omap2/board-omap3pandora.c   |    2 +-
 arch/arm/mach-omap2/board-omap3stalker.c   |    2 +-
 arch/arm/mach-omap2/board-omap3touchbook.c |    2 +-
 arch/arm/mach-omap2/board-omap4panda.c     |    2 +-
 arch/arm/mach-omap2/board-overo.c          |    2 +-
 arch/arm/mach-omap2/board-zoom.c           |    2 +-
 arch/arm/mach-omap2/usb-host.c             |   30 +++---------------
 arch/arm/mach-omap2/usb.h                  |   21 +------------
 drivers/mfd/omap-usb-host.c                |   46 ++++++++++++----------------
 drivers/mfd/omap-usb-tll.c                 |    8 ++--
 drivers/usb/host/ehci-omap.c               |    6 ++--
 include/linux/platform_data/usb-omap.h     |   26 ++++------------
 22 files changed, 56 insertions(+), 115 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index bb73afc..46147c8 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -424,7 +424,7 @@ static void enable_board_wakeup_source(void)
 		OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
 }
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/arch/arm/mach-omap2/board-3630sdp.c b/arch/arm/mach-omap2/board-3630sdp.c
index 050aaa7..78b1724 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -53,7 +53,7 @@ static void enable_board_wakeup_source(void)
 		OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
 }
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/arch/arm/mach-omap2/board-am3517crane.c b/arch/arm/mach-omap2/board-am3517crane.c
index 51b96a1..26f1916 100644
--- a/arch/arm/mach-omap2/board-am3517crane.c
+++ b/arch/arm/mach-omap2/board-am3517crane.c
@@ -40,7 +40,7 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct usbhs_omap_board_data usbhs_bdata __initdata = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
index f81a303..c76725d 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -274,7 +274,7 @@ static __init void am3517_evm_mcbsp1_init(void)
 	omap_ctrl_writel(devconf0, OMAP2_CONTROL_DEVCONF0);
 }
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
 		defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index b3102c2..cdf1d6e 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -418,7 +418,7 @@ static struct omap2_hsmmc_info mmc[] = {
 	{}	/* Terminator */
 };
 
-static struct usbhs_omap_board_data usbhs_bdata __initdata = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-cm-t3517.c b/arch/arm/mach-omap2/board-cm-t3517.c
index ebbc2ad..cfa9098 100644
--- a/arch/arm/mach-omap2/board-cm-t3517.c
+++ b/arch/arm/mach-omap2/board-cm-t3517.c
@@ -166,7 +166,7 @@ static inline void cm_t3517_init_rtc(void) {}
 #define HSUSB2_RESET_GPIO	(147)
 #define USB_HUB_RESET_GPIO	(152)
 
-static struct usbhs_omap_board_data cm_t3517_ehci_pdata __initdata = {
+static struct usbhs_omap_platform_data cm_t3517_ehci_pdata __initdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 12865af..051ec0d 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -435,7 +435,7 @@ static struct platform_device *devkit8000_devices[] __initdata = {
 	&omap_dm9000_dev,
 };
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index 0f24cb8..cfba790 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -526,7 +526,7 @@ static void __init igep_i2c_init(void)
 	omap3_pmic_init("twl4030", &igep_twldata);
 }
 
-static const struct usbhs_omap_board_data igep2_usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data igep2_usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
@@ -537,7 +537,7 @@ static const struct usbhs_omap_board_data igep2_usbhs_bdata __initconst = {
 	.reset_gpio_port[2] = -EINVAL,
 };
 
-static const struct usbhs_omap_board_data igep3_usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data igep3_usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 22c483d..1cb114e 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -430,7 +430,7 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
 	&madc_hwmon,
 };
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
 	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 3985f35..7bdc8a4 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -538,7 +538,7 @@ static int __init omap3_evm_i2c_init(void)
 	return 0;
 }
 
-static struct usbhs_omap_board_data usbhs_bdata __initdata = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
 	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index a53a668..145a6f8 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -567,7 +567,7 @@ static struct platform_device *omap3pandora_devices[] __initdata = {
 	&pandora_backlight,
 };
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
 	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index 53a6cbc..278ae95 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -361,7 +361,7 @@ static struct platform_device *omap3_stalker_devices[] __initdata = {
 	&keys_gpio,
 };
 
-static struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 263cb9c..65a285f 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -309,7 +309,7 @@ static struct platform_device *omap3_touchbook_devices[] __initdata = {
 	&keys_gpio,
 };
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index 5c8e9ce..ee76830 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -139,7 +139,7 @@ static struct platform_device *panda_devices[] __initdata = {
 	&btwilink_device,
 };
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index c8fde3e..b1b0f09 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -457,7 +457,7 @@ static int __init overo_spi_init(void)
 	return 0;
 }
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/board-zoom.c b/arch/arm/mach-omap2/board-zoom.c
index d7fa31e..2d7a457 100644
--- a/arch/arm/mach-omap2/board-zoom.c
+++ b/arch/arm/mach-omap2/board-zoom.c
@@ -92,7 +92,7 @@ static struct mtd_partition zoom_nand_partitions[] = {
 	},
 };
 
-static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
+static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0]		= OMAP_USBHS_PORT_MODE_UNUSED,
 	.port_mode[1]		= OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[2]		= OMAP_USBHS_PORT_MODE_UNUSED,
diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
index ee8c473..940aad4 100644
--- a/arch/arm/mach-omap2/usb-host.c
+++ b/arch/arm/mach-omap2/usb-host.c
@@ -37,11 +37,6 @@
 #define	USBHS_UHH_HWMODNAME	"usb_host_hs"
 #define USBHS_TLL_HWMODNAME	"usb_tll_hs"
 
-static struct usbhs_omap_platform_data		usbhs_data;
-static struct usbtll_omap_platform_data		usbtll_data;
-static struct ehci_hcd_omap_platform_data	ehci_data;
-static struct ohci_hcd_omap_platform_data	ohci_data;
-
 static struct omap_device_pm_latency omap_uhhtll_latency[] = {
 	  {
 		.deactivate_func = omap_device_idle_hwmods,
@@ -485,33 +480,18 @@ void __init setup_4430ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
 	}
 }
 
-void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
+void __init usbhs_init(struct usbhs_omap_platform_data *pdata)
 {
 	struct omap_hwmod	*uhh_hwm, *tll_hwm;
 	struct platform_device	*pdev;
 	int			bus_id = -1;
-	int			i;
-
-	for (i = 0; i < OMAP3_HS_USB_PORTS; i++) {
-		usbhs_data.port_mode[i] = pdata->port_mode[i];
-		usbtll_data.port_mode[i] = pdata->port_mode[i];
-		ohci_data.port_mode[i] = pdata->port_mode[i];
-		ehci_data.port_mode[i] = pdata->port_mode[i];
-		ehci_data.reset_gpio_port[i] = pdata->reset_gpio_port[i];
-		ehci_data.regulator[i] = pdata->regulator[i];
-	}
-	ehci_data.phy_reset = pdata->phy_reset;
-	ohci_data.es2_compatibility = pdata->es2_compatibility;
-	usbhs_data.ehci_data = &ehci_data;
-	usbhs_data.ohci_data = &ohci_data;
-	usbhs_data.nports = pdata->nports;
 
 	if (cpu_is_omap34xx()) {
 		setup_ehci_io_mux(pdata->port_mode);
 		setup_ohci_io_mux(pdata->port_mode);
 
 		if (omap_rev() <= OMAP3430_REV_ES2_1)
-			usbhs_data.single_ulpi_bypass = true;
+			pdata->single_ulpi_bypass = true;
 
 	} else if (cpu_is_omap44xx()) {
 		setup_4430ehci_io_mux(pdata->port_mode);
@@ -531,7 +511,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
 	}
 
 	pdev = omap_device_build(OMAP_USBTLL_DEVICE, bus_id, tll_hwm,
-				&usbtll_data, sizeof(usbtll_data),
+				pdata, sizeof(*pdata),
 				omap_uhhtll_latency,
 				ARRAY_SIZE(omap_uhhtll_latency), false);
 	if (IS_ERR(pdev)) {
@@ -541,7 +521,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
 	}
 
 	pdev = omap_device_build(OMAP_USBHS_DEVICE, bus_id, uhh_hwm,
-				&usbhs_data, sizeof(usbhs_data),
+				pdata, sizeof(*pdata),
 				omap_uhhtll_latency,
 				ARRAY_SIZE(omap_uhhtll_latency), false);
 	if (IS_ERR(pdev)) {
@@ -553,7 +533,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
 
 #else
 
-void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
+void __init usbhs_init(struct usbhs_omap_platform_data *pdata)
 {
 }
 
diff --git a/arch/arm/mach-omap2/usb.h b/arch/arm/mach-omap2/usb.h
index 7dc0f04..3319f5c 100644
--- a/arch/arm/mach-omap2/usb.h
+++ b/arch/arm/mach-omap2/usb.h
@@ -53,27 +53,8 @@
 #define USBPHY_OTGSESSEND_EN	(1 << 20)
 #define USBPHY_DATA_POLARITY	(1 << 23)
 
-struct usbhs_omap_board_data {
-	int				nports;
-	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
-
-	/* have to be valid if phy_reset is true and portx is in phy mode */
-	int	reset_gpio_port[OMAP3_HS_USB_PORTS];
-
-	/* Set this to true for ES2.x silicon */
-	unsigned			es2_compatibility:1;
-
-	unsigned			phy_reset:1;
-
-	/*
-	 * Regulators for USB PHYs.
-	 * Each PHY can have a separate regulator.
-	 */
-	struct regulator		*regulator[OMAP3_HS_USB_PORTS];
-};
-
 extern void usb_musb_init(struct omap_musb_board_data *board_data);
-extern void usbhs_init(const struct usbhs_omap_board_data *pdata);
+extern void usbhs_init(struct usbhs_omap_platform_data *pdata);
 
 extern void am35x_musb_reset(void);
 extern void am35x_musb_phy_power(u8 on);
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 9612535..7180b00 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -185,19 +185,13 @@ err_end:
 static int omap_usbhs_alloc_children(struct platform_device *pdev)
 {
 	struct device				*dev = &pdev->dev;
-	struct usbhs_hcd_omap			*omap;
-	struct ehci_hcd_omap_platform_data	*ehci_data;
-	struct ohci_hcd_omap_platform_data	*ohci_data;
+	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
 	struct platform_device			*ehci;
 	struct platform_device			*ohci;
 	struct resource				*res;
 	struct resource				resources[2];
 	int					ret;
 
-	omap = platform_get_drvdata(pdev);
-	ehci_data = omap->pdata->ehci_data;
-	ohci_data = omap->pdata->ohci_data;
-
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci");
 	if (!res) {
 		dev_err(dev, "EHCI get resource IORESOURCE_MEM failed\n");
@@ -214,8 +208,8 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev)
 	}
 	resources[1] = *res;
 
-	ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, ehci_data,
-		sizeof(*ehci_data), dev);
+	ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, pdata,
+		sizeof(*pdata), dev);
 
 	if (!ehci) {
 		dev_err(dev, "omap_usbhs_alloc_child failed\n");
@@ -239,8 +233,8 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev)
 	}
 	resources[1] = *res;
 
-	ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, ohci_data,
-		sizeof(*ohci_data), dev);
+	ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, pdata,
+		sizeof(*pdata), dev);
 	if (!ohci) {
 		dev_err(dev, "omap_usbhs_alloc_child failed\n");
 		ret = -ENOMEM;
@@ -441,13 +435,13 @@ static void omap_usbhs_init(struct device *dev)
 
 	dev_dbg(dev, "starting TI HSUSB Controller\n");
 
-	if (pdata->ehci_data->phy_reset) {
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
-			gpio_request_one(pdata->ehci_data->reset_gpio_port[0],
+	if (pdata->phy_reset) {
+		if (gpio_is_valid(pdata->reset_gpio_port[0]))
+			gpio_request_one(pdata->reset_gpio_port[0],
 					 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
 
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
-			gpio_request_one(pdata->ehci_data->reset_gpio_port[1],
+		if (gpio_is_valid(pdata->reset_gpio_port[1]))
+			gpio_request_one(pdata->reset_gpio_port[1],
 					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
 
 		/* Hold the PHY in RESET for enough time till DIR is high */
@@ -473,19 +467,19 @@ static void omap_usbhs_init(struct device *dev)
 	dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg);
 
 	pm_runtime_put_sync(dev);
-	if (pdata->ehci_data->phy_reset) {
+	if (pdata->phy_reset) {
 		/* Hold the PHY in RESET for enough time till
 		 * PHY is settled and ready
 		 */
 		udelay(10);
 
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
+		if (gpio_is_valid(pdata->reset_gpio_port[0]))
 			gpio_set_value_cansleep
-				(pdata->ehci_data->reset_gpio_port[0], 1);
+				(pdata->reset_gpio_port[0], 1);
 
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+		if (gpio_is_valid(pdata->reset_gpio_port[1]))
 			gpio_set_value_cansleep
-				(pdata->ehci_data->reset_gpio_port[1], 1);
+				(pdata->reset_gpio_port[1], 1);
 	}
 }
 
@@ -494,12 +488,12 @@ static void omap_usbhs_deinit(struct device *dev)
 	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
 	struct usbhs_omap_platform_data	*pdata = omap->pdata;
 
-	if (pdata->ehci_data->phy_reset) {
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
-			gpio_free(pdata->ehci_data->reset_gpio_port[0]);
+	if (pdata->phy_reset) {
+		if (gpio_is_valid(pdata->reset_gpio_port[0]))
+			gpio_free(pdata->reset_gpio_port[0]);
 
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
-			gpio_free(pdata->ehci_data->reset_gpio_port[1]);
+		if (gpio_is_valid(pdata->reset_gpio_port[1]))
+			gpio_free(pdata->reset_gpio_port[1]);
 	}
 }
 
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
index e63dc0b..a729cf3 100644
--- a/drivers/mfd/omap-usb-tll.c
+++ b/drivers/mfd/omap-usb-tll.c
@@ -105,7 +105,7 @@
 
 struct usbtll_omap {
 	int					nch;	/* num. of channels */
-	struct usbtll_omap_platform_data	*pdata;
+	struct usbhs_omap_platform_data		*pdata;
 	struct clk				**ch_clk;
 };
 
@@ -210,7 +210,7 @@ static unsigned ohci_omap3_fslsmode(enum usbhs_omap_port_mode mode)
 static int usbtll_omap_probe(struct platform_device *pdev)
 {
 	struct device				*dev =  &pdev->dev;
-	struct usbtll_omap_platform_data	*pdata = dev->platform_data;
+	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
 	void __iomem				*base;
 	struct resource				*res;
 	struct usbtll_omap			*tll;
@@ -376,7 +376,7 @@ static int usbtll_omap_remove(struct platform_device *pdev)
 static int usbtll_runtime_resume(struct device *dev)
 {
 	struct usbtll_omap			*tll = dev_get_drvdata(dev);
-	struct usbtll_omap_platform_data	*pdata = tll->pdata;
+	struct usbhs_omap_platform_data		*pdata = tll->pdata;
 	int i;
 
 	dev_dbg(dev, "usbtll_runtime_resume\n");
@@ -402,7 +402,7 @@ static int usbtll_runtime_resume(struct device *dev)
 static int usbtll_runtime_suspend(struct device *dev)
 {
 	struct usbtll_omap			*tll = dev_get_drvdata(dev);
-	struct usbtll_omap_platform_data	*pdata = tll->pdata;
+	struct usbhs_omap_platform_data		*pdata = tll->pdata;
 	int i;
 
 	dev_dbg(dev, "usbtll_runtime_suspend\n");
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index e9d9b09..b96a4bf 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -107,7 +107,7 @@ static int omap_ehci_init(struct usb_hcd *hcd)
 {
 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
 	int			rc;
-	struct ehci_hcd_omap_platform_data	*pdata;
+	struct usbhs_omap_platform_data	*pdata;
 
 	pdata = hcd->self.controller->platform_data;
 
@@ -151,7 +151,7 @@ static int omap_ehci_init(struct usb_hcd *hcd)
 }
 
 static void disable_put_regulator(
-		struct ehci_hcd_omap_platform_data *pdata)
+		struct usbhs_omap_platform_data *pdata)
 {
 	int i;
 
@@ -176,7 +176,7 @@ static void disable_put_regulator(
 static int ehci_hcd_omap_probe(struct platform_device *pdev)
 {
 	struct device				*dev = &pdev->dev;
-	struct ehci_hcd_omap_platform_data	*pdata = dev->platform_data;
+	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
 	struct resource				*res;
 	struct usb_hcd				*hcd;
 	void __iomem				*regs;
diff --git a/include/linux/platform_data/usb-omap.h b/include/linux/platform_data/usb-omap.h
index 57707c7..d63eb7d 100644
--- a/include/linux/platform_data/usb-omap.h
+++ b/include/linux/platform_data/usb-omap.h
@@ -38,31 +38,17 @@ enum usbhs_omap_port_mode {
 	OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM
 };
 
-struct usbtll_omap_platform_data {
-	enum usbhs_omap_port_mode		port_mode[OMAP3_HS_USB_PORTS];
-};
-
-struct ehci_hcd_omap_platform_data {
+struct usbhs_omap_platform_data {
+	int				nports;
 	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
 	int				reset_gpio_port[OMAP3_HS_USB_PORTS];
-	struct regulator		*regulator[OMAP3_HS_USB_PORTS];
-	unsigned			phy_reset:1;
-};
 
-struct ohci_hcd_omap_platform_data {
-	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
-	unsigned			es2_compatibility:1;
-};
-
-struct usbhs_omap_platform_data {
-	int					nports;
-	enum usbhs_omap_port_mode		port_mode[OMAP3_HS_USB_PORTS];
-
-	struct ehci_hcd_omap_platform_data	*ehci_data;
-	struct ohci_hcd_omap_platform_data	*ohci_data;
+	struct regulator		*regulator[OMAP3_HS_USB_PORTS];
 
 	/* OMAP3 <= ES2.1 have a single ulpi bypass control bit */
-	unsigned				single_ulpi_bypass:1;
+	unsigned			single_ulpi_bypass:1;
+	unsigned			es2_compatibility:1;
+	unsigned			phy_reset:1;
 };
 
 /*-------------------------------------------------------------------------*/
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 02/14] usb: phy: Add new API usb_get_phy_from_dev()
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
  2013-01-10 16:51 ` [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 16:51 ` [PATCH 03/14] usb: xceiv: nop: Manage PHY clock Roger Quadros
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

This API allows PHY users to get the usb_phy data structure
from a device handle.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/otg/otg.c   |   36 ++++++++++++++++++++++++++++++++++++
 include/linux/usb/phy.h |    6 ++++++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index a30c041..ba3a568 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -35,6 +35,21 @@ static struct usb_phy *__usb_find_phy(struct list_head *list,
 	return ERR_PTR(-ENODEV);
 }
 
+static struct usb_phy *__usb_find_phy_dev(struct list_head *list,
+	struct device *dev)
+{
+	struct usb_phy *phy;
+
+	list_for_each_entry(phy, list, head) {
+		if (phy->dev != dev)
+			continue;
+
+		return phy;
+	}
+
+	return ERR_PTR(-ENODEV);
+}
+
 static void devm_usb_phy_release(struct device *dev, void *res)
 {
 	struct usb_phy *phy = *(struct usb_phy **)res;
@@ -77,6 +92,27 @@ struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
 }
 EXPORT_SYMBOL(devm_usb_get_phy);
 
+struct usb_phy *usb_get_phy_from_dev(struct device *dev)
+{
+	struct usb_phy *phy = NULL;
+	unsigned long flags;
+
+	spin_lock_irqsave(&phy_lock, flags);
+
+	phy = __usb_find_phy_dev(&phy_list, dev);
+	if (IS_ERR(phy)) {
+		dev_err(dev, "%s: unable to find PHY\n", __func__);
+		goto done;
+	}
+
+	get_device(phy->dev);
+
+done:
+	spin_unlock_irqrestore(&phy_lock, flags);
+	return phy;
+}
+EXPORT_SYMBOL(usb_get_phy_from_dev);
+
 /**
  * usb_get_phy - find the USB PHY
  * @type - the type of the phy the controller requires
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index a29ae1e..cd798c4 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -147,6 +147,7 @@ usb_phy_shutdown(struct usb_phy *x)
 /* for usb host and peripheral controller drivers */
 #ifdef CONFIG_USB_OTG_UTILS
 extern struct usb_phy *usb_get_phy(enum usb_phy_type type);
+extern struct usb_phy *usb_get_phy_from_dev(struct device *dev);
 extern struct usb_phy *devm_usb_get_phy(struct device *dev,
 	enum usb_phy_type type);
 extern void usb_put_phy(struct usb_phy *);
@@ -157,6 +158,11 @@ static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
 	return NULL;
 }
 
+static inline struct usb_phy *usb_get_phy_from_dev(struct device *dev)
+{
+	return NULL;
+}
+
 static inline struct usb_phy *devm_usb_get_phy(struct device *dev,
 	enum usb_phy_type type)
 {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 03/14] usb: xceiv: nop: Manage PHY clock
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
  2013-01-10 16:51 ` [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data Roger Quadros
  2013-01-10 16:51 ` [PATCH 02/14] usb: phy: Add new API usb_get_phy_from_dev() Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 16:51 ` [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY Roger Quadros
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

If the PHY has a clock associated to it then manage the clock.
We just enable the clock in .init() and disable it in .shutdown().

Add clk_rate parameter in platform data and configure the
clock rate during probe if supplied.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/otg/nop-usb-xceiv.c   |   49 +++++++++++++++++++++++++++++++++++++
 include/linux/usb/nop-usb-xceiv.h |    1 +
 2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index a3ce24b..163f972 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -32,10 +32,12 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/nop-usb-xceiv.h>
 #include <linux/slab.h>
+#include <linux/clk.h>
 
 struct nop_usb_xceiv {
 	struct usb_phy		phy;
 	struct device		*dev;
+	struct clk		*clk;
 };
 
 static struct platform_device *pd;
@@ -64,6 +66,24 @@ static int nop_set_suspend(struct usb_phy *x, int suspend)
 	return 0;
 }
 
+static int nop_init(struct usb_phy *phy)
+{
+	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
+
+	if (nop->clk)
+		clk_enable(nop->clk);
+
+	return 0;
+}
+
+static void nop_shutdown(struct usb_phy *phy)
+{
+	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
+
+	if (nop->clk)
+		clk_disable(nop->clk);
+}
+
 static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
 {
 	if (!otg)
@@ -113,10 +133,36 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
 	if (pdata)
 		type = pdata->type;
 
+	nop->clk = devm_clk_get(&pdev->dev, "main_clk");
+	if (IS_ERR(nop->clk)) {
+		dev_dbg(&pdev->dev, "Can't get phy clock\n");
+		nop->clk = NULL;
+	}
+
+	if (nop->clk && pdata && pdata->clk_rate) {
+		err = clk_set_rate(nop->clk, pdata->clk_rate);
+		if (err) {
+			dev_err(&pdev->dev,
+					"Error setting clock rate\n");
+			goto exit;
+		}
+	}
+
+	if (nop->clk) {
+		err = clk_prepare(nop->clk);
+		if (err) {
+			dev_err(&pdev->dev,
+					"Error preparing clock\n");
+			goto exit;
+		}
+	}
+
 	nop->dev		= &pdev->dev;
 	nop->phy.dev		= nop->dev;
 	nop->phy.label		= "nop-xceiv";
 	nop->phy.set_suspend	= nop_set_suspend;
+	nop->phy.init		= nop_init;
+	nop->phy.shutdown	= nop_shutdown;
 	nop->phy.state		= OTG_STATE_UNDEFINED;
 
 	nop->phy.otg->phy		= &nop->phy;
@@ -145,6 +191,9 @@ static int nop_usb_xceiv_remove(struct platform_device *pdev)
 {
 	struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);
 
+	if (nop->clk)
+		clk_unprepare(nop->clk);
+
 	usb_remove_phy(&nop->phy);
 
 	platform_set_drvdata(pdev, NULL);
diff --git a/include/linux/usb/nop-usb-xceiv.h b/include/linux/usb/nop-usb-xceiv.h
index 28884c7..3265b61 100644
--- a/include/linux/usb/nop-usb-xceiv.h
+++ b/include/linux/usb/nop-usb-xceiv.h
@@ -5,6 +5,7 @@
 
 struct nop_usb_xceiv_platform_data {
 	enum usb_phy_type type;
+	unsigned long clk_rate;
 };
 
 #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE))
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (2 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 03/14] usb: xceiv: nop: Manage PHY clock Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 18:06   ` Sergei Shtylyov
  2013-01-11 17:17   ` Russell King - ARM Linux
  2013-01-10 16:51 ` [PATCH 05/14] usb: phy: nop: Handle RESET " Roger Quadros
                   ` (9 subsequent siblings)
  13 siblings, 2 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

We use "vcc" as the supply name for the PHY's power supply.
The power supply will be enabled during .init() and disabled
during .shutdown()

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/otg/nop-usb-xceiv.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index 163f972..1c6db10 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -33,11 +33,13 @@
 #include <linux/usb/nop-usb-xceiv.h>
 #include <linux/slab.h>
 #include <linux/clk.h>
+#include <linux/regulator/consumer.h>
 
 struct nop_usb_xceiv {
 	struct usb_phy		phy;
 	struct device		*dev;
 	struct clk		*clk;
+	struct regulator	*vcc;
 };
 
 static struct platform_device *pd;
@@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
 {
 	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
 
+	if (nop->vcc) {
+		if (regulator_enable(nop->vcc))
+			dev_err(phy->dev, "Failed to enable power\n");
+	}
+
 	if (nop->clk)
 		clk_enable(nop->clk);
 
@@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
 
 	if (nop->clk)
 		clk_disable(nop->clk);
+
+	if (nop->vcc) {
+		if (regulator_disable(nop->vcc))
+			dev_err(phy->dev, "Failed to disable power\n");
+	}
 }
 
 static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
@@ -157,6 +169,12 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
 		}
 	}
 
+	nop->vcc = devm_regulator_get(&pdev->dev, "vcc");
+	if (IS_ERR(nop->vcc)) {
+		dev_dbg(&pdev->dev, "Error getting vcc regulator\n");
+		nop->vcc = NULL;
+	}
+
 	nop->dev		= &pdev->dev;
 	nop->phy.dev		= nop->dev;
 	nop->phy.label		= "nop-xceiv";
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 05/14] usb: phy: nop: Handle RESET for the PHY
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (3 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 16:51 ` [PATCH 06/14] mfd: omap-usb-host: update nports in platform_data Roger Quadros
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

We expect the RESET line to be modeled as a regulator with supply
name "reset". The regulator should be modeled such that enabling
the regulator brings the PHY device out of RESET and disabling the
regulator holds the device in RESET.

They PHY will be held in RESET in .shutdown() and brought out of
RESET in .init().

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/otg/nop-usb-xceiv.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index 1c6db10..8fd49a8 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -40,6 +40,7 @@ struct nop_usb_xceiv {
 	struct device		*dev;
 	struct clk		*clk;
 	struct regulator	*vcc;
+	struct regulator	*reset;
 };
 
 static struct platform_device *pd;
@@ -80,6 +81,12 @@ static int nop_init(struct usb_phy *phy)
 	if (nop->clk)
 		clk_enable(nop->clk);
 
+	if (nop->reset) {
+		/* De-assert RESET */
+		if (regulator_enable(nop->reset))
+			dev_err(phy->dev, "Failed to de-assert reset\n");
+	}
+
 	return 0;
 }
 
@@ -87,6 +94,12 @@ static void nop_shutdown(struct usb_phy *phy)
 {
 	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
 
+	if (nop->reset) {
+		/* Assert RESET */
+		if (regulator_disable(nop->reset))
+			dev_err(phy->dev, "Failed to assert reset\n");
+	}
+
 	if (nop->clk)
 		clk_disable(nop->clk);
 
@@ -175,6 +188,12 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
 		nop->vcc = NULL;
 	}
 
+	nop->reset = devm_regulator_get(&pdev->dev, "reset");
+	if (IS_ERR(nop->reset)) {
+		dev_dbg(&pdev->dev, "Error getting reset regulator\n");
+		nop->reset = NULL;
+	}
+
 	nop->dev		= &pdev->dev;
 	nop->phy.dev		= nop->dev;
 	nop->phy.label		= "nop-xceiv";
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 06/14] mfd: omap-usb-host: update nports in platform_data
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (4 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 05/14] usb: phy: nop: Handle RESET " Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-22  3:29   ` Samuel Ortiz
  2013-01-10 16:51 ` [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required Roger Quadros
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

EHCI driver would need to know the number of ports available
on the platform. We set the nports parameter of platform_data
based on IP version if it was not already provided.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/mfd/omap-usb-host.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 7180b00..5c1c3ae 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -564,6 +564,7 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 			 omap->usbhs_rev, omap->nports);
 			break;
 		}
+		pdata->nports = omap->nports;
 	}
 
 	i = sizeof(struct clk *) * omap->nports;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (5 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 06/14] mfd: omap-usb-host: update nports in platform_data Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 20:48   ` Alan Stern
  2013-01-10 16:51 ` [PATCH 08/14] mfd: omap-usb-host: Remove PHY reset handling code Roger Quadros
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

If the OMAP's Host controller is in PHY mode then we instantiate
a platform device for the PHY (one for each port in PHY mode) and
hold a reference to it so that we can use the usb_phy API, e.g.
while suspend/resume.

The platform data for the PHY must be supplied in the newly added
.phy_config parameter in struct usbhs_omap_platform_data.

The end goal is to move the PHY's reset and power handling code
out of the ehci-omap driver and into the phy driver.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/host/ehci-omap.c           |   83 ++++++++++++++++++++++++++++++-
 include/linux/platform_data/usb-omap.h |    8 +++
 2 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index b96a4bf..e6a2d76 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -61,6 +61,11 @@
 
 static const struct hc_driver ehci_omap_hc_driver;
 
+struct omap_ehci_hcd {
+	struct usb_hcd *hcd;
+	struct usb_phy **phy;	/* one PHY for each port */
+	int nports;
+};
 
 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
@@ -179,6 +184,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
 	struct resource				*res;
 	struct usb_hcd				*hcd;
+	struct omap_ehci_hcd			*omap_hcd;
+	struct usb_phy				*phy;
 	void __iomem				*regs;
 	int					ret = -ENODEV;
 	int					irq;
@@ -193,6 +200,25 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	if (!pdata) {
+		dev_err(dev, "Missing platform data\n");
+		return -ENODEV;
+	}
+
+	omap_hcd = devm_kzalloc(&pdev->dev, sizeof(*omap_hcd), GFP_KERNEL);
+	if (!omap_hcd) {
+		dev_err(dev, "Memory allocation failed\n");
+		return -ENOMEM;
+	}
+
+	omap_hcd->nports = pdata->nports;
+	i = sizeof(struct usb_phy *) * omap_hcd->nports;
+	omap_hcd->phy = devm_kzalloc(&pdev->dev, i, GFP_KERNEL);
+	if (!omap_hcd->phy) {
+		dev_err(dev, "Memory allocation failed\n");
+		return -ENOMEM;
+	}
+
 	irq = platform_get_irq_byname(pdev, "ehci-irq");
 	if (irq < 0) {
 		dev_err(dev, "EHCI irq failed\n");
@@ -223,9 +249,15 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 	hcd->regs = regs;
+	omap_hcd->hcd = hcd;
+
+	platform_set_drvdata(pdev, omap_hcd);
 
 	/* get ehci regulator and enable */
-	for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
+	for (i = 0 ; i < omap_hcd->nports ; i++) {
+		struct platform_device *phy_pdev;
+		struct usbhs_phy_config *phy_config;
+
 		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
 			pdata->regulator[i] = NULL;
 			continue;
@@ -239,6 +271,33 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		} else {
 			regulator_enable(pdata->regulator[i]);
 		}
+
+		/* instantiate PHY */
+		if (!pdata->phy_config[i]) {
+			dev_dbg(dev, "missing phy_config for port %d\n", i);
+			continue;
+		}
+
+		phy_config = pdata->phy_config[i];
+		phy_pdev = platform_device_register_data(&pdev->dev,
+				phy_config->name, i, phy_config->pdata,
+				phy_config->pdata_size);
+		if (IS_ERR(phy_pdev)) {
+			dev_dbg(dev, "error creating PHY device for port %d\n",
+					i);
+		}
+
+		phy = usb_get_phy_from_dev(&phy_pdev->dev);
+		if (IS_ERR(phy)) {
+			dev_dbg(dev, "could not get USB PHY for port %d\n", i);
+			platform_device_unregister(phy_pdev);
+			continue;
+		}
+
+		usb_phy_init(phy);
+		omap_hcd->phy[i] = phy;
+		/* bring PHY out of suspend */
+		usb_phy_set_suspend(omap_hcd->phy[i], 0);
 	}
 
 	pm_runtime_enable(dev);
@@ -269,6 +328,12 @@ err_pm_runtime:
 	disable_put_regulator(pdata);
 	pm_runtime_put_sync(dev);
 	usb_put_hcd(hcd);
+	for (i = 0 ; i < omap_hcd->nports ; i++) {
+		phy = omap_hcd->phy[i];
+		if (!phy)
+			continue;
+		platform_device_unregister(to_platform_device(phy->dev));
+	}
 
 err_io:
 	iounmap(regs);
@@ -286,14 +351,26 @@ err_io:
  */
 static int ehci_hcd_omap_remove(struct platform_device *pdev)
 {
-	struct device *dev				= &pdev->dev;
-	struct usb_hcd *hcd				= dev_get_drvdata(dev);
+	struct device *dev		= &pdev->dev;
+	struct omap_ehci_hcd *omap_hcd	= dev_get_drvdata(dev);
+	struct usb_hcd *hcd		= omap_hcd->hcd;
+	int i;
 
 	usb_remove_hcd(hcd);
 	disable_put_regulator(dev->platform_data);
 	iounmap(hcd->regs);
 	usb_put_hcd(hcd);
 
+	for (i = 0; i < omap_hcd->nports; i++) {
+		struct usb_phy *phy = omap_hcd->phy[i];
+
+		if (!phy)
+			continue;
+
+		usb_phy_shutdown(phy);
+		platform_device_unregister(to_platform_device(phy->dev));
+	}
+
 	pm_runtime_put_sync(dev);
 	pm_runtime_disable(dev);
 
diff --git a/include/linux/platform_data/usb-omap.h b/include/linux/platform_data/usb-omap.h
index d63eb7d..927b8a1 100644
--- a/include/linux/platform_data/usb-omap.h
+++ b/include/linux/platform_data/usb-omap.h
@@ -38,6 +38,12 @@ enum usbhs_omap_port_mode {
 	OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM
 };
 
+struct usbhs_phy_config {
+	char *name;		/* binds to device driver */
+	void *pdata;		/* platform data for the phy */
+	size_t pdata_size;
+};
+
 struct usbhs_omap_platform_data {
 	int				nports;
 	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
@@ -49,6 +55,8 @@ struct usbhs_omap_platform_data {
 	unsigned			single_ulpi_bypass:1;
 	unsigned			es2_compatibility:1;
 	unsigned			phy_reset:1;
+
+	struct usbhs_phy_config		*phy_config[OMAP3_HS_USB_PORTS];
 };
 
 /*-------------------------------------------------------------------------*/
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 08/14] mfd: omap-usb-host: Remove PHY reset handling code
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (6 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-22  3:28   ` Samuel Ortiz
  2013-01-10 16:51 ` [PATCH 09/14] usb: ehci-omap: " Roger Quadros
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

PHY reset GPIO handling will be done in the PHY driver

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/mfd/omap-usb-host.c |   47 -------------------------------------------
 1 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 5c1c3ae..7547448 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -430,24 +430,10 @@ static unsigned omap_usbhs_rev2_hostconfig(struct usbhs_hcd_omap *omap,
 static void omap_usbhs_init(struct device *dev)
 {
 	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
-	struct usbhs_omap_platform_data	*pdata = omap->pdata;
 	unsigned			reg;
 
 	dev_dbg(dev, "starting TI HSUSB Controller\n");
 
-	if (pdata->phy_reset) {
-		if (gpio_is_valid(pdata->reset_gpio_port[0]))
-			gpio_request_one(pdata->reset_gpio_port[0],
-					 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
-
-		if (gpio_is_valid(pdata->reset_gpio_port[1]))
-			gpio_request_one(pdata->reset_gpio_port[1],
-					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
-
-		/* Hold the PHY in RESET for enough time till DIR is high */
-		udelay(10);
-	}
-
 	pm_runtime_get_sync(dev);
 
 	reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG);
@@ -467,37 +453,8 @@ static void omap_usbhs_init(struct device *dev)
 	dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg);
 
 	pm_runtime_put_sync(dev);
-	if (pdata->phy_reset) {
-		/* Hold the PHY in RESET for enough time till
-		 * PHY is settled and ready
-		 */
-		udelay(10);
-
-		if (gpio_is_valid(pdata->reset_gpio_port[0]))
-			gpio_set_value_cansleep
-				(pdata->reset_gpio_port[0], 1);
-
-		if (gpio_is_valid(pdata->reset_gpio_port[1]))
-			gpio_set_value_cansleep
-				(pdata->reset_gpio_port[1], 1);
-	}
-}
-
-static void omap_usbhs_deinit(struct device *dev)
-{
-	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
-	struct usbhs_omap_platform_data	*pdata = omap->pdata;
-
-	if (pdata->phy_reset) {
-		if (gpio_is_valid(pdata->reset_gpio_port[0]))
-			gpio_free(pdata->reset_gpio_port[0]);
-
-		if (gpio_is_valid(pdata->reset_gpio_port[1]))
-			gpio_free(pdata->reset_gpio_port[1]);
-	}
 }
 
-
 /**
  * usbhs_omap_probe - initialize TI-based HCDs
  *
@@ -705,8 +662,6 @@ static int usbhs_omap_probe(struct platform_device *pdev)
 	return 0;
 
 err_alloc:
-	omap_usbhs_deinit(&pdev->dev);
-
 	for (i = 0; i < omap->nports; i++) {
 		clk_put(omap->utmi_clk[i]);
 		clk_put(omap->hsic60m_clk[i]);
@@ -747,8 +702,6 @@ static int usbhs_omap_remove(struct platform_device *pdev)
 	struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
 	int i;
 
-	omap_usbhs_deinit(&pdev->dev);
-
 	for (i = 0; i < omap->nports; i++) {
 		clk_put(omap->utmi_clk[i]);
 		clk_put(omap->hsic60m_clk[i]);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 09/14] usb: ehci-omap: Remove PHY reset handling code
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (7 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 08/14] mfd: omap-usb-host: Remove PHY reset handling code Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 16:51 ` [PATCH 10/14] usb: ehci-omap: Remove PHY regulator " Roger Quadros
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

Reset GPIO handling for the PHY must be done in the PHY
driver. We use the PHY helpers instead to reset the PHY.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/host/ehci-omap.c |   70 ++++++------------------------------------
 1 files changed, 10 insertions(+), 60 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index e6a2d76..46b28d6 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -77,79 +77,29 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
 	return __raw_readl(base + reg);
 }
 
-
-static void omap_ehci_soft_phy_reset(struct usb_hcd *hcd, u8 port)
-{
-	unsigned long timeout = jiffies + msecs_to_jiffies(1000);
-	unsigned reg = 0;
-
-	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);
-
-	ehci_write(hcd->regs, EHCI_INSNREG05_ULPI, reg);
-
-	/* Wait for ULPI access completion */
-	while ((ehci_read(hcd->regs, EHCI_INSNREG05_ULPI)
-			& (1 << EHCI_INSNREG05_ULPI_CONTROL_SHIFT))) {
-		cpu_relax();
-
-		if (time_after(jiffies, timeout)) {
-			dev_dbg(hcd->self.controller,
-					"phy reset operation timed out\n");
-			break;
-		}
-	}
-}
-
 static int omap_ehci_init(struct usb_hcd *hcd)
 {
 	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
-	int			rc;
-	struct usbhs_omap_platform_data	*pdata;
+	struct omap_ehci_hcd	*omap_hcd;
+	int			rc, i;
 
-	pdata = hcd->self.controller->platform_data;
+	omap_hcd = dev_get_drvdata(hcd->self.controller);
 
 	/* Hold PHYs in reset while initializing EHCI controller */
-	if (pdata->phy_reset) {
-		if (gpio_is_valid(pdata->reset_gpio_port[0]))
-			gpio_set_value_cansleep(pdata->reset_gpio_port[0], 0);
-
-		if (gpio_is_valid(pdata->reset_gpio_port[1]))
-			gpio_set_value_cansleep(pdata->reset_gpio_port[1], 0);
-
-		/* Hold the PHY in RESET for enough time till DIR is high */
-		udelay(10);
+	for (i = 0; i < omap_hcd->nports; i++) {
+		if (omap_hcd->phy[i])
+			usb_phy_shutdown(omap_hcd->phy[i]);
 	}
 
-	/* Soft reset the PHY using PHY reset command over ULPI */
-	if (pdata->port_mode[0] == OMAP_EHCI_PORT_MODE_PHY)
-		omap_ehci_soft_phy_reset(hcd, 0);
-	if (pdata->port_mode[1] == OMAP_EHCI_PORT_MODE_PHY)
-		omap_ehci_soft_phy_reset(hcd, 1);
-
 	/* we know this is the memory we want, no need to ioremap again */
 	ehci->caps = hcd->regs;
 
 	rc = ehci_setup(hcd);
 
-	if (pdata->phy_reset) {
-		/* Hold the PHY in RESET for enough time till
-		 * PHY is settled and ready
-		 */
-		udelay(10);
-
-		if (gpio_is_valid(pdata->reset_gpio_port[0]))
-			gpio_set_value_cansleep(pdata->reset_gpio_port[0], 1);
-
-		if (gpio_is_valid(pdata->reset_gpio_port[1]))
-			gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);
+	/* Bring PHYs out of reset */
+	for (i = 0; i < omap_hcd->nports; i++) {
+		if (omap_hcd->phy[i])
+			usb_phy_init(omap_hcd->phy[i]);
 	}
 
 	return rc;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 10/14] usb: ehci-omap: Remove PHY regulator handling code
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (8 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 09/14] usb: ehci-omap: " Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 16:51 ` [PATCH 11/14] ARM: OMAP2+: omap4panda: Provide USB Host's PHY platform data Roger Quadros
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

PHY regulator handling must be done in the PHY driver

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/host/ehci-omap.c |   31 +------------------------------
 1 files changed, 1 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 46b28d6..02475c7 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -39,7 +39,6 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/usb/ulpi.h>
-#include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/gpio.h>
 #include <linux/clk.h>
@@ -105,19 +104,6 @@ static int omap_ehci_init(struct usb_hcd *hcd)
 	return rc;
 }
 
-static void disable_put_regulator(
-		struct usbhs_omap_platform_data *pdata)
-{
-	int i;
-
-	for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
-		if (pdata->regulator[i]) {
-			regulator_disable(pdata->regulator[i]);
-			regulator_put(pdata->regulator[i]);
-		}
-	}
-}
-
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */
 
@@ -140,7 +126,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	int					ret = -ENODEV;
 	int					irq;
 	int					i;
-	char					supply[7];
 
 	if (usb_disabled())
 		return -ENODEV;
@@ -203,24 +188,12 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, omap_hcd);
 
-	/* get ehci regulator and enable */
 	for (i = 0 ; i < omap_hcd->nports ; i++) {
 		struct platform_device *phy_pdev;
 		struct usbhs_phy_config *phy_config;
 
-		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
-			pdata->regulator[i] = NULL;
+		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY)
 			continue;
-		}
-		snprintf(supply, sizeof(supply), "hsusb%d", i);
-		pdata->regulator[i] = regulator_get(dev, supply);
-		if (IS_ERR(pdata->regulator[i])) {
-			pdata->regulator[i] = NULL;
-			dev_dbg(dev,
-			"failed to get ehci port%d regulator\n", i);
-		} else {
-			regulator_enable(pdata->regulator[i]);
-		}
 
 		/* instantiate PHY */
 		if (!pdata->phy_config[i]) {
@@ -275,7 +248,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	return 0;
 
 err_pm_runtime:
-	disable_put_regulator(pdata);
 	pm_runtime_put_sync(dev);
 	usb_put_hcd(hcd);
 	for (i = 0 ; i < omap_hcd->nports ; i++) {
@@ -307,7 +279,6 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
 	int i;
 
 	usb_remove_hcd(hcd);
-	disable_put_regulator(dev->platform_data);
 	iounmap(hcd->regs);
 	usb_put_hcd(hcd);
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 11/14] ARM: OMAP2+: omap4panda: Provide USB Host's PHY platform data
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (9 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 10/14] usb: ehci-omap: Remove PHY regulator " Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 16:51 ` [PATCH 12/14] ARM: OMAP2+: omap4panda: Adapt HUB power to regulator framework Roger Quadros
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

Provide platform data for the USB host's PHY.

Also get rid of managing PHY clock. This will now be done by the phy driver.
For that to work we create a clock alias that links the PHY clock name to the
PHY device name.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 arch/arm/mach-omap2/board-omap4panda.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index ee76830..350c4db 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -30,6 +30,7 @@
 #include <linux/regulator/fixed.h>
 #include <linux/ti_wilink_st.h>
 #include <linux/usb/musb.h>
+#include <linux/usb/nop-usb-xceiv.h>
 #include <linux/wl12xx.h>
 #include <linux/platform_data/omap-abe-twl6040.h>
 
@@ -139,6 +140,18 @@ static struct platform_device *panda_devices[] __initdata = {
 	&btwilink_device,
 };
 
+static struct nop_usb_xceiv_platform_data phy_pdata0 = {
+	.type = USB_PHY_TYPE_UNDEFINED,
+	/* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
+	.clk_rate = 19200000,
+};
+
+static struct usbhs_phy_config phy_config0 = {
+	.name = "nop_usb_xceiv",
+	.pdata = &phy_pdata0,
+	.pdata_size = sizeof(phy_pdata0),
+};
+
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
@@ -146,7 +159,8 @@ static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.phy_reset  = false,
 	.reset_gpio_port[0]  = -EINVAL,
 	.reset_gpio_port[1]  = -EINVAL,
-	.reset_gpio_port[2]  = -EINVAL
+	.reset_gpio_port[2]  = -EINVAL,
+	.phy_config[0] = &phy_config0,
 };
 
 static struct gpio panda_ehci_gpios[] __initdata = {
@@ -157,16 +171,6 @@ static struct gpio panda_ehci_gpios[] __initdata = {
 static void __init omap4_ehci_init(void)
 {
 	int ret;
-	struct clk *phy_ref_clk;
-
-	/* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
-	phy_ref_clk = clk_get(NULL, "auxclk3_ck");
-	if (IS_ERR(phy_ref_clk)) {
-		pr_err("Cannot request auxclk3\n");
-		return;
-	}
-	clk_set_rate(phy_ref_clk, 19200000);
-	clk_prepare_enable(phy_ref_clk);
 
 	/* disable the power to the usb hub prior to init and reset phy+hub */
 	ret = gpio_request_array(panda_ehci_gpios,
@@ -180,6 +184,11 @@ static void __init omap4_ehci_init(void)
 	gpio_export(GPIO_HUB_NRESET, 0);
 	gpio_set_value(GPIO_HUB_NRESET, 1);
 
+	/* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
+	ret = clk_add_alias("main_clk", "nop_usb_xceiv.0", "auxclk3_ck", NULL);
+	if (ret)
+		pr_err("Failed to add main_clk alias to auxclk3_ck\n");
+
 	usbhs_init(&usbhs_bdata);
 
 	/* enable power to hub */
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 12/14] ARM: OMAP2+: omap4panda: Adapt HUB power to regulator framework
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (10 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 11/14] ARM: OMAP2+: omap4panda: Provide USB Host's PHY platform data Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 16:51 ` [PATCH 13/14] ARM: OMAP2+: omap4panda: Adapt HUB reset " Roger Quadros
  2013-01-10 16:51 ` [PATCH 14/14] ARM: OMAP2+: omap4panda: Remove irrelevant USB host platform data Roger Quadros
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

We model the HUB_POWER GPIO as a fixed regulator device. This regulator
is then used as "vcc" supply for the USB PHY device and is managed
by the PHY driver.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 arch/arm/mach-omap2/board-omap4panda.c |   38 +++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index 350c4db..a4831cc 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -132,12 +132,45 @@ static struct platform_device btwilink_device = {
 	.id	= -1,
 };
 
+/* Regulator for USB HUB supply */
+static struct regulator_consumer_supply hub_power_supplies[] = {
+/* Link PHY device to USB HUB supply so it gets enabled in the PHY driver */
+	REGULATOR_SUPPLY("vcc", "nop_usb_xceiv.0"),
+};
+
+static struct regulator_init_data hub_power_data = {
+	.constraints = {
+		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
+	},
+	.consumer_supplies	= hub_power_supplies,
+	.num_consumer_supplies	= ARRAY_SIZE(hub_power_supplies),
+};
+
+static struct fixed_voltage_config hub_power_config = {
+	.supply_name    = "vhub",
+	.microvolts = 3300000,
+	.gpio = GPIO_HUB_POWER,
+	.startup_delay = 70000, /* 70msec */
+	.enable_high = 1,
+	.enabled_at_boot = 0,
+	.init_data = &hub_power_data,
+};
+
+static struct platform_device hub_power_device = {
+	.name	= "reg-fixed-voltage",
+	.id	= 2,
+	.dev = {
+		.platform_data = &hub_power_config,
+	},
+};
+
 static struct platform_device *panda_devices[] __initdata = {
 	&leds_gpio,
 	&wl1271_device,
 	&panda_abe_audio,
 	&panda_hdmi_audio_codec,
 	&btwilink_device,
+	&hub_power_device,
 };
 
 static struct nop_usb_xceiv_platform_data phy_pdata0 = {
@@ -164,7 +197,6 @@ static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 };
 
 static struct gpio panda_ehci_gpios[] __initdata = {
-	{ GPIO_HUB_POWER,	GPIOF_OUT_INIT_LOW,  "hub_power"  },
 	{ GPIO_HUB_NRESET,	GPIOF_OUT_INIT_LOW,  "hub_nreset" },
 };
 
@@ -180,7 +212,6 @@ static void __init omap4_ehci_init(void)
 		return;
 	}
 
-	gpio_export(GPIO_HUB_POWER, 0);
 	gpio_export(GPIO_HUB_NRESET, 0);
 	gpio_set_value(GPIO_HUB_NRESET, 1);
 
@@ -190,9 +221,6 @@ static void __init omap4_ehci_init(void)
 		pr_err("Failed to add main_clk alias to auxclk3_ck\n");
 
 	usbhs_init(&usbhs_bdata);
-
-	/* enable power to hub */
-	gpio_set_value(GPIO_HUB_POWER, 1);
 }
 
 static struct omap_musb_board_data musb_board_data = {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 13/14] ARM: OMAP2+: omap4panda: Adapt HUB reset to regulator framework
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (11 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 12/14] ARM: OMAP2+: omap4panda: Adapt HUB power to regulator framework Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  2013-01-10 16:51 ` [PATCH 14/14] ARM: OMAP2+: omap4panda: Remove irrelevant USB host platform data Roger Quadros
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

We model the HUB_RESET GPIO as a fixed regulator device. This regulator
is then used as "reset" supply for the USB PHY device and is managed
by the PHY driver.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 arch/arm/mach-omap2/board-omap4panda.c |   48 ++++++++++++++++++++++----------
 1 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index a4831cc..fd2f907 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -132,6 +132,38 @@ static struct platform_device btwilink_device = {
 	.id	= -1,
 };
 
+/* Regulator for USB HUB/PHY reset */
+static struct regulator_consumer_supply hub_reset_supplies[] = {
+/* Link PHY device to reset supply so it gets used in the PHY driver */
+	REGULATOR_SUPPLY("reset", "nop_usb_xceiv.0"),
+};
+
+static struct regulator_init_data hub_reset_data = {
+	.constraints = {
+		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
+	},
+	.consumer_supplies	= hub_reset_supplies,
+	.num_consumer_supplies	= ARRAY_SIZE(hub_reset_supplies),
+};
+
+static struct fixed_voltage_config hub_reset_config = {
+	.supply_name    = "hub_reset",
+	.microvolts = 3300000,
+	.gpio = GPIO_HUB_NRESET,
+	.startup_delay = 70000, /* 70msec */
+	.enable_high = 1,
+	.enabled_at_boot = 0,	/* keep in RESET */
+	.init_data = &hub_reset_data,
+};
+
+static struct platform_device hub_reset_device = {
+	.name	= "reg-fixed-voltage",
+	.id	= 3,
+	.dev = {
+		.platform_data = &hub_reset_config,
+	},
+};
+
 /* Regulator for USB HUB supply */
 static struct regulator_consumer_supply hub_power_supplies[] = {
 /* Link PHY device to USB HUB supply so it gets enabled in the PHY driver */
@@ -171,6 +203,7 @@ static struct platform_device *panda_devices[] __initdata = {
 	&panda_hdmi_audio_codec,
 	&btwilink_device,
 	&hub_power_device,
+	&hub_reset_device,
 };
 
 static struct nop_usb_xceiv_platform_data phy_pdata0 = {
@@ -196,25 +229,10 @@ static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.phy_config[0] = &phy_config0,
 };
 
-static struct gpio panda_ehci_gpios[] __initdata = {
-	{ GPIO_HUB_NRESET,	GPIOF_OUT_INIT_LOW,  "hub_nreset" },
-};
-
 static void __init omap4_ehci_init(void)
 {
 	int ret;
 
-	/* disable the power to the usb hub prior to init and reset phy+hub */
-	ret = gpio_request_array(panda_ehci_gpios,
-				 ARRAY_SIZE(panda_ehci_gpios));
-	if (ret) {
-		pr_err("Unable to initialize EHCI power/reset\n");
-		return;
-	}
-
-	gpio_export(GPIO_HUB_NRESET, 0);
-	gpio_set_value(GPIO_HUB_NRESET, 1);
-
 	/* FREF_CLK3 provides the 19.2 MHz reference clock to the PHY */
 	ret = clk_add_alias("main_clk", "nop_usb_xceiv.0", "auxclk3_ck", NULL);
 	if (ret)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 14/14] ARM: OMAP2+: omap4panda: Remove irrelevant USB host platform data
  2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
                   ` (12 preceding siblings ...)
  2013-01-10 16:51 ` [PATCH 13/14] ARM: OMAP2+: omap4panda: Adapt HUB reset " Roger Quadros
@ 2013-01-10 16:51 ` Roger Quadros
  13 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-10 16:51 UTC (permalink / raw)
  To: linux-arm-kernel

These platform data bits are no longer used so remove them.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 arch/arm/mach-omap2/board-omap4panda.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index fd2f907..cde7316 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -220,12 +220,6 @@ static struct usbhs_phy_config phy_config0 = {
 
 static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
-	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
-	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-	.phy_reset  = false,
-	.reset_gpio_port[0]  = -EINVAL,
-	.reset_gpio_port[1]  = -EINVAL,
-	.reset_gpio_port[2]  = -EINVAL,
 	.phy_config[0] = &phy_config0,
 };
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY
  2013-01-10 16:51 ` [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY Roger Quadros
@ 2013-01-10 18:06   ` Sergei Shtylyov
  2013-01-11  9:41     ` Roger Quadros
  2013-01-11 17:17   ` Russell King - ARM Linux
  1 sibling, 1 reply; 37+ messages in thread
From: Sergei Shtylyov @ 2013-01-10 18:06 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

On 01/10/2013 07:51 PM, Roger Quadros wrote:

> We use "vcc" as the supply name for the PHY's power supply.
> The power supply will be enabled during .init() and disabled
> during .shutdown()

> Signed-off-by: Roger Quadros <rogerq@ti.com>
> ---
>  drivers/usb/otg/nop-usb-xceiv.c |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)

> diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
> index 163f972..1c6db10 100644
> --- a/drivers/usb/otg/nop-usb-xceiv.c
> +++ b/drivers/usb/otg/nop-usb-xceiv.c
[...]
> @@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
>  {
>  	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
>  
> +	if (nop->vcc) {
> +		if (regulator_enable(nop->vcc))
> +			dev_err(phy->dev, "Failed to enable power\n");
> +	}

   Could be collapsed into single *if*.

> +
>  	if (nop->clk)
>  		clk_enable(nop->clk);
>  
> @@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
>  
>  	if (nop->clk)
>  		clk_disable(nop->clk);
> +
> +	if (nop->vcc) {
> +		if (regulator_disable(nop->vcc))
> +			dev_err(phy->dev, "Failed to disable power\n");
> +	}

   Same here.

WBR, Sergei

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-10 16:51 ` [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required Roger Quadros
@ 2013-01-10 20:48   ` Alan Stern
  2013-01-11 10:59     ` Roger Quadros
  0 siblings, 1 reply; 37+ messages in thread
From: Alan Stern @ 2013-01-10 20:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 10 Jan 2013, Roger Quadros wrote:

> If the OMAP's Host controller is in PHY mode then we instantiate
> a platform device for the PHY (one for each port in PHY mode) and
> hold a reference to it so that we can use the usb_phy API, e.g.
> while suspend/resume.
> 
> The platform data for the PHY must be supplied in the newly added
> .phy_config parameter in struct usbhs_omap_platform_data.
> 
> The end goal is to move the PHY's reset and power handling code
> out of the ehci-omap driver and into the phy driver.

As mentioned in another thread, I would prefer to have these changes to 
ehci-omap.c made after the driver is converted to the new "ehci-hcd is 
a library" scheme.  The patch below does the conversion; it is meant to 
apply on top of the similar patch for ehci-mxc posted recently on the 
linux-usb mailing list.

After this conversion, the omap_ehci_hcd private data structure doesn't 
have to be allocated specifically.  It can be handled in the same way 
as the private data structure in the ehci-mxc patch.

I haven't even tried to compile this.  Please let me know how it works.

Alan Stern



Index: usb-3.7/drivers/usb/host/Kconfig
===================================================================
--- usb-3.7.orig/drivers/usb/host/Kconfig
+++ usb-3.7/drivers/usb/host/Kconfig
@@ -155,7 +155,7 @@ config USB_EHCI_MXC
 	  Variation of ARC USB block used in some Freescale chips.
 
 config USB_EHCI_HCD_OMAP
-	bool "EHCI support for OMAP3 and later chips"
+	tristate "EHCI support for OMAP3 and later chips"
 	depends on USB_EHCI_HCD && ARCH_OMAP
 	default y
 	---help---
Index: usb-3.7/drivers/usb/host/Makefile
===================================================================
--- usb-3.7.orig/drivers/usb/host/Makefile
+++ usb-3.7/drivers/usb/host/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_USB_EHCI_HCD)	+= ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI)	+= ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)	+= ehci-platform.o
 obj-$(CONFIG_USB_EHCI_MXC)	+= ehci-mxc.o
+obj-$(CONFIG_USB_EHCI_HCD_OMAP)	+= ehci-omap.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD)	+= oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)	+= isp116x-hcd.o
Index: usb-3.7/drivers/usb/host/ehci-hcd.c
===================================================================
--- usb-3.7.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.7/drivers/usb/host/ehci-hcd.c
@@ -1255,11 +1255,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		ehci_hcd_sh_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_HCD_OMAP
-#include "ehci-omap.c"
-#define        PLATFORM_DRIVER         ehci_hcd_omap_driver
-#endif
-
 #ifdef CONFIG_PPC_PS3
 #include "ehci-ps3.c"
 #define	PS3_SYSTEM_BUS_DRIVER	ps3_ehci_driver
@@ -1349,6 +1344,7 @@ MODULE_LICENSE ("GPL");
 	!IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
 	!defined(CONFIG_USB_CHIPIDEA_HOST) && \
 	!defined(CONFIG_USB_EHCI_MXC) && \
+	!defined(CONFIG_USB_EHCI_HCD_OMAP) && \
 	!defined(PLATFORM_DRIVER) && \
 	!defined(PS3_SYSTEM_BUS_DRIVER) && \
 	!defined(OF_PLATFORM_DRIVER) && \
Index: usb-3.7/drivers/usb/host/ehci-omap.c
===================================================================
--- usb-3.7.orig/drivers/usb/host/ehci-omap.c
+++ usb-3.7/drivers/usb/host/ehci-omap.c
@@ -36,6 +36,9 @@
  *	- convert to use hwmod and runtime PM
  */
 
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/usb/ulpi.h>
@@ -44,6 +47,10 @@
 #include <linux/pm_runtime.h>
 #include <linux/gpio.h>
 #include <linux/clk.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
+
+#include "ehci.h"
 
 /* EHCI Register Set */
 #define EHCI_INSNREG04					(0xA0)
@@ -56,11 +63,13 @@
 #define	EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT		8
 #define	EHCI_INSNREG05_ULPI_WRDATA_SHIFT		0
 
-/*-------------------------------------------------------------------------*/
+#define DRIVER_DESC = "OMAP-EHCI Host Controller driver";
 
-static const struct hc_driver ehci_omap_hc_driver;
+static const char hcd_name[] = "ehci-omap";
 
 
+/*-------------------------------------------------------------------------*/
+
 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
 	__raw_writel(val, base + reg);
@@ -165,6 +174,12 @@ static void disable_put_regulator(
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */
 
+static struct hc_driver __read_mostly ehci_omap_hc_driver;
+
+static const struct ehci_driver_overrides ehci_omap_overrides __initdata = {
+	.reset =	omap_ehci_init,
+};
+
 /**
  * ehci_hcd_omap_probe - initialize TI-based HCDs
  *
@@ -322,56 +337,33 @@ static struct platform_driver ehci_hcd_o
 	/*.suspend		= ehci_hcd_omap_suspend, */
 	/*.resume		= ehci_hcd_omap_resume, */
 	.driver = {
-		.name		= "ehci-omap",
+		.name		= hcd_name,
 	}
 };
 
 /*-------------------------------------------------------------------------*/
 
-static const struct hc_driver ehci_omap_hc_driver = {
-	.description		= hcd_name,
-	.product_desc		= "OMAP-EHCI Host Controller",
-	.hcd_priv_size		= sizeof(struct ehci_hcd),
-
-	/*
-	 * generic hardware linkage
-	 */
-	.irq			= ehci_irq,
-	.flags			= HCD_MEMORY | HCD_USB2,
-
-	/*
-	 * basic lifecycle operations
-	 */
-	.reset			= omap_ehci_init,
-	.start			= ehci_run,
-	.stop			= ehci_stop,
-	.shutdown		= ehci_shutdown,
-
-	/*
-	 * managing i/o requests and associated device resources
-	 */
-	.urb_enqueue		= ehci_urb_enqueue,
-	.urb_dequeue		= ehci_urb_dequeue,
-	.endpoint_disable	= ehci_endpoint_disable,
-	.endpoint_reset		= ehci_endpoint_reset,
+static int __init ehci_omap_init(void)
+{
+	if (usb_disabled())
+		return -ENODEV;
 
-	/*
-	 * scheduling support
-	 */
-	.get_frame_number	= ehci_get_frame,
+	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
 
-	/*
-	 * root hub support
-	 */
-	.hub_status_data	= ehci_hub_status_data,
-	.hub_control		= ehci_hub_control,
-	.bus_suspend		= ehci_bus_suspend,
-	.bus_resume		= ehci_bus_resume,
+	ehci_init_driver(&ehci_omap_hc_driver, &ehci_omap_overrides);
+	return platform_driver_register(&ehci_omap_driver);
+}
+module_init(ehci_omap_init);
 
-	.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
-};
+static void __exit ehci_omap_cleanup(void)
+{
+	platform_driver_unregister(&ehci_omap_driver);
+}
+module_exit(ehci_omap_cleanup);
 
 MODULE_ALIAS("platform:omap-ehci");
 MODULE_AUTHOR("Texas Instruments, Inc.");
 MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
 
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data
  2013-01-10 16:51 ` [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data Roger Quadros
@ 2013-01-10 23:45   ` Tony Lindgren
  2013-01-11  9:40     ` Roger Quadros
  0 siblings, 1 reply; 37+ messages in thread
From: Tony Lindgren @ 2013-01-10 23:45 UTC (permalink / raw)
  To: linux-arm-kernel

* Roger Quadros <rogerq@ti.com> [130110 08:54]:
> Let's have a single platform data structure for the OMAP's High-Speed
> USB host subsystem instead of having 3 separate ones i.e. one for
> board data, one for USB Host (UHH) module and one for USB-TLL module.
> 
> This makes the code much simpler and avoids creating multiple copies of
> platform data.

I can apply just this patch alone into an immutable branch that
we all can merge in as needed as long as we have acks for the USB
and MFD parts.

Or does this one need to be changed based on Alan's comments
on the EHCI lib related changes?

Regards,

Tony
 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> ---
>  arch/arm/mach-omap2/board-3430sdp.c        |    2 +-
>  arch/arm/mach-omap2/board-3630sdp.c        |    2 +-
>  arch/arm/mach-omap2/board-am3517crane.c    |    2 +-
>  arch/arm/mach-omap2/board-am3517evm.c      |    2 +-
>  arch/arm/mach-omap2/board-cm-t35.c         |    2 +-
>  arch/arm/mach-omap2/board-cm-t3517.c       |    2 +-
>  arch/arm/mach-omap2/board-devkit8000.c     |    2 +-
>  arch/arm/mach-omap2/board-igep0020.c       |    4 +-
>  arch/arm/mach-omap2/board-omap3beagle.c    |    2 +-
>  arch/arm/mach-omap2/board-omap3evm.c       |    2 +-
>  arch/arm/mach-omap2/board-omap3pandora.c   |    2 +-
>  arch/arm/mach-omap2/board-omap3stalker.c   |    2 +-
>  arch/arm/mach-omap2/board-omap3touchbook.c |    2 +-
>  arch/arm/mach-omap2/board-omap4panda.c     |    2 +-
>  arch/arm/mach-omap2/board-overo.c          |    2 +-
>  arch/arm/mach-omap2/board-zoom.c           |    2 +-
>  arch/arm/mach-omap2/usb-host.c             |   30 +++---------------
>  arch/arm/mach-omap2/usb.h                  |   21 +------------
>  drivers/mfd/omap-usb-host.c                |   46 ++++++++++++----------------
>  drivers/mfd/omap-usb-tll.c                 |    8 ++--
>  drivers/usb/host/ehci-omap.c               |    6 ++--
>  include/linux/platform_data/usb-omap.h     |   26 ++++------------
>  22 files changed, 56 insertions(+), 115 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
> index bb73afc..46147c8 100644
> --- a/arch/arm/mach-omap2/board-3430sdp.c
> +++ b/arch/arm/mach-omap2/board-3430sdp.c
> @@ -424,7 +424,7 @@ static void enable_board_wakeup_source(void)
>  		OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
>  }
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
> diff --git a/arch/arm/mach-omap2/board-3630sdp.c b/arch/arm/mach-omap2/board-3630sdp.c
> index 050aaa7..78b1724 100644
> --- a/arch/arm/mach-omap2/board-3630sdp.c
> +++ b/arch/arm/mach-omap2/board-3630sdp.c
> @@ -53,7 +53,7 @@ static void enable_board_wakeup_source(void)
>  		OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
>  }
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
> diff --git a/arch/arm/mach-omap2/board-am3517crane.c b/arch/arm/mach-omap2/board-am3517crane.c
> index 51b96a1..26f1916 100644
> --- a/arch/arm/mach-omap2/board-am3517crane.c
> +++ b/arch/arm/mach-omap2/board-am3517crane.c
> @@ -40,7 +40,7 @@ static struct omap_board_mux board_mux[] __initdata = {
>  };
>  #endif
>  
> -static struct usbhs_omap_board_data usbhs_bdata __initdata = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
> index f81a303..c76725d 100644
> --- a/arch/arm/mach-omap2/board-am3517evm.c
> +++ b/arch/arm/mach-omap2/board-am3517evm.c
> @@ -274,7 +274,7 @@ static __init void am3517_evm_mcbsp1_init(void)
>  	omap_ctrl_writel(devconf0, OMAP2_CONTROL_DEVCONF0);
>  }
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
>  		defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
> diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
> index b3102c2..cdf1d6e 100644
> --- a/arch/arm/mach-omap2/board-cm-t35.c
> +++ b/arch/arm/mach-omap2/board-cm-t35.c
> @@ -418,7 +418,7 @@ static struct omap2_hsmmc_info mmc[] = {
>  	{}	/* Terminator */
>  };
>  
> -static struct usbhs_omap_board_data usbhs_bdata __initdata = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/board-cm-t3517.c b/arch/arm/mach-omap2/board-cm-t3517.c
> index ebbc2ad..cfa9098 100644
> --- a/arch/arm/mach-omap2/board-cm-t3517.c
> +++ b/arch/arm/mach-omap2/board-cm-t3517.c
> @@ -166,7 +166,7 @@ static inline void cm_t3517_init_rtc(void) {}
>  #define HSUSB2_RESET_GPIO	(147)
>  #define USB_HUB_RESET_GPIO	(152)
>  
> -static struct usbhs_omap_board_data cm_t3517_ehci_pdata __initdata = {
> +static struct usbhs_omap_platform_data cm_t3517_ehci_pdata __initdata = {
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
> index 12865af..051ec0d 100644
> --- a/arch/arm/mach-omap2/board-devkit8000.c
> +++ b/arch/arm/mach-omap2/board-devkit8000.c
> @@ -435,7 +435,7 @@ static struct platform_device *devkit8000_devices[] __initdata = {
>  	&omap_dm9000_dev,
>  };
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
> index 0f24cb8..cfba790 100644
> --- a/arch/arm/mach-omap2/board-igep0020.c
> +++ b/arch/arm/mach-omap2/board-igep0020.c
> @@ -526,7 +526,7 @@ static void __init igep_i2c_init(void)
>  	omap3_pmic_init("twl4030", &igep_twldata);
>  }
>  
> -static const struct usbhs_omap_board_data igep2_usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data igep2_usbhs_bdata __initdata = {
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
> @@ -537,7 +537,7 @@ static const struct usbhs_omap_board_data igep2_usbhs_bdata __initconst = {
>  	.reset_gpio_port[2] = -EINVAL,
>  };
>  
> -static const struct usbhs_omap_board_data igep3_usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data igep3_usbhs_bdata __initdata = {
>  	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> index 22c483d..1cb114e 100644
> --- a/arch/arm/mach-omap2/board-omap3beagle.c
> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> @@ -430,7 +430,7 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
>  	&madc_hwmon,
>  };
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  
>  	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
> diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
> index 3985f35..7bdc8a4 100644
> --- a/arch/arm/mach-omap2/board-omap3evm.c
> +++ b/arch/arm/mach-omap2/board-omap3evm.c
> @@ -538,7 +538,7 @@ static int __init omap3_evm_i2c_init(void)
>  	return 0;
>  }
>  
> -static struct usbhs_omap_board_data usbhs_bdata __initdata = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  
>  	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
> diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
> index a53a668..145a6f8 100644
> --- a/arch/arm/mach-omap2/board-omap3pandora.c
> +++ b/arch/arm/mach-omap2/board-omap3pandora.c
> @@ -567,7 +567,7 @@ static struct platform_device *omap3pandora_devices[] __initdata = {
>  	&pandora_backlight,
>  };
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  
>  	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
> diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
> index 53a6cbc..278ae95 100644
> --- a/arch/arm/mach-omap2/board-omap3stalker.c
> +++ b/arch/arm/mach-omap2/board-omap3stalker.c
> @@ -361,7 +361,7 @@ static struct platform_device *omap3_stalker_devices[] __initdata = {
>  	&keys_gpio,
>  };
>  
> -static struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
> index 263cb9c..65a285f 100644
> --- a/arch/arm/mach-omap2/board-omap3touchbook.c
> +++ b/arch/arm/mach-omap2/board-omap3touchbook.c
> @@ -309,7 +309,7 @@ static struct platform_device *omap3_touchbook_devices[] __initdata = {
>  	&keys_gpio,
>  };
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
> diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
> index 5c8e9ce..ee76830 100644
> --- a/arch/arm/mach-omap2/board-omap4panda.c
> +++ b/arch/arm/mach-omap2/board-omap4panda.c
> @@ -139,7 +139,7 @@ static struct platform_device *panda_devices[] __initdata = {
>  	&btwilink_device,
>  };
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
> index c8fde3e..b1b0f09 100644
> --- a/arch/arm/mach-omap2/board-overo.c
> +++ b/arch/arm/mach-omap2/board-overo.c
> @@ -457,7 +457,7 @@ static int __init overo_spi_init(void)
>  	return 0;
>  }
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  	.port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/board-zoom.c b/arch/arm/mach-omap2/board-zoom.c
> index d7fa31e..2d7a457 100644
> --- a/arch/arm/mach-omap2/board-zoom.c
> +++ b/arch/arm/mach-omap2/board-zoom.c
> @@ -92,7 +92,7 @@ static struct mtd_partition zoom_nand_partitions[] = {
>  	},
>  };
>  
> -static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
> +static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
>  	.port_mode[0]		= OMAP_USBHS_PORT_MODE_UNUSED,
>  	.port_mode[1]		= OMAP_EHCI_PORT_MODE_PHY,
>  	.port_mode[2]		= OMAP_USBHS_PORT_MODE_UNUSED,
> diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
> index ee8c473..940aad4 100644
> --- a/arch/arm/mach-omap2/usb-host.c
> +++ b/arch/arm/mach-omap2/usb-host.c
> @@ -37,11 +37,6 @@
>  #define	USBHS_UHH_HWMODNAME	"usb_host_hs"
>  #define USBHS_TLL_HWMODNAME	"usb_tll_hs"
>  
> -static struct usbhs_omap_platform_data		usbhs_data;
> -static struct usbtll_omap_platform_data		usbtll_data;
> -static struct ehci_hcd_omap_platform_data	ehci_data;
> -static struct ohci_hcd_omap_platform_data	ohci_data;
> -
>  static struct omap_device_pm_latency omap_uhhtll_latency[] = {
>  	  {
>  		.deactivate_func = omap_device_idle_hwmods,
> @@ -485,33 +480,18 @@ void __init setup_4430ohci_io_mux(const enum usbhs_omap_port_mode *port_mode)
>  	}
>  }
>  
> -void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
> +void __init usbhs_init(struct usbhs_omap_platform_data *pdata)
>  {
>  	struct omap_hwmod	*uhh_hwm, *tll_hwm;
>  	struct platform_device	*pdev;
>  	int			bus_id = -1;
> -	int			i;
> -
> -	for (i = 0; i < OMAP3_HS_USB_PORTS; i++) {
> -		usbhs_data.port_mode[i] = pdata->port_mode[i];
> -		usbtll_data.port_mode[i] = pdata->port_mode[i];
> -		ohci_data.port_mode[i] = pdata->port_mode[i];
> -		ehci_data.port_mode[i] = pdata->port_mode[i];
> -		ehci_data.reset_gpio_port[i] = pdata->reset_gpio_port[i];
> -		ehci_data.regulator[i] = pdata->regulator[i];
> -	}
> -	ehci_data.phy_reset = pdata->phy_reset;
> -	ohci_data.es2_compatibility = pdata->es2_compatibility;
> -	usbhs_data.ehci_data = &ehci_data;
> -	usbhs_data.ohci_data = &ohci_data;
> -	usbhs_data.nports = pdata->nports;
>  
>  	if (cpu_is_omap34xx()) {
>  		setup_ehci_io_mux(pdata->port_mode);
>  		setup_ohci_io_mux(pdata->port_mode);
>  
>  		if (omap_rev() <= OMAP3430_REV_ES2_1)
> -			usbhs_data.single_ulpi_bypass = true;
> +			pdata->single_ulpi_bypass = true;
>  
>  	} else if (cpu_is_omap44xx()) {
>  		setup_4430ehci_io_mux(pdata->port_mode);
> @@ -531,7 +511,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
>  	}
>  
>  	pdev = omap_device_build(OMAP_USBTLL_DEVICE, bus_id, tll_hwm,
> -				&usbtll_data, sizeof(usbtll_data),
> +				pdata, sizeof(*pdata),
>  				omap_uhhtll_latency,
>  				ARRAY_SIZE(omap_uhhtll_latency), false);
>  	if (IS_ERR(pdev)) {
> @@ -541,7 +521,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
>  	}
>  
>  	pdev = omap_device_build(OMAP_USBHS_DEVICE, bus_id, uhh_hwm,
> -				&usbhs_data, sizeof(usbhs_data),
> +				pdata, sizeof(*pdata),
>  				omap_uhhtll_latency,
>  				ARRAY_SIZE(omap_uhhtll_latency), false);
>  	if (IS_ERR(pdev)) {
> @@ -553,7 +533,7 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
>  
>  #else
>  
> -void __init usbhs_init(const struct usbhs_omap_board_data *pdata)
> +void __init usbhs_init(struct usbhs_omap_platform_data *pdata)
>  {
>  }
>  
> diff --git a/arch/arm/mach-omap2/usb.h b/arch/arm/mach-omap2/usb.h
> index 7dc0f04..3319f5c 100644
> --- a/arch/arm/mach-omap2/usb.h
> +++ b/arch/arm/mach-omap2/usb.h
> @@ -53,27 +53,8 @@
>  #define USBPHY_OTGSESSEND_EN	(1 << 20)
>  #define USBPHY_DATA_POLARITY	(1 << 23)
>  
> -struct usbhs_omap_board_data {
> -	int				nports;
> -	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
> -
> -	/* have to be valid if phy_reset is true and portx is in phy mode */
> -	int	reset_gpio_port[OMAP3_HS_USB_PORTS];
> -
> -	/* Set this to true for ES2.x silicon */
> -	unsigned			es2_compatibility:1;
> -
> -	unsigned			phy_reset:1;
> -
> -	/*
> -	 * Regulators for USB PHYs.
> -	 * Each PHY can have a separate regulator.
> -	 */
> -	struct regulator		*regulator[OMAP3_HS_USB_PORTS];
> -};
> -
>  extern void usb_musb_init(struct omap_musb_board_data *board_data);
> -extern void usbhs_init(const struct usbhs_omap_board_data *pdata);
> +extern void usbhs_init(struct usbhs_omap_platform_data *pdata);
>  
>  extern void am35x_musb_reset(void);
>  extern void am35x_musb_phy_power(u8 on);
> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index 9612535..7180b00 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -185,19 +185,13 @@ err_end:
>  static int omap_usbhs_alloc_children(struct platform_device *pdev)
>  {
>  	struct device				*dev = &pdev->dev;
> -	struct usbhs_hcd_omap			*omap;
> -	struct ehci_hcd_omap_platform_data	*ehci_data;
> -	struct ohci_hcd_omap_platform_data	*ohci_data;
> +	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
>  	struct platform_device			*ehci;
>  	struct platform_device			*ohci;
>  	struct resource				*res;
>  	struct resource				resources[2];
>  	int					ret;
>  
> -	omap = platform_get_drvdata(pdev);
> -	ehci_data = omap->pdata->ehci_data;
> -	ohci_data = omap->pdata->ohci_data;
> -
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ehci");
>  	if (!res) {
>  		dev_err(dev, "EHCI get resource IORESOURCE_MEM failed\n");
> @@ -214,8 +208,8 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev)
>  	}
>  	resources[1] = *res;
>  
> -	ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, ehci_data,
> -		sizeof(*ehci_data), dev);
> +	ehci = omap_usbhs_alloc_child(OMAP_EHCI_DEVICE, resources, 2, pdata,
> +		sizeof(*pdata), dev);
>  
>  	if (!ehci) {
>  		dev_err(dev, "omap_usbhs_alloc_child failed\n");
> @@ -239,8 +233,8 @@ static int omap_usbhs_alloc_children(struct platform_device *pdev)
>  	}
>  	resources[1] = *res;
>  
> -	ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, ohci_data,
> -		sizeof(*ohci_data), dev);
> +	ohci = omap_usbhs_alloc_child(OMAP_OHCI_DEVICE, resources, 2, pdata,
> +		sizeof(*pdata), dev);
>  	if (!ohci) {
>  		dev_err(dev, "omap_usbhs_alloc_child failed\n");
>  		ret = -ENOMEM;
> @@ -441,13 +435,13 @@ static void omap_usbhs_init(struct device *dev)
>  
>  	dev_dbg(dev, "starting TI HSUSB Controller\n");
>  
> -	if (pdata->ehci_data->phy_reset) {
> -		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
> -			gpio_request_one(pdata->ehci_data->reset_gpio_port[0],
> +	if (pdata->phy_reset) {
> +		if (gpio_is_valid(pdata->reset_gpio_port[0]))
> +			gpio_request_one(pdata->reset_gpio_port[0],
>  					 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
>  
> -		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
> -			gpio_request_one(pdata->ehci_data->reset_gpio_port[1],
> +		if (gpio_is_valid(pdata->reset_gpio_port[1]))
> +			gpio_request_one(pdata->reset_gpio_port[1],
>  					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
>  
>  		/* Hold the PHY in RESET for enough time till DIR is high */
> @@ -473,19 +467,19 @@ static void omap_usbhs_init(struct device *dev)
>  	dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg);
>  
>  	pm_runtime_put_sync(dev);
> -	if (pdata->ehci_data->phy_reset) {
> +	if (pdata->phy_reset) {
>  		/* Hold the PHY in RESET for enough time till
>  		 * PHY is settled and ready
>  		 */
>  		udelay(10);
>  
> -		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
> +		if (gpio_is_valid(pdata->reset_gpio_port[0]))
>  			gpio_set_value_cansleep
> -				(pdata->ehci_data->reset_gpio_port[0], 1);
> +				(pdata->reset_gpio_port[0], 1);
>  
> -		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
> +		if (gpio_is_valid(pdata->reset_gpio_port[1]))
>  			gpio_set_value_cansleep
> -				(pdata->ehci_data->reset_gpio_port[1], 1);
> +				(pdata->reset_gpio_port[1], 1);
>  	}
>  }
>  
> @@ -494,12 +488,12 @@ static void omap_usbhs_deinit(struct device *dev)
>  	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
>  	struct usbhs_omap_platform_data	*pdata = omap->pdata;
>  
> -	if (pdata->ehci_data->phy_reset) {
> -		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
> -			gpio_free(pdata->ehci_data->reset_gpio_port[0]);
> +	if (pdata->phy_reset) {
> +		if (gpio_is_valid(pdata->reset_gpio_port[0]))
> +			gpio_free(pdata->reset_gpio_port[0]);
>  
> -		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
> -			gpio_free(pdata->ehci_data->reset_gpio_port[1]);
> +		if (gpio_is_valid(pdata->reset_gpio_port[1]))
> +			gpio_free(pdata->reset_gpio_port[1]);
>  	}
>  }
>  
> diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c
> index e63dc0b..a729cf3 100644
> --- a/drivers/mfd/omap-usb-tll.c
> +++ b/drivers/mfd/omap-usb-tll.c
> @@ -105,7 +105,7 @@
>  
>  struct usbtll_omap {
>  	int					nch;	/* num. of channels */
> -	struct usbtll_omap_platform_data	*pdata;
> +	struct usbhs_omap_platform_data		*pdata;
>  	struct clk				**ch_clk;
>  };
>  
> @@ -210,7 +210,7 @@ static unsigned ohci_omap3_fslsmode(enum usbhs_omap_port_mode mode)
>  static int usbtll_omap_probe(struct platform_device *pdev)
>  {
>  	struct device				*dev =  &pdev->dev;
> -	struct usbtll_omap_platform_data	*pdata = dev->platform_data;
> +	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
>  	void __iomem				*base;
>  	struct resource				*res;
>  	struct usbtll_omap			*tll;
> @@ -376,7 +376,7 @@ static int usbtll_omap_remove(struct platform_device *pdev)
>  static int usbtll_runtime_resume(struct device *dev)
>  {
>  	struct usbtll_omap			*tll = dev_get_drvdata(dev);
> -	struct usbtll_omap_platform_data	*pdata = tll->pdata;
> +	struct usbhs_omap_platform_data		*pdata = tll->pdata;
>  	int i;
>  
>  	dev_dbg(dev, "usbtll_runtime_resume\n");
> @@ -402,7 +402,7 @@ static int usbtll_runtime_resume(struct device *dev)
>  static int usbtll_runtime_suspend(struct device *dev)
>  {
>  	struct usbtll_omap			*tll = dev_get_drvdata(dev);
> -	struct usbtll_omap_platform_data	*pdata = tll->pdata;
> +	struct usbhs_omap_platform_data		*pdata = tll->pdata;
>  	int i;
>  
>  	dev_dbg(dev, "usbtll_runtime_suspend\n");
> diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
> index e9d9b09..b96a4bf 100644
> --- a/drivers/usb/host/ehci-omap.c
> +++ b/drivers/usb/host/ehci-omap.c
> @@ -107,7 +107,7 @@ static int omap_ehci_init(struct usb_hcd *hcd)
>  {
>  	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);
>  	int			rc;
> -	struct ehci_hcd_omap_platform_data	*pdata;
> +	struct usbhs_omap_platform_data	*pdata;
>  
>  	pdata = hcd->self.controller->platform_data;
>  
> @@ -151,7 +151,7 @@ static int omap_ehci_init(struct usb_hcd *hcd)
>  }
>  
>  static void disable_put_regulator(
> -		struct ehci_hcd_omap_platform_data *pdata)
> +		struct usbhs_omap_platform_data *pdata)
>  {
>  	int i;
>  
> @@ -176,7 +176,7 @@ static void disable_put_regulator(
>  static int ehci_hcd_omap_probe(struct platform_device *pdev)
>  {
>  	struct device				*dev = &pdev->dev;
> -	struct ehci_hcd_omap_platform_data	*pdata = dev->platform_data;
> +	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
>  	struct resource				*res;
>  	struct usb_hcd				*hcd;
>  	void __iomem				*regs;
> diff --git a/include/linux/platform_data/usb-omap.h b/include/linux/platform_data/usb-omap.h
> index 57707c7..d63eb7d 100644
> --- a/include/linux/platform_data/usb-omap.h
> +++ b/include/linux/platform_data/usb-omap.h
> @@ -38,31 +38,17 @@ enum usbhs_omap_port_mode {
>  	OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM
>  };
>  
> -struct usbtll_omap_platform_data {
> -	enum usbhs_omap_port_mode		port_mode[OMAP3_HS_USB_PORTS];
> -};
> -
> -struct ehci_hcd_omap_platform_data {
> +struct usbhs_omap_platform_data {
> +	int				nports;
>  	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
>  	int				reset_gpio_port[OMAP3_HS_USB_PORTS];
> -	struct regulator		*regulator[OMAP3_HS_USB_PORTS];
> -	unsigned			phy_reset:1;
> -};
>  
> -struct ohci_hcd_omap_platform_data {
> -	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
> -	unsigned			es2_compatibility:1;
> -};
> -
> -struct usbhs_omap_platform_data {
> -	int					nports;
> -	enum usbhs_omap_port_mode		port_mode[OMAP3_HS_USB_PORTS];
> -
> -	struct ehci_hcd_omap_platform_data	*ehci_data;
> -	struct ohci_hcd_omap_platform_data	*ohci_data;
> +	struct regulator		*regulator[OMAP3_HS_USB_PORTS];
>  
>  	/* OMAP3 <= ES2.1 have a single ulpi bypass control bit */
> -	unsigned				single_ulpi_bypass:1;
> +	unsigned			single_ulpi_bypass:1;
> +	unsigned			es2_compatibility:1;
> +	unsigned			phy_reset:1;
>  };
>  
>  /*-------------------------------------------------------------------------*/
> -- 
> 1.7.4.1
> 

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data
  2013-01-10 23:45   ` Tony Lindgren
@ 2013-01-11  9:40     ` Roger Quadros
  2013-01-11 18:13       ` Tony Lindgren
  0 siblings, 1 reply; 37+ messages in thread
From: Roger Quadros @ 2013-01-11  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

Tony,

On 01/11/2013 01:45 AM, Tony Lindgren wrote:
> * Roger Quadros <rogerq@ti.com> [130110 08:54]:
>> Let's have a single platform data structure for the OMAP's High-Speed
>> USB host subsystem instead of having 3 separate ones i.e. one for
>> board data, one for USB Host (UHH) module and one for USB-TLL module.
>>
>> This makes the code much simpler and avoids creating multiple copies of
>> platform data.
> 
> I can apply just this patch alone into an immutable branch that
> we all can merge in as needed as long as we have acks for the USB
> and MFD parts.
> 
> Or does this one need to be changed based on Alan's comments
> on the EHCI lib related changes?
> 

This does not depend on EHCI lib based changes but it depends on the
OMAP USB Host cleanup series posted earlier.

regards,
-roger

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY
  2013-01-10 18:06   ` Sergei Shtylyov
@ 2013-01-11  9:41     ` Roger Quadros
  0 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-11  9:41 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/10/2013 08:06 PM, Sergei Shtylyov wrote:
> Hello.
> 
> On 01/10/2013 07:51 PM, Roger Quadros wrote:
> 
>> We use "vcc" as the supply name for the PHY's power supply.
>> The power supply will be enabled during .init() and disabled
>> during .shutdown()
> 
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> ---
>>  drivers/usb/otg/nop-usb-xceiv.c |   18 ++++++++++++++++++
>>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
>> diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
>> index 163f972..1c6db10 100644
>> --- a/drivers/usb/otg/nop-usb-xceiv.c
>> +++ b/drivers/usb/otg/nop-usb-xceiv.c
> [...]
>> @@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
>>  {
>>  	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
>>  
>> +	if (nop->vcc) {
>> +		if (regulator_enable(nop->vcc))
>> +			dev_err(phy->dev, "Failed to enable power\n");
>> +	}
> 
>    Could be collapsed into single *if*.

Right.

> 
>> +
>>  	if (nop->clk)
>>  		clk_enable(nop->clk);
>>  
>> @@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
>>  
>>  	if (nop->clk)
>>  		clk_disable(nop->clk);
>> +
>> +	if (nop->vcc) {
>> +		if (regulator_disable(nop->vcc))
>> +			dev_err(phy->dev, "Failed to disable power\n");
>> +	}
> 
>    Same here.

OK. I'll fix them in next spin.

--cheers,
-roger

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-10 20:48   ` Alan Stern
@ 2013-01-11 10:59     ` Roger Quadros
  2013-01-11 11:06       ` Roger Quadros
  2013-01-11 15:28       ` Alan Stern
  0 siblings, 2 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-11 10:59 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/10/2013 10:48 PM, Alan Stern wrote:
> On Thu, 10 Jan 2013, Roger Quadros wrote:
> 
>> If the OMAP's Host controller is in PHY mode then we instantiate
>> a platform device for the PHY (one for each port in PHY mode) and
>> hold a reference to it so that we can use the usb_phy API, e.g.
>> while suspend/resume.
>>
>> The platform data for the PHY must be supplied in the newly added
>> .phy_config parameter in struct usbhs_omap_platform_data.
>>
>> The end goal is to move the PHY's reset and power handling code
>> out of the ehci-omap driver and into the phy driver.
> 
> As mentioned in another thread, I would prefer to have these changes to 
> ehci-omap.c made after the driver is converted to the new "ehci-hcd is 
> a library" scheme.  The patch below does the conversion; it is meant to 
> apply on top of the similar patch for ehci-mxc posted recently on the 
> linux-usb mailing list.
> 
> After this conversion, the omap_ehci_hcd private data structure doesn't 
> have to be allocated specifically.  It can be handled in the same way 
> as the private data structure in the ehci-mxc patch.
> 
> I haven't even tried to compile this.  Please let me know how it works.
> 

Alan,

Thanks for the patch. I've pasted the version that builds and works and
put you as the Author of the patch, hope it is fine.

I could not find the equivalent ehci-mxc implementation though. Any
pointers to that? Thanks.

cheers,
-roger

>From fafa9c787bcf2ff3f46c07c045997614d7a8a417 Mon Sep 17 00:00:00 2001
From: Alan Stern <stern@rowland.harvard.edu>
Date: Fri, 11 Jan 2013 12:37:01 +0200
Subject: [PATCH] USB: ehci-omap: Convert to platform driver

Convert ehci-omap into a platform driver and use ehci-hcd
as a library.

CC: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/host/Kconfig     |    2 +-
 drivers/usb/host/Makefile    |    1 +
 drivers/usb/host/ehci-hcd.c  |    6 +---
 drivers/usb/host/ehci-omap.c |   76
+++++++++++++++++++-----------------------
 4 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index d6bb128..432a463 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -155,7 +155,7 @@ config USB_EHCI_MXC
 	  Variation of ARC USB block used in some Freescale chips.

 config USB_EHCI_HCD_OMAP
-	bool "EHCI support for OMAP3 and later chips"
+	tristate "EHCI support for OMAP3 and later chips"
 	depends on USB_EHCI_HCD && ARCH_OMAP
 	default y
 	---help---
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 1eb4c30..8a8d079 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_PCI)		+= pci-quirks.o
 obj-$(CONFIG_USB_EHCI_HCD)	+= ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI)	+= ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)	+= ehci-platform.o
+obj-$(CONFIG_USB_EHCI_HCD_OMAP)	+= ehci-omap.o

 obj-$(CONFIG_USB_OXU210HP_HCD)	+= oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)	+= isp116x-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c97503b..c44ef1d 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1260,11 +1260,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		ehci_hcd_sh_driver
 #endif

-#ifdef CONFIG_USB_EHCI_HCD_OMAP
-#include "ehci-omap.c"
-#define        PLATFORM_DRIVER         ehci_hcd_omap_driver
-#endif
-
 #ifdef CONFIG_PPC_PS3
 #include "ehci-ps3.c"
 #define	PS3_SYSTEM_BUS_DRIVER	ps3_ehci_driver
@@ -1352,6 +1347,7 @@ MODULE_LICENSE ("GPL");

 #if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \
 	!IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
+	!IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \
 	!defined(CONFIG_USB_CHIPIDEA_HOST) && \
 	!defined(PLATFORM_DRIVER) && \
 	!defined(PS3_SYSTEM_BUS_DRIVER) && \
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index b96a4bf..6388aa6 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -36,6 +36,9 @@
  *	- convert to use hwmod and runtime PM
  */

+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/usb/ulpi.h>
@@ -43,6 +46,10 @@
 #include <linux/pm_runtime.h>
 #include <linux/gpio.h>
 #include <linux/clk.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
+
+#include "ehci.h"

 #include <linux/platform_data/usb-omap.h>

@@ -57,9 +64,11 @@
 #define	EHCI_INSNREG05_ULPI_EXTREGADD_SHIFT		8
 #define	EHCI_INSNREG05_ULPI_WRDATA_SHIFT		0

-/*-------------------------------------------------------------------------*/
+#define DRIVER_DESC "OMAP-EHCI Host Controller driver"

-static const struct hc_driver ehci_omap_hc_driver;
+static const char hcd_name[] = "ehci-omap";
+
+/*-------------------------------------------------------------------------*/


 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
@@ -166,6 +175,12 @@ static void disable_put_regulator(
 /* configure so an HC device and id are always provided */
 /* always called with process context; sleeping is OK */

+static struct hc_driver __read_mostly ehci_omap_hc_driver;
+
+static const struct ehci_driver_overrides ehci_omap_overrides
__initdata = {
+	.reset =	omap_ehci_init,
+};
+
 /**
  * ehci_hcd_omap_probe - initialize TI-based HCDs
  *
@@ -315,56 +330,33 @@ static struct platform_driver ehci_hcd_omap_driver = {
 	/*.suspend		= ehci_hcd_omap_suspend, */
 	/*.resume		= ehci_hcd_omap_resume, */
 	.driver = {
-		.name		= "ehci-omap",
+		.name		= hcd_name,
 	}
 };

 /*-------------------------------------------------------------------------*/

-static const struct hc_driver ehci_omap_hc_driver = {
-	.description		= hcd_name,
-	.product_desc		= "OMAP-EHCI Host Controller",
-	.hcd_priv_size		= sizeof(struct ehci_hcd),
-
-	/*
-	 * generic hardware linkage
-	 */
-	.irq			= ehci_irq,
-	.flags			= HCD_MEMORY | HCD_USB2,
-
-	/*
-	 * basic lifecycle operations
-	 */
-	.reset			= omap_ehci_init,
-	.start			= ehci_run,
-	.stop			= ehci_stop,
-	.shutdown		= ehci_shutdown,
-
-	/*
-	 * managing i/o requests and associated device resources
-	 */
-	.urb_enqueue		= ehci_urb_enqueue,
-	.urb_dequeue		= ehci_urb_dequeue,
-	.endpoint_disable	= ehci_endpoint_disable,
-	.endpoint_reset		= ehci_endpoint_reset,
+static int __init ehci_omap_init(void)
+{
+	if (usb_disabled())
+		return -ENODEV;

-	/*
-	 * scheduling support
-	 */
-	.get_frame_number	= ehci_get_frame,
+	pr_info("%s: " DRIVER_DESC "\n", hcd_name);

-	/*
-	 * root hub support
-	 */
-	.hub_status_data	= ehci_hub_status_data,
-	.hub_control		= ehci_hub_control,
-	.bus_suspend		= ehci_bus_suspend,
-	.bus_resume		= ehci_bus_resume,
+	ehci_init_driver(&ehci_omap_hc_driver, &ehci_omap_overrides);
+	return platform_driver_register(&ehci_hcd_omap_driver);
+}
+module_init(ehci_omap_init);

-	.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
-};
+static void __exit ehci_omap_cleanup(void)
+{
+	platform_driver_unregister(&ehci_hcd_omap_driver);
+}
+module_exit(ehci_omap_cleanup);

 MODULE_ALIAS("platform:omap-ehci");
 MODULE_AUTHOR("Texas Instruments, Inc.");
 MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");

+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-11 10:59     ` Roger Quadros
@ 2013-01-11 11:06       ` Roger Quadros
  2013-01-11 15:28       ` Alan Stern
  1 sibling, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-11 11:06 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/11/2013 12:59 PM, Roger Quadros wrote:
> On 01/10/2013 10:48 PM, Alan Stern wrote:
>> On Thu, 10 Jan 2013, Roger Quadros wrote:
>>
>>> If the OMAP's Host controller is in PHY mode then we instantiate
>>> a platform device for the PHY (one for each port in PHY mode) and
>>> hold a reference to it so that we can use the usb_phy API, e.g.
>>> while suspend/resume.
>>>
>>> The platform data for the PHY must be supplied in the newly added
>>> .phy_config parameter in struct usbhs_omap_platform_data.
>>>
>>> The end goal is to move the PHY's reset and power handling code
>>> out of the ehci-omap driver and into the phy driver.
>>
>> As mentioned in another thread, I would prefer to have these changes to 
>> ehci-omap.c made after the driver is converted to the new "ehci-hcd is 
>> a library" scheme.  The patch below does the conversion; it is meant to 
>> apply on top of the similar patch for ehci-mxc posted recently on the 
>> linux-usb mailing list.
>>
>> After this conversion, the omap_ehci_hcd private data structure doesn't 
>> have to be allocated specifically.  It can be handled in the same way 
>> as the private data structure in the ehci-mxc patch.
>>
>> I haven't even tried to compile this.  Please let me know how it works.
>>
> 
> Alan,
> 
> Thanks for the patch. I've pasted the version that builds and works and
> put you as the Author of the patch, hope it is fine.
> 
> I could not find the equivalent ehci-mxc implementation though. Any
> pointers to that? Thanks.

OK I found it. Previously I was searching in the archives :P.

cheers,
-roger

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-11 10:59     ` Roger Quadros
  2013-01-11 11:06       ` Roger Quadros
@ 2013-01-11 15:28       ` Alan Stern
  2013-01-11 16:03         ` Roger Quadros
  1 sibling, 1 reply; 37+ messages in thread
From: Alan Stern @ 2013-01-11 15:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 11 Jan 2013, Roger Quadros wrote:

> Alan,
> 
> Thanks for the patch. I've pasted the version that builds and works and
> put you as the Author of the patch, hope it is fine.

As far as I can see, yours is the same as what I posted except that:

	You altered the changes to ehci-hcd.c and Makefile to remove 
	the dependency on the ehci-mxc patch;

	You made an unimportant whitespace change in ehci-omap.c
	(moved a blank line before ehci_write()).

Right?  It's hard to compare the patches directly because the one you 
posted was whitespace-damaged.

Anyway, if this is okay and there's nothing wrong with the ehci-mxc 
change (other than the comment for ehci->priv), I'll submit both of 
them to Greg soon.

Alan Stern

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-11 15:28       ` Alan Stern
@ 2013-01-11 16:03         ` Roger Quadros
  2013-01-11 16:32           ` Russell King - ARM Linux
  2013-01-11 18:27           ` Alan Stern
  0 siblings, 2 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-11 16:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/11/2013 05:28 PM, Alan Stern wrote:
> On Fri, 11 Jan 2013, Roger Quadros wrote:
> 
>> Alan,
>>
>> Thanks for the patch. I've pasted the version that builds and works and
>> put you as the Author of the patch, hope it is fine.
> 
> As far as I can see, yours is the same as what I posted except that:
> 
> 	You altered the changes to ehci-hcd.c and Makefile to remove 
> 	the dependency on the ehci-mxc patch;
> 
> 	You made an unimportant whitespace change in ehci-omap.c
> 	(moved a blank line before ehci_write()).
> 
> Right?  It's hard to compare the patches directly because the one you 
> posted was whitespace-damaged.

My bad pasting it. Patch is attached now.

Apart from what you mentioned I did some more trivial changes. e.g.

+       !IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \
instead of
+	!defined(CONFIG_USB_EHCI_HCD_OMAP) && \

use ehci_hcd_omap_driver instead of ehci_omap_driver


> 
> Anyway, if this is okay and there's nothing wrong with the ehci-mxc 
> change (other than the comment for ehci->priv), I'll submit both of 
> them to Greg soon.
> 

OK, thanks.

I tried using ehci->priv in ehci-omap driver but noticed that the
private data gets corrupted after the EHCI controller is running and has
enumerated a few devices.

If I disable USB_DEBUG then things are fine. Could it be possible
that someone is overflowing data when USB_DEBUG is enabled?

My implementation is pasted below. (May contain whitespace errors due to
MS exchange). Patch 2 attached in case.

What was happening there is that omap_priv->phy was not the same during
remove() as it was set to during probe().

Would be nice if you could check if the same happens with ehci-mxc.

cheers,
-roger

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 6388aa6..23c9b9c 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -70,6 +70,11 @@ static const char hcd_name[] = "ehci-omap";

 /*-------------------------------------------------------------------------*/

+struct omap_ehci_hcd {
+	struct usb_hcd *hcd;
+	struct usb_phy **phy;	/* one PHY for each port */
+	int nports;
+};

 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
@@ -194,6 +199,8 @@ static int ehci_hcd_omap_probe(struct
platform_device *pdev)
 	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
 	struct resource				*res;
 	struct usb_hcd				*hcd;
+	struct omap_ehci_hcd			*omap_hcd;
+	struct usb_phy				*phy;
 	void __iomem				*regs;
 	int					ret = -ENODEV;
 	int					irq;
@@ -208,6 +215,25 @@ static int ehci_hcd_omap_probe(struct
platform_device *pdev)
 		return -ENODEV;
 	}

+	if (!pdata) {
+		dev_err(dev, "Missing platform data\n");
+		return -ENODEV;
+	}
+
+	omap_hcd = devm_kzalloc(&pdev->dev, sizeof(*omap_hcd), GFP_KERNEL);
+	if (!omap_hcd) {
+		dev_err(dev, "Memory allocation failed\n");
+		return -ENOMEM;
+	}
+
+	omap_hcd->nports = pdata->nports;
+	i = sizeof(struct usb_phy *) * omap_hcd->nports;
+	omap_hcd->phy = devm_kzalloc(&pdev->dev, i, GFP_KERNEL);
+	if (!omap_hcd->phy) {
+		dev_err(dev, "Memory allocation failed\n");
+		return -ENOMEM;
+	}
+
 	irq = platform_get_irq_byname(pdev, "ehci-irq");
 	if (irq < 0) {
 		dev_err(dev, "EHCI irq failed\n");
@@ -238,9 +264,15 @@ static int ehci_hcd_omap_probe(struct
platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 	hcd->regs = regs;
+	omap_hcd->hcd = hcd;
+
+	platform_set_drvdata(pdev, omap_hcd);

 	/* get ehci regulator and enable */
-	for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
+	for (i = 0 ; i < omap_hcd->nports ; i++) {
+		struct platform_device *phy_pdev;
+		struct usbhs_phy_config *phy_config;
+
 		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
 			pdata->regulator[i] = NULL;
 			continue;
@@ -254,6 +286,33 @@ static int ehci_hcd_omap_probe(struct
platform_device *pdev)
 		} else {
 			regulator_enable(pdata->regulator[i]);
 		}
+
+		/* instantiate PHY */
+		if (!pdata->phy_config[i]) {
+			dev_dbg(dev, "missing phy_config for port %d\n", i);
+			continue;
+		}
+
+		phy_config = pdata->phy_config[i];
+		phy_pdev = platform_device_register_data(&pdev->dev,
+				phy_config->name, i, phy_config->pdata,
+				phy_config->pdata_size);
+		if (IS_ERR(phy_pdev)) {
+			dev_dbg(dev, "error creating PHY device for port %d\n",
+					i);
+		}
+
+		phy = usb_get_phy_from_dev(&phy_pdev->dev);
+		if (IS_ERR(phy)) {
+			dev_dbg(dev, "could not get USB PHY for port %d\n", i);
+			platform_device_unregister(phy_pdev);
+			continue;
+		}
+
+		usb_phy_init(phy);
+		omap_hcd->phy[i] = phy;
+		/* bring PHY out of suspend */
+		usb_phy_set_suspend(omap_hcd->phy[i], 0);
 	}

 	pm_runtime_enable(dev);
@@ -284,6 +343,12 @@ err_pm_runtime:
 	disable_put_regulator(pdata);
 	pm_runtime_put_sync(dev);
 	usb_put_hcd(hcd);
+	for (i = 0 ; i < omap_hcd->nports ; i++) {
+		phy = omap_hcd->phy[i];
+		if (!phy)
+			continue;
+		platform_device_unregister(to_platform_device(phy->dev));
+	}

 err_io:
 	iounmap(regs);
@@ -301,14 +366,26 @@ err_io:
  */
 static int ehci_hcd_omap_remove(struct platform_device *pdev)
 {
-	struct device *dev				= &pdev->dev;
-	struct usb_hcd *hcd				= dev_get_drvdata(dev);
+	struct device *dev		= &pdev->dev;
+	struct omap_ehci_hcd *omap_hcd	= dev_get_drvdata(dev);
+	struct usb_hcd *hcd		= omap_hcd->hcd;
+	int i;

 	usb_remove_hcd(hcd);
 	disable_put_regulator(dev->platform_data);
 	iounmap(hcd->regs);
 	usb_put_hcd(hcd);

+	for (i = 0; i < omap_hcd->nports; i++) {
+		struct usb_phy *phy = omap_hcd->phy[i];
+
+		if (!phy)
+			continue;
+
+		usb_phy_shutdown(phy);
+		platform_device_unregister(to_platform_device(phy->dev));
+	}
+
 	pm_runtime_put_sync(dev);
 	pm_runtime_disable(dev);

diff --git a/include/linux/platform_data/usb-omap.h
b/include/linux/platform_data/usb-omap.h
index d63eb7d..927b8a1 100644
--- a/include/linux/platform_data/usb-omap.h
+++ b/include/linux/platform_data/usb-omap.h
@@ -38,6 +38,12 @@ enum usbhs_omap_port_mode {
 	OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM
 };

+struct usbhs_phy_config {
+	char *name;		/* binds to device driver */
+	void *pdata;		/* platform data for the phy */
+	size_t pdata_size;
+};
+
 struct usbhs_omap_platform_data {
 	int				nports;
 	enum usbhs_omap_port_mode	port_mode[OMAP3_HS_USB_PORTS];
@@ -49,6 +55,8 @@ struct usbhs_omap_platform_data {
 	unsigned			single_ulpi_bypass:1;
 	unsigned			es2_compatibility:1;
 	unsigned			phy_reset:1;
+
+	struct usbhs_phy_config		*phy_config[OMAP3_HS_USB_PORTS];
 };

 /*-------------------------------------------------------------------------*/
-- 
1.7.4.1


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-USB-ehci-omap-Convert-to-platform-driver.patch
Type: text/x-patch
Size: 5842 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130111/84d5647c/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-usb-ehci-omap-Instantiate-PHY-devices-if-required.patch
Type: text/x-patch
Size: 5784 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130111/84d5647c/attachment-0003.bin>

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-11 16:03         ` Roger Quadros
@ 2013-01-11 16:32           ` Russell King - ARM Linux
  2013-01-14  9:48             ` Roger Quadros
  2013-01-11 18:27           ` Alan Stern
  1 sibling, 1 reply; 37+ messages in thread
From: Russell King - ARM Linux @ 2013-01-11 16:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jan 11, 2013 at 06:03:21PM +0200, Roger Quadros wrote:
> diff --git a/include/linux/platform_data/usb-omap.h
> b/include/linux/platform_data/usb-omap.h
> index d63eb7d..927b8a1 100644
> --- a/include/linux/platform_data/usb-omap.h
> +++ b/include/linux/platform_data/usb-omap.h
> @@ -38,6 +38,12 @@ enum usbhs_omap_port_mode {
>  	OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM
>  };
> 
> +struct usbhs_phy_config {
> +	char *name;		/* binds to device driver */

You may wish to consider making this const.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY
  2013-01-10 16:51 ` [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY Roger Quadros
  2013-01-10 18:06   ` Sergei Shtylyov
@ 2013-01-11 17:17   ` Russell King - ARM Linux
  2013-01-14  9:54     ` Roger Quadros
  1 sibling, 1 reply; 37+ messages in thread
From: Russell King - ARM Linux @ 2013-01-11 17:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 10, 2013 at 06:51:24PM +0200, Roger Quadros wrote:
> We use "vcc" as the supply name for the PHY's power supply.
> The power supply will be enabled during .init() and disabled
> during .shutdown()
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> ---
>  drivers/usb/otg/nop-usb-xceiv.c |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
> index 163f972..1c6db10 100644
> --- a/drivers/usb/otg/nop-usb-xceiv.c
> +++ b/drivers/usb/otg/nop-usb-xceiv.c
> @@ -33,11 +33,13 @@
>  #include <linux/usb/nop-usb-xceiv.h>
>  #include <linux/slab.h>
>  #include <linux/clk.h>
> +#include <linux/regulator/consumer.h>
>  
>  struct nop_usb_xceiv {
>  	struct usb_phy		phy;
>  	struct device		*dev;
>  	struct clk		*clk;
> +	struct regulator	*vcc;
>  };
>  
>  static struct platform_device *pd;
> @@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
>  {
>  	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
>  
> +	if (nop->vcc) {
> +		if (regulator_enable(nop->vcc))
> +			dev_err(phy->dev, "Failed to enable power\n");
> +	}
> +
>  	if (nop->clk)
>  		clk_enable(nop->clk);
>  
> @@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
>  
>  	if (nop->clk)
>  		clk_disable(nop->clk);
> +
> +	if (nop->vcc) {
> +		if (regulator_disable(nop->vcc))
> +			dev_err(phy->dev, "Failed to disable power\n");
> +	}
>  }
>  
>  static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
> @@ -157,6 +169,12 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> +	nop->vcc = devm_regulator_get(&pdev->dev, "vcc");
> +	if (IS_ERR(nop->vcc)) {
> +		dev_dbg(&pdev->dev, "Error getting vcc regulator\n");
> +		nop->vcc = NULL;
> +	}

Is it really appropriate for drivers to do this kind of thing with
pointer-returning functions (I mean, setting the pointer to NULL on
error, rather than just using a test for IS_ERR() in the above
locations).  You are imposing driver-local assumptions on an API.

Practically it probably doesn't make much difference but given the
amount of mistakes that we have with IS_ERR_OR_NULL()...

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data
  2013-01-11  9:40     ` Roger Quadros
@ 2013-01-11 18:13       ` Tony Lindgren
  2013-01-14 11:28         ` Roger Quadros
  0 siblings, 1 reply; 37+ messages in thread
From: Tony Lindgren @ 2013-01-11 18:13 UTC (permalink / raw)
  To: linux-arm-kernel

* Roger Quadros <rogerq@ti.com> [130111 01:43]:
> Tony,
> 
> On 01/11/2013 01:45 AM, Tony Lindgren wrote:
> > * Roger Quadros <rogerq@ti.com> [130110 08:54]:
> >> Let's have a single platform data structure for the OMAP's High-Speed
> >> USB host subsystem instead of having 3 separate ones i.e. one for
> >> board data, one for USB Host (UHH) module and one for USB-TLL module.
> >>
> >> This makes the code much simpler and avoids creating multiple copies of
> >> platform data.
> > 
> > I can apply just this patch alone into an immutable branch that
> > we all can merge in as needed as long as we have acks for the USB
> > and MFD parts.
> > 
> > Or does this one need to be changed based on Alan's comments
> > on the EHCI lib related changes?
> > 
> 
> This does not depend on EHCI lib based changes but it depends on the
> OMAP USB Host cleanup series posted earlier.

Can we first apply just the minimal platform_data + board file + clock
changes?

That way I can apply those to some immutable tree for everybody to use,
and we cut off the dependency to the driver changes for the rest of the
patches. And then I'm off the hook for the rest of the patches :)

Tony

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-11 16:03         ` Roger Quadros
  2013-01-11 16:32           ` Russell King - ARM Linux
@ 2013-01-11 18:27           ` Alan Stern
  1 sibling, 0 replies; 37+ messages in thread
From: Alan Stern @ 2013-01-11 18:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 11 Jan 2013, Roger Quadros wrote:

> Apart from what you mentioned I did some more trivial changes. e.g.
> 
> +       !IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \
> instead of
> +	!defined(CONFIG_USB_EHCI_HCD_OMAP) && \

Ah, that's a very good catch.  There's another entry needing the same
thing.  I'll put that in a separate preliminary patch, and also put
the ehci->priv addition in there instead of including it with the
ehci-mxc update.

> use ehci_hcd_omap_driver instead of ehci_omap_driver

Now fixed.

> I tried using ehci->priv in ehci-omap driver but noticed that the
> private data gets corrupted after the EHCI controller is running and has
> enumerated a few devices.
> 
> If I disable USB_DEBUG then things are fine. Could it be possible
> that someone is overflowing data when USB_DEBUG is enabled?
> 
> My implementation is pasted below. (May contain whitespace errors due to
> MS exchange). Patch 2 attached in case.
> 
> What was happening there is that omap_priv->phy was not the same during
> remove() as it was set to during probe().

I don't understand -- your second patch doesn't use ehci->priv at all.  
How can the private data be getting corrupted?

Below is an updated version of your second patch.  You'll need to
resolve one or two merge errors because it's not based on the same
starting point as yours.  (And it totally omits the part affecting
usb-omap.h.) But it will show you what needs to be done in order to use
ehci->priv.

> Would be nice if you could check if the same happens with ehci-mxc.

I can't -- I don't have an ARM-based system.  But if you still see 
problems, I can test with ehci-pci.

Alan Stern



Index: usb-3.7/drivers/usb/host/ehci-omap.c
===================================================================
--- usb-3.7.orig/drivers/usb/host/ehci-omap.c
+++ usb-3.7/drivers/usb/host/ehci-omap.c
@@ -69,6 +69,10 @@ static const char hcd_name[] = "ehci-oma
 
 /*-------------------------------------------------------------------------*/
 
+struct omap_ehci_hcd {
+	struct usb_phy **phy;	/* one PHY for each port */
+	int nports;
+};
 
 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
@@ -177,7 +181,8 @@ static void disable_put_regulator(
 static struct hc_driver __read_mostly ehci_omap_hc_driver;
 
 static const struct ehci_driver_overrides ehci_omap_overrides __initdata = {
-	.reset =	omap_ehci_init,
+	.reset =		omap_ehci_init,
+	.extra_priv_size =	sizeof(struct omap_ehci_hcd),
 };
 
 /**
@@ -193,6 +198,8 @@ static int ehci_hcd_omap_probe(struct pl
 	struct ehci_hcd_omap_platform_data	*pdata = dev->platform_data;
 	struct resource				*res;
 	struct usb_hcd				*hcd;
+	struct omap_ehci_hcd			*omap_hcd;
+	struct usb_phy				*phy;
 	void __iomem				*regs;
 	int					ret = -ENODEV;
 	int					irq;
@@ -207,6 +214,11 @@ static int ehci_hcd_omap_probe(struct pl
 		return -ENODEV;
 	}
 
+	if (!pdata) {
+		dev_err(dev, "Missing platform data\n");
+		return -ENODEV;
+	}
+
 	irq = platform_get_irq_byname(pdev, "ehci-irq");
 	if (irq < 0) {
 		dev_err(dev, "EHCI irq failed\n");
@@ -238,8 +250,24 @@ static int ehci_hcd_omap_probe(struct pl
 	hcd->rsrc_len = resource_size(res);
 	hcd->regs = regs;
 
+	omap_hcd = (struct omap_ehci_hcd *) (hcd_to_ehci(hcd))->priv;
+
+	omap_hcd->nports = pdata->nports;
+	i = sizeof(struct usb_phy *) * omap_hcd->nports;
+	omap_hcd->phy = devm_kzalloc(&pdev->dev, i, GFP_KERNEL);
+	if (!omap_hcd->phy) {
+		dev_err(dev, "Memory allocation failed\n");
+		ret = -ENOMEM;
+		goto err_alloc_phy;
+	}
+
+	platform_set_drvdata(pdev, hcd);
+
 	/* get ehci regulator and enable */
-	for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
+	for (i = 0 ; i < omap_hcd->nports ; i++) {
+		struct platform_device *phy_pdev;
+		struct usbhs_phy_config *phy_config;
+
 		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
 			pdata->regulator[i] = NULL;
 			continue;
@@ -253,6 +281,33 @@ static int ehci_hcd_omap_probe(struct pl
 		} else {
 			regulator_enable(pdata->regulator[i]);
 		}
+
+		/* instantiate PHY */
+		if (!pdata->phy_config[i]) {
+			dev_dbg(dev, "missing phy_config for port %d\n", i);
+			continue;
+		}
+
+		phy_config = pdata->phy_config[i];
+		phy_pdev = platform_device_register_data(&pdev->dev,
+				phy_config->name, i, phy_config->pdata,
+				phy_config->pdata_size);
+		if (IS_ERR(phy_pdev)) {
+			dev_dbg(dev, "error creating PHY device for port %d\n",
+					i);
+		}
+
+		phy = usb_get_phy_from_dev(&phy_pdev->dev);
+		if (IS_ERR(phy)) {
+			dev_dbg(dev, "could not get USB PHY for port %d\n", i);
+			platform_device_unregister(phy_pdev);
+			continue;
+		}
+
+		usb_phy_init(phy);
+		omap_hcd->phy[i] = phy;
+		/* bring PHY out of suspend */
+		usb_phy_set_suspend(omap_hcd->phy[i], 0);
 	}
 
 	pm_runtime_enable(dev);
@@ -282,6 +336,14 @@ static int ehci_hcd_omap_probe(struct pl
 err_pm_runtime:
 	disable_put_regulator(pdata);
 	pm_runtime_put_sync(dev);
+	for (i = 0 ; i < omap_hcd->nports ; i++) {
+		phy = omap_hcd->phy[i];
+		if (!phy)
+			continue;
+		platform_device_unregister(to_platform_device(phy->dev));
+	}
+
+err_alloc_phy:
 	usb_put_hcd(hcd);
 
 err_io:
@@ -300,13 +362,26 @@ err_io:
  */
 static int ehci_hcd_omap_remove(struct platform_device *pdev)
 {
-	struct device *dev				= &pdev->dev;
-	struct usb_hcd *hcd				= dev_get_drvdata(dev);
-	struct ehci_hcd_omap_platform_data *pdata	= dev->platform_data;
+	struct device *dev		= &pdev->dev;
+	struct usb_hcd *hcd		= dev_get_drvdata(dev);
+	struct omap_ehci_hcd *omap_hcd;
+	int i;
 
 	usb_remove_hcd(hcd);
 	disable_put_regulator(dev->platform_data);
 	iounmap(hcd->regs);
+
+	omap_hcd = (struct omap_ehci_hcd *) (hcd_to_ehci(hcd))->priv;
+	for (i = 0; i < omap_hcd->nports; i++) {
+		struct usb_phy *phy = omap_hcd->phy[i];
+
+		if (!phy)
+			continue;
+
+		usb_phy_shutdown(phy);
+		platform_device_unregister(to_platform_device(phy->dev));
+	}
+
 	usb_put_hcd(hcd);
 
 	pm_runtime_put_sync(dev);

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required
  2013-01-11 16:32           ` Russell King - ARM Linux
@ 2013-01-14  9:48             ` Roger Quadros
  0 siblings, 0 replies; 37+ messages in thread
From: Roger Quadros @ 2013-01-14  9:48 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/11/2013 06:32 PM, Russell King - ARM Linux wrote:
> On Fri, Jan 11, 2013 at 06:03:21PM +0200, Roger Quadros wrote:
>> diff --git a/include/linux/platform_data/usb-omap.h
>> b/include/linux/platform_data/usb-omap.h
>> index d63eb7d..927b8a1 100644
>> --- a/include/linux/platform_data/usb-omap.h
>> +++ b/include/linux/platform_data/usb-omap.h
>> @@ -38,6 +38,12 @@ enum usbhs_omap_port_mode {
>>  	OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM
>>  };
>>
>> +struct usbhs_phy_config {
>> +	char *name;		/* binds to device driver */
> 
> You may wish to consider making this const.
> 
OK.

--
cheers,
-roger

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY
  2013-01-11 17:17   ` Russell King - ARM Linux
@ 2013-01-14  9:54     ` Roger Quadros
  2013-01-14 11:25       ` Russell King - ARM Linux
  0 siblings, 1 reply; 37+ messages in thread
From: Roger Quadros @ 2013-01-14  9:54 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/11/2013 07:17 PM, Russell King - ARM Linux wrote:
> On Thu, Jan 10, 2013 at 06:51:24PM +0200, Roger Quadros wrote:
>> We use "vcc" as the supply name for the PHY's power supply.
>> The power supply will be enabled during .init() and disabled
>> during .shutdown()
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> ---
>>  drivers/usb/otg/nop-usb-xceiv.c |   18 ++++++++++++++++++
>>  1 files changed, 18 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
>> index 163f972..1c6db10 100644
>> --- a/drivers/usb/otg/nop-usb-xceiv.c
>> +++ b/drivers/usb/otg/nop-usb-xceiv.c
>> @@ -33,11 +33,13 @@
>>  #include <linux/usb/nop-usb-xceiv.h>
>>  #include <linux/slab.h>
>>  #include <linux/clk.h>
>> +#include <linux/regulator/consumer.h>
>>  
>>  struct nop_usb_xceiv {
>>  	struct usb_phy		phy;
>>  	struct device		*dev;
>>  	struct clk		*clk;
>> +	struct regulator	*vcc;
>>  };
>>  
>>  static struct platform_device *pd;
>> @@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
>>  {
>>  	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
>>  
>> +	if (nop->vcc) {
>> +		if (regulator_enable(nop->vcc))
>> +			dev_err(phy->dev, "Failed to enable power\n");
>> +	}
>> +
>>  	if (nop->clk)
>>  		clk_enable(nop->clk);
>>  
>> @@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
>>  
>>  	if (nop->clk)
>>  		clk_disable(nop->clk);
>> +
>> +	if (nop->vcc) {
>> +		if (regulator_disable(nop->vcc))
>> +			dev_err(phy->dev, "Failed to disable power\n");
>> +	}
>>  }
>>  
>>  static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
>> @@ -157,6 +169,12 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
>>  		}
>>  	}
>>  
>> +	nop->vcc = devm_regulator_get(&pdev->dev, "vcc");
>> +	if (IS_ERR(nop->vcc)) {
>> +		dev_dbg(&pdev->dev, "Error getting vcc regulator\n");
>> +		nop->vcc = NULL;
>> +	}
> 
> Is it really appropriate for drivers to do this kind of thing with
> pointer-returning functions (I mean, setting the pointer to NULL on
> error, rather than just using a test for IS_ERR() in the above
> locations).  You are imposing driver-local assumptions on an API.
> 
> Practically it probably doesn't make much difference but given the
> amount of mistakes that we have with IS_ERR_OR_NULL()...
> 
Makes sense. I'll convert it to use IS_ERR_OR_NULL() throughout.

--
cheers,
-roger

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY
  2013-01-14  9:54     ` Roger Quadros
@ 2013-01-14 11:25       ` Russell King - ARM Linux
  2013-01-14 11:51         ` Roger Quadros
  0 siblings, 1 reply; 37+ messages in thread
From: Russell King - ARM Linux @ 2013-01-14 11:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 14, 2013 at 11:54:42AM +0200, Roger Quadros wrote:
> On 01/11/2013 07:17 PM, Russell King - ARM Linux wrote:
> > On Thu, Jan 10, 2013 at 06:51:24PM +0200, Roger Quadros wrote:
> >> We use "vcc" as the supply name for the PHY's power supply.
> >> The power supply will be enabled during .init() and disabled
> >> during .shutdown()
> >>
> >> Signed-off-by: Roger Quadros <rogerq@ti.com>
> >> ---
> >>  drivers/usb/otg/nop-usb-xceiv.c |   18 ++++++++++++++++++
> >>  1 files changed, 18 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
> >> index 163f972..1c6db10 100644
> >> --- a/drivers/usb/otg/nop-usb-xceiv.c
> >> +++ b/drivers/usb/otg/nop-usb-xceiv.c
> >> @@ -33,11 +33,13 @@
> >>  #include <linux/usb/nop-usb-xceiv.h>
> >>  #include <linux/slab.h>
> >>  #include <linux/clk.h>
> >> +#include <linux/regulator/consumer.h>
> >>  
> >>  struct nop_usb_xceiv {
> >>  	struct usb_phy		phy;
> >>  	struct device		*dev;
> >>  	struct clk		*clk;
> >> +	struct regulator	*vcc;
> >>  };
> >>  
> >>  static struct platform_device *pd;
> >> @@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
> >>  {
> >>  	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
> >>  
> >> +	if (nop->vcc) {
> >> +		if (regulator_enable(nop->vcc))
> >> +			dev_err(phy->dev, "Failed to enable power\n");
> >> +	}
> >> +
> >>  	if (nop->clk)
> >>  		clk_enable(nop->clk);
> >>  
> >> @@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
> >>  
> >>  	if (nop->clk)
> >>  		clk_disable(nop->clk);
> >> +
> >> +	if (nop->vcc) {
> >> +		if (regulator_disable(nop->vcc))
> >> +			dev_err(phy->dev, "Failed to disable power\n");
> >> +	}
> >>  }
> >>  
> >>  static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
> >> @@ -157,6 +169,12 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
> >>  		}
> >>  	}
> >>  
> >> +	nop->vcc = devm_regulator_get(&pdev->dev, "vcc");
> >> +	if (IS_ERR(nop->vcc)) {
> >> +		dev_dbg(&pdev->dev, "Error getting vcc regulator\n");
> >> +		nop->vcc = NULL;
> >> +	}
> > 
> > Is it really appropriate for drivers to do this kind of thing with
> > pointer-returning functions (I mean, setting the pointer to NULL on
> > error, rather than just using a test for IS_ERR() in the above
> > locations).  You are imposing driver-local assumptions on an API.
> > 
> > Practically it probably doesn't make much difference but given the
> > amount of mistakes that we have with IS_ERR_OR_NULL()...
> > 
> Makes sense. I'll convert it to use IS_ERR_OR_NULL() throughout.

IS_ERR_OR_NULL() is going to be deprecated and removed.  Please take a
look at how these APIs work.

If regulator support is not enabled, then devm_regulator_get() returns
NULL, and all the other regulator functions become no-ops.  This is not
an error.  Do you need the driver to error out if CONFIG_REGULATOR is
disabled?

If regulator support is enabled, then it can return a pointer-error
value (as defined when IS_ERR() is true, and _in that case only_ can it
be decoded by PTR_ERR() - PTR_ERR() is _only_ valid when IS_ERR()
returns true - it is _not_ valid for all the cases that IS_ERR_OR_NULL()
returns true.)  Otherwise, it returns a cookie as far as the driver is
concerned for the regulator suitable for passing into the other regulator
APIs.

By having the driver do something different, and make use of NULL as its
own special sentinel, it's placing additional interpretations on the API,
which can lead to bugs.  Don't do this.

If you can start making use of 'nop' vcc/clk members before they've been
"got" then initialize them to ERR_PTR(-EINVAL) first.

Also consider that when using the devm interfaces, you can do:


	nop->clk = devm_clk_get(&pdev->dev, ...);
	nop->vcc = devm_regulator_get(&pdev->dev, "vcc");

	if (IS_ERR(nop->clk))
		dev_dbg(&pdev->dev, "unable to get clock: %d\n",
			PTR_ERR(nop->clk));

	if (IS_ERR(nop->vcc))
		dev_dbg(&pdev->dev, "unable to get vcc regulator: %d\n",
			PTR_ERR(nop->vcc));
...
	if (!IS_ERR(nop->clk))
		clk_enable(nop->clk);

You may also consider that if you're going to print a warning for
regulator_enable(), that you should print the error code as well, so that
you know the reason why the failure happened.

Also consider... is dev_err() appropriate for an "error", for which you
print a message and continue as if nothing went wrong.  To me that sounds
more like a warning than an error, so maybe dev_warn() would be more
appropriate?

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data
  2013-01-11 18:13       ` Tony Lindgren
@ 2013-01-14 11:28         ` Roger Quadros
  2013-01-14 17:18           ` Tony Lindgren
  0 siblings, 1 reply; 37+ messages in thread
From: Roger Quadros @ 2013-01-14 11:28 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/11/2013 08:13 PM, Tony Lindgren wrote:
> * Roger Quadros <rogerq@ti.com> [130111 01:43]:
>> Tony,
>>
>> On 01/11/2013 01:45 AM, Tony Lindgren wrote:
>>> * Roger Quadros <rogerq@ti.com> [130110 08:54]:
>>>> Let's have a single platform data structure for the OMAP's High-Speed
>>>> USB host subsystem instead of having 3 separate ones i.e. one for
>>>> board data, one for USB Host (UHH) module and one for USB-TLL module.
>>>>
>>>> This makes the code much simpler and avoids creating multiple copies of
>>>> platform data.
>>>
>>> I can apply just this patch alone into an immutable branch that
>>> we all can merge in as needed as long as we have acks for the USB
>>> and MFD parts.
>>>
>>> Or does this one need to be changed based on Alan's comments
>>> on the EHCI lib related changes?
>>>
>>
>> This does not depend on EHCI lib based changes but it depends on the
>> OMAP USB Host cleanup series posted earlier.
> 
> Can we first apply just the minimal platform_data + board file + clock
> changes?
> 
We could, but I'll then have to make changes to the patches in the first
series and re-post them. Do you want me to do that?

> That way I can apply those to some immutable tree for everybody to use,
> and we cut off the dependency to the driver changes for the rest of the
> patches. And then I'm off the hook for the rest of the patches :)
> 

Or you could just ack this patch ;). The platform data is specific to
USB host only :)

--
cheers,
-roger

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY
  2013-01-14 11:25       ` Russell King - ARM Linux
@ 2013-01-14 11:51         ` Roger Quadros
  2013-01-14 12:18           ` Russell King - ARM Linux
  0 siblings, 1 reply; 37+ messages in thread
From: Roger Quadros @ 2013-01-14 11:51 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/14/2013 01:25 PM, Russell King - ARM Linux wrote:
> On Mon, Jan 14, 2013 at 11:54:42AM +0200, Roger Quadros wrote:
>> On 01/11/2013 07:17 PM, Russell King - ARM Linux wrote:
>>> On Thu, Jan 10, 2013 at 06:51:24PM +0200, Roger Quadros wrote:
>>>> We use "vcc" as the supply name for the PHY's power supply.
>>>> The power supply will be enabled during .init() and disabled
>>>> during .shutdown()
>>>>
>>>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>>>> ---
>>>>  drivers/usb/otg/nop-usb-xceiv.c |   18 ++++++++++++++++++
>>>>  1 files changed, 18 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
>>>> index 163f972..1c6db10 100644
>>>> --- a/drivers/usb/otg/nop-usb-xceiv.c
>>>> +++ b/drivers/usb/otg/nop-usb-xceiv.c
>>>> @@ -33,11 +33,13 @@
>>>>  #include <linux/usb/nop-usb-xceiv.h>
>>>>  #include <linux/slab.h>
>>>>  #include <linux/clk.h>
>>>> +#include <linux/regulator/consumer.h>
>>>>  
>>>>  struct nop_usb_xceiv {
>>>>  	struct usb_phy		phy;
>>>>  	struct device		*dev;
>>>>  	struct clk		*clk;
>>>> +	struct regulator	*vcc;
>>>>  };
>>>>  
>>>>  static struct platform_device *pd;
>>>> @@ -70,6 +72,11 @@ static int nop_init(struct usb_phy *phy)
>>>>  {
>>>>  	struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev);
>>>>  
>>>> +	if (nop->vcc) {
>>>> +		if (regulator_enable(nop->vcc))
>>>> +			dev_err(phy->dev, "Failed to enable power\n");
>>>> +	}
>>>> +
>>>>  	if (nop->clk)
>>>>  		clk_enable(nop->clk);
>>>>  
>>>> @@ -82,6 +89,11 @@ static void nop_shutdown(struct usb_phy *phy)
>>>>  
>>>>  	if (nop->clk)
>>>>  		clk_disable(nop->clk);
>>>> +
>>>> +	if (nop->vcc) {
>>>> +		if (regulator_disable(nop->vcc))
>>>> +			dev_err(phy->dev, "Failed to disable power\n");
>>>> +	}
>>>>  }
>>>>  
>>>>  static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
>>>> @@ -157,6 +169,12 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
>>>>  		}
>>>>  	}
>>>>  
>>>> +	nop->vcc = devm_regulator_get(&pdev->dev, "vcc");
>>>> +	if (IS_ERR(nop->vcc)) {
>>>> +		dev_dbg(&pdev->dev, "Error getting vcc regulator\n");
>>>> +		nop->vcc = NULL;
>>>> +	}
>>>
>>> Is it really appropriate for drivers to do this kind of thing with
>>> pointer-returning functions (I mean, setting the pointer to NULL on
>>> error, rather than just using a test for IS_ERR() in the above
>>> locations).  You are imposing driver-local assumptions on an API.
>>>
>>> Practically it probably doesn't make much difference but given the
>>> amount of mistakes that we have with IS_ERR_OR_NULL()...
>>>
>> Makes sense. I'll convert it to use IS_ERR_OR_NULL() throughout.
> 
> IS_ERR_OR_NULL() is going to be deprecated and removed.  Please take a
> look at how these APIs work.

OK. I misunderstood what you meant earlier.

> 
> If regulator support is not enabled, then devm_regulator_get() returns
> NULL, and all the other regulator functions become no-ops.  This is not
> an error.  Do you need the driver to error out if CONFIG_REGULATOR is
> disabled?
> 
No, in fact even if CONFIG_REGULATOR is enabled and regulator_get()
fails, we just print a debug message and continue as usual. So
CONFIG_REGULATOR disabled _and_ regulator_get() error are handled in the
same way.

> If regulator support is enabled, then it can return a pointer-error
> value (as defined when IS_ERR() is true, and _in that case only_ can it
> be decoded by PTR_ERR() - PTR_ERR() is _only_ valid when IS_ERR()
> returns true - it is _not_ valid for all the cases that IS_ERR_OR_NULL()
> returns true.)  Otherwise, it returns a cookie as far as the driver is
> concerned for the regulator suitable for passing into the other regulator
> APIs.
> 
> By having the driver do something different, and make use of NULL as its
> own special sentinel, it's placing additional interpretations on the API,
> which can lead to bugs.  Don't do this.

Agreed.

> 
> If you can start making use of 'nop' vcc/clk members before they've been
> "got" then initialize them to ERR_PTR(-EINVAL) first.
> 
> Also consider that when using the devm interfaces, you can do:
> 
> 
> 	nop->clk = devm_clk_get(&pdev->dev, ...);
> 	nop->vcc = devm_regulator_get(&pdev->dev, "vcc");
> 
> 	if (IS_ERR(nop->clk))
> 		dev_dbg(&pdev->dev, "unable to get clock: %d\n",
> 			PTR_ERR(nop->clk));
> 
> 	if (IS_ERR(nop->vcc))
> 		dev_dbg(&pdev->dev, "unable to get vcc regulator: %d\n",
> 			PTR_ERR(nop->vcc));
> ...
> 	if (!IS_ERR(nop->clk))
> 		clk_enable(nop->clk);

OK I get it now. The only case where nop->clk or nop->vcc will be NULL
is if the framework is not enabled. It is fine to call the
regulator/clock APIs with NULL pointers in that case.

> 
> You may also consider that if you're going to print a warning for
> regulator_enable(), that you should print the error code as well, so that
> you know the reason why the failure happened.

OK.
> 
> Also consider... is dev_err() appropriate for an "error", for which you
> print a message and continue as if nothing went wrong.  To me that sounds
> more like a warning than an error, so maybe dev_warn() would be more
> appropriate?
> 
I used dev_dbg(), because we don't treat not getting the power supply
regulator as that serious.

--
cheers,
-roger

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY
  2013-01-14 11:51         ` Roger Quadros
@ 2013-01-14 12:18           ` Russell King - ARM Linux
  0 siblings, 0 replies; 37+ messages in thread
From: Russell King - ARM Linux @ 2013-01-14 12:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 14, 2013 at 01:51:07PM +0200, Roger Quadros wrote:
> On 01/14/2013 01:25 PM, Russell King - ARM Linux wrote:
> > Also consider... is dev_err() appropriate for an "error", for which you
> > print a message and continue as if nothing went wrong.  To me that sounds
> > more like a warning than an error, so maybe dev_warn() would be more
> > appropriate?
> > 
> I used dev_dbg(), because we don't treat not getting the power supply
> regulator as that serious.

This comment is about what you do when regulator_enable() and the like
returns non-zero.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data
  2013-01-14 11:28         ` Roger Quadros
@ 2013-01-14 17:18           ` Tony Lindgren
  0 siblings, 0 replies; 37+ messages in thread
From: Tony Lindgren @ 2013-01-14 17:18 UTC (permalink / raw)
  To: linux-arm-kernel

* Roger Quadros <rogerq@ti.com> [130114 03:31]:
> On 01/11/2013 08:13 PM, Tony Lindgren wrote:
> > * Roger Quadros <rogerq@ti.com> [130111 01:43]:
> >> Tony,
> >>
> >> On 01/11/2013 01:45 AM, Tony Lindgren wrote:
> >>> * Roger Quadros <rogerq@ti.com> [130110 08:54]:
> >>>> Let's have a single platform data structure for the OMAP's High-Speed
> >>>> USB host subsystem instead of having 3 separate ones i.e. one for
> >>>> board data, one for USB Host (UHH) module and one for USB-TLL module.
> >>>>
> >>>> This makes the code much simpler and avoids creating multiple copies of
> >>>> platform data.
> >>>
> >>> I can apply just this patch alone into an immutable branch that
> >>> we all can merge in as needed as long as we have acks for the USB
> >>> and MFD parts.
> >>>
> >>> Or does this one need to be changed based on Alan's comments
> >>> on the EHCI lib related changes?
> >>>
> >>
> >> This does not depend on EHCI lib based changes but it depends on the
> >> OMAP USB Host cleanup series posted earlier.
> > 
> > Can we first apply just the minimal platform_data + board file + clock
> > changes?
> > 
> We could, but I'll then have to make changes to the patches in the first
> series and re-post them. Do you want me to do that?

Yes please. Otherwise we'll unnecessarily complicate the dependencies between 
arch/arm/*omap* code and the drivers. And we've certainly had enough of
self-inflicted merge conflicts with the omap usb code already :)
 
> > That way I can apply those to some immutable tree for everybody to use,
> > and we cut off the dependency to the driver changes for the rest of the
> > patches. And then I'm off the hook for the rest of the patches :)
> > 
> 
> Or you could just ack this patch ;). The platform data is specific to
> USB host only :)

Well it's not just this patch. It's the clock related patches in your
earlier seriers that will conflict with any attempts to move the clock
data to live under drivers/clk/omap where it needs to go. And the three
patches at the end of this series to add platform data (which look fine),
but will likely conflict with something else. Let's try do do these changes
in a way where the dependencies are cut to minimum where possible.

Regards,

Tony

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 08/14] mfd: omap-usb-host: Remove PHY reset handling code
  2013-01-10 16:51 ` [PATCH 08/14] mfd: omap-usb-host: Remove PHY reset handling code Roger Quadros
@ 2013-01-22  3:28   ` Samuel Ortiz
  0 siblings, 0 replies; 37+ messages in thread
From: Samuel Ortiz @ 2013-01-22  3:28 UTC (permalink / raw)
  To: linux-arm-kernel

HI Roger,

On Thu, Jan 10, 2013 at 06:51:28PM +0200, Roger Quadros wrote:
> PHY reset GPIO handling will be done in the PHY driver
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 06/14] mfd: omap-usb-host: update nports in platform_data
  2013-01-10 16:51 ` [PATCH 06/14] mfd: omap-usb-host: update nports in platform_data Roger Quadros
@ 2013-01-22  3:29   ` Samuel Ortiz
  0 siblings, 0 replies; 37+ messages in thread
From: Samuel Ortiz @ 2013-01-22  3:29 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Roger,

On Thu, Jan 10, 2013 at 06:51:26PM +0200, Roger Quadros wrote:
> EHCI driver would need to know the number of ports available
> on the platform. We set the nports parameter of platform_data
> based on IP version if it was not already provided.
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Samuel Ortiz <sameo@linux.intel.com>

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2013-01-22  3:29 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-10 16:51 [PATCH 00/14] USB: omap-ehci: Move PHY management to PHY driver Roger Quadros
2013-01-10 16:51 ` [PATCH 01/14] mfd: omap-usb-host: Consolidate OMAP USB-HS platform data Roger Quadros
2013-01-10 23:45   ` Tony Lindgren
2013-01-11  9:40     ` Roger Quadros
2013-01-11 18:13       ` Tony Lindgren
2013-01-14 11:28         ` Roger Quadros
2013-01-14 17:18           ` Tony Lindgren
2013-01-10 16:51 ` [PATCH 02/14] usb: phy: Add new API usb_get_phy_from_dev() Roger Quadros
2013-01-10 16:51 ` [PATCH 03/14] usb: xceiv: nop: Manage PHY clock Roger Quadros
2013-01-10 16:51 ` [PATCH 04/14] usb: phy: nop: Handle power supply regulator for the PHY Roger Quadros
2013-01-10 18:06   ` Sergei Shtylyov
2013-01-11  9:41     ` Roger Quadros
2013-01-11 17:17   ` Russell King - ARM Linux
2013-01-14  9:54     ` Roger Quadros
2013-01-14 11:25       ` Russell King - ARM Linux
2013-01-14 11:51         ` Roger Quadros
2013-01-14 12:18           ` Russell King - ARM Linux
2013-01-10 16:51 ` [PATCH 05/14] usb: phy: nop: Handle RESET " Roger Quadros
2013-01-10 16:51 ` [PATCH 06/14] mfd: omap-usb-host: update nports in platform_data Roger Quadros
2013-01-22  3:29   ` Samuel Ortiz
2013-01-10 16:51 ` [PATCH 07/14] usb: ehci-omap: Instantiate PHY devices if required Roger Quadros
2013-01-10 20:48   ` Alan Stern
2013-01-11 10:59     ` Roger Quadros
2013-01-11 11:06       ` Roger Quadros
2013-01-11 15:28       ` Alan Stern
2013-01-11 16:03         ` Roger Quadros
2013-01-11 16:32           ` Russell King - ARM Linux
2013-01-14  9:48             ` Roger Quadros
2013-01-11 18:27           ` Alan Stern
2013-01-10 16:51 ` [PATCH 08/14] mfd: omap-usb-host: Remove PHY reset handling code Roger Quadros
2013-01-22  3:28   ` Samuel Ortiz
2013-01-10 16:51 ` [PATCH 09/14] usb: ehci-omap: " Roger Quadros
2013-01-10 16:51 ` [PATCH 10/14] usb: ehci-omap: Remove PHY regulator " Roger Quadros
2013-01-10 16:51 ` [PATCH 11/14] ARM: OMAP2+: omap4panda: Provide USB Host's PHY platform data Roger Quadros
2013-01-10 16:51 ` [PATCH 12/14] ARM: OMAP2+: omap4panda: Adapt HUB power to regulator framework Roger Quadros
2013-01-10 16:51 ` [PATCH 13/14] ARM: OMAP2+: omap4panda: Adapt HUB reset " Roger Quadros
2013-01-10 16:51 ` [PATCH 14/14] ARM: OMAP2+: omap4panda: Remove irrelevant USB host platform data Roger Quadros

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).