Skip to contentSkip to conversation

Allow xhci-plat using a second clock

PATCH New Gregory CLEMENT 4 participants 12 messages Feb 14, 2018 – Apr 19, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Allow xhci-plat using a second clock

Hello,

The purpose of this series is to allow xhci-plat using a second clock. It is needed on the Armada 7K/8K but could be used by other SoCs.

The first patch is just a fix found while I was working on this feature.

Thanks,

Gregory

Gregory CLEMENT (2):
usb: host: xhci-plat: Remove useless test before clk_disable_unprepare
usb: host: xhci-plat: Fix clock resource by adding a register clock

 Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 ++-
 drivers/usb/host/xhci-plat.c                       | 39 ++++++++++++++++------
 drivers/usb/host/xhci.h                            |  3 +-
 3 files changed, 35 insertions(+), 12 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/2 usb: host: xhci-plat: Remove useless test before clk_disable_unprepare

clk_disable_unprepare() already checks that the clock pointer is valid. No need to test it before calling it.

---
 drivers/usb/host/xhci-plat.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-plat.c +2 -4
index 6f038306c14d..79afaac57ef6 100644
@@ -319,8 +319,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	usb_put_hcd(xhci->shared_hcd);
 
 disable_clk:
-	if (!IS_ERR(clk))
-		clk_disable_unprepare(clk);
+	clk_disable_unprepare(clk);
 
 put_hcd:
 	usb_put_hcd(hcd);
@@ -346,8 +345,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 	usb_remove_hcd(hcd);
 	usb_put_hcd(xhci->shared_hcd);
 
-	if (!IS_ERR(clk))
-		clk_disable_unprepare(clk);
+	clk_disable_unprepare(clk);
 	usb_put_hcd(hcd);
 
 	pm_runtime_set_suspended(&dev->dev);
Signature · 1 line
2.15.1
#2 lore raw

PATCH 2/2 usb: host: xhci-plat: Fix clock resource by adding a register clock

In reply to Gregory CLEMENT

On Armada 7K/8K we need to explicitly enable the register clock. This clock is optional because not all the SoCs using this IP need it but at least for Armada 7K/8K it is actually mandatory.

The change was done at xhci-plat level and not at a xhci-mvebu.c because, it is expected that other SoC would have this kind of constraint.

The binding documentation is updating accordingly.

---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 +++-
 drivers/usb/host/xhci-plat.c                       | 33 ++++++++++++++++++----
 drivers/usb/host/xhci.h                            |  3 +-
 3 files changed, 33 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/usb/usb-xhci.txt +4 -1
index e2ea59bbca93..e4b14511f4f8 100644
@@ -27,7 +27,10 @@ Required properties:
   - interrupts: one XHCI interrupt should be described here.
 
 Optional properties:
-  - clocks: reference to a clock
+  - clocks: reference to the clocks
+  - clock-names: mandatory if there is a second clock, in this case
+    the name must be "core" for the first clock and "reg" for the
+    second one
   - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
   - quirk-broken-port-ped: set if the controller has broken port disable mechanism
drivers/usb/host/xhci-plat.c +27 -6
index 79afaac57ef6..fd0c399013a2 100644
@@ -157,6 +157,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	struct resource         *res;
 	struct usb_hcd		*hcd;
 	struct clk              *clk;
+	struct clk              *reg_clk;
 	int			ret;
 	int			irq;
 
@@ -226,17 +227,27 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	hcd->rsrc_len = resource_size(res);
 
 	/*
-	 * Not all platforms have a clk so it is not an error if the
-	 * clock does not exists.
+	 * Not all platforms have clks so it is not an error if the
+	 * clock do not exist.
 	 */
+	reg_clk = devm_clk_get(&pdev->dev, "reg");
+	if (!IS_ERR(reg_clk)) {
+		ret = clk_prepare_enable(reg_clk);
+		if (ret)
+			goto put_hcd;
+	} else if (PTR_ERR(reg_clk) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto put_hcd;
+	}
+
 	clk = devm_clk_get(&pdev->dev, NULL);
 	if (!IS_ERR(clk)) {
 		ret = clk_prepare_enable(clk);
 		if (ret)
-			goto put_hcd;
+			goto disable_reg_clk;
 	} else if (PTR_ERR(clk) == -EPROBE_DEFER) {
 		ret = -EPROBE_DEFER;
-		goto put_hcd;
+		goto disable_reg_clk;
 	}
 
 	xhci = hcd_to_xhci(hcd);
@@ -252,6 +263,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	device_wakeup_enable(hcd->self.controller);
 
 	xhci->clk = clk;
+	xhci->reg_clk = reg_clk;
 	xhci->main_hcd = hcd;
 	xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev,
 			dev_name(&pdev->dev), hcd);
@@ -321,6 +333,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
 disable_clk:
 	clk_disable_unprepare(clk);
 
+disable_reg_clk:
+	clk_disable_unprepare(reg_clk);
+
 put_hcd:
 	usb_put_hcd(hcd);
 
@@ -336,6 +351,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 	struct usb_hcd	*hcd = platform_get_drvdata(dev);
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	struct clk *clk = xhci->clk;
+	struct clk *reg_clk = xhci->reg_clk;
 
 	xhci->xhc_state |= XHCI_STATE_REMOVING;
 
@@ -346,6 +362,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 	usb_put_hcd(xhci->shared_hcd);
 
 	clk_disable_unprepare(clk);
+	clk_disable_unprepare(reg_clk);
 	usb_put_hcd(hcd);
 
 	pm_runtime_set_suspended(&dev->dev);
@@ -370,8 +387,10 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
 	 */
 	ret = xhci_suspend(xhci, device_may_wakeup(dev));
 
-	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
+	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) {
 		clk_disable_unprepare(xhci->clk);
+		clk_disable_unprepare(xhci->reg_clk);
+	}
 
 	return ret;
 }
@@ -382,8 +401,10 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	int ret;
 
-	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
+	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) {
+		clk_prepare_enable(xhci->reg_clk);
 		clk_prepare_enable(xhci->clk);
+	}
 
 	ret = xhci_priv_resume_quirk(hcd);
 	if (ret)
drivers/usb/host/xhci.h +2 -1
index 96099a245c69..9884aaba1b40 100644
@@ -1726,8 +1726,9 @@ struct xhci_hcd {
 	int		page_shift;
 	/* msi-x vectors */
 	int		msix_count;
-	/* optional clock */
+	/* optional clocks */
 	struct clk		*clk;
+	struct clk		*reg_clk;
 	/* data structures */
 	struct xhci_device_context_array *dcbaa;
 	struct xhci_ring	*cmd_ring;
Signature · 1 line
2.15.1
maintainer
#3 lore raw

PATCH 2/2 usb: host: xhci-plat: Fix clock resource by adding a register clock

Quoted 22 lines · Gregory CLEMENT

On Armada 7K/8K we need to explicitly enable the register clock. This clock is optional because not all the SoCs using this IP need it but at least for Armada 7K/8K it is actually mandatory.

The change was done at xhci-plat level and not at a xhci-mvebu.c because, it is expected that other SoC would have this kind of constraint.

The binding documentation is updating accordingly.

---
  Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 +++-
  drivers/usb/host/xhci-plat.c                       | 33 ++++++++++++++++++----
  drivers/usb/host/xhci.h                            |  3 +-
  3 files changed, 33 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/usb/usb-xhci.txt +0 -0
index e2ea59bbca93..e4b14511f4f8 100644
@@ -27,7 +27,10 @@ Required properties:
    - interrupts: one XHCI interrupt should be described here.

Documentation/devicetree/bindings/usb/usb-xhci.txt Required properties: · line 36

Quoted 10 lines
Documentation/devicetree/bindings/usb/usb-xhci.txt +4 -1
 
  Optional properties:
-  - clocks: reference to a clock
+  - clocks: reference to the clocks
+  - clock-names: mandatory if there is a second clock, in this case
+    the name must be "core" for the first clock and "reg" for the
+    second one
    - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM
    - usb3-lpm-capable: determines if platform is USB3 LPM capable
    - quirk-broken-port-ped: set if the controller has broken port disable mechanism

Would be good to get a Ack or review by Rob Herring for the above

Quoted 45 lines
drivers/usb/host/xhci-plat.c +15 -4
index 79afaac57ef6..fd0c399013a2 100644
@@ -157,6 +157,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
  	struct resource         *res;
  	struct usb_hcd		*hcd;
  	struct clk              *clk;
+	struct clk              *reg_clk;
  	int			ret;
  	int			irq;
 
@@ -226,17 +227,27 @@ static int xhci_plat_probe(struct platform_device *pdev)
  	hcd->rsrc_len = resource_size(res);
 
  	/*
-	 * Not all platforms have a clk so it is not an error if the
-	 * clock does not exists.
+	 * Not all platforms have clks so it is not an error if the
+	 * clock do not exist.
  	 */
+	reg_clk = devm_clk_get(&pdev->dev, "reg");
+	if (!IS_ERR(reg_clk)) {
+		ret = clk_prepare_enable(reg_clk);
+		if (ret)
+			goto put_hcd;
+	} else if (PTR_ERR(reg_clk) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto put_hcd;
+	}
+
  	clk = devm_clk_get(&pdev->dev, NULL);
  	if (!IS_ERR(clk)) {
  		ret = clk_prepare_enable(clk);
  		if (ret)
-			goto put_hcd;
+			goto disable_reg_clk;
  	} else if (PTR_ERR(clk) == -EPROBE_DEFER) {
  		ret = -EPROBE_DEFER;
-		goto put_hcd;
+		goto disable_reg_clk;
  	}
 
  	xhci = hcd_to_xhci(hcd);

drivers/usb/host/xhci-plat.c static int xhci_plat_probe(struct platform_device *pdev) · line 268

Quoted 6 lines
drivers/usb/host/xhci-plat.c +1 -0
@@ -252,6 +263,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
  	device_wakeup_enable(hcd->self.controller);
 
  	xhci->clk = clk;
+	xhci->reg_clk = reg_clk;
  	xhci->main_hcd = hcd;
  	xhci->shared_hcd = __usb_create_

hcd(driver, sysdev, &pdev->dev,

Quoted 57 lines
drivers/usb/host/xhci-plat.c +11 -2
  			dev_name(&pdev->dev), hcd);
@@ -321,6 +333,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
  disable_clk:
  	clk_disable_unprepare(clk);
 
+disable_reg_clk:
+	clk_disable_unprepare(reg_clk);
+
  put_hcd:
  	usb_put_hcd(hcd);
 
@@ -336,6 +351,7 @@ static int xhci_plat_remove(struct platform_device *dev)
  	struct usb_hcd	*hcd = platform_get_drvdata(dev);
  	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
  	struct clk *clk = xhci->clk;
+	struct clk *reg_clk = xhci->reg_clk;
 
  	xhci->xhc_state |= XHCI_STATE_REMOVING;
 
@@ -346,6 +362,7 @@ static int xhci_plat_remove(struct platform_device *dev)
  	usb_put_hcd(xhci->shared_hcd);
 
  	clk_disable_unprepare(clk);
+	clk_disable_unprepare(reg_clk);
  	usb_put_hcd(hcd);
 
  	pm_runtime_set_suspended(&dev->dev);
@@ -370,8 +387,10 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
  	 */
  	ret = xhci_suspend(xhci, device_may_wakeup(dev));
 
-	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
+	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) {
  		clk_disable_unprepare(xhci->clk);
+		clk_disable_unprepare(xhci->reg_clk);
+	}
 
  	return ret;
  }
@@ -382,8 +401,10 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
  	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
  	int ret;
 
-	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
+	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) {
+		clk_prepare_enable(xhci->reg_clk);
  		clk_prepare_enable(xhci->clk);
+	}
 
  	ret = xhci_priv_resume_quirk(hcd);
  	if (ret)
drivers/usb/host/xhci.h +0 -0
index 96099a245c69..9884aaba1b40 100644

drivers/usb/host/xhci.h struct xhci_hcd { · line 1734

Quoted 10 lines
drivers/usb/host/xhci.h +2 -1
@@ -1726,8 +1726,9 @@ struct xhci_hcd {
  	int		page_shift;
  	/* msi-x vectors */
  	int		msix_count;
-	/* optional clock */
+	/* optional clocks */
  	struct clk		*clk;
+	struct clk		*reg_clk;
  	/* data structures */
  	struct xhci_device_context_array *dcbaa;
  	struct xhci_ring	*cmd_ring;

Looks good to me, I'll queue it up if the devicetree bindings looks ok for Rob Herring

-Mathias

#4 lore raw

PATCH 2/2 usb: host: xhci-plat: Fix clock resource by adding a register clock

Hi Rob,

Quoted 26 lines · Mathias Nyman
Quoted 25 lines · Gregory CLEMENT

On Armada 7K/8K we need to explicitly enable the register clock. This clock is optional because not all the SoCs using this IP need it but at least for Armada 7K/8K it is actually mandatory.

The change was done at xhci-plat level and not at a xhci-mvebu.c because, it is expected that other SoC would have this kind of constraint.

The binding documentation is updating accordingly.

---
  Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 +++-
  drivers/usb/host/xhci-plat.c                       | 33 ++++++++++++++++++----
  drivers/usb/host/xhci.h                            |  3 +-
  3 files changed, 33 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/usb/usb-xhci.txt +1 -1
index e2ea59bbca93..e4b14511f4f8 100644
@@ -27,7 +27,10 @@ Required properties:
    - interrupts: one XHCI interrupt should be described here.
    Optional properties:
-  - clocks: reference to a clock
+  - clocks: reference to the clocks
Quoted 8 lines

Documentation/devicetree/bindings/usb/usb-xhci.txt Required properties: · line 36

Quoted 6 lines
Documentation/devicetree/bindings/usb/usb-xhci.txt +3 -0
+  - clock-names: mandatory if there is a second clock, in this case
+    the name must be "core" for the first clock and "reg" for the
+    second one
    - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM
    - usb3-lpm-capable: determines if platform is USB3 LPM capable
    - quirk-broken-port-ped: set if the controller has broken port disable mechanism

Would be good to get a Ack or review by Rob Herring for the above

Would you mind to have a look on this binding update ?

Initially I didn't copy you trying to not overflow you because this change is only about adding a new clock, which is pretty common. But I think Mathias would be more confident with a Ack or review by you.

Thanks,

Gregory

Quoted 115 lines
Quoted 44 lines
drivers/usb/host/xhci-plat.c +1 -0
index 79afaac57ef6..fd0c399013a2 100644
@@ -157,6 +157,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
  	struct resource         *res;
  	struct usb_hcd		*hcd;
  	struct clk              *clk;
+	struct clk              *reg_clk;
  	int			ret;
  	int			irq;
  @@ -226,17 +227,27 @@ static int xhci_plat_probe(struct

platform_device *pdev)

  	hcd->rsrc_len = resource_size(res);
    	/*
drivers/usb/host/xhci-plat.c +14 -4
-	 * Not all platforms have a clk so it is not an error if the
-	 * clock does not exists.
+	 * Not all platforms have clks so it is not an error if the
+	 * clock do not exist.
  	 */
+	reg_clk = devm_clk_get(&pdev->dev, "reg");
+	if (!IS_ERR(reg_clk)) {
+		ret = clk_prepare_enable(reg_clk);
+		if (ret)
+			goto put_hcd;
+	} else if (PTR_ERR(reg_clk) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto put_hcd;
+	}
+
  	clk = devm_clk_get(&pdev->dev, NULL);
  	if (!IS_ERR(clk)) {
  		ret = clk_prepare_enable(clk);
  		if (ret)
-			goto put_hcd;
+			goto disable_reg_clk;
  	} else if (PTR_ERR(clk) == -EPROBE_DEFER) {
  		ret = -EPROBE_DEFER;
-		goto put_hcd;
+		goto disable_reg_clk;
  	}
    	xhci = hcd_to_xhci(hcd);

drivers/usb/host/xhci-plat.c static int xhci_plat_probe(struct platform_device *pdev) · line 267

Quoted 5 lines
drivers/usb/host/xhci-plat.c +1 -0
@@ -252,6 +263,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
  	device_wakeup_enable(hcd->self.controller);
    	xhci->clk = clk;
+	xhci->reg_clk = reg_clk;
  	xhci->main_hcd = hcd;
  	xhci->shared_hcd = __usb_create_

hcd(driver, sysdev, &pdev->dev,

Quoted 49 lines
drivers/usb/host/xhci-plat.c +2 -0
  			dev_name(&pdev->dev), hcd);
@@ -321,6 +333,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
  disable_clk:
  	clk_disable_unprepare(clk);
  +disable_reg_clk:
+	clk_disable_unprepare(reg_clk);
+
  put_hcd:
  	usb_put_hcd(hcd);
  @@ -336,6 +351,7 @@ static int xhci_plat_remove(struct

platform_device *dev)
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct clk *clk = xhci->clk;

drivers/usb/host/xhci-plat.c +1 -0
+	struct clk *reg_clk = xhci->reg_clk;
    	xhci->xhc_state |= XHCI_STATE_REMOVING;
  @@ -346,6 +362,7 @@ static int xhci_plat_remove(struct

platform_device *dev)

  	usb_put_hcd(xhci->shared_hcd);
    	clk_disable_unprepare(clk);
drivers/usb/host/xhci-plat.c +7 -0
+	clk_disable_unprepare(reg_clk);
  	usb_put_hcd(hcd);
    	pm_runtime_set_suspended(&dev->dev);
@@ -370,8 +387,10 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
  	 */
  	ret = xhci_suspend(xhci, device_may_wakeup(dev));
  -	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
+	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) {
  		clk_disable_unprepare(xhci->clk);
+		clk_disable_unprepare(xhci->reg_clk);
+	}
    	return ret;
  }
@@ -382,8 +401,10 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
  	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
  	int ret;
  -	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
+	if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) {
+		clk_prepare_enable(xhci->reg_clk);
  		clk_prepare_enable(xhci->clk);
+	}
    	ret = xhci_priv_resume_quirk(hcd);
  	if (ret)
drivers/usb/host/xhci.h +0 -0
index 96099a245c69..9884aaba1b40 100644

drivers/usb/host/xhci.h struct xhci_hcd { · line 1734

Quoted 10 lines
drivers/usb/host/xhci.h +2 -1
@@ -1726,8 +1726,9 @@ struct xhci_hcd {
  	int		page_shift;
  	/* msi-x vectors */
  	int		msix_count;
-	/* optional clock */
+	/* optional clocks */
  	struct clk		*clk;
+	struct clk		*reg_clk;
  	/* data structures */
  	struct xhci_device_context_array *dcbaa;
  	struct xhci_ring	*cmd_ring;

Looks good to me, I'll queue it up if the devicetree bindings looks ok for Rob Herring

-Mathias

Signature · 3 lines
Gregory Clement, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#5 lore raw

PATCH 2/2 usb: host: xhci-plat: Fix clock resource by adding a register clock

In reply to Mathias Nyman

Hi Rob,

(resent because of malformed cc list)

Quoted 26 lines · Mathias Nyman
Quoted 25 lines · Gregory CLEMENT

On Armada 7K/8K we need to explicitly enable the register clock. This clock is optional because not all the SoCs using this IP need it but at least for Armada 7K/8K it is actually mandatory.

The change was done at xhci-plat level and not at a xhci-mvebu.c because, it is expected that other SoC would have this kind of constraint.

The binding documentation is updating accordingly.

---
  Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 +++-
  drivers/usb/host/xhci-plat.c                       | 33 ++++++++++++++++++----
  drivers/usb/host/xhci.h                            |  3 +-
  3 files changed, 33 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/usb/usb-xhci.txt +1 -1
index e2ea59bbca93..e4b14511f4f8 100644
@@ -27,7 +27,10 @@ Required properties:
    - interrupts: one XHCI interrupt should be described here.
    Optional properties:
-  - clocks: reference to a clock
+  - clocks: reference to the clocks
Quoted 8 lines

Documentation/devicetree/bindings/usb/usb-xhci.txt Required properties: · line 36

Quoted 6 lines
Documentation/devicetree/bindings/usb/usb-xhci.txt +3 -0
+  - clock-names: mandatory if there is a second clock, in this case
+    the name must be "core" for the first clock and "reg" for the
+    second one
    - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM
    - usb3-lpm-capable: determines if platform is USB3 LPM capable
    - quirk-broken-port-ped: set if the controller has broken port disable mechanism

Would be good to get a Ack or review by Rob Herring for the above

Would you mind to have a look on this binding update ?

Initially I didn't copy you trying to not overflow you because this change is only about adding a new clock, which is pretty common. But I think Mathias would be more confident with a Ack or review by you.

Thanks,

Gregory

Signature · 3 lines
Gregory Clement, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#6 lore raw

PATCH 2/2 usb: host: xhci-plat: Fix clock resource by adding a register clock

In reply to Gregory CLEMENT

Hi,

Quoted 53 lines · Gregory CLEMENT

On Armada 7K/8K we need to explicitly enable the register clock. This clock is optional because not all the SoCs using this IP need it but at least for Armada 7K/8K it is actually mandatory.

The change was done at xhci-plat level and not at a xhci-mvebu.c because, it is expected that other SoC would have this kind of constraint.

The binding documentation is updating accordingly.

---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 +++-
 drivers/usb/host/xhci-plat.c                       | 33 ++++++++++++++++++----
 drivers/usb/host/xhci.h                            |  3 +-
 3 files changed, 33 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/usb/usb-xhci.txt +4 -1
index e2ea59bbca93..e4b14511f4f8 100644
@@ -27,7 +27,10 @@ Required properties:
   - interrupts: one XHCI interrupt should be described here.
 
 Optional properties:
-  - clocks: reference to a clock
+  - clocks: reference to the clocks
+  - clock-names: mandatory if there is a second clock, in this case
+    the name must be "core" for the first clock and "reg" for the
+    second one
   - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
   - quirk-broken-port-ped: set if the controller has broken port disable mechanism
drivers/usb/host/xhci-plat.c +3 -2
index 79afaac57ef6..fd0c399013a2 100644
@@ -157,6 +157,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	struct resource         *res;
 	struct usb_hcd		*hcd;
 	struct clk              *clk;
+	struct clk              *reg_clk;
 	int			ret;
 	int			irq;
 
@@ -226,17 +227,27 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	hcd->rsrc_len = resource_size(res);
 
 	/*
-	 * Not all platforms have a clk so it is not an error if the
-	 * clock does not exists.
+	 * Not all platforms have clks so it is not an error if the
+	 * clock do not exist.
 	 */

drivers/usb/host/xhci-plat.c static int xhci_plat_probe(struct platform_device *pdev) · line 242

Quoted 10 lines
drivers/usb/host/xhci-plat.c +10 -0
+	reg_clk = devm_clk_get(&pdev->dev, "reg");
+	if (!IS_ERR(reg_clk)) {
+		ret = clk_prepare_enable(reg_clk);
+		if (ret)
+			goto put_hcd;
+	} else if (PTR_ERR(reg_clk) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto put_hcd;
+	}
+

How about using clk_bulk_ APIs?

Quoted 4 lines
drivers/usb/host/xhci-plat.c +0 -0
 	clk = devm_clk_get(&pdev->dev, NULL);
 	if (!IS_ERR(clk)) {
 		ret = clk_prepare_enable(clk);
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#7 lore raw

PATCH 2/2 usb: host: xhci-plat: Fix clock resource by adding a register clock

Hi Manu,

Quoted 61 lines · Manu Gautam

Hi,

Quoted 57 lines · Gregory CLEMENT

On Armada 7K/8K we need to explicitly enable the register clock. This clock is optional because not all the SoCs using this IP need it but at least for Armada 7K/8K it is actually mandatory.

The change was done at xhci-plat level and not at a xhci-mvebu.c because, it is expected that other SoC would have this kind of constraint.

The binding documentation is updating accordingly.

---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 +++-
 drivers/usb/host/xhci-plat.c                       | 33 ++++++++++++++++++----
 drivers/usb/host/xhci.h                            |  3 +-
 3 files changed, 33 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/usb/usb-xhci.txt +4 -1
index e2ea59bbca93..e4b14511f4f8 100644
@@ -27,7 +27,10 @@ Required properties:
   - interrupts: one XHCI interrupt should be described here.
 
 Optional properties:
-  - clocks: reference to a clock
+  - clocks: reference to the clocks
+  - clock-names: mandatory if there is a second clock, in this case
+    the name must be "core" for the first clock and "reg" for the
+    second one
   - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
   - quirk-broken-port-ped: set if the controller has broken port disable mechanism
drivers/usb/host/xhci-plat.c +7 -2
index 79afaac57ef6..fd0c399013a2 100644
@@ -157,6 +157,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	struct resource         *res;
 	struct usb_hcd		*hcd;
 	struct clk              *clk;
+	struct clk              *reg_clk;
 	int			ret;
 	int			irq;
 
@@ -226,17 +227,27 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	hcd->rsrc_len = resource_size(res);
 
 	/*
-	 * Not all platforms have a clk so it is not an error if the
-	 * clock does not exists.
+	 * Not all platforms have clks so it is not an error if the
+	 * clock do not exist.
 	 */
+	reg_clk = devm_clk_get(&pdev->dev, "reg");
+	if (!IS_ERR(reg_clk)) {
+		ret = clk_prepare_enable(reg_clk);
+		if (ret)
Quoted 8 lines

drivers/usb/host/xhci-plat.c static int xhci_plat_probe(struct platform_device *pdev) · line 242

Quoted 6 lines
drivers/usb/host/xhci-plat.c +6 -0
+			goto put_hcd;
+	} else if (PTR_ERR(reg_clk) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto put_hcd;
+	}
+

How about using clk_bulk_ APIs?

I didn't know this API, but after having a look on it, it didn't match what I need. Indeed the second clock is "optional" to handle the backward compatibility. With the clk_bulk_ APIS all the clocks are mandatory.

Thanks,

Gregory

Quoted 15 lines
Quoted 5 lines
drivers/usb/host/xhci-plat.c +0 -0
 	clk = devm_clk_get(&pdev->dev, NULL);
 	if (!IS_ERR(clk)) {
 		ret = clk_prepare_enable(clk);
 
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 3 lines
Gregory Clement, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#8 lore raw

cover Allow xhci-plat using a second clock

In reply to Gregory CLEMENT

Hi Mathias,

Quoted 5 lines · Gregory CLEMENT

Hello,

The purpose of this series is to allow xhci-plat using a second clock. It is needed on the Armada 7K/8K but could be used by other SoCs.

Do you have some comments on this series and especially on the second patch?

Thanks,

Gregory

Quoted 21 lines

The first patch is just a fix found while I was working on this feature.

Thanks,

Gregory

Gregory CLEMENT (2):
usb: host: xhci-plat: Remove useless test before clk_disable_unprepare
usb: host: xhci-plat: Fix clock resource by adding a register clock

 Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 ++-
 drivers/usb/host/xhci-plat.c                       | 39 ++++++++++++++++------
 drivers/usb/host/xhci.h                            |  3 +-
 3 files changed, 35 insertions(+), 12 deletions(-)
Signature · 1 line
2.15.1
Signature · 3 lines
Gregory Clement, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#9 lore raw

cover Allow xhci-plat using a second clock

In reply to Gregory CLEMENT

Hi Mathias,

Quoted 8 lines · Gregory CLEMENT

Hello,

The purpose of this series is to allow xhci-plat using a second clock. It is needed on the Armada 7K/8K but could be used by other SoCs.

The first patch is just a fix found while I was working on this feature.

I've just realized that this series sent 2 months ago was not merged in v4.17. The issue is that now the USB support on the Armada 7K/8K is broken, because the clock support part was already merged.

You already had a look on this series one month ago. The issue you had was about getting an approval for the extension of the binding [1]. I pinged Rob about it [2] one month ago but we didn't get any feedback. However, Rob already approved the similar changes I introduced in an other for mv_xor_v2: [3].

So would it be possible to apply this series on v4.17-rc ?

Thanks,

Gregory

[1]:
http://lists.infradead.org/pipermail/linux-arm-kernel/2018-February/562739.html

[2]:
http://lists.infradead.org/pipermail/linux-arm-kernel/2018-March/566076.html

[3]:
http://lists.infradead.org/pipermail/linux-arm-kernel/2018-March/564594.html

Quoted 23 lines

Thanks,

Gregory

Gregory CLEMENT (2):
usb: host: xhci-plat: Remove useless test before clk_disable_unprepare
usb: host: xhci-plat: Fix clock resource by adding a register clock

 Documentation/devicetree/bindings/usb/usb-xhci.txt |  5 ++-
 drivers/usb/host/xhci-plat.c                       | 39 ++++++++++++++++------
 drivers/usb/host/xhci.h                            |  3 +-
 3 files changed, 35 insertions(+), 12 deletions(-)
Signature · 7 lines
2.15.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 3 lines
Gregory Clement, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
#10 lore raw

cover Allow xhci-plat using a second clock

Quoted 17 lines · Gregory CLEMENT

Hi Mathias,

Quoted 8 lines · Gregory CLEMENT

Hello,

The purpose of this series is to allow xhci-plat using a second clock. It is needed on the Armada 7K/8K but could be used by other SoCs.

The first patch is just a fix found while I was working on this feature.

I've just realized that this series sent 2 months ago was not merged in v4.17. The issue is that now the USB support on the Armada 7K/8K is broken, because the clock support part was already merged.

Quoted 7 lines

You already had a look on this series one month ago. The issue you had was about getting an approval for the extension of the binding [1]. I pinged Rob about it [2] one month ago but we didn't get any feedback. However, Rob already approved the similar changes I introduced in an other for mv_xor_v2: [3].

So would it be possible to apply this series on v4.17-rc ?

Patch 2/2 no longer applies due to clk suspend/resume changes in:

commit d56e57ca030c8b4296944a2ae61ac167bf979c07
usb: host: xhci-plat: revert "usb: host: xhci-plat: enable clk in resume timing"

Not sure how that change affects Armada 7K/8K
Can you rebase and resend the series?

-Mathias

#11 lore raw

cover Allow xhci-plat using a second clock

Hi Mathias,

Quoted 26 lines · Mathias Nyman
Quoted 17 lines · Gregory CLEMENT

Hi Mathias,

    On mer., f?vr. 14 2018, Gregory CLEMENT
Quoted 8 lines · <[email protected]> wrote:

Hello,

The purpose of this series is to allow xhci-plat using a second clock. It is needed on the Armada 7K/8K but could be used by other SoCs.

The first patch is just a fix found while I was working on this feature.

I've just realized that this series sent 2 months ago was not merged in v4.17. The issue is that now the USB support on the Armada 7K/8K is broken, because the clock support part was already merged.

Quoted 7 lines

You already had a look on this series one month ago. The issue you had was about getting an approval for the extension of the binding [1]. I pinged Rob about it [2] one month ago but we didn't get any feedback. However, Rob already approved the similar changes I introduced in an other for mv_xor_v2: [3].

So would it be possible to apply this series on v4.17-rc ?

Quoted 7 lines

Patch 2/2 no longer applies due to clk suspend/resume changes in:

commit d56e57ca030c8b4296944a2ae61ac167bf979c07
usb: host: xhci-plat: revert "usb: host: xhci-plat: enable clk in resume timing"

Not sure how that change affects Armada 7K/8K
Can you rebase and resend the series?

It's done!

About the suspend/resume part it does not affect Armada 7K/8K because we don't support it yet.

However I am a bit surprised by the commit log because reverting a common part because of a specific implementation looks wrong. I expect issues when we will add PM support but we will see that later.

Gregory

Quoted 3 lines

-Mathias

Signature · 3 lines
Gregory Clement, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com