ohci and ehci-platform clks, phy and dt support
Subsystems (4)
v3 cover ohci and ehci-platform clks, phy and dt support
Hi All,
Here is v3 of my ohci and ehci-platform clks, phy and dt support patch-set.
This version is mostly the result of some discussions on irc with Maxime to improve the dt-bindings. This has resulted in 2 changes:
1) Drop the clock-names from the dt-bindings, instead get clocks by index.
Since the intend is to be a generic ohci / ehci driver, the code does not give any special meaning to any of the clocks, so simply just get as many clocks as there are by index.
2) Change the compatible string to "mmio-ohci" resp. "mmio-ehci"
v2 was using allwinner,sun4i-ohci as compat string to avoid having to come up with a generic name, but in retrospect this is the wrong thing to do. This will likely lead to dts files for non allwinner boards using compatible = "allwinner,sun4i-ohci", and if we then ever need to do some allwinner specific quirks, these boards end up getting these quirks applied too.
dts files should use the generic mmio-ehci compatible as least prefered option,
ie: compatible = "allwinner,sun7i-a20-ehci", "mmio-ehci";
This will allow use of the generic driver while leaving the option open to later add soc specific quirks without needing dt changes.
Regards,
Hans
PATCH v3 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.
--- .../devicetree/bindings/usb/mmio-ohci.txt | 22 +++ drivers/usb/host/ohci-platform.c | 150 ++++++++++++++++++--- 2 files changed, 152 insertions(+), 20 deletions(-) create mode 100644 Documentation/devicetree/bindings/usb/mmio-ohci.txt
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +22 -0
@@ -0,0 +1,22 @@ +Generic MMIO OHCI controller + +Required properties: +- compatible : "mmio-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 = "mmio-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 +130 -20
226 lines not on this page · raw message
Signature · 1 line
1.8.4.2
PATCH v3 1/2 ohci-platform: Add support for devicetree instantiation
Quoted 10 lines · On Thursday 09 January 2014 18:57:05 Hans de Goede wrote:
drivers/usb/host/ohci-platform.c +10
-0+if (pdata == &ohci_platform_defaults && dev->dev.of_node) { + priv->phy =devm_phy_get (&dev->dev,"usb" ); +if (IS_ERR (priv->phy)) { + err =PTR_ERR (priv->phy); +if (err == -EPROBE_DEFER ) + goto err_put_hcd; + priv->phy =NULL ; + } + +for (clk =0 ; clk <OHCI_MAX_CLKS ; clk++) {
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 192
Quoted 10 lines
drivers/usb/host/ohci-platform.c +10
-0+ priv->clks[clk] =of_clk_get (dev->dev.of_node, clk); +if (IS_ERR (priv->clks[clk])) { + err =PTR_ERR (priv->clks[clk]); +if (err == -EPROBE_DEFER ) + goto err_put_clks; + priv->clks[clk] =NULL ; +break ; + } + } + }
Ah, very nice! This way it will actually work to replace a number of older drivers that require a specific clock name.
I still think we should change the phy subsystem to allow the same, that would make it more consistent here, and avoid the need for coming up with a number of bogus phy names for random drivers that can only ever have one phy.
Arnd
PATCH v3 1/2 ohci-platform: Add support for devicetree instantiation
Hi,
Quoted 22 lines · Arnd Bergmann
Quoted 10 lines · On Thursday 09 January 2014 18:57:05 Hans de Goede wrote:
drivers/usb/host/ohci-platform.c +10
-0+if (pdata == &ohci_platform_defaults && dev->dev.of_node) { + priv->phy =devm_phy_get (&dev->dev,"usb" ); +if (IS_ERR (priv->phy)) { + err =PTR_ERR (priv->phy); +if (err == -EPROBE_DEFER ) + goto err_put_hcd; + priv->phy =NULL ; + } + +for (clk =0 ; clk <OHCI_MAX_CLKS ; clk++) {drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 192
Quoted 10 lines
drivers/usb/host/ohci-platform.c +10
-0+ priv->clks[clk] =of_clk_get (dev->dev.of_node, clk); +if (IS_ERR (priv->clks[clk])) { + err =PTR_ERR (priv->clks[clk]); +if (err == -EPROBE_DEFER ) + goto err_put_clks; + priv->clks[clk] =NULL ; +break ; + } + } + }
Quoted 2 lines
Ah, very nice! This way it will actually work to replace a number of older drivers that require a specific clock name.
I'm glad you like it.
Quoted 5 lines
I still think we should change the phy subsystem to allow the same, that would make it more consistent here, and avoid the need for coming up with a number of bogus phy names for random drivers that can only ever have one phy.
I'm not disagreeing, but that will have to be a battle for another day. Currently the dt-bindings for phy actually make phy-names mandatory at the bindings-description level, so someone would first need to change the specification.
Documentation/devicetree/bindings/phy/phy-bindings.txt:
"""
PHY user node
=============
Required Properties:
phys : the phandle for the PHY device (used by the PHY subsystem) phy-names : the names of the PHY corresponding to the PHYs present in the
*phys* phandle
"""
Regards,
Hans
PATCH v3 1/2 ohci-platform: Add support for devicetree instantiation
In reply to Hans de GoedeHello.
Quoted 21 lines · Hans de Goede
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.
Signed-off-by Hans de Goede <[email protected]>--- .../devicetree/bindings/usb/mmio-ohci.txt | 22 +++ drivers/usb/host/ohci-platform.c | 150 ++++++++++++++++++--- 2 files changed, 152 insertions(+), 20 deletions(-)create mode 100644
Documentation/devicetree/bindings/usb/mmio-ohci.txtDocumentation/devicetree/bindings/usb/mmio-ohci.txt new file +0
-0
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +1
-0@@ -0,0 +1,22 @@ +Generic MMIO OHCI controller
OHCI controller always uses MMIO, and likewise EHCI. You don't need to
specifically mention it.
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 4
Quoted 3 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +3
-0+ +Required properties: +- compatible : "mmio-ohci"
Likewise, it's not a good name. Why not call it "platform-ohci"?
Quoted 8 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +8
-0+- 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" +
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 22
Quoted 10 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +10
-0+Example: + + ohci0: ohci at 0x01c14400 { + compatible = "mmio-ohci"; + reg = <0x01c14400 0x100>; + interrupts = <64>; + clocks = <&usb_clk 6>, <&ahb_gates 2>; + phys = <&usbphy 1>; + phy-names = "usb"; + };
WBR, Sergei
PATCH v3 1/2 ohci-platform: Add support for devicetree instantiation
Hi,
Quoted 19 lines · Sergei Shtylyov
Hello.
Quoted 14 lines · Hans de Goede
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.
Signed-off-by Hans de Goede <[email protected]>--- .../devicetree/bindings/usb/mmio-ohci.txt | 22 +++ drivers/usb/host/ohci-platform.c | 150 ++++++++++++++++++--- 2 files changed, 152 insertions(+), 20 deletions(-)create mode 100644
Documentation/devicetree/bindings/usb/mmio-ohci.txt
Quoted 9 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 1
Quoted 7 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +1
-0@@ -0,0 +1,22 @@ +Generic MMIO OHCI controllerOHCI controller always uses MMIO, and likewise EHCI. You don't need to specifically mention it.
Right, I'm only using it here because it is also used in the compatible string.
Quoted 6 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 4
Quoted 4 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +3
-0+ +Required properties: +- compatible : "mmio-ohci"Likewise, it's not a good name. Why not call it "platform-ohci"?
Because, as you would have known had you read the entire thread, people objected against exactly that name because the "platform" bus thing is a Linux invention, and other operating systems don't use the platform nomenclature for non pci busses.
Regards,
Hans
PATCH v3 1/2 ohci-platform: Add support for devicetree instantiation
Quoted 35 lines · Hans de Goede
Hi,
Quoted 20 lines · Sergei Shtylyov
Hello.
Quoted 15 lines · Hans de Goede
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.
Signed-off-by Hans de Goede <[email protected]>--- .../devicetree/bindings/usb/mmio-ohci.txt | 22 +++ drivers/usb/host/ohci-platform.c | 150 ++++++++++++++++++--- 2 files changed, 152 insertions(+), 20 deletions(-)create mode 100644
Documentation/devicetree/bindings/usb/mmio-ohci.txtQuoted 11 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 1
Quoted 8 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +1
-0@@ -0,0 +1,22 @@ +Generic MMIO OHCI controllerOHCI controller always uses MMIO, and likewise EHCI. You don't need to
specifically mention it.
Quoted 1 line
Right, I'm only using it here because it is also used in the compatible string.
Please drop it.
Quoted 10 lines
Quoted 5 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 4
Quoted 3 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +3
-0+ +Required properties: +- compatible : "mmio-ohci"Likewise, it's not a good name. Why not call it "platform-ohci"?
Because, as you would have known had you read the entire thread, people objected against exactly that name because the "platform" bus thing is a Linux invention, and other operating systems don't use the platform nomenclature for non pci busses.
I wonder where were all those people when "xhci-platform" compatible got
adopted in drivers/usb/host/xhci-plat.c? :-P
Anyway, I want to suggest "usb-[eo]hci" of which "usb-ehci" binding has
even already documented in Documentation/devicetree/bindings/usb/usb-ehci.txt. Both these "compatible" values are used as backups in the multiple described bindings of the platform-specific [EO]HCI controllers. I really don't see why you should invent anything new (and so poorly named).
Quoted 3 lines
Regards,
Hans
WBR, Sergei
[linux-sunxi] Re: [PATCH v3 1/2] ohci-platform: Add support for devicetree instantiation
Hi,
Quoted 51 lines · Sergei Shtylyov
Quoted 35 lines · Hans de Goede
Hi,
Quoted 20 lines · Sergei Shtylyov
Hello.
Quoted 15 lines · Hans de Goede
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.
Signed-off-by Hans de Goede <[email protected]>--- .../devicetree/bindings/usb/mmio-ohci.txt | 22 +++ drivers/usb/host/ohci-platform.c | 150 ++++++++++++++++++--- 2 files changed, 152 insertions(+), 20 deletions(-)create mode 100644
Documentation/devicetree/bindings/usb/mmio-ohci.txtQuoted 11 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 1
Quoted 8 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +1
-0@@ -0,0 +1,22 @@ +Generic MMIO OHCI controllerOHCI controller always uses MMIO, and likewise EHCI. You don't need to
specifically mention it.Quoted 1 line
Right, I'm only using it here because it is also used in the compatible string.
Please drop it.
Quoted 10 lines
Quoted 5 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 4
Quoted 3 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +3
-0+ +Required properties: +- compatible : "mmio-ohci"Likewise, it's not a good name. Why not call it "platform-ohci"?
Because, as you would have known had you read the entire thread, people objected against exactly that name because the "platform" bus thing is a Linux invention, and other operating systems don't use the platform nomenclature for non pci busses.
Quoted 4 lines
I wonder where were all those people when "xhci-platform" compatible got adopted in
drivers/usb/host/xhci-plat.c? :-PAnyway, I want to suggest "usb-[eo]hci" of which "usb-ehci" binding has even already documented in
Documentation/devicetree/bindings/usb/usb-ehci.txt.
Both these "compatible" values are used as backups in the multiple described bindings of the platform-specific [EO]HCI controllers. I really don't see why you should invent anything new (and so poorly named).
This too has already been discussed, again please read the entire thread including review of earlier versions of the patch.
We cannot usb usb-ehci, because the existing usb-ehci compatible string is not used for a generic usb controller, but for a ppc specific one which needs model specific setup, see the driver currently implementing compatible = usb-ehci.
Regards,
Hans
[linux-sunxi] Re: [PATCH v3 1/2] ohci-platform: Add support for devicetree instantiation
Hello.
Quoted 1 line · Hans de Goede
Hi,
I would like to know why you dropped me from the To: list when replying. I
have hardly noticed your reply.
Quoted 46 lines
Quoted 45 lines
Quoted 28 lines
Quoted 16 lines
Quoted 15 lines
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.
Signed-off-by Hans de Goede <[email protected]>--- .../devicetree/bindings/usb/mmio-ohci.txt | 22 +++ drivers/usb/host/ohci-platform.c | 150 ++++++++++++++++++--- 2 files changed, 152 insertions(+), 20 deletions(-)create mode 100644
Documentation/devicetree/bindings/usb/mmio-ohci.txtQuoted 11 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 1
Quoted 8 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +1
-0@@ -0,0 +1,22 @@ +Generic MMIO OHCI controllerOHCI controller always uses MMIO, and likewise EHCI. You don't need to
specifically mention it.Quoted 2 lines
Right, I'm only using it here because it is also used in the compatible string.
Please drop it.
Quoted 12 lines
Quoted 5 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt line 4
Quoted 3 lines
Documentation/devicetree/bindings/usb/mmio-ohci.txt new file +3
-0+ +Required properties: +- compatible : "mmio-ohci"Likewise, it's not a good name. Why not call it "platform-ohci"?
Because, as you would have known had you read the entire thread, people objected
against exactly that name because the "platform" bus thing is a Linux invention,
and other operating systems don't use the platform nomenclature for non pci busses.
Quoted 2 lines
Quoted 2 lines
I wonder where were all those people when "xhci-platform" compatible got
adopted indrivers/usb/host/xhci-plat.c? :-P
I remember I suggested "usb-xhci" but the author didn't want to do it and
I said that I have no strong opinion (along with Alan Stern, IIRC), so we have it now...
Quoted 8 lines
Quoted 5 lines
Anyway, I want to suggest "usb-[eo]hci" of which "usb-ehci" binding has
even already documented inDocumentation/devicetree/bindings/usb/usb-ehci.txt. Both these "compatible" values are used as backups in the multiple described bindings of the platform-specific [EO]HCI controllers. I really don't see why you should invent anything new (and so poorly named).This too has already been discussed, again please read the entire thread including review of earlier versions of the patch.
Sorry, I have been generally lacking the time to read linux-usb recently.
I only bumped into your patch randomly, despite me being interested in this matter for my own platform...
Quoted 4 lines
We cannot usb usb-ehci, because the existing usb-ehci compatible string is not used for a generic usb controller, but
for a ppc specific one which needs model specific setup, see the driver currently implementing compatible = usb-ehci.
Not true about it being entirely PPC specific: the driver actually looks
for another "compatible" property to make it truly PPC specific (and apply some errata fixes for that specific PPC platform) and "usb-ehci" is used in many non-PPC binding examples as a backup still. Valentine Barshak's did his work on ehci-ppc-of.c when DT was used only on PPC and SPARC, so it was kind of a honest mistake on his part to name the driver so that people would think it's PPC specific (not only his, it seems, as the driver was based on the other two). This does not seem a fatal mistake, and we could limit the driver to match only on that IBM 440EPx platform it was designed for and tested on, making ehci-platform.c handle "usb-ehci". This is more work but I believe it's the Right Thing. The problem is that we'll have to do this atomically with ehci-platform.c change since 2 other PPC platforms use "usb-ehci" as a backup to their specific "compatible" props and don't have the platform-specific drivers for them, and we probably wouldn't want to break them.
I would like to help you here but the matter is not urgent for me, so cannot work on it right now... :-(
Anyway, I'm strongly against such names as "mmio-[eo]hci". But I could
live with just "[eo]hci" if you don't follow my advice and unravel the ehci-ppc-of.c knot...
Quoted 3 lines
Regards,
Hans
WBR, Sergei
Alan Stern
maintainerPATCH v3 1/2 ohci-platform: Add support for devicetree instantiation
In reply to Hans de GoedeQuoted 9 lines · Hans de Goede
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.
Signed-off-by Hans de Goede <[email protected]>
Looking pretty good. Still a couple of things to address...
drivers/usb/host/ohci-platform.c static int ohci_platform_reset(struct usb_hcd *hcd) · line 124
Quoted 5 lines
drivers/usb/host/ohci-platform.c +4
-0+static struct usb_ohci_pdata ohci_platform_defaults = { + .power_on = ohci_platform_power_on, + .power_suspend = ohci_platform_power_off, + .power_off = ohci_platform_power_off, };
I wonder if these routines couldn't be shared with non-DT setups. We could add an array of 3 struct clk pointers to the usb_ohci_pdata structure. Then if any of them are set, store these routines in the power_* pointers. (And likewise for ehci-platform.) Something to consider for a future patch...
Quoted 7 lines
drivers/usb/host/ohci-platform.c +1
-2@@ -60,12 +128,24 @@ static int ohci_platform_probe(struct platform_device *dev)struct usb_hcd *hcd;struct resource *res_mem;struct usb_ohci_pdata *pdata =dev_get_platdata (&dev->dev); -int irq; -int err = -ENOMEM ; +struct ohci_platform_priv *priv;
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 139
Quoted 10 lines
drivers/usb/host/ohci-platform.c +6
-2+int clk, irq, err; +/* +* Use reasonable defaults so platforms don't have to provide these +* with DT probing on ARM. +*/ if (!pdata) { -WARN_ON (1 ); -return -ENODEV ; + pdata = dev->dev.platform_data = &ohci_platform_defaults;
This has a subtle bug. Consider what will happen if ohci-platform is loaded, then unloaded and loaded again.
The existing ehci-platform driver has this same bug. I definitely remember discussing at once or twice in the past, but evidently it has never been fixed.
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 148
Quoted 9 lines
drivers/usb/host/ohci-platform.c +9
-0+/* +* 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. +*/ + err =dma_coerce_mask_and_coherent (&dev->dev, +DMA_BIT_MASK (32 )); +if (err) +return err;
The ehci-platform driver does this even when platform data is present. I guess you should do the same thing here (and lose the comment).
(Also, I dislike this alignment of the continuation line. IMO it's a bad idea to match up with some particular element of the preceding line. The style used in most of the USB stack is to indent continuation lines by two tab stops.)
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 151
Quoted 3 lines
drivers/usb/host/ohci-platform.c +0
-0}if (usb_disabled ())
This test belongs at the start of the function. It is more fundamental than the stuff you inserted.
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 171
Quoted 10 lines
drivers/usb/host/ohci-platform.c +6
-0@@ -83,17 +163,39 @@ static int ohci_platform_probe(struct platform_device *dev)return -ENXIO ; } + hcd =usb_create_hcd (&ohci_platform_hc_driver, &dev->dev, +dev_name (&dev->dev)); +if (!hcd) +return -ENOMEM ; + + priv = (struct ohci_platform_priv *)hcd_to_ohci (hcd)->priv;
Please define an inline routine or a macro for this messy computation.
Alan Stern
PATCH v3 1/2 ohci-platform: Add support for devicetree instantiation
Hi,
Quoted 14 lines · Alan Stern
Quoted 9 lines · Hans de Goede
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.
Signed-off-by Hans de Goede <[email protected]>Looking pretty good. Still a couple of things to address...
Quoted 11 lines
drivers/usb/host/ohci-platform.c static int ohci_platform_reset(struct usb_hcd *hcd) · line 124
Quoted 5 lines
drivers/usb/host/ohci-platform.c +4
-0+static struct usb_ohci_pdata ohci_platform_defaults = { + .power_on = ohci_platform_power_on, + .power_suspend = ohci_platform_power_off, + .power_off = ohci_platform_power_off, };I wonder if these routines couldn't be shared with non-DT setups. We could add an array of 3 struct clk pointers to the
usb_ohci_pdatastructure. Then if any of them are set, store these routines in the power_* pointers. (And likewise for ehci-platform.) Something to consider for a future patch...
I don't like automatically setting the power_ platform_data members much.
But I've already been thinking about moving the clks member to platform_data, and simply exporting ohci_platform_power_* so that other drivers can use them and put them in the platform_data members themselves. That is indeed something for another patch though.
Quoted 9 lines
Quoted 9 lines
drivers/usb/host/ohci-platform.c +2
-2@@ -60,12 +128,24 @@ static int ohci_platform_probe(struct platform_device *dev)struct usb_hcd *hcd;struct resource *res_mem;struct usb_ohci_pdata *pdata =dev_get_platdata (&dev->dev); -int irq; -int err = -ENOMEM ; +struct ohci_platform_priv *priv; +int clk, irq, err;
Quoted 11 lines
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 139
Quoted 8 lines
drivers/usb/host/ohci-platform.c +5
-2+/* +* Use reasonable defaults so platforms don't have to provide these +* with DT probing on ARM. +*/ if (!pdata) { -WARN_ON (1 ); -return -ENODEV ; + pdata = dev->dev.platform_data = &ohci_platform_defaults;This has a subtle bug. Consider what will happen if ohci-platform is loaded, then unloaded and loaded again.
Right, so we need to add a "dev->dev.platform_data == &ohci_platform_defaults" check on remove an then set platform_data to NULL, good point, will fix in the next version.
Quoted 4 lines
The existing ehci-platform driver has this same bug. I definitely remember discussing at once or twice in the past, but evidently it has never been fixed.
If you agree with the above fix I'll also throw it into the next revision of the ehci patch.
Quoted 14 lines
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 148
Quoted 10 lines
drivers/usb/host/ohci-platform.c +9
-0+/* +* 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. +*/ + err =dma_coerce_mask_and_coherent (&dev->dev, +DMA_BIT_MASK (32 )); +if (err) +return err;The ehci-platform driver does this even when platform data is present. I guess you should do the same thing here (and lose the comment).
Quoted 4 lines
(Also, I dislike this alignment of the continuation line. IMO it's a bad idea to match up with some particular element of the preceding line. The style used in most of the USB stack is to indent continuation lines by two tab stops.)
Ok, will fix.
Quoted 8 lines
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 151
Quoted 4 lines
drivers/usb/host/ohci-platform.c +0
-0}if (usb_disabled ())This test belongs at the start of the function. It is more fundamental than the stuff you inserted.
Ok, will fix.
Quoted 4 lines
Quoted 4 lines
drivers/usb/host/ohci-platform.c +0
-0@@ -83,17 +163,39 @@ static int ohci_platform_probe(struct platform_device *dev)return -ENXIO ; }
Quoted 8 lines
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 171
Quoted 6 lines
drivers/usb/host/ohci-platform.c +6
-0+ hcd =usb_create_hcd (&ohci_platform_hc_driver, &dev->dev, +dev_name (&dev->dev)); +if (!hcd) +return -ENOMEM ; + + priv = (struct ohci_platform_priv *)hcd_to_ohci (hcd)->priv;Please define an inline routine or a macro for this messy computation.
Ok, will fix.
Before I do a v4, one question:
Ma Haijun does not like the use of OHCI_MAX_CLKS:
Quoted 5 lines
drivers/usb/host/ohci-platform.c line 35
Quoted 1 line
drivers/usb/host/ohci-platform.c +1
-0+#define OHCI_MAX_CLKS 3I still recommend using
of_count_phandle_with_args(np, "clocks", "#clock-cells")to determine the number of clocks or the existence of clocks property (-ENOENT)
His suggestion would mean dynamically allocating the clks array and having clks_count variable. I still think this is a bit overkill, but I can do that for v4 if you want, so what do you prefer ?
Regards,
Hans
Alan Stern
maintainerPATCH v3 1/2 ohci-platform: Add support for devicetree instantiation
Quoted 12 lines · Hans de Goede
Quoted 11 lines
drivers/usb/host/ohci-platform.c static int ohci_platform_reset(struct usb_hcd *hcd) · line 124
Quoted 5 lines
drivers/usb/host/ohci-platform.c +4
-0+static struct usb_ohci_pdata ohci_platform_defaults = { + .power_on = ohci_platform_power_on, + .power_suspend = ohci_platform_power_off, + .power_off = ohci_platform_power_off, };I wonder if these routines couldn't be shared with non-DT setups. We could add an array of 3 struct clk pointers to the
usb_ohci_pdatastructure. Then if any of them are set, store these routines in the power_* pointers. (And likewise for ehci-platform.) Something to consider for a future patch...
Quoted 1 line
I don't like automatically setting the
power_platform_datamembers much.
Me either.
Quoted 4 lines
But I've already been thinking about moving the clks member to
platform_data, and simply exporting ohci_platform_power_* so that other drivers can use them and put them in theplatform_datamembers themselves. That is indeed something for another patch though.
It would require building ohci-platform into the kernel instead of making it a separate module. That shouldn't matter much for embedded/SoC systems, though. It seems like a good approach.
Quoted 11 lines
Quoted 7 lines
drivers/usb/host/ohci-platform.c static int ohci_platform_probe(struct platform_device *dev) · line 139
Quoted 4 lines
if (!pdata) {drivers/usb/host/ohci-platform.c +1
-2-WARN_ON (1 ); -return -ENODEV ; + pdata = dev->dev.platform_data = &ohci_platform_defaults;This has a subtle bug. Consider what will happen if ohci-platform is loaded, then unloaded and loaded again.
Right, so we need to add a "
dev->dev.platform_data==&ohci_platform_defaults" check on remove an then setplatform_datato NULL, good point, will fix in the next version.
Exactly.
Quoted 6 lines
Quoted 3 lines
The existing ehci-platform driver has this same bug. I definitely remember discussing at once or twice in the past, but evidently it has never been fixed.
If you agree with the above fix I'll also throw it into the next revision of the ehci patch.
Thank you.
Quoted 6 lines
Before I do a v4, one question:
Ma Haijun does not like the use of
OHCI_MAX_CLKS:Quoted 2 lines
Quoted 1 line
+#define
OHCI_MAX_CLKS3
Quoted 7 lines
Quoted 3 lines
I still recommend using
of_count_phandle_with_args(np, "clocks", "#clock-cells")to determine the number of clocks or the existence of clocks property (-ENOENT)His suggestion would mean dynamically allocating the clks array and having
clks_countvariable. I still think this is a bit overkill, but I can do that for v4 if you want, so what do you prefer ?
Space isn't a big consideration, because we're not likely to see a system with more a few controllers. I say keep it simple. If someone comes up with a controller using more than 3 clocks, we can change to dynamic allocation then.
Alan Stern
PATCH v3 2/2 ehci-platform: Add support for clks and phy passed through devicetree
In reply to Hans de GoedeCurrently 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.
Somehow we've ended up with 2 device-bindings documents for ehci-platform.c, this patch renames and updates one to mmio-ehci.txt to reflect that this is a generic ehci driver, and removes the other.
--- .../devicetree/bindings/usb/mmio-ehci.txt | 22 ++++ .../devicetree/bindings/usb/via,vt8500-ehci.txt | 15 --- .../devicetree/bindings/usb/vt8500-ehci.txt | 12 -- drivers/usb/host/ehci-platform.c | 129 +++++++++++++++++---- 4 files changed, 131 insertions(+), 47 deletions(-) create mode 100644 Documentation/devicetree/bindings/usb/mmio-ehci.txt 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/mmio-ehci.txt new file +22 -0
@@ -0,0 +1,22 @@ +Generic MMIO EHCI controller + +Required properties: +- compatible : "via,vt8500-ehci", "wm,prizm-ehci", or "mmio-ehci" +- reg : ehci controller register range (address and length) +- interrupts : ehci controller interrupt + +Optional properties: +- clocks : a list of phandle + clock specifier pairs +- phys : phandle + phy specifier pair +- phy-names : "usb" + +Example: + + ehci at d8007900 { + compatible = "via,vt8500-ehci", "mmio-ehci"; + reg = <0xd8007900 0x200>; + interrupts = <43>; + clocks = <&usb_clk 6>, <&ahb_gates 2>; + phys = <&usbphy 1>; + phy-names = "usb"; + };
Documentation/devicetree/bindings/usb/via,vt8500-ehci.txt deleted +0 -15
@@ -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
@@ -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/ehci-platform.c +109 -20
205 lines not on this page · raw message
Signature · 1 line
1.8.4.2