Skip to contentSkip to conversation

airoha: an7581: USB support

PATCH Superseded Christian Marangi 2 participants 17 messages Mar 6 – Mar 13

Subsystems (2)

v6 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v6 cover airoha: an7581: USB support

This is a major rework of the old v2 series.

The SoC always support USB 2.0 but for USB 3.0 it needs additional configuration for the Serdes port. Such port can be either configured for USB usage or for PCIe lines or HSGMII and these are configured in the SCU space.

The previous implementation of a dedicated SSR driver was too complex and fragile for the simple task of configuring a register hence it was dropped and the handling is entirely in the PHY driver.

Everything was reducted to the dt-bindings to describe the Serdes line.

Also the property for the PHY are renamed to a more suitable name and everything is now mandatory to simplify the implementation. (the PHY are always present and active on the SoC)

Also other unrelated patch are dropped from this series.

Changes v6:
- Fix kernel test robot (sparse warning)

Changes v5:
- Add Ack and Review tag from Connor
- Implement Ethernet support in the USB driver (testing support for this Serdes on a special reference board)
- Use an7581 prefix for USB PHY driver

Changes v4:
- Rename PCIe and USB PHY to AN7581
- Drop airoha,scu (handled directly in driver)
- Drop dt-bindings for monitor clock in favor of raw values
- Better describe the usage of airoha,usb3-serdes
- Simplify values of dt-bindings SSR SERDES

Changes v3:
- Drop clk changes
- Drop SSR driver
- Rename property in Documentation
- Simplify PHY handling
- Move SSR handling inside the PHY driver

Changes v2:
- Drop changes for simple-mfd
- Rework PHY node structure to single node
- Drop port-id property in favor of serdes-port and usb2-monitor-clock-sel
- Make the SSR driver probe from the clock driver

Christian Marangi (4):
dt-bindings: soc: Add bindings for Airoha SCU Serdes lines
dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY
phy: move and rename Airoha PCIe PHY driver to dedicated directory
phy: airoha: Add support for Airoha AN7581 USB PHY

 .../bindings/phy/airoha,an7581-usb-phy.yaml   |   71 +
 MAINTAINERS                                   |   11 +-
 drivers/phy/Kconfig                           |   11 +-
 drivers/phy/Makefile                          |    4 +-
 drivers/phy/airoha/Kconfig                    |   23 +
 drivers/phy/airoha/Makefile                   |    4 +
 drivers/phy/airoha/phy-an7581-pcie-regs.h     |  494 +++++++
 drivers/phy/airoha/phy-an7581-pcie.c          | 1290 +++++++++++++++++
 drivers/phy/airoha/phy-an7581-usb.c           |  640 ++++++++
 include/dt-bindings/soc/airoha,scu-ssr.h      |   11 +
 10 files changed, 2545 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
 create mode 100644 drivers/phy/airoha/Kconfig
 create mode 100644 drivers/phy/airoha/Makefile
 create mode 100644 drivers/phy/airoha/phy-an7581-pcie-regs.h
 create mode 100644 drivers/phy/airoha/phy-an7581-pcie.c
 create mode 100644 drivers/phy/airoha/phy-an7581-usb.c
 create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.h
Signature · 1 line
2.51.0
#1 lore raw

PATCH v6 1/4 dt-bindings: soc: Add bindings for Airoha SCU Serdes lines

The Airoha AN7581 SoC can configure the SCU serdes lines for multiple purpose. For example the Serdes for the USB1 port can be both used for USB 3.0 operation or for Ethernet. Or the USB2 serdes can both used for USB 3.0 operation or for PCIe.

The PCIe Serdes can be both used for PCIe operation or for Ethernet.

Add bindings to permit correct reference of the different ports in DT, mostly to differentiate the different supported modes internally to the drivers.

---
 include/dt-bindings/soc/airoha,scu-ssr.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.h
include/dt-bindings/soc/airoha,scu-ssr.h new file +11 -0
new file mode 100644
index 000000000000..a14cef465dad
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+#ifndef __DT_BINDINGS_AIROHA_SCU_SSR_H
+#define __DT_BINDINGS_AIROHA_SCU_SSR_H
+
+#define AIROHA_SCU_SERDES_PCIE1		0
+#define AIROHA_SCU_SERDES_PCIE2		1
+#define AIROHA_SCU_SERDES_USB1		0
+#define AIROHA_SCU_SERDES_USB2		1
+
+#endif /* __DT_BINDINGS_AIROHA_SCU_SSR_H */
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v6 1/4] dt-bindings: soc: Add bindings for Airoha SCU Serdes lines

Quoted 11 lines · Christian Marangi

The Airoha AN7581 SoC can configure the SCU serdes lines for multiple purpose. For example the Serdes for the USB1 port can be both used for USB 3.0 operation or for Ethernet. Or the USB2 serdes can both used for USB 3.0 operation or for PCIe.

The PCIe Serdes can be both used for PCIe operation or for Ethernet.

Add bindings to permit correct reference of the different ports in DT, mostly to differentiate the different supported modes internally to the drivers.

Quoted 6 lines
---
 include/dt-bindings/soc/airoha,scu-ssr.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 include/dt-bindings/soc/airoha,scu-ssr.h

No, this is not a separate patch. Binding headers ALWAYS go with the bindings, when you add new devices.

Best regards,
Krzysztof

#3 lore raw

PATCH v6 2/4 dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY

In reply to Christian Marangi

Add documentation for Airoha AN7581 USB PHY that describe the USB PHY for the USB controller.

Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is always supported. The USB 3.0 mode is optional and depends on the Serdes mode currently configured on the system for the relevant USB port.

To correctly calibrate, the USB 2.0 port require correct value in "airoha,usb2-monitor-clk-sel" property. Both the 2 USB 2.0 port permit selecting one of the 4 monitor clock for calibration (internal clock not exposed to the system) but each port have only one of the 4 actually connected in HW hence the correct value needs to be specified in DT based on board and the physical port. Normally it's monitor clock 1 for USB1 and monitor clock 2 for USB2.

To correctly setup the Serdes mode attached to the USB 3.0 mode, the "airoha,usb3-serdes" property is required. This can be either AIROHA_SCU_SERDES_USB1 or AIROHA_SCU_SERDES_USB2 and is used to identify what modes support the PHY and what register to use to setup the requested mode.

The first USB port on the SoC can be both used for USB 3.0 operation or Ethernet (HSGMII).
The second USB port on the SoC can be both used for USB 3.0 operation or for an additional PCIe line.

---
 .../bindings/phy/airoha,an7581-usb-phy.yaml   | 71 +++++++++++++++++++
 MAINTAINERS                                   |  6 ++
 2 files changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml new file +71 -0
new file mode 100644
index 000000000000..ec467fb7f971
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/airoha,an7581-usb-phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha AN7581 SoC USB PHY
+
+maintainers:
+  - Christian Marangi <[email protected]>
+
+description: >
+  The Airoha AN7581 SoC USB PHY describes the USB PHY for the USB controller.
+
+  Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is
+  always supported. The USB 3.0 mode is optional and depends on the Serdes
+  mode currently configured on the system for the relevant USB port.
+
+  The first USB port on the SoC can be both used for USB 3.0 operation or
+  Ethernet (HSGMII).
+  The second USB port on the SoC can be both used for USB 3.0 operation or
+  for an additional PCIe line.
+
+properties:
+  compatible:
+    const: airoha,an7581-usb-phy
+
+  reg:
+    maxItems: 1
+
+  airoha,usb2-monitor-clk-sel:
+    description: Describe what oscillator across the available 4
+      should be selected for USB 2.0 Slew Rate calibration.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1, 2, 3]
+
+  airoha,usb3-serdes:
+    description: Describe what Serdes line is attached to the USB 3.0 port.
+      Can be either AIROHA_SCU_SERDES_USB1 or AIROHA_SCU_SERDES_USB2 as
+      defined in dt-bindings/soc/airoha,scu-ssr.h
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+
+  '#phy-cells':
+    description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3,
+      as defined in dt-bindings/phy/phy.h.
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - airoha,usb2-monitor-clk-sel
+  - airoha,usb3-serdes
+  - '#phy-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/soc/airoha,scu-ssr.h>
+
+    phy@1fac0000 {
+        compatible = "airoha,an7581-usb-phy";
+        reg = <0x1fac0000 0x10000>;
+
+        airoha,usb2-monitor-clk-sel = <1>;
+        airoha,usb3-serdes = <AIROHA_SCU_SERDES_USB1>;
+
+        #phy-cells = <1>;
+    };
+
MAINTAINERS +6 -0
index 364f0bec8748..d75f59118a9a 100644
@@ -779,6 +779,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
 F:	drivers/spi/spi-airoha-snfi.c
 
+AIROHA USB PHY DRIVER
+M:	Christian Marangi <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
+
 AIRSPY MEDIA DRIVER
 L:	[email protected]
 S:	Orphan
Signature · 1 line
2.51.0
#4 lore raw

Re: [PATCH v6 2/4] dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY

Quoted 2 lines · Christian Marangi

Add documentation for Airoha AN7581 USB PHY that describe the USB PHY for the USB controller.

A nit, subject: drop second/last, redundant "documentation for". The "dt-bindings" prefix is already stating that these are docs. See also:
https://elixir.bootlin.com/linux/v6.17-rc3/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Quoted 5 lines

Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is always supported. The USB 3.0 mode is optional and depends on the Serdes mode currently configured on the system for the relevant USB port.

Quoted 7 lines

To correctly calibrate, the USB 2.0 port require correct value in "airoha,usb2-monitor-clk-sel" property. Both the 2 USB 2.0 port permit selecting one of the 4 monitor clock for calibration (internal clock not exposed to the system) but each port have only one of the 4 actually connected in HW hence the correct value needs to be specified in DT based on board and the physical port. Normally it's monitor clock 1 for USB1 and monitor clock 2 for USB2.

...

This must contain the header you are also adding/referencing here.

MAINTAINERS S: Maintained · line 786

Quoted 13 lines
MAINTAINERS +5 -0
index 364f0bec8748..d75f59118a9a 100644
@@ -779,6 +779,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
 F:	drivers/spi/spi-airoha-snfi.c
 
+AIROHA USB PHY DRIVER
+M:	Christian Marangi <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml

No maintainers for the header?

Quoted 7 lines
MAINTAINERS +1 -0
+
 AIRSPY MEDIA DRIVER
 L:	[email protected]
 S:	Orphan
Signature · 1 line
2.51.0
#5 lore raw

Re: [PATCH v6 2/4] dt-bindings: phy: Add documentation for Airoha AN7581 USB PHY

Quoted 23 lines · Krzysztof Kozlowski
Quoted 2 lines · Christian Marangi

Add documentation for Airoha AN7581 USB PHY that describe the USB PHY for the USB controller.

A nit, subject: drop second/last, redundant "documentation for". The "dt-bindings" prefix is already stating that these are docs. See also:
https://elixir.bootlin.com/linux/v6.17-rc3/source/Documentation/devicetree/bindings/submitting-patches.rst#L18

Quoted 5 lines

Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is always supported. The USB 3.0 mode is optional and depends on the Serdes mode currently configured on the system for the relevant USB port.

Quoted 7 lines

To correctly calibrate, the USB 2.0 port require correct value in "airoha,usb2-monitor-clk-sel" property. Both the 2 USB 2.0 port permit selecting one of the 4 monitor clock for calibration (internal clock not exposed to the system) but each port have only one of the 4 actually connected in HW hence the correct value needs to be specified in DT based on board and the physical port. Normally it's monitor clock 1 for USB1 and monitor clock 2 for USB2.

Quoted 4 lines

...

This must contain the header you are also adding/referencing here.

Thanks ok will squash the 2.

Quoted 24 lines
Quoted 6 lines
MAINTAINERS +0 -0
index 364f0bec8748..d75f59118a9a 100644

MAINTAINERS S: Maintained · line 786

Quoted 8 lines
MAINTAINERS +5 -0
@@ -779,6 +779,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
 F:	drivers/spi/spi-airoha-snfi.c
 
+AIROHA USB PHY DRIVER
+M:	Christian Marangi <[email protected]>
+L:	[email protected] (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml

No maintainers for the header?

Quoted 7 lines
MAINTAINERS +1 -0
+
 AIRSPY MEDIA DRIVER
 L:	[email protected]
 S:	Orphan
Signature · 1 line
2.51.0
Signature · 1 line
	Ansuel
#6 lore raw

PATCH v6 3/4 phy: move and rename Airoha PCIe PHY driver to dedicated directory

In reply to Christian Marangi

To keep the generic PHY directory tidy, move the PCIe PHY driver for Airoha AN7581 SoC to a dedicated directory.

Also rename the driver and add the relevant SoC name to the .c and .h file in preparation for support of PCIe and USB PHY driver for Airoha AN7583 SoC that use a completely different implementation and calibration for PHYs and will have their own dedicated drivers.

The rename permits to better identify the specific usage of the driver in the future once the airoha PHY directory will have multiple driver for multiple SoC.

The config is changed from PHY_AIROHA_PCIE to PHY_AIROHA_AN7581_PCIE.

---
 MAINTAINERS                               |    4 +-
 drivers/phy/Kconfig                       |   11 +-
 drivers/phy/Makefile                      |    4 +-
 drivers/phy/airoha/Kconfig                |   13 +
 drivers/phy/airoha/Makefile               |    3 +
 drivers/phy/airoha/phy-an7581-pcie-regs.h |  494 ++++++++
 drivers/phy/airoha/phy-an7581-pcie.c      | 1290 +++++++++++++++++++++
 7 files changed, 1805 insertions(+), 14 deletions(-)
 create mode 100644 drivers/phy/airoha/Kconfig
 create mode 100644 drivers/phy/airoha/Makefile
 create mode 100644 drivers/phy/airoha/phy-an7581-pcie-regs.h
 create mode 100644 drivers/phy/airoha/phy-an7581-pcie.c
MAINTAINERS +2 -2
index d75f59118a9a..ec9064e92d33 100644
@@ -767,8 +767,8 @@ M:	Lorenzo Bianconi <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 F:	Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml
-F:	drivers/phy/phy-airoha-pcie-regs.h
-F:	drivers/phy/phy-airoha-pcie.c
+F:	drivers/phy/airoha/phy-an7581-pcie-regs.h
+F:	drivers/phy/airoha/phy-an7581-pcie.c
 
 AIROHA SPI SNFI DRIVER
 M:	Lorenzo Bianconi <[email protected]>
drivers/phy/Kconfig +1 -10
index 227b9a4c612e..f9cd765a3ccc 100644
@@ -46,16 +46,6 @@ config GENERIC_PHY_MIPI_DPHY
 	  Provides a number of helpers a core functions for MIPI D-PHY
 	  drivers to us.
 
-config PHY_AIROHA_PCIE
-	tristate "Airoha PCIe-PHY Driver"
-	depends on ARCH_AIROHA || COMPILE_TEST
-	depends on OF
-	select GENERIC_PHY
-	help
-	  Say Y here to add support for Airoha PCIe PHY driver.
-	  This driver create the basic PHY instance and provides initialize
-	  callback for PCIe GEN3 port.
-
 config PHY_CAN_TRANSCEIVER
 	tristate "CAN transceiver PHY"
 	select GENERIC_PHY
@@ -133,6 +123,7 @@ config PHY_XGENE
 	help
 	  This option enables support for APM X-Gene SoC multi-purpose PHY.
 
+source "drivers/phy/airoha/Kconfig"
 source "drivers/phy/allwinner/Kconfig"
 source "drivers/phy/amlogic/Kconfig"
 source "drivers/phy/apple/Kconfig"
drivers/phy/Makefile +2 -2
index f49d83f00a3d..84062279fa63 100644
@@ -7,7 +7,6 @@ obj-$(CONFIG_PHY_COMMON_PROPS)		+= phy-common-props.o
 obj-$(CONFIG_PHY_COMMON_PROPS_TEST)	+= phy-common-props-test.o
 obj-$(CONFIG_GENERIC_PHY)		+= phy-core.o
 obj-$(CONFIG_GENERIC_PHY_MIPI_DPHY)	+= phy-core-mipi-dphy.o
-obj-$(CONFIG_PHY_AIROHA_PCIE)		+= phy-airoha-pcie.o
 obj-$(CONFIG_PHY_CAN_TRANSCEIVER)	+= phy-can-transceiver.o
 obj-$(CONFIG_PHY_GOOGLE_USB)		+= phy-google-usb.o
 obj-$(CONFIG_USB_LGM_PHY)		+= phy-lgm-usb.o
@@ -17,7 +16,8 @@ obj-$(CONFIG_PHY_PISTACHIO_USB)		+= phy-pistachio-usb.o
 obj-$(CONFIG_PHY_SNPS_EUSB2)		+= phy-snps-eusb2.o
 obj-$(CONFIG_PHY_XGENE)			+= phy-xgene.o
 
-obj-$(CONFIG_GENERIC_PHY)		+= allwinner/	\
+obj-$(CONFIG_GENERIC_PHY)		+= airoha/	\
+					   allwinner/	\
 					   amlogic/	\
 					   apple/	\
 					   broadcom/	\
drivers/phy/airoha/Kconfig new file +13 -0
new file mode 100644
index 000000000000..9a1b625a7701
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Phy drivers for Airoha devices
+#
+config PHY_AIROHA_AN7581_PCIE
+	tristate "Airoha AN7581 PCIe-PHY Driver"
+	depends on ARCH_AIROHA || COMPILE_TEST
+	depends on OF
+	select GENERIC_PHY
+	help
+	  Say Y here to add support for Airoha AN7581 PCIe PHY driver.
+	  This driver create the basic PHY instance and provides initialize
+	  callback for PCIe GEN3 port.
drivers/phy/airoha/Makefile new file +3 -0
new file mode 100644
index 000000000000..912f3e11a061
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_PHY_AIROHA_AN7581_PCIE)	+= phy-an7581-pcie.o
drivers/phy/airoha/phy-an7581-pcie-regs.h new file +494 -0

494 lines not on this page · raw message

drivers/phy/airoha/phy-an7581-pcie.c new file +1290 -0

1,290 lines not on this page · raw message

Signature · 1 line
2.51.0
#7 lore raw

PATCH v6 4/4 phy: airoha: Add support for Airoha AN7581 USB PHY

In reply to Christian Marangi

Add support for Airoha AN7581 USB PHY driver. AN7581 supports up to 2 USB port with USB 2.0 mode always supported and USB 3.0 mode available only if the Serdes port is correctly configured for USB 3.0.

The first USB port on the SoC can be both used for USB 3.0 operation or Ethernet.
The second USB port on the SoC can be both used for USB 3.0 operation or PCIe.
Both port operation toggled by the SCU SSR register and configured by the USB PHY driver.

If the USB 3.0 mode is not configured, the modes needs to be also disabled in the xHCI node or the driver will report unsable clock and fail probe.

For USB 2.0 Slew Rate calibration, airoha,usb2-monitor-clk-sel is mandatory and is used to select the monitor clock for calibration.

Normally it's 1 for USB port 1 and 2 for USB port 2.

---
 MAINTAINERS                         |   1 +
 drivers/phy/airoha/Kconfig          |  10 +
 drivers/phy/airoha/Makefile         |   1 +
 drivers/phy/airoha/phy-an7581-usb.c | 640 ++++++++++++++++++++++++++++
 4 files changed, 652 insertions(+)
 create mode 100644 drivers/phy/airoha/phy-an7581-usb.c
MAINTAINERS +1 -0
index ec9064e92d33..ee3dfa7b7f04 100644
@@ -784,6 +784,7 @@ M:	Christian Marangi <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 F:	Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
+F:	drivers/phy/airoha/phy-an7581-usb.c
 
 AIRSPY MEDIA DRIVER
 L:	[email protected]
drivers/phy/airoha/Kconfig +10 -0
index 9a1b625a7701..bb4e3367baa5 100644
@@ -11,3 +11,13 @@ config PHY_AIROHA_AN7581_PCIE
 	  Say Y here to add support for Airoha AN7581 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
+	depends on OF
+	select GENERIC_PHY
+	help
+	  Say 'Y' here to add support for Airoha AN7581 USB PHY driver.
+	  This driver create the basic PHY instance and provides initialize
+	  callback for USB port.
drivers/phy/airoha/Makefile +1 -0
index 912f3e11a061..944bf842deba 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_PHY_AIROHA_AN7581_PCIE)	+= phy-an7581-pcie.o
+obj-$(CONFIG_PHY_AIROHA_AN7581_USB)	+= phy-an7581-usb.o
drivers/phy/airoha/phy-an7581-usb.c new file +640 -0

640 lines not on this page · raw message

Signature · 1 line
2.51.0
#8 lore raw

Re: [PATCH v6 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY

Quoted 10 lines · Christian Marangi
drivers/phy/airoha/phy-an7581-usb.c new file +10 -0
+	for (index = 0; index < AIROHA_PHY_USB_MAX; index++) {
+		enum an7581_usb_phy_instance_type phy_type;
+		struct an7581_usb_phy_instance *instance;
+
+		switch (index) {
+		case AIROHA_PHY_USB2:
+			phy_type = PHY_TYPE_USB2;
+			break;
+		case AIROHA_PHY_USB3:
+			phy_type = PHY_TYPE_USB3;

drivers/phy/airoha/phy-an7581-usb.c line 598

Quoted 10 lines
drivers/phy/airoha/phy-an7581-usb.c new file +10 -0
+			break;
+		}
+
+		if (phy_type == PHY_TYPE_USB3) {
+			ret = of_property_read_u32(dev->of_node, "airoha,usb3-serdes",
+						   &priv->serdes_port);
+			if (ret)
+				return dev_err_probe(dev, ret, "missing serdes line for USB 3.0\n");
+
+			priv->scu = syscon_regmap_lookup_by_compatible("airoha,en7581-scu");

Nope, you need phandle to express proper device links.

Don't sprinkle compatible lookups for new code which does not need to keep things backwards compatible. How do you manage device links without phandle? How do you manage device probe ordering?

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH v6 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY

Quoted 24 lines · Krzysztof Kozlowski
Quoted 10 lines · Christian Marangi
drivers/phy/airoha/phy-an7581-usb.c new file +10 -0
+	for (index = 0; index < AIROHA_PHY_USB_MAX; index++) {
+		enum an7581_usb_phy_instance_type phy_type;
+		struct an7581_usb_phy_instance *instance;
+
+		switch (index) {
+		case AIROHA_PHY_USB2:
+			phy_type = PHY_TYPE_USB2;
+			break;
+		case AIROHA_PHY_USB3:
+			phy_type = PHY_TYPE_USB3;

drivers/phy/airoha/phy-an7581-usb.c line 598

Quoted 10 lines
drivers/phy/airoha/phy-an7581-usb.c new file +10 -0
+			break;
+		}
+
+		if (phy_type == PHY_TYPE_USB3) {
+			ret = of_property_read_u32(dev->of_node, "airoha,usb3-serdes",
+						   &priv->serdes_port);
+			if (ret)
+				return dev_err_probe(dev, ret, "missing serdes line for USB 3.0\n");
+
+			priv->scu = syscon_regmap_lookup_by_compatible("airoha,en7581-scu");

Nope, you need phandle to express proper device links.

Quoted 4 lines

Don't sprinkle compatible lookups for new code which does not need to keep things backwards compatible. How do you manage device links without phandle? How do you manage device probe ordering?

Hi,

the phandle to SCU was present in old implementation but later dropped as it was said that it wouldn't describe the HW.

I will readd as airoha,scu. Is it ok for you?

(I actually prefer phandle than hardcoding compatible as it makes things more descriptive and prevent all kind of problem in the future, so I'm more than happy than using that)

Signature · 1 line
	Ansuel
#10 lore raw

Re: [PATCH v6 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY

Quoted 16 lines · Christian Marangi
Quoted 11 lines

drivers/phy/airoha/phy-an7581-usb.c line 598

Quoted 8 lines
drivers/phy/airoha/phy-an7581-usb.c new file +8 -0
+
+		if (phy_type == PHY_TYPE_USB3) {
+			ret = of_property_read_u32(dev->of_node, "airoha,usb3-serdes",
+						   &priv->serdes_port);
+			if (ret)
+				return dev_err_probe(dev, ret, "missing serdes line for USB 3.0\n");
+
+			priv->scu = syscon_regmap_lookup_by_compatible("airoha,en7581-scu");

Nope, you need phandle to express proper device links.

Quoted 4 lines

Don't sprinkle compatible lookups for new code which does not need to keep things backwards compatible. How do you manage device links without phandle? How do you manage device probe ordering?

Quoted 4 lines

Hi,

the phandle to SCU was present in old implementation but later dropped as it was said that it wouldn't describe the HW.

I went through v3 review and I did not find such said arguments. Can you point me to it?

Quoted 7 lines

I will readd as airoha,scu. Is it ok for you?

(I actually prefer phandle than hardcoding compatible as it makes things more descriptive and prevent all kind of problem in the future, so I'm more than happy than using that)

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH v6 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY

Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Christian Marangi
Quoted 15 lines

drivers/phy/airoha/phy-an7581-usb.c line 598

Quoted 8 lines
drivers/phy/airoha/phy-an7581-usb.c new file +8 -0
+
+		if (phy_type == PHY_TYPE_USB3) {
+			ret = of_property_read_u32(dev->of_node, "airoha,usb3-serdes",
+						   &priv->serdes_port);
+			if (ret)
+				return dev_err_probe(dev, ret, "missing serdes line for USB 3.0\n");
+
+			priv->scu = syscon_regmap_lookup_by_compatible("airoha,en7581-scu");

Nope, you need phandle to express proper device links.

Don't sprinkle compatible lookups for new code which does not need to keep things backwards compatible. How do you manage device links without phandle? How do you manage device probe ordering?

Quoted 10 lines
Quoted 4 lines

Hi,

the phandle to SCU was present in old implementation but later dropped as it was said that it wouldn't describe the HW.

I went through v3 review and I did not find such said arguments. Can you point me to it?

Here was v2 [0] that was clock + USB PHY. (there were clock stuff as the SCU implementation was different) The link wasn't added in the changelog as it's quite different than this current series.

In patch 7 Rob pointed out that serdes-port + scu was a bit unusual.

Then the implementation changed in favor of a more simple one where it's the PHY that configure everything and in this new version the usage of the SCU phandle is really to just get the regmap and modify the single bit to select the PHY path/mode for USB 3.0. (it's mainly the reason the SCU is referenced directly with a compatible instead of a phandle, in the previous implementation we used a function exposed by the SCU SSR, while in this it's just a regmap that can PROBE_DEFER)

Rob suggested an additional layer (a PHY) to handle this but I don't feel it would actually describe the HW this way as that bit doesn't modify another PHY but it just toggle the mode to the related USB 3.0 PHY.

This is really another case of not-so-organized register mapping on the SoC.

[0] https://lore.kernel.org/all/[email protected]/

Quoted 11 lines
Quoted 7 lines

I will readd as airoha,scu. Is it ok for you?

(I actually prefer phandle than hardcoding compatible as it makes things more descriptive and prevent all kind of problem in the future, so I'm more than happy than using that)

Best regards,
Krzysztof

Signature · 1 line
	Ansuel
#12 lore raw

Re: [PATCH v6 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY

Quoted 43 lines · Christian Marangi
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Christian Marangi
Quoted 15 lines

drivers/phy/airoha/phy-an7581-usb.c line 598

Quoted 8 lines
drivers/phy/airoha/phy-an7581-usb.c new file +8 -0
+
+		if (phy_type == PHY_TYPE_USB3) {
+			ret = of_property_read_u32(dev->of_node, "airoha,usb3-serdes",
+						   &priv->serdes_port);
+			if (ret)
+				return dev_err_probe(dev, ret, "missing serdes line for USB 3.0\n");
+
+			priv->scu = syscon_regmap_lookup_by_compatible("airoha,en7581-scu");

Nope, you need phandle to express proper device links.

Don't sprinkle compatible lookups for new code which does not need to keep things backwards compatible. How do you manage device links without phandle? How do you manage device probe ordering?

Quoted 10 lines
Quoted 4 lines

Hi,

the phandle to SCU was present in old implementation but later dropped as it was said that it wouldn't describe the HW.

I went through v3 review and I did not find such said arguments. Can you point me to it?

Here was v2 [0] that was clock + USB PHY. (there were clock stuff as the SCU implementation was different) The link wasn't added in the changelog as it's quite different than this current series.

In patch 7 Rob pointed out that serdes-port + scu was a bit unusual.

Then the implementation changed in favor of a more simple one where it's the PHY that configure everything and in this new version the usage of the SCU phandle is really to just get the regmap and modify the single bit to select the PHY path/mode for USB 3.0. (it's mainly the reason the SCU is referenced directly with a compatible instead of a phandle, in the previous implementation we used a function exposed by the SCU SSR, while in this it's just a regmap that can PROBE_DEFER)

Quoted 7 lines

Rob suggested an additional layer (a PHY) to handle this but I don't feel it would actually describe the HW this way as that bit doesn't modify another PHY but it just toggle the mode to the related USB 3.0 PHY.

This is really another case of not-so-organized register mapping on the SoC.

[0] https://lore.kernel.org/all/[email protected]/

That's the cover letter. I guess you did not implement Rob's feedback, either. This is either phy (for phy) as Rob asked or scu phandle. Removing scu phandle and not implementing phy is not what Rob proposed.

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v6 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY

Quoted 48 lines · Krzysztof Kozlowski
Quoted 47 lines · Christian Marangi
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Christian Marangi
Quoted 15 lines

drivers/phy/airoha/phy-an7581-usb.c line 598

Quoted 8 lines
drivers/phy/airoha/phy-an7581-usb.c new file +8 -0
+
+		if (phy_type == PHY_TYPE_USB3) {
+			ret = of_property_read_u32(dev->of_node, "airoha,usb3-serdes",
+						   &priv->serdes_port);
+			if (ret)
+				return dev_err_probe(dev, ret, "missing serdes line for USB 3.0\n");
+
+			priv->scu = syscon_regmap_lookup_by_compatible("airoha,en7581-scu");

Nope, you need phandle to express proper device links.

Don't sprinkle compatible lookups for new code which does not need to keep things backwards compatible. How do you manage device links without phandle? How do you manage device probe ordering?

Quoted 10 lines
Quoted 4 lines

Hi,

the phandle to SCU was present in old implementation but later dropped as it was said that it wouldn't describe the HW.

I went through v3 review and I did not find such said arguments. Can you point me to it?

Here was v2 [0] that was clock + USB PHY. (there were clock stuff as the SCU implementation was different) The link wasn't added in the changelog as it's quite different than this current series.

In patch 7 Rob pointed out that serdes-port + scu was a bit unusual.

Then the implementation changed in favor of a more simple one where it's the PHY that configure everything and in this new version the usage of the SCU phandle is really to just get the regmap and modify the single bit to select the PHY path/mode for USB 3.0. (it's mainly the reason the SCU is referenced directly with a compatible instead of a phandle, in the previous implementation we used a function exposed by the SCU SSR, while in this it's just a regmap that can PROBE_DEFER)

Rob suggested an additional layer (a PHY) to handle this but I don't feel it would actually describe the HW this way as that bit doesn't modify another PHY but it just toggle the mode to the related USB 3.0 PHY.

Quoted 9 lines
Quoted 3 lines

This is really another case of not-so-organized register mapping on the SoC.

[0] https://lore.kernel.org/all/[email protected]/

That's the cover letter. I guess you did not implement Rob's feedback, either. This is either phy (for phy) as Rob asked or scu phandle. Removing scu phandle and not implementing phy is not what Rob proposed.

It was to give the full series. The specific comment from Rob was [0].

SCU phandle is going back to the old dual binding that Rob was against but PHY for PHY would not be descriptive of the HW.

I can do that but would it be correct?

[0] https://lore.kernel.org/all/[email protected]/

Signature · 1 line
	Ansuel
#14 lore raw

Re: [PATCH v6 4/4] phy: airoha: Add support for Airoha AN7581 USB PHY

Quoted 59 lines · Christian Marangi
Quoted 48 lines · Krzysztof Kozlowski
Quoted 47 lines · Christian Marangi
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Christian Marangi
Quoted 15 lines

Review

Quoted 8 lines
(quoted diff) +8 -0
+
+		if (phy_type == PHY_TYPE_USB3) {
+			ret = of_property_read_u32(dev->of_node, "airoha,usb3-serdes",
+						   &priv->serdes_port);
+			if (ret)
+				return dev_err_probe(dev, ret, "missing serdes line for USB 3.0\n");
+
+			priv->scu = syscon_regmap_lookup_by_compatible("airoha,en7581-scu");

Nope, you need phandle to express proper device links.

Don't sprinkle compatible lookups for new code which does not need to keep things backwards compatible. How do you manage device links without phandle? How do you manage device probe ordering?

Quoted 10 lines
Quoted 4 lines

Hi,

the phandle to SCU was present in old implementation but later dropped as it was said that it wouldn't describe the HW.

I went through v3 review and I did not find such said arguments. Can you point me to it?

Here was v2 [0] that was clock + USB PHY. (there were clock stuff as the SCU implementation was different) The link wasn't added in the changelog as it's quite different than this current series.

In patch 7 Rob pointed out that serdes-port + scu was a bit unusual.

Then the implementation changed in favor of a more simple one where it's the PHY that configure everything and in this new version the usage of the SCU phandle is really to just get the regmap and modify the single bit to select the PHY path/mode for USB 3.0. (it's mainly the reason the SCU is referenced directly with a compatible instead of a phandle, in the previous implementation we used a function exposed by the SCU SSR, while in this it's just a regmap that can PROBE_DEFER)

Rob suggested an additional layer (a PHY) to handle this but I don't feel it would actually describe the HW this way as that bit doesn't modify another PHY but it just toggle the mode to the related USB 3.0 PHY.

Quoted 9 lines
Quoted 3 lines

This is really another case of not-so-organized register mapping on the SoC.

[0] https://lore.kernel.org/all/[email protected]/

That's the cover letter. I guess you did not implement Rob's feedback, either. This is either phy (for phy) as Rob asked or scu phandle. Removing scu phandle and not implementing phy is not what Rob proposed.

Quoted 6 lines

It was to give the full series. The specific comment from Rob was [0].

SCU phandle is going back to the old dual binding that Rob was against but PHY for PHY would not be descriptive of the HW.

I can do that but would it be correct?

You cannot avoid proper DT structure and DT review by re-implementing the DT properties by such lookups.

Best regards,
Krzysztof

#15 lore raw
In reply to Christian Marangi
Quoted 29 lines · Christian Marangi

This is a major rework of the old v2 series.

The SoC always support USB 2.0 but for USB 3.0 it needs additional configuration for the Serdes port. Such port can be either configured for USB usage or for PCIe lines or HSGMII and these are configured in the SCU space.

The previous implementation of a dedicated SSR driver was too complex and fragile for the simple task of configuring a register hence it was dropped and the handling is entirely in the PHY driver.

Everything was reducted to the dt-bindings to describe the Serdes line.

Also the property for the PHY are renamed to a more suitable name and everything is now mandatory to simplify the implementation. (the PHY are always present and active on the SoC)

Also other unrelated patch are dropped from this series.

Changes v6:
- Fix kernel test robot (sparse warning)

Changes v5:
- Add Ack and Review tag from Connor
- Implement Ethernet support in the USB driver (testing support for this Serdes on a special reference board)
- Use an7581 prefix for USB PHY driver

Quoted 7 lines

Changes v4:
- Rename PCIe and USB PHY to AN7581
- Drop airoha,scu (handled directly in driver)
- Drop dt-bindings for monitor clock in favor of raw values
- Better describe the usage of airoha,usb3-serdes
- Simplify values of dt-bindings SSR SERDES

Why is this the same link as v5?

Quoted 8 lines

Changes v3:
- Drop clk changes
- Drop SSR driver
- Rename property in Documentation
- Simplify PHY handling
- Move SSR handling inside the PHY driver

Best regards,
Krzysztof

#16 lore raw
Quoted 38 lines · Krzysztof Kozlowski
Quoted 29 lines · Christian Marangi

This is a major rework of the old v2 series.

The SoC always support USB 2.0 but for USB 3.0 it needs additional configuration for the Serdes port. Such port can be either configured for USB usage or for PCIe lines or HSGMII and these are configured in the SCU space.

The previous implementation of a dedicated SSR driver was too complex and fragile for the simple task of configuring a register hence it was dropped and the handling is entirely in the PHY driver.

Everything was reducted to the dt-bindings to describe the Serdes line.

Also the property for the PHY are renamed to a more suitable name and everything is now mandatory to simplify the implementation. (the PHY are always present and active on the SoC)

Also other unrelated patch are dropped from this series.

Changes v6:
- Fix kernel test robot (sparse warning)

Changes v5:
- Add Ack and Review tag from Connor
- Implement Ethernet support in the USB driver (testing support for this Serdes on a special reference board)
- Use an7581 prefix for USB PHY driver

Quoted 7 lines

Changes v4:
- Rename PCIe and USB PHY to AN7581
- Drop airoha,scu (handled directly in driver)
- Drop dt-bindings for monitor clock in favor of raw values
- Better describe the usage of airoha,usb3-serdes
- Simplify values of dt-bindings SSR SERDES

Quoted 2 lines

Why is this the same link as v5?

Sorry a copy paste error. Here [0]

[0] https://lore.kernel.org/all/[email protected]/

Quoted 12 lines
Quoted 8 lines

Changes v3:
- Drop clk changes
- Drop SSR driver
- Rename property in Documentation
- Simplify PHY handling
- Move SSR handling inside the PHY driver

Best regards,
Krzysztof

Signature · 1 line
	Ansuel