Skip to contentSkip to conversation

phy: airoha: add support for AN7583 PCIe PHY driver

PATCH New Christian Marangi 2 participants 4 messages Nov 24

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

v6 cover phy: airoha: add support for AN7583 PCIe PHY driver

This small series introduce support for Airoha AN7583 Gen3 PCIe PHY.

It's not possible to reuse the EN7581 code as the register changed between the 2 SoC and also the setup method changed (different calibration logic)

Putting the PHY in a dedicated directory is also needed for other series current pending that will add USB PHY support.

Also a dedicated schema is added as the register names is entirely different compared to EN7581.

Changes v6:
- Rebase on top of phy/next
- Address suggestion by sashiko bot

Changes v5:
- Rebase on top of phy/next
- Add Review tag

Changes v4:
- Add REGMAP_MMIO to kconfig
- Better handle exit
- Add additional info on QPHY usage

Changes v3:
- Improve example for Documentation patch
- Deinit G3 PHY on QPHY error

Changes v2:
- Drop move patch (handled in different series)
- Rework to regmap implementation
- Rename files to more specific name
- Add .exit logic
- Drop QPHY in favor of external PHY handling
- Update schema with new requirement and improve example

Christian Marangi (2):
dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY
phy: airoha: add support for AN7583 Gen3 PCIe PHY driver

 .../phy/airoha,an7583-pcie-gen3-phy.yaml      |  65 ++
 MAINTAINERS                                   |   8 +
 drivers/phy/airoha/Kconfig                    |  11 +
 drivers/phy/airoha/Makefile                   |   1 +
 drivers/phy/airoha/phy-an7583-pcie-regs.h     | 377 ++++++++
 drivers/phy/airoha/phy-an7583-pcie.c          | 831 ++++++++++++++++++
 6 files changed, 1293 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml
 create mode 100644 drivers/phy/airoha/phy-an7583-pcie-regs.h
 create mode 100644 drivers/phy/airoha/phy-an7583-pcie.c
Signature · 1 line
2.55.0
#1 lore raw

PATCH v6 1/2 dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY

Document support for AN7583 PCIe PHY used to make the Gen3 PCIe port work. Add the required register to configure the PCIe PHY and provide an example for it.

The PHY link to another PHY (the QPHY as described in the YAML) to correctly handle Gen2 speed and mode. It's mandatory to have this PHY configured for correct functionality of PCIe. The QPHY is a unified PHY that both handle USB and PCIe PHY.

It's also mondatory that the QPHY setup is done in the PCIe PHY setup and calibration phase or calibration might fail.

---
 .../phy/airoha,an7583-pcie-gen3-phy.yaml      | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +65 -0
new file mode 100644
index 000000000000..a8ec5ac781cc
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/airoha,an7583-pcie-gen3-phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha AN7583 PCI-Express PHY
+
+maintainers:
+  - Christian Marangi <[email protected]>
+
+description:
+  The PCIe PHY supports physical layer functionality for PCIe Gen2/Gen3 port.
+
+properties:
+  compatible:
+    const: airoha,an7583-pcie-gen3-phy
+
+  reg:
+    items:
+      - description: PCIE G3 analog base address
+      - description: PCIE G3 PMA base address
+      - description: PCIE detection time base address
+      - description: PCIE Rx AEQ base address
+
+  reg-names:
+    items:
+      - const: g3-ana
+      - const: g3-pma
+      - const: xr-dtime
+      - const: rx-aeq
+
+  phys:
+    items:
+      - description: phandle to QPHY phy for Gen2 support
+
+  "#phy-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - phys
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/phy/phy.h>
+
+    phy@1fc7f000 {
+        compatible = "airoha,an7583-pcie-gen3-phy";
+        reg = <0x1fc7f000 0x1000>,
+              <0x1fc7e000 0x1000>,
+              <0x1fc30044 0x4>,
+              <0x1fc35030 0x4>;
+        reg-names = "g3-ana", "g3-pma",
+                    "xr-dtime", "rx-aeq";
+
+        phys = <&pcie1_phy PHY_TYPE_PCIE>;
+
+        #phy-cells = <0>;
+    };
Signature · 1 line
2.55.0
#3 lore raw

PATCH v6 2/2 phy: airoha: add support for AN7583 Gen3 PCIe PHY driver

In reply to Christian Marangi

Add support for AN7583 PCIe PHY driver. This is required to make the Gen3 PCIe port present on the Airoha AN7583 SoC correctly work.

A different setup is needed compared to Airoha EN7581 where the calibration process and the register map greatly changed.

---
 MAINTAINERS                               |   8 +
 drivers/phy/airoha/Kconfig                |  11 +
 drivers/phy/airoha/Makefile               |   1 +
 drivers/phy/airoha/phy-an7583-pcie-regs.h | 377 ++++++++++
 drivers/phy/airoha/phy-an7583-pcie.c      | 831 ++++++++++++++++++++++
 5 files changed, 1228 insertions(+)
 create mode 100644 drivers/phy/airoha/phy-an7583-pcie-regs.h
 create mode 100644 drivers/phy/airoha/phy-an7583-pcie.c
MAINTAINERS +8 -0
index c689bdf1da89..50a6dee88d1b 100644
@@ -771,6 +771,14 @@ S:	Supported
 F:	fs/aio.c
 F:	include/linux/*aio*.h
 
+AIROHA AN7583 PCIE PHY DRIVER
+M:	Christian Marangi <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml
+F:	drivers/phy/airoha/phy-an7583-pcie-regs.h
+F:	drivers/phy/airoha/phy-an7583-pcie.c
+
 AIROHA ETHERNET DRIVER
 M:	Lorenzo Bianconi <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
drivers/phy/airoha/Kconfig +11 -0
index 634448ee39b5..10394aaf3071 100644
@@ -12,6 +12,17 @@ config PHY_AIROHA_AN7581_PCIE
 	  This driver create the basic PHY instance and provides initialize
 	  callback for PCIe GEN3 port.
 
+config PHY_AIROHA_AN7583_PCIE
+	tristate "Airoha AN7583 PCIe-PHY Driver"
+	depends on ARCH_AIROHA || COMPILE_TEST
+	depends on OF
+	select GENERIC_PHY
+	select REGMAP_MMIO
+	help
+	  Say Y here to add support for Airoha AN7583 PCIe PHY driver.
+	  This driver create the basic PHY instance and provides initialize
+	  callback for PCIe GEN3 port.
+
 config PHY_AIROHA_AN7581_USB
 	tristate "Airoha AN7581 USB PHY Driver"
 	depends on ARCH_AIROHA || COMPILE_TEST
drivers/phy/airoha/Makefile +1 -0
index 944bf842deba..bf6f9b244767 100644
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_PHY_AIROHA_AN7581_PCIE)	+= phy-an7581-pcie.o
+obj-$(CONFIG_PHY_AIROHA_AN7583_PCIE)	+= phy-an7583-pcie.o
 obj-$(CONFIG_PHY_AIROHA_AN7581_USB)	+= phy-an7581-usb.o
drivers/phy/airoha/phy-an7583-pcie-regs.h new file +377 -0

377 lines not on this page · raw message

drivers/phy/airoha/phy-an7583-pcie.c new file +831 -0

831 lines not on this page · raw message

Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v6 1/2] dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY

In reply to Christian Marangi
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] dt-bindings: phy: airoha: single 4-byte registers modeled as reg blocks --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] dt-bindings: phy: airoha: single 4-byte registers modeled as reg blocks
--

commit 4195ba1ead4d27d20beddf043b1dfb9d83d460c7
Author: Christian Marangi <[email protected]>

dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY

This commit adds the Device Tree binding schema for the Airoha AN7583 Gen3 PCIe PHY.

Quoted 6 lines
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +0 -0
new file mode 100644
index 0000000000000..a8ec5ac781ccc
@@ -0,0 +1,65 @@

[ ... ]

Quoted 17 lines
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +17 -0
+properties:
+  compatible:
+    const: airoha,an7583-pcie-gen3-phy
+
+  reg:
+    items:
+      - description: PCIE G3 analog base address
+      - description: PCIE G3 PMA base address
+      - description: PCIE detection time base address
+      - description: PCIE Rx AEQ base address
+
+  reg-names:
+    items:
+      - const: g3-ana
+      - const: g3-pma
+      - const: xr-dtime
+      - const: rx-aeq

[ ... ]

Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml line 60

Quoted 8 lines
Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml new file +8 -0
+    phy@1fc7f000 {
+        compatible = "airoha,an7583-pcie-gen3-phy";
+        reg = <0x1fc7f000 0x1000>,
+              <0x1fc7e000 0x1000>,
+              <0x1fc30044 0x4>,
+              <0x1fc35030 0x4>;
+        reg-names = "g3-ana", "g3-pma",
+                    "xr-dtime", "rx-aeq";

[Severity: Medium]
As reported by Krzysztof Kozlowski on v2 [1], should xr-dtime and rx-aeq describe the enclosing PEXTP register block(s) instead of individual 4-byte registers?

In the companion driver header drivers/phy/airoha/phy-an7583-pcie-regs.h (added in commit "phy: airoha: add support for AN7583 Gen3 PCIe PHY driver"), 0x1fc30044 and 0x1fc35030 correspond to REG_PCIE_PEXTP_DIG_GLB44 (offset 0x44 in PEXTP_DIG_GLB at 0x1fc30000) and REG_PCIE_PEXTP_DIG_LN_RX30 (offset 0x30 in PEXTP_DIG_LN_RX at 0x1fc35000). Binding two single 4-byte registers as separate reg regions locks the DT ABI to the registers currently touched by the driver and prevents accessing any other PEXTP digital global or lane RX registers without changing the binding.

[1] https://lore.kernel.org/r/20260831-elastic-turquoise-puma-f032fc@quoll

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1