Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] phy: cadence-torrent: rewrite Torrent PHY driver
@ 2026-11-20 12:55 Benjamin Robin
  2026-11-20 12:55 ` [PATCH 1/4] arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY Benjamin Robin
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Benjamin Robin @ 2026-11-20 12:55 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis
  Cc: Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy,
	Benjamin Robin

This series rewrites the driver for the Cadence Torrent multi-protocol
PHY (sd0801).

Motivation
----------
The existing phy-cadence-torrent driver hard-codes, for each supported
configuration, the register values to program. The configuration space
is large: protocol and associated PLL frequency, DisplayPort bit rate,
reference clock frequency, spread-spectrum clocking (SSC), number of
lanes, PHY revision and technology. As a result, every new board or
standard combination requires a full extra table of opaque register
values, which is inflexible and hard to maintain.

The rewrite aims to:

  - simplify the addition of support for a new board;
  - support every reference clock frequencies supported by the Cadence
    Torrent PHY;
  - support multiple links per standard without restriction (the previous
    driver, for instance, was limited to two PCIe links);
  - allow, in the future, the dynamic reconfiguration of the SerDes link
    rate (for example, to switch between SGMII and 2500BASE-X).

Because this is a complete rewrite, the diff is large and not well suited
to a line-by-line review. The rewritten driver can be fetched from the
`phy-cadence-torrent` branch at https://github.com/benjarobin/linux

Design
------
The new driver computes the register values instead of hard-coding them:

  - registers that depend on the reference clock frequency or on a PLL
    frequency are computed at run time, from the reference clock
    obtained through the clock framework and from the PLL frequency
    derived from the selected standard;
  - the remaining registers, which only depend on the standard type, the
    PHY revision and the technology, are written through one function per
    register, with an internal table selected by a
    standard/revision/technology key.

The PHY revision and technology are detected from the PHY identification
registers, and the DisplayPort link initialization and rate-change
sequence were rewritten.

Validation
----------
Because the rewritten driver computes register values instead of
hard-coding them, its output was validated against two independent
references:

  - The Cadence "Torrent Programmers Guide" spreadsheet, for the
    registers that depend on the reference clock and on the PLL
    frequencies. The spreadsheet generates (as a CSV) the expected value
    of every register to write; the values computed by the driver were
    compared with these expected values over a large number of
    combinations of reference clock, PLL frequency.
    To make this comparison feasible, the reference-clock and PLL
    computation code was extracted into small userspace harnesses,
    so that many combinations can be swept without booting the hardware,
    and the results are fed to a comparison tool that checks them against
    the spreadsheet CSV.

  - The existing driver, for the complete set of programmed registers.
    Every supported configuration of the old driver was extracted as a
    test case. Two userspace harnesses were generated:
     - tp-full-old, mirroring the old cdns_torrent_phy_init() /
       cdns_torrent_phy_configure_multilink() path;
     - tp-full-new, mirroring the new tp_configure_links() path.
    These 2 userspace harnesses run the same test cases (single
    standards, standard pairs, PCIe-Multilink and internal-SSC variants)
    and then compare, register by register, the writes performed by each
    driver for the same configuration. The registers written by both
    drivers match, with a small number of remaining differences that are
    all explained (for example, values that were fixed in a later
    revision of the spreadsheet, or obsolete/unused registers);

The last patch of the series adds a debug trace on every register read
or write, so the same comparison can also be performed on real hardware
by capturing the driver logs.

The tooling used for the validation described above is available at:
https://github.com/benjarobin/cadence-torrent-phy-tooling

Status / testing
----------------
The driver has so far been validated on two TI boards:

  - J784S4XEVM: two PCIe links (x2, x4), one DisplayPort link (display
    output working) and one USB-C port (configured as host);
  - J721EXCPXEVM: two PCIe links (x2, x1) and a J721EXENETXPANEVM
    daughter card exposing four Ethernet ports over a single QSGMII
    link (~1 Gbps per port).

Comments on the overall approach are welcome, as is testing on additional
hardware, for which Tested-by tags would be appreciated.

Dependency
----------
This series should be applied on top of v7.4-rc3. This was done this way
since the commit "treewide: Convert devm_kmalloc() family to the
devm_kmalloc_obj() family" introduced conflicts.

The driver depends on the following series:

  - [1]: needed since the driver requires the consumers to call
    phy_power_on() and phy_power_off();
  - [2]: needed otherwise the QSGMII SerDes link is never powered ON.

The series [2] is included in this one.

[1] https://lore.kernel.org/all/20260601095041.3042950-1-a-kumar2@ti.com/
[2] https://lore.kernel.org/all/20260326134929.1696750-1-c-vankar@ti.com/

Signed-off-by: Benjamin Robin <benjamin.robin@bootlin.com>
---
Benjamin Robin (3):
      dt-bindings: phy: cadence-torrent: drop cdns,num-lanes default value
      dt-bindings: phy: cadence-torrent: add phy-mode constants
      phy: cadence-torrent: rewrite Torrent PHY driver

Chintan Vankar (1):
      arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY

 .../bindings/phy/phy-cadence-torrent.yaml          |   10 +-
 .../dts/ti/k3-j7200-evm-quad-port-eth-exp.dtso     |    3 +-
 drivers/phy/cadence/phy-cadence-torrent.c          | 9417 +++++++++-----------
 include/dt-bindings/phy/phy-cadence.h              |    8 +
 4 files changed, 4376 insertions(+), 5062 deletions(-)
---
base-commit: 6515d69692fb374d01e3dc95eef53047ca8f947c
change-id: 20261103-phy-cadence-torrent-ng-8d497bd05f48

Best regards,
--  
Benjamin Robin <benjamin.robin@bootlin.com>



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

* [PATCH 1/4] arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY
  2026-11-20 12:55 [PATCH 0/4] phy: cadence-torrent: rewrite Torrent PHY driver Benjamin Robin
@ 2026-11-20 12:55 ` Benjamin Robin
  2026-11-20 12:55 ` [PATCH 2/4] dt-bindings: phy: cadence-torrent: drop cdns,num-lanes default value Benjamin Robin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Benjamin Robin @ 2026-11-20 12:55 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis
  Cc: Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy,
	Benjamin Robin

From: Chintan Vankar <c-vankar@ti.com>

For CPSW5G QSGMII ports, CPSW assumes SERDES to be configured. Since it
may not be always true, add SERDES phys to guarantee it.

Fixes: 496cdc82e05f ("arm64: dts: ti: k3-j7200: Add overlay to enable CPSW5G ports in QSGMII mode")
Signed-off-by: Chintan Vankar <c-vankar@ti.com>
Signed-off-by: Benjamin Robin <benjamin.robin@bootlin.com>
---
 arch/arm64/boot/dts/ti/k3-j7200-evm-quad-port-eth-exp.dtso | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-evm-quad-port-eth-exp.dtso b/arch/arm64/boot/dts/ti/k3-j7200-evm-quad-port-eth-exp.dtso
index 6432ca08ee8e..4824d53c95bb 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-evm-quad-port-eth-exp.dtso
+++ b/arch/arm64/boot/dts/ti/k3-j7200-evm-quad-port-eth-exp.dtso
@@ -32,7 +32,8 @@ &cpsw0_port1 {
 	phy-handle = <&cpsw5g_phy0>;
 	phy-mode = "qsgmii";
 	mac-address = [00 00 00 00 00 00];
-	phys = <&cpsw0_phy_gmii_sel 1>;
+	phys = <&cpsw0_phy_gmii_sel 1>, <&serdes0_qsgmii_link>;
+	phy-names = "mac", "serdes";
 };
 
 &cpsw0_port2 {

-- 
2.56.1



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

* [PATCH 2/4] dt-bindings: phy: cadence-torrent: drop cdns,num-lanes default value
  2026-11-20 12:55 [PATCH 0/4] phy: cadence-torrent: rewrite Torrent PHY driver Benjamin Robin
  2026-11-20 12:55 ` [PATCH 1/4] arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY Benjamin Robin
@ 2026-11-20 12:55 ` Benjamin Robin
  2026-11-21 16:19   ` Krzysztof Kozlowski
  2026-11-20 12:55 ` [PATCH 3/4] dt-bindings: phy: cadence-torrent: add phy-mode constants Benjamin Robin
       [not found] ` <20261120-phy-cadence-torrent-ng-v1-4-da2db7125cd7@bootlin.com>
  3 siblings, 1 reply; 10+ messages in thread
From: Benjamin Robin @ 2026-11-20 12:55 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis
  Cc: Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy,
	Benjamin Robin

The driver treats cdns,num-lanes as mandatory and refuses to probe a PHY
sub-node that does not provide it, logging:

  No "cdns,num-lanes"-property.

A default value in the schema wrongly suggests that the property is
optional, which it is not since it is listed as required. Remove the
"default: 4" so the binding reflects the actual driver behavior and the
mandatory nature of the property.

Signed-off-by: Benjamin Robin <benjamin.robin@bootlin.com>
---
 Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml b/Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml
index 9af39b33646a..8e845e2373ac 100644
--- a/Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml
+++ b/Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml
@@ -106,7 +106,6 @@ patternProperties:
           Number of lanes.
         $ref: /schemas/types.yaml#/definitions/uint32
         enum: [1, 2, 3, 4]
-        default: 4
 
       cdns,ssc-mode:
         description:

-- 
2.56.1



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

* [PATCH 3/4] dt-bindings: phy: cadence-torrent: add phy-mode constants
  2026-11-20 12:55 [PATCH 0/4] phy: cadence-torrent: rewrite Torrent PHY driver Benjamin Robin
  2026-11-20 12:55 ` [PATCH 1/4] arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY Benjamin Robin
  2026-11-20 12:55 ` [PATCH 2/4] dt-bindings: phy: cadence-torrent: drop cdns,num-lanes default value Benjamin Robin
@ 2026-11-20 12:55 ` Benjamin Robin
  2026-11-21 16:20   ` Krzysztof Kozlowski
       [not found] ` <20261120-phy-cadence-torrent-ng-v1-4-da2db7125cd7@bootlin.com>
  3 siblings, 1 reply; 10+ messages in thread
From: Benjamin Robin @ 2026-11-20 12:55 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis
  Cc: Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy,
	Benjamin Robin

Add the `CDNS_TORRENT_MODE_*` constants to
include/dt-bindings/phy/phy-cadence.h such as SATA-LP and 2500BASE-X.

These constants are used by the new Cadence Torrent PHY driver and
are referenced by the `cdns,phy-mode` property of the Cadence Torrent
PHY binding to select the PHY mode.

Signed-off-by: Benjamin Robin <benjamin.robin@bootlin.com>
---
 Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml | 9 +++++++++
 include/dt-bindings/phy/phy-cadence.h                          | 8 ++++++++
 2 files changed, 17 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml b/Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml
index 8e845e2373ac..17a8343ac899 100644
--- a/Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml
+++ b/Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml
@@ -101,6 +101,15 @@ patternProperties:
         $ref: /schemas/types.yaml#/definitions/uint32
         enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 12]
 
+      cdns,phy-mode:
+        description:
+          Specifies an optional mode of PHY for which the group of PHY lanes is used.
+          Refer include/dt-bindings/phy/phy-cadence.h for the constants to be used.
+        $ref: /schemas/types.yaml#/definitions/uint32
+        minimum: 0
+        maximum: 63
+        default: 0
+
       cdns,num-lanes:
         description:
           Number of lanes.
diff --git a/include/dt-bindings/phy/phy-cadence.h b/include/dt-bindings/phy/phy-cadence.h
index 0671991208fc..94945b843288 100644
--- a/include/dt-bindings/phy/phy-cadence.h
+++ b/include/dt-bindings/phy/phy-cadence.h
@@ -15,6 +15,14 @@
 #define CDNS_TORRENT_DERIVED_REFCLK	1
 #define CDNS_TORRENT_RECEIVED_REFCLK	2
 
+#define CDNS_TORRENT_MODE_NONE		0x00
+#define CDNS_TORRENT_MODE_USB_G1	0x01
+#define CDNS_TORRENT_MODE_USB_IO_11V	0x02
+#define CDNS_TORRENT_MODE_XAUI_LP	0x04
+#define CDNS_TORRENT_MODE_SATA_LP	0x08
+#define CDNS_TORRENT_MODE_2500_BASEX	0x10
+#define CDNS_TORRENT_MODE_QSGMII	0x20
+
 /* Sierra */
 #define CDNS_SIERRA_PLL_CMNLC		0
 #define CDNS_SIERRA_PLL_CMNLC1		1

-- 
2.56.1



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

* Re: [PATCH 4/4] phy: cadence-torrent: rewrite Torrent PHY driver
       [not found] ` <20261120-phy-cadence-torrent-ng-v1-4-da2db7125cd7@bootlin.com>
@ 2026-11-21 16:16   ` Krzysztof Kozlowski
  2026-11-24 17:18     ` Benjamin Robin
  0 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-21 16:16 UTC (permalink / raw)
  To: Benjamin Robin
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis,
	Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy

On Fri, Nov 20, 2026 at 01:55:52PM +0100, Benjamin Robin wrote:
> The Cadence Torrent PHY (sd0801) is a multi-protocol SerDes used in
> several SoCs, among them the Texas Instruments J72xx family. Its
> programming depends on many parameters: the selected protocol (each
> associated PLL has to be set to a different frequency), the DisplayPort
> bit rate, the reference clock frequency, whether spread-spectrum
> clocking (SSC) is enabled, the number of lanes, and the PHY revision
> and technology (process node).
> 
> The current phy-cadence-torrent driver hard-codes, for every supported
> configuration, the set of register values to program. Because this
> configuration space is large, adding a new board or a new combination
> of standards requires duplicating dozens of opaque register values,
> which is inflexible and hard to maintain.
> 
> This new driver version computes the register values instead:
> 
>   - registers that depend on the reference clock frequency or on a PLL
>     frequency are computed at run time, from the reference clock
>     obtained through the clock framework and from the PLL frequency
>     derived from the selected standard;
>   - the other registers, which only depend on the standard type, the
>     PHY revision and the technology, are handled by one function per
>     register, using an internal table selected through a
>     standard/revision/technology key.
> 
> The PHY revision and technology are detected automatically from the
> PHY identification registers, and the DisplayPort link initialization
> and rate reconfiguration have been rewritten.
> 
> Compared with the existing driver, this rewrite provides:

10k lines patch!

No, instead improve the driver instead of doing bunch of significant
changes like:

> -#define MAX_NUM_LANES		4
> +#define MAX_NUM_LANES		8


mixed up with things like:

>  	/* voltage swing 3, pre-emphasis 0->3 */
> -	{	{.diag_tx_drv = 0x0003, .mgnfs_mult = 0x0000,
> -		 .cpost_mult = 0x0000},
> -		{.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
> -		 .cpost_mult = 0xFFFF},
> -		{.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
> -		 .cpost_mult = 0xFFFF},
> -		{.diag_tx_drv = 0xFFFF, .mgnfs_mult = 0xFFFF,
> -		 .cpost_mult = 0xFFFF}
> +	{
> +		{ .mgnfs_mult = 0x0000, .cpost_mult = 0x0000 },
> +		{ .mgnfs_mult = 0xFFFF, .cpost_mult = 0xFFFF },
> +		{ .mgnfs_mult = 0xFFFF, .cpost_mult = 0xFFFF },
> +		{ .mgnfs_mult = 0xFFFF, .cpost_mult = 0xFFFF },
>  	}

and with:

> -static int cdns_torrent_dp_configure(struct phy *phy,
> -				     union phy_configure_opts *opts)
> +static int tp_phy_configure(struct phy *phy, union phy_configure_opts *opts)
>  {

...

> -static int cdns_torrent_phy_on(struct phy *phy)
> +static int tp_phy_on(struct phy *phy)

This is absolutely unreviewable.

>  };

Best regards,
Krzysztof



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

* Re: [PATCH 2/4] dt-bindings: phy: cadence-torrent: drop cdns,num-lanes default value
  2026-11-20 12:55 ` [PATCH 2/4] dt-bindings: phy: cadence-torrent: drop cdns,num-lanes default value Benjamin Robin
@ 2026-11-21 16:19   ` Krzysztof Kozlowski
  2026-11-24 16:11     ` Benjamin Robin
  0 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-21 16:19 UTC (permalink / raw)
  To: Benjamin Robin
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis,
	Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy

On Fri, Nov 20, 2026 at 01:55:50PM +0100, Benjamin Robin wrote:
> The driver treats cdns,num-lanes as mandatory and refuses to probe a PHY
> sub-node that does not provide it, logging:
> 
>   No "cdns,num-lanes"-property.
> 
> A default value in the schema wrongly suggests that the property is
> optional, which it is not since it is listed as required. Remove the
> "default: 4" so the binding reflects the actual driver behavior and the
> mandatory nature of the property.

No, that's a bug in the driver introduced in 2020. You ignored the
background and history of this driver and DT bindings.

Best regards,
Krzysztof



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

* Re: [PATCH 3/4] dt-bindings: phy: cadence-torrent: add phy-mode constants
  2026-11-20 12:55 ` [PATCH 3/4] dt-bindings: phy: cadence-torrent: add phy-mode constants Benjamin Robin
@ 2026-11-21 16:20   ` Krzysztof Kozlowski
  2026-11-24 16:41     ` Benjamin Robin
  0 siblings, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-21 16:20 UTC (permalink / raw)
  To: Benjamin Robin
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis,
	Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy

On Fri, Nov 20, 2026 at 01:55:51PM +0100, Benjamin Robin wrote:
> Add the `CDNS_TORRENT_MODE_*` constants to
> include/dt-bindings/phy/phy-cadence.h such as SATA-LP and 2500BASE-X.

But why? Why do we need more of these properties?

> 
> These constants are used by the new Cadence Torrent PHY driver and
> are referenced by the `cdns,phy-mode` property of the Cadence Torrent
> PHY binding to select the PHY mode.

That's obvious, explain why you are duplicating phy type instead.

Best regards,
Krzysztof



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

* Re: [PATCH 2/4] dt-bindings: phy: cadence-torrent: drop cdns,num-lanes default value
  2026-11-21 16:19   ` Krzysztof Kozlowski
@ 2026-11-24 16:11     ` Benjamin Robin
  0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Robin @ 2026-11-24 16:11 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis,
	Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy

On Saturday, November 21, 2026 at 5:19 PM, Krzysztof Kozlowski wrote:
> On Fri, Nov 20, 2026 at 01:55:50PM +0100, Benjamin Robin wrote:
> > The driver treats cdns,num-lanes as mandatory and refuses to probe a PHY
> > sub-node that does not provide it, logging:
> > 
> >   No "cdns,num-lanes"-property.
> > 
> > A default value in the schema wrongly suggests that the property is
> > optional, which it is not since it is listed as required. Remove the
> > "default: 4" so the binding reflects the actual driver behavior and the
> > mandatory nature of the property.
> 
> No, that's a bug in the driver introduced in 2020. You ignored the
> background and history of this driver and DT bindings.

Hello Krzysztof,

I was not aware that this was a driver bug introduced in 2020. Series [1]
made the "cdns,num-lanes" property required in the DT binding back then
(see [2]), so the mismatch has been there for six years with no one
complaining so far.

Two options (I have a slight preference for the 2nd proposal):

1. Keep my current change: leave the property required and drop the
   misleading "default: 4" from the schema, so the binding matches the
   driver's behavior.

2. Restore the previous behavior: make "cdns,num-lanes" optional and
   default to 4 lanes again, fixing the driver regression introduced
   in 2020.

Which one do you prefer? If you consider the 2020 change a regression,
I can fix the driver instead and make the property optional with a
default of 4.

[1] https://lore.kernel.org/all/1600280911-9214-6-git-send-email-sjakhade@cadence.com/
[2] https://lore.kernel.org/all/1600280911-9214-8-git-send-email-sjakhade@cadence.com/

-- 
Benjamin Robin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com





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

* Re: [PATCH 3/4] dt-bindings: phy: cadence-torrent: add phy-mode constants
  2026-11-21 16:20   ` Krzysztof Kozlowski
@ 2026-11-24 16:41     ` Benjamin Robin
  0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Robin @ 2026-11-24 16:41 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis,
	Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy

On Saturday, November 21, 2026 at 5:20 PM, Krzysztof Kozlowski wrote:
> On Fri, Nov 20, 2026 at 01:55:51PM +0100, Benjamin Robin wrote:
> > Add the `CDNS_TORRENT_MODE_*` constants to
> > include/dt-bindings/phy/phy-cadence.h such as SATA-LP and 2500BASE-X.
> 
> But why? Why do we need more of these properties?

The Torrent PHY supports multiple standards: PCIe, USB, SATA, XAUI and
SGMII, ... For some of them, additional configuration options exist:

- USB:
  We need to know the I/O supply voltage (1.1 V or 1.2 V), since it
  affects the TX full-swing magnitude multiplier configuration for the
  USB TX/RX pad supply.

  The link can also be limited to Gen 1 speed (5 Gb/s SuperSpeed)
  instead of Gen 2 (10 Gb/s SuperSpeed+) to reduce power, which is why
  the option is named "LP" (low power).

- SATA:
  The PHY supports SATA Gen 1 (1.5 Gb/s), Gen 2 (3.0 Gb/s) and Gen 3
  (6.0 Gb/s). The link can also be limited to Gen 2 to reduces power.

- XAUI:
  The link can be configured to 1X only (3.125 Gb/s lane rate),
  dropping the 2X rate (6.25 Gb/s), again to reduce power.

- SGMII:
  The link can be "overclocked" to 2500BASE-X (called SGMII+ in the
  user guide) instead of 1Gbps. There is no PHY type in
  `include/dt-bindings/phy/phy.h` for 2500BASE-X, and since it is
  technically SGMII at a higher speed, I am not sure adding a new PHY
  type there is appropriate. That is why I added these constants to
  phy-cadence.h instead of reusing PHY_* types. If there is a preferred
  way, I am happy to rework this.

> > 
> > These constants are used by the new Cadence Torrent PHY driver and
> > are referenced by the `cdns,phy-mode` property of the Cadence Torrent
> > PHY binding to select the PHY mode.
> 
> That's obvious, explain why you are duplicating phy type instead.

You are right, the commit message needs improvement.

Any guidance on how you would like these options represented in the
binding would be much appreciated as I am not entirely sure about the
best approach myself.

The plan is to eventually allow reconfiguring the SGMII link speed
dynamically through phy_set_mode(), but for now the configuration needs
to be expressed statically from the DTS.

-- 
Benjamin Robin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com





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

* Re: [PATCH 4/4] phy: cadence-torrent: rewrite Torrent PHY driver
  2026-11-21 16:16   ` [PATCH 4/4] phy: cadence-torrent: rewrite Torrent PHY driver Krzysztof Kozlowski
@ 2026-11-24 17:18     ` Benjamin Robin
  0 siblings, 0 replies; 10+ messages in thread
From: Benjamin Robin @ 2026-11-24 17:18 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Yuti Amonkar,
	Philipp Zabel, Andrzej Hajda, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Nishanth Menon, Vignesh Raghavendra, Tero Kristo, Andrew Davis,
	Vinod Koul, Chintan Vankar, Abhash Kumar Jha, Neil Armstrong,
	Manivannan Sadhasivam, Thomas Richard, Swapnil Jakhade,
	Siddharth Vadapalli, Gregory CLEMENT, Théo Lebrun,
	Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
	linux-arm-kernel, devicetree, linux-kernel, linux-phy

On Saturday, November 21, 2026 at 5:16 PM, Krzysztof Kozlowski wrote:
> On Fri, Nov 20, 2026 at 01:55:52PM +0100, Benjamin Robin wrote:
> > The Cadence Torrent PHY (sd0801) is a multi-protocol SerDes used in
> > several SoCs, among them the Texas Instruments J72xx family. Its
> > programming depends on many parameters: the selected protocol (each
> > associated PLL has to be set to a different frequency), the DisplayPort
> > bit rate, the reference clock frequency, whether spread-spectrum
> > clocking (SSC) is enabled, the number of lanes, and the PHY revision
> > and technology (process node).
> > 
> > The current phy-cadence-torrent driver hard-codes, for every supported
> > configuration, the set of register values to program. Because this
> > configuration space is large, adding a new board or a new combination
> > of standards requires duplicating dozens of opaque register values,
> > which is inflexible and hard to maintain.
> > 
> > This new driver version computes the register values instead:
> > 
> >   - registers that depend on the reference clock frequency or on a PLL
> >     frequency are computed at run time, from the reference clock
> >     obtained through the clock framework and from the PLL frequency
> >     derived from the selected standard;
> >   - the other registers, which only depend on the standard type, the
> >     PHY revision and the technology, are handled by one function per
> >     register, using an internal table selected through a
> >     standard/revision/technology key.
> > 
> > The PHY revision and technology are detected automatically from the
> > PHY identification registers, and the DisplayPort link initialization
> > and rate reconfiguration have been rewritten.
> > 
> > Compared with the existing driver, this rewrite provides:
> 
> 10k lines patch!

I was expecting this kind of feedback, which is why the cover letter says:

  Because this is a complete rewrite, the diff is large and not well
  suited to a line-by-line review. The rewritten driver can be fetched
  from the phy-cadence-torrent branch at https://github.com/benjarobin/linux

To give more context: the new driver was written from scratch, in a new
empty file, although a very small part of the old driver was copied over.
I initially considered adding the new driver to staging, but after internal
discussion we decided against it.

> 
> No, instead improve the driver instead of doing bunch of significant
> changes like:
> 
> > -#define MAX_NUM_LANES		4
> > +#define MAX_NUM_LANES		8

Regarding incremental changes: I could try to build a series of smaller
steps from the old driver towards the new one. That comes at an
additional "cost", since intermediate patches would fix functions or
how there are called, that a later patch then removes or replaces.

However, even with such a series, the core transformation remains: one
patch replacing all the tables with per-register functions computing the
values. That patch alone removes roughly 3k lines and adds 2.5k lines,
which cannot really be split further.

So, I am going to try to create an incremental series: many "small" patches
converging towards the new implementation, with one unavoidable large patch.

With this additional context, could you confirm whether you would
prefer the series split into smaller patches?

> 
> This is absolutely unreviewable.


-- 
Benjamin Robin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com





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

end of thread, other threads:[~2026-11-24 17:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 12:55 [PATCH 0/4] phy: cadence-torrent: rewrite Torrent PHY driver Benjamin Robin
2026-11-20 12:55 ` [PATCH 1/4] arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY Benjamin Robin
2026-11-20 12:55 ` [PATCH 2/4] dt-bindings: phy: cadence-torrent: drop cdns,num-lanes default value Benjamin Robin
2026-11-21 16:19   ` Krzysztof Kozlowski
2026-11-24 16:11     ` Benjamin Robin
2026-11-20 12:55 ` [PATCH 3/4] dt-bindings: phy: cadence-torrent: add phy-mode constants Benjamin Robin
2026-11-21 16:20   ` Krzysztof Kozlowski
2026-11-24 16:41     ` Benjamin Robin
     [not found] ` <20261120-phy-cadence-torrent-ng-v1-4-da2db7125cd7@bootlin.com>
2026-11-21 16:16   ` [PATCH 4/4] phy: cadence-torrent: rewrite Torrent PHY driver Krzysztof Kozlowski
2026-11-24 17:18     ` Benjamin Robin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox