linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375
@ 2014-10-24 15:24 Gregory CLEMENT
  2014-10-24 15:24 ` [PATCH v2 1/6] phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle Gregory CLEMENT
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2014-10-24 15:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Gregory CLEMENT
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Hello,

this is the second version of a series I initially submitted in May:
https://lkml.org/lkml/2014/5/16/743

This series adds support for the USB cluster which is on the Armada
375 SoC. We can mainly see this device as a PHY muxer.

I more or less forgotten this series until the talk of Kishon Vijay
Abraham I about the phy framework.

Since this time, things have changed in the USB framework and I no
longer have to add the generic phy support in the xhci driver since it
was done at the usb core level.

While I ran coccicheck on my code I also found some possible
improvement in the phy driver: it was done in the 1st patch.

The second patch was a patch initially submitted by Andrew. This patch
added the mvebu-phy.txt but fell through a crack when adding the
driver. I join this patch on my series in order to be able to add the
new binding for the USB cluster of the Armada 375.

This was done in the third patch.

The forth patch was the addition of the phys driver itself.

The fifth and sixth patches are updating the device tree files related
to the Armada 375 using the new biding.

Thanks,

Gregory

Changelog:

v1 -> v2:

- Add a patch fixing the use of PTR_ERR_OR_ZERO.

- Add the patch adding the DT binding documentation for Marvell MVEBU
SATA phy from Andrew Lunn

- Move the DT binding documentation of the Armada 375 USB cluster into
  the phy-mvebu.txt file.

- Made the armada375_usb_phy_xlate more robust" if there is a phy_put
  and then a phy_get".

Andrew Lunn (1):
  Phy: DT binding documentation for Marvell MVEBU SATA phy.

Gregory CLEMENT (5):
  phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle
  Phy: DT binding documentation for the Armada 375 USB cluster binding
  phy: add support for USB cluster on the Armada 375 SoC
  ARM: mvebu: add Device Tree description of USB cluster controller on
    Armada 375
  ARM: mvebu: add PHY support to the dts for the USB controllers on
    Armada 375

 Documentation/devicetree/bindings/ata/marvell.txt  |   6 +
 .../devicetree/bindings/phy/phy-mvebu.txt          |  43 ++++++
 arch/arm/boot/dts/armada-375.dtsi                  |  11 ++
 drivers/phy/Kconfig                                |   6 +
 drivers/phy/Makefile                               |   1 +
 drivers/phy/phy-armada375-usb2.c                   | 145 +++++++++++++++++++++
 drivers/phy/phy-berlin-sata.c                      |   5 +-
 drivers/phy/phy-hix5hd2-sata.c                     |   5 +-
 drivers/phy/phy-miphy365x.c                        |   5 +-
 drivers/phy/phy-stih41x-usb.c                      |   5 +-
 include/dt-bindings/phy/armada-375-usb-cluster.h   |  19 +++
 11 files changed, 235 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-mvebu.txt
 create mode 100644 drivers/phy/phy-armada375-usb2.c
 create mode 100644 include/dt-bindings/phy/armada-375-usb-cluster.h

-- 
1.9.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/6] phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle
  2014-10-24 15:24 [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
@ 2014-10-24 15:24 ` Gregory CLEMENT
  2014-10-24 15:24 ` [PATCH v2 2/6] Phy: DT binding documentation for Marvell MVEBU SATA phy Gregory CLEMENT
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2014-10-24 15:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Gregory CLEMENT
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: coccinelle/api/ptr_ret.cocci

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
 drivers/phy/phy-berlin-sata.c  | 5 +----
 drivers/phy/phy-hix5hd2-sata.c | 5 +----
 drivers/phy/phy-miphy365x.c    | 5 +----
 drivers/phy/phy-stih41x-usb.c  | 5 +----
 4 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/phy/phy-berlin-sata.c b/drivers/phy/phy-berlin-sata.c
index 69ced52d72aa..86602c0ffb42 100644
--- a/drivers/phy/phy-berlin-sata.c
+++ b/drivers/phy/phy-berlin-sata.c
@@ -258,10 +258,7 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
 
 	phy_provider =
 		devm_of_phy_provider_register(dev, phy_berlin_sata_phy_xlate);
-	if (IS_ERR(phy_provider))
-		return PTR_ERR(phy_provider);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(phy_provider);
 }
 
 static const struct of_device_id phy_berlin_sata_of_match[] = {
diff --git a/drivers/phy/phy-hix5hd2-sata.c b/drivers/phy/phy-hix5hd2-sata.c
index d5d978085c6d..62bc30ae0534 100644
--- a/drivers/phy/phy-hix5hd2-sata.c
+++ b/drivers/phy/phy-hix5hd2-sata.c
@@ -164,10 +164,7 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)
 
 	phy_set_drvdata(phy, priv);
 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-	if (IS_ERR(phy_provider))
-		return PTR_ERR(phy_provider);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(phy_provider);
 }
 
 static const struct of_device_id hix5hd2_sata_phy_of_match[] = {
diff --git a/drivers/phy/phy-miphy365x.c b/drivers/phy/phy-miphy365x.c
index 801afaf2d449..d2796a454f95 100644
--- a/drivers/phy/phy-miphy365x.c
+++ b/drivers/phy/phy-miphy365x.c
@@ -610,10 +610,7 @@ static int miphy365x_probe(struct platform_device *pdev)
 	}
 
 	provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate);
-	if (IS_ERR(provider))
-		return PTR_ERR(provider);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(provider);
 }
 
 static const struct of_device_id miphy365x_of_match[] = {
diff --git a/drivers/phy/phy-stih41x-usb.c b/drivers/phy/phy-stih41x-usb.c
index 9f16cb8e01f4..20c630c2f295 100644
--- a/drivers/phy/phy-stih41x-usb.c
+++ b/drivers/phy/phy-stih41x-usb.c
@@ -160,10 +160,7 @@ static int stih41x_usb_phy_probe(struct platform_device *pdev)
 	phy_set_drvdata(phy, phy_dev);
 
 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-	if (IS_ERR(phy_provider))
-		return PTR_ERR(phy_provider);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(phy_provider);
 }
 
 static const struct of_device_id stih41x_usb_phy_of_match[] = {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/6] Phy: DT binding documentation for Marvell MVEBU SATA phy.
  2014-10-24 15:24 [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
  2014-10-24 15:24 ` [PATCH v2 1/6] phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle Gregory CLEMENT
@ 2014-10-24 15:24 ` Gregory CLEMENT
  2014-10-24 15:24 ` [PATCH v2 3/6] Phy: DT binding documentation for the Armada 375 USB cluster binding Gregory CLEMENT
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2014-10-24 15:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Gregory CLEMENT
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

From: Andrew Lunn <andrew@lunn.ch>

Describe the binding for the Marvell MVEBU SATA phy. This driver
can be used at least with Kirkwood, Dove and maybe others.
Additionally, update the SATA binding with the properties to link
to the phy nodes.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 Documentation/devicetree/bindings/ata/marvell.txt  |  6 ++++++
 .../devicetree/bindings/phy/phy-mvebu.txt          | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-mvebu.txt

diff --git a/Documentation/devicetree/bindings/ata/marvell.txt b/Documentation/devicetree/bindings/ata/marvell.txt
index 1c8351604d38..b460edd12766 100644
--- a/Documentation/devicetree/bindings/ata/marvell.txt
+++ b/Documentation/devicetree/bindings/ata/marvell.txt
@@ -6,11 +6,17 @@ Required Properties:
 - interrupts    : Interrupt controller is using
 - nr-ports      : Number of SATA ports in use.
 
+Optional Properties:
+- phys		: List of phandles to sata phys
+- phy-names	: Should be "0", "1", etc, one number per phandle
+
 Example:
 
 	sata@80000 {
 		compatible = "marvell,orion-sata";
 		reg = <0x80000 0x5000>;
 		interrupts = <21>;
+		phys = <&sata_phy0>, <&sata_phy1>;
+		phy-names = "0", "1";
 		nr-ports = <2>;
 	}
diff --git a/Documentation/devicetree/bindings/phy/phy-mvebu.txt b/Documentation/devicetree/bindings/phy/phy-mvebu.txt
new file mode 100644
index 000000000000..6cb3364aeafb
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-mvebu.txt
@@ -0,0 +1,22 @@
+* Marvell MVEBU SATA PHY
+
+Power control for the SATA phy found on Marvell MVEBU SoCs.
+
+This document extends the binding described in phy-bindings.txt
+
+Required properties :
+
+ - reg		   : Offset and length of the register set for the SATA device
+ - compatible	   : Should be "marvell,mvebu-sata-phy"
+ - clocks	   : phandle of clock and specifier that supplies the device
+ - clock-names	   : Should be "sata"
+
+Example:
+		sata-phy@84000 {
+			compatible = "marvell,mvebu-sata-phy";
+			reg = <0x84000 0x0334>;
+			clocks = <&gate_clk 15>;
+			clock-names = "sata";
+			#phy-cells = <0>;
+			status = "ok";
+		};
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/6] Phy: DT binding documentation for the Armada 375 USB cluster binding
  2014-10-24 15:24 [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
  2014-10-24 15:24 ` [PATCH v2 1/6] phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle Gregory CLEMENT
  2014-10-24 15:24 ` [PATCH v2 2/6] Phy: DT binding documentation for Marvell MVEBU SATA phy Gregory CLEMENT
@ 2014-10-24 15:24 ` Gregory CLEMENT
  2014-10-24 15:24 ` [PATCH v2 4/6] phy: add support for USB cluster on the Armada 375 SoC Gregory CLEMENT
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2014-10-24 15:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Gregory CLEMENT
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Armada 375 comes with an USB2 host and device controller and an USB3
controller. The USB cluster control register allows to manage common
features of both USB controllers. This commit adds the Device Tree
binding documentation for this piece of hardware.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
 Documentation/devicetree/bindings/phy/phy-mvebu.txt | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/phy-mvebu.txt b/Documentation/devicetree/bindings/phy/phy-mvebu.txt
index 6cb3364aeafb..f95b6260a3b3 100644
--- a/Documentation/devicetree/bindings/phy/phy-mvebu.txt
+++ b/Documentation/devicetree/bindings/phy/phy-mvebu.txt
@@ -20,3 +20,24 @@ Example:
 			#phy-cells = <0>;
 			status = "ok";
 		};
+
+Armada 375 USB cluster
+----------------------
+
+Armada 375 comes with an USB2 host and device controller and an USB3
+controller. The USB cluster control register allows to manage common
+features of both USB controllers.
+
+Required properties:
+
+- compatible: "marvell,armada-375-usb-cluster"
+- reg: Should contain usb cluster register location and length.
+- #phy-cells : from the generic phy bindings, must be 1. Possible
+values are 1 (USB2), 2 (USB3).
+
+Example:
+		usbcluster: usb-cluster@18400 {
+			compatible = "marvell,armada-375-usb-cluster";
+			reg = <0x18400 0x4>;
+			#phy-cells = <1>
+		};
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/6] phy: add support for USB cluster on the Armada 375 SoC
  2014-10-24 15:24 [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
                   ` (2 preceding siblings ...)
  2014-10-24 15:24 ` [PATCH v2 3/6] Phy: DT binding documentation for the Armada 375 USB cluster binding Gregory CLEMENT
@ 2014-10-24 15:24 ` Gregory CLEMENT
  2014-11-04  9:18   ` Kishon Vijay Abraham I
  2014-10-24 15:24 ` [PATCH v2 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375 Gregory CLEMENT
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Gregory CLEMENT @ 2014-10-24 15:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Gregory CLEMENT
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

The Armada 375 SoC comes with an USB2 host and device controller and
an USB3 controller. The USB cluster control register allows to manage
common features of both USB controllers.

This commit adds a driver integrated in the generic PHY framework to
control this USB cluster feature.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 drivers/phy/Kconfig                              |   6 +
 drivers/phy/Makefile                             |   1 +
 drivers/phy/phy-armada375-usb2.c                 | 145 +++++++++++++++++++++++
 include/dt-bindings/phy/armada-375-usb-cluster.h |  19 +++
 4 files changed, 171 insertions(+)
 create mode 100644 drivers/phy/phy-armada375-usb2.c
 create mode 100644 include/dt-bindings/phy/armada-375-usb-cluster.h

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 2a436e607f99..625adb0abd43 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -21,6 +21,12 @@ config PHY_BERLIN_SATA
 	select GENERIC_PHY
 	help
 	  Enable this to support the SATA PHY on Marvell Berlin SoCs.
+config ARMADA375_USBCLUSTER_PHY
+	def_bool y
+	depends on MACH_ARMADA_375 || COMPILE_TEST
+	depends on OF
+	select GENERIC_PHY
+
 
 config PHY_EXYNOS_MIPI_VIDEO
 	tristate "S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver"
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index c4590fce082f..26b5633f378a 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
 obj-$(CONFIG_PHY_BERLIN_SATA)		+= phy-berlin-sata.o
+obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)	+= phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)	+= phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)	+= phy-exynos-mipi-video.o
diff --git a/drivers/phy/phy-armada375-usb2.c b/drivers/phy/phy-armada375-usb2.c
new file mode 100644
index 000000000000..7c6daa9029b3
--- /dev/null
+++ b/drivers/phy/phy-armada375-usb2.c
@@ -0,0 +1,145 @@
+/*
+ * USB cluster support for Armada 375 platform.
+ *
+ * Copyright (C) 2014 Marvell
+ *
+ * Gregory CLEMENT <gregory.clement@free-electrons.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2 or later. This program is licensed "as is"
+ * without any warranty of any kind, whether express or implied.
+ *
+ * Armada 375 comes with an USB2 host and device controller and an
+ * USB3 controller. The USB cluster control register allows to manage
+ * common features of both USB controllers.
+ */
+
+#include <dt-bindings/phy/armada-375-usb-cluster.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+
+#define USB2_PHY_CONFIG_DISABLE BIT(0)
+
+struct armada375_cluster_phy {
+	struct phy *phy;
+	void __iomem *reg;
+	bool use_usb3;
+	int phy_provided;
+};
+
+static struct armada375_cluster_phy usb_cluster_phy;
+
+static int armada375_usb_phy_init(struct phy *phy)
+{
+	struct armada375_cluster_phy *cluster_phy = phy_get_drvdata(phy);
+	u32 reg;
+
+	reg = readl(cluster_phy->reg);
+	if (cluster_phy->use_usb3)
+		reg |= USB2_PHY_CONFIG_DISABLE;
+	else
+		reg &= ~USB2_PHY_CONFIG_DISABLE;
+	writel(reg, cluster_phy->reg);
+
+	return 0;
+}
+
+static struct phy_ops armada375_usb_phy_ops = {
+	.init = armada375_usb_phy_init,
+	.owner = THIS_MODULE,
+};
+
+/*
+ * Only one controller can use this PHY. We shouldn't have the case
+ * when two controllers want to use this PHY. But if this case occurs
+ * then we provide a phy to the first one and return an error for the
+ * next one. This error has also to be an error returned by
+ * devm_phy_optional_get() so different from ENODEV for USB2. In the
+ * USB3 case it still optional and we use ENODEV.
+ */
+static struct phy *armada375_usb_phy_xlate(struct device *dev,
+					struct of_phandle_args *args)
+{
+
+    /*
+     * Either the phy had never been requested and then the first usb
+     * claiming it can get it, or it had already been requested in
+     * this case, we only allow to use it with the same configuration.
+     */
+	if (WARN_ON((usb_cluster_phy.phy_provided != PHY_NONE) &&
+			(usb_cluster_phy.phy_provided != args->args[0]))) {
+		dev_err(dev, "This PHY has already been provided!\n");
+		dev_err(dev, "Check your device tree, only one controller can use it\n.");
+		if (args->args[0] == PHY_USB2)
+			return ERR_PTR(-EBUSY);
+		else
+			return ERR_PTR(-ENODEV);
+	}
+
+	if (args->args[0] == PHY_USB2)
+		usb_cluster_phy.use_usb3 = false;
+	else if (args->args[0] == PHY_USB3)
+		usb_cluster_phy.use_usb3 = true;
+	else {
+		dev_err(dev, "Invalid PHY mode\n");
+		return ERR_PTR(-ENODEV);
+	}
+
+	/* Store which phy mode is used for next test */
+	usb_cluster_phy.phy_provided = args->args[0];
+
+	return usb_cluster_phy.phy;
+}
+
+static int armada375_usb_phy_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct phy *phy;
+	struct phy_provider *phy_provider;
+	void __iomem *usb_cluster_base;
+	struct resource *res;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	usb_cluster_base = devm_ioremap_resource(&pdev->dev, res);
+	if (!usb_cluster_base)
+		return -ENOMEM;
+
+	phy = devm_phy_create(dev, NULL, &armada375_usb_phy_ops, NULL);
+	if (IS_ERR(phy)) {
+		dev_err(dev, "failed to create PHY\n");
+		return PTR_ERR(phy);
+	}
+
+	usb_cluster_phy.phy = phy;
+	usb_cluster_phy.reg = usb_cluster_base;
+	phy_set_drvdata(phy, &usb_cluster_phy);
+
+	phy_provider = devm_of_phy_provider_register(&pdev->dev,
+						     armada375_usb_phy_xlate);
+	return PTR_ERR_OR_ZERO(phy_provider);
+}
+
+static const struct of_device_id of_usb_cluster_table[] = {
+	{ .compatible = "marvell,armada-375-usb-cluster", },
+	{ /* end of list */ },
+};
+MODULE_DEVICE_TABLE(of, of_usb_cluster_table);
+
+static struct platform_driver armada375_usb_phy_driver = {
+	.probe	= armada375_usb_phy_probe,
+	.driver = {
+		.of_match_table	= of_usb_cluster_table,
+		.name  = "armada-375-usb-cluster",
+		.owner = THIS_MODULE,
+	}
+};
+module_platform_driver(armada375_usb_phy_driver);
+
+MODULE_DESCRIPTION("Armada 375 USB cluster driver");
+MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
+MODULE_LICENSE("GPL");
diff --git a/include/dt-bindings/phy/armada-375-usb-cluster.h b/include/dt-bindings/phy/armada-375-usb-cluster.h
new file mode 100644
index 000000000000..cbd2d4e720bb
--- /dev/null
+++ b/include/dt-bindings/phy/armada-375-usb-cluster.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2014 Marvell
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ */
+
+#ifndef __ARMADA_375_USB_CLUSTER__
+#define __ARMADA_375_USB_CLUSTER__
+
+/* The supported mode passed through by the phandle are the following */
+
+#define PHY_NONE    0
+#define PHY_USB2    1
+#define PHY_USB3    2
+
+#endif /* __DT_BINDINGS_CLOCK_R8A7791_H__ */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375
  2014-10-24 15:24 [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
                   ` (3 preceding siblings ...)
  2014-10-24 15:24 ` [PATCH v2 4/6] phy: add support for USB cluster on the Armada 375 SoC Gregory CLEMENT
@ 2014-10-24 15:24 ` Gregory CLEMENT
  2014-11-04  6:25   ` Kishon Vijay Abraham I
  2014-10-24 15:24 ` [PATCH v2 6/6] ARM: mvebu: add PHY support to the dts for the USB controllers " Gregory CLEMENT
  2014-11-01 22:46 ` [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the " Jason Cooper
  6 siblings, 1 reply; 13+ messages in thread
From: Gregory CLEMENT @ 2014-10-24 15:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Gregory CLEMENT
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

On Armada 375, the USB cluster allows to control the cluster composed
of the USB2 and USB3 host controllers.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
 arch/arm/boot/dts/armada-375.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/armada-375.dtsi b/arch/arm/boot/dts/armada-375.dtsi
index de6571445cef..8f45cf5d2a50 100644
--- a/arch/arm/boot/dts/armada-375.dtsi
+++ b/arch/arm/boot/dts/armada-375.dtsi
@@ -342,6 +342,12 @@
 				#clock-cells = <1>;
 			};
 
+			usbcluster: usb-cluster@18400 {
+				compatible = "marvell,armada-375-usb-cluster";
+				reg = <0x18400 0x4>;
+				#phy-cells = <1>;
+			};
+
 			mbusc: mbus-controller@20000 {
 				compatible = "marvell,mbus-controller";
 				reg = <0x20000 0x100>, <0x20180 0x20>;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 6/6] ARM: mvebu: add PHY support to the dts for the USB controllers on Armada 375
  2014-10-24 15:24 [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
                   ` (4 preceding siblings ...)
  2014-10-24 15:24 ` [PATCH v2 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375 Gregory CLEMENT
@ 2014-10-24 15:24 ` Gregory CLEMENT
  2014-11-01 22:46 ` [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the " Jason Cooper
  6 siblings, 0 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2014-10-24 15:24 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Jason Cooper, Andrew Lunn,
	Sebastian Hesselbarth, Gregory CLEMENT
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Now that the USB cluster node has been added, use it as a PHY provider
for the USB controller linked to it: the first EHCI and the xHCI.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
 arch/arm/boot/dts/armada-375.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/armada-375.dtsi b/arch/arm/boot/dts/armada-375.dtsi
index 8f45cf5d2a50..39a3afbb293d 100644
--- a/arch/arm/boot/dts/armada-375.dtsi
+++ b/arch/arm/boot/dts/armada-375.dtsi
@@ -14,6 +14,7 @@
 #include "skeleton.dtsi"
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/phy/armada-375-usb-cluster.h>
 
 #define MBUS_ID(target,attributes) (((target) << 24) | ((attributes) << 16))
 
@@ -396,6 +397,8 @@
 				reg = <0x50000 0x500>;
 				interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
 				clocks = <&gateclk 18>;
+				phys = <&usbcluster PHY_USB2>;
+				phy-names = "usb";
 				status = "disabled";
 			};
 
@@ -412,6 +415,8 @@
 				reg = <0x58000 0x20000>,<0x5b880 0x80>;
 				interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
 				clocks = <&gateclk 16>;
+				phys = <&usbcluster PHY_USB3>;
+				phy-names = "usb";
 				status = "disabled";
 			};
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375
  2014-10-24 15:24 [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
                   ` (5 preceding siblings ...)
  2014-10-24 15:24 ` [PATCH v2 6/6] ARM: mvebu: add PHY support to the dts for the USB controllers " Gregory CLEMENT
@ 2014-11-01 22:46 ` Jason Cooper
  2014-11-03 16:48   ` Gregory CLEMENT
  6 siblings, 1 reply; 13+ messages in thread
From: Jason Cooper @ 2014-11-01 22:46 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Kishon Vijay Abraham I, Andrew Lunn, Sebastian Hesselbarth,
	Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Gregory,

On Fri, Oct 24, 2014 at 05:24:08PM +0200, Gregory CLEMENT wrote:
> Hello,
> 
> this is the second version of a series I initially submitted in May:
> https://lkml.org/lkml/2014/5/16/743
> 
> This series adds support for the USB cluster which is on the Armada
> 375 SoC. We can mainly see this device as a PHY muxer.
> 
> I more or less forgotten this series until the talk of Kishon Vijay
> Abraham I about the phy framework.
> 
> Since this time, things have changed in the USB framework and I no
> longer have to add the generic phy support in the xhci driver since it
> was done at the usb core level.
> 
> While I ran coccicheck on my code I also found some possible
> improvement in the phy driver: it was done in the 1st patch.
> 
> The second patch was a patch initially submitted by Andrew. This patch
> added the mvebu-phy.txt but fell through a crack when adding the
> driver. I join this patch on my series in order to be able to add the
> new binding for the USB cluster of the Armada 375.
> 
> This was done in the third patch.
> 
> The forth patch was the addition of the phys driver itself.
> 
> The fifth and sixth patches are updating the device tree files related
> to the Armada 375 using the new biding.
> 
> Thanks,
> 
> Gregory
> 
> Changelog:
> 
> v1 -> v2:
> 
> - Add a patch fixing the use of PTR_ERR_OR_ZERO.
> 
> - Add the patch adding the DT binding documentation for Marvell MVEBU
> SATA phy from Andrew Lunn
> 
> - Move the DT binding documentation of the Armada 375 USB cluster into
>   the phy-mvebu.txt file.
> 
> - Made the armada375_usb_phy_xlate more robust" if there is a phy_put
>   and then a phy_get".
> 
> Andrew Lunn (1):
>   Phy: DT binding documentation for Marvell MVEBU SATA phy.
> 
> Gregory CLEMENT (5):
>   phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle
>   Phy: DT binding documentation for the Armada 375 USB cluster binding
>   phy: add support for USB cluster on the Armada 375 SoC
>   ARM: mvebu: add Device Tree description of USB cluster controller on
>     Armada 375
>   ARM: mvebu: add PHY support to the dts for the USB controllers on
>     Armada 375

I assume Kishon is taking the phy portion of this series and we'll
handle the dts portion?  Before doing so, I'd like to see an Ack from
the DT maintainers and Kishon...

thx,

Jason.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375
  2014-11-01 22:46 ` [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the " Jason Cooper
@ 2014-11-03 16:48   ` Gregory CLEMENT
  0 siblings, 0 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2014-11-03 16:48 UTC (permalink / raw)
  To: Jason Cooper
  Cc: Kishon Vijay Abraham I, Andrew Lunn, Sebastian Hesselbarth,
	Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Hi Jason,

On 01/11/2014 23:46, Jason Cooper wrote:
> Gregory,
> 
> On Fri, Oct 24, 2014 at 05:24:08PM +0200, Gregory CLEMENT wrote:
>> Hello,
>>
>> this is the second version of a series I initially submitted in May:
>> https://lkml.org/lkml/2014/5/16/743
>>
>> This series adds support for the USB cluster which is on the Armada
>> 375 SoC. We can mainly see this device as a PHY muxer.
>>
>> I more or less forgotten this series until the talk of Kishon Vijay
>> Abraham I about the phy framework.
>>
>> Since this time, things have changed in the USB framework and I no
>> longer have to add the generic phy support in the xhci driver since it
>> was done at the usb core level.
>>
>> While I ran coccicheck on my code I also found some possible
>> improvement in the phy driver: it was done in the 1st patch.
>>
>> The second patch was a patch initially submitted by Andrew. This patch
>> added the mvebu-phy.txt but fell through a crack when adding the
>> driver. I join this patch on my series in order to be able to add the
>> new binding for the USB cluster of the Armada 375.
>>
>> This was done in the third patch.
>>
>> The forth patch was the addition of the phys driver itself.
>>
>> The fifth and sixth patches are updating the device tree files related
>> to the Armada 375 using the new biding.
>>
>> Thanks,
>>
>> Gregory
>>
>> Changelog:
>>
>> v1 -> v2:
>>
>> - Add a patch fixing the use of PTR_ERR_OR_ZERO.
>>
>> - Add the patch adding the DT binding documentation for Marvell MVEBU
>> SATA phy from Andrew Lunn
>>
>> - Move the DT binding documentation of the Armada 375 USB cluster into
>>   the phy-mvebu.txt file.
>>
>> - Made the armada375_usb_phy_xlate more robust" if there is a phy_put
>>   and then a phy_get".
>>
>> Andrew Lunn (1):
>>   Phy: DT binding documentation for Marvell MVEBU SATA phy.
>>
>> Gregory CLEMENT (5):
>>   phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle
>>   Phy: DT binding documentation for the Armada 375 USB cluster binding
>>   phy: add support for USB cluster on the Armada 375 SoC
>>   ARM: mvebu: add Device Tree description of USB cluster controller on
>>     Armada 375
>>   ARM: mvebu: add PHY support to the dts for the USB controllers on
>>     Armada 375
> 
> I assume Kishon is taking the phy portion of this series and we'll
> handle the dts portion? 

Yes I expect that we merge the patch 5 and 6, and patch 1-4 should
be pulled by Kishon.


> Before doing so, I'd like to see an Ack from
> the DT maintainers and Kishon...

I also would like have a feedback from them :)


Thanks,

Gregory

> 
> thx,
> 
> Jason.
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375
  2014-10-24 15:24 ` [PATCH v2 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375 Gregory CLEMENT
@ 2014-11-04  6:25   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 13+ messages in thread
From: Kishon Vijay Abraham I @ 2014-11-04  6:25 UTC (permalink / raw)
  To: Gregory CLEMENT, Jason Cooper, Andrew Lunn, Sebastian Hesselbarth
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel



On Friday 24 October 2014 08:54 PM, Gregory CLEMENT wrote:
> On Armada 375, the USB cluster allows to control the cluster composed
> of the USB2 and USB3 host controllers.
> 
> Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  arch/arm/boot/dts/armada-375.dtsi | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/armada-375.dtsi b/arch/arm/boot/dts/armada-375.dtsi
> index de6571445cef..8f45cf5d2a50 100644
> --- a/arch/arm/boot/dts/armada-375.dtsi
> +++ b/arch/arm/boot/dts/armada-375.dtsi
> @@ -342,6 +342,12 @@
>  				#clock-cells = <1>;
>  			};
>  
> +			usbcluster: usb-cluster@18400 {
> +				compatible = "marvell,armada-375-usb-cluster";
> +				reg = <0x18400 0x4>;
> +				#phy-cells = <1>;
> +			};
> +
>  			mbusc: mbus-controller@20000 {
>  				compatible = "marvell,mbus-controller";
>  				reg = <0x20000 0x100>, <0x20180 0x20>;
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/6] phy: add support for USB cluster on the Armada 375 SoC
  2014-10-24 15:24 ` [PATCH v2 4/6] phy: add support for USB cluster on the Armada 375 SoC Gregory CLEMENT
@ 2014-11-04  9:18   ` Kishon Vijay Abraham I
  2014-11-11 10:14     ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 13+ messages in thread
From: Kishon Vijay Abraham I @ 2014-11-04  9:18 UTC (permalink / raw)
  To: Gregory CLEMENT, Jason Cooper, Andrew Lunn, Sebastian Hesselbarth
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Hi,

On Friday 24 October 2014 08:54 PM, Gregory CLEMENT wrote:
> The Armada 375 SoC comes with an USB2 host and device controller and
> an USB3 controller. The USB cluster control register allows to manage
> common features of both USB controllers.
> 
> This commit adds a driver integrated in the generic PHY framework to
> control this USB cluster feature.
> 
> Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>  drivers/phy/Kconfig                              |   6 +
>  drivers/phy/Makefile                             |   1 +
>  drivers/phy/phy-armada375-usb2.c                 | 145 +++++++++++++++++++++++
>  include/dt-bindings/phy/armada-375-usb-cluster.h |  19 +++
>  4 files changed, 171 insertions(+)
>  create mode 100644 drivers/phy/phy-armada375-usb2.c
>  create mode 100644 include/dt-bindings/phy/armada-375-usb-cluster.h
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index 2a436e607f99..625adb0abd43 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -21,6 +21,12 @@ config PHY_BERLIN_SATA
>  	select GENERIC_PHY
>  	help
>  	  Enable this to support the SATA PHY on Marvell Berlin SoCs.
> +config ARMADA375_USBCLUSTER_PHY
> +	def_bool y
> +	depends on MACH_ARMADA_375 || COMPILE_TEST
> +	depends on OF
> +	select GENERIC_PHY
> +
>  
>  config PHY_EXYNOS_MIPI_VIDEO
>  	tristate "S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver"
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index c4590fce082f..26b5633f378a 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -4,6 +4,7 @@
>  
>  obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
>  obj-$(CONFIG_PHY_BERLIN_SATA)		+= phy-berlin-sata.o
> +obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)	+= phy-armada375-usb2.o
>  obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
>  obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)	+= phy-exynos-dp-video.o
>  obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)	+= phy-exynos-mipi-video.o
> diff --git a/drivers/phy/phy-armada375-usb2.c b/drivers/phy/phy-armada375-usb2.c
> new file mode 100644
> index 000000000000..7c6daa9029b3
> --- /dev/null
> +++ b/drivers/phy/phy-armada375-usb2.c
> @@ -0,0 +1,145 @@
> +/*
> + * USB cluster support for Armada 375 platform.
> + *
> + * Copyright (C) 2014 Marvell
> + *
> + * Gregory CLEMENT <gregory.clement@free-electrons.com>
> + *
> + * This file is licensed under the terms of the GNU General Public
> + * License version 2 or later. This program is licensed "as is"
> + * without any warranty of any kind, whether express or implied.
> + *
> + * Armada 375 comes with an USB2 host and device controller and an
> + * USB3 controller. The USB cluster control register allows to manage
> + * common features of both USB controllers.
> + */
> +
> +#include <dt-bindings/phy/armada-375-usb-cluster.h>
> +#include <linux/init.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of_address.h>
> +#include <linux/phy/phy.h>
> +#include <linux/platform_device.h>
> +
> +#define USB2_PHY_CONFIG_DISABLE BIT(0)
> +
> +struct armada375_cluster_phy {
> +	struct phy *phy;
> +	void __iomem *reg;
> +	bool use_usb3;
> +	int phy_provided;
> +};
> +
> +static struct armada375_cluster_phy usb_cluster_phy;
> +
> +static int armada375_usb_phy_init(struct phy *phy)
> +{
> +	struct armada375_cluster_phy *cluster_phy = phy_get_drvdata(phy);
> +	u32 reg;
> +
> +	reg = readl(cluster_phy->reg);
> +	if (cluster_phy->use_usb3)
> +		reg |= USB2_PHY_CONFIG_DISABLE;
> +	else
> +		reg &= ~USB2_PHY_CONFIG_DISABLE;
> +	writel(reg, cluster_phy->reg);
> +
> +	return 0;
> +}
> +
> +static struct phy_ops armada375_usb_phy_ops = {
> +	.init = armada375_usb_phy_init,
> +	.owner = THIS_MODULE,
> +};
> +
> +/*
> + * Only one controller can use this PHY. We shouldn't have the case
> + * when two controllers want to use this PHY. But if this case occurs
> + * then we provide a phy to the first one and return an error for the
> + * next one. This error has also to be an error returned by
> + * devm_phy_optional_get() so different from ENODEV for USB2. In the
> + * USB3 case it still optional and we use ENODEV.
> + */
> +static struct phy *armada375_usb_phy_xlate(struct device *dev,
> +					struct of_phandle_args *args)
> +{
> +
> +    /*
> +     * Either the phy had never been requested and then the first usb
> +     * claiming it can get it, or it had already been requested in
> +     * this case, we only allow to use it with the same configuration.
> +     */
> +	if (WARN_ON((usb_cluster_phy.phy_provided != PHY_NONE) &&
> +			(usb_cluster_phy.phy_provided != args->args[0]))) {
> +		dev_err(dev, "This PHY has already been provided!\n");
> +		dev_err(dev, "Check your device tree, only one controller can use it\n.");
> +		if (args->args[0] == PHY_USB2)
> +			return ERR_PTR(-EBUSY);
> +		else
> +			return ERR_PTR(-ENODEV);
> +	}
> +
> +	if (args->args[0] == PHY_USB2)
> +		usb_cluster_phy.use_usb3 = false;
> +	else if (args->args[0] == PHY_USB3)
> +		usb_cluster_phy.use_usb3 = true;
> +	else {
> +		dev_err(dev, "Invalid PHY mode\n");
> +		return ERR_PTR(-ENODEV);
> +	}
> +
> +	/* Store which phy mode is used for next test */
> +	usb_cluster_phy.phy_provided = args->args[0];
> +
> +	return usb_cluster_phy.phy;
> +}
> +
> +static int armada375_usb_phy_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct phy *phy;
> +	struct phy_provider *phy_provider;
> +	void __iomem *usb_cluster_base;
> +	struct resource *res;
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	usb_cluster_base = devm_ioremap_resource(&pdev->dev, res);
> +	if (!usb_cluster_base)
> +		return -ENOMEM;
> +
> +	phy = devm_phy_create(dev, NULL, &armada375_usb_phy_ops, NULL);
> +	if (IS_ERR(phy)) {
> +		dev_err(dev, "failed to create PHY\n");
> +		return PTR_ERR(phy);
> +	}
> +
> +	usb_cluster_phy.phy = phy;
> +	usb_cluster_phy.reg = usb_cluster_base;
> +	phy_set_drvdata(phy, &usb_cluster_phy);
> +
> +	phy_provider = devm_of_phy_provider_register(&pdev->dev,
> +						     armada375_usb_phy_xlate);
> +	return PTR_ERR_OR_ZERO(phy_provider);
> +}
> +
> +static const struct of_device_id of_usb_cluster_table[] = {
> +	{ .compatible = "marvell,armada-375-usb-cluster", },
> +	{ /* end of list */ },
> +};
> +MODULE_DEVICE_TABLE(of, of_usb_cluster_table);
> +
> +static struct platform_driver armada375_usb_phy_driver = {
> +	.probe	= armada375_usb_phy_probe,
> +	.driver = {
> +		.of_match_table	= of_usb_cluster_table,
> +		.name  = "armada-375-usb-cluster",
> +		.owner = THIS_MODULE,
> +	}
> +};
> +module_platform_driver(armada375_usb_phy_driver);
> +
> +MODULE_DESCRIPTION("Armada 375 USB cluster driver");
> +MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
> +MODULE_LICENSE("GPL");
> diff --git a/include/dt-bindings/phy/armada-375-usb-cluster.h b/include/dt-bindings/phy/armada-375-usb-cluster.h
> new file mode 100644
> index 000000000000..cbd2d4e720bb
> --- /dev/null
> +++ b/include/dt-bindings/phy/armada-375-usb-cluster.h
> @@ -0,0 +1,19 @@
> +/*
> + * Copyright (C) 2014 Marvell
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of the
> + * License, or (at your option) any later version.
> + */
> +
> +#ifndef __ARMADA_375_USB_CLUSTER__
> +#define __ARMADA_375_USB_CLUSTER__
> +
> +/* The supported mode passed through by the phandle are the following */
> +
> +#define PHY_NONE    0
> +#define PHY_USB2    1
> +#define PHY_USB3    2

Let's not add a separate file for every platform for these generic modes.

Thanks
Kishon
> +
> +#endif /* __DT_BINDINGS_CLOCK_R8A7791_H__ */
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/6] phy: add support for USB cluster on the Armada 375 SoC
  2014-11-04  9:18   ` Kishon Vijay Abraham I
@ 2014-11-11 10:14     ` Kishon Vijay Abraham I
  2014-11-12  8:18       ` Gregory CLEMENT
  0 siblings, 1 reply; 13+ messages in thread
From: Kishon Vijay Abraham I @ 2014-11-11 10:14 UTC (permalink / raw)
  To: Gregory CLEMENT, Jason Cooper, Andrew Lunn, Sebastian Hesselbarth
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Hi,

On Tuesday 04 November 2014 02:48 PM, Kishon Vijay Abraham I wrote:
> Hi,
> 
> On Friday 24 October 2014 08:54 PM, Gregory CLEMENT wrote:
>> The Armada 375 SoC comes with an USB2 host and device controller and
>> an USB3 controller. The USB cluster control register allows to manage
>> common features of both USB controllers.
>>
>> This commit adds a driver integrated in the generic PHY framework to
>> control this USB cluster feature.
>>
>> Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>> ---
>>  drivers/phy/Kconfig                              |   6 +
>>  drivers/phy/Makefile                             |   1 +
>>  drivers/phy/phy-armada375-usb2.c                 | 145 +++++++++++++++++++++++
>>  include/dt-bindings/phy/armada-375-usb-cluster.h |  19 +++
>>  4 files changed, 171 insertions(+)
>>  create mode 100644 drivers/phy/phy-armada375-usb2.c
>>  create mode 100644 include/dt-bindings/phy/armada-375-usb-cluster.h
>>
>> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
>> index 2a436e607f99..625adb0abd43 100644
>> --- a/drivers/phy/Kconfig
>> +++ b/drivers/phy/Kconfig
>> @@ -21,6 +21,12 @@ config PHY_BERLIN_SATA
>>  	select GENERIC_PHY
>>  	help
>>  	  Enable this to support the SATA PHY on Marvell Berlin SoCs.
>> +config ARMADA375_USBCLUSTER_PHY
>> +	def_bool y
>> +	depends on MACH_ARMADA_375 || COMPILE_TEST
>> +	depends on OF
>> +	select GENERIC_PHY
>> +
>>  
>>  config PHY_EXYNOS_MIPI_VIDEO
>>  	tristate "S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver"
>> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
>> index c4590fce082f..26b5633f378a 100644
>> --- a/drivers/phy/Makefile
>> +++ b/drivers/phy/Makefile
>> @@ -4,6 +4,7 @@
>>  
>>  obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
>>  obj-$(CONFIG_PHY_BERLIN_SATA)		+= phy-berlin-sata.o
>> +obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)	+= phy-armada375-usb2.o
>>  obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
>>  obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)	+= phy-exynos-dp-video.o
>>  obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)	+= phy-exynos-mipi-video.o
>> diff --git a/drivers/phy/phy-armada375-usb2.c b/drivers/phy/phy-armada375-usb2.c
>> new file mode 100644
>> index 000000000000..7c6daa9029b3
>> --- /dev/null
>> +++ b/drivers/phy/phy-armada375-usb2.c
>> @@ -0,0 +1,145 @@
>> +/*
>> + * USB cluster support for Armada 375 platform.
>> + *
>> + * Copyright (C) 2014 Marvell
>> + *
>> + * Gregory CLEMENT <gregory.clement@free-electrons.com>
>> + *
>> + * This file is licensed under the terms of the GNU General Public
>> + * License version 2 or later. This program is licensed "as is"
>> + * without any warranty of any kind, whether express or implied.
>> + *
>> + * Armada 375 comes with an USB2 host and device controller and an
>> + * USB3 controller. The USB cluster control register allows to manage
>> + * common features of both USB controllers.
>> + */
>> +
>> +#include <dt-bindings/phy/armada-375-usb-cluster.h>
>> +#include <linux/init.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of_address.h>
>> +#include <linux/phy/phy.h>
>> +#include <linux/platform_device.h>
>> +
>> +#define USB2_PHY_CONFIG_DISABLE BIT(0)
>> +
>> +struct armada375_cluster_phy {
>> +	struct phy *phy;
>> +	void __iomem *reg;
>> +	bool use_usb3;
>> +	int phy_provided;
>> +};
>> +
>> +static struct armada375_cluster_phy usb_cluster_phy;
>> +
>> +static int armada375_usb_phy_init(struct phy *phy)
>> +{
>> +	struct armada375_cluster_phy *cluster_phy = phy_get_drvdata(phy);
>> +	u32 reg;
>> +
>> +	reg = readl(cluster_phy->reg);
>> +	if (cluster_phy->use_usb3)
>> +		reg |= USB2_PHY_CONFIG_DISABLE;
>> +	else
>> +		reg &= ~USB2_PHY_CONFIG_DISABLE;
>> +	writel(reg, cluster_phy->reg);
>> +
>> +	return 0;
>> +}
>> +
>> +static struct phy_ops armada375_usb_phy_ops = {
>> +	.init = armada375_usb_phy_init,
>> +	.owner = THIS_MODULE,
>> +};
>> +
>> +/*
>> + * Only one controller can use this PHY. We shouldn't have the case
>> + * when two controllers want to use this PHY. But if this case occurs
>> + * then we provide a phy to the first one and return an error for the
>> + * next one. This error has also to be an error returned by
>> + * devm_phy_optional_get() so different from ENODEV for USB2. In the
>> + * USB3 case it still optional and we use ENODEV.
>> + */
>> +static struct phy *armada375_usb_phy_xlate(struct device *dev,
>> +					struct of_phandle_args *args)
>> +{
>> +
>> +    /*
>> +     * Either the phy had never been requested and then the first usb
>> +     * claiming it can get it, or it had already been requested in
>> +     * this case, we only allow to use it with the same configuration.
>> +     */
>> +	if (WARN_ON((usb_cluster_phy.phy_provided != PHY_NONE) &&
>> +			(usb_cluster_phy.phy_provided != args->args[0]))) {
>> +		dev_err(dev, "This PHY has already been provided!\n");
>> +		dev_err(dev, "Check your device tree, only one controller can use it\n.");
>> +		if (args->args[0] == PHY_USB2)
>> +			return ERR_PTR(-EBUSY);
>> +		else
>> +			return ERR_PTR(-ENODEV);
>> +	}
>> +
>> +	if (args->args[0] == PHY_USB2)
>> +		usb_cluster_phy.use_usb3 = false;
>> +	else if (args->args[0] == PHY_USB3)
>> +		usb_cluster_phy.use_usb3 = true;
>> +	else {
>> +		dev_err(dev, "Invalid PHY mode\n");
>> +		return ERR_PTR(-ENODEV);
>> +	}
>> +
>> +	/* Store which phy mode is used for next test */
>> +	usb_cluster_phy.phy_provided = args->args[0];
>> +
>> +	return usb_cluster_phy.phy;
>> +}
>> +
>> +static int armada375_usb_phy_probe(struct platform_device *pdev)
>> +{
>> +	struct device *dev = &pdev->dev;
>> +	struct phy *phy;
>> +	struct phy_provider *phy_provider;
>> +	void __iomem *usb_cluster_base;
>> +	struct resource *res;
>> +
>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +	usb_cluster_base = devm_ioremap_resource(&pdev->dev, res);
>> +	if (!usb_cluster_base)
>> +		return -ENOMEM;
>> +
>> +	phy = devm_phy_create(dev, NULL, &armada375_usb_phy_ops, NULL);
>> +	if (IS_ERR(phy)) {
>> +		dev_err(dev, "failed to create PHY\n");
>> +		return PTR_ERR(phy);
>> +	}
>> +
>> +	usb_cluster_phy.phy = phy;
>> +	usb_cluster_phy.reg = usb_cluster_base;
>> +	phy_set_drvdata(phy, &usb_cluster_phy);
>> +
>> +	phy_provider = devm_of_phy_provider_register(&pdev->dev,
>> +						     armada375_usb_phy_xlate);
>> +	return PTR_ERR_OR_ZERO(phy_provider);
>> +}
>> +
>> +static const struct of_device_id of_usb_cluster_table[] = {
>> +	{ .compatible = "marvell,armada-375-usb-cluster", },
>> +	{ /* end of list */ },
>> +};
>> +MODULE_DEVICE_TABLE(of, of_usb_cluster_table);
>> +
>> +static struct platform_driver armada375_usb_phy_driver = {
>> +	.probe	= armada375_usb_phy_probe,
>> +	.driver = {
>> +		.of_match_table	= of_usb_cluster_table,
>> +		.name  = "armada-375-usb-cluster",
>> +		.owner = THIS_MODULE,
>> +	}
>> +};
>> +module_platform_driver(armada375_usb_phy_driver);
>> +
>> +MODULE_DESCRIPTION("Armada 375 USB cluster driver");
>> +MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
>> +MODULE_LICENSE("GPL");
>> diff --git a/include/dt-bindings/phy/armada-375-usb-cluster.h b/include/dt-bindings/phy/armada-375-usb-cluster.h
>> new file mode 100644
>> index 000000000000..cbd2d4e720bb
>> --- /dev/null
>> +++ b/include/dt-bindings/phy/armada-375-usb-cluster.h
>> @@ -0,0 +1,19 @@
>> +/*
>> + * Copyright (C) 2014 Marvell
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License as
>> + * published by the Free Software Foundation; either version 2 of the
>> + * License, or (at your option) any later version.
>> + */
>> +
>> +#ifndef __ARMADA_375_USB_CLUSTER__
>> +#define __ARMADA_375_USB_CLUSTER__
>> +
>> +/* The supported mode passed through by the phandle are the following */
>> +
>> +#define PHY_NONE    0
>> +#define PHY_USB2    1
>> +#define PHY_USB3    2
> 
> Let's not add a separate file for every platform for these generic modes.

Can you use this patch [1] and resend your series?

Thanks
Kishon

[1] -> http://www.gossamer-threads.com/lists/linux/kernel/2044969
> 
> Thanks
> Kishon
>> +
>> +#endif /* __DT_BINDINGS_CLOCK_R8A7791_H__ */
>>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/6] phy: add support for USB cluster on the Armada 375 SoC
  2014-11-11 10:14     ` Kishon Vijay Abraham I
@ 2014-11-12  8:18       ` Gregory CLEMENT
  0 siblings, 0 replies; 13+ messages in thread
From: Gregory CLEMENT @ 2014-11-12  8:18 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Jason Cooper, Andrew Lunn, Sebastian Hesselbarth
  Cc: Thomas Petazzoni, Ezequiel Garcia, linux-arm-kernel,
	Lior Amsalem, Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree, Grant Likely, Rob Herring, linux-kernel

Hi,
[...]
>>> index 000000000000..cbd2d4e720bb
>>> --- /dev/null
>>> +++ b/include/dt-bindings/phy/armada-375-usb-cluster.h
>>> @@ -0,0 +1,19 @@
>>> +/*
>>> + * Copyright (C) 2014 Marvell
>>> + *
>>> + * This program is free software; you can redistribute it and/or
>>> + * modify it under the terms of the GNU General Public License as
>>> + * published by the Free Software Foundation; either version 2 of the
>>> + * License, or (at your option) any later version.
>>> + */
>>> +
>>> +#ifndef __ARMADA_375_USB_CLUSTER__
>>> +#define __ARMADA_375_USB_CLUSTER__
>>> +
>>> +/* The supported mode passed through by the phandle are the following */
>>> +
>>> +#define PHY_NONE    0
>>> +#define PHY_USB2    1
>>> +#define PHY_USB3    2
>>
>> Let's not add a separate file for every platform for these generic modes.
> 
> Can you use this patch [1] and resend your series?
> 

Yes sure, a new series is coming soon.

Thanks,

Gregory


> Thanks
> Kishon
> 
> [1] -> http://www.gossamer-threads.com/lists/linux/kernel/2044969
>>
>> Thanks
>> Kishon
>>> +
>>> +#endif /* __DT_BINDINGS_CLOCK_R8A7791_H__ */
>>>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-11-12  8:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-24 15:24 [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
2014-10-24 15:24 ` [PATCH v2 1/6] phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle Gregory CLEMENT
2014-10-24 15:24 ` [PATCH v2 2/6] Phy: DT binding documentation for Marvell MVEBU SATA phy Gregory CLEMENT
2014-10-24 15:24 ` [PATCH v2 3/6] Phy: DT binding documentation for the Armada 375 USB cluster binding Gregory CLEMENT
2014-10-24 15:24 ` [PATCH v2 4/6] phy: add support for USB cluster on the Armada 375 SoC Gregory CLEMENT
2014-11-04  9:18   ` Kishon Vijay Abraham I
2014-11-11 10:14     ` Kishon Vijay Abraham I
2014-11-12  8:18       ` Gregory CLEMENT
2014-10-24 15:24 ` [PATCH v2 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375 Gregory CLEMENT
2014-11-04  6:25   ` Kishon Vijay Abraham I
2014-10-24 15:24 ` [PATCH v2 6/6] ARM: mvebu: add PHY support to the dts for the USB controllers " Gregory CLEMENT
2014-11-01 22:46 ` [PATCH v2 0/6] Add support for USB cluster(PHY muxer) on the " Jason Cooper
2014-11-03 16:48   ` Gregory CLEMENT

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).