Commit 199e5d79 authored by Keith Packard's avatar Keith Packard

drm/i915: Fix PCH SSC reference clock settings

The PCH refclk settings are global, so we need to look at all of the
encoders, not just the current encoder when deciding how to configure
it. Also, handle systems with more than one panel (any combination of
PCH/non-PCH eDP and LVDS).

Disable SSC clocks when no panels are connected.
Signed-off-by: default avatarKeith Packard <keithp@keithp.com>
parent 72bbe58c
...@@ -5113,31 +5113,32 @@ static void ironlake_update_pch_refclk(struct drm_device *dev) ...@@ -5113,31 +5113,32 @@ static void ironlake_update_pch_refclk(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_mode_config *mode_config = &dev->mode_config; struct drm_mode_config *mode_config = &dev->mode_config;
struct drm_crtc *crtc;
struct intel_encoder *encoder; struct intel_encoder *encoder;
struct intel_encoder *has_edp_encoder = NULL;
u32 temp; u32 temp;
bool has_lvds = false; bool has_lvds = false;
bool has_cpu_edp = false;
bool has_pch_edp = false;
bool has_panel = false;
/* We need to take the global config into account */ /* We need to take the global config into account */
list_for_each_entry(crtc, &mode_config->crtc_list, head) { list_for_each_entry(encoder, &mode_config->encoder_list,
if (!crtc->enabled) base.head) {
continue; switch (encoder->type) {
case INTEL_OUTPUT_LVDS:
list_for_each_entry(encoder, &mode_config->encoder_list, has_panel = true;
base.head) { has_lvds = true;
if (encoder->base.crtc != crtc) break;
continue; case INTEL_OUTPUT_EDP:
has_panel = true;
switch (encoder->type) { if (intel_encoder_is_pch_edp(&encoder->base))
case INTEL_OUTPUT_LVDS: has_pch_edp = true;
has_lvds = true; else
case INTEL_OUTPUT_EDP: has_cpu_edp = true;
has_edp_encoder = encoder; break;
break;
}
} }
} }
DRM_DEBUG_KMS("has_panel %d has_lvds %d has_pch_edp %d has_cpu_edp %d\n",
has_panel, has_lvds, has_pch_edp, has_cpu_edp);
/* Ironlake: try to setup display ref clock before DPLL /* Ironlake: try to setup display ref clock before DPLL
* enabling. This is only under driver's control after * enabling. This is only under driver's control after
...@@ -5148,36 +5149,57 @@ static void ironlake_update_pch_refclk(struct drm_device *dev) ...@@ -5148,36 +5149,57 @@ static void ironlake_update_pch_refclk(struct drm_device *dev)
/* Always enable nonspread source */ /* Always enable nonspread source */
temp &= ~DREF_NONSPREAD_SOURCE_MASK; temp &= ~DREF_NONSPREAD_SOURCE_MASK;
temp |= DREF_NONSPREAD_SOURCE_ENABLE; temp |= DREF_NONSPREAD_SOURCE_ENABLE;
temp &= ~DREF_SSC_SOURCE_MASK;
temp |= DREF_SSC_SOURCE_ENABLE;
I915_WRITE(PCH_DREF_CONTROL, temp);
POSTING_READ(PCH_DREF_CONTROL); if (has_panel) {
udelay(200); temp &= ~DREF_SSC_SOURCE_MASK;
temp |= DREF_SSC_SOURCE_ENABLE;
if (has_edp_encoder) { /* SSC must be turned on before enabling the CPU output */
if (intel_panel_use_ssc(dev_priv)) { if (intel_panel_use_ssc(dev_priv)) {
DRM_DEBUG_KMS("Using SSC on panel\n");
temp |= DREF_SSC1_ENABLE; temp |= DREF_SSC1_ENABLE;
I915_WRITE(PCH_DREF_CONTROL, temp);
POSTING_READ(PCH_DREF_CONTROL);
udelay(200);
} }
/* Get SSC going before enabling the outputs */
I915_WRITE(PCH_DREF_CONTROL, temp);
POSTING_READ(PCH_DREF_CONTROL);
udelay(200);
temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK; temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK;
/* Enable CPU source on CPU attached eDP */ /* Enable CPU source on CPU attached eDP */
if (!intel_encoder_is_pch_edp(&has_edp_encoder->base)) { if (has_cpu_edp) {
if (intel_panel_use_ssc(dev_priv)) if (intel_panel_use_ssc(dev_priv)) {
DRM_DEBUG_KMS("Using SSC on eDP\n");
temp |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD; temp |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD;
}
else else
temp |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD; temp |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD;
} else { } else
/* Enable SSC on PCH eDP if needed */ temp |= DREF_CPU_SOURCE_OUTPUT_DISABLE;
if (intel_panel_use_ssc(dev_priv)) {
DRM_ERROR("enabling SSC on PCH\n"); I915_WRITE(PCH_DREF_CONTROL, temp);
temp |= DREF_SUPERSPREAD_SOURCE_ENABLE; POSTING_READ(PCH_DREF_CONTROL);
} udelay(200);
} } else {
DRM_DEBUG_KMS("Disabling SSC entirely\n");
temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK;
/* Turn off CPU output */
temp |= DREF_CPU_SOURCE_OUTPUT_DISABLE;
I915_WRITE(PCH_DREF_CONTROL, temp);
POSTING_READ(PCH_DREF_CONTROL);
udelay(200);
/* Turn off the SSC source */
temp &= ~DREF_SSC_SOURCE_MASK;
temp |= DREF_SSC_SOURCE_DISABLE;
/* Turn off SSC1 */
temp &= ~ DREF_SSC1_ENABLE;
I915_WRITE(PCH_DREF_CONTROL, temp); I915_WRITE(PCH_DREF_CONTROL, temp);
POSTING_READ(PCH_DREF_CONTROL); POSTING_READ(PCH_DREF_CONTROL);
udelay(200); udelay(200);
......
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