2017-08-02 20:18:35

by Franklin S Cooper Jr

[permalink] [raw]
Subject: [PATCH 0/3] ARM: dts: k2g: Add support for USB instances on 66AK2G

Add support for 66AK2G usb instances. However, the driver needs to be updated
to support PM_RUNTIME. This update has been validated to work on K2L and boot
tested on K2HK and K2E.

Franklin S Cooper Jr (2):
usb: dwc3: keystone: Add PM_RUNTIME Support to DWC3 Keystone USB
driver
dt-bindings: usb: keystone-usb: Update bindings pm and clocks
properties

Vitaly Andrianov (1):
ARM: dts: k2g: Add USB instances

.../devicetree/bindings/usb/keystone-usb.txt | 18 ++++++-
arch/arm/boot/dts/keystone-k2g.dtsi | 56 ++++++++++++++++++++++
drivers/usb/dwc3/dwc3-keystone.c | 22 ++++-----
3 files changed, 82 insertions(+), 14 deletions(-)

--
2.9.4.dirty


2017-08-02 20:18:40

by Franklin S Cooper Jr

[permalink] [raw]
Subject: [PATCH 1/3] usb: dwc3: keystone: Add PM_RUNTIME Support to DWC3 Keystone USB driver

For 66AK2Gx there is a requirement to use PM Runtime to properly manage
clocks and the power domains. Therefore, add PM runtime support. Remove
legacy clock api's calls since other users of this driver worked without
these clock apis calls.

Signed-off-by: Franklin S Cooper Jr <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
drivers/usb/dwc3/dwc3-keystone.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c
index 12ee23f..d2ed952 100644
--- a/drivers/usb/dwc3/dwc3-keystone.c
+++ b/drivers/usb/dwc3/dwc3-keystone.c
@@ -15,7 +15,6 @@
* GNU General Public License for more details.
*/

-#include <linux/clk.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
@@ -23,6 +22,7 @@
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/of_platform.h>
+#include <linux/pm_runtime.h>

/* USBSS register offsets */
#define USBSS_REVISION 0x0000
@@ -41,7 +41,6 @@

struct dwc3_keystone {
struct device *dev;
- struct clk *clk;
void __iomem *usbss;
};

@@ -106,17 +105,13 @@ static int kdwc3_probe(struct platform_device *pdev)
if (IS_ERR(kdwc->usbss))
return PTR_ERR(kdwc->usbss);

- kdwc->clk = devm_clk_get(kdwc->dev, "usb");
- if (IS_ERR(kdwc->clk)) {
- dev_err(kdwc->dev, "unable to get usb clock\n");
- return PTR_ERR(kdwc->clk);
- }
+ pm_runtime_enable(kdwc->dev);

- error = clk_prepare_enable(kdwc->clk);
+ error = pm_runtime_get_sync(kdwc->dev);
if (error < 0) {
- dev_err(kdwc->dev, "unable to enable usb clock, error %d\n",
+ dev_err(kdwc->dev, "pm_runtime_get_sync failed, error %d\n",
error);
- return error;
+ goto err_irq;
}

irq = platform_get_irq(pdev, 0);
@@ -147,7 +142,8 @@ static int kdwc3_probe(struct platform_device *pdev)
err_core:
kdwc3_disable_irqs(kdwc);
err_irq:
- clk_disable_unprepare(kdwc->clk);
+ pm_runtime_put_sync(kdwc->dev);
+ pm_runtime_disable(kdwc->dev);

return error;
}
@@ -167,7 +163,9 @@ static int kdwc3_remove(struct platform_device *pdev)

kdwc3_disable_irqs(kdwc);
device_for_each_child(&pdev->dev, NULL, kdwc3_remove_core);
- clk_disable_unprepare(kdwc->clk);
+ pm_runtime_put_sync(kdwc->dev);
+ pm_runtime_disable(kdwc->dev);
+
platform_set_drvdata(pdev, NULL);

return 0;
--
2.9.4.dirty

2017-08-02 20:18:38

by Franklin S Cooper Jr

[permalink] [raw]
Subject: [PATCH 3/3] ARM: dts: k2g: Add USB instances

From: Vitaly Andrianov <[email protected]>

Add nodes for both USB instances supported by 66AK2G.

[[email protected]: Add power domain and clock properties]
Signed-off-by: Dave Gerlach <[email protected]>
[[email protected]: Update commit message and subject]
Signed-off-by: Franklin S Cooper Jr <[email protected]>
---
arch/arm/boot/dts/keystone-k2g.dtsi | 56 +++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)

diff --git a/arch/arm/boot/dts/keystone-k2g.dtsi b/arch/arm/boot/dts/keystone-k2g.dtsi
index bf4d1fa..b206b69 100644
--- a/arch/arm/boot/dts/keystone-k2g.dtsi
+++ b/arch/arm/boot/dts/keystone-k2g.dtsi
@@ -168,5 +168,61 @@
#reset-cells = <2>;
};
};
+
+ usb0_phy: usb-phy@0 {
+ compatible = "usb-nop-xceiv";
+ status = "disabled";
+ };
+
+ keystone_usb0: keystone-dwc3@2680000 {
+ compatible = "ti,keystone-dwc3";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ reg = <0x2680000 0x10000>;
+ interrupts = <GIC_SPI 128 IRQ_TYPE_EDGE_RISING>;
+ ranges;
+ dma-coherent;
+ dma-ranges;
+ status = "disabled";
+ power-domains = <&k2g_pds 0x0016>;
+
+ usb0: usb@2690000 {
+ compatible = "snps,dwc3";
+ reg = <0x2690000 0x10000>;
+ interrupts = <GIC_SPI 128 IRQ_TYPE_EDGE_RISING>;
+ maximum-speed = "high-speed";
+ dr_mode = "otg";
+ usb-phy = <&usb0_phy>;
+ status = "disabled";
+ };
+ };
+
+ usb1_phy: usb-phy@1 {
+ compatible = "usb-nop-xceiv";
+ status = "disabled";
+ };
+
+ keystone_usb1: keystone-dwc3@2580000 {
+ compatible = "ti,keystone-dwc3";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ reg = <0x2580000 0x10000>;
+ interrupts = <GIC_SPI 144 IRQ_TYPE_EDGE_RISING>;
+ ranges;
+ dma-coherent;
+ dma-ranges;
+ status = "disabled";
+ power-domains = <&k2g_pds 0x0017>;
+
+ usb1: usb@2590000 {
+ compatible = "snps,dwc3";
+ reg = <0x2590000 0x10000>;
+ interrupts = <GIC_SPI 144 IRQ_TYPE_EDGE_RISING>;
+ maximum-speed = "high-speed";
+ dr_mode = "otg";
+ usb-phy = <&usb1_phy>;
+ status = "disabled";
+ };
+ };
};
};
--
2.9.4.dirty

2017-08-02 20:20:03

by Franklin S Cooper Jr

[permalink] [raw]
Subject: [PATCH 2/3] dt-bindings: usb: keystone-usb: Update bindings pm and clocks properties

Update varous properties to properly indicate their requirement depending
on the SoC.

Signed-off-by: Franklin S Cooper Jr <[email protected]>
---
Documentation/devicetree/bindings/usb/keystone-usb.txt | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/keystone-usb.txt b/Documentation/devicetree/bindings/usb/keystone-usb.txt
index 60527d3..307531b 100644
--- a/Documentation/devicetree/bindings/usb/keystone-usb.txt
+++ b/Documentation/devicetree/bindings/usb/keystone-usb.txt
@@ -12,8 +12,22 @@ Required properties:
MPU.
- ranges: allows valid 1:1 translation between child's address space and
parent's address space.
- - clocks: Clock IDs array as required by the controller.
- - clock-names: names of clocks correseponding to IDs in the clock property.
+
+SoC-specific Required Properties:
+The following are mandatory properties for Keystone 2 66AK2HK, 66AK2L and 66AK2E
+SoCs only:
+
+- clocks: Clock IDs array as required by the controller.
+- clock-names: names of clocks correseponding to IDs in the clock
+ property.
+
+
+The following are mandatory properties for Keystone 2 66AK2G SoCs only:
+
+- power-domains: Should contain a phandle to a PM domain provider node
+ and an args specifier containing the USB device id
+ value. This property is as per the binding,
+ Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt

Sub-nodes:
The dwc3 core should be added as subnode to Keystone DWC3 glue.
--
2.9.4.dirty

2017-08-07 13:42:05

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH 0/3] ARM: dts: k2g: Add support for USB instances on 66AK2G

On 8/2/17 1:17 PM, Franklin S Cooper Jr wrote:
> Add support for 66AK2G usb instances. However, the driver needs to be updated
> to support PM_RUNTIME. This update has been validated to work on K2L and boot
> tested on K2HK and K2E.
>
> Franklin S Cooper Jr (2):
> usb: dwc3: keystone: Add PM_RUNTIME Support to DWC3 Keystone USB
> driver
> dt-bindings: usb: keystone-usb: Update bindings pm and clocks
> properties
>
> Vitaly Andrianov (1):
> ARM: dts: k2g: Add USB instances
>
> .../devicetree/bindings/usb/keystone-usb.txt | 18 ++++++-
> arch/arm/boot/dts/keystone-k2g.dtsi | 56 ++++++++++++++++++++++
> drivers/usb/dwc3/dwc3-keystone.c | 22 ++++-----
> 3 files changed, 82 insertions(+), 14 deletions(-)
>
Once you get you driver patch lined up, post
the DTS patch separately.

Regards,
Santosh

2017-08-10 16:34:04

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 2/3] dt-bindings: usb: keystone-usb: Update bindings pm and clocks properties

On Wed, Aug 02, 2017 at 03:17:23PM -0500, Franklin S Cooper Jr wrote:
> Update varous properties to properly indicate their requirement depending
> on the SoC.
>
> Signed-off-by: Franklin S Cooper Jr <[email protected]>
> ---
> Documentation/devicetree/bindings/usb/keystone-usb.txt | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/keystone-usb.txt b/Documentation/devicetree/bindings/usb/keystone-usb.txt
> index 60527d3..307531b 100644
> --- a/Documentation/devicetree/bindings/usb/keystone-usb.txt
> +++ b/Documentation/devicetree/bindings/usb/keystone-usb.txt
> @@ -12,8 +12,22 @@ Required properties:
> MPU.
> - ranges: allows valid 1:1 translation between child's address space and
> parent's address space.
> - - clocks: Clock IDs array as required by the controller.
> - - clock-names: names of clocks correseponding to IDs in the clock property.
> +
> +SoC-specific Required Properties:
> +The following are mandatory properties for Keystone 2 66AK2HK, 66AK2L and 66AK2E
> +SoCs only:
> +
> +- clocks: Clock IDs array as required by the controller.
> +- clock-names: names of clocks correseponding to IDs in the clock
> + property.

This needs to be specific as to how many clocks and their names.

> +
> +
> +The following are mandatory properties for Keystone 2 66AK2G SoCs only:
> +
> +- power-domains: Should contain a phandle to a PM domain provider node
> + and an args specifier containing the USB device id
> + value. This property is as per the binding,
> + Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt
>
> Sub-nodes:
> The dwc3 core should be added as subnode to Keystone DWC3 glue.
> --
> 2.9.4.dirty
>