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

this is the third version of a series adding support for the USB
cluster which is on the Armada 375 SoC. We can mainly see this device
as a PHY muxer.

Since the last version I reused the file include/dt-bindings/phy/phy.h
as suggested by Kishon and I added his acked-by on the 5th patch.

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:
v2 -> v3:

 - Added Kishon acked-by on the 5th patch.

 - Used include/dt-bindings/phy/phy.h instead of creating a new one in
   the forth patch.

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/phy.h                      |   1 +
 11 files changed, 217 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/phy-mvebu.txt
 create mode 100644 drivers/phy/phy-armada375-usb2.c

-- 
1.9.1

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

* [PATCH v3 1/6] phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle
  2014-11-12  9:57 [PATCH v3 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
@ 2014-11-12  9:57 ` Gregory CLEMENT
  2014-11-12  9:57 ` [PATCH v3 2/6] Phy: DT binding documentation for Marvell MVEBU SATA phy Gregory CLEMENT
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Gregory CLEMENT @ 2014-11-12  9:57 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] 9+ messages in thread

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

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

* [PATCH v3 4/6] phy: add support for USB cluster on the Armada 375 SoC
  2014-11-12  9:57 [PATCH v3 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
                   ` (2 preceding siblings ...)
  2014-11-12  9:57 ` [PATCH v3 3/6] Phy: DT binding documentation for the Armada 375 USB cluster binding Gregory CLEMENT
@ 2014-11-12  9:57 ` Gregory CLEMENT
       [not found]   ` <1415786237-21985-5-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
  2014-11-12  9:57 ` [PATCH v3 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375 Gregory CLEMENT
  2014-11-12  9:57 ` [PATCH v3 6/6] ARM: mvebu: add PHY support to the dts for the USB controllers " Gregory CLEMENT
  5 siblings, 1 reply; 9+ messages in thread
From: Gregory CLEMENT @ 2014-11-12  9:57 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/phy.h    |   1 +
 4 files changed, 153 insertions(+)
 create mode 100644 drivers/phy/phy-armada375-usb2.c

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..d22fed4761f4
--- /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/phy.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_TYPE_USB2)
+			return ERR_PTR(-EBUSY);
+		else
+			return ERR_PTR(-ENODEV);
+	}
+
+	if (args->args[0] == PHY_TYPE_USB2)
+		usb_cluster_phy.use_usb3 = false;
+	else if (args->args[0] == PHY_TYPE_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/phy.h b/include/dt-bindings/phy/phy.h
index e8c6a3f04b85..6c901930eb3e 100644
--- a/include/dt-bindings/phy/phy.h
+++ b/include/dt-bindings/phy/phy.h
@@ -10,6 +10,7 @@
 #ifndef _DT_BINDINGS_PHY
 #define _DT_BINDINGS_PHY
 
+#define PHY_NONE		0
 #define PHY_TYPE_SATA		1
 #define PHY_TYPE_PCIE		2
 #define PHY_TYPE_USB2		3
-- 
1.9.1

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

* [PATCH v3 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375
  2014-11-12  9:57 [PATCH v3 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
                   ` (3 preceding siblings ...)
  2014-11-12  9:57 ` [PATCH v3 4/6] phy: add support for USB cluster on the Armada 375 SoC Gregory CLEMENT
@ 2014-11-12  9:57 ` Gregory CLEMENT
  2014-11-12  9:57 ` [PATCH v3 6/6] ARM: mvebu: add PHY support to the dts for the USB controllers " Gregory CLEMENT
  5 siblings, 0 replies; 9+ messages in thread
From: Gregory CLEMENT @ 2014-11-12  9:57 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.

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
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] 9+ messages in thread

* [PATCH v3 6/6] ARM: mvebu: add PHY support to the dts for the USB controllers on Armada 375
  2014-11-12  9:57 [PATCH v3 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
                   ` (4 preceding siblings ...)
  2014-11-12  9:57 ` [PATCH v3 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375 Gregory CLEMENT
@ 2014-11-12  9:57 ` Gregory CLEMENT
  5 siblings, 0 replies; 9+ messages in thread
From: Gregory CLEMENT @ 2014-11-12  9:57 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..f344ec420c95 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/phy.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_TYPE_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_TYPE_USB3>;
+				phy-names = "usb";
 				status = "disabled";
 			};
 
-- 
1.9.1

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

* Re: [PATCH v3 4/6] phy: add support for USB cluster on the Armada 375 SoC
       [not found]   ` <1415786237-21985-5-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
@ 2014-11-13  6:15     ` Kishon Vijay Abraham I
       [not found]       ` <54644C92.8000900-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Kishon Vijay Abraham I @ 2014-11-13  6:15 UTC (permalink / raw)
  To: Gregory CLEMENT, Jason Cooper, Andrew Lunn, Sebastian Hesselbarth
  Cc: Thomas Petazzoni, Ezequiel Garcia,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Lior Amsalem,
	Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Grant Likely, Rob Herring,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi,

On Wednesday 12 November 2014 03:27 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-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  drivers/phy/Kconfig              |   6 ++
>  drivers/phy/Makefile             |   1 +
>  drivers/phy/phy-armada375-usb2.c | 145 +++++++++++++++++++++++++++++++++++++++
>  include/dt-bindings/phy/phy.h    |   1 +
>  4 files changed, 153 insertions(+)
>  create mode 100644 drivers/phy/phy-armada375-usb2.c
> 
> 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..d22fed4761f4
> --- /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-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> + *
> + * 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/phy.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;

don't use global variables.
> +
> +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.
> +     */

You can dynamically create usb_cluster_phy in probe and then invoke
platform_set_drvdata by passing *usb_cluster_phy. Then you can invoke
platform_get_drvdata here to get *usb_cluster_phy.

While fixing this also add yourself as Maintainer of this file.

Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v3 4/6] phy: add support for USB cluster on the Armada 375 SoC
       [not found]       ` <54644C92.8000900-l0cyMroinI0@public.gmane.org>
@ 2014-11-13 11:46         ` Gregory CLEMENT
  0 siblings, 0 replies; 9+ messages in thread
From: Gregory CLEMENT @ 2014-11-13 11:46 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth,
	Thomas Petazzoni, Ezequiel Garcia,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Lior Amsalem,
	Tawfik Bayouk, Nadav Haklai, Mark Rutland,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Grant Likely, Rob Herring,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi,

[...]
>> +
>> +static struct armada375_cluster_phy usb_cluster_phy;
> 
> don't use global variables.
>> +
>> +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.
>> +     */
> 
> You can dynamically create usb_cluster_phy in probe and then invoke
> platform_set_drvdata by passing *usb_cluster_phy. Then you can invoke
> platform_get_drvdata here to get *usb_cluster_phy.
> 
> While fixing this also add yourself as Maintainer of this file.

I am taking into account your comment and I am going to send a new version soon.

Thanks,

Gregory


> 
> Thanks
> Kishon
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-11-13 11:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-12  9:57 [PATCH v3 0/6] Add support for USB cluster(PHY muxer) on the Armada 375 Gregory CLEMENT
2014-11-12  9:57 ` [PATCH v3 1/6] phy: Use PTR_ERR_OR_ZERO to fix warning raised by coccinelle Gregory CLEMENT
2014-11-12  9:57 ` [PATCH v3 2/6] Phy: DT binding documentation for Marvell MVEBU SATA phy Gregory CLEMENT
2014-11-12  9:57 ` [PATCH v3 3/6] Phy: DT binding documentation for the Armada 375 USB cluster binding Gregory CLEMENT
2014-11-12  9:57 ` [PATCH v3 4/6] phy: add support for USB cluster on the Armada 375 SoC Gregory CLEMENT
     [not found]   ` <1415786237-21985-5-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-11-13  6:15     ` Kishon Vijay Abraham I
     [not found]       ` <54644C92.8000900-l0cyMroinI0@public.gmane.org>
2014-11-13 11:46         ` Gregory CLEMENT
2014-11-12  9:57 ` [PATCH v3 5/6] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375 Gregory CLEMENT
2014-11-12  9:57 ` [PATCH v3 6/6] ARM: mvebu: add PHY support to the dts for the USB controllers " 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).