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.
To be able to test this driver, it 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.
Both series [1] and [2] are included in this one.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Signed-off-by: Benjamin Robin <[email protected]>
---
Changes in v2:
- Split the series into a series of "smaller" patches
- Addressed the sashiko comments
- Link to v1:
https://patch.msgid.link/[email protected]
---
Abhash Kumar Jha (1):
drm/bridge: cdns-mhdp8546: Power on/off the PHY in probe/remove
Benjamin Robin (19):
dt-bindings: phy: cadence-torrent: make cdns,num-lanes optional again
dt-bindings: phy: cadence-torrent: add phy-mode constants
phy: cadence-torrent: make cdns,num-lanes optional again
phy: cadence-torrent: rename symbols to prepare for rewrite
phy: cadence-torrent: replace regmap with readw/writew
phy: cadence-torrent: move refclk clk_init_data to the stack
phy: cadence-torrent: drop diag_tx_drv from DP voltage coeff
phy: cadence-torrent: use link lane count and mlane for DP config
phy: cadence-torrent: use devm_of_clk_add_hw_provider()
phy: cadence-torrent: rework subnode parsing and lane validation
phy: cadence-torrent: rework ref clock init and probe cleanup
phy: cadence-torrent: factor out DP PLL frequency update
phy: cadence-torrent: store clock and reset handles only on success
phy: cadence-torrent: unify link configuration in the probe
phy: cadence-torrent: allow config on an already-configured DP link
phy: cadence-torrent: track current DP link bit rate
phy: cadence-torrent: rework suspend/resume to restore link config
phy: cadence-torrent: rewrite Torrent PHY driver
phy: cadence-torrent: support 8 lanes on the sd0801 PHY
Chintan Vankar (1):
arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY
Dmitry Guzman (1):
phy: torrent: fix `RX_DIAG_NQST_CTRL` register address
.../bindings/phy/phy-cadence-torrent.yaml | 9 +-
.../dts/ti/k3-j7200-evm-quad-port-eth-exp.dtso | 3 +-
.../gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 11 +-
drivers/phy/cadence/phy-cadence-torrent.c | 9411 +++++++++-----------
include/dt-bindings/phy/phy-cadence.h | 7 +
5 files changed, 4438 insertions(+), 5003 deletions(-)
---
base-commit: 6515d69692fb374d01e3dc95eef53047ca8f947c
change-id: 20261103-phy-cadence-torrent-ng-8d497bd05f48
Best regards,
--
Benjamin Robin <[email protected]>