Skip to contentSkip to conversation

ohci and ehci-platform clks, phy and dt support

PATCH Superseded Hans de Goede 2 participants 5 messages Jan 15, 2014

Subsystems (4)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v6 cover ohci and ehci-platform clks, phy and dt support

Hi all,

And here is v6 of my ohci and ehci-platform clks, phy and dt support patch-set, this version addresses the 2 small bugs Alan found.

Other then that there are no changes compared to v5.

Regards,

Hans

#1 lore raw

PATCH v6 1/2 ohci-platform: Add support for devicetree instantiation

Add support for ohci-platform instantiation from devicetree, including optionally getting clks and a phy from devicetree, and enabling / disabling those on power_on / off.

This should allow using ohci-platform from devicetree in various cases. Specifically after this commit it can be used for the ohci controller found on Allwinner sunxi SoCs.

---
 Documentation/devicetree/bindings/usb/usb-ohci.txt |  22 +++
 drivers/usb/host/ohci-platform.c                   | 164 ++++++++++++++++++---
 2 files changed, 162 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-ohci.txt
Documentation/devicetree/bindings/usb/usb-ohci.txt new file +22 -0
new file mode 100644
index 0000000..f9d6c73
@@ -0,0 +1,22 @@
+USB OHCI controllers
+
+Required properties:
+- compatible : "usb-ohci"
+- reg : ohci controller register range (address and length)
+- interrupts : ohci controller interrupt
+
+Optional properties:
+- clocks : a list of phandle + clock specifier pairs
+- phys : phandle + phy specifier pair
+- phy-names : "usb"
+
+Example:
+
+	ohci0: ohci at 0x01c14400 {
+		compatible = "allwinner,sun4i-a10-ohci", "usb-ohci";
+		reg = <0x01c14400 0x100>;
+		interrupts = <64>;
+		clocks = <&usb_clk 6>, <&ahb_gates 2>;
+		phys = <&usbphy 1>;
+		phy-names = "usb";
+	};
drivers/usb/host/ohci-platform.c +140 -24

254 lines not on this page · raw message

Signature · 1 line
1.8.4.2
maintainer
#2 lore raw

PATCH v6 1/2 ohci-platform: Add support for devicetree instantiation

drivers/usb/host/ohci-platform.c static int ohci_platform_reset(struct usb_hcd *hcd) · line 68

Quoted 7 lines · Hans de Goede
drivers/usb/host/ohci-platform.c +7 -0
+static int ohci_platform_power_on(struct platform_device *dev)
+{
+	struct usb_hcd *hcd = platform_get_drvdata(dev);
+	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
+	int clk, ret;
+
+	for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {

You fixed this one...

Quoted 4 lines
drivers/usb/host/ohci-platform.c +0 -0
@@ -125,13 +225,22 @@ static int ohci_platform_remove(struct platform_device *dev)
 {
 	struct usb_hcd *hcd = platform_get_drvdata(dev);
 	struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);

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

Quoted 10 lines
drivers/usb/host/ohci-platform.c +3 -1
+	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
+	int clk;
 
 	usb_remove_hcd(hcd);
-	usb_put_hcd(hcd);
 
 	if (pdata->power_off)
 		pdata->power_off(dev);
 
+	for (clk = 0; priv->clks[clk] && clk < OHCI_MAX_CLKS; clk++)

but not this one. :-( Same for the ehci-platform patch.

In fact, it might be easier to make this loop go backward, like you do in the *_platform_power_off routines.

Is there a devm-type routine that will take care of all this for you?

Alan Stern

#3 lore raw

PATCH v6 1/2 ohci-platform: Add support for devicetree instantiation

Hi,

Quoted 22 lines · Alan Stern

drivers/usb/host/ohci-platform.c static int ohci_platform_reset(struct usb_hcd *hcd) · line 68

Quoted 7 lines · Hans de Goede
drivers/usb/host/ohci-platform.c +7 -0
+static int ohci_platform_power_on(struct platform_device *dev)
+{
+	struct usb_hcd *hcd = platform_get_drvdata(dev);
+	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
+	int clk, ret;
+
+	for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {

You fixed this one...

Quoted 10 lines
drivers/usb/host/ohci-platform.c +2 -1
@@ -125,13 +225,22 @@ static int ohci_platform_remove(struct platform_device *dev)
  {
  	struct usb_hcd *hcd = platform_get_drvdata(dev);
  	struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
+	struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
+	int clk;
 
  	usb_remove_hcd(hcd);
-	usb_put_hcd(hcd);
 
Quoted 6 lines

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

Quoted 4 lines
drivers/usb/host/ohci-platform.c +1 -0
  	if (pdata->power_off)
  		pdata->power_off(dev);
 
+	for (clk = 0; priv->clks[clk] && clk < OHCI_MAX_CLKS; clk++)

but not this one. :-( Same for the ehci-platform patch.

Oops, sorry about that, v7 coming up.

Quoted 2 lines

In fact, it might be easier to make this loop go backward, like you do in the *_platform_power_off routines.

I prefer keep doing things forward here, the backward loop in power_off is because the disable_unprepare must be done in reverse order if the prepare_enable calls.

Quoted 1 line

Is there a devm-type routine that will take care of all this for you?

Nope, the downside of getting the clocks by index rather then by name is that there are no devm routines for that.

Regards,

Hans

#4 lore raw

PATCH v6 2/2 ehci-platform: Add support for clks and phy passed through devicetree

In reply to Hans de Goede

Currently ehci-platform is only used in combination with devicetree when used with some Via socs. By extending it to (optionally) get clks and a phy from devicetree, and enabling / disabling those on power_on / off, it can be used more generically. Specifically after this commit it can be used for the ehci controller on Allwinner sunxi SoCs.

Since ehci-platform is intended to handle any generic enough non pci ehci device, add a "usb-ehci" compatibility string.

There already is a usb-ehci device-tree bindings document, update this with clks and phy bindings info.

Although actually quite generic so far the via,vt8500 compatibilty string had its own bindings document. Somehow we even ended up with 2 of them. Since these provide no extra information over the generic usb-ehci documentation, this patch removes them.

The ehci-ppc-of.c driver also claims the usb-ehci compatibility string, even though it mostly is ibm,usb-ehci-440epx specific. ehci-platform.c is not needed on ppc platforms, so add a !PPC_OF dependency to it to avoid 2 drivers claiming the same compatibility string getting build on ppc.

---
 Documentation/devicetree/bindings/usb/usb-ehci.txt |  25 +++-
 .../devicetree/bindings/usb/via,vt8500-ehci.txt    |  15 ---
 .../devicetree/bindings/usb/vt8500-ehci.txt        |  12 --
 drivers/usb/host/Kconfig                           |   1 +
 drivers/usb/host/ehci-platform.c                   | 149 +++++++++++++++++----
 5 files changed, 142 insertions(+), 60 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/usb/via,vt8500-ehci.txt
 delete mode 100644 Documentation/devicetree/bindings/usb/vt8500-ehci.txt
Documentation/devicetree/bindings/usb/usb-ehci.txt +18 -7
index fa18612..fad10f3 100644
@@ -7,13 +7,14 @@ Required properties:
     (debug-port or other) can be also specified here, but only after
     definition of standard EHCI registers.
   - interrupts : one EHCI interrupt should be described here.
-If device registers are implemented in big endian mode, the device
-node should have "big-endian-regs" property.
-If controller implementation operates with big endian descriptors,
-"big-endian-desc" property should be specified.
-If both big endian registers and descriptors are used by the controller
-implementation, "big-endian" property can be specified instead of having
-both "big-endian-regs" and "big-endian-desc".
+
+Optional properties:
+ - big-endian-regs : boolean, set this for hcds with big-endian registers
+ - big-endian-desc : boolean, set this for hcds with big-endian descriptors
+ - big-endian : boolean, for hcds with big-endian-regs + big-endian-desc
+ - clocks : a list of phandle + clock specifier pairs
+ - phys : phandle + phy specifier pair
+ - phy-names : "usb"
 
 Example (Sequoia 440EPx):
     ehci at e0000300 {
@@ -23,3 +24,13 @@ Example (Sequoia 440EPx):
 	   reg = <0 e0000300 90 0 e0000390 70>;
 	   big-endian;
    };
+
+Example (Allwinner sun4i A10 SoC):
+   ehci0: ehci at 0x01c14000 {
+	   compatible = "allwinner,sun4i-a10-ehci", "usb-ehci";
+	   reg = <0x01c14000 0x100>;
+	   interrupts = <39>;
+	   clocks = <&ahb_gates 1>;
+	   phys = <&usbphy 1>;
+	   phy-names = "usb";
+   };
Documentation/devicetree/bindings/usb/via,vt8500-ehci.txt deleted +0 -15
deleted file mode 100644
index 17b3ad1..0000000
@@ -1,15 +0,0 @@
-VIA/Wondermedia VT8500 EHCI Controller
------------------------------------------------------
-
-Required properties:
-- compatible : "via,vt8500-ehci"
-- reg : Should contain 1 register ranges(address and length)
-- interrupts : ehci controller interrupt
-
-Example:
-
-	ehci at d8007900 {
-		compatible = "via,vt8500-ehci";
-		reg = <0xd8007900 0x200>;
-		interrupts = <43>;
-	};
Documentation/devicetree/bindings/usb/vt8500-ehci.txt deleted +0 -12
deleted file mode 100644
index 5fb8fd6..0000000
@@ -1,12 +0,0 @@
-VIA VT8500 and Wondermedia WM8xxx SoC USB controllers.
-
-Required properties:
- - compatible: Should be "via,vt8500-ehci" or "wm,prizm-ehci".
- - reg: Address range of the ehci registers. size should be 0x200
- - interrupts: Should contain the ehci interrupt.
-
-usb: ehci at D8007100 {
-	compatible = "wm,prizm-ehci", "usb-ehci";
-	reg = <0xD8007100 0x200>;
-	interrupts = <1>;
-};
drivers/usb/host/Kconfig +1 -0
index a9707da..e28cbe0 100644
@@ -255,6 +255,7 @@ config USB_EHCI_ATH79
 
 config USB_EHCI_HCD_PLATFORM
 	tristate "Generic EHCI driver for a platform device"
+	depends on !PPC_OF
 	default n
 	---help---
 	  Adds an EHCI host driver for a generic platform device, which
drivers/usb/host/ehci-platform.c +123 -26

244 lines not on this page · raw message

Signature · 1 line
1.8.4.2