All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] USB3 support for Broadcom NS2 SoC
@ 2017-07-26 22:56 ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: bcm-kernel-feedback-list, devicetree, linux-arm-kernel, linux-kernel

Changes in v2:
* Addressed Rob Herring's comments on the binding documentation, which
  resulted in a restructing of the device tree and how the driver
  references those nodes.  This, in turn, resulted in a few new
  documentation files being created.

This patch set contains the USB3 support for Broadcom NS2 SoC.  The USB3
PHY is connected through the MDIO interface.

Jon Mason (3):
  dt-bindings: usb: Add documentation for NS2 CDRU USB3
  dt-bindings: usb: Add documentation for NS2 ICFG USB3
  dt-bindings: usb: Add documentation for NS2 IDM USB3

Yendapally Reddy Dhananjaya Reddy (3):
  dt-bindings: phy: Add documentation for NS2 USB3 PHY
  phy: Add USB3 PHY support for Broadcom NS2 SoC
  arm64: dts: ns2: Add USB3 Support

 .../devicetree/bindings/phy/brcm,ns2-usb3-phy.txt  |  48 ++
 .../bindings/usb/brcm,cdru-usb3-ctrl.txt           |  14 +
 .../devicetree/bindings/usb/brcm,icfg-usb.txt      |  13 +
 .../devicetree/bindings/usb/brcm,usb3-idm.txt      |  14 +
 arch/arm64/boot/dts/broadcom/ns2-svk.dts           |  16 +
 arch/arm64/boot/dts/broadcom/ns2-xmc.dts           |   8 +
 arch/arm64/boot/dts/broadcom/ns2.dtsi              |  59 +++
 drivers/phy/broadcom/Kconfig                       |   9 +
 drivers/phy/broadcom/Makefile                      |   1 +
 drivers/phy/broadcom/phy-bcm-ns2-usb3.c            | 580 +++++++++++++++++++++
 10 files changed, 762 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
 create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c

-- 
2.7.4

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

* [PATCH v2 0/6] USB3 support for Broadcom NS2 SoC
@ 2017-07-26 22:56 ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: linux-arm-kernel

Changes in v2:
* Addressed Rob Herring's comments on the binding documentation, which
  resulted in a restructing of the device tree and how the driver
  references those nodes.  This, in turn, resulted in a few new
  documentation files being created.

This patch set contains the USB3 support for Broadcom NS2 SoC.  The USB3
PHY is connected through the MDIO interface.

Jon Mason (3):
  dt-bindings: usb: Add documentation for NS2 CDRU USB3
  dt-bindings: usb: Add documentation for NS2 ICFG USB3
  dt-bindings: usb: Add documentation for NS2 IDM USB3

Yendapally Reddy Dhananjaya Reddy (3):
  dt-bindings: phy: Add documentation for NS2 USB3 PHY
  phy: Add USB3 PHY support for Broadcom NS2 SoC
  arm64: dts: ns2: Add USB3 Support

 .../devicetree/bindings/phy/brcm,ns2-usb3-phy.txt  |  48 ++
 .../bindings/usb/brcm,cdru-usb3-ctrl.txt           |  14 +
 .../devicetree/bindings/usb/brcm,icfg-usb.txt      |  13 +
 .../devicetree/bindings/usb/brcm,usb3-idm.txt      |  14 +
 arch/arm64/boot/dts/broadcom/ns2-svk.dts           |  16 +
 arch/arm64/boot/dts/broadcom/ns2-xmc.dts           |   8 +
 arch/arm64/boot/dts/broadcom/ns2.dtsi              |  59 +++
 drivers/phy/broadcom/Kconfig                       |   9 +
 drivers/phy/broadcom/Makefile                      |   1 +
 drivers/phy/broadcom/phy-bcm-ns2-usb3.c            | 580 +++++++++++++++++++++
 10 files changed, 762 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
 create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c

-- 
2.7.4

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

* [PATCH v2 1/6] dt-bindings: phy: Add documentation for NS2 USB3 PHY
  2017-07-26 22:56 ` Jon Mason
  (?)
@ 2017-07-26 22:56   ` Jon Mason
  -1 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: bcm-kernel-feedback-list, devicetree, linux-arm-kernel, linux-kernel

From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>

Add documentation for USB3 PHY available in NS2 SoC

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 .../devicetree/bindings/phy/brcm,ns2-usb3-phy.txt  | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
new file mode 100644
index 000000000000..b1c058c37d54
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
@@ -0,0 +1,48 @@
+Broadcom USB3 dual port phy for Northstar2 SoC
+This is a child bus node of "brcm,mdio-mux-iproc" node.
+
+Required mdio 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-usb3-phy"
+- reg: MDIO Phy ID for the MDIO interface
+- #phy-cells: must be 0
+- #address-cells: must be 1
+- #size-cells: must be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+ - reg: the PHY number
+ - phy-cells: from the generic PHY bindings, must be 0
+
+Example:
+
+mdio@1 {
+	reg = <0x1>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	usb3_phy: usb3_phy@0 {
+		compatible = "brcm,ns2-usb3-phy";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usb3_phy0: usb3_phy@0 {
+			reg = <0>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
+		usb3_phy1: usb_phy@1 {
+			reg = <1>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+	};
+};
-- 
2.7.4

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

* [PATCH v2 1/6] dt-bindings: phy: Add documentation for NS2 USB3 PHY
@ 2017-07-26 22:56   ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: devicetree, bcm-kernel-feedback-list, linux-kernel, linux-arm-kernel

From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>

Add documentation for USB3 PHY available in NS2 SoC

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 .../devicetree/bindings/phy/brcm,ns2-usb3-phy.txt  | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
new file mode 100644
index 000000000000..b1c058c37d54
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
@@ -0,0 +1,48 @@
+Broadcom USB3 dual port phy for Northstar2 SoC
+This is a child bus node of "brcm,mdio-mux-iproc" node.
+
+Required mdio 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-usb3-phy"
+- reg: MDIO Phy ID for the MDIO interface
+- #phy-cells: must be 0
+- #address-cells: must be 1
+- #size-cells: must be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+ - reg: the PHY number
+ - phy-cells: from the generic PHY bindings, must be 0
+
+Example:
+
+mdio@1 {
+	reg = <0x1>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	usb3_phy: usb3_phy@0 {
+		compatible = "brcm,ns2-usb3-phy";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usb3_phy0: usb3_phy@0 {
+			reg = <0>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
+		usb3_phy1: usb_phy@1 {
+			reg = <1>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+	};
+};
-- 
2.7.4

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

* [PATCH v2 1/6] dt-bindings: phy: Add documentation for NS2 USB3 PHY
@ 2017-07-26 22:56   ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>

Add documentation for USB3 PHY available in NS2 SoC

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 .../devicetree/bindings/phy/brcm,ns2-usb3-phy.txt  | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
new file mode 100644
index 000000000000..b1c058c37d54
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
@@ -0,0 +1,48 @@
+Broadcom USB3 dual port phy for Northstar2 SoC
+This is a child bus node of "brcm,mdio-mux-iproc" node.
+
+Required mdio 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-usb3-phy"
+- reg: MDIO Phy ID for the MDIO interface
+- #phy-cells: must be 0
+- #address-cells: must be 1
+- #size-cells: must be 0
+
+Sub-nodes:
+  Each port's PHY should be represented as a sub-node.
+
+Sub-nodes required properties:
+ - reg: the PHY number
+ - phy-cells: from the generic PHY bindings, must be 0
+
+Example:
+
+mdio at 1 {
+	reg = <0x1>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	usb3_phy: usb3_phy at 0 {
+		compatible = "brcm,ns2-usb3-phy";
+		reg = <0x0>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		usb3_phy0: usb3_phy at 0 {
+			reg = <0>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
+		usb3_phy1: usb_phy at 1 {
+			reg = <1>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+	};
+};
-- 
2.7.4

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

* [PATCH v2 2/6] dt-bindings: usb: Add documentation for NS2 CDRU USB3
  2017-07-26 22:56 ` Jon Mason
@ 2017-07-26 22:56   ` Jon Mason
  -1 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: bcm-kernel-feedback-list, devicetree, linux-arm-kernel, linux-kernel

Add documentation for CDRU USB3 registers available in NS2 SoC

Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 .../devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt        | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
new file mode 100644
index 000000000000..30c03bef58fd
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
@@ -0,0 +1,14 @@
+Broadcom Chip Device Resource Unit USB3 register
+
+Required properties:
+- compatible: "brcm,cdru-usb3-ctrl"
+- reg: Base address and length of the USB registers
+
+
+Example:
+
+cdru_usb3_ctrl: cdru_usb3_ctrl@6501d144 {
+        compatible = "brcm,cdru-usb3-ctrl";
+        reg = <0x6501d144 0x4>;
+};
+
-- 
2.7.4

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

* [PATCH v2 2/6] dt-bindings: usb: Add documentation for NS2 CDRU USB3
@ 2017-07-26 22:56   ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: linux-arm-kernel

Add documentation for CDRU USB3 registers available in NS2 SoC

Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 .../devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt        | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
new file mode 100644
index 000000000000..30c03bef58fd
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
@@ -0,0 +1,14 @@
+Broadcom Chip Device Resource Unit USB3 register
+
+Required properties:
+- compatible: "brcm,cdru-usb3-ctrl"
+- reg: Base address and length of the USB registers
+
+
+Example:
+
+cdru_usb3_ctrl: cdru_usb3_ctrl at 6501d144 {
+        compatible = "brcm,cdru-usb3-ctrl";
+        reg = <0x6501d144 0x4>;
+};
+
-- 
2.7.4

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

* [PATCH v2 3/6] dt-bindings: usb: Add documentation for NS2 ICFG USB3
  2017-07-26 22:56 ` Jon Mason
@ 2017-07-26 22:56   ` Jon Mason
  -1 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: bcm-kernel-feedback-list, devicetree, linux-arm-kernel, linux-kernel

Add documentation for ICFG USB3 registers available in NS2 SoC

Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt b/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
new file mode 100644
index 000000000000..72176e25a692
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
@@ -0,0 +1,13 @@
+Broadcom ICFG USB3 registers
+
+Required properties:
+- compatible: "brcm,icfg-usb"
+- reg: Base address and length of the USB registers
+
+
+Example:
+
+icfg_usb3: icfg_usb3@66000900 {
+        compatible = "brcm,icfg-usb";
+        reg = <0x66000900 0x60>;
+};
-- 
2.7.4

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

* [PATCH v2 3/6] dt-bindings: usb: Add documentation for NS2 ICFG USB3
@ 2017-07-26 22:56   ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: linux-arm-kernel

Add documentation for ICFG USB3 registers available in NS2 SoC

Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt b/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
new file mode 100644
index 000000000000..72176e25a692
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
@@ -0,0 +1,13 @@
+Broadcom ICFG USB3 registers
+
+Required properties:
+- compatible: "brcm,icfg-usb"
+- reg: Base address and length of the USB registers
+
+
+Example:
+
+icfg_usb3: icfg_usb3 at 66000900 {
+        compatible = "brcm,icfg-usb";
+        reg = <0x66000900 0x60>;
+};
-- 
2.7.4

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

* [PATCH v2 4/6] dt-bindings: usb: Add documentation for NS2 IDM USB3
  2017-07-26 22:56 ` Jon Mason
@ 2017-07-26 22:56   ` Jon Mason
  -1 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: bcm-kernel-feedback-list, devicetree, linux-arm-kernel, linux-kernel

Add documentation for IDM USB3 registers available in NS2 SoC

Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt b/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
new file mode 100644
index 000000000000..3618dbcbe890
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
@@ -0,0 +1,14 @@
+Broadcom IDM USB3 registers
+
+Required properties:
+- compatible: "brcm,usb3-idm"
+- reg: Base address and length of the USB registers
+
+
+Example:
+
+usb3_idm: idm@67000000 {
+        compatible = "brcm,usb3-idm";
+        reg = <0x67000000 0x2000>;
+};
+
-- 
2.7.4

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

* [PATCH v2 4/6] dt-bindings: usb: Add documentation for NS2 IDM USB3
@ 2017-07-26 22:56   ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: linux-arm-kernel

Add documentation for IDM USB3 registers available in NS2 SoC

Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt b/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
new file mode 100644
index 000000000000..3618dbcbe890
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
@@ -0,0 +1,14 @@
+Broadcom IDM USB3 registers
+
+Required properties:
+- compatible: "brcm,usb3-idm"
+- reg: Base address and length of the USB registers
+
+
+Example:
+
+usb3_idm: idm at 67000000 {
+        compatible = "brcm,usb3-idm";
+        reg = <0x67000000 0x2000>;
+};
+
-- 
2.7.4

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

* [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC
  2017-07-26 22:56 ` Jon Mason
@ 2017-07-26 22:56   ` Jon Mason
  -1 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: bcm-kernel-feedback-list, devicetree, linux-arm-kernel, linux-kernel

From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>

This patch adds support for Broadcom NS2 USB3 PHY

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 drivers/phy/broadcom/Kconfig            |   9 +
 drivers/phy/broadcom/Makefile           |   1 +
 drivers/phy/broadcom/phy-bcm-ns2-usb3.c | 580 ++++++++++++++++++++++++++++++++
 3 files changed, 590 insertions(+)
 create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c

diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
index 37371b89b14f..e7d238efd539 100644
--- a/drivers/phy/broadcom/Kconfig
+++ b/drivers/phy/broadcom/Kconfig
@@ -45,6 +45,15 @@ config PHY_NS2_PCIE
 	  Enable this to support the Broadcom Northstar2 PCIe PHY.
 	  If unsure, say N.
 
+config PHY_NS2_USB3
+	tristate "Broadcom NorthStar2 USB3 PHY driver"
+	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
+	select GENERIC_PHY
+	default ARCH_BCM_IPROC
+	help
+	  Enable this to support the Broadcom Northstar2 USB3 PHY.
+	  If unsure, say N.
+
 config PHY_NS2_USB_DRD
 	tristate "Broadcom Northstar2 USB DRD PHY support"
 	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
index 4eb82ec8d491..a40e6e6f56b8 100644
--- a/drivers/phy/broadcom/Makefile
+++ b/drivers/phy/broadcom/Makefile
@@ -3,5 +3,6 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB2)		+= phy-bcm-ns-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB3)		+= phy-bcm-ns-usb3.o
 obj-$(CONFIG_PHY_NS2_PCIE)		+= phy-bcm-ns2-pcie.o
+obj-$(CONFIG_PHY_NS2_USB3)		+= phy-bcm-ns2-usb3.o
 obj-$(CONFIG_PHY_NS2_USB_DRD)		+= phy-bcm-ns2-usbdrd.o
 obj-$(CONFIG_PHY_BRCM_SATA)		+= phy-brcm-sata.o
diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usb3.c b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
new file mode 100644
index 000000000000..7f272757434b
--- /dev/null
+++ b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
@@ -0,0 +1,580 @@
+/*
+ * 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/delay.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mdio.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/phy/phy.h>
+
+#define NS2_USB3_PHY_MAX			0x02
+
+#define NS2_USB3_PHY_CONFIG_CTRL_REG		0x10
+#define NS2_USB3_PHY_CONFIG_CTRL_MASK		(BIT(3) | BIT(4) | BIT(5))
+#define NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START	BIT(6)
+
+#define NS2_USB3_PHY_P0CTL_REG			0x14
+#define NS2_USB3_PHY_P1CTL_REG			0x18
+#define NS2_USB3_PHY_PXCTL_I_BIT		BIT(1)
+
+#define NS2_USB3_PHY_MISC_STATUS_REG		0x20
+
+#define NS2_IDM_RST_CTRL_P0_OFFSET		0x800
+#define NS2_IDM_RST_CTRL_P1_OFFSET		0x1800
+#define NS2_IDM_RESET_CONTROL_BIT		BIT(0)
+
+#define NS2_IDM_IO_CTRL_P0_OFFSET		0x408
+#define NS2_IDM_IO_CTRL_P1_OFFSET		0x1408
+/* Bit 23 for PPC Polarity, Bit 24 for PPC NANDNOR select */
+#define NS2_IDM_IO_CTRL_PPC_CFG			(BIT(23) | BIT(24))
+
+#define NS2_PHY_RESET_BIT			BIT(5)
+#define NS2_PHY_PLL_RESET_BIT			BIT(6)
+
+/* NS2 USB3 MDIO */
+#define NS2_USB3_MDIO_PLL30_ADDR		0x8000
+#define NS2_USB3_MDIO_BLK_ACCESS		0x1F
+#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL		0x14
+#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL	0x23
+#define NS2_USB3_MDIO_PLL30_GEN_PLL		0xF
+#define NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL	BIT(11)
+#define NS2_USB3_MDIO_P0_AFE30_ADDR		0x8080
+#define NS2_USB3_MDIO_P1_AFE30_ADDR		0x9080
+#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT	0x5
+#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL	0xAC0D
+
+#define NS2_USB3_MDIO_P0_PIPE_BLK_ADDR		0x8060
+#define NS2_USB3_MDIO_P1_PIPE_BLK_ADDR		0x9060
+#define NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET	0x1
+#define NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL	0x207
+
+#define NS2_USB3_MDIO_P0_AEQ_BLK_ADDR		0x80E0
+#define NS2_USB3_MDIO_P1_AEQ_BLK_ADDR		0x90E0
+#define NS2_USB3_MDIO_AEQ_BLK_REG_1_OFFSET	0x1
+#define NS2_USB3_MDIO_AEQ_BLK_REG_1_VAL		0x3000
+
+enum ns2_phy_block {
+	PHY_RESET,
+	PHY_PLL_RESET,
+	PHY_SOFT_RESET,
+	PHY_PIPE_RESET,
+	PHY_REF_CLOCK,
+	PHY_PLL_SEQ_START,
+	PHY_PLL_STATUS,
+	PHY_VBUS_PPC,
+};
+
+enum ns2_reg_base {
+	NS2_USB3_CTRL = 1,
+	NS2_USB3_PHY_CFG,
+	NS2_USB3_RST_CTRL,
+	NS2_USB3_REG_BASE_MAX
+};
+
+struct ns2_usb3_phy {
+	void __iomem *reg_base[NS2_USB3_REG_BASE_MAX];
+	struct ns2_usb3_phy_master *mphy;
+	struct phy *phy;
+	int port_no;
+};
+
+struct ns2_usb3_phy_master {
+	struct ns2_usb3_phy iphys[NS2_USB3_PHY_MAX];
+	struct mdio_device *mdiodev;
+	struct mutex phy_mutex;
+	int init_count; /* PHY is dual port phy, so init once*/
+};
+
+static int iproc_ns2_phy_action(struct ns2_usb3_phy *iphy,
+				enum ns2_phy_block block, bool assert)
+{
+	void __iomem *addr;
+	u32  data, count;
+	u32 offset = 0;
+	int ret = 0;
+
+	switch (block) {
+	case PHY_RESET:
+		addr = iphy->reg_base[NS2_USB3_CTRL];
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data &= ~NS2_PHY_RESET_BIT;
+		else
+			data |= NS2_PHY_RESET_BIT;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_PLL_RESET:
+		addr = iphy->reg_base[NS2_USB3_CTRL];
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data &= ~NS2_PHY_PLL_RESET_BIT;
+		else
+			data |= NS2_PHY_PLL_RESET_BIT;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_SOFT_RESET:
+		addr = iphy->reg_base[NS2_USB3_PHY_CFG];
+		offset = NS2_USB3_PHY_P0CTL_REG;
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data &= ~NS2_USB3_PHY_PXCTL_I_BIT;
+		else
+			data |= NS2_USB3_PHY_PXCTL_I_BIT;
+
+		writel(data, addr + offset);
+
+		offset = NS2_USB3_PHY_P1CTL_REG;
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data &= ~NS2_USB3_PHY_PXCTL_I_BIT;
+		else
+			data |= NS2_USB3_PHY_PXCTL_I_BIT;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_PIPE_RESET:
+		addr = iphy->reg_base[NS2_USB3_RST_CTRL];
+		offset = NS2_IDM_RST_CTRL_P0_OFFSET;
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data |= NS2_IDM_RESET_CONTROL_BIT;
+		else
+			data &= ~NS2_IDM_RESET_CONTROL_BIT;
+
+		writel(data, addr + offset);
+
+		offset = NS2_IDM_RST_CTRL_P1_OFFSET;
+		data = readl(addr + offset);
+
+		if (assert)
+			data |= NS2_IDM_RESET_CONTROL_BIT;
+		else
+			data &= ~NS2_IDM_RESET_CONTROL_BIT;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_VBUS_PPC:
+		addr = iphy->reg_base[NS2_USB3_RST_CTRL];
+		offset = NS2_IDM_IO_CTRL_P0_OFFSET;
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data |= NS2_IDM_IO_CTRL_PPC_CFG;
+		else
+			data &= ~NS2_IDM_IO_CTRL_PPC_CFG;
+
+		writel(data, addr + offset);
+
+		offset = NS2_IDM_IO_CTRL_P1_OFFSET;
+		data = readl(addr + offset);
+
+		if (assert)
+			data |= NS2_IDM_IO_CTRL_PPC_CFG;
+		else
+			data &= ~NS2_IDM_IO_CTRL_PPC_CFG;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_REF_CLOCK:
+		addr = iphy->reg_base[NS2_USB3_PHY_CFG];
+		offset = NS2_USB3_PHY_CONFIG_CTRL_REG;
+
+		data = readl(addr + offset);
+
+		data &= ~NS2_USB3_PHY_CONFIG_CTRL_MASK;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_PLL_SEQ_START:
+		addr = iphy->reg_base[NS2_USB3_PHY_CFG];
+		offset = NS2_USB3_PHY_CONFIG_CTRL_REG;
+
+		data = readl(addr + offset);
+
+		data |= NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_PLL_STATUS:
+		count = 2000;
+		addr = iphy->reg_base[NS2_USB3_PHY_CFG];
+		offset = NS2_USB3_PHY_MISC_STATUS_REG;
+
+		do {
+			udelay(1);
+
+			data = readl(addr + offset);
+			if (data == 1)
+				break;
+		} while (--count);
+
+		if (!count)
+			ret = -ETIMEDOUT;
+		break;
+
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+static int ns2_usb3_phy_exit(struct phy *phy)
+{
+	struct ns2_usb3_phy *iphy = phy_get_drvdata(phy);
+	int rc = 0;
+
+	mutex_lock(&iphy->mphy->phy_mutex);
+
+	if (iphy->mphy->init_count <= 0) {
+		mutex_unlock(&iphy->mphy->phy_mutex);
+		return 0;
+	} else if (iphy->mphy->init_count == 1) {
+		/* Only put in to reset for last port to exit */
+		rc = iproc_ns2_phy_action(iphy, PHY_PLL_RESET, true);
+		if (rc)
+			goto out;
+
+		rc = iproc_ns2_phy_action(iphy, PHY_SOFT_RESET, true);
+		if (rc)
+			goto out;
+
+		rc = iproc_ns2_phy_action(iphy, PHY_RESET, true);
+		if (rc)
+			goto out;
+
+		rc = iproc_ns2_phy_action(iphy, PHY_PIPE_RESET, true);
+		if (rc)
+			goto out;
+	}
+
+out:
+	iphy->mphy->init_count--;
+	mutex_unlock(&iphy->mphy->phy_mutex);
+
+	return rc;
+}
+
+static int ns2_usb3_phy_init(struct phy *phy)
+{
+	struct ns2_usb3_phy *iphy = phy_get_drvdata(phy);
+	u16 addr;
+	u16 reg_val;
+	int rc;
+
+	mutex_lock(&iphy->mphy->phy_mutex);
+
+	if (iphy->mphy->init_count) {
+		/* Use count to identify last port to call phy_exit. */
+		iphy->mphy->init_count++;
+		mutex_unlock(&iphy->mphy->phy_mutex);
+		return 0;
+	}
+
+	rc = iproc_ns2_phy_action(iphy, PHY_RESET, false);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_SOFT_RESET, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PIPE_RESET, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_REF_CLOCK, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PLL_RESET, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_RESET, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_RESET, false);
+	if (rc)
+		goto out;
+
+	/* PLL programming */
+	/* PHY PLL30 Block */
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS,
+				NS2_USB3_MDIO_PLL30_ADDR);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PLL30_ANAPLL_CTRL,
+				NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL);
+	if (rc)
+		goto out;
+
+	reg_val = (u16) mdiobus_read(iphy->mphy->mdiodev->bus,
+				iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PLL30_GEN_PLL);
+	reg_val |= NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PLL30_GEN_PLL, reg_val);
+	if (rc)
+		goto out;
+
+	/* PHY AFE30 Block */
+	addr = NS2_USB3_MDIO_P0_AFE30_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_AFE30_RX_SIG_DETECT,
+				NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL);
+	if (rc)
+		goto out;
+
+	addr = NS2_USB3_MDIO_P1_AFE30_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_AFE30_RX_SIG_DETECT,
+				NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL);
+	if (rc)
+		goto out;
+
+	/* PHY PIPE Block */
+	addr = NS2_USB3_MDIO_P0_PIPE_BLK_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET,
+				NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL);
+	if (rc)
+		goto out;
+
+	addr = NS2_USB3_MDIO_P1_PIPE_BLK_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET,
+				NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL);
+	if (rc)
+		goto out;
+
+	/* AEQ Block */
+	addr = NS2_USB3_MDIO_P0_AEQ_BLK_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_AEQ_BLK_REG_1_OFFSET,
+				NS2_USB3_MDIO_AEQ_BLK_REG_1_VAL);
+	if (rc)
+		goto out;
+
+	/* PHY PORT_1 */
+	addr = NS2_USB3_MDIO_P1_AEQ_BLK_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_AEQ_BLK_REG_1_OFFSET,
+				NS2_USB3_MDIO_AEQ_BLK_REG_1_VAL);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PLL_SEQ_START, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PIPE_RESET, false);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_SOFT_RESET, false);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PLL_RESET, false);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PLL_STATUS, true);
+	if (rc)
+		goto out;
+
+	/* Set USB3H VBUS PPC Polarity and NandNor select */
+	rc = iproc_ns2_phy_action(iphy, PHY_VBUS_PPC, true);
+
+out:
+	iphy->mphy->init_count++;
+	mutex_unlock(&iphy->mphy->phy_mutex);
+
+	return rc;
+}
+
+static struct phy_ops ns2_usb3_phy_ops = {
+	.init = ns2_usb3_phy_init,
+	.exit = ns2_usb3_phy_exit,
+	.owner = THIS_MODULE,
+};
+
+static int ns2_usb3_phy_map_by_name(struct ns2_usb3_phy *iphy,
+				    enum ns2_reg_base reg, const char *compat)
+{
+	struct device_node *temp;
+	void __iomem *base;
+	struct device *dev = &iphy->mphy->mdiodev->dev;
+
+	temp = of_find_compatible_node(NULL, NULL, compat);
+	if (!temp) {
+		dev_err(dev, "Unable to find %s in Device Tree\n", compat);
+		return -EINVAL;
+	}
+
+	base = of_iomap(temp, 0);
+	if (!base) {
+		dev_err(dev, "Unable to map %s\n", compat);
+		return -EINVAL;
+	}
+	iphy->reg_base[reg] = base;
+
+	return 0;
+}
+
+static int ns2_usb3_phy_probe(struct mdio_device *mdiodev)
+{
+	struct device *dev = &mdiodev->dev;
+	struct device_node *dn = dev->of_node, *child;
+	struct ns2_usb3_phy_master *mphy;
+	struct phy_provider *provider;
+	int cnt;
+
+	mphy = devm_kzalloc(dev, sizeof(*mphy), GFP_KERNEL);
+	if (!mphy)
+		return -ENOMEM;
+	mphy->mdiodev = mdiodev;
+	mutex_init(&mphy->phy_mutex);
+	mphy->init_count = 0;
+
+	cnt = 0;
+	for_each_available_child_of_node(dn, child) {
+		struct ns2_usb3_phy *iphy;
+		unsigned int val;
+		int rc;
+
+		iphy = &mphy->iphys[cnt];
+		if (of_property_read_u32(child, "reg", &val)) {
+			dev_err(dev, "missing reg property in node %s\n",
+					child->name);
+			return -EINVAL;
+		}
+		iphy->port_no = val;
+		iphy->mphy = mphy;
+
+		rc = ns2_usb3_phy_map_by_name(iphy, NS2_USB3_CTRL,
+					      "brcm,cdru-usb3-ctrl");
+		if (rc)
+			return rc;
+
+		rc = ns2_usb3_phy_map_by_name(iphy, NS2_USB3_PHY_CFG,
+					      "brcm,icfg-usb");
+		if (rc)
+			return rc;
+
+		rc = ns2_usb3_phy_map_by_name(iphy, NS2_USB3_RST_CTRL,
+					      "brcm,usb3-idm");
+		if (rc)
+			return rc;
+
+		iphy->phy = devm_phy_create(dev, child, &ns2_usb3_phy_ops);
+		if (IS_ERR(iphy->phy)) {
+			dev_err(dev, "failed to create PHY\n");
+			return PTR_ERR(iphy->phy);
+		}
+
+		phy_set_drvdata(iphy->phy, iphy);
+		cnt++;
+	}
+
+	dev_set_drvdata(dev, mphy);
+	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+	if (IS_ERR(provider)) {
+		dev_err(dev, "could not register PHY provider\n");
+		return PTR_ERR(provider);
+	}
+
+	dev_info(dev, "registered %d phy(s)\n", cnt);
+	return 0;
+}
+
+static const struct of_device_id ns2_usb3_phy_of_match[] = {
+	{.compatible = "brcm,ns2-usb3-phy",},
+	{ /* sentinel */ }
+};
+
+static struct mdio_driver ns2_usb3_phy_driver = {
+	.mdiodrv = {
+		.driver = {
+			.name = "ns2-usb3-phy",
+			.of_match_table = ns2_usb3_phy_of_match,
+		},
+	},
+	.probe = ns2_usb3_phy_probe,
+};
+mdio_module_driver(ns2_usb3_phy_driver);
+
+MODULE_DESCRIPTION("Broadcom NS2 USB3 PHY driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Broadcom");
-- 
2.7.4

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

* [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC
@ 2017-07-26 22:56   ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>

This patch adds support for Broadcom NS2 USB3 PHY

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 drivers/phy/broadcom/Kconfig            |   9 +
 drivers/phy/broadcom/Makefile           |   1 +
 drivers/phy/broadcom/phy-bcm-ns2-usb3.c | 580 ++++++++++++++++++++++++++++++++
 3 files changed, 590 insertions(+)
 create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c

diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
index 37371b89b14f..e7d238efd539 100644
--- a/drivers/phy/broadcom/Kconfig
+++ b/drivers/phy/broadcom/Kconfig
@@ -45,6 +45,15 @@ config PHY_NS2_PCIE
 	  Enable this to support the Broadcom Northstar2 PCIe PHY.
 	  If unsure, say N.
 
+config PHY_NS2_USB3
+	tristate "Broadcom NorthStar2 USB3 PHY driver"
+	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
+	select GENERIC_PHY
+	default ARCH_BCM_IPROC
+	help
+	  Enable this to support the Broadcom Northstar2 USB3 PHY.
+	  If unsure, say N.
+
 config PHY_NS2_USB_DRD
 	tristate "Broadcom Northstar2 USB DRD PHY support"
 	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
index 4eb82ec8d491..a40e6e6f56b8 100644
--- a/drivers/phy/broadcom/Makefile
+++ b/drivers/phy/broadcom/Makefile
@@ -3,5 +3,6 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB2)		+= phy-bcm-ns-usb2.o
 obj-$(CONFIG_PHY_BCM_NS_USB3)		+= phy-bcm-ns-usb3.o
 obj-$(CONFIG_PHY_NS2_PCIE)		+= phy-bcm-ns2-pcie.o
+obj-$(CONFIG_PHY_NS2_USB3)		+= phy-bcm-ns2-usb3.o
 obj-$(CONFIG_PHY_NS2_USB_DRD)		+= phy-bcm-ns2-usbdrd.o
 obj-$(CONFIG_PHY_BRCM_SATA)		+= phy-brcm-sata.o
diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usb3.c b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
new file mode 100644
index 000000000000..7f272757434b
--- /dev/null
+++ b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
@@ -0,0 +1,580 @@
+/*
+ * 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/delay.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mdio.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/phy/phy.h>
+
+#define NS2_USB3_PHY_MAX			0x02
+
+#define NS2_USB3_PHY_CONFIG_CTRL_REG		0x10
+#define NS2_USB3_PHY_CONFIG_CTRL_MASK		(BIT(3) | BIT(4) | BIT(5))
+#define NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START	BIT(6)
+
+#define NS2_USB3_PHY_P0CTL_REG			0x14
+#define NS2_USB3_PHY_P1CTL_REG			0x18
+#define NS2_USB3_PHY_PXCTL_I_BIT		BIT(1)
+
+#define NS2_USB3_PHY_MISC_STATUS_REG		0x20
+
+#define NS2_IDM_RST_CTRL_P0_OFFSET		0x800
+#define NS2_IDM_RST_CTRL_P1_OFFSET		0x1800
+#define NS2_IDM_RESET_CONTROL_BIT		BIT(0)
+
+#define NS2_IDM_IO_CTRL_P0_OFFSET		0x408
+#define NS2_IDM_IO_CTRL_P1_OFFSET		0x1408
+/* Bit 23 for PPC Polarity, Bit 24 for PPC NANDNOR select */
+#define NS2_IDM_IO_CTRL_PPC_CFG			(BIT(23) | BIT(24))
+
+#define NS2_PHY_RESET_BIT			BIT(5)
+#define NS2_PHY_PLL_RESET_BIT			BIT(6)
+
+/* NS2 USB3 MDIO */
+#define NS2_USB3_MDIO_PLL30_ADDR		0x8000
+#define NS2_USB3_MDIO_BLK_ACCESS		0x1F
+#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL		0x14
+#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL	0x23
+#define NS2_USB3_MDIO_PLL30_GEN_PLL		0xF
+#define NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL	BIT(11)
+#define NS2_USB3_MDIO_P0_AFE30_ADDR		0x8080
+#define NS2_USB3_MDIO_P1_AFE30_ADDR		0x9080
+#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT	0x5
+#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL	0xAC0D
+
+#define NS2_USB3_MDIO_P0_PIPE_BLK_ADDR		0x8060
+#define NS2_USB3_MDIO_P1_PIPE_BLK_ADDR		0x9060
+#define NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET	0x1
+#define NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL	0x207
+
+#define NS2_USB3_MDIO_P0_AEQ_BLK_ADDR		0x80E0
+#define NS2_USB3_MDIO_P1_AEQ_BLK_ADDR		0x90E0
+#define NS2_USB3_MDIO_AEQ_BLK_REG_1_OFFSET	0x1
+#define NS2_USB3_MDIO_AEQ_BLK_REG_1_VAL		0x3000
+
+enum ns2_phy_block {
+	PHY_RESET,
+	PHY_PLL_RESET,
+	PHY_SOFT_RESET,
+	PHY_PIPE_RESET,
+	PHY_REF_CLOCK,
+	PHY_PLL_SEQ_START,
+	PHY_PLL_STATUS,
+	PHY_VBUS_PPC,
+};
+
+enum ns2_reg_base {
+	NS2_USB3_CTRL = 1,
+	NS2_USB3_PHY_CFG,
+	NS2_USB3_RST_CTRL,
+	NS2_USB3_REG_BASE_MAX
+};
+
+struct ns2_usb3_phy {
+	void __iomem *reg_base[NS2_USB3_REG_BASE_MAX];
+	struct ns2_usb3_phy_master *mphy;
+	struct phy *phy;
+	int port_no;
+};
+
+struct ns2_usb3_phy_master {
+	struct ns2_usb3_phy iphys[NS2_USB3_PHY_MAX];
+	struct mdio_device *mdiodev;
+	struct mutex phy_mutex;
+	int init_count; /* PHY is dual port phy, so init once*/
+};
+
+static int iproc_ns2_phy_action(struct ns2_usb3_phy *iphy,
+				enum ns2_phy_block block, bool assert)
+{
+	void __iomem *addr;
+	u32  data, count;
+	u32 offset = 0;
+	int ret = 0;
+
+	switch (block) {
+	case PHY_RESET:
+		addr = iphy->reg_base[NS2_USB3_CTRL];
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data &= ~NS2_PHY_RESET_BIT;
+		else
+			data |= NS2_PHY_RESET_BIT;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_PLL_RESET:
+		addr = iphy->reg_base[NS2_USB3_CTRL];
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data &= ~NS2_PHY_PLL_RESET_BIT;
+		else
+			data |= NS2_PHY_PLL_RESET_BIT;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_SOFT_RESET:
+		addr = iphy->reg_base[NS2_USB3_PHY_CFG];
+		offset = NS2_USB3_PHY_P0CTL_REG;
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data &= ~NS2_USB3_PHY_PXCTL_I_BIT;
+		else
+			data |= NS2_USB3_PHY_PXCTL_I_BIT;
+
+		writel(data, addr + offset);
+
+		offset = NS2_USB3_PHY_P1CTL_REG;
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data &= ~NS2_USB3_PHY_PXCTL_I_BIT;
+		else
+			data |= NS2_USB3_PHY_PXCTL_I_BIT;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_PIPE_RESET:
+		addr = iphy->reg_base[NS2_USB3_RST_CTRL];
+		offset = NS2_IDM_RST_CTRL_P0_OFFSET;
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data |= NS2_IDM_RESET_CONTROL_BIT;
+		else
+			data &= ~NS2_IDM_RESET_CONTROL_BIT;
+
+		writel(data, addr + offset);
+
+		offset = NS2_IDM_RST_CTRL_P1_OFFSET;
+		data = readl(addr + offset);
+
+		if (assert)
+			data |= NS2_IDM_RESET_CONTROL_BIT;
+		else
+			data &= ~NS2_IDM_RESET_CONTROL_BIT;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_VBUS_PPC:
+		addr = iphy->reg_base[NS2_USB3_RST_CTRL];
+		offset = NS2_IDM_IO_CTRL_P0_OFFSET;
+
+		data = readl(addr + offset);
+
+		if (assert)
+			data |= NS2_IDM_IO_CTRL_PPC_CFG;
+		else
+			data &= ~NS2_IDM_IO_CTRL_PPC_CFG;
+
+		writel(data, addr + offset);
+
+		offset = NS2_IDM_IO_CTRL_P1_OFFSET;
+		data = readl(addr + offset);
+
+		if (assert)
+			data |= NS2_IDM_IO_CTRL_PPC_CFG;
+		else
+			data &= ~NS2_IDM_IO_CTRL_PPC_CFG;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_REF_CLOCK:
+		addr = iphy->reg_base[NS2_USB3_PHY_CFG];
+		offset = NS2_USB3_PHY_CONFIG_CTRL_REG;
+
+		data = readl(addr + offset);
+
+		data &= ~NS2_USB3_PHY_CONFIG_CTRL_MASK;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_PLL_SEQ_START:
+		addr = iphy->reg_base[NS2_USB3_PHY_CFG];
+		offset = NS2_USB3_PHY_CONFIG_CTRL_REG;
+
+		data = readl(addr + offset);
+
+		data |= NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START;
+
+		writel(data, addr + offset);
+		break;
+
+	case PHY_PLL_STATUS:
+		count = 2000;
+		addr = iphy->reg_base[NS2_USB3_PHY_CFG];
+		offset = NS2_USB3_PHY_MISC_STATUS_REG;
+
+		do {
+			udelay(1);
+
+			data = readl(addr + offset);
+			if (data == 1)
+				break;
+		} while (--count);
+
+		if (!count)
+			ret = -ETIMEDOUT;
+		break;
+
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+static int ns2_usb3_phy_exit(struct phy *phy)
+{
+	struct ns2_usb3_phy *iphy = phy_get_drvdata(phy);
+	int rc = 0;
+
+	mutex_lock(&iphy->mphy->phy_mutex);
+
+	if (iphy->mphy->init_count <= 0) {
+		mutex_unlock(&iphy->mphy->phy_mutex);
+		return 0;
+	} else if (iphy->mphy->init_count == 1) {
+		/* Only put in to reset for last port to exit */
+		rc = iproc_ns2_phy_action(iphy, PHY_PLL_RESET, true);
+		if (rc)
+			goto out;
+
+		rc = iproc_ns2_phy_action(iphy, PHY_SOFT_RESET, true);
+		if (rc)
+			goto out;
+
+		rc = iproc_ns2_phy_action(iphy, PHY_RESET, true);
+		if (rc)
+			goto out;
+
+		rc = iproc_ns2_phy_action(iphy, PHY_PIPE_RESET, true);
+		if (rc)
+			goto out;
+	}
+
+out:
+	iphy->mphy->init_count--;
+	mutex_unlock(&iphy->mphy->phy_mutex);
+
+	return rc;
+}
+
+static int ns2_usb3_phy_init(struct phy *phy)
+{
+	struct ns2_usb3_phy *iphy = phy_get_drvdata(phy);
+	u16 addr;
+	u16 reg_val;
+	int rc;
+
+	mutex_lock(&iphy->mphy->phy_mutex);
+
+	if (iphy->mphy->init_count) {
+		/* Use count to identify last port to call phy_exit. */
+		iphy->mphy->init_count++;
+		mutex_unlock(&iphy->mphy->phy_mutex);
+		return 0;
+	}
+
+	rc = iproc_ns2_phy_action(iphy, PHY_RESET, false);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_SOFT_RESET, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PIPE_RESET, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_REF_CLOCK, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PLL_RESET, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_RESET, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_RESET, false);
+	if (rc)
+		goto out;
+
+	/* PLL programming */
+	/* PHY PLL30 Block */
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS,
+				NS2_USB3_MDIO_PLL30_ADDR);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PLL30_ANAPLL_CTRL,
+				NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL);
+	if (rc)
+		goto out;
+
+	reg_val = (u16) mdiobus_read(iphy->mphy->mdiodev->bus,
+				iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PLL30_GEN_PLL);
+	reg_val |= NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PLL30_GEN_PLL, reg_val);
+	if (rc)
+		goto out;
+
+	/* PHY AFE30 Block */
+	addr = NS2_USB3_MDIO_P0_AFE30_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_AFE30_RX_SIG_DETECT,
+				NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL);
+	if (rc)
+		goto out;
+
+	addr = NS2_USB3_MDIO_P1_AFE30_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_AFE30_RX_SIG_DETECT,
+				NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL);
+	if (rc)
+		goto out;
+
+	/* PHY PIPE Block */
+	addr = NS2_USB3_MDIO_P0_PIPE_BLK_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET,
+				NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL);
+	if (rc)
+		goto out;
+
+	addr = NS2_USB3_MDIO_P1_PIPE_BLK_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET,
+				NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL);
+	if (rc)
+		goto out;
+
+	/* AEQ Block */
+	addr = NS2_USB3_MDIO_P0_AEQ_BLK_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_AEQ_BLK_REG_1_OFFSET,
+				NS2_USB3_MDIO_AEQ_BLK_REG_1_VAL);
+	if (rc)
+		goto out;
+
+	/* PHY PORT_1 */
+	addr = NS2_USB3_MDIO_P1_AEQ_BLK_ADDR;
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_BLK_ACCESS, addr);
+	if (rc)
+		goto out;
+
+	rc = mdiobus_write(iphy->mphy->mdiodev->bus, iphy->mphy->mdiodev->addr,
+				NS2_USB3_MDIO_AEQ_BLK_REG_1_OFFSET,
+				NS2_USB3_MDIO_AEQ_BLK_REG_1_VAL);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PLL_SEQ_START, true);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PIPE_RESET, false);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_SOFT_RESET, false);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PLL_RESET, false);
+	if (rc)
+		goto out;
+
+	rc = iproc_ns2_phy_action(iphy, PHY_PLL_STATUS, true);
+	if (rc)
+		goto out;
+
+	/* Set USB3H VBUS PPC Polarity and NandNor select */
+	rc = iproc_ns2_phy_action(iphy, PHY_VBUS_PPC, true);
+
+out:
+	iphy->mphy->init_count++;
+	mutex_unlock(&iphy->mphy->phy_mutex);
+
+	return rc;
+}
+
+static struct phy_ops ns2_usb3_phy_ops = {
+	.init = ns2_usb3_phy_init,
+	.exit = ns2_usb3_phy_exit,
+	.owner = THIS_MODULE,
+};
+
+static int ns2_usb3_phy_map_by_name(struct ns2_usb3_phy *iphy,
+				    enum ns2_reg_base reg, const char *compat)
+{
+	struct device_node *temp;
+	void __iomem *base;
+	struct device *dev = &iphy->mphy->mdiodev->dev;
+
+	temp = of_find_compatible_node(NULL, NULL, compat);
+	if (!temp) {
+		dev_err(dev, "Unable to find %s in Device Tree\n", compat);
+		return -EINVAL;
+	}
+
+	base = of_iomap(temp, 0);
+	if (!base) {
+		dev_err(dev, "Unable to map %s\n", compat);
+		return -EINVAL;
+	}
+	iphy->reg_base[reg] = base;
+
+	return 0;
+}
+
+static int ns2_usb3_phy_probe(struct mdio_device *mdiodev)
+{
+	struct device *dev = &mdiodev->dev;
+	struct device_node *dn = dev->of_node, *child;
+	struct ns2_usb3_phy_master *mphy;
+	struct phy_provider *provider;
+	int cnt;
+
+	mphy = devm_kzalloc(dev, sizeof(*mphy), GFP_KERNEL);
+	if (!mphy)
+		return -ENOMEM;
+	mphy->mdiodev = mdiodev;
+	mutex_init(&mphy->phy_mutex);
+	mphy->init_count = 0;
+
+	cnt = 0;
+	for_each_available_child_of_node(dn, child) {
+		struct ns2_usb3_phy *iphy;
+		unsigned int val;
+		int rc;
+
+		iphy = &mphy->iphys[cnt];
+		if (of_property_read_u32(child, "reg", &val)) {
+			dev_err(dev, "missing reg property in node %s\n",
+					child->name);
+			return -EINVAL;
+		}
+		iphy->port_no = val;
+		iphy->mphy = mphy;
+
+		rc = ns2_usb3_phy_map_by_name(iphy, NS2_USB3_CTRL,
+					      "brcm,cdru-usb3-ctrl");
+		if (rc)
+			return rc;
+
+		rc = ns2_usb3_phy_map_by_name(iphy, NS2_USB3_PHY_CFG,
+					      "brcm,icfg-usb");
+		if (rc)
+			return rc;
+
+		rc = ns2_usb3_phy_map_by_name(iphy, NS2_USB3_RST_CTRL,
+					      "brcm,usb3-idm");
+		if (rc)
+			return rc;
+
+		iphy->phy = devm_phy_create(dev, child, &ns2_usb3_phy_ops);
+		if (IS_ERR(iphy->phy)) {
+			dev_err(dev, "failed to create PHY\n");
+			return PTR_ERR(iphy->phy);
+		}
+
+		phy_set_drvdata(iphy->phy, iphy);
+		cnt++;
+	}
+
+	dev_set_drvdata(dev, mphy);
+	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+	if (IS_ERR(provider)) {
+		dev_err(dev, "could not register PHY provider\n");
+		return PTR_ERR(provider);
+	}
+
+	dev_info(dev, "registered %d phy(s)\n", cnt);
+	return 0;
+}
+
+static const struct of_device_id ns2_usb3_phy_of_match[] = {
+	{.compatible = "brcm,ns2-usb3-phy",},
+	{ /* sentinel */ }
+};
+
+static struct mdio_driver ns2_usb3_phy_driver = {
+	.mdiodrv = {
+		.driver = {
+			.name = "ns2-usb3-phy",
+			.of_match_table = ns2_usb3_phy_of_match,
+		},
+	},
+	.probe = ns2_usb3_phy_probe,
+};
+mdio_module_driver(ns2_usb3_phy_driver);
+
+MODULE_DESCRIPTION("Broadcom NS2 USB3 PHY driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Broadcom");
-- 
2.7.4

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

* [PATCH v2 6/6] arm64: dts: ns2: Add USB3 Support
  2017-07-26 22:56 ` Jon Mason
@ 2017-07-26 22:56   ` Jon Mason
  -1 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: bcm-kernel-feedback-list, devicetree, linux-arm-kernel, linux-kernel

From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>

Add USB3 support to the Northstar2 Device tree files

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 arch/arm64/boot/dts/broadcom/ns2-svk.dts | 16 +++++++++
 arch/arm64/boot/dts/broadcom/ns2-xmc.dts |  8 +++++
 arch/arm64/boot/dts/broadcom/ns2.dtsi    | 59 ++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+)

diff --git a/arch/arm64/boot/dts/broadcom/ns2-svk.dts b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
index ec19fbf928a1..7cd2ef77103f 100644
--- a/arch/arm64/boot/dts/broadcom/ns2-svk.dts
+++ b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
@@ -234,3 +234,19 @@
 		};
 	};
 };
+
+&usb3_phy0 {
+	status = "okay";
+};
+
+&usb3_phy1 {
+	status = "okay";
+};
+
+&xhci0 {
+	status = "okay";
+};
+
+&xhci1 {
+	status = "okay";
+};
diff --git a/arch/arm64/boot/dts/broadcom/ns2-xmc.dts b/arch/arm64/boot/dts/broadcom/ns2-xmc.dts
index ab4ae1a32fab..8e8feb7db4ba 100644
--- a/arch/arm64/boot/dts/broadcom/ns2-xmc.dts
+++ b/arch/arm64/boot/dts/broadcom/ns2-xmc.dts
@@ -189,3 +189,11 @@
 &uart3 {
 	status = "okay";
 };
+
+&usb3_phy0 {
+	status = "okay";
+};
+
+&xhci0 {
+	status = "okay";
+};
diff --git a/arch/arm64/boot/dts/broadcom/ns2.dtsi b/arch/arm64/boot/dts/broadcom/ns2.dtsi
index 35c8457e3d1f..838010f8e58b 100644
--- a/arch/arm64/boot/dts/broadcom/ns2.dtsi
+++ b/arch/arm64/boot/dts/broadcom/ns2.dtsi
@@ -343,6 +343,11 @@
 			      <0x660009b0 0x40>;
 		};
 
+		cdru_usb3_ctrl: cdru_usb3_ctrl@6501d144 {
+			compatible = "brcm,cdru-usb3-ctrl";
+			reg = <0x6501d144 0x4>;
+		};
+
 		gpio_aon: gpio@65024800 {
 			compatible = "brcm,iproc-gpio";
 			reg = <0x65024800 0x50>,
@@ -460,6 +465,11 @@
 			};
 		};
 
+		icfg_usb3: icfg_usb3@66000900 {
+			compatible = "brcm,icfg-usb";
+			reg = <0x66000900 0x60>;
+		};
+
 		usbdrd_phy: phy@66000960 {
 			#phy-cells = <0>;
 			compatible = "brcm,ns2-drd-phy";
@@ -501,6 +511,31 @@
 				};
 			};
 
+			mdio@1 {
+				reg = <0x1>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				usb3_phy: usb3_phy@0 {
+					compatible = "brcm,ns2-usb3-phy";
+					reg = <0x0>;
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					usb3_phy0: usb3_phy@0 {
+						reg = <0>;
+						#phy-cells = <0>;
+						status = "disabled";
+					};
+
+					usb3_phy1: usb_phy@1 {
+						reg = <1>;
+						#phy-cells = <0>;
+						status = "disabled";
+					};
+				};
+			};
+
 			mdio@7 {
 				reg = <0x7>;
 				#address-cells = <1>;
@@ -666,6 +701,26 @@
 			reg = <0x66220000 0x28>;
 		};
 
+		xhci0: usb@66300000 {
+			compatible = "generic-xhci";
+			reg = <0x66300000 0x1000>;
+			interrupts = <GIC_SPI 429 IRQ_TYPE_LEVEL_HIGH>;
+			phys = <&usb3_phy0>;
+			phy-names = "usb";
+			dma-coherent;
+			status = "disabled";
+		};
+
+		xhci1: usb@66310000 {
+			compatible = "generic-xhci";
+			reg = <0x66310000 0x1000>;
+			interrupts = <GIC_SPI 433 IRQ_TYPE_LEVEL_HIGH>;
+			phys = <&usb3_phy1>;
+			phy-names = "usb";
+			dma-coherent;
+			status = "disabled";
+		};
+
 		sata_phy: sata_phy@663f0100 {
 			compatible = "brcm,iproc-ns2-sata-phy";
 			reg = <0x663f0100 0x1f00>,
@@ -761,5 +816,9 @@
 			#size-cells = <0>;
 		};
 
+		usb3_idm: idm@67000000 {
+			compatible = "brcm,usb3-idm";
+			reg = <0x67000000 0x2000>;
+		};
 	};
 };
-- 
2.7.4

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

* [PATCH v2 6/6] arm64: dts: ns2: Add USB3 Support
@ 2017-07-26 22:56   ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-07-26 22:56 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>

Add USB3 support to the Northstar2 Device tree files

Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
 arch/arm64/boot/dts/broadcom/ns2-svk.dts | 16 +++++++++
 arch/arm64/boot/dts/broadcom/ns2-xmc.dts |  8 +++++
 arch/arm64/boot/dts/broadcom/ns2.dtsi    | 59 ++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+)

diff --git a/arch/arm64/boot/dts/broadcom/ns2-svk.dts b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
index ec19fbf928a1..7cd2ef77103f 100644
--- a/arch/arm64/boot/dts/broadcom/ns2-svk.dts
+++ b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
@@ -234,3 +234,19 @@
 		};
 	};
 };
+
+&usb3_phy0 {
+	status = "okay";
+};
+
+&usb3_phy1 {
+	status = "okay";
+};
+
+&xhci0 {
+	status = "okay";
+};
+
+&xhci1 {
+	status = "okay";
+};
diff --git a/arch/arm64/boot/dts/broadcom/ns2-xmc.dts b/arch/arm64/boot/dts/broadcom/ns2-xmc.dts
index ab4ae1a32fab..8e8feb7db4ba 100644
--- a/arch/arm64/boot/dts/broadcom/ns2-xmc.dts
+++ b/arch/arm64/boot/dts/broadcom/ns2-xmc.dts
@@ -189,3 +189,11 @@
 &uart3 {
 	status = "okay";
 };
+
+&usb3_phy0 {
+	status = "okay";
+};
+
+&xhci0 {
+	status = "okay";
+};
diff --git a/arch/arm64/boot/dts/broadcom/ns2.dtsi b/arch/arm64/boot/dts/broadcom/ns2.dtsi
index 35c8457e3d1f..838010f8e58b 100644
--- a/arch/arm64/boot/dts/broadcom/ns2.dtsi
+++ b/arch/arm64/boot/dts/broadcom/ns2.dtsi
@@ -343,6 +343,11 @@
 			      <0x660009b0 0x40>;
 		};
 
+		cdru_usb3_ctrl: cdru_usb3_ctrl at 6501d144 {
+			compatible = "brcm,cdru-usb3-ctrl";
+			reg = <0x6501d144 0x4>;
+		};
+
 		gpio_aon: gpio at 65024800 {
 			compatible = "brcm,iproc-gpio";
 			reg = <0x65024800 0x50>,
@@ -460,6 +465,11 @@
 			};
 		};
 
+		icfg_usb3: icfg_usb3 at 66000900 {
+			compatible = "brcm,icfg-usb";
+			reg = <0x66000900 0x60>;
+		};
+
 		usbdrd_phy: phy at 66000960 {
 			#phy-cells = <0>;
 			compatible = "brcm,ns2-drd-phy";
@@ -501,6 +511,31 @@
 				};
 			};
 
+			mdio at 1 {
+				reg = <0x1>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				usb3_phy: usb3_phy at 0 {
+					compatible = "brcm,ns2-usb3-phy";
+					reg = <0x0>;
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					usb3_phy0: usb3_phy at 0 {
+						reg = <0>;
+						#phy-cells = <0>;
+						status = "disabled";
+					};
+
+					usb3_phy1: usb_phy at 1 {
+						reg = <1>;
+						#phy-cells = <0>;
+						status = "disabled";
+					};
+				};
+			};
+
 			mdio at 7 {
 				reg = <0x7>;
 				#address-cells = <1>;
@@ -666,6 +701,26 @@
 			reg = <0x66220000 0x28>;
 		};
 
+		xhci0: usb at 66300000 {
+			compatible = "generic-xhci";
+			reg = <0x66300000 0x1000>;
+			interrupts = <GIC_SPI 429 IRQ_TYPE_LEVEL_HIGH>;
+			phys = <&usb3_phy0>;
+			phy-names = "usb";
+			dma-coherent;
+			status = "disabled";
+		};
+
+		xhci1: usb at 66310000 {
+			compatible = "generic-xhci";
+			reg = <0x66310000 0x1000>;
+			interrupts = <GIC_SPI 433 IRQ_TYPE_LEVEL_HIGH>;
+			phys = <&usb3_phy1>;
+			phy-names = "usb";
+			dma-coherent;
+			status = "disabled";
+		};
+
 		sata_phy: sata_phy at 663f0100 {
 			compatible = "brcm,iproc-ns2-sata-phy";
 			reg = <0x663f0100 0x1f00>,
@@ -761,5 +816,9 @@
 			#size-cells = <0>;
 		};
 
+		usb3_idm: idm at 67000000 {
+			compatible = "brcm,usb3-idm";
+			reg = <0x67000000 0x2000>;
+		};
 	};
 };
-- 
2.7.4

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

* Re: [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC
  2017-07-26 22:56   ` Jon Mason
  (?)
@ 2017-08-02  6:36     ` Kishon Vijay Abraham I
  -1 siblings, 0 replies; 31+ messages in thread
From: Kishon Vijay Abraham I @ 2017-08-02  6:36 UTC (permalink / raw)
  To: Jon Mason, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: bcm-kernel-feedback-list, devicetree, linux-arm-kernel, linux-kernel

Hi,

On Thursday 27 July 2017 04:26 AM, Jon Mason wrote:
> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> 
> This patch adds support for Broadcom NS2 USB3 PHY
> 
> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  drivers/phy/broadcom/Kconfig            |   9 +
>  drivers/phy/broadcom/Makefile           |   1 +
>  drivers/phy/broadcom/phy-bcm-ns2-usb3.c | 580 ++++++++++++++++++++++++++++++++
>  3 files changed, 590 insertions(+)
>  create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> 
> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
> index 37371b89b14f..e7d238efd539 100644
> --- a/drivers/phy/broadcom/Kconfig
> +++ b/drivers/phy/broadcom/Kconfig
> @@ -45,6 +45,15 @@ config PHY_NS2_PCIE
>  	  Enable this to support the Broadcom Northstar2 PCIe PHY.
>  	  If unsure, say N.
>  
> +config PHY_NS2_USB3
> +	tristate "Broadcom NorthStar2 USB3 PHY driver"
> +	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
> +	select GENERIC_PHY

depends on MDIO_BUS?
> +	default ARCH_BCM_IPROC
> +	help
> +	  Enable this to support the Broadcom Northstar2 USB3 PHY.
> +	  If unsure, say N.
> +
>  config PHY_NS2_USB_DRD
>  	tristate "Broadcom Northstar2 USB DRD PHY support"
>  	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
> index 4eb82ec8d491..a40e6e6f56b8 100644
> --- a/drivers/phy/broadcom/Makefile
> +++ b/drivers/phy/broadcom/Makefile
> @@ -3,5 +3,6 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB2)		+= phy-bcm-ns-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB3)		+= phy-bcm-ns-usb3.o
>  obj-$(CONFIG_PHY_NS2_PCIE)		+= phy-bcm-ns2-pcie.o
> +obj-$(CONFIG_PHY_NS2_USB3)		+= phy-bcm-ns2-usb3.o
>  obj-$(CONFIG_PHY_NS2_USB_DRD)		+= phy-bcm-ns2-usbdrd.o
>  obj-$(CONFIG_PHY_BRCM_SATA)		+= phy-brcm-sata.o
> diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usb3.c b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> new file mode 100644
> index 000000000000..7f272757434b
> --- /dev/null
> +++ b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> @@ -0,0 +1,580 @@
> +/*
> + * 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/delay.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/mdio.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/phy/phy.h>
> +
> +#define NS2_USB3_PHY_MAX			0x02
> +
> +#define NS2_USB3_PHY_CONFIG_CTRL_REG		0x10
> +#define NS2_USB3_PHY_CONFIG_CTRL_MASK		(BIT(3) | BIT(4) | BIT(5))
> +#define NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START	BIT(6)
> +
> +#define NS2_USB3_PHY_P0CTL_REG			0x14
> +#define NS2_USB3_PHY_P1CTL_REG			0x18
> +#define NS2_USB3_PHY_PXCTL_I_BIT		BIT(1)
> +
> +#define NS2_USB3_PHY_MISC_STATUS_REG		0x20
> +
> +#define NS2_IDM_RST_CTRL_P0_OFFSET		0x800
> +#define NS2_IDM_RST_CTRL_P1_OFFSET		0x1800
> +#define NS2_IDM_RESET_CONTROL_BIT		BIT(0)
> +
> +#define NS2_IDM_IO_CTRL_P0_OFFSET		0x408
> +#define NS2_IDM_IO_CTRL_P1_OFFSET		0x1408
> +/* Bit 23 for PPC Polarity, Bit 24 for PPC NANDNOR select */
> +#define NS2_IDM_IO_CTRL_PPC_CFG			(BIT(23) | BIT(24))
> +
> +#define NS2_PHY_RESET_BIT			BIT(5)
> +#define NS2_PHY_PLL_RESET_BIT			BIT(6)
> +
> +/* NS2 USB3 MDIO */
> +#define NS2_USB3_MDIO_PLL30_ADDR		0x8000
> +#define NS2_USB3_MDIO_BLK_ACCESS		0x1F
> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL		0x14
> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL	0x23
> +#define NS2_USB3_MDIO_PLL30_GEN_PLL		0xF
> +#define NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL	BIT(11)
> +#define NS2_USB3_MDIO_P0_AFE30_ADDR		0x8080
> +#define NS2_USB3_MDIO_P1_AFE30_ADDR		0x9080
> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT	0x5
> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL	0xAC0D
> +
> +#define NS2_USB3_MDIO_P0_PIPE_BLK_ADDR		0x8060
> +#define NS2_USB3_MDIO_P1_PIPE_BLK_ADDR		0x9060
> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET	0x1
> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL	0x207
> +
> +#define NS2_USB3_MDIO_P0_AEQ_BLK_ADDR		0x80E0
> +#define NS2_USB3_MDIO_P1_AEQ_BLK_ADDR		0x90E0

Looking at the register offsets, P0 and P1 can be abstracted IMO. i.e you can
simply have 'NS2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET 0x60' and the base address can
come from dt. For P0 it should be 0x8000 and P1 it should be 0x9000.

Then when the consumer requests for initialization of P0, it can be just
P0 base address + S2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET and likewise for P1.

Same thing is applicable for NS2_USB3_MDIO_P0_AEQ_BLK_ADDR,
NS2_USB3_MDIO_P0_AFE30_ADDR etc.

Thanks
Kishon

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

* Re: [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC
@ 2017-08-02  6:36     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 31+ messages in thread
From: Kishon Vijay Abraham I @ 2017-08-02  6:36 UTC (permalink / raw)
  To: Jon Mason, Florian Fainelli, Rob Herring, Mark Rutland
  Cc: devicetree, bcm-kernel-feedback-list, linux-kernel, linux-arm-kernel

Hi,

On Thursday 27 July 2017 04:26 AM, Jon Mason wrote:
> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> 
> This patch adds support for Broadcom NS2 USB3 PHY
> 
> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  drivers/phy/broadcom/Kconfig            |   9 +
>  drivers/phy/broadcom/Makefile           |   1 +
>  drivers/phy/broadcom/phy-bcm-ns2-usb3.c | 580 ++++++++++++++++++++++++++++++++
>  3 files changed, 590 insertions(+)
>  create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> 
> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
> index 37371b89b14f..e7d238efd539 100644
> --- a/drivers/phy/broadcom/Kconfig
> +++ b/drivers/phy/broadcom/Kconfig
> @@ -45,6 +45,15 @@ config PHY_NS2_PCIE
>  	  Enable this to support the Broadcom Northstar2 PCIe PHY.
>  	  If unsure, say N.
>  
> +config PHY_NS2_USB3
> +	tristate "Broadcom NorthStar2 USB3 PHY driver"
> +	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
> +	select GENERIC_PHY

depends on MDIO_BUS?
> +	default ARCH_BCM_IPROC
> +	help
> +	  Enable this to support the Broadcom Northstar2 USB3 PHY.
> +	  If unsure, say N.
> +
>  config PHY_NS2_USB_DRD
>  	tristate "Broadcom Northstar2 USB DRD PHY support"
>  	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
> index 4eb82ec8d491..a40e6e6f56b8 100644
> --- a/drivers/phy/broadcom/Makefile
> +++ b/drivers/phy/broadcom/Makefile
> @@ -3,5 +3,6 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB2)		+= phy-bcm-ns-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB3)		+= phy-bcm-ns-usb3.o
>  obj-$(CONFIG_PHY_NS2_PCIE)		+= phy-bcm-ns2-pcie.o
> +obj-$(CONFIG_PHY_NS2_USB3)		+= phy-bcm-ns2-usb3.o
>  obj-$(CONFIG_PHY_NS2_USB_DRD)		+= phy-bcm-ns2-usbdrd.o
>  obj-$(CONFIG_PHY_BRCM_SATA)		+= phy-brcm-sata.o
> diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usb3.c b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> new file mode 100644
> index 000000000000..7f272757434b
> --- /dev/null
> +++ b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> @@ -0,0 +1,580 @@
> +/*
> + * 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/delay.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/mdio.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/phy/phy.h>
> +
> +#define NS2_USB3_PHY_MAX			0x02
> +
> +#define NS2_USB3_PHY_CONFIG_CTRL_REG		0x10
> +#define NS2_USB3_PHY_CONFIG_CTRL_MASK		(BIT(3) | BIT(4) | BIT(5))
> +#define NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START	BIT(6)
> +
> +#define NS2_USB3_PHY_P0CTL_REG			0x14
> +#define NS2_USB3_PHY_P1CTL_REG			0x18
> +#define NS2_USB3_PHY_PXCTL_I_BIT		BIT(1)
> +
> +#define NS2_USB3_PHY_MISC_STATUS_REG		0x20
> +
> +#define NS2_IDM_RST_CTRL_P0_OFFSET		0x800
> +#define NS2_IDM_RST_CTRL_P1_OFFSET		0x1800
> +#define NS2_IDM_RESET_CONTROL_BIT		BIT(0)
> +
> +#define NS2_IDM_IO_CTRL_P0_OFFSET		0x408
> +#define NS2_IDM_IO_CTRL_P1_OFFSET		0x1408
> +/* Bit 23 for PPC Polarity, Bit 24 for PPC NANDNOR select */
> +#define NS2_IDM_IO_CTRL_PPC_CFG			(BIT(23) | BIT(24))
> +
> +#define NS2_PHY_RESET_BIT			BIT(5)
> +#define NS2_PHY_PLL_RESET_BIT			BIT(6)
> +
> +/* NS2 USB3 MDIO */
> +#define NS2_USB3_MDIO_PLL30_ADDR		0x8000
> +#define NS2_USB3_MDIO_BLK_ACCESS		0x1F
> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL		0x14
> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL	0x23
> +#define NS2_USB3_MDIO_PLL30_GEN_PLL		0xF
> +#define NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL	BIT(11)
> +#define NS2_USB3_MDIO_P0_AFE30_ADDR		0x8080
> +#define NS2_USB3_MDIO_P1_AFE30_ADDR		0x9080
> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT	0x5
> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL	0xAC0D
> +
> +#define NS2_USB3_MDIO_P0_PIPE_BLK_ADDR		0x8060
> +#define NS2_USB3_MDIO_P1_PIPE_BLK_ADDR		0x9060
> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET	0x1
> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL	0x207
> +
> +#define NS2_USB3_MDIO_P0_AEQ_BLK_ADDR		0x80E0
> +#define NS2_USB3_MDIO_P1_AEQ_BLK_ADDR		0x90E0

Looking at the register offsets, P0 and P1 can be abstracted IMO. i.e you can
simply have 'NS2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET 0x60' and the base address can
come from dt. For P0 it should be 0x8000 and P1 it should be 0x9000.

Then when the consumer requests for initialization of P0, it can be just
P0 base address + S2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET and likewise for P1.

Same thing is applicable for NS2_USB3_MDIO_P0_AEQ_BLK_ADDR,
NS2_USB3_MDIO_P0_AFE30_ADDR etc.

Thanks
Kishon

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

* [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC
@ 2017-08-02  6:36     ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 31+ messages in thread
From: Kishon Vijay Abraham I @ 2017-08-02  6:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Thursday 27 July 2017 04:26 AM, Jon Mason wrote:
> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> 
> This patch adds support for Broadcom NS2 USB3 PHY
> 
> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  drivers/phy/broadcom/Kconfig            |   9 +
>  drivers/phy/broadcom/Makefile           |   1 +
>  drivers/phy/broadcom/phy-bcm-ns2-usb3.c | 580 ++++++++++++++++++++++++++++++++
>  3 files changed, 590 insertions(+)
>  create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> 
> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
> index 37371b89b14f..e7d238efd539 100644
> --- a/drivers/phy/broadcom/Kconfig
> +++ b/drivers/phy/broadcom/Kconfig
> @@ -45,6 +45,15 @@ config PHY_NS2_PCIE
>  	  Enable this to support the Broadcom Northstar2 PCIe PHY.
>  	  If unsure, say N.
>  
> +config PHY_NS2_USB3
> +	tristate "Broadcom NorthStar2 USB3 PHY driver"
> +	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
> +	select GENERIC_PHY

depends on MDIO_BUS?
> +	default ARCH_BCM_IPROC
> +	help
> +	  Enable this to support the Broadcom Northstar2 USB3 PHY.
> +	  If unsure, say N.
> +
>  config PHY_NS2_USB_DRD
>  	tristate "Broadcom Northstar2 USB DRD PHY support"
>  	depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
> index 4eb82ec8d491..a40e6e6f56b8 100644
> --- a/drivers/phy/broadcom/Makefile
> +++ b/drivers/phy/broadcom/Makefile
> @@ -3,5 +3,6 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY)		+= phy-bcm-kona-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB2)		+= phy-bcm-ns-usb2.o
>  obj-$(CONFIG_PHY_BCM_NS_USB3)		+= phy-bcm-ns-usb3.o
>  obj-$(CONFIG_PHY_NS2_PCIE)		+= phy-bcm-ns2-pcie.o
> +obj-$(CONFIG_PHY_NS2_USB3)		+= phy-bcm-ns2-usb3.o
>  obj-$(CONFIG_PHY_NS2_USB_DRD)		+= phy-bcm-ns2-usbdrd.o
>  obj-$(CONFIG_PHY_BRCM_SATA)		+= phy-brcm-sata.o
> diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usb3.c b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> new file mode 100644
> index 000000000000..7f272757434b
> --- /dev/null
> +++ b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
> @@ -0,0 +1,580 @@
> +/*
> + * 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/delay.h>
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/mdio.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/phy/phy.h>
> +
> +#define NS2_USB3_PHY_MAX			0x02
> +
> +#define NS2_USB3_PHY_CONFIG_CTRL_REG		0x10
> +#define NS2_USB3_PHY_CONFIG_CTRL_MASK		(BIT(3) | BIT(4) | BIT(5))
> +#define NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START	BIT(6)
> +
> +#define NS2_USB3_PHY_P0CTL_REG			0x14
> +#define NS2_USB3_PHY_P1CTL_REG			0x18
> +#define NS2_USB3_PHY_PXCTL_I_BIT		BIT(1)
> +
> +#define NS2_USB3_PHY_MISC_STATUS_REG		0x20
> +
> +#define NS2_IDM_RST_CTRL_P0_OFFSET		0x800
> +#define NS2_IDM_RST_CTRL_P1_OFFSET		0x1800
> +#define NS2_IDM_RESET_CONTROL_BIT		BIT(0)
> +
> +#define NS2_IDM_IO_CTRL_P0_OFFSET		0x408
> +#define NS2_IDM_IO_CTRL_P1_OFFSET		0x1408
> +/* Bit 23 for PPC Polarity, Bit 24 for PPC NANDNOR select */
> +#define NS2_IDM_IO_CTRL_PPC_CFG			(BIT(23) | BIT(24))
> +
> +#define NS2_PHY_RESET_BIT			BIT(5)
> +#define NS2_PHY_PLL_RESET_BIT			BIT(6)
> +
> +/* NS2 USB3 MDIO */
> +#define NS2_USB3_MDIO_PLL30_ADDR		0x8000
> +#define NS2_USB3_MDIO_BLK_ACCESS		0x1F
> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL		0x14
> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL	0x23
> +#define NS2_USB3_MDIO_PLL30_GEN_PLL		0xF
> +#define NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL	BIT(11)
> +#define NS2_USB3_MDIO_P0_AFE30_ADDR		0x8080
> +#define NS2_USB3_MDIO_P1_AFE30_ADDR		0x9080
> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT	0x5
> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL	0xAC0D
> +
> +#define NS2_USB3_MDIO_P0_PIPE_BLK_ADDR		0x8060
> +#define NS2_USB3_MDIO_P1_PIPE_BLK_ADDR		0x9060
> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET	0x1
> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL	0x207
> +
> +#define NS2_USB3_MDIO_P0_AEQ_BLK_ADDR		0x80E0
> +#define NS2_USB3_MDIO_P1_AEQ_BLK_ADDR		0x90E0

Looking at the register offsets, P0 and P1 can be abstracted IMO. i.e you can
simply have 'NS2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET 0x60' and the base address can
come from dt. For P0 it should be 0x8000 and P1 it should be 0x9000.

Then when the consumer requests for initialization of P0, it can be just
P0 base address + S2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET and likewise for P1.

Same thing is applicable for NS2_USB3_MDIO_P0_AEQ_BLK_ADDR,
NS2_USB3_MDIO_P0_AFE30_ADDR etc.

Thanks
Kishon

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

* Re: [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC
@ 2017-08-03 15:23       ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-08-03 15:23 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Florian Fainelli, Rob Herring, Mark Rutland, BCM Kernel Feedback,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-arm-kernel, open list

On Wed, Aug 2, 2017 at 2:36 AM, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> Hi,
>
> On Thursday 27 July 2017 04:26 AM, Jon Mason wrote:
>> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
>>
>> This patch adds support for Broadcom NS2 USB3 PHY
>>
>> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
>> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
>> ---
>>  drivers/phy/broadcom/Kconfig            |   9 +
>>  drivers/phy/broadcom/Makefile           |   1 +
>>  drivers/phy/broadcom/phy-bcm-ns2-usb3.c | 580 ++++++++++++++++++++++++++++++++
>>  3 files changed, 590 insertions(+)
>>  create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>>
>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>> index 37371b89b14f..e7d238efd539 100644
>> --- a/drivers/phy/broadcom/Kconfig
>> +++ b/drivers/phy/broadcom/Kconfig
>> @@ -45,6 +45,15 @@ config PHY_NS2_PCIE
>>         Enable this to support the Broadcom Northstar2 PCIe PHY.
>>         If unsure, say N.
>>
>> +config PHY_NS2_USB3
>> +     tristate "Broadcom NorthStar2 USB3 PHY driver"
>> +     depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
>> +     select GENERIC_PHY
>
> depends on MDIO_BUS?
>> +     default ARCH_BCM_IPROC
>> +     help
>> +       Enable this to support the Broadcom Northstar2 USB3 PHY.
>> +       If unsure, say N.
>> +
>>  config PHY_NS2_USB_DRD
>>       tristate "Broadcom Northstar2 USB DRD PHY support"
>>       depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>> index 4eb82ec8d491..a40e6e6f56b8 100644
>> --- a/drivers/phy/broadcom/Makefile
>> +++ b/drivers/phy/broadcom/Makefile
>> @@ -3,5 +3,6 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY)               += phy-bcm-kona-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB2)                += phy-bcm-ns-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB3)                += phy-bcm-ns-usb3.o
>>  obj-$(CONFIG_PHY_NS2_PCIE)           += phy-bcm-ns2-pcie.o
>> +obj-$(CONFIG_PHY_NS2_USB3)           += phy-bcm-ns2-usb3.o
>>  obj-$(CONFIG_PHY_NS2_USB_DRD)                += phy-bcm-ns2-usbdrd.o
>>  obj-$(CONFIG_PHY_BRCM_SATA)          += phy-brcm-sata.o
>> diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usb3.c b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>> new file mode 100644
>> index 000000000000..7f272757434b
>> --- /dev/null
>> +++ b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>> @@ -0,0 +1,580 @@
>> +/*
>> + * 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/delay.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/mdio.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_address.h>
>> +#include <linux/phy/phy.h>
>> +
>> +#define NS2_USB3_PHY_MAX                     0x02
>> +
>> +#define NS2_USB3_PHY_CONFIG_CTRL_REG         0x10
>> +#define NS2_USB3_PHY_CONFIG_CTRL_MASK                (BIT(3) | BIT(4) | BIT(5))
>> +#define NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START       BIT(6)
>> +
>> +#define NS2_USB3_PHY_P0CTL_REG                       0x14
>> +#define NS2_USB3_PHY_P1CTL_REG                       0x18
>> +#define NS2_USB3_PHY_PXCTL_I_BIT             BIT(1)
>> +
>> +#define NS2_USB3_PHY_MISC_STATUS_REG         0x20
>> +
>> +#define NS2_IDM_RST_CTRL_P0_OFFSET           0x800
>> +#define NS2_IDM_RST_CTRL_P1_OFFSET           0x1800
>> +#define NS2_IDM_RESET_CONTROL_BIT            BIT(0)
>> +
>> +#define NS2_IDM_IO_CTRL_P0_OFFSET            0x408
>> +#define NS2_IDM_IO_CTRL_P1_OFFSET            0x1408
>> +/* Bit 23 for PPC Polarity, Bit 24 for PPC NANDNOR select */
>> +#define NS2_IDM_IO_CTRL_PPC_CFG                      (BIT(23) | BIT(24))
>> +
>> +#define NS2_PHY_RESET_BIT                    BIT(5)
>> +#define NS2_PHY_PLL_RESET_BIT                        BIT(6)
>> +
>> +/* NS2 USB3 MDIO */
>> +#define NS2_USB3_MDIO_PLL30_ADDR             0x8000
>> +#define NS2_USB3_MDIO_BLK_ACCESS             0x1F
>> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL              0x14
>> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL  0x23
>> +#define NS2_USB3_MDIO_PLL30_GEN_PLL          0xF
>> +#define NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL BIT(11)
>> +#define NS2_USB3_MDIO_P0_AFE30_ADDR          0x8080
>> +#define NS2_USB3_MDIO_P1_AFE30_ADDR          0x9080
>> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT    0x5
>> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL        0xAC0D
>> +
>> +#define NS2_USB3_MDIO_P0_PIPE_BLK_ADDR               0x8060
>> +#define NS2_USB3_MDIO_P1_PIPE_BLK_ADDR               0x9060
>> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET  0x1
>> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL     0x207
>> +
>> +#define NS2_USB3_MDIO_P0_AEQ_BLK_ADDR                0x80E0
>> +#define NS2_USB3_MDIO_P1_AEQ_BLK_ADDR                0x90E0
>
> Looking at the register offsets, P0 and P1 can be abstracted IMO. i.e you can
> simply have 'NS2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET 0x60' and the base address can
> come from dt. For P0 it should be 0x8000 and P1 it should be 0x9000.
>
> Then when the consumer requests for initialization of P0, it can be just
> P0 base address + S2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET and likewise for P1.
>
> Same thing is applicable for NS2_USB3_MDIO_P0_AEQ_BLK_ADDR,
> NS2_USB3_MDIO_P0_AFE30_ADDR etc.

Thanks for the input.  These are good suggestions.  I'll make the
changes and push a new version shortly.

Thanks,
Jon

>
> Thanks
> Kishon

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

* Re: [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC
@ 2017-08-03 15:23       ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-08-03 15:23 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Florian Fainelli, Rob Herring, Mark Rutland, BCM Kernel Feedback,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-arm-kernel, open list

On Wed, Aug 2, 2017 at 2:36 AM, Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org> wrote:
> Hi,
>
> On Thursday 27 July 2017 04:26 AM, Jon Mason wrote:
>> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
>>
>> This patch adds support for Broadcom NS2 USB3 PHY
>>
>> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
>> Signed-off-by: Jon Mason <jon.mason-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
>> ---
>>  drivers/phy/broadcom/Kconfig            |   9 +
>>  drivers/phy/broadcom/Makefile           |   1 +
>>  drivers/phy/broadcom/phy-bcm-ns2-usb3.c | 580 ++++++++++++++++++++++++++++++++
>>  3 files changed, 590 insertions(+)
>>  create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>>
>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>> index 37371b89b14f..e7d238efd539 100644
>> --- a/drivers/phy/broadcom/Kconfig
>> +++ b/drivers/phy/broadcom/Kconfig
>> @@ -45,6 +45,15 @@ config PHY_NS2_PCIE
>>         Enable this to support the Broadcom Northstar2 PCIe PHY.
>>         If unsure, say N.
>>
>> +config PHY_NS2_USB3
>> +     tristate "Broadcom NorthStar2 USB3 PHY driver"
>> +     depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
>> +     select GENERIC_PHY
>
> depends on MDIO_BUS?
>> +     default ARCH_BCM_IPROC
>> +     help
>> +       Enable this to support the Broadcom Northstar2 USB3 PHY.
>> +       If unsure, say N.
>> +
>>  config PHY_NS2_USB_DRD
>>       tristate "Broadcom Northstar2 USB DRD PHY support"
>>       depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>> index 4eb82ec8d491..a40e6e6f56b8 100644
>> --- a/drivers/phy/broadcom/Makefile
>> +++ b/drivers/phy/broadcom/Makefile
>> @@ -3,5 +3,6 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY)               += phy-bcm-kona-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB2)                += phy-bcm-ns-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB3)                += phy-bcm-ns-usb3.o
>>  obj-$(CONFIG_PHY_NS2_PCIE)           += phy-bcm-ns2-pcie.o
>> +obj-$(CONFIG_PHY_NS2_USB3)           += phy-bcm-ns2-usb3.o
>>  obj-$(CONFIG_PHY_NS2_USB_DRD)                += phy-bcm-ns2-usbdrd.o
>>  obj-$(CONFIG_PHY_BRCM_SATA)          += phy-brcm-sata.o
>> diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usb3.c b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>> new file mode 100644
>> index 000000000000..7f272757434b
>> --- /dev/null
>> +++ b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>> @@ -0,0 +1,580 @@
>> +/*
>> + * 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/delay.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/mdio.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_address.h>
>> +#include <linux/phy/phy.h>
>> +
>> +#define NS2_USB3_PHY_MAX                     0x02
>> +
>> +#define NS2_USB3_PHY_CONFIG_CTRL_REG         0x10
>> +#define NS2_USB3_PHY_CONFIG_CTRL_MASK                (BIT(3) | BIT(4) | BIT(5))
>> +#define NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START       BIT(6)
>> +
>> +#define NS2_USB3_PHY_P0CTL_REG                       0x14
>> +#define NS2_USB3_PHY_P1CTL_REG                       0x18
>> +#define NS2_USB3_PHY_PXCTL_I_BIT             BIT(1)
>> +
>> +#define NS2_USB3_PHY_MISC_STATUS_REG         0x20
>> +
>> +#define NS2_IDM_RST_CTRL_P0_OFFSET           0x800
>> +#define NS2_IDM_RST_CTRL_P1_OFFSET           0x1800
>> +#define NS2_IDM_RESET_CONTROL_BIT            BIT(0)
>> +
>> +#define NS2_IDM_IO_CTRL_P0_OFFSET            0x408
>> +#define NS2_IDM_IO_CTRL_P1_OFFSET            0x1408
>> +/* Bit 23 for PPC Polarity, Bit 24 for PPC NANDNOR select */
>> +#define NS2_IDM_IO_CTRL_PPC_CFG                      (BIT(23) | BIT(24))
>> +
>> +#define NS2_PHY_RESET_BIT                    BIT(5)
>> +#define NS2_PHY_PLL_RESET_BIT                        BIT(6)
>> +
>> +/* NS2 USB3 MDIO */
>> +#define NS2_USB3_MDIO_PLL30_ADDR             0x8000
>> +#define NS2_USB3_MDIO_BLK_ACCESS             0x1F
>> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL              0x14
>> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL  0x23
>> +#define NS2_USB3_MDIO_PLL30_GEN_PLL          0xF
>> +#define NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL BIT(11)
>> +#define NS2_USB3_MDIO_P0_AFE30_ADDR          0x8080
>> +#define NS2_USB3_MDIO_P1_AFE30_ADDR          0x9080
>> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT    0x5
>> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL        0xAC0D
>> +
>> +#define NS2_USB3_MDIO_P0_PIPE_BLK_ADDR               0x8060
>> +#define NS2_USB3_MDIO_P1_PIPE_BLK_ADDR               0x9060
>> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET  0x1
>> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL     0x207
>> +
>> +#define NS2_USB3_MDIO_P0_AEQ_BLK_ADDR                0x80E0
>> +#define NS2_USB3_MDIO_P1_AEQ_BLK_ADDR                0x90E0
>
> Looking at the register offsets, P0 and P1 can be abstracted IMO. i.e you can
> simply have 'NS2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET 0x60' and the base address can
> come from dt. For P0 it should be 0x8000 and P1 it should be 0x9000.
>
> Then when the consumer requests for initialization of P0, it can be just
> P0 base address + S2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET and likewise for P1.
>
> Same thing is applicable for NS2_USB3_MDIO_P0_AEQ_BLK_ADDR,
> NS2_USB3_MDIO_P0_AFE30_ADDR etc.

Thanks for the input.  These are good suggestions.  I'll make the
changes and push a new version shortly.

Thanks,
Jon

>
> 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] 31+ messages in thread

* [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC
@ 2017-08-03 15:23       ` Jon Mason
  0 siblings, 0 replies; 31+ messages in thread
From: Jon Mason @ 2017-08-03 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 2, 2017 at 2:36 AM, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> Hi,
>
> On Thursday 27 July 2017 04:26 AM, Jon Mason wrote:
>> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
>>
>> This patch adds support for Broadcom NS2 USB3 PHY
>>
>> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
>> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
>> ---
>>  drivers/phy/broadcom/Kconfig            |   9 +
>>  drivers/phy/broadcom/Makefile           |   1 +
>>  drivers/phy/broadcom/phy-bcm-ns2-usb3.c | 580 ++++++++++++++++++++++++++++++++
>>  3 files changed, 590 insertions(+)
>>  create mode 100644 drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>>
>> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
>> index 37371b89b14f..e7d238efd539 100644
>> --- a/drivers/phy/broadcom/Kconfig
>> +++ b/drivers/phy/broadcom/Kconfig
>> @@ -45,6 +45,15 @@ config PHY_NS2_PCIE
>>         Enable this to support the Broadcom Northstar2 PCIe PHY.
>>         If unsure, say N.
>>
>> +config PHY_NS2_USB3
>> +     tristate "Broadcom NorthStar2 USB3 PHY driver"
>> +     depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
>> +     select GENERIC_PHY
>
> depends on MDIO_BUS?
>> +     default ARCH_BCM_IPROC
>> +     help
>> +       Enable this to support the Broadcom Northstar2 USB3 PHY.
>> +       If unsure, say N.
>> +
>>  config PHY_NS2_USB_DRD
>>       tristate "Broadcom Northstar2 USB DRD PHY support"
>>       depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
>> diff --git a/drivers/phy/broadcom/Makefile b/drivers/phy/broadcom/Makefile
>> index 4eb82ec8d491..a40e6e6f56b8 100644
>> --- a/drivers/phy/broadcom/Makefile
>> +++ b/drivers/phy/broadcom/Makefile
>> @@ -3,5 +3,6 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY)               += phy-bcm-kona-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB2)                += phy-bcm-ns-usb2.o
>>  obj-$(CONFIG_PHY_BCM_NS_USB3)                += phy-bcm-ns-usb3.o
>>  obj-$(CONFIG_PHY_NS2_PCIE)           += phy-bcm-ns2-pcie.o
>> +obj-$(CONFIG_PHY_NS2_USB3)           += phy-bcm-ns2-usb3.o
>>  obj-$(CONFIG_PHY_NS2_USB_DRD)                += phy-bcm-ns2-usbdrd.o
>>  obj-$(CONFIG_PHY_BRCM_SATA)          += phy-brcm-sata.o
>> diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usb3.c b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>> new file mode 100644
>> index 000000000000..7f272757434b
>> --- /dev/null
>> +++ b/drivers/phy/broadcom/phy-bcm-ns2-usb3.c
>> @@ -0,0 +1,580 @@
>> +/*
>> + * 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/delay.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/mdio.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/of_address.h>
>> +#include <linux/phy/phy.h>
>> +
>> +#define NS2_USB3_PHY_MAX                     0x02
>> +
>> +#define NS2_USB3_PHY_CONFIG_CTRL_REG         0x10
>> +#define NS2_USB3_PHY_CONFIG_CTRL_MASK                (BIT(3) | BIT(4) | BIT(5))
>> +#define NS2_USB3_PHY_CONFIG_CTRL_PLL_SEQ_START       BIT(6)
>> +
>> +#define NS2_USB3_PHY_P0CTL_REG                       0x14
>> +#define NS2_USB3_PHY_P1CTL_REG                       0x18
>> +#define NS2_USB3_PHY_PXCTL_I_BIT             BIT(1)
>> +
>> +#define NS2_USB3_PHY_MISC_STATUS_REG         0x20
>> +
>> +#define NS2_IDM_RST_CTRL_P0_OFFSET           0x800
>> +#define NS2_IDM_RST_CTRL_P1_OFFSET           0x1800
>> +#define NS2_IDM_RESET_CONTROL_BIT            BIT(0)
>> +
>> +#define NS2_IDM_IO_CTRL_P0_OFFSET            0x408
>> +#define NS2_IDM_IO_CTRL_P1_OFFSET            0x1408
>> +/* Bit 23 for PPC Polarity, Bit 24 for PPC NANDNOR select */
>> +#define NS2_IDM_IO_CTRL_PPC_CFG                      (BIT(23) | BIT(24))
>> +
>> +#define NS2_PHY_RESET_BIT                    BIT(5)
>> +#define NS2_PHY_PLL_RESET_BIT                        BIT(6)
>> +
>> +/* NS2 USB3 MDIO */
>> +#define NS2_USB3_MDIO_PLL30_ADDR             0x8000
>> +#define NS2_USB3_MDIO_BLK_ACCESS             0x1F
>> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL              0x14
>> +#define NS2_USB3_MDIO_PLL30_ANAPLL_CTRL_VAL  0x23
>> +#define NS2_USB3_MDIO_PLL30_GEN_PLL          0xF
>> +#define NS2_USB3_MDIO_PLL30_GEN_PLL_PCLK_SEL BIT(11)
>> +#define NS2_USB3_MDIO_P0_AFE30_ADDR          0x8080
>> +#define NS2_USB3_MDIO_P1_AFE30_ADDR          0x9080
>> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT    0x5
>> +#define NS2_USB3_MDIO_AFE30_RX_SIG_DETECT_VAL        0xAC0D
>> +
>> +#define NS2_USB3_MDIO_P0_PIPE_BLK_ADDR               0x8060
>> +#define NS2_USB3_MDIO_P1_PIPE_BLK_ADDR               0x9060
>> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_OFFSET  0x1
>> +#define NS2_USB3_MDIO_PIPE_BLK_REG_1_VAL     0x207
>> +
>> +#define NS2_USB3_MDIO_P0_AEQ_BLK_ADDR                0x80E0
>> +#define NS2_USB3_MDIO_P1_AEQ_BLK_ADDR                0x90E0
>
> Looking at the register offsets, P0 and P1 can be abstracted IMO. i.e you can
> simply have 'NS2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET 0x60' and the base address can
> come from dt. For P0 it should be 0x8000 and P1 it should be 0x9000.
>
> Then when the consumer requests for initialization of P0, it can be just
> P0 base address + S2_USB3_MDIO_PIPE_BLK_ADDR_OFFSET and likewise for P1.
>
> Same thing is applicable for NS2_USB3_MDIO_P0_AEQ_BLK_ADDR,
> NS2_USB3_MDIO_P0_AFE30_ADDR etc.

Thanks for the input.  These are good suggestions.  I'll make the
changes and push a new version shortly.

Thanks,
Jon

>
> Thanks
> Kishon

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

* Re: [PATCH v2 1/6] dt-bindings: phy: Add documentation for NS2 USB3 PHY
@ 2017-08-03 19:03     ` Rob Herring
  0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:03 UTC (permalink / raw)
  To: Jon Mason
  Cc: Kishon Vijay Abraham I, Florian Fainelli, Mark Rutland,
	bcm-kernel-feedback-list, devicetree, linux-arm-kernel,
	linux-kernel

On Wed, Jul 26, 2017 at 06:56:22PM -0400, Jon Mason wrote:
> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> 
> Add documentation for USB3 PHY available in NS2 SoC
> 
> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  .../devicetree/bindings/phy/brcm,ns2-usb3-phy.txt  | 48 ++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> 
> diff --git a/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> new file mode 100644
> index 000000000000..b1c058c37d54
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> @@ -0,0 +1,48 @@
> +Broadcom USB3 dual port phy for Northstar2 SoC
> +This is a child bus node of "brcm,mdio-mux-iproc" node.
> +
> +Required mdio 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-usb3-phy"
> +- reg: MDIO Phy ID for the MDIO interface
> +- #phy-cells: must be 0
> +- #address-cells: must be 1
> +- #size-cells: must be 0
> +
> +Sub-nodes:
> +  Each port's PHY should be represented as a sub-node.
> +
> +Sub-nodes required properties:
> + - reg: the PHY number
> + - phy-cells: from the generic PHY bindings, must be 0
> +
> +Example:
> +
> +mdio@1 {
> +	reg = <0x1>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	usb3_phy: usb3_phy@0 {

usb3-phy@0

> +		compatible = "brcm,ns2-usb3-phy";
> +		reg = <0x0>;
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		usb3_phy0: usb3_phy@0 {
> +			reg = <0>;
> +			#phy-cells = <0>;
> +			status = "disabled";

Don't show status in examples.

With those nits fixed,

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


> +		};
> +
> +		usb3_phy1: usb_phy@1 {
> +			reg = <1>;
> +			#phy-cells = <0>;
> +			status = "disabled";
> +		};
> +	};
> +};
> -- 
> 2.7.4
> 

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

* Re: [PATCH v2 1/6] dt-bindings: phy: Add documentation for NS2 USB3 PHY
@ 2017-08-03 19:03     ` Rob Herring
  0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:03 UTC (permalink / raw)
  To: Jon Mason
  Cc: Kishon Vijay Abraham I, Florian Fainelli, Mark Rutland,
	bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Wed, Jul 26, 2017 at 06:56:22PM -0400, Jon Mason wrote:
> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> 
> Add documentation for USB3 PHY available in NS2 SoC
> 
> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Jon Mason <jon.mason-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> ---
>  .../devicetree/bindings/phy/brcm,ns2-usb3-phy.txt  | 48 ++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> 
> diff --git a/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> new file mode 100644
> index 000000000000..b1c058c37d54
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> @@ -0,0 +1,48 @@
> +Broadcom USB3 dual port phy for Northstar2 SoC
> +This is a child bus node of "brcm,mdio-mux-iproc" node.
> +
> +Required mdio 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-usb3-phy"
> +- reg: MDIO Phy ID for the MDIO interface
> +- #phy-cells: must be 0
> +- #address-cells: must be 1
> +- #size-cells: must be 0
> +
> +Sub-nodes:
> +  Each port's PHY should be represented as a sub-node.
> +
> +Sub-nodes required properties:
> + - reg: the PHY number
> + - phy-cells: from the generic PHY bindings, must be 0
> +
> +Example:
> +
> +mdio@1 {
> +	reg = <0x1>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	usb3_phy: usb3_phy@0 {

usb3-phy@0

> +		compatible = "brcm,ns2-usb3-phy";
> +		reg = <0x0>;
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		usb3_phy0: usb3_phy@0 {
> +			reg = <0>;
> +			#phy-cells = <0>;
> +			status = "disabled";

Don't show status in examples.

With those nits fixed,

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>


> +		};
> +
> +		usb3_phy1: usb_phy@1 {
> +			reg = <1>;
> +			#phy-cells = <0>;
> +			status = "disabled";
> +		};
> +	};
> +};
> -- 
> 2.7.4
> 
--
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] 31+ messages in thread

* [PATCH v2 1/6] dt-bindings: phy: Add documentation for NS2 USB3 PHY
@ 2017-08-03 19:03     ` Rob Herring
  0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 26, 2017 at 06:56:22PM -0400, Jon Mason wrote:
> From: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> 
> Add documentation for USB3 PHY available in NS2 SoC
> 
> Signed-off-by: Yendapally Reddy Dhananjaya Reddy <yendapally.reddy@broadcom.com>
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  .../devicetree/bindings/phy/brcm,ns2-usb3-phy.txt  | 48 ++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> 
> diff --git a/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> new file mode 100644
> index 000000000000..b1c058c37d54
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/brcm,ns2-usb3-phy.txt
> @@ -0,0 +1,48 @@
> +Broadcom USB3 dual port phy for Northstar2 SoC
> +This is a child bus node of "brcm,mdio-mux-iproc" node.
> +
> +Required mdio 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-usb3-phy"
> +- reg: MDIO Phy ID for the MDIO interface
> +- #phy-cells: must be 0
> +- #address-cells: must be 1
> +- #size-cells: must be 0
> +
> +Sub-nodes:
> +  Each port's PHY should be represented as a sub-node.
> +
> +Sub-nodes required properties:
> + - reg: the PHY number
> + - phy-cells: from the generic PHY bindings, must be 0
> +
> +Example:
> +
> +mdio at 1 {
> +	reg = <0x1>;
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +
> +	usb3_phy: usb3_phy at 0 {

usb3-phy at 0

> +		compatible = "brcm,ns2-usb3-phy";
> +		reg = <0x0>;
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		usb3_phy0: usb3_phy at 0 {
> +			reg = <0>;
> +			#phy-cells = <0>;
> +			status = "disabled";

Don't show status in examples.

With those nits fixed,

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


> +		};
> +
> +		usb3_phy1: usb_phy at 1 {
> +			reg = <1>;
> +			#phy-cells = <0>;
> +			status = "disabled";
> +		};
> +	};
> +};
> -- 
> 2.7.4
> 

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

* Re: [PATCH v2 2/6] dt-bindings: usb: Add documentation for NS2 CDRU USB3
@ 2017-08-03 19:05     ` Rob Herring
  0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:05 UTC (permalink / raw)
  To: Jon Mason
  Cc: Kishon Vijay Abraham I, Florian Fainelli, Mark Rutland,
	bcm-kernel-feedback-list, devicetree, linux-arm-kernel,
	linux-kernel

On Wed, Jul 26, 2017 at 06:56:23PM -0400, Jon Mason wrote:
> Add documentation for CDRU USB3 registers available in NS2 SoC
> 
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  .../devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt        | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> new file mode 100644
> index 000000000000..30c03bef58fd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> @@ -0,0 +1,14 @@
> +Broadcom Chip Device Resource Unit USB3 register
> +
> +Required properties:
> +- compatible: "brcm,cdru-usb3-ctrl"
> +- reg: Base address and length of the USB registers
> +
> +
> +Example:
> +
> +cdru_usb3_ctrl: cdru_usb3_ctrl@6501d144 {

s/_/-/

With that,

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

> +        compatible = "brcm,cdru-usb3-ctrl";
> +        reg = <0x6501d144 0x4>;
> +};
> +
> -- 
> 2.7.4
> 

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

* Re: [PATCH v2 2/6] dt-bindings: usb: Add documentation for NS2 CDRU USB3
@ 2017-08-03 19:05     ` Rob Herring
  0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:05 UTC (permalink / raw)
  To: Jon Mason
  Cc: Kishon Vijay Abraham I, Florian Fainelli, Mark Rutland,
	bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Wed, Jul 26, 2017 at 06:56:23PM -0400, Jon Mason wrote:
> Add documentation for CDRU USB3 registers available in NS2 SoC
> 
> Signed-off-by: Jon Mason <jon.mason-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
> ---
>  .../devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt        | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> new file mode 100644
> index 000000000000..30c03bef58fd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> @@ -0,0 +1,14 @@
> +Broadcom Chip Device Resource Unit USB3 register
> +
> +Required properties:
> +- compatible: "brcm,cdru-usb3-ctrl"
> +- reg: Base address and length of the USB registers
> +
> +
> +Example:
> +
> +cdru_usb3_ctrl: cdru_usb3_ctrl@6501d144 {

s/_/-/

With that,

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

> +        compatible = "brcm,cdru-usb3-ctrl";
> +        reg = <0x6501d144 0x4>;
> +};
> +
> -- 
> 2.7.4
> 
--
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] 31+ messages in thread

* [PATCH v2 2/6] dt-bindings: usb: Add documentation for NS2 CDRU USB3
@ 2017-08-03 19:05     ` Rob Herring
  0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:05 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 26, 2017 at 06:56:23PM -0400, Jon Mason wrote:
> Add documentation for CDRU USB3 registers available in NS2 SoC
> 
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  .../devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt        | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> new file mode 100644
> index 000000000000..30c03bef58fd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/brcm,cdru-usb3-ctrl.txt
> @@ -0,0 +1,14 @@
> +Broadcom Chip Device Resource Unit USB3 register
> +
> +Required properties:
> +- compatible: "brcm,cdru-usb3-ctrl"
> +- reg: Base address and length of the USB registers
> +
> +
> +Example:
> +
> +cdru_usb3_ctrl: cdru_usb3_ctrl at 6501d144 {

s/_/-/

With that,

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

> +        compatible = "brcm,cdru-usb3-ctrl";
> +        reg = <0x6501d144 0x4>;
> +};
> +
> -- 
> 2.7.4
> 

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

* Re: [PATCH v2 3/6] dt-bindings: usb: Add documentation for NS2 ICFG USB3
  2017-07-26 22:56   ` Jon Mason
@ 2017-08-03 19:06     ` Rob Herring
  -1 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:06 UTC (permalink / raw)
  To: Jon Mason
  Cc: Kishon Vijay Abraham I, Florian Fainelli, Mark Rutland,
	bcm-kernel-feedback-list, devicetree, linux-arm-kernel,
	linux-kernel

On Wed, Jul 26, 2017 at 06:56:24PM -0400, Jon Mason wrote:
> Add documentation for ICFG USB3 registers available in NS2 SoC
> 
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt b/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
> new file mode 100644
> index 000000000000..72176e25a692
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
> @@ -0,0 +1,13 @@
> +Broadcom ICFG USB3 registers
> +
> +Required properties:
> +- compatible: "brcm,icfg-usb"
> +- reg: Base address and length of the USB registers
> +
> +
> +Example:
> +
> +icfg_usb3: icfg_usb3@66000900 {
> +        compatible = "brcm,icfg-usb";

s/_/-/

With that,

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

> +        reg = <0x66000900 0x60>;
> +};
> -- 
> 2.7.4
> 

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

* [PATCH v2 3/6] dt-bindings: usb: Add documentation for NS2 ICFG USB3
@ 2017-08-03 19:06     ` Rob Herring
  0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 26, 2017 at 06:56:24PM -0400, Jon Mason wrote:
> Add documentation for ICFG USB3 registers available in NS2 SoC
> 
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt b/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
> new file mode 100644
> index 000000000000..72176e25a692
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/brcm,icfg-usb.txt
> @@ -0,0 +1,13 @@
> +Broadcom ICFG USB3 registers
> +
> +Required properties:
> +- compatible: "brcm,icfg-usb"
> +- reg: Base address and length of the USB registers
> +
> +
> +Example:
> +
> +icfg_usb3: icfg_usb3 at 66000900 {
> +        compatible = "brcm,icfg-usb";

s/_/-/

With that,

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

> +        reg = <0x66000900 0x60>;
> +};
> -- 
> 2.7.4
> 

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

* Re: [PATCH v2 4/6] dt-bindings: usb: Add documentation for NS2 IDM USB3
  2017-07-26 22:56   ` Jon Mason
@ 2017-08-03 19:08     ` Rob Herring
  -1 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:08 UTC (permalink / raw)
  To: Jon Mason
  Cc: Kishon Vijay Abraham I, Florian Fainelli, Mark Rutland,
	bcm-kernel-feedback-list, devicetree, linux-arm-kernel,
	linux-kernel

On Wed, Jul 26, 2017 at 06:56:25PM -0400, Jon Mason wrote:
> Add documentation for IDM USB3 registers available in NS2 SoC
> 
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt b/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
> new file mode 100644
> index 000000000000..3618dbcbe890
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
> @@ -0,0 +1,14 @@
> +Broadcom IDM USB3 registers
> +
> +Required properties:
> +- compatible: "brcm,usb3-idm"
> +- reg: Base address and length of the USB registers
> +
> +
> +Example:
> +
> +usb3_idm: idm@67000000 {

I'm assuming these are all some misc registers in addition to the USB 
controller? If this is the USB controller itself, then use generic node 
names for the DT spec.

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

> +        compatible = "brcm,usb3-idm";
> +        reg = <0x67000000 0x2000>;
> +};
> +
> -- 
> 2.7.4
> 

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

* [PATCH v2 4/6] dt-bindings: usb: Add documentation for NS2 IDM USB3
@ 2017-08-03 19:08     ` Rob Herring
  0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2017-08-03 19:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 26, 2017 at 06:56:25PM -0400, Jon Mason wrote:
> Add documentation for IDM USB3 registers available in NS2 SoC
> 
> Signed-off-by: Jon Mason <jon.mason@broadcom.com>
> ---
>  Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt b/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
> new file mode 100644
> index 000000000000..3618dbcbe890
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/brcm,usb3-idm.txt
> @@ -0,0 +1,14 @@
> +Broadcom IDM USB3 registers
> +
> +Required properties:
> +- compatible: "brcm,usb3-idm"
> +- reg: Base address and length of the USB registers
> +
> +
> +Example:
> +
> +usb3_idm: idm at 67000000 {

I'm assuming these are all some misc registers in addition to the USB 
controller? If this is the USB controller itself, then use generic node 
names for the DT spec.

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

> +        compatible = "brcm,usb3-idm";
> +        reg = <0x67000000 0x2000>;
> +};
> +
> -- 
> 2.7.4
> 

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

end of thread, other threads:[~2017-08-03 19:08 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-26 22:56 [PATCH v2 0/6] USB3 support for Broadcom NS2 SoC Jon Mason
2017-07-26 22:56 ` Jon Mason
2017-07-26 22:56 ` [PATCH v2 1/6] dt-bindings: phy: Add documentation for NS2 USB3 PHY Jon Mason
2017-07-26 22:56   ` Jon Mason
2017-07-26 22:56   ` Jon Mason
2017-08-03 19:03   ` Rob Herring
2017-08-03 19:03     ` Rob Herring
2017-08-03 19:03     ` Rob Herring
2017-07-26 22:56 ` [PATCH v2 2/6] dt-bindings: usb: Add documentation for NS2 CDRU USB3 Jon Mason
2017-07-26 22:56   ` Jon Mason
2017-08-03 19:05   ` Rob Herring
2017-08-03 19:05     ` Rob Herring
2017-08-03 19:05     ` Rob Herring
2017-07-26 22:56 ` [PATCH v2 3/6] dt-bindings: usb: Add documentation for NS2 ICFG USB3 Jon Mason
2017-07-26 22:56   ` Jon Mason
2017-08-03 19:06   ` Rob Herring
2017-08-03 19:06     ` Rob Herring
2017-07-26 22:56 ` [PATCH v2 4/6] dt-bindings: usb: Add documentation for NS2 IDM USB3 Jon Mason
2017-07-26 22:56   ` Jon Mason
2017-08-03 19:08   ` Rob Herring
2017-08-03 19:08     ` Rob Herring
2017-07-26 22:56 ` [PATCH v2 5/6] phy: Add USB3 PHY support for Broadcom NS2 SoC Jon Mason
2017-07-26 22:56   ` Jon Mason
2017-08-02  6:36   ` Kishon Vijay Abraham I
2017-08-02  6:36     ` Kishon Vijay Abraham I
2017-08-02  6:36     ` Kishon Vijay Abraham I
2017-08-03 15:23     ` Jon Mason
2017-08-03 15:23       ` Jon Mason
2017-08-03 15:23       ` Jon Mason
2017-07-26 22:56 ` [PATCH v2 6/6] arm64: dts: ns2: Add USB3 Support Jon Mason
2017-07-26 22:56   ` Jon Mason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.