[PATCH v2 18/22] phy: cadence-torrent: allow config on an already-configured DP link
Benjamin Robin
benjamin.robin at bootlin.com
Wed Dec 2 07:09:03 PST 2026
Allow the DisplayPort link to be configured even when the PHY is already
configured, recovering the number of lanes actually in use from the
hardware in that case. When the probe finds the PHY already configured,
the DP lane count is read from the PHY_RESET register.
Signed-off-by: Benjamin Robin <benjamin.robin at bootlin.com>
---
drivers/phy/cadence/phy-cadence-torrent.c | 36 ++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c
index 3b4d52ee7a53..0cbbedeefd87 100644
--- a/drivers/phy/cadence/phy-cadence-torrent.c
+++ b/drivers/phy/cadence/phy-cadence-torrent.c
@@ -1310,6 +1310,27 @@ static int tp_dp_verify_config(const struct tp_link *link,
return 0;
}
+static void tp_dp_find_used_lanes(const struct tp_data *tp_data, struct tp_link *link)
+{
+ u32 mlane = link->mlane;
+ u32 used_lanes_mask;
+ u32 all_lane_mask;
+ u32 value;
+
+ all_lane_mask = ((1U << link->max_lanes) - 1) << mlane;
+ value = tp_reg_dptx_read(tp_data, PHY_RESET);
+
+ /* only keep the lanes not in reset */
+ used_lanes_mask = value & all_lane_mask;
+
+ /* only keep the lanes with Tx differential output not into electrical idle */
+ used_lanes_mask &= (~(value >> PMA_TX_ELEC_IDLE_SHIFT)) & all_lane_mask;
+
+ /* update the number of used lanes */
+ used_lanes_mask >>= mlane;
+ link->num_lanes = __ffs(~used_lanes_mask);
+}
+
/* Configure lane count as required. */
static void tp_dp_set_lanes(const struct tp_data *tp_data, struct tp_link *link, u32 num_lanes)
{
@@ -1433,9 +1454,6 @@ static int tp_phy_configure(struct phy *phy, union phy_configure_opts *opts)
guard(mutex)(&tp_data->lock);
- if (tp_data->already_configured)
- return 0;
-
if (link->phy_type != TYPE_DP)
return -EINVAL;
@@ -1617,6 +1635,16 @@ static const struct phy_ops cdns_torrent_phy_ops = {
.owner = THIS_MODULE,
};
+static void tp_init_already_configured_links_opts(struct tp_data *tp_data)
+{
+ for (u8 i = 0; i < tp_data->nb_links; ++i) {
+ struct tp_link *link = &tp_data->links[i];
+
+ if (link->phy_type == TYPE_DP)
+ tp_dp_find_used_lanes(tp_data, link);
+ }
+}
+
static int tp_derived_refclk_enable(struct clk_hw *hw)
{
struct tp_data *tp_data = tp_derived_refclk_to_tp_data(hw);
@@ -2750,6 +2778,8 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)
ret = tp_ref_clks_init(tp_data);
if (ret)
goto cleanup;
+ } else {
+ tp_init_already_configured_links_opts(tp_data);
}
ret = tp_dp_reg_base_init(pdev, tp_data);
--
2.56.1
More information about the linux-arm-kernel
mailing list