[Intel-gfx] [PATCH 12/29] drm/i915/tc: Factor out tc_phy_verify_legacy_or_dp_alt_mode()

Imre Deak imre.deak at intel.com
Thu Mar 23 14:20:18 UTC 2023


Factor out a function verifying the PHY connected state in legacy or
DP-alt mode. This is common to all platforms, which can be reused in
platform specific connect hooks added in follow-up patches.

No functional changes.

Signed-off-by: Imre Deak <imre.deak at intel.com>
---
 drivers/gpu/drm/i915/display/intel_tc.c | 47 +++++++++++++++----------
 1 file changed, 29 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_tc.c b/drivers/gpu/drm/i915/display/intel_tc.c
index 9179f86287ab0..ee4db9d0eb978 100644
--- a/drivers/gpu/drm/i915/display/intel_tc.c
+++ b/drivers/gpu/drm/i915/display/intel_tc.c
@@ -434,27 +434,13 @@ static void icl_tc_phy_get_hw_state(struct intel_tc_port *tc)
  * connect and disconnect to cleanly transfer ownership with the controller and
  * set the type-C power state.
  */
-static bool icl_tc_phy_connect(struct intel_tc_port *tc,
-			       int required_lanes)
+static bool tc_phy_verify_legacy_or_dp_alt_mode(struct intel_tc_port *tc,
+						int required_lanes)
 {
 	struct drm_i915_private *i915 = tc_to_i915(tc);
 	struct intel_digital_port *dig_port = tc->dig_port;
 	int max_lanes;
 
-	if (tc->mode == TC_PORT_TBT_ALT)
-		return true;
-
-	if (!tc_phy_is_ready(tc) &&
-	    !drm_WARN_ON(&i915->drm, tc->legacy_port)) {
-		drm_dbg_kms(&i915->drm, "Port %s: PHY not ready\n",
-			    tc->port_name);
-		return false;
-	}
-
-	if (!tc_phy_take_ownership(tc, true) &&
-	    !drm_WARN_ON(&i915->drm, tc->legacy_port))
-		return false;
-
 	max_lanes = intel_tc_port_fia_max_lane_count(dig_port);
 	if (tc->legacy_port) {
 		drm_WARN_ON(&i915->drm, max_lanes != 4);
@@ -470,7 +456,7 @@ static bool icl_tc_phy_connect(struct intel_tc_port *tc,
 	if (!(tc_phy_hpd_live_status(tc) & BIT(TC_PORT_DP_ALT))) {
 		drm_dbg_kms(&i915->drm, "Port %s: PHY sudden disconnect\n",
 			    tc->port_name);
-		goto out_release_phy;
+		return false;
 	}
 
 	if (max_lanes < required_lanes) {
@@ -478,9 +464,34 @@ static bool icl_tc_phy_connect(struct intel_tc_port *tc,
 			    "Port %s: PHY max lanes %d < required lanes %d\n",
 			    tc->port_name,
 			    max_lanes, required_lanes);
-		goto out_release_phy;
+		return false;
+	}
+
+	return true;
+}
+
+static bool icl_tc_phy_connect(struct intel_tc_port *tc,
+			       int required_lanes)
+{
+	struct drm_i915_private *i915 = tc_to_i915(tc);
+
+	if (tc->mode == TC_PORT_TBT_ALT)
+		return true;
+
+	if (!tc_phy_is_ready(tc) &&
+	    !drm_WARN_ON(&i915->drm, tc->legacy_port)) {
+		drm_dbg_kms(&i915->drm, "Port %s: PHY not ready\n",
+			    tc->port_name);
+		return false;
 	}
 
+	if (!tc_phy_take_ownership(tc, true) &&
+	    !drm_WARN_ON(&i915->drm, tc->legacy_port))
+		return false;
+
+	if (!tc_phy_verify_legacy_or_dp_alt_mode(tc, required_lanes))
+		goto out_release_phy;
+
 	return true;
 
 out_release_phy:
-- 
2.37.1



More information about the Intel-gfx mailing list