Commit 9a4edada authored by Jim Bride's avatar Jim Bride Committed by Rodrigo Vivi

drm/i915: Split skl_get_dpll()

Split out the DisplayPort and HDMI pll setup code into separate
functions and refactor the DP code does not directly depend on
crtc state, so that the code can be used for upfront link training.
Reviewed-by: default avatarManasi Navare <manasi.d.navare@intel.com>
Signed-off-by: default avatarJim Bride <jim.bride@linux.intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent a277ca7d
...@@ -1172,75 +1172,110 @@ skl_ddi_calculate_wrpll(int clock /* in Hz */, ...@@ -1172,75 +1172,110 @@ skl_ddi_calculate_wrpll(int clock /* in Hz */,
return true; return true;
} }
static struct intel_shared_dpll * static bool skl_ddi_hdmi_pll_dividers(struct intel_crtc *crtc,
skl_get_dpll(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state, struct intel_crtc_state *crtc_state,
struct intel_encoder *encoder) int clock)
{ {
struct intel_shared_dpll *pll;
uint32_t ctrl1, cfgcr1, cfgcr2; uint32_t ctrl1, cfgcr1, cfgcr2;
int clock = crtc_state->port_clock; struct skl_wrpll_params wrpll_params = { 0, };
/* /*
* See comment in intel_dpll_hw_state to understand why we always use 0 * See comment in intel_dpll_hw_state to understand why we always use 0
* as the DPLL id in this function. * as the DPLL id in this function.
*/ */
ctrl1 = DPLL_CTRL1_OVERRIDE(0); ctrl1 = DPLL_CTRL1_OVERRIDE(0);
if (encoder->type == INTEL_OUTPUT_HDMI) { ctrl1 |= DPLL_CTRL1_HDMI_MODE(0);
struct skl_wrpll_params wrpll_params = { 0, };
ctrl1 |= DPLL_CTRL1_HDMI_MODE(0); if (!skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params))
return false;
if (!skl_ddi_calculate_wrpll(clock * 1000, &wrpll_params)) cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE |
return NULL; DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) |
wrpll_params.dco_integer;
cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) |
DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) |
DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
wrpll_params.central_freq;
memset(&crtc_state->dpll_hw_state, 0,
sizeof(crtc_state->dpll_hw_state));
crtc_state->dpll_hw_state.ctrl1 = ctrl1;
crtc_state->dpll_hw_state.cfgcr1 = cfgcr1;
crtc_state->dpll_hw_state.cfgcr2 = cfgcr2;
return true;
}
bool skl_ddi_dp_set_dpll_hw_state(int clock,
struct intel_dpll_hw_state *dpll_hw_state)
{
uint32_t ctrl1;
/*
* See comment in intel_dpll_hw_state to understand why we always use 0
* as the DPLL id in this function.
*/
ctrl1 = DPLL_CTRL1_OVERRIDE(0);
switch (clock / 2) {
case 81000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_810, 0);
break;
case 135000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1350, 0);
break;
case 270000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2700, 0);
break;
/* eDP 1.4 rates */
case 162000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1620, 0);
break;
case 108000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1080, 0);
break;
case 216000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2160, 0);
break;
}
cfgcr1 = DPLL_CFGCR1_FREQ_ENABLE | dpll_hw_state->ctrl1 = ctrl1;
DPLL_CFGCR1_DCO_FRACTION(wrpll_params.dco_fraction) | return true;
wrpll_params.dco_integer; }
cfgcr2 = DPLL_CFGCR2_QDIV_RATIO(wrpll_params.qdiv_ratio) | static struct intel_shared_dpll *
DPLL_CFGCR2_QDIV_MODE(wrpll_params.qdiv_mode) | skl_get_dpll(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state,
DPLL_CFGCR2_KDIV(wrpll_params.kdiv) | struct intel_encoder *encoder)
DPLL_CFGCR2_PDIV(wrpll_params.pdiv) | {
wrpll_params.central_freq; struct intel_shared_dpll *pll;
int clock = crtc_state->port_clock;
bool bret;
struct intel_dpll_hw_state dpll_hw_state;
memset(&dpll_hw_state, 0, sizeof(dpll_hw_state));
if (encoder->type == INTEL_OUTPUT_HDMI) {
bret = skl_ddi_hdmi_pll_dividers(crtc, crtc_state, clock);
if (!bret) {
DRM_DEBUG_KMS("Could not get HDMI pll dividers.\n");
return NULL;
}
} else if (encoder->type == INTEL_OUTPUT_DP || } else if (encoder->type == INTEL_OUTPUT_DP ||
encoder->type == INTEL_OUTPUT_DP_MST || encoder->type == INTEL_OUTPUT_DP_MST ||
encoder->type == INTEL_OUTPUT_EDP) { encoder->type == INTEL_OUTPUT_EDP) {
switch (crtc_state->port_clock / 2) { bret = skl_ddi_dp_set_dpll_hw_state(clock, &dpll_hw_state);
case 81000: if (!bret) {
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_810, 0); DRM_DEBUG_KMS("Could not set DP dpll HW state.\n");
break; return NULL;
case 135000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1350, 0);
break;
case 270000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2700, 0);
break;
/* eDP 1.4 rates */
case 162000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1620, 0);
break;
case 108000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1080, 0);
break;
case 216000:
ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2160, 0);
break;
} }
crtc_state->dpll_hw_state = dpll_hw_state;
cfgcr1 = cfgcr2 = 0;
} else { } else {
return NULL; return NULL;
} }
memset(&crtc_state->dpll_hw_state, 0,
sizeof(crtc_state->dpll_hw_state));
crtc_state->dpll_hw_state.ctrl1 = ctrl1;
crtc_state->dpll_hw_state.cfgcr1 = cfgcr1;
crtc_state->dpll_hw_state.cfgcr2 = cfgcr2;
if (encoder->type == INTEL_OUTPUT_EDP) if (encoder->type == INTEL_OUTPUT_EDP)
pll = intel_find_shared_dpll(crtc, crtc_state, pll = intel_find_shared_dpll(crtc, crtc_state,
DPLL_ID_SKL_DPLL0, DPLL_ID_SKL_DPLL0,
......
...@@ -164,4 +164,8 @@ void intel_shared_dpll_init(struct drm_device *dev); ...@@ -164,4 +164,8 @@ void intel_shared_dpll_init(struct drm_device *dev);
bool bxt_ddi_dp_set_dpll_hw_state(int clock, bool bxt_ddi_dp_set_dpll_hw_state(int clock,
struct intel_dpll_hw_state *dpll_hw_state); struct intel_dpll_hw_state *dpll_hw_state);
/* SKL dpll related functions */
bool skl_ddi_dp_set_dpll_hw_state(int clock,
struct intel_dpll_hw_state *dpll_hw_state);
#endif /* _INTEL_DPLL_MGR_H_ */ #endif /* _INTEL_DPLL_MGR_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment