Commit 712f422e authored by Imre Deak's avatar Imre Deak
Browse files

drm/i915/tc: Factor out tc_phy_verify_legacy_or_dp_alt_mode()



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: default avatarMika Kahola <mika.kahola@intel.com>
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230323142035.1432621-13-imre.deak@intel.com
parent d1fc4e39
Loading
Loading
Loading
Loading
+29 −18
Original line number Diff line number Diff line
@@ -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,
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: