linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs
@ 2016-06-06 12:41 Pramod Kumar
  2016-06-06 12:41 ` [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers Pramod Kumar
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-06 12:41 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Pramod Kumar

Broadcom iProc based SoCs use a MDIO bus multiplexer where child buses
could be internal as well external to SoCs. These buses could supports
MDIO transaction compatible to C-22/C-45.

Broadcom MDIO bus multiplexer is an integrated multiplexer where child bus
selection and mdio transaction logic lies inside multiplexer itself.
To accommodate this multiplexer in existing mux framework below changes
were required-

1. Passed MDIO parent bus via mdio_mux_init to MDIO mux framework.

This patch set includes MDIO bus multiplexer driver along with above
framework change. It includes one external bus node having Ethernet PHY
attached and two internal bus node holding PCIe PHYs.

This patch series is based on v4.7-rc1 and is available from github-
repo: https://github.com/Broadcom/arm64-linux.git
branch:mdio-mux-v4

-Changes from v3:
- Unregister and free the parent MDIO bus.
- rebased on net-next/master branch.

Reason for resend:
-Rebased on v4.7-rc1

Changes from v2:
-Addressed Rob's comments in this patch regarding typo/grammers.
-Addressed David's comments regarding local variables order.
-Removed property "mdio-integrated-mux" and used mdiobus_register()
in place of of_mdiobus_regsiter().
-removed usage of IS_ERR_OR_NULL to IS_ERR in PCIe PHY driver.

Changes from v1:
- stop using "brcm,is_c45" from bus node as suggested by Andrew. MDIO
PHY driver will logically OR MII_ADDR_C45 into the address when issues
any C45 MDIO read/write transaction.

Pramod Kumar (7):
  mdio: mux: Enhanced MDIO mux framework for integrated multiplexers
  binding: Make "mdio-parent-bus" property from mandatory to optional
  binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus
    multiplexer
  dt: mdio-mux: Add mdio multiplexer driver node
  net: mdio-mux: Add MDIO mux driver for iProc SoCs
  binding: PHY: Binding doc for NS2 PCIe PHYs.
  phy: Add Northstar2 PCI Phy support

 .../bindings/net/brcm,mdio-mux-iproc.txt           |  59 +++++
 Documentation/devicetree/bindings/net/mdio-mux.txt |   3 +-
 .../bindings/phy/brcm,mdio-mux-bus-pci.txt         |  27 +++
 arch/arm64/boot/dts/broadcom/ns2-svk.dts           |  12 +
 arch/arm64/boot/dts/broadcom/ns2.dtsi              |  31 +++
 drivers/net/phy/Kconfig                            |  11 +
 drivers/net/phy/Makefile                           |   1 +
 drivers/net/phy/mdio-mux-bcm-iproc.c               | 248 +++++++++++++++++++++
 drivers/net/phy/mdio-mux-gpio.c                    |   2 +-
 drivers/net/phy/mdio-mux-mmioreg.c                 |   2 +-
 drivers/net/phy/mdio-mux.c                         |  28 ++-
 drivers/phy/Kconfig                                |   8 +
 drivers/phy/Makefile                               |   2 +-
 drivers/phy/phy-bcm-ns2-pcie.c                     | 115 ++++++++++
 include/linux/mdio-mux.h                           |   4 +-
 15 files changed, 538 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,mdio-mux-bus-pci.txt
 create mode 100644 drivers/net/phy/mdio-mux-bcm-iproc.c
 create mode 100644 drivers/phy/phy-bcm-ns2-pcie.c

-- 
1.9.1

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

* [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers
  2016-06-06 12:41 [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs Pramod Kumar
@ 2016-06-06 12:41 ` Pramod Kumar
  2016-06-06 14:17   ` Andrew Lunn
  2016-06-06 18:33   ` Florian Fainelli
  2016-06-06 12:41 ` [PATCH v4 2/7] binding: Make "mdio-parent-bus" property from mandatory to optional Pramod Kumar
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-06 12:41 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Pramod Kumar

An integrated multiplexer uses same address space for
"muxed bus selection" and "generation of mdio transaction"
hence its good to register parent bus from mux driver.

Hence added a mechanism where mux driver could register a
parent bus and pass it down to framework via mdio_mux_init api.

Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
---
 drivers/net/phy/mdio-mux-gpio.c    |  2 +-
 drivers/net/phy/mdio-mux-mmioreg.c |  2 +-
 drivers/net/phy/mdio-mux.c         | 28 ++++++++++++++++++----------
 include/linux/mdio-mux.h           |  4 +++-
 4 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c
index 7ddb1ab..9199499 100644
--- a/drivers/net/phy/mdio-mux-gpio.c
+++ b/drivers/net/phy/mdio-mux-gpio.c
@@ -55,7 +55,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev)
 		return PTR_ERR(s->gpios);
 
 	r = mdio_mux_init(&pdev->dev,
-			  mdio_mux_gpio_switch_fn, &s->mux_handle, s);
+			  mdio_mux_gpio_switch_fn, &s->mux_handle, s, NULL);
 
 	if (r != 0) {
 		gpiod_put_array(s->gpios);
diff --git a/drivers/net/phy/mdio-mux-mmioreg.c b/drivers/net/phy/mdio-mux-mmioreg.c
index 7fde454..d0bed52 100644
--- a/drivers/net/phy/mdio-mux-mmioreg.c
+++ b/drivers/net/phy/mdio-mux-mmioreg.c
@@ -126,7 +126,7 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
 	}
 
 	ret = mdio_mux_init(&pdev->dev, mdio_mux_mmioreg_switch_fn,
-			    &s->mux_handle, s);
+			    &s->mux_handle, s, NULL);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register mdio-mux bus %s\n",
 			np->full_name);
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 5c81d6f..dbd4ecc 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -89,7 +89,8 @@ static int parent_count;
 int mdio_mux_init(struct device *dev,
 		  int (*switch_fn)(int cur, int desired, void *data),
 		  void **mux_handle,
-		  void *data)
+		  void *data,
+		  struct mii_bus *mux_bus)
 {
 	struct device_node *parent_bus_node;
 	struct device_node *child_bus_node;
@@ -101,10 +102,21 @@ int mdio_mux_init(struct device *dev,
 	if (!dev->of_node)
 		return -ENODEV;
 
-	parent_bus_node = of_parse_phandle(dev->of_node, "mdio-parent-bus", 0);
+	if (!mux_bus) {
+		parent_bus_node = of_parse_phandle(dev->of_node,
+						   "mdio-parent-bus", 0);
 
-	if (!parent_bus_node)
-		return -ENODEV;
+		if (!parent_bus_node)
+			return -ENODEV;
+
+		parent_bus = of_mdio_find_bus(parent_bus_node);
+		if (!parent_bus) {
+			ret_val = -EPROBE_DEFER;
+			goto err_parent_bus;
+		}
+	} else {
+		parent_bus = mux_bus;
+	}
 
 	pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL);
 	if (pb == NULL) {
@@ -112,11 +124,6 @@ int mdio_mux_init(struct device *dev,
 		goto err_parent_bus;
 	}
 
-	parent_bus = of_mdio_find_bus(parent_bus_node);
-	if (parent_bus == NULL) {
-		ret_val = -EPROBE_DEFER;
-		goto err_parent_bus;
-	}
 
 	pb->switch_data = data;
 	pb->switch_fn = switch_fn;
@@ -177,7 +184,8 @@ int mdio_mux_init(struct device *dev,
 	put_device(&pb->mii_bus->dev);
 
 err_parent_bus:
-	of_node_put(parent_bus_node);
+	if (!mux_bus)
+		of_node_put(parent_bus_node);
 	return ret_val;
 }
 EXPORT_SYMBOL_GPL(mdio_mux_init);
diff --git a/include/linux/mdio-mux.h b/include/linux/mdio-mux.h
index a243dbb..61f5b21 100644
--- a/include/linux/mdio-mux.h
+++ b/include/linux/mdio-mux.h
@@ -10,11 +10,13 @@
 #ifndef __LINUX_MDIO_MUX_H
 #define __LINUX_MDIO_MUX_H
 #include <linux/device.h>
+#include <linux/phy.h>
 
 int mdio_mux_init(struct device *dev,
 		  int (*switch_fn) (int cur, int desired, void *data),
 		  void **mux_handle,
-		  void *data);
+		  void *data,
+		  struct mii_bus *mux_bus);
 
 void mdio_mux_uninit(void *mux_handle);
 
-- 
1.9.1

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

* [PATCH v4 2/7] binding: Make "mdio-parent-bus" property from mandatory to optional
  2016-06-06 12:41 [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs Pramod Kumar
  2016-06-06 12:41 ` [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers Pramod Kumar
@ 2016-06-06 12:41 ` Pramod Kumar
  2016-06-06 14:17   ` Andrew Lunn
  2016-06-08 19:39   ` Rob Herring
  2016-06-06 12:41 ` [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer Pramod Kumar
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-06 12:41 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Pramod Kumar

Change "mdio-parent-bus" from mandatory section to optional
as it won't be required by integrated MDIO multiplexer
which has bus selection and mdio transaction generation logic,
integrated inside.

Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
---
 Documentation/devicetree/bindings/net/mdio-mux.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/mdio-mux.txt b/Documentation/devicetree/bindings/net/mdio-mux.txt
index 491f5bd..f58571f 100644
--- a/Documentation/devicetree/bindings/net/mdio-mux.txt
+++ b/Documentation/devicetree/bindings/net/mdio-mux.txt
@@ -5,11 +5,12 @@ numbered uniquely in a device dependent manner.  The nodes for an MDIO
 bus multiplexer/switch will have one child node for each child bus.
 
 Required properties:
-- mdio-parent-bus : phandle to the parent MDIO bus.
 - #address-cells = <1>;
 - #size-cells = <0>;
 
 Optional properties:
+- mdio-parent-bus : phandle to the parent MDIO bus.
+
 - Other properties specific to the multiplexer/switch hardware.
 
 Required properties for child nodes:
-- 
1.9.1

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

* [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer
  2016-06-06 12:41 [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs Pramod Kumar
  2016-06-06 12:41 ` [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers Pramod Kumar
  2016-06-06 12:41 ` [PATCH v4 2/7] binding: Make "mdio-parent-bus" property from mandatory to optional Pramod Kumar
@ 2016-06-06 12:41 ` Pramod Kumar
  2016-06-06 18:36   ` Florian Fainelli
  2016-06-08 19:43   ` Rob Herring
  2016-06-06 12:41 ` [PATCH v4 4/7] dt: mdio-mux: Add mdio multiplexer driver node Pramod Kumar
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-06 12:41 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Pramod Kumar

Add DT binding doc for Broadcom MDIO bus multiplexer driver.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
---
 .../bindings/net/brcm,mdio-mux-iproc.txt           | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt

diff --git a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
new file mode 100644
index 0000000..dfe287a
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
@@ -0,0 +1,59 @@
+Properties for an MDIO bus multiplexer found in Broadcom iProc based SoCs.
+
+This MDIO bus multiplexer defines buses that could be internal as well as
+external to SoCs and could accept MDIO transaction compatible to C-22 or
+C-45 Clause. When child bus is selected, one needs to select these two
+properties as well to generate desired MDIO transaction on appropriate bus.
+
+Required properties in addition to the generic multiplexer properties:
+
+MDIO multiplexer node:
+- compatible: brcm,mdio-mux-iproc.
+
+Every non-ethernet PHY requires a compatible so that it could be probed based
+on this compatible string.
+
+Additional information regarding generic multiplexer properties can be found
+at- Documentation/devicetree/bindings/net/mdio-mux.txt
+
+
+for example:
+		mdio_mux_iproc: mdio-mux@6602023c {
+			compatible = "brcm,mdio-mux-iproc";
+			reg = <0x6602023c 0x14>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			mdio@0 {
+				reg = <0x0>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				pci_phy0: pci-phy@0 {
+					compatible = "brcm,ns2-pcie-phy";
+					reg = <0x0>;
+					#phy-cells = <0>;
+				};
+			};
+
+			mdio@7 {
+				reg = <0x7>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				pci_phy1: pci-phy@0 {
+					compatible = "brcm,ns2-pcie-phy";
+					reg = <0x0>;
+					#phy-cells = <0>;
+				};
+			};
+			mdio@10 {
+				reg = <0x10>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				gphy0: eth-phy@10 {
+					reg = <0x10>;
+				};
+			};
+		};
-- 
1.9.1

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

* [PATCH v4 4/7] dt: mdio-mux: Add mdio multiplexer driver node
  2016-06-06 12:41 [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs Pramod Kumar
                   ` (2 preceding siblings ...)
  2016-06-06 12:41 ` [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer Pramod Kumar
@ 2016-06-06 12:41 ` Pramod Kumar
  2016-06-06 18:37   ` Florian Fainelli
  2016-06-06 12:41 ` [PATCH v4 5/7] net: mdio-mux: Add MDIO mux driver for iProc SoCs Pramod Kumar
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Pramod Kumar @ 2016-06-06 12:41 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Pramod Kumar

Add integrated MDIO multiplexer driver node which contains
two mux PCIe bus and one ethernet bus along with phys
lying on these bus.

Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
---
 arch/arm64/boot/dts/broadcom/ns2-svk.dts | 12 ++++++++++++
 arch/arm64/boot/dts/broadcom/ns2.dtsi    | 31 +++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/broadcom/ns2-svk.dts b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
index 54ca40c..71f8503 100644
--- a/arch/arm64/boot/dts/broadcom/ns2-svk.dts
+++ b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
@@ -132,3 +132,15 @@
 		#size-cells = <1>;
 	};
 };
+
+&mdio_mux_iproc {
+	mdio@10 {
+		reg = <0x10>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		gphy0: eth-phy@10 {
+			reg = <0x10>;
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/broadcom/ns2.dtsi b/arch/arm64/boot/dts/broadcom/ns2.dtsi
index ec68ec1..9f20a66 100644
--- a/arch/arm64/boot/dts/broadcom/ns2.dtsi
+++ b/arch/arm64/boot/dts/broadcom/ns2.dtsi
@@ -263,6 +263,37 @@
 				      IRQ_TYPE_LEVEL_HIGH)>;
 		};
 
+		mdio_mux_iproc: mdio-mux@6602023c {
+			compatible = "brcm,mdio-mux-iproc";
+			reg = <0x6602023c 0x14>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			mdio@0 {
+				reg = <0x0>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				pci_phy0: pci-phy@0 {
+					compatible = "brcm,ns2-pcie-phy";
+					reg = <0x0>;
+					#phy-cells = <0>;
+				};
+			};
+
+			mdio@7 {
+				reg = <0x7>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				pci_phy1: pci-phy@0 {
+					compatible = "brcm,ns2-pcie-phy";
+					reg = <0x0>;
+					#phy-cells = <0>;
+				};
+			};
+		};
+
 		timer0: timer@66030000 {
 			compatible = "arm,sp804", "arm,primecell";
 			reg = <0x66030000 0x1000>;
-- 
1.9.1

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

* [PATCH v4 5/7] net: mdio-mux: Add MDIO mux driver for iProc SoCs
  2016-06-06 12:41 [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs Pramod Kumar
                   ` (3 preceding siblings ...)
  2016-06-06 12:41 ` [PATCH v4 4/7] dt: mdio-mux: Add mdio multiplexer driver node Pramod Kumar
@ 2016-06-06 12:41 ` Pramod Kumar
  2016-06-06 14:15   ` Andrew Lunn
  2016-06-06 18:42   ` Florian Fainelli
  2016-06-06 12:41 ` [PATCH v4 6/7] binding: PHY: Binding doc for NS2 PCIe PHYs Pramod Kumar
  2016-06-06 12:41 ` [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support Pramod Kumar
  6 siblings, 2 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-06 12:41 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Pramod Kumar

iProc based SoCs supports the integrated mdio multiplexer which
has the bus selection as well as mdio transaction generation logic
inside.

This multiplexer has child buses for PCIe, SATA, USB and ETH. These
buses could be internal or external to SOC where PHYs are attached.
These buses could use C-45 or C-22 mdio transaction.

Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
---
 drivers/net/phy/Kconfig              |  11 ++
 drivers/net/phy/Makefile             |   1 +
 drivers/net/phy/mdio-mux-bcm-iproc.c | 248 +++++++++++++++++++++++++++++++++++
 3 files changed, 260 insertions(+)
 create mode 100644 drivers/net/phy/mdio-mux-bcm-iproc.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 6dad9a9..94c0707 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -254,6 +254,17 @@ config MDIO_BUS_MUX_MMIOREG
 
 	  Currently, only 8-bit registers are supported.
 
+config MDIO_BUS_MUX_BCM_IPROC
+	tristate "Support for iProc based MDIO bus multiplexers"
+	depends on OF && OF_MDIO && (ARCH_BCM_IPROC || COMPILE_TEST)
+	select MDIO_BUS_MUX
+	default ARCH_BCM_IPROC
+	help
+	  This module provides a driver for MDIO bus multiplexers found in
+	  iProc based Broadcom SoCs. This multiplexer connects one of several
+	  child MDIO bus to a parent bus. Buses could be internal as well as
+	  external and selection logic lies inside the same multiplexer.
+
 config MDIO_BCM_UNIMAC
 	tristate "Broadcom UniMAC MDIO bus controller"
 	depends on HAS_IOMEM
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index fcdbb92..f5951d5a 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_AMD_PHY)		+= amd.o
 obj-$(CONFIG_MDIO_BUS_MUX)	+= mdio-mux.o
 obj-$(CONFIG_MDIO_BUS_MUX_GPIO)	+= mdio-mux-gpio.o
 obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += mdio-mux-mmioreg.o
+obj-$(CONFIG_MDIO_BUS_MUX_BCM_IPROC)	+= mdio-mux-bcm-iproc.o
 obj-$(CONFIG_MDIO_SUN4I)	+= mdio-sun4i.o
 obj-$(CONFIG_MDIO_MOXART)	+= mdio-moxart.o
 obj-$(CONFIG_MDIO_BCM_UNIMAC)	+= mdio-bcm-unimac.o
diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
new file mode 100644
index 0000000..0a04125
--- /dev/null
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2016 Broadcom
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation (the "GPL").
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 (GPLv2) for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 (GPLv2) along with this source code.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/device.h>
+#include <linux/of_mdio.h>
+#include <linux/module.h>
+#include <linux/phy.h>
+#include <linux/mdio-mux.h>
+#include <linux/delay.h>
+
+#define MDIO_PARAM_OFFSET		0x00
+#define MDIO_PARAM_MIIM_CYCLE		29
+#define MDIO_PARAM_INTERNAL_SEL		25
+#define MDIO_PARAM_BUS_ID		22
+#define MDIO_PARAM_C45_SEL		21
+#define MDIO_PARAM_PHY_ID		16
+#define MDIO_PARAM_PHY_DATA		0
+
+#define MDIO_READ_OFFSET		0x04
+#define MDIO_READ_DATA_MASK		0xffff
+#define MDIO_ADDR_OFFSET		0x08
+
+#define MDIO_CTRL_OFFSET		0x0C
+#define MDIO_CTRL_WRITE_OP		0x1
+#define MDIO_CTRL_READ_OP		0x2
+
+#define MDIO_STAT_OFFSET		0x10
+#define MDIO_STAT_DONE			1
+
+#define BUS_MAX_ADDR			32
+#define EXT_BUS_START_ADDR		16
+
+struct iproc_mdiomux_desc {
+	void *mux_handle;
+	void __iomem *base;
+	struct device *dev;
+	struct mii_bus *mii_bus;
+};
+
+static int iproc_mdio_wait_for_idle(void __iomem *base, bool result)
+{
+	unsigned int timeout = 1000; /* loop for 1s */
+	u32 val;
+
+	do {
+		val = readl(base + MDIO_STAT_OFFSET);
+		if ((val & MDIO_STAT_DONE) == result)
+			return 0;
+
+		usleep_range(1000, 2000);
+	} while (timeout--);
+
+	return -ETIMEDOUT;
+}
+
+/* start_miim_ops- Program and start MDIO transaction over mdio bus.
+ * @base: Base address
+ * @phyid: phyid of the selected bus.
+ * @reg: register offset to be read/written.
+ * @val :0 if read op else value to be written in @reg;
+ * @op: Operation that need to be carried out.
+ *      MDIO_CTRL_READ_OP: Read transaction.
+ *      MDIO_CTRL_WRITE_OP: Write transaction.
+ *
+ * Return value: Successful Read operation returns read reg values and write
+ *      operation returns 0. Failure operation returns negative error code.
+ */
+static int start_miim_ops(void __iomem *base,
+			  u16 phyid, u32 reg, u16 val, u32 op)
+{
+	u32 param;
+	int ret;
+
+	writel(0, base + MDIO_CTRL_OFFSET);
+	ret = iproc_mdio_wait_for_idle(base, 0);
+	if (ret)
+		goto err;
+
+	param = readl(base + MDIO_PARAM_OFFSET);
+	param |= phyid << MDIO_PARAM_PHY_ID;
+	param |= val << MDIO_PARAM_PHY_DATA;
+	if (reg & MII_ADDR_C45)
+		param |= BIT(MDIO_PARAM_C45_SEL);
+
+	writel(param, base + MDIO_PARAM_OFFSET);
+
+	writel(reg, base + MDIO_ADDR_OFFSET);
+
+	writel(op, base + MDIO_CTRL_OFFSET);
+
+	ret = iproc_mdio_wait_for_idle(base, 1);
+	if (ret)
+		goto err;
+
+	if (op == MDIO_CTRL_READ_OP)
+		ret = readl(base + MDIO_READ_OFFSET) & MDIO_READ_DATA_MASK;
+err:
+	return ret;
+}
+
+static int iproc_mdiomux_read(struct mii_bus *bus, int phyid, int reg)
+{
+	struct iproc_mdiomux_desc *md = bus->priv;
+	int ret;
+
+	ret = start_miim_ops(md->base, phyid, reg, 0, MDIO_CTRL_READ_OP);
+	if (ret < 0)
+		dev_err(&bus->dev, "mdiomux read operation failed!!!");
+
+	return ret;
+}
+
+static int iproc_mdiomux_write(struct mii_bus *bus,
+			       int phyid, int reg, u16 val)
+{
+	struct iproc_mdiomux_desc *md = bus->priv;
+	int ret;
+
+	/* Write val at reg offset */
+	ret = start_miim_ops(md->base, phyid, reg, val, MDIO_CTRL_WRITE_OP);
+	if (ret < 0)
+		dev_err(&bus->dev, "mdiomux write operation failed!!!");
+
+	return ret;
+}
+
+static int mdio_mux_iproc_switch_fn(int current_child, int desired_child,
+				    void *data)
+{
+	struct iproc_mdiomux_desc *md = data;
+	u32 param, bus_id;
+	bool bus_dir;
+
+	/* select bus and its properties */
+	bus_dir = (desired_child < EXT_BUS_START_ADDR);
+	bus_id = bus_dir ? desired_child : (desired_child - EXT_BUS_START_ADDR);
+
+	param = (bus_dir ? 1 : 0) << MDIO_PARAM_INTERNAL_SEL;
+	param |= (bus_id << MDIO_PARAM_BUS_ID);
+
+	writel(param, md->base + MDIO_PARAM_OFFSET);
+	return 0;
+}
+
+static int mdio_mux_iproc_probe(struct platform_device *pdev)
+{
+	struct iproc_mdiomux_desc *md;
+	struct mii_bus *bus;
+	struct resource *res;
+	int rc;
+
+	md = devm_kzalloc(&pdev->dev, sizeof(*md), GFP_KERNEL);
+	if (!md)
+		return -ENOMEM;
+	md->dev = &pdev->dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	md->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(md->base)) {
+		dev_err(&pdev->dev, "failed to ioremap register\n");
+		return PTR_ERR(md->base);
+	}
+
+	md->mii_bus = mdiobus_alloc();
+	if (!md->mii_bus) {
+		dev_err(&pdev->dev, "mdiomux bus alloc failed\n");
+		return -ENOMEM;
+	}
+
+	bus = md->mii_bus;
+	bus->priv = md;
+	bus->name = "iProc MDIO mux bus";
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-%d", pdev->name, pdev->id);
+	bus->parent = &pdev->dev;
+	bus->read = iproc_mdiomux_read;
+	bus->write = iproc_mdiomux_write;
+
+	bus->phy_mask = ~0;
+	bus->dev.of_node = pdev->dev.of_node;
+	rc = mdiobus_register(bus);
+	if (rc) {
+		dev_err(&pdev->dev, "mdiomux registration failed\n");
+		goto out;
+	}
+
+	platform_set_drvdata(pdev, md);
+
+	rc = mdio_mux_init(md->dev, mdio_mux_iproc_switch_fn,
+			   &md->mux_handle, md, md->mii_bus);
+	if (rc) {
+		dev_info(md->dev, "mdiomux initialization failed\n");
+		goto out;
+	}
+
+	dev_info(md->dev, "iProc mdiomux registered\n");
+	return 0;
+out:
+	mdiobus_free(bus);
+	return rc;
+}
+
+static int mdio_mux_iproc_remove(struct platform_device *pdev)
+{
+	struct iproc_mdiomux_desc *md = dev_get_platdata(&pdev->dev);
+
+	mdio_mux_uninit(md->mux_handle);
+	mdiobus_unregister(md->mii_bus);
+	mdiobus_free(md->mii_bus);
+
+	return 0;
+}
+
+static const struct of_device_id mdio_mux_iproc_match[] = {
+	{
+		.compatible = "brcm,mdio-mux-iproc",
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(of, mdio_mux_iproc_match);
+
+static struct platform_driver mdiomux_iproc_driver = {
+	.driver = {
+		.name		= "mdio-mux-iproc",
+		.of_match_table = mdio_mux_iproc_match,
+	},
+	.probe		= mdio_mux_iproc_probe,
+	.remove		= mdio_mux_iproc_remove,
+};
+
+module_platform_driver(mdiomux_iproc_driver);
+
+MODULE_DESCRIPTION("iProc MDIO Mux Bus Driver");
+MODULE_AUTHOR("Pramod Kumar <pramod.kumar@broadcom.com>");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1

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

* [PATCH v4 6/7] binding: PHY: Binding doc for NS2 PCIe PHYs.
  2016-06-06 12:41 [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs Pramod Kumar
                   ` (4 preceding siblings ...)
  2016-06-06 12:41 ` [PATCH v4 5/7] net: mdio-mux: Add MDIO mux driver for iProc SoCs Pramod Kumar
@ 2016-06-06 12:41 ` Pramod Kumar
  2016-06-06 12:41 ` [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support Pramod Kumar
  6 siblings, 0 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-06 12:41 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Pramod Kumar, Jon Mason

Binding doc for NS2 PCIe PHYs.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jon Mason <jonmason@broadcom.com>
Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
---
 .../bindings/phy/brcm,mdio-mux-bus-pci.txt         | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,mdio-mux-bus-pci.txt

diff --git a/Documentation/devicetree/bindings/phy/brcm,mdio-mux-bus-pci.txt b/Documentation/devicetree/bindings/phy/brcm,mdio-mux-bus-pci.txt
new file mode 100644
index 0000000..5b51007
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,mdio-mux-bus-pci.txt
@@ -0,0 +1,27 @@
+* Broadcom NS2 PCIe PHY binding document
+
+Required bus properties:
+- reg: MDIO Bus number for the MDIO interface
+- #address-cells: must be 1
+- #size-cells: must be 0
+
+Required PHY properties:
+- compatible: should be "brcm,ns2-pcie-phy"
+- reg: MDIO Phy ID for the MDIO interface
+- #phy-cells: must be 0
+
+This is a child bus node of "brcm,mdio-mux-iproc" node.
+
+Example:
+
+mdio@0 {
+	reg = <0x0>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	pci_phy0: pci-phy@0 {
+		compatible = "brcm,ns2-pcie-phy";
+		reg = <0x0>;
+		#phy-cells = <0>;
+	};
+};
-- 
1.9.1

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

* [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support
  2016-06-06 12:41 [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs Pramod Kumar
                   ` (5 preceding siblings ...)
  2016-06-06 12:41 ` [PATCH v4 6/7] binding: PHY: Binding doc for NS2 PCIe PHYs Pramod Kumar
@ 2016-06-06 12:41 ` Pramod Kumar
  2016-06-06 18:42   ` Florian Fainelli
  2016-06-30 12:16   ` Kishon Vijay Abraham I
  6 siblings, 2 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-06 12:41 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Pramod Kumar, Jon Mason

Add PCI Phy support for Broadcom Northstar2 SoCs.  This driver uses the
interface from the iproc mdio mux driver to enable the devices
respective phys.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jon Mason <jonmason@broadcom.com>
Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
---
 drivers/phy/Kconfig            |   8 +++
 drivers/phy/Makefile           |   2 +-
 drivers/phy/phy-bcm-ns2-pcie.c | 115 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100644 drivers/phy/phy-bcm-ns2-pcie.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b869b98..01fb93b 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
 
 source "drivers/phy/tegra/Kconfig"
 
+config PHY_NS2_PCIE
+	tristate "Broadcom Northstar2 PCIe PHY driver"
+	depends on OF && MDIO_BUS_MUX_BCM_IPROC
+	select GENERIC_PHY
+	default ARCH_BCM_IPROC
+	help
+	  Enable this to support the Broadcom Northstar2 PCIe PHY.
+	  If unsure, say N.
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9c3e73c..7aea094 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -53,5 +53,5 @@ obj-$(CONFIG_PHY_TUSB1210)		+= phy-tusb1210.o
 obj-$(CONFIG_PHY_BRCM_SATA)		+= phy-brcm-sata.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)		+= phy-pistachio-usb.o
 obj-$(CONFIG_PHY_CYGNUS_PCIE)		+= phy-bcm-cygnus-pcie.o
-
 obj-$(CONFIG_ARCH_TEGRA) += tegra/
+obj-$(CONFIG_PHY_NS2_PCIE)		+= phy-bcm-ns2-pcie.o
diff --git a/drivers/phy/phy-bcm-ns2-pcie.c b/drivers/phy/phy-bcm-ns2-pcie.c
new file mode 100644
index 0000000..9513f7a
--- /dev/null
+++ b/drivers/phy/phy-bcm-ns2-pcie.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2016 Broadcom
+ *
+ * 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 version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/of_mdio.h>
+#include <linux/mdio.h>
+#include <linux/phy.h>
+#include <linux/phy/phy.h>
+
+struct ns2_pci_phy {
+	struct mdio_device *mdiodev;
+	struct phy *phy;
+};
+
+#define BLK_ADDR_REG_OFFSET	0x1f
+#define PLL_AFE1_100MHZ_BLK	0x2100
+#define PLL_CLK_AMP_OFFSET	0x03
+#define PLL_CLK_AMP_2P05V	0x2b18
+
+static int ns2_pci_phy_init(struct phy *p)
+{
+	struct ns2_pci_phy *phy = phy_get_drvdata(p);
+	int rc;
+
+	/* select the AFE 100MHz block page */
+	rc = mdiobus_write(phy->mdiodev->bus, phy->mdiodev->addr,
+			   BLK_ADDR_REG_OFFSET, PLL_AFE1_100MHZ_BLK);
+	if (rc)
+		goto err;
+
+	/* set the 100 MHz reference clock amplitude to 2.05 v */
+	rc = mdiobus_write(phy->mdiodev->bus, phy->mdiodev->addr,
+			   PLL_CLK_AMP_OFFSET, PLL_CLK_AMP_2P05V);
+	if (rc)
+		goto err;
+
+	return 0;
+
+err:
+	dev_err(&phy->mdiodev->dev, "Error %d writing to phy\n", rc);
+	return rc;
+}
+
+static struct phy_ops ns2_pci_phy_ops = {
+	.init = ns2_pci_phy_init,
+};
+
+static int ns2_pci_phy_probe(struct mdio_device *mdiodev)
+{
+	struct device *dev = &mdiodev->dev;
+	struct phy_provider *provider;
+	struct ns2_pci_phy *p;
+	struct phy *phy;
+
+	phy = devm_phy_create(dev, dev->of_node, &ns2_pci_phy_ops);
+	if (IS_ERR(phy)) {
+		dev_err(dev, "failed to create Phy\n");
+		return PTR_ERR(phy);
+	}
+
+	p = devm_kmalloc(dev, sizeof(struct ns2_pci_phy),
+			 GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+
+	p->mdiodev = mdiodev;
+	dev_set_drvdata(dev, p);
+
+	p->phy = phy;
+	phy_set_drvdata(phy, p);
+
+	provider = devm_of_phy_provider_register(&phy->dev,
+						 of_phy_simple_xlate);
+	if (IS_ERR(provider)) {
+		dev_err(dev, "failed to register Phy provider\n");
+		return PTR_ERR(provider);
+	}
+
+	dev_info(dev, "%s PHY registered\n", dev_name(dev));
+
+	return 0;
+}
+
+static const struct of_device_id ns2_pci_phy_of_match[] = {
+	{ .compatible = "brcm,ns2-pcie-phy", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, ns2_pci_phy_of_match);
+
+static struct mdio_driver ns2_pci_phy_driver = {
+	.mdiodrv = {
+		.driver = {
+			.name = "phy-bcm-ns2-pci",
+			.of_match_table = ns2_pci_phy_of_match,
+		},
+	},
+	.probe = ns2_pci_phy_probe,
+};
+mdio_module_driver(ns2_pci_phy_driver);
+
+MODULE_AUTHOR("Broadcom");
+MODULE_DESCRIPTION("Broadcom Northstar2 PCI Phy driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:phy-bcm-ns2-pci");
-- 
1.9.1

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

* Re: [PATCH v4 5/7] net: mdio-mux: Add MDIO mux driver for iProc SoCs
  2016-06-06 12:41 ` [PATCH v4 5/7] net: mdio-mux: Add MDIO mux driver for iProc SoCs Pramod Kumar
@ 2016-06-06 14:15   ` Andrew Lunn
  2016-06-06 18:42   ` Florian Fainelli
  1 sibling, 0 replies; 23+ messages in thread
From: Andrew Lunn @ 2016-06-06 14:15 UTC (permalink / raw)
  To: Pramod Kumar
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller, devicetree, netdev, linux-kernel,
	bcm-kernel-feedback-list, linux-arm-kernel

On Mon, Jun 06, 2016 at 06:11:38PM +0530, Pramod Kumar wrote:
> iProc based SoCs supports the integrated mdio multiplexer which
> has the bus selection as well as mdio transaction generation logic
> inside.
> 
> This multiplexer has child buses for PCIe, SATA, USB and ETH. These
> buses could be internal or external to SOC where PHYs are attached.
> These buses could use C-45 or C-22 mdio transaction.
> 
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

     Andrew

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

* Re: [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers
  2016-06-06 12:41 ` [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers Pramod Kumar
@ 2016-06-06 14:17   ` Andrew Lunn
  2016-06-06 18:33   ` Florian Fainelli
  1 sibling, 0 replies; 23+ messages in thread
From: Andrew Lunn @ 2016-06-06 14:17 UTC (permalink / raw)
  To: Pramod Kumar
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller, devicetree, netdev, linux-kernel,
	bcm-kernel-feedback-list, linux-arm-kernel

On Mon, Jun 06, 2016 at 06:11:34PM +0530, Pramod Kumar wrote:
> An integrated multiplexer uses same address space for
> "muxed bus selection" and "generation of mdio transaction"
> hence its good to register parent bus from mux driver.
> 
> Hence added a mechanism where mux driver could register a
> parent bus and pass it down to framework via mdio_mux_init api.
> 
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

     Andrew

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

* Re: [PATCH v4 2/7] binding: Make "mdio-parent-bus" property from mandatory to optional
  2016-06-06 12:41 ` [PATCH v4 2/7] binding: Make "mdio-parent-bus" property from mandatory to optional Pramod Kumar
@ 2016-06-06 14:17   ` Andrew Lunn
  2016-06-08 19:39   ` Rob Herring
  1 sibling, 0 replies; 23+ messages in thread
From: Andrew Lunn @ 2016-06-06 14:17 UTC (permalink / raw)
  To: Pramod Kumar
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller, devicetree, netdev, linux-kernel,
	bcm-kernel-feedback-list, linux-arm-kernel

On Mon, Jun 06, 2016 at 06:11:35PM +0530, Pramod Kumar wrote:
> Change "mdio-parent-bus" from mandatory section to optional
> as it won't be required by integrated MDIO multiplexer
> which has bus selection and mdio transaction generation logic,
> integrated inside.
> 
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers
  2016-06-06 12:41 ` [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers Pramod Kumar
  2016-06-06 14:17   ` Andrew Lunn
@ 2016-06-06 18:33   ` Florian Fainelli
  1 sibling, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2016-06-06 18:33 UTC (permalink / raw)
  To: Pramod Kumar, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	Kishon Vijay Abraham I, David S. Miller
  Cc: devicetree, netdev, linux-kernel, bcm-kernel-feedback-list,
	linux-arm-kernel

On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> An integrated multiplexer uses same address space for
> "muxed bus selection" and "generation of mdio transaction"
> hence its good to register parent bus from mux driver.
> 
> Hence added a mechanism where mux driver could register a
> parent bus and pass it down to framework via mdio_mux_init api.
> 
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>


> diff --git a/include/linux/mdio-mux.h b/include/linux/mdio-mux.h
> index a243dbb..61f5b21 100644
> --- a/include/linux/mdio-mux.h
> +++ b/include/linux/mdio-mux.h
> @@ -10,11 +10,13 @@
>  #ifndef __LINUX_MDIO_MUX_H
>  #define __LINUX_MDIO_MUX_H
>  #include <linux/device.h>
> +#include <linux/phy.h>

You could have added just a forward declaration, this is a pointer to
the structure so you don't need the compiler to have full knowledge of
the storage type. Not a biggie.
-- 
Florian

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

* Re: [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer
  2016-06-06 12:41 ` [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer Pramod Kumar
@ 2016-06-06 18:36   ` Florian Fainelli
  2016-06-07 11:57     ` Pramod Kumar
  2016-06-08 19:43   ` Rob Herring
  1 sibling, 1 reply; 23+ messages in thread
From: Florian Fainelli @ 2016-06-06 18:36 UTC (permalink / raw)
  To: Pramod Kumar, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	Kishon Vijay Abraham I, David S. Miller
  Cc: devicetree, netdev, linux-kernel, bcm-kernel-feedback-list,
	linux-arm-kernel

On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> Add DT binding doc for Broadcom MDIO bus multiplexer driver.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>


> +for example:
> +		mdio_mux_iproc: mdio-mux@6602023c {

I think Rob wanted you to drop the underscores here in favor of dashes,
there are more below, not critical imho.

> +			compatible = "brcm,mdio-mux-iproc";
> +			reg = <0x6602023c 0x14>;
> +			#address-cells = <1>;
> +			#size-cells = <0>;
> +
> +			mdio@0 {
> +				reg = <0x0>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +
> +				pci_phy0: pci-phy@0 {


-- 
Florian

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

* Re: [PATCH v4 4/7] dt: mdio-mux: Add mdio multiplexer driver node
  2016-06-06 12:41 ` [PATCH v4 4/7] dt: mdio-mux: Add mdio multiplexer driver node Pramod Kumar
@ 2016-06-06 18:37   ` Florian Fainelli
  2016-06-10  4:24     ` Pramod Kumar
  0 siblings, 1 reply; 23+ messages in thread
From: Florian Fainelli @ 2016-06-06 18:37 UTC (permalink / raw)
  To: Pramod Kumar, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	Kishon Vijay Abraham I, David S. Miller
  Cc: devicetree, netdev, linux-kernel, bcm-kernel-feedback-list,
	linux-arm-kernel

On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> Add integrated MDIO multiplexer driver node which contains
> two mux PCIe bus and one ethernet bus along with phys
> lying on these bus.
> 
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
> ---
> +		mdio_mux_iproc: mdio-mux@6602023c {
> +			compatible = "brcm,mdio-mux-iproc";
> +			reg = <0x6602023c 0x14>;
> +			#address-cells = <1>;
> +			#size-cells = <0>;
> +
> +			mdio@0 {
> +				reg = <0x0>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +
> +				pci_phy0: pci-phy@0 {
> +					compatible = "brcm,ns2-pcie-phy";
> +					reg = <0x0>;
> +					#phy-cells = <0>;
> +				};
> +			};
> +
> +			mdio@7 {
> +				reg = <0x7>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +
> +				pci_phy1: pci-phy@0 {
> +					compatible = "brcm,ns2-pcie-phy";
> +					reg = <0x0>;
> +					#phy-cells = <0>;
> +				};

Are these two PHYs always available in the NS2 SoC, or does that depend
on interfaces exposed at the board level? Should not they be flagged
with a disabled status property by default and enabled in their
respective board files?
-- 
Florian

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

* Re: [PATCH v4 5/7] net: mdio-mux: Add MDIO mux driver for iProc SoCs
  2016-06-06 12:41 ` [PATCH v4 5/7] net: mdio-mux: Add MDIO mux driver for iProc SoCs Pramod Kumar
  2016-06-06 14:15   ` Andrew Lunn
@ 2016-06-06 18:42   ` Florian Fainelli
  1 sibling, 0 replies; 23+ messages in thread
From: Florian Fainelli @ 2016-06-06 18:42 UTC (permalink / raw)
  To: Pramod Kumar, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	Kishon Vijay Abraham I, David S. Miller
  Cc: devicetree, netdev, linux-kernel, bcm-kernel-feedback-list,
	linux-arm-kernel

On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> iProc based SoCs supports the integrated mdio multiplexer which
> has the bus selection as well as mdio transaction generation logic
> inside.
> 
> This multiplexer has child buses for PCIe, SATA, USB and ETH. These
> buses could be internal or external to SOC where PHYs are attached.
> These buses could use C-45 or C-22 mdio transaction.
> 
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support
  2016-06-06 12:41 ` [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support Pramod Kumar
@ 2016-06-06 18:42   ` Florian Fainelli
  2016-06-07 12:25     ` Pramod Kumar
  2016-06-30 12:16   ` Kishon Vijay Abraham I
  1 sibling, 1 reply; 23+ messages in thread
From: Florian Fainelli @ 2016-06-06 18:42 UTC (permalink / raw)
  To: Pramod Kumar, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	Kishon Vijay Abraham I, David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Jon Mason

On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> Add PCI Phy support for Broadcom Northstar2 SoCs.  This driver uses the
> interface from the iproc mdio mux driver to enable the devices
> respective phys.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Jon Mason <jonmason@broadcom.com>
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
> ---
>  drivers/phy/Kconfig            |   8 +++
>  drivers/phy/Makefile           |   2 +-
>  drivers/phy/phy-bcm-ns2-pcie.c | 115 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 124 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/phy/phy-bcm-ns2-pcie.c
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index b869b98..01fb93b 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
>  
>  source "drivers/phy/tegra/Kconfig"
>  
> +config PHY_NS2_PCIE
> +	tristate "Broadcom Northstar2 PCIe PHY driver"
> +	depends on OF && MDIO_BUS_MUX_BCM_IPROC
> +	select GENERIC_PHY
> +	default ARCH_BCM_IPROC

Are not you missing a dependency on PHYLIB too to provide
mdio_module_register() etc. (at least make it build)?

-- 
Florian

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

* RE: [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer
  2016-06-06 18:36   ` Florian Fainelli
@ 2016-06-07 11:57     ` Pramod Kumar
  2016-06-08 19:40       ` Rob Herring
  0 siblings, 1 reply; 23+ messages in thread
From: Pramod Kumar @ 2016-06-07 11:57 UTC (permalink / raw)
  To: Florian Fainelli, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	Kishon Vijay Abraham I, David S. Miller
  Cc: devicetree, netdev, linux-kernel, bcm-kernel-feedback-list,
	linux-arm-kernel

Hi Florian,

> -----Original Message-----
> From: Florian Fainelli [mailto:f.fainelli@gmail.com]
> Sent: 07 June 2016 00:06
> To: Pramod Kumar; Rob Herring; Pawel Moll; Mark Rutland; Ian Campbell;
> Kumar Gala; Catalin Marinas; Will Deacon; Kishon Vijay Abraham I; David S.
> Miller
> Cc: devicetree@vger.kernel.org; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; bcm-kernel-feedback-list@broadcom.com; linux-arm-
> kernel@lists.infradead.org
> Subject: Re: [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for
> Broadcom MDIO bus multiplexer
>
> On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> > Add DT binding doc for Broadcom MDIO bus multiplexer driver.
> >
> > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> > Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
>
>
> > +for example:
> > +		mdio_mux_iproc: mdio-mux@6602023c {
>
> I think Rob wanted you to drop the underscores here in favor of dashes,
> there
> are more below, not critical imho.
>

I'd changed node name in favor of dashes. I don't think Label could be
written with hyphens,"-".  "-" in label provides DT parsing error.


> > +			compatible = "brcm,mdio-mux-iproc";
> > +			reg = <0x6602023c 0x14>;
> > +			#address-cells = <1>;
> > +			#size-cells = <0>;
> > +
> > +			mdio@0 {
> > +				reg = <0x0>;
> > +				#address-cells = <1>;
> > +				#size-cells = <0>;
> > +
> > +				pci_phy0: pci-phy@0 {
>
>
> --
> Florian

Regards,
Pramod

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

* RE: [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support
  2016-06-06 18:42   ` Florian Fainelli
@ 2016-06-07 12:25     ` Pramod Kumar
  0 siblings, 0 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-07 12:25 UTC (permalink / raw)
  To: Florian Fainelli, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	Kishon Vijay Abraham I, David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Jon Mason

Hi Florian,

> -----Original Message-----
> From: Florian Fainelli [mailto:f.fainelli@gmail.com]
> Sent: 07 June 2016 00:12
> To: Pramod Kumar; Rob Herring; Pawel Moll; Mark Rutland; Ian Campbell;
> Kumar Gala; Catalin Marinas; Will Deacon; Kishon Vijay Abraham I; David S.
> Miller
> Cc: devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; bcm-
> kernel-feedback-list@broadcom.com; linux-kernel@vger.kernel.org;
> netdev@vger.kernel.org; Jon Mason
> Subject: Re: [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support
>
> On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> > Add PCI Phy support for Broadcom Northstar2 SoCs.  This driver uses
> > the interface from the iproc mdio mux driver to enable the devices
> > respective phys.
> >
> > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> > Signed-off-by: Jon Mason <jonmason@broadcom.com>
> > Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
> > ---
> >  drivers/phy/Kconfig            |   8 +++
> >  drivers/phy/Makefile           |   2 +-
> >  drivers/phy/phy-bcm-ns2-pcie.c | 115
> > +++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 124 insertions(+), 1 deletion(-)  create mode 100644
> > drivers/phy/phy-bcm-ns2-pcie.c
> >
> > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index
> > b869b98..01fb93b 100644
> > --- a/drivers/phy/Kconfig
> > +++ b/drivers/phy/Kconfig
> > @@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
> >
> >  source "drivers/phy/tegra/Kconfig"
> >
> > +config PHY_NS2_PCIE
> > +	tristate "Broadcom Northstar2 PCIe PHY driver"
> > +	depends on OF && MDIO_BUS_MUX_BCM_IPROC
> > +	select GENERIC_PHY
> > +	default ARCH_BCM_IPROC
>
> Are not you missing a dependency on PHYLIB too to provide
> mdio_module_register() etc. (at least make it build)?
>

This depends on MDIO_BUS_MUX_BCM_IPROC which itself depends on PHYLIB. Hence
I don't think We need to take care of this here.

> --
> Florian

Regards,
Pramod

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

* Re: [PATCH v4 2/7] binding: Make "mdio-parent-bus" property from mandatory to optional
  2016-06-06 12:41 ` [PATCH v4 2/7] binding: Make "mdio-parent-bus" property from mandatory to optional Pramod Kumar
  2016-06-06 14:17   ` Andrew Lunn
@ 2016-06-08 19:39   ` Rob Herring
  1 sibling, 0 replies; 23+ messages in thread
From: Rob Herring @ 2016-06-08 19:39 UTC (permalink / raw)
  To: Pramod Kumar
  Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller, devicetree, linux-arm-kernel,
	bcm-kernel-feedback-list, linux-kernel, netdev

On Mon, Jun 06, 2016 at 06:11:35PM +0530, Pramod Kumar wrote:
> Change "mdio-parent-bus" from mandatory section to optional
> as it won't be required by integrated MDIO multiplexer
> which has bus selection and mdio transaction generation logic,
> integrated inside.
> 
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
> ---
>  Documentation/devicetree/bindings/net/mdio-mux.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer
  2016-06-07 11:57     ` Pramod Kumar
@ 2016-06-08 19:40       ` Rob Herring
  0 siblings, 0 replies; 23+ messages in thread
From: Rob Herring @ 2016-06-08 19:40 UTC (permalink / raw)
  To: Pramod Kumar
  Cc: Florian Fainelli, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller, devicetree, netdev, linux-kernel,
	bcm-kernel-feedback-list, linux-arm-kernel

On Tue, Jun 07, 2016 at 05:27:29PM +0530, Pramod Kumar wrote:
> Hi Florian,
> 
> > -----Original Message-----
> > From: Florian Fainelli [mailto:f.fainelli@gmail.com]
> > Sent: 07 June 2016 00:06
> > To: Pramod Kumar; Rob Herring; Pawel Moll; Mark Rutland; Ian Campbell;
> > Kumar Gala; Catalin Marinas; Will Deacon; Kishon Vijay Abraham I; David S.
> > Miller
> > Cc: devicetree@vger.kernel.org; netdev@vger.kernel.org; linux-
> > kernel@vger.kernel.org; bcm-kernel-feedback-list@broadcom.com; linux-arm-
> > kernel@lists.infradead.org
> > Subject: Re: [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for
> > Broadcom MDIO bus multiplexer
> >
> > On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> > > Add DT binding doc for Broadcom MDIO bus multiplexer driver.
> > >
> > > Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> > > Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
> >
> > Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> >
> >
> > > +for example:
> > > +		mdio_mux_iproc: mdio-mux@6602023c {
> >
> > I think Rob wanted you to drop the underscores here in favor of dashes,
> > there
> > are more below, not critical imho.
> >
> 
> I'd changed node name in favor of dashes. I don't think Label could be
> written with hyphens,"-".  "-" in label provides DT parsing error.

Right. Labels don't matter as they aren't part of the binding.

Rob

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

* Re: [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer
  2016-06-06 12:41 ` [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer Pramod Kumar
  2016-06-06 18:36   ` Florian Fainelli
@ 2016-06-08 19:43   ` Rob Herring
  1 sibling, 0 replies; 23+ messages in thread
From: Rob Herring @ 2016-06-08 19:43 UTC (permalink / raw)
  To: Pramod Kumar
  Cc: Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	Catalin Marinas, Will Deacon, Kishon Vijay Abraham I,
	David S. Miller, devicetree, linux-arm-kernel,
	bcm-kernel-feedback-list, linux-kernel, netdev

On Mon, Jun 06, 2016 at 06:11:36PM +0530, Pramod Kumar wrote:
> Add DT binding doc for Broadcom MDIO bus multiplexer driver.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
> ---
>  .../bindings/net/brcm,mdio-mux-iproc.txt           | 59 ++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt

Acked-by: Rob Herring <robh@kernel.org>

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

* RE: [PATCH v4 4/7] dt: mdio-mux: Add mdio multiplexer driver node
  2016-06-06 18:37   ` Florian Fainelli
@ 2016-06-10  4:24     ` Pramod Kumar
  0 siblings, 0 replies; 23+ messages in thread
From: Pramod Kumar @ 2016-06-10  4:24 UTC (permalink / raw)
  To: Florian Fainelli, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	Kishon Vijay Abraham I, David S. Miller
  Cc: devicetree, netdev, linux-kernel, bcm-kernel-feedback-list,
	linux-arm-kernel

Hi Florian,

> -----Original Message-----
> From: Florian Fainelli [mailto:f.fainelli@gmail.com]
> Sent: 07 June 2016 00:08
> To: Pramod Kumar; Rob Herring; Pawel Moll; Mark Rutland; Ian Campbell;
> Kumar Gala; Catalin Marinas; Will Deacon; Kishon Vijay Abraham I; David S.
> Miller
> Cc: devicetree@vger.kernel.org; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; bcm-kernel-feedback-list@broadcom.com; linux-arm-
> kernel@lists.infradead.org
> Subject: Re: [PATCH v4 4/7] dt: mdio-mux: Add mdio multiplexer driver node
>
> On 06/06/2016 05:41 AM, Pramod Kumar wrote:
> > Add integrated MDIO multiplexer driver node which contains two mux
> > PCIe bus and one ethernet bus along with phys lying on these bus.
> >
> > Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
> > ---
> > +		mdio_mux_iproc: mdio-mux@6602023c {
> > +			compatible = "brcm,mdio-mux-iproc";
> > +			reg = <0x6602023c 0x14>;
> > +			#address-cells = <1>;
> > +			#size-cells = <0>;
> > +
> > +			mdio@0 {
> > +				reg = <0x0>;
> > +				#address-cells = <1>;
> > +				#size-cells = <0>;
> > +
> > +				pci_phy0: pci-phy@0 {
> > +					compatible = "brcm,ns2-pcie-phy";
> > +					reg = <0x0>;
> > +					#phy-cells = <0>;
> > +				};
> > +			};
> > +
> > +			mdio@7 {
> > +				reg = <0x7>;
> > +				#address-cells = <1>;
> > +				#size-cells = <0>;
> > +
> > +				pci_phy1: pci-phy@0 {
> > +					compatible = "brcm,ns2-pcie-phy";
> > +					reg = <0x0>;
> > +					#phy-cells = <0>;
> > +				};
>
> Are these two PHYs always available in the NS2 SoC, or does that depend on
> interfaces exposed at the board level? Should not they be flagged with a
> disabled status property by default and enabled in their respective board
> files?
> --

It depends on the interfaces exposed at board level. We will disable it in
dtsi and enable it dts file. I'll address this through next patch set.

> Florian

Regards,
Pramod

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

* Re: [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support
  2016-06-06 12:41 ` [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support Pramod Kumar
  2016-06-06 18:42   ` Florian Fainelli
@ 2016-06-30 12:16   ` Kishon Vijay Abraham I
  1 sibling, 0 replies; 23+ messages in thread
From: Kishon Vijay Abraham I @ 2016-06-30 12:16 UTC (permalink / raw)
  To: Pramod Kumar, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, Catalin Marinas, Will Deacon,
	David S. Miller
  Cc: devicetree, linux-arm-kernel, bcm-kernel-feedback-list,
	linux-kernel, netdev, Jon Mason

Hi,

On Monday 06 June 2016 06:11 PM, Pramod Kumar wrote:
> Add PCI Phy support for Broadcom Northstar2 SoCs.  This driver uses the
> interface from the iproc mdio mux driver to enable the devices
> respective phys.
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Jon Mason <jonmason@broadcom.com>
> Signed-off-by: Pramod Kumar <pramod.kumar@broadcom.com>
> ---
>  drivers/phy/Kconfig            |   8 +++
>  drivers/phy/Makefile           |   2 +-
>  drivers/phy/phy-bcm-ns2-pcie.c | 115 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 124 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/phy/phy-bcm-ns2-pcie.c
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index b869b98..01fb93b 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
>  
>  source "drivers/phy/tegra/Kconfig"
>  
> +config PHY_NS2_PCIE
> +	tristate "Broadcom Northstar2 PCIe PHY driver"
> +	depends on OF && MDIO_BUS_MUX_BCM_IPROC
> +	select GENERIC_PHY
> +	default ARCH_BCM_IPROC
> +	help
> +	  Enable this to support the Broadcom Northstar2 PCIe PHY.
> +	  If unsure, say N.
>  endmenu
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 9c3e73c..7aea094 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -53,5 +53,5 @@ obj-$(CONFIG_PHY_TUSB1210)		+= phy-tusb1210.o
>  obj-$(CONFIG_PHY_BRCM_SATA)		+= phy-brcm-sata.o
>  obj-$(CONFIG_PHY_PISTACHIO_USB)		+= phy-pistachio-usb.o
>  obj-$(CONFIG_PHY_CYGNUS_PCIE)		+= phy-bcm-cygnus-pcie.o
> -
>  obj-$(CONFIG_ARCH_TEGRA) += tegra/
> +obj-$(CONFIG_PHY_NS2_PCIE)		+= phy-bcm-ns2-pcie.o
> diff --git a/drivers/phy/phy-bcm-ns2-pcie.c b/drivers/phy/phy-bcm-ns2-pcie.c
> new file mode 100644
> index 0000000..9513f7a
> --- /dev/null
> +++ b/drivers/phy/phy-bcm-ns2-pcie.c
> @@ -0,0 +1,115 @@
> +/*
> + * Copyright (C) 2016 Broadcom
> + *
> + * 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 version 2.
> + *
> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> + * kind, whether express or implied; without even the implied warranty
> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/module.h>
> +#include <linux/of_mdio.h>
> +#include <linux/mdio.h>
> +#include <linux/phy.h>
> +#include <linux/phy/phy.h>
> +
> +struct ns2_pci_phy {
> +	struct mdio_device *mdiodev;
> +	struct phy *phy;
> +};
> +
> +#define BLK_ADDR_REG_OFFSET	0x1f
> +#define PLL_AFE1_100MHZ_BLK	0x2100
> +#define PLL_CLK_AMP_OFFSET	0x03
> +#define PLL_CLK_AMP_2P05V	0x2b18
> +
> +static int ns2_pci_phy_init(struct phy *p)
> +{
> +	struct ns2_pci_phy *phy = phy_get_drvdata(p);
> +	int rc;
> +
> +	/* select the AFE 100MHz block page */
> +	rc = mdiobus_write(phy->mdiodev->bus, phy->mdiodev->addr,
> +			   BLK_ADDR_REG_OFFSET, PLL_AFE1_100MHZ_BLK);
> +	if (rc)
> +		goto err;
> +
> +	/* set the 100 MHz reference clock amplitude to 2.05 v */
> +	rc = mdiobus_write(phy->mdiodev->bus, phy->mdiodev->addr,
> +			   PLL_CLK_AMP_OFFSET, PLL_CLK_AMP_2P05V);
> +	if (rc)
> +		goto err;
> +
> +	return 0;
> +
> +err:
> +	dev_err(&phy->mdiodev->dev, "Error %d writing to phy\n", rc);
> +	return rc;
> +}
> +
> +static struct phy_ops ns2_pci_phy_ops = {
> +	.init = ns2_pci_phy_init,

.owner is required for phy_ops.
> +};
> +
> +static int ns2_pci_phy_probe(struct mdio_device *mdiodev)
> +{
> +	struct device *dev = &mdiodev->dev;
> +	struct phy_provider *provider;
> +	struct ns2_pci_phy *p;
> +	struct phy *phy;
> +
> +	phy = devm_phy_create(dev, dev->of_node, &ns2_pci_phy_ops);
> +	if (IS_ERR(phy)) {
> +		dev_err(dev, "failed to create Phy\n");
> +		return PTR_ERR(phy);
> +	}
> +
> +	p = devm_kmalloc(dev, sizeof(struct ns2_pci_phy),
> +			 GFP_KERNEL);
> +	if (!p)
> +		return -ENOMEM;
> +
> +	p->mdiodev = mdiodev;
> +	dev_set_drvdata(dev, p);
> +
> +	p->phy = phy;
> +	phy_set_drvdata(phy, p);
> +
> +	provider = devm_of_phy_provider_register(&phy->dev,
> +						 of_phy_simple_xlate);

just use return PTR_ERR_OR_ZERO(provider);

All the error messages are un-necessary.

Thanks
Kishon

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

end of thread, other threads:[~2016-06-30 12:17 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-06 12:41 [PATCH v4 0/7] Add MDIO bus multiplexer support for iProc SoCs Pramod Kumar
2016-06-06 12:41 ` [PATCH v4 1/7] mdio: mux: Enhanced MDIO mux framework for integrated multiplexers Pramod Kumar
2016-06-06 14:17   ` Andrew Lunn
2016-06-06 18:33   ` Florian Fainelli
2016-06-06 12:41 ` [PATCH v4 2/7] binding: Make "mdio-parent-bus" property from mandatory to optional Pramod Kumar
2016-06-06 14:17   ` Andrew Lunn
2016-06-08 19:39   ` Rob Herring
2016-06-06 12:41 ` [PATCH v4 3/7] binding: mdio-mux: Add DT binding doc for Broadcom MDIO bus multiplexer Pramod Kumar
2016-06-06 18:36   ` Florian Fainelli
2016-06-07 11:57     ` Pramod Kumar
2016-06-08 19:40       ` Rob Herring
2016-06-08 19:43   ` Rob Herring
2016-06-06 12:41 ` [PATCH v4 4/7] dt: mdio-mux: Add mdio multiplexer driver node Pramod Kumar
2016-06-06 18:37   ` Florian Fainelli
2016-06-10  4:24     ` Pramod Kumar
2016-06-06 12:41 ` [PATCH v4 5/7] net: mdio-mux: Add MDIO mux driver for iProc SoCs Pramod Kumar
2016-06-06 14:15   ` Andrew Lunn
2016-06-06 18:42   ` Florian Fainelli
2016-06-06 12:41 ` [PATCH v4 6/7] binding: PHY: Binding doc for NS2 PCIe PHYs Pramod Kumar
2016-06-06 12:41 ` [PATCH v4 7/7] phy: Add Northstar2 PCI Phy support Pramod Kumar
2016-06-06 18:42   ` Florian Fainelli
2016-06-07 12:25     ` Pramod Kumar
2016-06-30 12:16   ` Kishon Vijay Abraham I

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).