Skip to contentSkip to conversation

Make ohci-platform usable for omap3/4/5

PATCH Superseded Tony Lindgren 4 participants 20 messages May 17, 2017 – May 19, 2017 9 messages not in the archive

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Make ohci-platform usable for omap3/4/5

Hi all,

Here are patches I promised several months ago so we can eventually get rid of ohci-omap3 in favor of ohci-platform as suggested by Alan Stern.

I think we need to wait a while before removing ohci-omap3, so I just added a warning for now to urge people to move to use ohci-platform instead.

Regards,

Tony

Tony Lindgren (4):
usb: host: ohci-platform: Add basic runtime PM support
usb: host: ohci-platform: Add support for omap3 and later
usb: host: ohci-omap3: Print warning to get people to use
ohci-platform
ARM: dts: Add remote-wakeup-connected for omap OHCI

 Documentation/devicetree/bindings/usb/usb-ohci.txt |  1 +
 arch/arm/boot/dts/omap3.dtsi                       |  1 +
 arch/arm/boot/dts/omap4.dtsi                       |  1 +
 arch/arm/boot/dts/omap5.dtsi                       |  1 +
 drivers/usb/host/ohci-omap3.c                      |  3 +++
 drivers/usb/host/ohci-platform.c                   | 16 ++++++++++++++++
 6 files changed, 23 insertions(+)
Signature · 5 lines
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH 1/4 usb: host: ohci-platform: Add basic runtime PM support

In reply to a message not in the archive

This is needed in preparation of adding support for omap3 and later OHCI. The runtime PM will only do something on platforms that implement it.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 drivers/usb/host/ohci-platform.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/usb/host/ohci-platform.c +11 -0
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/reset.h>
 #include <linux/usb/ohci_pdriver.h>
 #include <linux/usb.h>
@@ -51,6 +52,10 @@ static int ohci_platform_power_on(struct platform_device *dev)
 	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
 	int clk, ret, phy_num;
 
+	ret = pm_runtime_get_sync(&dev->dev);
+	if (ret < 0)
+		return ret;
+
 	for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {
 		ret = clk_prepare_enable(priv->clks[clk]);
 		if (ret)
@@ -96,6 +101,8 @@ static void ohci_platform_power_off(struct platform_device *dev)
 	for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--)
 		if (priv->clks[clk])
 			clk_disable_unprepare(priv->clks[clk]);
+
+	pm_runtime_put_sync(&dev->dev);
 }
 
 static struct hc_driver __read_mostly ohci_platform_hc_driver;
@@ -242,6 +249,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	}
 #endif
 
+	pm_runtime_enable(&dev->dev);
 	if (pdata->power_on) {
 		err = pdata->power_on(dev);
 		if (err < 0)
@@ -271,6 +279,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	if (pdata->power_off)
 		pdata->power_off(dev);
 err_reset:
+	pm_runtime_disable(&dev->dev);
 	while (--rst >= 0)
 		reset_control_assert(priv->resets[rst]);
 err_put_clks:
@@ -305,6 +314,8 @@ static int ohci_platform_remove(struct platform_device *dev)
 
 	usb_put_hcd(hcd);
 
+	pm_runtime_disable(&dev->dev);
+
 	if (pdata == &ohci_platform_defaults)
 		dev->dev.platform_data = NULL;
 
Signature · 5 lines
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw

PATCH 2/4 usb: host: ohci-platform: Add support for omap3 and later

In reply to a message not in the archive

With the runtime PM implemented for ohci-platform driver, we can now support omap3 and later OHCI by adding one device tree property.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 Documentation/devicetree/bindings/usb/usb-ohci.txt | 1 +
 drivers/usb/host/ohci-platform.c                   | 5 +++++
 2 files changed, 6 insertions(+)
Documentation/devicetree/bindings/usb/usb-ohci.txt +1 -0
@@ -10,6 +10,7 @@ Optional properties:
 - big-endian-desc : boolean, set this for hcds with big-endian descriptors
 - big-endian : boolean, for hcds with big-endian-regs + big-endian-desc
 - no-big-frame-no : boolean, set if frame_no lives in bits [15:0] of HCCA
+- remote-wakeup-connected: remote wakeup is wired on the platform
 - num-ports : u32, to override the detected port count
 - clocks : a list of phandle + clock specifier pairs
 - phys : phandle + phy specifier pair
drivers/usb/host/ohci-platform.c +5 -0
@@ -170,6 +170,10 @@ static int ohci_platform_probe(struct platform_device *dev)
 		if (of_property_read_bool(dev->dev.of_node, "no-big-frame-no"))
 			ohci->flags |= OHCI_QUIRK_FRAME_NO;
 
+		if (of_property_read_bool(dev->dev.of_node,
+					  "remote-wakeup-connected"))
+			ohci->hc_control = OHCI_CTRL_RWC;
+
 		of_property_read_u32(dev->dev.of_node, "num-ports",
 				     &ohci->num_ports);
 
@@ -361,6 +365,7 @@ static int ohci_platform_resume(struct device *dev)
 static const struct of_device_id ohci_platform_ids[] = {
 	{ .compatible = "generic-ohci", },
 	{ .compatible = "cavium,octeon-6335-ohci", },
+	{ .compatible = "ti,ohci-omap3", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ohci_platform_ids);
Signature · 5 lines
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#17 lore raw

PATCH 3/4 usb: host: ohci-omap3: Print warning to get people to use ohci-platform

In reply to a message not in the archive

We can't just remove ohci-omap3 as that could make some people's systems unusable for keyboard and mouse. Let's print a warning for now, and then remove the driver in a year or so.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 drivers/usb/host/ohci-omap3.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/host/ohci-omap3.c +3 -0
@@ -130,6 +130,9 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)
 		dev_dbg(dev, "failed to add hcd with err %d\n", ret);
 		goto err_add_hcd;
 	}
+
+	WARN(1, "ohci-omap3 is deprecated, please use ohci-platform instead\n");
+
 	device_wakeup_enable(hcd->self.controller);
 
 	return 0;
Signature · 5 lines
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#25 lore raw

PATCH 4/4 ARM: dts: Add remote-wakeup-connected for omap OHCI

In reply to a message not in the archive

Add remote-wakeup-connected for omap OHCI as that's needed by ehci-platform driver.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 arch/arm/boot/dts/omap3.dtsi | 1 +
 arch/arm/boot/dts/omap4.dtsi | 1 +
 arch/arm/boot/dts/omap5.dtsi | 1 +
 3 files changed, 3 insertions(+)
arch/arm/boot/dts/omap3.dtsi +1 -0
@@ -715,6 +715,7 @@
 				reg = <0x48064400 0x400>;
 				interrupt-parent = <&intc>;
 				interrupts = <76>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@48064800 {
arch/arm/boot/dts/omap4.dtsi +1 -0
@@ -863,6 +863,7 @@
 				reg = <0x4a064800 0x400>;
 				interrupt-parent = <&gic>;
 				interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@4a064c00 {
arch/arm/boot/dts/omap5.dtsi +1 -0
@@ -939,6 +939,7 @@
 				compatible = "ti,ohci-omap3";
 				reg = <0x4a064800 0x400>;
 				interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@4a064c00 {
Signature · 5 lines
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#19 lore raw

Re: [PATCH 3/4] usb: host: ohci-omap3: Print warning to get people to use ohci-platform

In reply to a message not in the archive

Hi,

Quoted 9 lines · Tony Lindgren

We can't just remove ohci-omap3 as that could make some people's systems unusable for keyboard and mouse. Let's print a warning for now, and then remove the driver in a year or so.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>

I guess you could drop the driver and modify the Kconfig entry, so that it selects USB_OHCI_HCD_PLATFORM? I just checked and there are already a few examples of this in the USB host Kconfig :)

-- Sebastian

Quoted 23 lines
---
 drivers/usb/host/ohci-omap3.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/host/ohci-omap3.c +3 -0
@@ -130,6 +130,9 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)
 		dev_dbg(dev, "failed to add hcd with err %d\n", ret);
 		goto err_add_hcd;
 	}
+
+	WARN(1, "ohci-omap3 is deprecated, please use ohci-platform instead\n");
+
 	device_wakeup_enable(hcd->self.controller);
 
 	return 0;
Signature · 5 lines
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by
#4 lore raw

Re: [PATCH 1/4] usb: host: ohci-platform: Add basic runtime PM support

In reply to a message not in the archive
Quoted 10 lines · Tony Lindgren

This is needed in preparation of adding support for omap3 and later OHCI. The runtime PM will only do something on platforms that implement it.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
Quoted 61 lines
---
 drivers/usb/host/ohci-platform.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/usb/host/ohci-platform.c +11 -0
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/reset.h>
 #include <linux/usb/ohci_pdriver.h>
 #include <linux/usb.h>
@@ -51,6 +52,10 @@ static int ohci_platform_power_on(struct platform_device *dev)
 	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
 	int clk, ret, phy_num;
 
+	ret = pm_runtime_get_sync(&dev->dev);
+	if (ret < 0)
+		return ret;
+
 	for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {
 		ret = clk_prepare_enable(priv->clks[clk]);
 		if (ret)
@@ -96,6 +101,8 @@ static void ohci_platform_power_off(struct platform_device *dev)
 	for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--)
 		if (priv->clks[clk])
 			clk_disable_unprepare(priv->clks[clk]);
+
+	pm_runtime_put_sync(&dev->dev);
 }
 
 static struct hc_driver __read_mostly ohci_platform_hc_driver;
@@ -242,6 +249,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	}
 #endif
 
+	pm_runtime_enable(&dev->dev);
 	if (pdata->power_on) {
 		err = pdata->power_on(dev);
 		if (err < 0)
@@ -271,6 +279,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	if (pdata->power_off)
 		pdata->power_off(dev);
 err_reset:
+	pm_runtime_disable(&dev->dev);
 	while (--rst >= 0)
 		reset_control_assert(priv->resets[rst]);
 err_put_clks:
@@ -305,6 +314,8 @@ static int ohci_platform_remove(struct platform_device *dev)
 
 	usb_put_hcd(hcd);
 
+	pm_runtime_disable(&dev->dev);
+
 	if (pdata == &ohci_platform_defaults)
 		dev->dev.platform_data = NULL;
 
Signature · 6 lines
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by
#13 lore raw

Re: [PATCH 2/4] usb: host: ohci-platform: Add support for omap3 and later

In reply to a message not in the archive
Quoted 9 lines · Tony Lindgren

With the runtime PM implemented for ohci-platform driver, we can now support omap3 and later OHCI by adding one device tree property.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
Quoted 39 lines
---
 Documentation/devicetree/bindings/usb/usb-ohci.txt | 1 +
 drivers/usb/host/ohci-platform.c                   | 5 +++++
 2 files changed, 6 insertions(+)
Documentation/devicetree/bindings/usb/usb-ohci.txt +1 -0
@@ -10,6 +10,7 @@ Optional properties:
 - big-endian-desc : boolean, set this for hcds with big-endian descriptors
 - big-endian : boolean, for hcds with big-endian-regs + big-endian-desc
 - no-big-frame-no : boolean, set if frame_no lives in bits [15:0] of HCCA
+- remote-wakeup-connected: remote wakeup is wired on the platform
 - num-ports : u32, to override the detected port count
 - clocks : a list of phandle + clock specifier pairs
 - phys : phandle + phy specifier pair
drivers/usb/host/ohci-platform.c +5 -0
@@ -170,6 +170,10 @@ static int ohci_platform_probe(struct platform_device *dev)
 		if (of_property_read_bool(dev->dev.of_node, "no-big-frame-no"))
 			ohci->flags |= OHCI_QUIRK_FRAME_NO;
 
+		if (of_property_read_bool(dev->dev.of_node,
+					  "remote-wakeup-connected"))
+			ohci->hc_control = OHCI_CTRL_RWC;
+
 		of_property_read_u32(dev->dev.of_node, "num-ports",
 				     &ohci->num_ports);
 
@@ -361,6 +365,7 @@ static int ohci_platform_resume(struct device *dev)
 static const struct of_device_id ohci_platform_ids[] = {
 	{ .compatible = "generic-ohci", },
 	{ .compatible = "cavium,octeon-6335-ohci", },
+	{ .compatible = "ti,ohci-omap3", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ohci_platform_ids);
Signature · 6 lines
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by
#27 lore raw

Re: [PATCH 4/4] ARM: dts: Add remote-wakeup-connected for omap OHCI

In reply to a message not in the archive
Quoted 9 lines · Tony Lindgren

Add remote-wakeup-connected for omap OHCI as that's needed by ehci-platform driver.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
Quoted 40 lines
---
 arch/arm/boot/dts/omap3.dtsi | 1 +
 arch/arm/boot/dts/omap4.dtsi | 1 +
 arch/arm/boot/dts/omap5.dtsi | 1 +
 3 files changed, 3 insertions(+)
arch/arm/boot/dts/omap3.dtsi +1 -0
@@ -715,6 +715,7 @@
 				reg = <0x48064400 0x400>;
 				interrupt-parent = <&intc>;
 				interrupts = <76>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@48064800 {
arch/arm/boot/dts/omap4.dtsi +1 -0
@@ -863,6 +863,7 @@
 				reg = <0x4a064800 0x400>;
 				interrupt-parent = <&gic>;
 				interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@4a064c00 {
arch/arm/boot/dts/omap5.dtsi +1 -0
@@ -939,6 +939,7 @@
 				compatible = "ti,ohci-omap3";
 				reg = <0x4a064800 0x400>;
 				interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@4a064c00 {
Signature · 6 lines
cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#20 lore raw

Re: [PATCH 3/4] usb: host: ohci-omap3: Print warning to get people to use ohci-platform

In reply to Sebastian Reichel
Quoted 8 lines · Sebastian Reichel
Quoted 3 lines · Tony Lindgren

We can't just remove ohci-omap3 as that could make some people's systems unusable for keyboard and mouse. Let's print a warning for now, and then remove the driver in a year or so.

I guess you could drop the driver and modify the Kconfig entry, so that it selects USB_OHCI_HCD_PLATFORM? I just checked and there are already a few examples of this in the USB host Kconfig :)

Right but there's still nothing telling people to load ohci-platform instead of ohci-omap3 if we just remove ohci-omap3 without any warnings. I don't think there's any need to rush to remove ohci-omap3.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH 1/4] usb: host: ohci-platform: Add basic runtime PM support

In reply to a message not in the archive
Quoted 3 lines · Tony Lindgren

This is needed in preparation of adding support for omap3 and later OHCI. The runtime PM will only do something on platforms that implement it.

This patch isn't correct. See below.

Quoted 33 lines
Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 drivers/usb/host/ohci-platform.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/usb/host/ohci-platform.c +5 -0
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/reset.h>
 #include <linux/usb/ohci_pdriver.h>
 #include <linux/usb.h>
@@ -51,6 +52,10 @@ static int ohci_platform_power_on(struct platform_device *dev)
 	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
 	int clk, ret, phy_num;
 
+	ret = pm_runtime_get_sync(&dev->dev);
+	if (ret < 0)
+		return ret;
+
 	for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {
 		ret = clk_prepare_enable(priv->clks[clk]);
 		if (ret)

drivers/usb/host/ohci-platform.c static void ohci_platform_power_off(struct platform_device *dev) · line 106

Quoted 6 lines
drivers/usb/host/ohci-platform.c +2 -0
@@ -96,6 +101,8 @@ static void ohci_platform_power_off(struct platform_device *dev)
 	for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--)
 		if (priv->clks[clk])
 			clk_disable_unprepare(priv->clks[clk]);
+
+	pm_runtime_put_sync(&dev->dev);
 }

ohci_platform_power_on() is invoked (by default) by the runtime-resume callback routine ohci_platform_resume(), through the pdata->power_on method pointer. Likewise, ohci_platform_power_off() is invoked by the runtime-suspend callback routine.

This means you shouldn't do pm_runtime_get/put calls from within these routines.

Is there any particular reason you wanted to add these calls? In general, USB host controllers are expected to go into runtime suspend whenever there aren't any children keeping them awake. Hence they usually don't need to worry about initiating their own suspends and resumes.

drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 252

Quoted 6 lines
drivers/usb/host/ohci-platform.c +1 -0
 static struct hc_driver __read_mostly ohci_platform_hc_driver;
@@ -242,6 +249,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	}
 #endif
 
+	pm_runtime_enable(&dev->dev);

There should be a pm_runtime_set_active() just before this.

Quoted 12 lines
drivers/usb/host/ohci-platform.c +1 -0
 	if (pdata->power_on) {
 		err = pdata->power_on(dev);
 		if (err < 0)
@@ -271,6 +279,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	if (pdata->power_off)
 		pdata->power_off(dev);
 err_reset:
+	pm_runtime_disable(&dev->dev);
 	while (--rst >= 0)
 		reset_control_assert(priv->resets[rst]);
 err_put_clks:

drivers/usb/host/ohci-platform.c static int ohci_platform_remove(struct platform_device *dev) · line 320

Quoted 7 lines
drivers/usb/host/ohci-platform.c +2 -0
@@ -305,6 +314,8 @@ static int ohci_platform_remove(struct platform_device *dev)
 
 	usb_put_hcd(hcd);
 
+	pm_runtime_disable(&dev->dev);
+
 	if (pdata == &ohci_platform_defaults)
 		dev->dev.platform_data = NULL;

These changes make sense.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#14 lore raw

Re: [PATCH 2/4] usb: host: ohci-platform: Add support for omap3 and later

In reply to a message not in the archive
Quoted 40 lines · Tony Lindgren

With the runtime PM implemented for ohci-platform driver, we can now support omap3 and later OHCI by adding one device tree property.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 Documentation/devicetree/bindings/usb/usb-ohci.txt | 1 +
 drivers/usb/host/ohci-platform.c                   | 5 +++++
 2 files changed, 6 insertions(+)
Documentation/devicetree/bindings/usb/usb-ohci.txt +1 -0
@@ -10,6 +10,7 @@ Optional properties:
 - big-endian-desc : boolean, set this for hcds with big-endian descriptors
 - big-endian : boolean, for hcds with big-endian-regs + big-endian-desc
 - no-big-frame-no : boolean, set if frame_no lives in bits [15:0] of HCCA
+- remote-wakeup-connected: remote wakeup is wired on the platform
 - num-ports : u32, to override the detected port count
 - clocks : a list of phandle + clock specifier pairs
 - phys : phandle + phy specifier pair
drivers/usb/host/ohci-platform.c +4 -0
@@ -170,6 +170,10 @@ static int ohci_platform_probe(struct platform_device *dev)
 		if (of_property_read_bool(dev->dev.of_node, "no-big-frame-no"))
 			ohci->flags |= OHCI_QUIRK_FRAME_NO;
 
+		if (of_property_read_bool(dev->dev.of_node,
+					  "remote-wakeup-connected"))
+			ohci->hc_control = OHCI_CTRL_RWC;
+
 		of_property_read_u32(dev->dev.of_node, "num-ports",
 				     &ohci->num_ports);
 

drivers/usb/host/ohci-platform.c static int ohci_platform_resume(struct device *dev) · line 371

Quoted 7 lines
drivers/usb/host/ohci-platform.c +1 -0
@@ -361,6 +365,7 @@ static int ohci_platform_resume(struct device *dev)
 static const struct of_device_id ohci_platform_ids[] = {
 	{ .compatible = "generic-ohci", },
 	{ .compatible = "cavium,octeon-6335-ohci", },
+	{ .compatible = "ti,ohci-omap3", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ohci_platform_ids);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw

Re: [PATCH 2/4] usb: host: ohci-platform: Add support for omap3 and later

In reply to a message not in the archive
Quoted 5 lines · Alan Stern
Quoted 3 lines · Tony Lindgren

With the runtime PM implemented for ohci-platform driver, we can now support omap3 and later OHCI by adding one device tree property.

...

Quoted 14 lines
Quoted 14 lines
drivers/usb/host/ohci-platform.c +4 -0
@@ -170,6 +170,10 @@ static int ohci_platform_probe(struct platform_device *dev)
 		if (of_property_read_bool(dev->dev.of_node, "no-big-frame-no"))
 			ohci->flags |= OHCI_QUIRK_FRAME_NO;
 
+		if (of_property_read_bool(dev->dev.of_node,
+					  "remote-wakeup-connected"))
+			ohci->hc_control = OHCI_CTRL_RWC;
+
 		of_property_read_u32(dev->dev.of_node, "num-ports",
 				     &ohci->num_ports);
 
Quoted 10 lines

drivers/usb/host/ohci-platform.c static int ohci_platform_resume(struct device *dev) · line 371

Quoted 8 lines
drivers/usb/host/ohci-platform.c +1 -0
@@ -361,6 +365,7 @@ static int ohci_platform_resume(struct device *dev)
 static const struct of_device_id ohci_platform_ids[] = {
 	{ .compatible = "generic-ohci", },
 	{ .compatible = "cavium,octeon-6335-ohci", },
+	{ .compatible = "ti,ohci-omap3", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ohci_platform_ids);

FYI, this depends on the patch1/4 PM runtime issue getting sorted out first as otherwise the USB controller is powered off on omaps. So let's not apply this yet.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#24 lore raw

Re: [PATCH 3/4] usb: host: ohci-omap3: Print warning to get people to use ohci-platform

In reply to a message not in the archive
Quoted 17 lines · Tony Lindgren

We can't just remove ohci-omap3 as that could make some people's systems unusable for keyboard and mouse. Let's print a warning for now, and then remove the driver in a year or so.

Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 drivers/usb/host/ohci-omap3.c | 3 +++
 1 file changed, 3 insertions(+)

drivers/usb/host/ohci-omap3.c static int ohci_hcd_omap3_probe(struct platform_device *pdev) · line 138

Quoted 9 lines
drivers/usb/host/ohci-omap3.c +3 -0
@@ -130,6 +130,9 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)
 		dev_dbg(dev, "failed to add hcd with err %d\n", ret);
 		goto err_add_hcd;
 	}
+
+	WARN(1, "ohci-omap3 is deprecated, please use ohci-platform instead\n");
+
 	device_wakeup_enable(hcd->self.controller);
 
 	return 0;

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#28 lore raw

Re: [PATCH 4/4] ARM: dts: Add remote-wakeup-connected for omap OHCI

In reply to a message not in the archive
Quoted 2 lines · Tony Lindgren

Add remote-wakeup-connected for omap OHCI as that's needed by ehci-platform driver.

This should be "ohci", not "ehci". Otherwise,

Quoted 39 lines
Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 arch/arm/boot/dts/omap3.dtsi | 1 +
 arch/arm/boot/dts/omap4.dtsi | 1 +
 arch/arm/boot/dts/omap5.dtsi | 1 +
 3 files changed, 3 insertions(+)
arch/arm/boot/dts/omap3.dtsi +1 -0
@@ -715,6 +715,7 @@
 				reg = <0x48064400 0x400>;
 				interrupt-parent = <&intc>;
 				interrupts = <76>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@48064800 {
arch/arm/boot/dts/omap4.dtsi +1 -0
@@ -863,6 +863,7 @@
 				reg = <0x4a064800 0x400>;
 				interrupt-parent = <&gic>;
 				interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@4a064c00 {

arch/arm/boot/dts/omap5.dtsi line 945

Quoted 7 lines
arch/arm/boot/dts/omap5.dtsi +1 -0
@@ -939,6 +939,7 @@
 				compatible = "ti,ohci-omap3";
 				reg = <0x4a064800 0x400>;
 				interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
+				remote-wakeup-connected;
 			};
 
 			usbhsehci: ehci@4a064c00 {

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH 1/4] usb: host: ohci-platform: Add basic runtime PM support

In reply to a message not in the archive
Quoted 53 lines · Alan Stern
Quoted 3 lines · Tony Lindgren

This is needed in preparation of adding support for omap3 and later OHCI. The runtime PM will only do something on platforms that implement it.

This patch isn't correct. See below.

Quoted 33 lines
Cc Hans de Goede <[email protected]>
Cc Rob Herring <[email protected]>
Cc Roger Quadros <[email protected]>
Cc Yoshihiro Shimoda <[email protected]>
---
 drivers/usb/host/ohci-platform.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/usb/host/ohci-platform.c +5 -0
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/reset.h>
 #include <linux/usb/ohci_pdriver.h>
 #include <linux/usb.h>
@@ -51,6 +52,10 @@ static int ohci_platform_power_on(struct platform_device *dev)
 	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
 	int clk, ret, phy_num;
 
+	ret = pm_runtime_get_sync(&dev->dev);
+	if (ret < 0)
+		return ret;
+
 	for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {
 		ret = clk_prepare_enable(priv->clks[clk]);
 		if (ret)

drivers/usb/host/ohci-platform.c static void ohci_platform_power_off(struct platform_device *dev) · line 106

Quoted 6 lines
drivers/usb/host/ohci-platform.c +2 -0
@@ -96,6 +101,8 @@ static void ohci_platform_power_off(struct platform_device *dev)
 	for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--)
 		if (priv->clks[clk])
 			clk_disable_unprepare(priv->clks[clk]);
+
+	pm_runtime_put_sync(&dev->dev);
 }

ohci_platform_power_on() is invoked (by default) by the runtime-resume callback routine ohci_platform_resume(), through the pdata->power_on method pointer. Likewise, ohci_platform_power_off() is invoked by the runtime-suspend callback routine.

Quoted 2 lines

This means you shouldn't do pm_runtime_get/put calls from within these routines.

Oh OK great, so the above should not be needed at all.

Quoted 5 lines

Is there any particular reason you wanted to add these calls? In general, USB host controllers are expected to go into runtime suspend whenever there aren't any children keeping them awake. Hence they usually don't need to worry about initiating their own suspends and resumes.

No particular reason as it sounds things work without it :) I'll check.

Quoted 8 lines

drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 252

Quoted 6 lines
drivers/usb/host/ohci-platform.c +1 -0
 static struct hc_driver __read_mostly ohci_platform_hc_driver;
@@ -242,6 +249,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	}
 #endif
 
+	pm_runtime_enable(&dev->dev);

There should be a pm_runtime_set_active() just before this.

OK

Quoted 13 lines
Quoted 13 lines
drivers/usb/host/ohci-platform.c +1 -0
 	if (pdata->power_on) {
 		err = pdata->power_on(dev);
 		if (err < 0)
@@ -271,6 +279,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 	if (pdata->power_off)
 		pdata->power_off(dev);
 err_reset:
+	pm_runtime_disable(&dev->dev);
 	while (--rst >= 0)
 		reset_control_assert(priv->resets[rst]);
 err_put_clks:
@@ -305,6 +314,8 @@ static int ohci_platform_remove(struct platform_device *dev)
 
Quoted 8 lines

drivers/usb/host/ohci-platform.c static int ohci_platform_remove(struct platform_device *dev) · line 320

Quoted 6 lines
drivers/usb/host/ohci-platform.c +2 -0
 	usb_put_hcd(hcd);
 
+	pm_runtime_disable(&dev->dev);
+
 	if (pdata == &ohci_platform_defaults)
 		dev->dev.platform_data = NULL;

These changes make sense.

OK thanks for looking.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

Re: [PATCH 1/4] usb: host: ohci-platform: Add basic runtime PM support

In reply to a message not in the archive

drivers/usb/host/ohci-platform.c static int ohci_platform_power_on(struct platform_device *dev) · line 58

Quoted 12 lines · Tony Lindgren

This is needed in preparation of adding support for omap3 and later OHCI. The runtime PM will only do something on platforms that implement it.

drivers/usb/host/ohci-platform.c +4 -0
@@ -51,6 +52,10 @@ static int ohci_platform_power_on(struct platform_device *dev)
 	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
 	int clk, ret, phy_num;
 
+	ret = pm_runtime_get_sync(&dev->dev);
+	if (ret < 0)
+		return ret;
+

I don't remember how probing for platform device drivers is set up. So although this is definitely the wrong place for pm_runtime_get_sync(), it may turn out that you need to do a pm_runtime_get_noresume() before calling pm_runtime_enable(), and a pm_runtime_put() at the end of ohci_platform_probe(). Otherwise runtime PM might kick in during the middle of the probe sequence -- not what you want.

Similarly, you may need pm_runtime_get_sync() at the start of ohci_platform_remove() and pm_runtime_put_noidle() at the end.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#22 lore raw

Re: [PATCH 3/4] usb: host: ohci-omap3: Print warning to get people to use ohci-platform

In reply to a message not in the archive

Hi,

Quoted 6 lines · Tony Lindgren
Quoted 5 lines · Sebastian Reichel
Quoted 3 lines · Tony Lindgren

We can't just remove ohci-omap3 as that could make some people's systems unusable for keyboard and mouse. Let's print a warning for now, and then remove the driver in a year or so.

Quoted 6 lines
Quoted 3 lines

I guess you could drop the driver and modify the Kconfig entry, so that it selects USB_OHCI_HCD_PLATFORM? I just checked and there are already a few examples of this in the USB host Kconfig :)

Right but there's still nothing telling people to load ohci-platform instead of ohci-omap3 if we just remove ohci-omap3 without any warnings.

Shouldn't the driver be loaded automatically due to the DT compatible value?

Quoted 1 line

I don't think there's any need to rush to remove ohci-omap3.

Just looked like it can be dropped with trivial changes.

-- Sebastian

#23 lore raw

Re: [PATCH 3/4] usb: host: ohci-omap3: Print warning to get people to use ohci-platform

Quoted 13 lines · Sebastian Reichel

Hi,

Quoted 10 lines · Tony Lindgren
Quoted 8 lines · Sebastian Reichel
Quoted 3 lines · Tony Lindgren

We can't just remove ohci-omap3 as that could make some people's systems unusable for keyboard and mouse. Let's print a warning for now, and then remove the driver in a year or so.

I guess you could drop the driver and modify the Kconfig entry, so that it selects USB_OHCI_HCD_PLATFORM? I just checked and there are already a few examples of this in the USB host Kconfig :)

Quoted 5 lines
Quoted 2 lines

Right but there's still nothing telling people to load ohci-platform instead of ohci-omap3 if we just remove ohci-omap3 without any warnings.

Shouldn't the driver be loaded automatically due to the DT compatible value?

Doesn't that depend on a collection of user space software of varying quality and usability? :)

But I think we can actually ohci-omap3 once the issues are sorted out. That's because for OHCI omaps need an OHCI PHY. In most cases there is just EHCI PHY and an external hub is needed. I'll do some more testing.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [PATCH 1/4] usb: host: ohci-platform: Add basic runtime PM support

In reply to a message not in the archive
Quoted 10 lines · Alan Stern
Quoted 8 lines · Tony Lindgren

This is needed in preparation of adding support for omap3 and later OHCI. The runtime PM will only do something on platforms that implement it.

drivers/usb/host/ohci-platform.c +0 -0
@@ -51,6 +52,10 @@ static int ohci_platform_power_on(struct platform_device *dev)
 	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
 	int clk, ret, phy_num;
 
Quoted 12 lines

drivers/usb/host/ohci-platform.c static int ohci_platform_power_on(struct platform_device *dev) · line 58

Quoted 4 lines
drivers/usb/host/ohci-platform.c +4 -0
+	ret = pm_runtime_get_sync(&dev->dev);
+	if (ret < 0)
+		return ret;
+

I don't remember how probing for platform device drivers is set up. So although this is definitely the wrong place for pm_runtime_get_sync(), it may turn out that you need to do a pm_runtime_get_noresume() before calling pm_runtime_enable(), and a pm_runtime_put() at the end of ohci_platform_probe(). Otherwise runtime PM might kick in during the middle of the probe sequence -- not what you want.

Just removing those parts seems to work for probing.

Quoted 2 lines

Similarly, you may need pm_runtime_get_sync() at the start of ohci_platform_remove() and pm_runtime_put_noidle() at the end.

Yup that I noticed that too trying to rmmod it with no devices connected.

While testing I also saw once "external abort on non-linefetch":

(ohci_hub_status_data [ohci_hcd]) from [<bf0298bc>] (usb_hcd_poll_rh_status+0x3c/0x128 [usbcore]) (usb_hcd_poll_rh_status [usbcore]) from [<c01c790c>] (call_timer_fn+0xb0/0x3f8)
(call_timer_fn) from [<c01c7d38>] (expire_timers+0xe4/0x220) (expire_timers) from [<c01c7f08>] (run_timer_softirq+0x94/0x19c) (run_timer_softirq) from [<c0141cf8>] (__do_softirq+0x140/0x570)

Also I'm still checking if legacy usb_phy vs phy needs handling. So far it seems that no need to do anything because most devices need a USB hub anyways unless they have USB serial transceiver configured with drivers/mfd/omap-usb-host.c for LS/FS.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html