drm/i915/tc: Factor out tc_phy_verify_legacy_or_dp_alt_mode()
authorImre Deak <imre.deak@intel.com>
Thu, 23 Mar 2023 14:20:18 +0000 (16:20 +0200)
committerImre Deak <imre.deak@intel.com>
Mon, 3 Apr 2023 08:35:30 +0000 (11:35 +0300)
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.

Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230323142035.1432621-13-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_tc.c

index 2910921..bf83e67 100644 (file)
@@ -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: