linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10
@ 2013-03-12 10:44 Roger Quadros
  2013-03-12 10:44 ` [PATCH 01/12] USB: EHCI: split ehci-omap out to a separate driver Roger Quadros
                   ` (12 more replies)
  0 siblings, 13 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

Hi Greg,

These patches implement device tree support for the OMAP's
EHCI host controller. The corresponding MFD/SoC patches will be sent
separately and this set has no dependeny with them.

NOTE: Last 2 patches are new and still need and Ack from Alan Stern.
Please accept this set after he has acked them. Thanks.

cheers,
-roger

The following changes since commit f6161aa153581da4a3867a2d1a7caf4be19b6ec9:

  Linux 3.9-rc2 (2013-03-10 16:54:19 -0700)

are available in the git repository at:
  git://github.com/rogerq/linux.git usbhost-usb-next

Alan Stern (1):
  USB: EHCI: split ehci-omap out to a separate driver

Roger Quadros (11):
  USB: ehci-omap: Use devm_ioremap_resource()
  USB: ehci-omap: Use PHY APIs to get the PHY device and put it out of
    suspend
  USB: ehci-omap: Remove PHY reset handling code
  USB: ehci-omap: Remove PHY regulator handling code
  USB: ehci-omap: Select NOP USB transceiver driver
  USB: ehci-omap: Get platform resources by index rather than by name
  USB: ohci-omap3: Get platform resources by index rather than by name
  USB: ohci-omap3: Add device tree support and binding information
  USB: ehci-omap: Add device tree support and binding information
  USB: ehci-omap: Try to get PHY even if not in PHY mode
  USB: ehci-omap: Fix detection in HSIC mode

 .../devicetree/bindings/usb/ehci-omap.txt          |   32 ++
 .../devicetree/bindings/usb/ohci-omap3.txt         |   15 +
 drivers/usb/host/Kconfig                           |    3 +-
 drivers/usb/host/Makefile                          |    1 +
 drivers/usb/host/ehci-hcd.c                        |    6 +-
 drivers/usb/host/ehci-omap.c                       |  312 +++++++++-----------
 drivers/usb/host/ohci-omap3.c                      |   24 ++-
 7 files changed, 214 insertions(+), 179 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-omap.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-omap3.txt

-- 
1.7.4.1


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

* [PATCH 01/12] USB: EHCI: split ehci-omap out to a separate driver
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 02/12] USB: ehci-omap: Use devm_ioremap_resource() Roger Quadros
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

From: Alan Stern <stern@rowland.harvard.edu>

This patch (as1645) converts ehci-omap over to the new "ehci-hcd is a
library" approach, so that it can coexist peacefully with other EHCI
platform drivers and can make use of the private area allocated at
the end of struct ehci_hcd.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
---
 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 c59a112..62f4e9a 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 001fbff..56de410 100644
--- a/drivers/usb/host/Makefile
+++ b/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
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index b416a3f..303b022 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1252,11 +1252,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
@@ -1346,6 +1341,7 @@ MODULE_LICENSE ("GPL");
 	!IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
 	!IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST) && \
 	!IS_ENABLED(CONFIG_USB_EHCI_MXC) && \
+	!IS_ENABLED(CONFIG_USB_EHCI_HCD_OMAP) && \
 	!defined(PLATFORM_DRIVER) && \
 	!defined(PS3_SYSTEM_BUS_DRIVER) && \
 	!defined(OF_PLATFORM_DRIVER) && \
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 0555ee4..fa66757 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:ehci-omap");
 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] 25+ messages in thread

* [PATCH 02/12] USB: ehci-omap: Use devm_ioremap_resource()
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
  2013-03-12 10:44 ` [PATCH 01/12] USB: EHCI: split ehci-omap out to a separate driver Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 03/12] USB: ehci-omap: Use PHY APIs to get the PHY device and put it out of suspend Roger Quadros
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

Make use of devm_ioremap_resource() and correct comment.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index fa66757..70e8e6f 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -216,23 +216,15 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 
 	res =  platform_get_resource_byname(pdev,
 				IORESOURCE_MEM, "ehci");
-	if (!res) {
-		dev_err(dev, "UHH EHCI get resource failed\n");
-		return -ENODEV;
-	}
-
-	regs = ioremap(res->start, resource_size(res));
-	if (!regs) {
-		dev_err(dev, "UHH EHCI ioremap failed\n");
-		return -ENOMEM;
-	}
+	regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
 	hcd = usb_create_hcd(&ehci_omap_hc_driver, dev,
 			dev_name(dev));
 	if (!hcd) {
-		dev_err(dev, "failed to create hcd with err %d\n", ret);
-		ret = -ENOMEM;
-		goto err_io;
+		dev_err(dev, "Failed to create HCD\n");
+		return -ENOMEM;
 	}
 
 	hcd->rsrc_start = res->start;
@@ -285,8 +277,6 @@ err_pm_runtime:
 	pm_runtime_put_sync(dev);
 	usb_put_hcd(hcd);
 
-err_io:
-	iounmap(regs);
 	return ret;
 }
 
@@ -306,7 +296,6 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
 
 	usb_remove_hcd(hcd);
 	disable_put_regulator(dev->platform_data);
-	iounmap(hcd->regs);
 	usb_put_hcd(hcd);
 
 	pm_runtime_put_sync(dev);
-- 
1.7.4.1


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

* [PATCH 03/12] USB: ehci-omap: Use PHY APIs to get the PHY device and put it out of suspend
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
  2013-03-12 10:44 ` [PATCH 01/12] USB: EHCI: split ehci-omap out to a separate driver Roger Quadros
  2013-03-12 10:44 ` [PATCH 02/12] USB: ehci-omap: Use devm_ioremap_resource() Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 04/12] USB: ehci-omap: Remove PHY reset handling code Roger Quadros
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

For each port that is in PHY mode we obtain a PHY device using the USB PHY
library and put it out of suspend.

It is up to platform code to associate the PHY to the controller's
port and it is up to the PHY driver to manage the PHY's resources.

Also remove weird spacing around declarations we come across.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |   76 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 62 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 70e8e6f..6b8b7e5 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -4,10 +4,11 @@
  * Bus Glue for the EHCI controllers in OMAP3/4
  * Tested on several OMAP3 boards, and OMAP4 Pandaboard
  *
- * Copyright (C) 2007-2011 Texas Instruments, Inc.
+ * Copyright (C) 2007-2013 Texas Instruments, Inc.
  *	Author: Vikram Pandita <vikram.pandita@ti.com>
  *	Author: Anand Gadiyar <gadiyar@ti.com>
  *	Author: Keshava Munegowda <keshava_mgowda@ti.com>
+ *	Author: Roger Quadros <rogerq@ti.com>
  *
  * Copyright (C) 2009 Nokia Corporation
  *	Contact: Felipe Balbi <felipe.balbi@nokia.com>
@@ -70,6 +71,10 @@ static const char hcd_name[] = "ehci-omap";
 
 /*-------------------------------------------------------------------------*/
 
+struct omap_hcd {
+	struct usb_phy *phy[OMAP3_HS_USB_PORTS]; /* one PHY for each port */
+	int nports;
+};
 
 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
@@ -178,7 +183,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_hcd),
 };
 
 /**
@@ -190,15 +196,16 @@ static const struct ehci_driver_overrides ehci_omap_overrides __initdata = {
  */
 static int ehci_hcd_omap_probe(struct platform_device *pdev)
 {
-	struct device				*dev = &pdev->dev;
-	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
-	struct resource				*res;
-	struct usb_hcd				*hcd;
-	void __iomem				*regs;
-	int					ret = -ENODEV;
-	int					irq;
-	int					i;
-	char					supply[7];
+	struct device *dev = &pdev->dev;
+	struct usbhs_omap_platform_data *pdata = dev->platform_data;
+	struct resource	*res;
+	struct usb_hcd	*hcd;
+	void __iomem *regs;
+	int ret = -ENODEV;
+	int irq;
+	int i;
+	char supply[7];
+	struct omap_hcd	*omap;
 
 	if (usb_disabled())
 		return -ENODEV;
@@ -231,6 +238,33 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	hcd->rsrc_len = resource_size(res);
 	hcd->regs = regs;
 
+	omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
+	omap->nports = pdata->nports;
+
+	platform_set_drvdata(pdev, hcd);
+
+	/* get the PHY devices if needed */
+	for (i = 0 ; i < omap->nports ; i++) {
+		struct usb_phy *phy;
+
+		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY)
+			continue;
+
+		/* get the PHY device */
+		phy = devm_usb_get_phy_dev(dev, i);
+		if (IS_ERR(phy) || !phy) {
+			ret = IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
+			dev_err(dev, "Can't get PHY device for port %d: %d\n",
+					i, ret);
+			goto err_phy;
+		}
+
+		omap->phy[i] = phy;
+		usb_phy_init(omap->phy[i]);
+		/* bring PHY out of suspend */
+		usb_phy_set_suspend(omap->phy[i], 0);
+	}
+
 	/* get ehci regulator and enable */
 	for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
 		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
@@ -275,6 +309,13 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 err_pm_runtime:
 	disable_put_regulator(pdata);
 	pm_runtime_put_sync(dev);
+
+err_phy:
+	for (i = 0; i < omap->nports; i++) {
+		if (omap->phy[i])
+			usb_phy_shutdown(omap->phy[i]);
+	}
+
 	usb_put_hcd(hcd);
 
 	return ret;
@@ -291,13 +332,20 @@ err_pm_runtime:
  */
 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 usb_hcd *hcd = dev_get_drvdata(dev);
+	struct omap_hcd *omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
+	int i;
 
 	usb_remove_hcd(hcd);
 	disable_put_regulator(dev->platform_data);
-	usb_put_hcd(hcd);
 
+	for (i = 0; i < omap->nports; i++) {
+		if (omap->phy[i])
+			usb_phy_shutdown(omap->phy[i]);
+	}
+
+	usb_put_hcd(hcd);
 	pm_runtime_put_sync(dev);
 	pm_runtime_disable(dev);
 
-- 
1.7.4.1


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

* [PATCH 04/12] USB: ehci-omap: Remove PHY reset handling code
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (2 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 03/12] USB: ehci-omap: Use PHY APIs to get the PHY device and put it out of suspend Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 05/12] USB: ehci-omap: Remove PHY regulator " Roger Quadros
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

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>
Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |   72 ++++++------------------------------------
 1 files changed, 10 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 6b8b7e5..0bbfdc1 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -86,79 +86,27 @@ 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;
-
-	pdata = hcd->self.controller->platform_data;
+	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
+	struct omap_hcd	*omap = (struct omap_hcd *)ehci->priv;
+	int rc, i;
 
 	/* 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->nports; i++) {
+		if (omap->phy[i])
+			usb_phy_shutdown(omap->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->nports; i++) {
+		if (omap->phy[i])
+			usb_phy_init(omap->phy[i]);
 	}
 
 	return rc;
-- 
1.7.4.1


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

* [PATCH 05/12] USB: ehci-omap: Remove PHY regulator handling code
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (3 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 04/12] USB: ehci-omap: Remove PHY reset handling code Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 06/12] USB: ehci-omap: Select NOP USB transceiver driver Roger Quadros
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

PHY regulator handling must be done in the PHY driver

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |   34 ----------------------------------
 1 files changed, 0 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 0bbfdc1..57fe985 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -43,7 +43,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>
@@ -112,19 +111,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 */
 
@@ -152,7 +138,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	int ret = -ENODEV;
 	int irq;
 	int i;
-	char supply[7];
 	struct omap_hcd	*omap;
 
 	if (usb_disabled())
@@ -213,23 +198,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		usb_phy_set_suspend(omap->phy[i], 0);
 	}
 
-	/* get ehci regulator and enable */
-	for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
-		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
-			pdata->regulator[i] = NULL;
-			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]);
-		}
-	}
-
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);
 
@@ -255,7 +223,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);
 
 err_phy:
@@ -286,7 +253,6 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
 	int i;
 
 	usb_remove_hcd(hcd);
-	disable_put_regulator(dev->platform_data);
 
 	for (i = 0; i < omap->nports; i++) {
 		if (omap->phy[i])
-- 
1.7.4.1


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

* [PATCH 06/12] USB: ehci-omap: Select NOP USB transceiver driver
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (4 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 05/12] USB: ehci-omap: Remove PHY regulator " Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 07/12] USB: ehci-omap: Get platform resources by index rather than by name Roger Quadros
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

In PHY mode we need to have the nop-usb-xceiv transceiver
driver to operate, so select it in Kconfig.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 62f4e9a..2f68221 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -157,6 +157,7 @@ config USB_EHCI_MXC
 config USB_EHCI_HCD_OMAP
 	tristate "EHCI support for OMAP3 and later chips"
 	depends on USB_EHCI_HCD && ARCH_OMAP
+	select NOP_USB_XCEIV
 	default y
 	---help---
 	  Enables support for the on-chip EHCI controller on
-- 
1.7.4.1


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

* [PATCH 07/12] USB: ehci-omap: Get platform resources by index rather than by name
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (5 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 06/12] USB: ehci-omap: Select NOP USB transceiver driver Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 08/12] USB: ohci-omap3: " Roger Quadros
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

Since there is only one resource per type we don't really need
to use resource name to obtain it. This also also makes it easier
for device tree adaptation.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 57fe985..7d05cce 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -148,14 +148,13 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	irq = platform_get_irq_byname(pdev, "ehci-irq");
+	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "EHCI irq failed\n");
 		return -ENODEV;
 	}
 
-	res =  platform_get_resource_byname(pdev,
-				IORESOURCE_MEM, "ehci");
+	res =  platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
-- 
1.7.4.1


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

* [PATCH 08/12] USB: ohci-omap3: Get platform resources by index rather than by name
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (6 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 07/12] USB: ehci-omap: Get platform resources by index rather than by name Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 09/12] USB: ohci-omap3: Add device tree support and binding information Roger Quadros
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

Since there is only one resource per type we don't really need
to use resource name to obtain it. This also also makes it easier
for device tree adaptation.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ohci-omap3.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
index eb35d96..5ed28c5 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ b/drivers/usb/host/ohci-omap3.c
@@ -141,14 +141,13 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	irq = platform_get_irq_byname(pdev, "ohci-irq");
+	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "OHCI irq failed\n");
 		return -ENODEV;
 	}
 
-	res = platform_get_resource_byname(pdev,
-				IORESOURCE_MEM, "ohci");
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		dev_err(dev, "UHH OHCI get resource failed\n");
 		return -ENOMEM;
-- 
1.7.4.1


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

* [PATCH 09/12] USB: ohci-omap3: Add device tree support and binding information
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (7 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 08/12] USB: ohci-omap3: " Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 10/12] USB: ehci-omap: " Roger Quadros
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

Allows the OHCI controller found in OMAP3 and later chips to
be specified via device tree.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 .../devicetree/bindings/usb/ohci-omap3.txt         |   15 +++++++++++++++
 drivers/usb/host/ohci-omap3.c                      |   19 +++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-omap3.txt

diff --git a/Documentation/devicetree/bindings/usb/ohci-omap3.txt b/Documentation/devicetree/bindings/usb/ohci-omap3.txt
new file mode 100644
index 0000000..14ab428
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ohci-omap3.txt
@@ -0,0 +1,15 @@
+OMAP HS USB OHCI controller (OMAP3 and later)
+
+Required properties:
+
+- compatible: should be "ti,ohci-omap3"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+
+Example for OMAP4:
+
+usbhsohci: ohci@4a064800 {
+	compatible = "ti,ohci-omap3", "usb-ohci";
+	reg = <0x4a064800 0x400>;
+	interrupts = <0 76 0x4>;
+};
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
index 5ed28c5..ddfc314 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ b/drivers/usb/host/ohci-omap3.c
@@ -31,6 +31,8 @@
 
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/of.h>
+#include <linux/dma-mapping.h>
 
 /*-------------------------------------------------------------------------*/
 
@@ -112,6 +114,8 @@ static const struct hc_driver ohci_omap3_hc_driver = {
 
 /*-------------------------------------------------------------------------*/
 
+static u64 omap_ohci_dma_mask = DMA_BIT_MASK(32);
+
 /*
  * configure so an HC device and id are always provided
  * always called with process context; sleeping is OK
@@ -159,6 +163,13 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	/*
+	 * Right now device-tree probed devices don't get dma_mask set.
+	 * Since shared usb code relies on it, set it here for now.
+	 * Once we have dma capability bindings this can go away.
+	 */
+	if (!pdev->dev.dma_mask)
+		pdev->dev.dma_mask = &omap_ohci_dma_mask;
 
 	hcd = usb_create_hcd(&ohci_omap3_hc_driver, dev,
 			dev_name(dev));
@@ -228,12 +239,20 @@ static void ohci_hcd_omap3_shutdown(struct platform_device *pdev)
 		hcd->driver->shutdown(hcd);
 }
 
+static const struct of_device_id omap_ohci_dt_ids[] = {
+	{ .compatible = "ti,ohci-omap3" },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, omap_ohci_dt_ids);
+
 static struct platform_driver ohci_hcd_omap3_driver = {
 	.probe		= ohci_hcd_omap3_probe,
 	.remove		= ohci_hcd_omap3_remove,
 	.shutdown	= ohci_hcd_omap3_shutdown,
 	.driver		= {
 		.name	= "ohci-omap3",
+		.of_match_table = of_match_ptr(omap_ohci_dt_ids),
 	},
 };
 
-- 
1.7.4.1


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

* [PATCH 10/12] USB: ehci-omap: Add device tree support and binding information
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (8 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 09/12] USB: ohci-omap3: Add device tree support and binding information Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:44 ` [PATCH 11/12] USB: ehci-omap: Try to get PHY even if not in PHY mode Roger Quadros
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

Allows the OMAP EHCI controller to be specified via device tree.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 .../devicetree/bindings/usb/ehci-omap.txt          |   32 +++++++++++++++++
 drivers/usb/host/ehci-omap.c                       |   37 +++++++++++++++++++-
 2 files changed, 68 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-omap.txt

diff --git a/Documentation/devicetree/bindings/usb/ehci-omap.txt b/Documentation/devicetree/bindings/usb/ehci-omap.txt
new file mode 100644
index 0000000..485a9a1
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ehci-omap.txt
@@ -0,0 +1,32 @@
+OMAP HS USB EHCI controller
+
+This device is usually the child of the omap-usb-host
+Documentation/devicetree/bindings/mfd/omap-usb-host.txt
+
+Required properties:
+
+- compatible: should be "ti,ehci-omap"
+- reg: should contain one register range i.e. start and length
+- interrupts: description of the interrupt line
+
+Optional properties:
+
+- phys: list of phandles to PHY nodes.
+  This property is required if at least one of the ports are in
+  PHY mode i.e. OMAP_EHCI_PORT_MODE_PHY
+
+To specify the port mode, see
+Documentation/devicetree/bindings/mfd/omap-usb-host.txt
+
+Example for OMAP4:
+
+usbhsehci: ehci@4a064c00 {
+	compatible = "ti,ehci-omap", "usb-ehci";
+	reg = <0x4a064c00 0x400>;
+	interrupts = <0 77 0x4>;
+};
+
+&usbhsehci {
+	phys = <&hsusb1_phy 0 &hsusb3_phy>;
+};
+
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 7d05cce..45cd01e 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -48,6 +48,8 @@
 #include <linux/clk.h>
 #include <linux/usb.h>
 #include <linux/usb/hcd.h>
+#include <linux/of.h>
+#include <linux/dma-mapping.h>
 
 #include "ehci.h"
 
@@ -121,6 +123,8 @@ static const struct ehci_driver_overrides ehci_omap_overrides __initdata = {
 	.extra_priv_size = sizeof(struct omap_hcd),
 };
 
+static u64 omap_ehci_dma_mask = DMA_BIT_MASK(32);
+
 /**
  * ehci_hcd_omap_probe - initialize TI-based HCDs
  *
@@ -148,6 +152,17 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	/* For DT boot, get platform data from parent. i.e. usbhshost */
+	if (dev->of_node) {
+		pdata = dev->parent->platform_data;
+		dev->platform_data = pdata;
+	}
+
+	if (!pdata) {
+		dev_err(dev, "Missing platform data\n");
+		return -ENODEV;
+	}
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "EHCI irq failed\n");
@@ -159,6 +174,14 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
 
+	/*
+	 * Right now device-tree probed devices don't get dma_mask set.
+	 * Since shared usb code relies on it, set it here for now.
+	 * Once we have dma capability bindings this can go away.
+	 */
+	if (!pdev->dev.dma_mask)
+		pdev->dev.dma_mask = &omap_ehci_dma_mask;
+
 	hcd = usb_create_hcd(&ehci_omap_hc_driver, dev,
 			dev_name(dev));
 	if (!hcd) {
@@ -183,7 +206,10 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 			continue;
 
 		/* get the PHY device */
-		phy = devm_usb_get_phy_dev(dev, i);
+		if (dev->of_node)
+			phy = devm_usb_get_phy_by_phandle(dev, "phys", i);
+		else
+			phy = devm_usb_get_phy_dev(dev, i);
 		if (IS_ERR(phy) || !phy) {
 			ret = IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
 			dev_err(dev, "Can't get PHY device for port %d: %d\n",
@@ -273,6 +299,13 @@ static void ehci_hcd_omap_shutdown(struct platform_device *pdev)
 		hcd->driver->shutdown(hcd);
 }
 
+static const struct of_device_id omap_ehci_dt_ids[] = {
+	{ .compatible = "ti,ehci-omap" },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, omap_ehci_dt_ids);
+
 static struct platform_driver ehci_hcd_omap_driver = {
 	.probe			= ehci_hcd_omap_probe,
 	.remove			= ehci_hcd_omap_remove,
@@ -281,6 +314,7 @@ static struct platform_driver ehci_hcd_omap_driver = {
 	/*.resume		= ehci_hcd_omap_resume, */
 	.driver = {
 		.name		= hcd_name,
+		.of_match_table = of_match_ptr(omap_ehci_dt_ids),
 	}
 };
 
@@ -307,6 +341,7 @@ module_exit(ehci_omap_cleanup);
 MODULE_ALIAS("platform:ehci-omap");
 MODULE_AUTHOR("Texas Instruments, Inc.");
 MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>");
+MODULE_AUTHOR("Roger Quadros <rogerq@ti.com>");
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-- 
1.7.4.1


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

* [PATCH 11/12] USB: ehci-omap: Try to get PHY even if not in PHY mode
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (9 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 10/12] USB: ehci-omap: " Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 15:57   ` Alan Stern
  2013-03-12 10:44 ` [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode Roger Quadros
  2013-03-13 13:16 ` [PATCH 13/13] USB: ehci-omap: Get rid of omap_ehci_init() Roger Quadros
  12 siblings, 1 reply; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

Even when not in PHY mode, the USB device on the port (e.g. HUB)
might need resources like RESET which can be modelled as a PHY
device. So try to get the PHY device in any case.

Signed-off-by: Roger Quadros <rogerq@ti.com>
CC: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 45cd01e..1ba1df8 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -202,15 +202,16 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	for (i = 0 ; i < omap->nports ; i++) {
 		struct usb_phy *phy;
 
-		if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY)
-			continue;
-
 		/* get the PHY device */
 		if (dev->of_node)
 			phy = devm_usb_get_phy_by_phandle(dev, "phys", i);
 		else
 			phy = devm_usb_get_phy_dev(dev, i);
 		if (IS_ERR(phy) || !phy) {
+			/* Don't bail out if PHY is not absolutely necessary */
+			if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY)
+				continue;
+
 			ret = IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
 			dev_err(dev, "Can't get PHY device for port %d: %d\n",
 					i, ret);
-- 
1.7.4.1


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

* [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (10 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 11/12] USB: ehci-omap: Try to get PHY even if not in PHY mode Roger Quadros
@ 2013-03-12 10:44 ` Roger Quadros
  2013-03-12 10:51   ` kishon
  2013-03-12 11:09   ` [PATCH v2 " Roger Quadros
  2013-03-13 13:16 ` [PATCH 13/13] USB: ehci-omap: Get rid of omap_ehci_init() Roger Quadros
  12 siblings, 2 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:44 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq

The HSIC devices need to be kept in reset while the EHCI controller
is being initialized and only brought out of reset after the
initialization is complete, else HSIC devices will not be detected.

Signed-off-by: Roger Quadros <rogerq@ti.com>
CC: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 1ba1df8..52a2d46 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -50,6 +50,7 @@
 #include <linux/usb/hcd.h>
 #include <linux/of.h>
 #include <linux/dma-mapping.h>
+#include <linux/delay.h>
 
 #include "ehci.h"
 
@@ -90,26 +91,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
 static int omap_ehci_init(struct usb_hcd *hcd)
 {
 	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
-	struct omap_hcd	*omap = (struct omap_hcd *)ehci->priv;
-	int rc, i;
-
-	/* Hold PHYs in reset while initializing EHCI controller */
-	for (i = 0; i < omap->nports; i++) {
-		if (omap->phy[i])
-			usb_phy_shutdown(omap->phy[i]);
-	}
+	int rc;
 
 	/* we know this is the memory we want, no need to ioremap again */
 	ehci->caps = hcd->regs;
 
 	rc = ehci_setup(hcd);
 
-	/* Bring PHYs out of reset */
-	for (i = 0; i < omap->nports; i++) {
-		if (omap->phy[i])
-			usb_phy_init(omap->phy[i]);
-	}
-
 	return rc;
 }
 
@@ -219,9 +207,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		}
 
 		omap->phy[i] = phy;
-		usb_phy_init(omap->phy[i]);
-		/* bring PHY out of suspend */
-		usb_phy_set_suspend(omap->phy[i], 0);
 	}
 
 	pm_runtime_enable(dev);
@@ -245,6 +230,15 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		goto err_pm_runtime;
 	}
 
+	/* Bring PHYs out of reset */
+	for (i = 0; i < omap->nports; i++) {
+		if (!omap->phy[i])
+			continue;
+
+		usb_phy_init(omap->phy[i]);
+		/* bring PHY out of suspend */
+		usb_phy_set_suspend(omap->phy[i], 0);
+	}
 
 	return 0;
 
-- 
1.7.4.1


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

* Re: [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode
  2013-03-12 10:44 ` [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode Roger Quadros
@ 2013-03-12 10:51   ` kishon
  2013-03-12 10:53     ` Roger Quadros
  2013-03-12 11:09   ` [PATCH v2 " Roger Quadros
  1 sibling, 1 reply; 25+ messages in thread
From: kishon @ 2013-03-12 10:51 UTC (permalink / raw)
  To: Roger Quadros
  Cc: gregkh, stern, balbi, b-cousson, mark.rutland, linux-kernel,
	linux-usb, linux-omap, devicetree-discuss

Hi,

On Tuesday 12 March 2013 04:14 PM, Roger Quadros wrote:
> The HSIC devices need to be kept in reset while the EHCI controller
> is being initialized and only brought out of reset after the
> initialization is complete, else HSIC devices will not be detected.
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> CC: Alan Stern <stern@rowland.harvard.edu>
> ---
>   drivers/usb/host/ehci-omap.c |   28 +++++++++++-----------------
>   1 files changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
> index 1ba1df8..52a2d46 100644
> --- a/drivers/usb/host/ehci-omap.c
> +++ b/drivers/usb/host/ehci-omap.c
> @@ -50,6 +50,7 @@
>   #include <linux/usb/hcd.h>
>   #include <linux/of.h>
>   #include <linux/dma-mapping.h>
> +#include <linux/delay.h>

not needed here I guess.
>
>   #include "ehci.h"
>
> @@ -90,26 +91,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
>   static int omap_ehci_init(struct usb_hcd *hcd)
>   {
>   	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
> -	struct omap_hcd	*omap = (struct omap_hcd *)ehci->priv;
> -	int rc, i;
> -
> -	/* Hold PHYs in reset while initializing EHCI controller */
> -	for (i = 0; i < omap->nports; i++) {
> -		if (omap->phy[i])
> -			usb_phy_shutdown(omap->phy[i]);
> -	}
> +	int rc;
>
>   	/* we know this is the memory we want, no need to ioremap again */
>   	ehci->caps = hcd->regs;
>
>   	rc = ehci_setup(hcd);
>
> -	/* Bring PHYs out of reset */
> -	for (i = 0; i < omap->nports; i++) {
> -		if (omap->phy[i])
> -			usb_phy_init(omap->phy[i]);
> -	}
> -
>   	return rc;
>   }
>
> @@ -219,9 +207,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
>   		}
>
>   		omap->phy[i] = phy;
> -		usb_phy_init(omap->phy[i]);
> -		/* bring PHY out of suspend */
> -		usb_phy_set_suspend(omap->phy[i], 0);
>   	}
>
>   	pm_runtime_enable(dev);
> @@ -245,6 +230,15 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
>   		goto err_pm_runtime;
>   	}
>
> +	/* Bring PHYs out of reset */
> +	for (i = 0; i < omap->nports; i++) {
> +		if (!omap->phy[i])
> +			continue;
> +
> +		usb_phy_init(omap->phy[i]);
> +		/* bring PHY out of suspend */
> +		usb_phy_set_suspend(omap->phy[i], 0);
> +	}

But isn't HSIC supposed to be PHYless devices. Maybe a comment 
explaining it might be helpful.

Thanks
Kishon

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

* Re: [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode
  2013-03-12 10:51   ` kishon
@ 2013-03-12 10:53     ` Roger Quadros
  0 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 10:53 UTC (permalink / raw)
  To: kishon
  Cc: gregkh, stern, balbi, b-cousson, mark.rutland, linux-kernel,
	linux-usb, linux-omap, devicetree-discuss

On 03/12/2013 12:51 PM, kishon wrote:
> Hi,
> 
> On Tuesday 12 March 2013 04:14 PM, Roger Quadros wrote:
>> The HSIC devices need to be kept in reset while the EHCI controller
>> is being initialized and only brought out of reset after the
>> initialization is complete, else HSIC devices will not be detected.
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> CC: Alan Stern <stern@rowland.harvard.edu>
>> ---
>>   drivers/usb/host/ehci-omap.c |   28 +++++++++++-----------------
>>   1 files changed, 11 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
>> index 1ba1df8..52a2d46 100644
>> --- a/drivers/usb/host/ehci-omap.c
>> +++ b/drivers/usb/host/ehci-omap.c
>> @@ -50,6 +50,7 @@
>>   #include <linux/usb/hcd.h>
>>   #include <linux/of.h>
>>   #include <linux/dma-mapping.h>
>> +#include <linux/delay.h>
> 
> not needed here I guess.

Right. will remove.

>>
>>   #include "ehci.h"
>>
>> @@ -90,26 +91,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
>>   static int omap_ehci_init(struct usb_hcd *hcd)
>>   {
>>       struct ehci_hcd    *ehci = hcd_to_ehci(hcd);
>> -    struct omap_hcd    *omap = (struct omap_hcd *)ehci->priv;
>> -    int rc, i;
>> -
>> -    /* Hold PHYs in reset while initializing EHCI controller */
>> -    for (i = 0; i < omap->nports; i++) {
>> -        if (omap->phy[i])
>> -            usb_phy_shutdown(omap->phy[i]);
>> -    }
>> +    int rc;
>>
>>       /* we know this is the memory we want, no need to ioremap again */
>>       ehci->caps = hcd->regs;
>>
>>       rc = ehci_setup(hcd);
>>
>> -    /* Bring PHYs out of reset */
>> -    for (i = 0; i < omap->nports; i++) {
>> -        if (omap->phy[i])
>> -            usb_phy_init(omap->phy[i]);
>> -    }
>> -
>>       return rc;
>>   }
>>
>> @@ -219,9 +207,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
>>           }
>>
>>           omap->phy[i] = phy;
>> -        usb_phy_init(omap->phy[i]);
>> -        /* bring PHY out of suspend */
>> -        usb_phy_set_suspend(omap->phy[i], 0);
>>       }
>>
>>       pm_runtime_enable(dev);
>> @@ -245,6 +230,15 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
>>           goto err_pm_runtime;
>>       }
>>
>> +    /* Bring PHYs out of reset */
>> +    for (i = 0; i < omap->nports; i++) {
>> +        if (!omap->phy[i])
>> +            continue;
>> +
>> +        usb_phy_init(omap->phy[i]);
>> +        /* bring PHY out of suspend */
>> +        usb_phy_set_suspend(omap->phy[i], 0);
>> +    }
> 
> But isn't HSIC supposed to be PHYless devices. Maybe a comment explaining it might be helpful.
> 

Yes HSIC is PHYless but they do have reset line between the chips.
I'll put a comment.

cheers,
-roger

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

* [PATCH v2 12/12] USB: ehci-omap: Fix detection in HSIC mode
  2013-03-12 10:44 ` [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode Roger Quadros
  2013-03-12 10:51   ` kishon
@ 2013-03-12 11:09   ` Roger Quadros
  2013-03-12 16:07     ` Alan Stern
  2013-03-13 13:14     ` [PATCH v3 12/13] " Roger Quadros
  1 sibling, 2 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-12 11:09 UTC (permalink / raw)
  To: gregkh
  Cc: stern, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, rogerq, kishon

The HSIC devices need to be kept in reset while the EHCI controller
is being initialized and only brought out of reset after the
initialization is complete, else HSIC devices will not be detected.

Also remove outdated TODO list from header.

Signed-off-by: Roger Quadros <rogerq@ti.com>
CC: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |   38 +++++++++++++++-----------------------
 1 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 1ba1df8..dc2de47 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -29,12 +29,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
- * TODO (last updated Feb 27, 2010):
- *	- add kernel-doc
- *	- enable AUTOIDLE
- *	- add suspend/resume
- *	- add HSIC and TLL support
- *	- convert to use hwmod and runtime PM
  */
 
 #include <linux/kernel.h>
@@ -90,26 +84,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
 static int omap_ehci_init(struct usb_hcd *hcd)
 {
 	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
-	struct omap_hcd	*omap = (struct omap_hcd *)ehci->priv;
-	int rc, i;
-
-	/* Hold PHYs in reset while initializing EHCI controller */
-	for (i = 0; i < omap->nports; i++) {
-		if (omap->phy[i])
-			usb_phy_shutdown(omap->phy[i]);
-	}
+	int rc;
 
 	/* we know this is the memory we want, no need to ioremap again */
 	ehci->caps = hcd->regs;
 
 	rc = ehci_setup(hcd);
 
-	/* Bring PHYs out of reset */
-	for (i = 0; i < omap->nports; i++) {
-		if (omap->phy[i])
-			usb_phy_init(omap->phy[i]);
-	}
-
 	return rc;
 }
 
@@ -219,9 +200,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		}
 
 		omap->phy[i] = phy;
-		usb_phy_init(omap->phy[i]);
-		/* bring PHY out of suspend */
-		usb_phy_set_suspend(omap->phy[i], 0);
 	}
 
 	pm_runtime_enable(dev);
@@ -245,6 +223,20 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		goto err_pm_runtime;
 	}
 
+	/*
+	 * Bring PHYs out of reset.
+	 * Even though HSIC mode is a PHY-less mode, the reset
+	 * line exists between the chips and can be modelled
+	 * as a PHY device for reset control.
+	 */
+	for (i = 0; i < omap->nports; i++) {
+		if (!omap->phy[i])
+			continue;
+
+		usb_phy_init(omap->phy[i]);
+		/* bring PHY out of suspend */
+		usb_phy_set_suspend(omap->phy[i], 0);
+	}
 
 	return 0;
 
-- 
1.7.4.1


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

* Re: [PATCH 11/12] USB: ehci-omap: Try to get PHY even if not in PHY mode
  2013-03-12 10:44 ` [PATCH 11/12] USB: ehci-omap: Try to get PHY even if not in PHY mode Roger Quadros
@ 2013-03-12 15:57   ` Alan Stern
  2013-03-14 14:08     ` Felipe Balbi
  0 siblings, 1 reply; 25+ messages in thread
From: Alan Stern @ 2013-03-12 15:57 UTC (permalink / raw)
  To: Roger Quadros, Felipe Balbi
  Cc: gregkh, b-cousson, mark.rutland, Kernel development list,
	USB list, linux-omap, devicetree-discuss

On Tue, 12 Mar 2013, Roger Quadros wrote:

> Even when not in PHY mode, the USB device on the port (e.g. HUB)
> might need resources like RESET which can be modelled as a PHY
> device. So try to get the PHY device in any case.
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> CC: Alan Stern <stern@rowland.harvard.edu>

Acked-by: Alan Stern <stern@rowland.harvard.edu>

>  		/* get the PHY device */
>  		if (dev->of_node)
>  			phy = devm_usb_get_phy_by_phandle(dev, "phys", i);
>  		else
>  			phy = devm_usb_get_phy_dev(dev, i);
>  		if (IS_ERR(phy) || !phy) {
> +			/* Don't bail out if PHY is not absolutely necessary */
> +			if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY)
> +				continue;
> +
>  			ret = IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
>  			dev_err(dev, "Can't get PHY device for port %d: %d\n",
>  					i, ret);

Felipe, this is a strange interface.  Why do we sometimes get an 
error-pointer and sometimes get just NULL?  Why not always an 
error-pointer?

Alan Stern


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

* Re: [PATCH v2 12/12] USB: ehci-omap: Fix detection in HSIC mode
  2013-03-12 11:09   ` [PATCH v2 " Roger Quadros
@ 2013-03-12 16:07     ` Alan Stern
  2013-03-13 11:48       ` Roger Quadros
  2013-03-13 13:14     ` [PATCH v3 12/13] " Roger Quadros
  1 sibling, 1 reply; 25+ messages in thread
From: Alan Stern @ 2013-03-12 16:07 UTC (permalink / raw)
  To: Roger Quadros
  Cc: gregkh, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, kishon

On Tue, 12 Mar 2013, Roger Quadros wrote:

> The HSIC devices need to be kept in reset while the EHCI controller
> is being initialized and only brought out of reset after the
> initialization is complete, else HSIC devices will not be detected.

This is not a great description of what the patch does.  You should say
that it moves PHY initialization until after EHCI initialization is
complete, instead of initializing the PHYs first, shutting them down
again, and then initializing them a second time.

> Also remove outdated TODO list from header.
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> CC: Alan Stern <stern@rowland.harvard.edu>
> ---
>  drivers/usb/host/ehci-omap.c |   38 +++++++++++++++-----------------------
>  1 files changed, 15 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
> index 1ba1df8..dc2de47 100644
> --- a/drivers/usb/host/ehci-omap.c
> +++ b/drivers/usb/host/ehci-omap.c
> @@ -29,12 +29,6 @@
>   * along with this program; if not, write to the Free Software
>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
>   *
> - * TODO (last updated Feb 27, 2010):
> - *	- add kernel-doc
> - *	- enable AUTOIDLE
> - *	- add suspend/resume
> - *	- add HSIC and TLL support
> - *	- convert to use hwmod and runtime PM
>   */
>  
>  #include <linux/kernel.h>
> @@ -90,26 +84,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
>  static int omap_ehci_init(struct usb_hcd *hcd)
>  {
>  	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
> -	struct omap_hcd	*omap = (struct omap_hcd *)ehci->priv;
> -	int rc, i;
> -
> -	/* Hold PHYs in reset while initializing EHCI controller */
> -	for (i = 0; i < omap->nports; i++) {
> -		if (omap->phy[i])
> -			usb_phy_shutdown(omap->phy[i]);
> -	}
> +	int rc;
>  
>  	/* we know this is the memory we want, no need to ioremap again */
>  	ehci->caps = hcd->regs;
>  
>  	rc = ehci_setup(hcd);
>  
> -	/* Bring PHYs out of reset */
> -	for (i = 0; i < omap->nports; i++) {
> -		if (omap->phy[i])
> -			usb_phy_init(omap->phy[i]);
> -	}
> -
>  	return rc;
>  }

Now that there's almost nothing left of this function, you can get rid
of it completely.  Move the assignment to ehci->caps into
ehci_hcd_omap_probe() and remove the init entry in the overrides
structure.

Alan Stern


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

* Re: [PATCH v2 12/12] USB: ehci-omap: Fix detection in HSIC mode
  2013-03-12 16:07     ` Alan Stern
@ 2013-03-13 11:48       ` Roger Quadros
  0 siblings, 0 replies; 25+ messages in thread
From: Roger Quadros @ 2013-03-13 11:48 UTC (permalink / raw)
  To: Alan Stern
  Cc: gregkh, balbi, b-cousson, mark.rutland, linux-kernel, linux-usb,
	linux-omap, devicetree-discuss, kishon

On 03/12/2013 06:07 PM, Alan Stern wrote:
> On Tue, 12 Mar 2013, Roger Quadros wrote:
> 
>> The HSIC devices need to be kept in reset while the EHCI controller
>> is being initialized and only brought out of reset after the
>> initialization is complete, else HSIC devices will not be detected.
> 
> This is not a great description of what the patch does.  You should say
> that it moves PHY initialization until after EHCI initialization is
> complete, instead of initializing the PHYs first, shutting them down
> again, and then initializing them a second time.
> 

Okay will update the description.

>> Also remove outdated TODO list from header.
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> CC: Alan Stern <stern@rowland.harvard.edu>
>> ---
>>  drivers/usb/host/ehci-omap.c |   38 +++++++++++++++-----------------------
>>  1 files changed, 15 insertions(+), 23 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
>> index 1ba1df8..dc2de47 100644
>> --- a/drivers/usb/host/ehci-omap.c
>> +++ b/drivers/usb/host/ehci-omap.c
>> @@ -29,12 +29,6 @@
>>   * along with this program; if not, write to the Free Software
>>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
>>   *
>> - * TODO (last updated Feb 27, 2010):
>> - *	- add kernel-doc
>> - *	- enable AUTOIDLE
>> - *	- add suspend/resume
>> - *	- add HSIC and TLL support
>> - *	- convert to use hwmod and runtime PM
>>   */
>>  
>>  #include <linux/kernel.h>
>> @@ -90,26 +84,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
>>  static int omap_ehci_init(struct usb_hcd *hcd)
>>  {
>>  	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
>> -	struct omap_hcd	*omap = (struct omap_hcd *)ehci->priv;
>> -	int rc, i;
>> -
>> -	/* Hold PHYs in reset while initializing EHCI controller */
>> -	for (i = 0; i < omap->nports; i++) {
>> -		if (omap->phy[i])
>> -			usb_phy_shutdown(omap->phy[i]);
>> -	}
>> +	int rc;
>>  
>>  	/* we know this is the memory we want, no need to ioremap again */
>>  	ehci->caps = hcd->regs;
>>  
>>  	rc = ehci_setup(hcd);
>>  
>> -	/* Bring PHYs out of reset */
>> -	for (i = 0; i < omap->nports; i++) {
>> -		if (omap->phy[i])
>> -			usb_phy_init(omap->phy[i]);
>> -	}
>> -
>>  	return rc;
>>  }
> 
> Now that there's almost nothing left of this function, you can get rid
> of it completely.  Move the assignment to ehci->caps into
> ehci_hcd_omap_probe() and remove the init entry in the overrides
> structure.

Right. Sounds good.

cheers,
-roger

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

* [PATCH v3 12/13] USB: ehci-omap: Fix detection in HSIC mode
  2013-03-12 11:09   ` [PATCH v2 " Roger Quadros
  2013-03-12 16:07     ` Alan Stern
@ 2013-03-13 13:14     ` Roger Quadros
  2013-03-13 14:30       ` Alan Stern
  1 sibling, 1 reply; 25+ messages in thread
From: Roger Quadros @ 2013-03-13 13:14 UTC (permalink / raw)
  To: gregkh, stern; +Cc: balbi, linux-kernel, linux-usb, linux-omap, kishon, rogerq

Move PHY initialization until after EHCI initialization is
complete, instead of initializing the PHYs first, shutting
them down again, and then initializing them a second time.

This fixes HSIC device detection.

Signed-off-by: Roger Quadros <rogerq@ti.com>
CC: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |   32 +++++++++++++++-----------------
 1 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 1ba1df8..755b428 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -90,26 +90,13 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
 static int omap_ehci_init(struct usb_hcd *hcd)
 {
 	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
-	struct omap_hcd	*omap = (struct omap_hcd *)ehci->priv;
-	int rc, i;
-
-	/* Hold PHYs in reset while initializing EHCI controller */
-	for (i = 0; i < omap->nports; i++) {
-		if (omap->phy[i])
-			usb_phy_shutdown(omap->phy[i]);
-	}
+	int rc;
 
 	/* we know this is the memory we want, no need to ioremap again */
 	ehci->caps = hcd->regs;
 
 	rc = ehci_setup(hcd);
 
-	/* Bring PHYs out of reset */
-	for (i = 0; i < omap->nports; i++) {
-		if (omap->phy[i])
-			usb_phy_init(omap->phy[i]);
-	}
-
 	return rc;
 }
 
@@ -219,9 +206,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		}
 
 		omap->phy[i] = phy;
-		usb_phy_init(omap->phy[i]);
-		/* bring PHY out of suspend */
-		usb_phy_set_suspend(omap->phy[i], 0);
 	}
 
 	pm_runtime_enable(dev);
@@ -245,6 +229,20 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		goto err_pm_runtime;
 	}
 
+	/*
+	 * Bring PHYs out of reset.
+	 * Even though HSIC mode is a PHY-less mode, the reset
+	 * line exists between the chips and can be modelled
+	 * as a PHY device for reset control.
+	 */
+	for (i = 0; i < omap->nports; i++) {
+		if (!omap->phy[i])
+			continue;
+
+		usb_phy_init(omap->phy[i]);
+		/* bring PHY out of suspend */
+		usb_phy_set_suspend(omap->phy[i], 0);
+	}
 
 	return 0;
 
-- 
1.7.4.1


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

* [PATCH 13/13] USB: ehci-omap: Get rid of omap_ehci_init()
  2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
                   ` (11 preceding siblings ...)
  2013-03-12 10:44 ` [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode Roger Quadros
@ 2013-03-13 13:16 ` Roger Quadros
  2013-03-13 14:32   ` Alan Stern
  12 siblings, 1 reply; 25+ messages in thread
From: Roger Quadros @ 2013-03-13 13:16 UTC (permalink / raw)
  To: gregkh, stern; +Cc: balbi, linux-kernel, linux-usb, linux-omap, kishon, rogerq

As it does almost nothing, get rid of omap_ehci_init()
and move the ehci->caps initialization part into probe().

Also remove the outdated TODO list from header.

Signed-off-by: Roger Quadros <rogerq@ti.com>
CC: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ehci-omap.c |   21 +--------------------
 1 files changed, 1 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 755b428..5de3e43 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -29,12 +29,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
- * TODO (last updated Feb 27, 2010):
- *	- add kernel-doc
- *	- enable AUTOIDLE
- *	- add suspend/resume
- *	- add HSIC and TLL support
- *	- convert to use hwmod and runtime PM
  */
 
 #include <linux/kernel.h>
@@ -87,26 +81,12 @@ static inline u32 ehci_read(void __iomem *base, u32 reg)
 	return __raw_readl(base + reg);
 }
 
-static int omap_ehci_init(struct usb_hcd *hcd)
-{
-	struct ehci_hcd	*ehci = hcd_to_ehci(hcd);
-	int rc;
-
-	/* we know this is the memory we want, no need to ioremap again */
-	ehci->caps = hcd->regs;
-
-	rc = ehci_setup(hcd);
-
-	return rc;
-}
-
 /* 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,
 	.extra_priv_size = sizeof(struct omap_hcd),
 };
 
@@ -179,6 +159,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 	hcd->regs = regs;
+	hcd_to_ehci(hcd)->caps = regs;
 
 	omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
 	omap->nports = pdata->nports;
-- 
1.7.4.1


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

* Re: [PATCH v3 12/13] USB: ehci-omap: Fix detection in HSIC mode
  2013-03-13 13:14     ` [PATCH v3 12/13] " Roger Quadros
@ 2013-03-13 14:30       ` Alan Stern
  0 siblings, 0 replies; 25+ messages in thread
From: Alan Stern @ 2013-03-13 14:30 UTC (permalink / raw)
  To: Roger Quadros; +Cc: gregkh, balbi, linux-kernel, linux-usb, linux-omap, kishon

On Wed, 13 Mar 2013, Roger Quadros wrote:

> Move PHY initialization until after EHCI initialization is
> complete, instead of initializing the PHYs first, shutting
> them down again, and then initializing them a second time.
> 
> This fixes HSIC device detection.
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> CC: Alan Stern <stern@rowland.harvard.edu>

Acked-by: Alan Stern <stern@rowland.harvard.edu>


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

* Re: [PATCH 13/13] USB: ehci-omap: Get rid of omap_ehci_init()
  2013-03-13 13:16 ` [PATCH 13/13] USB: ehci-omap: Get rid of omap_ehci_init() Roger Quadros
@ 2013-03-13 14:32   ` Alan Stern
  0 siblings, 0 replies; 25+ messages in thread
From: Alan Stern @ 2013-03-13 14:32 UTC (permalink / raw)
  To: Roger Quadros; +Cc: gregkh, balbi, linux-kernel, linux-usb, linux-omap, kishon

On Wed, 13 Mar 2013, Roger Quadros wrote:

> As it does almost nothing, get rid of omap_ehci_init()
> and move the ehci->caps initialization part into probe().
> 
> Also remove the outdated TODO list from header.
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> CC: Alan Stern <stern@rowland.harvard.edu>

Acked-by: Alan Stern <stern@rowland.harvard.edu>


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

* Re: [PATCH 11/12] USB: ehci-omap: Try to get PHY even if not in PHY mode
  2013-03-12 15:57   ` Alan Stern
@ 2013-03-14 14:08     ` Felipe Balbi
  2013-03-14 15:08       ` Alan Stern
  0 siblings, 1 reply; 25+ messages in thread
From: Felipe Balbi @ 2013-03-14 14:08 UTC (permalink / raw)
  To: Alan Stern
  Cc: Roger Quadros, Felipe Balbi, gregkh, b-cousson, mark.rutland,
	Kernel development list, USB list, linux-omap,
	devicetree-discuss

[-- Attachment #1: Type: text/plain, Size: 1308 bytes --]

On Tue, Mar 12, 2013 at 11:57:56AM -0400, Alan Stern wrote:
> On Tue, 12 Mar 2013, Roger Quadros wrote:
> 
> > Even when not in PHY mode, the USB device on the port (e.g. HUB)
> > might need resources like RESET which can be modelled as a PHY
> > device. So try to get the PHY device in any case.
> > 
> > Signed-off-by: Roger Quadros <rogerq@ti.com>
> > CC: Alan Stern <stern@rowland.harvard.edu>
> 
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
> 
> >  		/* get the PHY device */
> >  		if (dev->of_node)
> >  			phy = devm_usb_get_phy_by_phandle(dev, "phys", i);
> >  		else
> >  			phy = devm_usb_get_phy_dev(dev, i);
> >  		if (IS_ERR(phy) || !phy) {
> > +			/* Don't bail out if PHY is not absolutely necessary */
> > +			if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY)
> > +				continue;
> > +
> >  			ret = IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
> >  			dev_err(dev, "Can't get PHY device for port %d: %d\n",
> >  					i, ret);
> 
> Felipe, this is a strange interface.  Why do we sometimes get an 
> error-pointer and sometimes get just NULL?  Why not always an 
> error-pointer?

looks like we get NULL when PHY layer is disabled. Sounds like an
oversight to me. Do you want to send a patch, or do I cook one and put
yourself as Reported-by ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 11/12] USB: ehci-omap: Try to get PHY even if not in PHY mode
  2013-03-14 14:08     ` Felipe Balbi
@ 2013-03-14 15:08       ` Alan Stern
  0 siblings, 0 replies; 25+ messages in thread
From: Alan Stern @ 2013-03-14 15:08 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Roger Quadros, gregkh, b-cousson, mark.rutland,
	Kernel development list, USB list, linux-omap,
	devicetree-discuss

On Thu, 14 Mar 2013, Felipe Balbi wrote:

> > >  		if (IS_ERR(phy) || !phy) {
> > > +			/* Don't bail out if PHY is not absolutely necessary */
> > > +			if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY)
> > > +				continue;
> > > +
> > >  			ret = IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
> > >  			dev_err(dev, "Can't get PHY device for port %d: %d\n",
> > >  					i, ret);
> > 
> > Felipe, this is a strange interface.  Why do we sometimes get an 
> > error-pointer and sometimes get just NULL?  Why not always an 
> > error-pointer?
> 
> looks like we get NULL when PHY layer is disabled. Sounds like an
> oversight to me. Do you want to send a patch, or do I cook one and put
> yourself as Reported-by ?

You're more familiar with that code.  "Reported-by" is good enough for 
me.  :-)

Alan Stern


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

end of thread, other threads:[~2013-03-14 15:08 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-12 10:44 [PATCH 00/12] USB: ehci-omap: Device tree support for 3.10 Roger Quadros
2013-03-12 10:44 ` [PATCH 01/12] USB: EHCI: split ehci-omap out to a separate driver Roger Quadros
2013-03-12 10:44 ` [PATCH 02/12] USB: ehci-omap: Use devm_ioremap_resource() Roger Quadros
2013-03-12 10:44 ` [PATCH 03/12] USB: ehci-omap: Use PHY APIs to get the PHY device and put it out of suspend Roger Quadros
2013-03-12 10:44 ` [PATCH 04/12] USB: ehci-omap: Remove PHY reset handling code Roger Quadros
2013-03-12 10:44 ` [PATCH 05/12] USB: ehci-omap: Remove PHY regulator " Roger Quadros
2013-03-12 10:44 ` [PATCH 06/12] USB: ehci-omap: Select NOP USB transceiver driver Roger Quadros
2013-03-12 10:44 ` [PATCH 07/12] USB: ehci-omap: Get platform resources by index rather than by name Roger Quadros
2013-03-12 10:44 ` [PATCH 08/12] USB: ohci-omap3: " Roger Quadros
2013-03-12 10:44 ` [PATCH 09/12] USB: ohci-omap3: Add device tree support and binding information Roger Quadros
2013-03-12 10:44 ` [PATCH 10/12] USB: ehci-omap: " Roger Quadros
2013-03-12 10:44 ` [PATCH 11/12] USB: ehci-omap: Try to get PHY even if not in PHY mode Roger Quadros
2013-03-12 15:57   ` Alan Stern
2013-03-14 14:08     ` Felipe Balbi
2013-03-14 15:08       ` Alan Stern
2013-03-12 10:44 ` [PATCH 12/12] USB: ehci-omap: Fix detection in HSIC mode Roger Quadros
2013-03-12 10:51   ` kishon
2013-03-12 10:53     ` Roger Quadros
2013-03-12 11:09   ` [PATCH v2 " Roger Quadros
2013-03-12 16:07     ` Alan Stern
2013-03-13 11:48       ` Roger Quadros
2013-03-13 13:14     ` [PATCH v3 12/13] " Roger Quadros
2013-03-13 14:30       ` Alan Stern
2013-03-13 13:16 ` [PATCH 13/13] USB: ehci-omap: Get rid of omap_ehci_init() Roger Quadros
2013-03-13 14:32   ` Alan Stern

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