Skip to contentSkip to conversation

Add iProc MDIO and Cygnus PCIe PHY support

PATCH Superseded Ray Jui 1 participant 7 messages May 22, 2015 – Sep 1, 2015

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Ray Jui

author maintainer
#0 lore raw

v2 cover Add iProc MDIO and Cygnus PCIe PHY support

This patch series adds support for the Cygnus PCIe PHY and support of the MDC/MDIO bus interface found in various iProc based of SoCs. The iProc MDC/MDIO bus interface can be used by the host processor to communicate with various internal Serdes/PHYs including Ethernet, PCIe, USB, etc.

This patch series is based on Linux v4.1-rc4 and is avaliable in:
https://github.com/Broadcom/cygnus-linux/tree/cygnus-pcie-phy-v2

Changes from v1:
- Move the MDC/MDIO bus driver from drivers/phy/* to drivers/bus/*
- Make the PCIe PHY device node child node of the MDIO bus
- Change the PCIe PHY driver to tristate so it can be compiled as a module
- Other minor changes

Ray Jui (5):
dt_bindings: Add iProc MDC/MDIO interface binding
phy: iproc-mdio: Initial iProc MDC/MDIO support
phy: cygnus: pcie: Define DT binding
phy: cygnus: pcie: Add Cygnus PCIe PHY support
ARM: dts: enable PCIe PHY support for Cygnus

 .../devicetree/bindings/bus/brcm,iproc-mdio.txt    |   21 ++
 .../bindings/phy/brcm,cygnus-pcie-phy.txt          |   34 ++
 arch/arm/boot/dts/bcm-cygnus.dtsi                  |   20 ++
 drivers/bus/Kconfig                                |   12 +
 drivers/bus/Makefile                               |    1 +
 drivers/bus/iproc-mdio-bus.c                       |  255 +++++++++++++++
 drivers/phy/Kconfig                                |   15 +
 drivers/phy/Makefile                               |    1 +
 drivers/phy/phy-cygnus-pcie.c                      |  340 ++++++++++++++++++++
 include/linux/iproc_mdio_bus.h                     |   22 ++
 10 files changed, 721 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/brcm,iproc-mdio.txt
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,cygnus-pcie-phy.txt
 create mode 100644 drivers/bus/iproc-mdio-bus.c
 create mode 100644 drivers/phy/phy-cygnus-pcie.c
 create mode 100644 include/linux/iproc_mdio_bus.h
Signature · 1 line
1.7.9.5
author maintainer
#1 lore raw

PATCH v2 1/5 dt_bindings: Add iProc MDC/MDIO interface binding

Define device tree bindings for iProc MDC/MDIO bus interface

---
 .../devicetree/bindings/bus/brcm,iproc-mdio.txt    |   21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/brcm,iproc-mdio.txt
Documentation/devicetree/bindings/bus/brcm,iproc-mdio.txt new file +21 -0
new file mode 100644
index 0000000..db7228b
@@ -0,0 +1,21 @@
+Broadcom iProc MDC/MDIO bus interface
+
+The iProc MDC/MDIO bus interface is found on various iProc based SoCs and is
+used to communicate with various types of Serdes/PHYs including Ethernet,
+PCIe, USB, and etc.
+
+Required properties:
+- compatible: Must be "brcm,iproc-mdio"
+- reg: base address and length of the MDC/MDIO interface
+- address-cells: must be 1
+- size-cells: must be 1
+- ranges: leave it empty
+
+Example:
+	mdio_bus: mdio_bus@18002000 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "brcm,iproc-mdio";
+		ranges;
+		reg = <0x18002000 0x8>;
+	};
Signature · 1 line
1.7.9.5
author maintainer
#2 lore raw

PATCH v2 2/5 phy: iproc-mdio: Initial iProc MDC/MDIO support

In reply to Ray Jui

This adds the support for the iProc MDC/MDIO bus interface. Various iProc SoCs can use the MDC/MDIO bus interface to communicate with various Serdes/PHYs including Ethernet, PCIe, USB, etc.

---
 drivers/bus/Kconfig            |   12 ++
 drivers/bus/Makefile           |    1 +
 drivers/bus/iproc-mdio-bus.c   |  255 ++++++++++++++++++++++++++++++++++++++++
 include/linux/iproc_mdio_bus.h |   22 ++++
 4 files changed, 290 insertions(+)
 create mode 100644 drivers/bus/iproc-mdio-bus.c
 create mode 100644 include/linux/iproc_mdio_bus.h
drivers/bus/Kconfig +12 -0
index a1d4af6..99b38cb 100644
@@ -55,6 +55,18 @@ config IMX_WEIM
 	  The WEIM(Wireless External Interface Module) works like a bus.
 	  You can attach many different devices on it, such as NOR, onenand.
 
+config IPROC_MDIO
+	bool "Broadcom iProc MDC/MDIO driver"
+	depends on ARCH_BCM_IPROC
+	default ARCH_BCM_IPROC
+	help
+	  Enable this to support the iProc generic MDC/MDIO bus interface found
+	  in various iProc based SoCs. The generic MDC/MDIO bus interface can
+	  be used to communicate with various types of Serdes/PHYs including
+	  Ethernet, PCIe, USB, and etc.
+
+	  If unsure, say N.
+
 config MIPS_CDMM
 	bool "MIPS Common Device Memory Map (CDMM) Driver"
 	depends on CPU_MIPSR2
drivers/bus/Makefile +1 -0
index 790e7b9..6dff76a 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_ARM_CCN)		+= arm-ccn.o
 
 obj-$(CONFIG_BRCMSTB_GISB_ARB)	+= brcmstb_gisb.o
 obj-$(CONFIG_IMX_WEIM)		+= imx-weim.o
+obj-$(CONFIG_IPROC_MDIO)	+= iproc-mdio-bus.o
 obj-$(CONFIG_MIPS_CDMM)		+= mips_cdmm.o
 obj-$(CONFIG_MVEBU_MBUS) 	+= mvebu-mbus.o
 
drivers/bus/iproc-mdio-bus.c new file +255 -0

255 lines not on this page · raw message

include/linux/iproc_mdio_bus.h new file +22 -0
new file mode 100644
index 0000000..4d1235a
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2015 Broadcom Corporation
+ *
+ * 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.
+ */
+
+#ifndef __IPROC_MDIO_BUS_H
+#define __IPROC_MDIO_BUS_H
+
+int iproc_mdio_read(unsigned clk_div, unsigned phy_addr, unsigned reg_addr,
+		    u16 *data);
+int iproc_mdio_write(unsigned clk_div, unsigned phy_addr, unsigned reg_addr,
+		     u16 data);
+
+#endif /* __IPROC_MDIO_BUS_H */
Signature · 1 line
1.7.9.5
author maintainer
#3 lore raw

PATCH v2 3/5 phy: cygnus: pcie: Define DT binding

In reply to Ray Jui

Add DT binding document for Broadcom Cygnus PCIe PHY driver

---
 .../bindings/phy/brcm,cygnus-pcie-phy.txt          |   34 ++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,cygnus-pcie-phy.txt
Documentation/devicetree/bindings/phy/brcm,cygnus-pcie-phy.txt new file +34 -0
new file mode 100644
index 0000000..1b1a7af
@@ -0,0 +1,34 @@
+Broadcom Cygnus PCIe PHY
+
+Required properties:
+- compatible: Must be "brcm,cygnus-pcie-phy"
+- reg: base address and length of the CRMU block
+- #phy-cells: must be <2>
+The first cell is the PHY ID:
+0 - PCIe RC 0
+1 - PCIe RC 1
+The second cell is the internal PHY address
+
+Example:
+	mdio_bus {
+		...
+		phy: phy@0301d0a0 {
+			compatible = "brcm,cygnus-pcie-phy";
+			reg = <0x0301d0a0 0x14>;
+			#phy-cells = <2>;
+		};
+	};
+
+	pcie0: pcie@18012000 {
+		...
+		...
+		phys = <&phy 0 5>;
+		phy-names = "pcie-phy";
+	};
+
+	pcie1: pcie@18013000 {
+		...
+		...
+		phys = <&phy 1 6>;
+		phy-names = "pcie-phy";
+	};
Signature · 1 line
1.7.9.5
author maintainer
#4 lore raw

PATCH v2 4/5 phy: cygnus: pcie: Add Cygnus PCIe PHY support

In reply to Ray Jui

This patch adds the PCIe PHY support for the Broadcom PCIe RC interface

---
 drivers/phy/Kconfig           |   15 ++
 drivers/phy/Makefile          |    1 +
 drivers/phy/phy-cygnus-pcie.c |  340 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 356 insertions(+)
 create mode 100644 drivers/phy/phy-cygnus-pcie.c
drivers/phy/Kconfig +15 -0
index a53bd5b..ba1954f 100644
@@ -35,6 +35,21 @@ config ARMADA375_USBCLUSTER_PHY
 	depends on OF
 	select GENERIC_PHY
 
+config PHY_CYGNUS_PCIE
+	tristate "Broadcom Cygnus PCIe PHY driver"
+	depends on ARCH_BCM_CYGNUS
+	select GENERIC_PHY
+	select IPROC_MDIO
+	default ARCH_BCM_CYGNUS
+	help
+	  Enable this to support the Broadcom Cygnus PCIe PHY.
+
+	  The host communicates with the PHY through the iProc MDC/MDIO
+	  interface.
+
+	  If unsure, say N.
+
+
 config PHY_DM816X_USB
 	tristate "TI dm816x USB PHY driver"
 	depends on ARCH_OMAP2PLUS
drivers/phy/Makefile +1 -0
index f126251..0a4a6c8 100644
@@ -5,6 +5,7 @@
 obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
 obj-$(CONFIG_PHY_BERLIN_USB)		+= phy-berlin-usb.o
 obj-$(CONFIG_PHY_BERLIN_SATA)		+= phy-berlin-sata.o
+obj-$(CONFIG_PHY_CYGNUS_PCIE)		+= phy-cygnus-pcie.o
 obj-$(CONFIG_PHY_DM816X_USB)		+= phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)	+= phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
drivers/phy/phy-cygnus-pcie.c new file +340 -0

340 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author maintainer
#5 lore raw

PATCH v2 5/5 ARM: dts: enable PCIe PHY support for Cygnus

In reply to Ray Jui

Added MDIO and PCIe PHY device nodes for Cygnus. The PCIe PHY is referenced by the iProc PCIe device

---
 arch/arm/boot/dts/bcm-cygnus.dtsi |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
arch/arm/boot/dts/bcm-cygnus.dtsi +20 -0
index 7b52c33..57667a8 100644
@@ -106,6 +106,20 @@
 		};
 	};
 
+	mdio_bus: mdio_bus@18002000 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "brcm,iproc-mdio";
+		reg = <0x18002000 0x8>;
+		ranges;
+
+		pcie_phy: pcie_phy@0301d0a0 {
+			compatible = "brcm,cygnus-pcie-phy";
+			reg = <0x0301d0a0 0x14>;
+			#phy-cells = <2>;
+		};
+	};
+
 	i2c0: i2c@18008000 {
 		compatible = "brcm,cygnus-iproc-i2c", "brcm,iproc-i2c";
 		reg = <0x18008000 0x100>;
@@ -144,6 +158,9 @@
 		ranges = <0x81000000 0 0	  0x28000000 0 0x00010000
 			  0x82000000 0 0x20000000 0x20000000 0 0x04000000>;
 
+		phys = <&pcie_phy 0 5>;
+		phy-names = "pcie-phy";
+
 		status = "disabled";
 	};
 
@@ -165,6 +182,9 @@
 		ranges = <0x81000000 0 0	  0x48000000 0 0x00010000
 			  0x82000000 0 0x40000000 0x40000000 0 0x04000000>;
 
+		phys = <&pcie_phy 1 6>;
+		phy-names = "pcie-phy";
+
 		status = "disabled";
 	};
 
Signature · 1 line
1.7.9.5
author maintainer
#6 lore raw
In reply to Ray Jui

Hi Arnd,

Please help to advise if the following changes make sense to you. There does not seem to be a maintainer for drivers/bus/* and Florian mentioned that you "may" be able to help to pull in changes for ARM SoCs related changes under drivers/bus/*.

The problem I'm trying to solve:
Some iProc based SoCs (like Cygnus) has an internal MDIO based bus interface that is used to communicate with various types of Serdes/PHYs including PCIe, Ethernet, and etc. However, there's only one MDIO interface per SoC so the access needs to be serialized and protected in software

The solution:
1. According to convention, Ethernet PHYs should be in drivers/net/phy/* and PCIe (and other) PHYs should be in drivers/phy/*
2. Kishon suggested putting the low-level MDIO interface/bus driver in drivers/bus/* which I also think is more proper than leaving it any where else
3. Both PCIe PHY driver and Ethernet PHY driver call specific iproc based MDIO API to access their PHYs (e.g., iproc_mdio_write and iproc_mdio_read).

There are some changes/fixes I need to make to both the MDIO bus driver and PCIe PHY driver so there will be a v3 of this patchset. But before I do that, I'd like to cross check with you and make sure the way how I partition these drivers are acceptable.

Thanks,

Ray

Quoted 38 lines · Ray Jui

This patch series adds support for the Cygnus PCIe PHY and support of the MDC/MDIO bus interface found in various iProc based of SoCs. The iProc MDC/MDIO bus interface can be used by the host processor to communicate with various internal Serdes/PHYs including Ethernet, PCIe, USB, etc.

This patch series is based on Linux v4.1-rc4 and is avaliable in:
https://github.com/Broadcom/cygnus-linux/tree/cygnus-pcie-phy-v2

Changes from v1:
- Move the MDC/MDIO bus driver from drivers/phy/* to drivers/bus/*
- Make the PCIe PHY device node child node of the MDIO bus
- Change the PCIe PHY driver to tristate so it can be compiled as a module
- Other minor changes

Ray Jui (5):
dt_bindings: Add iProc MDC/MDIO interface binding
phy: iproc-mdio: Initial iProc MDC/MDIO support
phy: cygnus: pcie: Define DT binding
phy: cygnus: pcie: Add Cygnus PCIe PHY support
ARM: dts: enable PCIe PHY support for Cygnus

 .../devicetree/bindings/bus/brcm,iproc-mdio.txt    |   21 ++
 .../bindings/phy/brcm,cygnus-pcie-phy.txt          |   34 ++
 arch/arm/boot/dts/bcm-cygnus.dtsi                  |   20 ++
 drivers/bus/Kconfig                                |   12 +
 drivers/bus/Makefile                               |    1 +
 drivers/bus/iproc-mdio-bus.c                       |  255 +++++++++++++++
 drivers/phy/Kconfig                                |   15 +
 drivers/phy/Makefile                               |    1 +
 drivers/phy/phy-cygnus-pcie.c                      |  340 ++++++++++++++++++++
 include/linux/iproc_mdio_bus.h                     |   22 ++
 10 files changed, 721 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/brcm,iproc-mdio.txt
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,cygnus-pcie-phy.txt
 create mode 100644 drivers/bus/iproc-mdio-bus.c
 create mode 100644 drivers/phy/phy-cygnus-pcie.c
 create mode 100644 include/linux/iproc_mdio_bus.h