Skip to content

Commit fc62009

Browse files
committed
drm/i915/icl+: Simplify combo/TBT PLL calculation call-chain
To simplify things, call the combo PHY/TBT PLL calculation functions directly from the corresponding combo/TypeC PLL get functions, instead of calling the same calculation functions after having to recheck if the given PHY is combo or TypeC. Signed-off-by: Imre Deak <[email protected]> Reviewed-by: José Roberto de Souza <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 09eac82 commit fc62009

File tree

1 file changed

+27
-37
lines changed

1 file changed

+27
-37
lines changed

drivers/gpu/drm/i915/display/intel_dpll_mgr.c

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,49 +3049,26 @@ static int icl_ddi_combo_pll_get_freq(struct drm_i915_private *i915,
30493049
icl_wrpll_ref_clock(i915));
30503050
}
30513051

3052-
static bool icl_calc_dpll_state(struct intel_crtc_state *crtc_state,
3053-
struct intel_encoder *encoder,
3052+
static void icl_calc_dpll_state(struct drm_i915_private *i915,
3053+
const struct skl_wrpll_params *pll_params,
30543054
struct intel_dpll_hw_state *pll_state)
30553055
{
3056-
struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
3057-
u32 cfgcr0, cfgcr1;
3058-
struct skl_wrpll_params pll_params = { 0 };
3059-
bool ret;
3060-
3061-
if (intel_phy_is_tc(dev_priv, intel_port_to_phy(dev_priv,
3062-
encoder->port)))
3063-
ret = icl_calc_tbt_pll(crtc_state, &pll_params);
3064-
else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI) ||
3065-
intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI))
3066-
ret = icl_calc_wrpll(crtc_state, &pll_params);
3067-
else
3068-
ret = icl_calc_dp_combo_pll(crtc_state, &pll_params);
3069-
3070-
if (!ret)
3071-
return false;
3056+
memset(pll_state, 0, sizeof(*pll_state));
30723057

3073-
cfgcr0 = DPLL_CFGCR0_DCO_FRACTION(pll_params.dco_fraction) |
3074-
pll_params.dco_integer;
3058+
pll_state->cfgcr0 = DPLL_CFGCR0_DCO_FRACTION(pll_params->dco_fraction) |
3059+
pll_params->dco_integer;
30753060

3076-
cfgcr1 = DPLL_CFGCR1_QDIV_RATIO(pll_params.qdiv_ratio) |
3077-
DPLL_CFGCR1_QDIV_MODE(pll_params.qdiv_mode) |
3078-
DPLL_CFGCR1_KDIV(pll_params.kdiv) |
3079-
DPLL_CFGCR1_PDIV(pll_params.pdiv);
3061+
pll_state->cfgcr1 = DPLL_CFGCR1_QDIV_RATIO(pll_params->qdiv_ratio) |
3062+
DPLL_CFGCR1_QDIV_MODE(pll_params->qdiv_mode) |
3063+
DPLL_CFGCR1_KDIV(pll_params->kdiv) |
3064+
DPLL_CFGCR1_PDIV(pll_params->pdiv);
30803065

3081-
if (INTEL_GEN(dev_priv) >= 12)
3082-
cfgcr1 |= TGL_DPLL_CFGCR1_CFSELOVRD_NORMAL_XTAL;
3066+
if (INTEL_GEN(i915) >= 12)
3067+
pll_state->cfgcr1 |= TGL_DPLL_CFGCR1_CFSELOVRD_NORMAL_XTAL;
30833068
else
3084-
cfgcr1 |= DPLL_CFGCR1_CENTRAL_FREQ_8400;
3085-
3086-
memset(pll_state, 0, sizeof(*pll_state));
3087-
3088-
pll_state->cfgcr0 = cfgcr0;
3089-
pll_state->cfgcr1 = cfgcr1;
3090-
3091-
return true;
3069+
pll_state->cfgcr1 |= DPLL_CFGCR1_CENTRAL_FREQ_8400;
30923070
}
30933071

3094-
30953072
static enum tc_port icl_pll_id_to_tc_port(enum intel_dpll_id id)
30963073
{
30973074
return id - DPLL_ID_ICL_MGPLL1;
@@ -3504,19 +3481,29 @@ static bool icl_get_combo_phy_dpll(struct intel_atomic_state *state,
35043481
{
35053482
struct intel_crtc_state *crtc_state =
35063483
intel_atomic_get_new_crtc_state(state, crtc);
3484+
struct skl_wrpll_params pll_params = { };
35073485
struct icl_port_dpll *port_dpll =
35083486
&crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT];
35093487
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
35103488
enum port port = encoder->port;
35113489
unsigned long dpll_mask;
3490+
int ret;
35123491

3513-
if (!icl_calc_dpll_state(crtc_state, encoder, &port_dpll->hw_state)) {
3492+
if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI) ||
3493+
intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI))
3494+
ret = icl_calc_wrpll(crtc_state, &pll_params);
3495+
else
3496+
ret = icl_calc_dp_combo_pll(crtc_state, &pll_params);
3497+
3498+
if (!ret) {
35143499
drm_dbg_kms(&dev_priv->drm,
35153500
"Could not calculate combo PHY PLL state.\n");
35163501

35173502
return false;
35183503
}
35193504

3505+
icl_calc_dpll_state(dev_priv, &pll_params, &port_dpll->hw_state);
3506+
35203507
if (IS_ELKHARTLAKE(dev_priv) && port != PORT_A)
35213508
dpll_mask =
35223509
BIT(DPLL_ID_EHL_DPLL4) |
@@ -3550,16 +3537,19 @@ static bool icl_get_tc_phy_dplls(struct intel_atomic_state *state,
35503537
struct drm_i915_private *dev_priv = to_i915(state->base.dev);
35513538
struct intel_crtc_state *crtc_state =
35523539
intel_atomic_get_new_crtc_state(state, crtc);
3540+
struct skl_wrpll_params pll_params = { };
35533541
struct icl_port_dpll *port_dpll;
35543542
enum intel_dpll_id dpll_id;
35553543

35563544
port_dpll = &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT];
3557-
if (!icl_calc_dpll_state(crtc_state, encoder, &port_dpll->hw_state)) {
3545+
if (!icl_calc_tbt_pll(crtc_state, &pll_params)) {
35583546
drm_dbg_kms(&dev_priv->drm,
35593547
"Could not calculate TBT PLL state.\n");
35603548
return false;
35613549
}
35623550

3551+
icl_calc_dpll_state(dev_priv, &pll_params, &port_dpll->hw_state);
3552+
35633553
port_dpll->pll = intel_find_shared_dpll(state, crtc,
35643554
&port_dpll->hw_state,
35653555
BIT(DPLL_ID_ICL_TBTPLL));

0 commit comments

Comments
 (0)