Skip to contentSkip to conversation

ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

PATCH Superseded Russ Dill 6 participants 8 messages Jun 14, 2012 – Jul 2, 2012

Subsystems (5)
lore
Share & tools
lore

Russ Dill

author
#0 lore raw

PATCH v3 1/1 ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

From: Russ Dill <[email protected]>

'ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset issue' (1fcb57d0) fixes an issue where the ULPI PHYs were not held in reset while initializing the EHCI controller. However, it also changes behavior in omap-usb-host.c omap_usbhs_init by releasing reset while the configuration in that function was done.

This change caused a regression on BB-xM where USB would not function if 'usb start' had been run from u-boot before booting. A change was made to release reset a little bit earlier which fixed the issue on BB-xM and did not cause any regressions on 3430 sdp, the board for which the fix was originally made.

This new fix, 'USB: EHCI: OMAP: Finish ehci omap phy reset cycle before adding hcd.', (3aa2ae74) caused a regression on OMAP5.

The original fix to hold the EHCI controller in reset during initialization was correct, however it appears that changing omap_usbhs_init to not hold the PHYs in reset during it's configuration was incorrect. This patch first reverts both fixes, and then changes ehci_hcd_omap_probe in ehci-omap.c to hold the PHYs in reset as the original patch had done. It also is sure to incorporate the _cansleep change that has been made in the meantime.

I've tested this on Beagleboard xM, I'd really like to get an ack from the 3430 sdp and OMAP5 guys before getting this merged.

v3 - Brown paper bag its too early in the morning actually run
git commit amend fix
v2 - Put cansleep gpiolib call outside of spinlock

---
 drivers/mfd/omap-usb-host.c  |   48 +++++++++++++++++++++++++++++++++++++++++-
 drivers/usb/host/ehci-omap.c |   18 +++++++---------
 2 files changed, 55 insertions(+), 11 deletions(-)
drivers/mfd/omap-usb-host.c +47 -1
index 7e96bb2..41088ec 100644
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
+#include <linux/gpio.h>
 #include <plat/cpu.h>
 #include <plat/usb.h>
 #include <linux/pm_runtime.h>
@@ -500,8 +501,21 @@ static void omap_usbhs_init(struct device *dev)
 	dev_dbg(dev, "starting TI HSUSB Controller\n");
 
 	pm_runtime_get_sync(dev);
-	spin_lock_irqsave(&omap->lock, flags);
 
+	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],
+					 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],
+					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
+
+		/* Hold the PHY in RESET for enough time till DIR is high */
+		udelay(10);
+	}
+
+	spin_lock_irqsave(&omap->lock, flags);
 	omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
 	dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
 
@@ -581,9 +595,39 @@ static void omap_usbhs_init(struct device *dev)
 	}
 
 	spin_unlock_irqrestore(&omap->lock, flags);
+
+	if (pdata->ehci_data->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]))
+			gpio_set_value_cansleep
+				(pdata->ehci_data->reset_gpio_port[0], 1);
+
+		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+			gpio_set_value_cansleep
+				(pdata->ehci_data->reset_gpio_port[1], 1);
+	}
+
 	pm_runtime_put_sync(dev);
 }
 
+static void omap_usbhs_deinit(struct device *dev)
+{
+	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
+	struct usbhs_omap_platform_data	*pdata = &omap->platdata;
+
+	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 (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+			gpio_free(pdata->ehci_data->reset_gpio_port[1]);
+	}
+}
+
 
 /**
  * usbhs_omap_probe - initialize TI-based HCDs
@@ -767,6 +811,7 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev)
 	goto end_probe;
 
 err_alloc:
+	omap_usbhs_deinit(&pdev->dev);
 	iounmap(omap->tll_base);
 
 err_tll:
@@ -818,6 +863,7 @@ static int __devexit usbhs_omap_remove(struct platform_device *pdev)
 {
 	struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
 
+	omap_usbhs_deinit(&pdev->dev);
 	iounmap(omap->tll_base);
 	iounmap(omap->uhh_base);
 	clk_put(omap->init_60m_fclk);
drivers/usb/host/ehci-omap.c +8 -10
index a44294d..d0815b6 100644
@@ -192,14 +192,13 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* Hold PHYs in reset while initializing EHCI controller */
 	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");
+			gpio_set_value_cansleep(pdata->reset_gpio_port[0], 0);
 
 		if (gpio_is_valid(pdata->reset_gpio_port[1]))
-			gpio_request_one(pdata->reset_gpio_port[1],
-					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
+			gpio_set_value_cansleep(pdata->reset_gpio_port[1], 0);
 
 		/* Hold the PHY in RESET for enough time till DIR is high */
 		udelay(10);
@@ -241,6 +240,11 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params);
 
 	ehci_reset(omap_ehci);
+	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
+	if (ret) {
+		dev_err(dev, "failed to add hcd with err %d\n", ret);
+		goto err_add_hcd;
+	}
 
 	if (pdata->phy_reset) {
 		/* Hold the PHY in RESET for enough time till
@@ -255,12 +259,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 			gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);
 	}
 
-	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
-	if (ret) {
-		dev_err(dev, "failed to add hcd with err %d\n", ret);
-		goto err_add_hcd;
-	}
-
 	/* root ports should always stay powered */
 	ehci_port_power(omap_ehci, 1);
 
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v3 1/1 ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

'Acked-by: mantesh at ti.com'
'Tested-by: mantesh at ti.com'

Regards,
Mantesh
-----Original Message-----
From: Russ Dill [mailto:russ.dill at gmail.com] On Behalf Of Dill, Russ
Sent: Thursday, June 14, 2012 11:24 AM
To: linux-omap at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Cc: Balbi, Felipe; Munegowda, Keshava; Partha Basak; Igor Grinberg; Samuel Ortiz; Sarashetti, Mantesh; Setty, Sapna; Russ Dill
Subject: [PATCH v3] ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

From: Russ Dill <[email protected]>

'ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset issue' (1fcb57d0) fixes an issue where the ULPI PHYs were not held in reset while initializing the EHCI controller. However, it also changes behavior in omap-usb-host.c omap_usbhs_init by releasing reset while the configuration in that function was done.

This change caused a regression on BB-xM where USB would not function if 'usb start' had been run from u-boot before booting. A change was made to release reset a little bit earlier which fixed the issue on BB-xM and did not cause any regressions on 3430 sdp, the board for which the fix was originally made.

This new fix, 'USB: EHCI: OMAP: Finish ehci omap phy reset cycle before adding hcd.', (3aa2ae74) caused a regression on OMAP5.

The original fix to hold the EHCI controller in reset during initialization was correct, however it appears that changing omap_usbhs_init to not hold the PHYs in reset during it's configuration was incorrect. This patch first reverts both fixes, and then changes ehci_hcd_omap_probe in ehci-omap.c to hold the PHYs in reset as the original patch had done. It also is sure to incorporate the _cansleep change that has been made in the meantime.

I've tested this on Beagleboard xM, I'd really like to get an ack from the 3430 sdp and OMAP5 guys before getting this merged.

v3 - Brown paper bag its too early in the morning actually run
git commit amend fix
v2 - Put cansleep gpiolib call outside of spinlock

---
 drivers/mfd/omap-usb-host.c  |   48 +++++++++++++++++++++++++++++++++++++++++-
 drivers/usb/host/ehci-omap.c |   18 +++++++---------
 2 files changed, 55 insertions(+), 11 deletions(-)
drivers/mfd/omap-usb-host.c +47 -1
index 7e96bb2..41088ec 100644
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/spinlock.h>
+#include <linux/gpio.h>
 #include <plat/cpu.h>
 #include <plat/usb.h>
 #include <linux/pm_runtime.h>
@@ -500,8 +501,21 @@ static void omap_usbhs_init(struct device *dev)
 	dev_dbg(dev, "starting TI HSUSB Controller\n");
 
 	pm_runtime_get_sync(dev);
-	spin_lock_irqsave(&omap->lock, flags);
 
+	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],
+					 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],
+					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
+
+		/* Hold the PHY in RESET for enough time till DIR is high */
+		udelay(10);
+	}
+
+	spin_lock_irqsave(&omap->lock, flags);
 	omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
 	dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
 
@@ -581,9 +595,39 @@ static void omap_usbhs_init(struct device *dev)
 	}
 
 	spin_unlock_irqrestore(&omap->lock, flags);
+
+	if (pdata->ehci_data->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]))
+			gpio_set_value_cansleep
+				(pdata->ehci_data->reset_gpio_port[0], 1);
+
+		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+			gpio_set_value_cansleep
+				(pdata->ehci_data->reset_gpio_port[1], 1);
+	}
+
 	pm_runtime_put_sync(dev);
 }
 
+static void omap_usbhs_deinit(struct device *dev)
+{
+	struct usbhs_hcd_omap		*omap = dev_get_drvdata(dev);
+	struct usbhs_omap_platform_data	*pdata = &omap->platdata;
+
+	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 (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+			gpio_free(pdata->ehci_data->reset_gpio_port[1]);
+	}
+}
+
 
 /**
  * usbhs_omap_probe - initialize TI-based HCDs
@@ -767,6 +811,7 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev)
 	goto end_probe;
 
 err_alloc:
+	omap_usbhs_deinit(&pdev->dev);
 	iounmap(omap->tll_base);
 
 err_tll:
@@ -818,6 +863,7 @@ static int __devexit usbhs_omap_remove(struct platform_device *pdev)
 {
 	struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
 
+	omap_usbhs_deinit(&pdev->dev);
 	iounmap(omap->tll_base);
 	iounmap(omap->uhh_base);
 	clk_put(omap->init_60m_fclk);
drivers/usb/host/ehci-omap.c +8 -10
index a44294d..d0815b6 100644
@@ -192,14 +192,13 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* Hold PHYs in reset while initializing EHCI controller */
 	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");
+			gpio_set_value_cansleep(pdata->reset_gpio_port[0], 0);
 
 		if (gpio_is_valid(pdata->reset_gpio_port[1]))
-			gpio_request_one(pdata->reset_gpio_port[1],
-					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
+			gpio_set_value_cansleep(pdata->reset_gpio_port[1], 0);
 
 		/* Hold the PHY in RESET for enough time till DIR is high */
 		udelay(10);
@@ -241,6 +240,11 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params);
 
 	ehci_reset(omap_ehci);
+	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
+	if (ret) {
+		dev_err(dev, "failed to add hcd with err %d\n", ret);
+		goto err_add_hcd;
+	}
 
 	if (pdata->phy_reset) {
 		/* Hold the PHY in RESET for enough time till
@@ -255,12 +259,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 			gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);
 	}
 
-	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
-	if (ret) {
-		dev_err(dev, "failed to add hcd with err %d\n", ret);
-		goto err_add_hcd;
-	}
-
 	/* root ports should always stay powered */
 	ehci_port_power(omap_ehci, 1);
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v3 1/1 ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

Quoted 188 lines · Mantesh

'Acked-by: mantesh at ti.com'
'Tested-by: mantesh at ti.com'

Regards,
Mantesh
-----Original Message-----
From: Russ Dill [mailto:russ.dill at gmail.com] On Behalf Of Dill, Russ
Sent: Thursday, June 14, 2012 11:24 AM
To: linux-omap at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Cc: Balbi, Felipe; Munegowda, Keshava; Partha Basak; Igor Grinberg; Samuel Ortiz; Sarashetti, Mantesh; Setty, Sapna; Russ Dill
Subject: [PATCH v3] ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

From: Russ Dill <[email protected]>

'ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset issue' (1fcb57d0) fixes an issue where the ULPI PHYs were not held in reset while initializing the EHCI controller. However, it also changes behavior in omap-usb-host.c omap_usbhs_init by releasing reset while the configuration in that function was done.

This change caused a regression on BB-xM where USB would not function if 'usb start' had been run from u-boot before booting. A change was made to release reset a little bit earlier which fixed the issue on BB-xM and did not cause any regressions on 3430 sdp, the board for which the fix was originally made.

This new fix, 'USB: EHCI: OMAP: Finish ehci omap phy reset cycle before adding hcd.', (3aa2ae74) caused a regression on OMAP5.

The original fix to hold the EHCI controller in reset during initialization was correct, however it appears that changing omap_usbhs_init to not hold the PHYs in reset during it's configuration was incorrect. This patch first reverts both fixes, and then changes ehci_hcd_omap_probe in ehci-omap.c to hold the PHYs in reset as the original patch had done. It also is sure to incorporate the _cansleep change that has been made in the meantime.

I've tested this on Beagleboard xM, I'd really like to get an ack from the 3430 sdp and OMAP5 guys before getting this merged.

v3 - Brown paper bag its too early in the morning actually run ? ? git commit amend fix
v2 - Put cansleep gpiolib call outside of spinlock

---
?drivers/mfd/omap-usb-host.c ?| ? 48 +++++++++++++++++++++++++++++++++++++++++- ?drivers/usb/host/ehci-omap.c | ? 18 +++++++---------
?2 files changed, 55 insertions(+), 11 deletions(-)

drivers/mfd/omap-usb-host.c +0 -0
index 7e96bb2..41088ec 100644
@@ -25,6 +25,7 @@

?#include <linux/clk.h>
?#include <linux/dma-mapping.h>
?#include <linux/spinlock.h>
+#include <linux/gpio.h>
?#include <plat/cpu.h>
?#include <plat/usb.h>
?#include <linux/pm_runtime.h>

drivers/mfd/omap-usb-host.c +44 -1
@@ -500,8 +501,21 @@ static void omap_usbhs_init(struct device *dev)
 ? ? ? ?dev_dbg(dev, "starting TI HSUSB Controller\n");
 
 ? ? ? ?pm_runtime_get_sync(dev);
- ? ? ? spin_lock_irqsave(&omap->lock, flags);
 
+ ? ? ? 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],
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?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],
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
+
+ ? ? ? ? ? ? ? /* Hold the PHY in RESET for enough time till DIR is high */
+ ? ? ? ? ? ? ? udelay(10);
+ ? ? ? }
+
+ ? ? ? spin_lock_irqsave(&omap->lock, flags);
 ? ? ? ?omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
 ? ? ? ?dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
 
@@ -581,9 +595,39 @@ static void omap_usbhs_init(struct device *dev)
 ? ? ? ?}
 
 ? ? ? ?spin_unlock_irqrestore(&omap->lock, flags);
+
+ ? ? ? if (pdata->ehci_data->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]))
+ ? ? ? ? ? ? ? ? ? ? ? gpio_set_value_cansleep
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (pdata->ehci_data->reset_gpio_port[0], 1);
+
+ ? ? ? ? ? ? ? if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+ ? ? ? ? ? ? ? ? ? ? ? gpio_set_value_cansleep
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (pdata->ehci_data->reset_gpio_port[1], 1);
+ ? ? ? }
+
 ? ? ? ?pm_runtime_put_sync(dev);
 ?}
 
+static void omap_usbhs_deinit(struct device *dev)
+{
+ ? ? ? struct usbhs_hcd_omap ? ? ? ? ? *omap = dev_get_drvdata(dev);
+ ? ? ? struct usbhs_omap_platform_data *pdata = &omap->platdata;
+
+ ? ? ? 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 (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+ ? ? ? ? ? ? ? ? ? ? ? gpio_free(pdata->ehci_data->reset_gpio_port[1]);
+ ? ? ? }
+}
+
 

?/**
?* usbhs_omap_probe - initialize TI-based HCDs

drivers/mfd/omap-usb-host.c +0 -0
@@ -767,6 +811,7 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev)
 ? ? ? ?goto end_probe;
 

?err_alloc:
+ ? ? ? omap_usbhs_deinit(&pdev->dev);
? ? ? ?iounmap(omap->tll_base);

?err_tll:

drivers/mfd/omap-usb-host.c +1 -0
@@ -818,6 +863,7 @@ static int __devexit usbhs_omap_remove(struct platform_device *pdev)
 ?{
 ? ? ? ?struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
 
+ ? ? ? omap_usbhs_deinit(&pdev->dev);
 ? ? ? ?iounmap(omap->tll_base);
 ? ? ? ?iounmap(omap->uhh_base);
 ? ? ? ?clk_put(omap->init_60m_fclk);
drivers/usb/host/ehci-omap.c +3 -4
index a44294d..d0815b6 100644
@@ -192,14 +192,13 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 ? ? ? ? ? ? ? ?}
 ? ? ? ?}
 
+ ? ? ? /* Hold PHYs in reset while initializing EHCI controller */
 ? ? ? ?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");
+ ? ? ? ? ? ? ? ? ? ? ? gpio_set_value_cansleep(pdata->reset_gpio_port[0], 0);
 
 ? ? ? ? ? ? ? ?if (gpio_is_valid(pdata->reset_gpio_port[1]))
- ? ? ? ? ? ? ? ? ? ? ? gpio_request_one(pdata->reset_gpio_port[1],
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
+ ? ? ? ? ? ? ? ? ? ? ? gpio_set_value_cansleep(pdata->reset_gpio_port[1], 0);
 

? ? ? ? ? ? ? ?/* Hold the PHY in RESET for enough time till DIR is high */ ? ? ? ? ? ? ? ?udelay(10);

drivers/usb/host/ehci-omap.c +5 -0
@@ -241,6 +240,11 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 ? ? ? ?omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params);
 
 ? ? ? ?ehci_reset(omap_ehci);
+ ? ? ? ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
+ ? ? ? if (ret) {
+ ? ? ? ? ? ? ? dev_err(dev, "failed to add hcd with err %d\n", ret);
+ ? ? ? ? ? ? ? goto err_add_hcd;
+ ? ? ? }
 
 ? ? ? ?if (pdata->phy_reset) {

? ? ? ? ? ? ? ?/* Hold the PHY in RESET for enough time till

drivers/usb/host/ehci-omap.c +0 -6
@@ -255,12 +259,6 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 ? ? ? ? ? ? ? ? ? ? ? ?gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);
 ? ? ? ?}
 
- ? ? ? ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
- ? ? ? if (ret) {
- ? ? ? ? ? ? ? dev_err(dev, "failed to add hcd with err %d\n", ret);
- ? ? ? ? ? ? ? goto err_add_hcd;
- ? ? ? }
-

? ? ? ?/* root ports should always stay powered */ ? ? ? ?ehci_port_power(omap_ehci, 1);

Quoted 3 lines

--
1.7.10.4

Hi Samuel

I have validated this patch v3 in omap3 beagle XM .

regards
keshava

#3 lore raw

PATCH v3 1/1 ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

Thanks Keshava.

Regards
Sunil Matange

-----Original Message-----
From: Munegowda, Keshava [mailto:keshava_mgowda at ti.com]
Sent: Monday, June 18, 2012 1:59 PM
To: Samuel Ortiz
Cc: Dill, Russ; linux-omap at vger.kernel.org; linux-arm-kernel at lists.infradead.org; Balbi, Felipe; Partha Basak; Igor Grinberg; Setty, Sapna; Russ Dill; Mantesh Sarashetti; Sunil Matange; Nishant Kamat; Linux USB Devel
Subject: Re: [PATCH v3] ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

Quoted 10 lines · Mantesh

'Acked-by: mantesh at ti.com'
'Tested-by: mantesh at ti.com'

Regards,
Mantesh
-----Original Message-----
From: Russ Dill [mailto:russ.dill at gmail.com] On Behalf Of Dill, Russ
Sent: Thursday, June 14, 2012 11:24 AM
To: linux-omap at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Cc: Balbi, Felipe; Munegowda, Keshava; Partha Basak; Igor Grinberg;

Samuel Ortiz; Sarashetti, Mantesh; Setty, Sapna; Russ Dill

Quoted 1 line

Subject: [PATCH v3] ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix

issues.

Quoted 29 lines

From: Russ Dill <[email protected]>

'ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset issue' (1fcb57d0) fixes an issue where the ULPI PHYs were not held in reset while initializing the EHCI controller. However, it also changes behavior in omap-usb-host.c omap_usbhs_init by releasing reset while the configuration in that function was done.

This change caused a regression on BB-xM where USB would not function if 'usb start' had been run from u-boot before booting. A change was made to release reset a little bit earlier which fixed the issue on BB-xM and did not cause any regressions on 3430 sdp, the board for which the fix was originally made.

This new fix, 'USB: EHCI: OMAP: Finish ehci omap phy reset cycle before adding hcd.', (3aa2ae74) caused a regression on OMAP5.

The original fix to hold the EHCI controller in reset during initialization was correct, however it appears that changing omap_usbhs_init to not hold the PHYs in reset during it's configuration was incorrect. This patch first reverts both fixes, and then changes ehci_hcd_omap_probe in ehci-omap.c to hold the PHYs in reset as the original patch had done. It also is sure to incorporate the _cansleep change that has been made in the meantime.

I've tested this on Beagleboard xM, I'd really like to get an ack from the 3430 sdp and OMAP5 guys before getting this merged.

Quoted 7 lines

v3 - Brown paper bag its too early in the morning actually run ? ? git commit amend fix
v2 - Put cansleep gpiolib call outside of spinlock

---
?drivers/mfd/omap-usb-host.c ?| ? 48

+++++++++++++++++++++++++++++++++++++++++-

Quoted 16 lines

?drivers/usb/host/ehci-omap.c | ? 18 +++++++--------- ?2 files changed, 55 insertions(+), 11 deletions(-)

drivers/mfd/omap-usb-host.c +0 -0
index 7e96bb2..41088ec 100644
@@ -25,6 +25,7 @@

?#include <linux/clk.h>
?#include <linux/dma-mapping.h>
?#include <linux/spinlock.h>
+#include <linux/gpio.h>
?#include <plat/cpu.h>
?#include <plat/usb.h>
?#include <linux/pm_runtime.h>

drivers/mfd/omap-usb-host.c static void omap_usbhs_init(struct device *dev) · line 507

Quoted 8 lines
drivers/mfd/omap-usb-host.c +3 -1
@@ -500,8 +501,21 @@ static void omap_usbhs_init(struct device *dev)
 ? ? ? ?dev_dbg(dev, "starting TI HSUSB Controller\n");
 
 ? ? ? ?pm_runtime_get_sync(dev);
- ? ? ? spin_lock_irqsave(&omap->lock, flags);
 
+ ? ? ? 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],

drivers/mfd/omap-usb-host.c static void omap_usbhs_init(struct device *dev) · line 508

Quoted 1 line
drivers/mfd/omap-usb-host.c +1 -0
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GPIOF_OUT_INIT_LOW, "USB1 PHY

reset");

drivers/mfd/omap-usb-host.c static void omap_usbhs_init(struct device *dev) · line 513

Quoted 3 lines
drivers/mfd/omap-usb-host.c +3 -0
+
+ ? ? ? ? ? ? ? if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+

gpio_request_one(pdata->ehci_data->reset_gpio_port[1],

drivers/mfd/omap-usb-host.c static void omap_usbhs_init(struct device *dev) · line 512

Quoted 1 line
drivers/mfd/omap-usb-host.c +1 -0
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GPIOF_OUT_INIT_LOW, "USB2 PHY

reset");

drivers/mfd/omap-usb-host.c static void omap_usbhs_init(struct device *dev) · line 514

Quoted 2 lines
drivers/mfd/omap-usb-host.c +2 -0
+
+ ? ? ? ? ? ? ? /* Hold the PHY in RESET for enough time till DIR is

high */

Quoted 11 lines
drivers/mfd/omap-usb-host.c +4 -0
+ ? ? ? ? ? ? ? udelay(10);
+ ? ? ? }
+
+ ? ? ? spin_lock_irqsave(&omap->lock, flags);
 ? ? ? ?omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
 ? ? ? ?dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
 
@@ -581,9 +595,39 @@ static void omap_usbhs_init(struct device *dev)
 ? ? ? ?}
 
 ? ? ? ?spin_unlock_irqrestore(&omap->lock, flags);

drivers/mfd/omap-usb-host.c static void omap_usbhs_init(struct device *dev) · line 607

Quoted 10 lines
drivers/mfd/omap-usb-host.c +10 -0
+
+ ? ? ? if (pdata->ehci_data->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]))
+ ? ? ? ? ? ? ? ? ? ? ? gpio_set_value_cansleep
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (pdata->ehci_data->reset_gpio_port[0],

1);

drivers/mfd/omap-usb-host.c static void omap_usbhs_init(struct device *dev) · line 611

Quoted 4 lines
drivers/mfd/omap-usb-host.c +4 -0
+
+ ? ? ? ? ? ? ? if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+ ? ? ? ? ? ? ? ? ? ? ? gpio_set_value_cansleep
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (pdata->ehci_data->reset_gpio_port[1],

1);

drivers/mfd/omap-usb-host.c static int __devinit usbhs_omap_probe(struct

Quoted 23 lines
drivers/mfd/omap-usb-host.c +16 -0
+ ? ? ? }
+
 ? ? ? ?pm_runtime_put_sync(dev);
 ?}
 
+static void omap_usbhs_deinit(struct device *dev)
+{
+ ? ? ? struct usbhs_hcd_omap ? ? ? ? ? *omap = dev_get_drvdata(dev);
+ ? ? ? struct usbhs_omap_platform_data *pdata = &omap->platdata;
+
+ ? ? ? 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 (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+ ? ? ? ? ? ? ? ? ? ? ? gpio_free(pdata->ehci_data->reset_gpio_port[1]);
+ ? ? ? }
+}
+
 

?/**
?* usbhs_omap_probe - initialize TI-based HCDs

drivers/mfd/omap-usb-host.c +0 -0
@@ -767,6 +811,7 @@ static int __devinit usbhs_omap_probe(struct

platform_device *pdev)

drivers/mfd/omap-usb-host.c static int __devexit usbhs_omap_remove(struct

Quoted 8 lines
drivers/mfd/omap-usb-host.c +0 -0
 ? ? ? ?goto end_probe;
 

?err_alloc:
+ ? ? ? omap_usbhs_deinit(&pdev->dev);
? ? ? ?iounmap(omap->tll_base);

?err_tll:

drivers/mfd/omap-usb-host.c +0 -0
@@ -818,6 +863,7 @@ static int __devexit usbhs_omap_remove(struct

platform_device *pdev)

drivers/usb/host/ehci-omap.c static int ehci_hcd_omap_probe(struct

Quoted 12 lines
drivers/mfd/omap-usb-host.c +1 -0
 ?{
 ? ? ? ?struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
 
+ ? ? ? omap_usbhs_deinit(&pdev->dev);
 ? ? ? ?iounmap(omap->tll_base);
 ? ? ? ?iounmap(omap->uhh_base);
 ? ? ? ?clk_put(omap->init_60m_fclk);
drivers/usb/host/ehci-omap.c +0 -0
index a44294d..d0815b6 100644
@@ -192,14 +192,13 @@ static int ehci_hcd_omap_probe(struct

platform_device *pdev)

drivers/usb/host/ehci-omap.c static int ehci_hcd_omap_probe(struct · line 198

Quoted 8 lines
drivers/usb/host/ehci-omap.c +1 -2
 ? ? ? ? ? ? ? ?}
 ? ? ? ?}
 
+ ? ? ? /* Hold PHYs in reset while initializing EHCI controller */
 ? ? ? ?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");

drivers/usb/host/ehci-omap.c static int ehci_hcd_omap_probe(struct · line 198

Quoted 1 line
drivers/usb/host/ehci-omap.c +1 -0
+

gpio_set_value_cansleep(pdata->reset_gpio_port[0], 0);

drivers/usb/host/ehci-omap.c static int ehci_hcd_omap_probe(struct · line 201

Quoted 4 lines
drivers/usb/host/ehci-omap.c +0 -2
 ? ? ? ? ? ? ? ?if (gpio_is_valid(pdata->reset_gpio_port[1]))
- ? ? ? ? ? ? ? ? ? ? ? gpio_request_one(pdata->reset_gpio_port[1],
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?GPIOF_OUT_INIT_LOW, "USB2 PHY

reset");

drivers/usb/host/ehci-omap.c static int ehci_hcd_omap_probe(struct · line 200

Quoted 1 line
drivers/usb/host/ehci-omap.c +1 -0
+

gpio_set_value_cansleep(pdata->reset_gpio_port[1], 0);

Quoted 2 lines

? ? ? ? ? ? ? ?/* Hold the PHY in RESET for enough time till DIR is high

*/

drivers/usb/host/ehci-omap.c static int ehci_hcd_omap_probe(struct

Quoted 2 lines

? ? ? ? ? ? ? ?udelay(10);

drivers/usb/host/ehci-omap.c +0 -0
@@ -241,6 +240,11 @@ static int ehci_hcd_omap_probe(struct

platform_device *pdev)

drivers/usb/host/ehci-omap.c static int ehci_hcd_omap_probe(struct

Quoted 12 lines
drivers/usb/host/ehci-omap.c +5 -0
 ? ? ? ?omap_ehci->hcs_params = readl(&omap_ehci->caps->hcs_params);
 
 ? ? ? ?ehci_reset(omap_ehci);
+ ? ? ? ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
+ ? ? ? if (ret) {
+ ? ? ? ? ? ? ? dev_err(dev, "failed to add hcd with err %d\n", ret);
+ ? ? ? ? ? ? ? goto err_add_hcd;
+ ? ? ? }
 
 ? ? ? ?if (pdata->phy_reset) {

? ? ? ? ? ? ? ?/* Hold the PHY in RESET for enough time till

drivers/usb/host/ehci-omap.c +0 -0
@@ -255,12 +259,6 @@ static int ehci_hcd_omap_probe(struct

platform_device *pdev)

Quoted 1 line

?gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1);

Quoted 11 lines

? ? ? ?}

- ? ? ? ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
- ? ? ? if (ret) {
- ? ? ? ? ? ? ? dev_err(dev, "failed to add hcd with err %d\n", ret);
- ? ? ? ? ? ? ? goto err_add_hcd;
- ? ? ? }
-
? ? ? ?/* root ports should always stay powered */
? ? ? ?ehci_port_power(omap_ehci, 1);

Quoted 3 lines

--
1.7.10.4

Hi Samuel

I have validated this patch v3 in omap3 beagle XM .

regards
keshava

#4 lore raw

PATCH v3 1/1 ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

In reply to Russ Dill

Hi Russ,

Quoted 32 lines · Russ Dill

From: Russ Dill <[email protected]>

'ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset issue' (1fcb57d0) fixes an issue where the ULPI PHYs were not held in reset while initializing the EHCI controller. However, it also changes behavior in omap-usb-host.c omap_usbhs_init by releasing reset while the configuration in that function was done.

This change caused a regression on BB-xM where USB would not function if 'usb start' had been run from u-boot before booting. A change was made to release reset a little bit earlier which fixed the issue on BB-xM and did not cause any regressions on 3430 sdp, the board for which the fix was originally made.

This new fix, 'USB: EHCI: OMAP: Finish ehci omap phy reset cycle before adding hcd.', (3aa2ae74) caused a regression on OMAP5.

The original fix to hold the EHCI controller in reset during initialization was correct, however it appears that changing omap_usbhs_init to not hold the PHYs in reset during it's configuration was incorrect. This patch first reverts both fixes, and then changes ehci_hcd_omap_probe in ehci-omap.c to hold the PHYs in reset as the original patch had done. It also is sure to incorporate the _cansleep change that has been made in the meantime.

I've tested this on Beagleboard xM, I'd really like to get an ack from the 3430 sdp and OMAP5 guys before getting this merged.

v3 - Brown paper bag its too early in the morning actually run
git commit amend fix
v2 - Put cansleep gpiolib call outside of spinlock

Quoted 5 lines
---
 drivers/mfd/omap-usb-host.c  |   48 +++++++++++++++++++++++++++++++++++++++++-
 drivers/usb/host/ehci-omap.c |   18 +++++++---------
 2 files changed, 55 insertions(+), 11 deletions(-)

I applied this one to my for-linus branch, it will be part of my next 3.5 pull request to Linus.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#5 lore raw

PATCH v3 1/1 ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

Quoted 40 lines · Samuel Ortiz

Hi Russ,

Quoted 32 lines · Russ Dill

From: Russ Dill <[email protected]>

'ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset issue' (1fcb57d0) fixes an issue where the ULPI PHYs were not held in reset while initializing the EHCI controller. However, it also changes behavior in omap-usb-host.c omap_usbhs_init by releasing reset while the configuration in that function was done.

This change caused a regression on BB-xM where USB would not function if 'usb start' had been run from u-boot before booting. A change was made to release reset a little bit earlier which fixed the issue on BB-xM and did not cause any regressions on 3430 sdp, the board for which the fix was originally made.

This new fix, 'USB: EHCI: OMAP: Finish ehci omap phy reset cycle before adding hcd.', (3aa2ae74) caused a regression on OMAP5.

The original fix to hold the EHCI controller in reset during initialization was correct, however it appears that changing omap_usbhs_init to not hold the PHYs in reset during it's configuration was incorrect. This patch first reverts both fixes, and then changes ehci_hcd_omap_probe in ehci-omap.c to hold the PHYs in reset as the original patch had done. It also is sure to incorporate the _cansleep change that has been made in the meantime.

I've tested this on Beagleboard xM, I'd really like to get an ack from the 3430 sdp and OMAP5 guys before getting this merged.

v3 - Brown paper bag its too early in the morning actually run
git commit amend fix
v2 - Put cansleep gpiolib call outside of spinlock

Quoted 5 lines
---
 drivers/mfd/omap-usb-host.c  |   48 +++++++++++++++++++++++++++++++++++++++++-
 drivers/usb/host/ehci-omap.c |   18 +++++++---------
 2 files changed, 55 insertions(+), 11 deletions(-)
Quoted 6 lines

I applied this one to my for-linus branch, it will be part of my next 3.5 pull request to Linus.

Cheers,
Samuel.

Hi Samuel
please drop this patch for now , since Alan stern has mentioned
improvements for this patch and we
need to wait for Alan's new patch on ehci-omap.c and then Rus dill patch and my usbhs tll
patch series need to be rebased.

regards
keshava

maintainer
#6 lore raw

PATCH v3 1/1 ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

Quoted 6 lines · Keshava

Hi Samuel
please drop this patch for now , since Alan stern has mentioned
improvements for this patch and we
need to wait for Alan's new patch on ehci-omap.c and then Rus dill patch and my usbhs tll
patch series need to be rebased.

No, that's okay. I rebased my patch on top of Russ's; see

	http://marc.info/?l=linux-usb&m=134098478928668&w=2

so Russ's patch should be kept. My patch needed other changes also, so this wasn't a big deal.

The extra problems I mentioned in an earlier email will still need to be fixed after both Russ's patch and my own are merged.

Alan Stern

#7 lore raw

PATCH v3 1/1 ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset fix issues.

Quoted 13 lines · Alan Stern
Quoted 6 lines · Keshava

Hi Samuel
please drop this patch for now , since Alan stern has mentioned
improvements for this patch and we
need to wait for Alan's new patch on ehci-omap.c and then Rus dill patch and my usbhs tll
patch series need to be rebased.

No, that's okay. I rebased my patch on top of Russ's; see

        http://marc.info/?l=linux-usb&m=134098478928668&w=2
Quoted 7 lines

so Russ's patch should be kept. My patch needed other changes also, so this wasn't a big deal.

The extra problems I mentioned in an earlier email will still need to be fixed after both Russ's patch and my own are merged.

Alan Stern

Thanks Alan,
Ok, then I will rebase my TLL driver patch series on top
of this patch.

regards
keshava