Skip to contentSkip to conversation

phy: Add CIX Sky1 USB3 PHY support

PATCH In review Hongliang Yang 2 participants 4 messages Nov 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v9 cover phy: Add CIX Sky1 USB3 PHY support

This series adds support for the USB3 PHY integrated in the CIX Sky1
SoC: the device tree binding and the PHY driver. It is a PHY series only; the arm64 device tree nodes belong to the SoC subsystem and will be sent separately once the binding is accepted. The PHY and the USBSSP controller series were split in v4 and are posted independently.

The PHY provides the SuperSpeed lanes for the two USB3 Type-A (USB4 and USB5) Cadence USBSSP controllers of the SoC. There is one PHY block with two lanes: they share one register block, the same clocks and resets, and one initialization sequence, so the binding describes the block as a single provider with #phy-cells = <0> and both controllers reference the same phandle. The PHY core reference counts the phy_init() and phy_exit() calls accordingly.

v5 described one child node per lane. v6 collapsed them into the parent node, but nothing in the binding or in the changelog said where the second lane went. The second lane did not go anywhere: it is the second lane of the same block and has no registers, clocks or resets of its own. The binding description and the commit message now say that.

Tested on Radxa Orion O6 (Sky1) together with the USBSSP controller
series: the PHY probes and USB 3.x devices enumerate at SuperSpeed. The series applies on top of v7.4-rc1.

Changes in v9:
- Address the driver review comments of Manivannan Sadhasivam: describe the PHY block in the file header instead of naming the internal IP, get and enable the clocks with the bulk API (the two clocks are always handled together) and check that both are present, add the missing blank lines before return statements, and use lower case for the remaining hexadecimal literal.

Changes in v8:
- Rely on the PHY core for serialization and reference counting of phy_init() and phy_exit() instead of a driver-local mutex and counter, and call the Sky1 init and exit functions directly from the PHY operations; the per-SoC callback structure and its duplicate error messages are gone.
- Drop the register macros that the initialization sequence does not use from the private header.

Changes in v7:
- Removed the arm64 dts from the series; it is a separate SoC patchset.
- Describe the two lanes as one PHY provider and say why, instead of dropping the per-lane child nodes without an explanation.
- Renamed the register header to phy-cix-usb3.h: it holds the register map of the USB3 PHY, and the usbdp name suggested a USB/DP combo PHY.
- Fixed the module description and the Kconfig help text.

Changes in v6:
- Dropped the per-port child nodes; the PHY node itself is the provider with #phy-cells = <0> and the driver exports a single PHY instance shared by both controllers.
- Selected REGMAP in the PHY Kconfig.
- Used dev_err_probe() for the reset, clock and regmap acquisition failures in the probe path.

Hongliang Yang (2):
dt-bindings: phy: Add CIX Sky1 USB3 PHY
phy: cix: Add CIX Sky1 USB3 PHY driver

 .../bindings/phy/cix,sky1-usb3-phy.yaml       |  78 +++++
 MAINTAINERS                                   |   2 +
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/Makefile                          |   1 +
 drivers/phy/cix/Kconfig                       |  21 ++
 drivers/phy/cix/Makefile                      |   6 +
 drivers/phy/cix/phy-cix-usb3.c                | 316 ++++++++++++++++++
 drivers/phy/cix/phy-cix-usb3.h                | 180 ++++++++++
 8 files changed, 605 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml
 create mode 100644 drivers/phy/cix/Kconfig
 create mode 100644 drivers/phy/cix/Makefile
 create mode 100644 drivers/phy/cix/phy-cix-usb3.c
 create mode 100644 drivers/phy/cix/phy-cix-usb3.h
Signature · 1 line
2.54.0
#1 lore raw

PATCH v9 1/2 dt-bindings: phy: Add CIX Sky1 USB3 PHY

Add device tree binding for the CIX Sky1 USB3 PHY, the SuperSpeedPlus PHY of the two USB3 Type-A ports of the SoC.

The two lanes are not separate devices: they live in one register block, share the same clocks and resets, and are brought up by the same initialization sequence. The node is therefore a single PHY provider with #phy-cells = <0>, referenced by both controllers, and the driver reference counts phy_init() and phy_exit() so that the block is set up once for all of them.

---
Changes in v7:
- Describe the PHY as one provider of both lanes and say why. v5 had one child node per lane, v6 dropped them, and nothing in the binding or the changelog said where the second lane went.
- Reword the description so that it describes the provider instead of the register programming of the block.

Changes in v6:
- Drop the per-port child nodes. The parent node is the PHY provider with #phy-cells = <0>, as the block drives both lanes and the ports share the initialization sequence.

---
 .../bindings/phy/cix,sky1-usb3-phy.yaml       | 78 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml
Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml new file +78 -0
new file mode 100644
index 000000000000..205140bf84e7
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/cix,sky1-usb3-phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: CIX Sky1 USB3 PHY
+
+maintainers:
+  - Hongliang Yang <[email protected]>
+
+description: |
+  The CIX Sky1 USB3 PHY provides the SuperSpeed lanes of the USB3 Type-A
+  ports of the SoC.
+
+  Both lanes are programmed through one register block and share the
+  same clocks and resets, so the node is a single PHY provider with
+  #phy-cells = <0> that all consumers reference. The driver reference
+  counts phy_init() and phy_exit(), so the block is set up once for all
+  its consumers.
+
+properties:
+  compatible:
+    const: cix,sky1-usb3-phy
+
+  reg:
+    maxItems: 1
+
+  "#phy-cells":
+    const: 0
+
+  clocks:
+    items:
+      - description: APB register interface clock
+      - description: PHY reference clock
+
+  clock-names:
+    items:
+      - const: apb
+      - const: ref
+
+  resets:
+    items:
+      - description: PHY reset
+      - description: PHY APB preset
+
+  reset-names:
+    items:
+      - const: core
+      - const: apb
+
+required:
+  - compatible
+  - reg
+  - "#phy-cells"
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/cix,sky1.h>
+    #include <dt-bindings/reset/cix,sky1-s5-system-control.h>
+
+    usb-phy@9210000 {
+        compatible = "cix,sky1-usb3-phy";
+        reg = <0x9210000 0x40000>;
+        #phy-cells = <0>;
+        clocks = <&scmi_clk CLK_TREE_USB3A_PHY3_GATE>,
+                 <&scmi_clk CLK_TREE_USB3A_PHY_x2_REF>;
+        clock-names = "apb", "ref";
+        resets = <&s5_syscon SKY1_USBPHY_SS_RST_N>,
+                 <&s5_syscon SKY1_USBPHY_SS_PST_N>;
+        reset-names = "core", "apb";
+    };
MAINTAINERS +1 -0
index 93abbb315065..73783abe027e 100644
@@ -2903,6 +2903,7 @@ S:	Maintained
 T:	git https://github.com/cixtech/linux-mainline.git
 F:	Documentation/devicetree/bindings/arm/cix.yaml
 F:	Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml
+F:	Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml
 F:	arch/arm64/boot/dts/cix/
 F:	drivers/mailbox/cix-mailbox.c
 K:	\bcix\b
Signature · 1 line
2.54.0
#2 lore raw

Re: [PATCH v9 1/2] dt-bindings: phy: Add CIX Sky1 USB3 PHY

Quoted 10 lines · Hongliang Yang

Add device tree binding for the CIX Sky1 USB3 PHY, the SuperSpeedPlus PHY of the two USB3 Type-A ports of the SoC.

The two lanes are not separate devices: they live in one register block, share the same clocks and resets, and are brought up by the same initialization sequence. The node is therefore a single PHY provider with #phy-cells = <0>, referenced by both controllers, and the driver reference counts phy_init() and phy_exit() so that the block is set up once for all of them.

Quoted 3 lines

---
Changes in v7:

So we had some talks, some reviews, invested time and now you just ignore it. OK, we shall ignore your patches as well.

Best regards,
Krzysztof

#3 lore raw

PATCH v9 2/2 phy: cix: Add CIX Sky1 USB3 PHY driver

In reply to Hongliang Yang

Add a driver for the Cadence SD0803 USB3 PHY integrated in the CIX Sky1 SoC. The driver enables the APB and reference clocks, releases the resets, programs the register sequence of the PHY, and exports a single PHY instance for the two lanes of the block. The PHY core reference counts phy_init() and phy_exit(), so the sequence is programmed once and the block stays powered while any of its consumers is active.

---
Changes in v9:
- Describe the PHY block in the file header instead of naming the internal IP: the block provides the two SuperSpeed lanes of the Type-A ports, and both lanes belong to one PHY instance.
- Get and enable the clocks with the bulk API, the two clocks are always handled together, and check that both are present.
- Add the missing blank line before return statements.
- Use lower case for the hexadecimal literal in the register header.

Changes in v8:
- Rely on the PHY core for serialization and reference counting instead of a driver-local mutex and counter, and call the Sky1 init and exit functions directly from the PHY operations: the per-SoC callback structure and its duplicate error messages are gone.
- Drop the register macros that the initialization sequence does not use from the private header.

Changes in v7:
- Rename the register header to phy-cix-usb3.h: it is the register map of the USB3 PHY, and the old usbdp name suggested a USB/DP combo PHY.
- Fix the module description and the Kconfig help text.

Changes in v6:
- Select REGMAP in the Kconfig.
- Use dev_err_probe() for the reset, clock and regmap acquisition failures in the probe path.
- Assert the resets before registering the PHY provider, disable the clocks in LIFO order, and fix the error unroll path so that clocks which were never enabled are not disabled.

---
 MAINTAINERS                    |   1 +
 drivers/phy/Kconfig            |   1 +
 drivers/phy/Makefile           |   1 +
 drivers/phy/cix/Kconfig        |  21 +++
 drivers/phy/cix/Makefile       |   6 +
 drivers/phy/cix/phy-cix-usb3.c | 316 +++++++++++++++++++++++++++++++++
 drivers/phy/cix/phy-cix-usb3.h | 180 +++++++++++++++++++
 7 files changed, 526 insertions(+)
 create mode 100644 drivers/phy/cix/Kconfig
 create mode 100644 drivers/phy/cix/Makefile
 create mode 100644 drivers/phy/cix/phy-cix-usb3.c
 create mode 100644 drivers/phy/cix/phy-cix-usb3.h
MAINTAINERS +1 -0
index 73783abe027e..b857e529e5e2 100644
@@ -2906,6 +2906,7 @@ F:	Documentation/devicetree/bindings/mailbox/cix,sky1-mbox.yaml
 F:	Documentation/devicetree/bindings/phy/cix,sky1-usb3-phy.yaml
 F:	arch/arm64/boot/dts/cix/
 F:	drivers/mailbox/cix-mailbox.c
+F:	drivers/phy/cix/
 K:	\bcix\b
 
 ARM/CLKDEV SUPPORT
drivers/phy/Kconfig +1 -0
index 105fbe408aa2..876e5857634c 100644
@@ -176,6 +176,7 @@ source "drivers/phy/axiado/Kconfig"
 source "drivers/phy/broadcom/Kconfig"
 source "drivers/phy/cadence/Kconfig"
 source "drivers/phy/canaan/Kconfig"
+source "drivers/phy/cix/Kconfig"
 source "drivers/phy/eswin/Kconfig"
 source "drivers/phy/freescale/Kconfig"
 source "drivers/phy/hisilicon/Kconfig"
drivers/phy/Makefile +1 -0
index c6dd02003bbe..5a31c5df1746 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_GENERIC_PHY)		+= allwinner/	\
 					   broadcom/	\
 					   cadence/	\
 					   canaan/	\
+					   cix/		\
 					   eswin/	\
 					   freescale/	\
 					   hisilicon/	\
drivers/phy/cix/Kconfig new file +21 -0
new file mode 100644
index 000000000000..24452144ff78
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# PHY drivers for CIX PHYs
+#
+
+if ARCH_CIX || COMPILE_TEST
+
+config PHY_CIX_USB3
+	tristate "CIX Sky1 USB3 Type-A PHY support"
+	depends on OF && HAS_IOMEM
+	select GENERIC_PHY
+	select REGMAP
+	help
+	  Enable this to support the USB3 SuperSpeed PHY of the Type-A
+	  ports on CIX Sky1 SoCs. The PHY provides the SuperSpeed lanes
+	  used by the two Cadence USBSSP controllers (USB4 and USB5) of
+	  the SoC, and is shared between them.
+
+	  If unsure, say N.
+
+endif # ARCH_CIX || COMPILE_TEST
drivers/phy/cix/Makefile new file +6 -0
new file mode 100644
index 000000000000..58ec925a4425
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the CIX PHY drivers.
+#
+
+obj-$(CONFIG_PHY_CIX_USB3)	+= phy-cix-usb3.o
drivers/phy/cix/phy-cix-usb3.c new file +316 -0

316 lines not on this page · raw message

drivers/phy/cix/phy-cix-usb3.h new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
2.54.0