aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-07-11 16:13:42 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-07-12 12:54:01 -0400
commit426115cf5dd81d17a6322c493ca337e637ce2aed (patch)
tree0f4a79cdd72db333fe3f44b6561e70b2222597be /drivers/gpu/drm/i915/intel_display.c
parent84734a049d0ef2f6f5fb0a1fe060cd51480dd855 (diff)
drm/i915: clean up vlv ->pre_pll_enable and pll enable sequence
No need to call the ->pre_pll_enable hook twice if we don't enable the dpll too early. This should make Jani a bit less grumpy. v2: Rebase on top of the newly-colored BUG_ONs. v3: Reinstate the lost write of the DPLL_MD register, spotted by Imre. Cc: Imre Deak <imre.deak@intel.com> Cc: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Imre Deak <imre.deak@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index b1b1d2a38fc9..abaae78f0c52 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1321,32 +1321,40 @@ static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv,
1321 assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMID); 1321 assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMID);
1322} 1322}
1323 1323
1324static void vlv_enable_pll(struct drm_i915_private *dev_priv, enum pipe pipe) 1324static void vlv_enable_pll(struct intel_crtc *crtc)
1325{ 1325{
1326 int reg; 1326 struct drm_device *dev = crtc->base.dev;
1327 u32 val; 1327 struct drm_i915_private *dev_priv = dev->dev_private;
1328 int reg = DPLL(crtc->pipe);
1329 u32 dpll = crtc->config.dpll_hw_state.dpll;
1328 1330
1329 assert_pipe_disabled(dev_priv, pipe); 1331 assert_pipe_disabled(dev_priv, crtc->pipe);
1330 1332
1331 /* No really, not for ILK+ */ 1333 /* No really, not for ILK+ */
1332 BUG_ON(!IS_VALLEYVIEW(dev_priv->dev)); 1334 BUG_ON(!IS_VALLEYVIEW(dev_priv->dev));
1333 1335
1334 /* PLL is protected by panel, make sure we can write it */ 1336 /* PLL is protected by panel, make sure we can write it */
1335 if (IS_MOBILE(dev_priv->dev) && !IS_I830(dev_priv->dev)) 1337 if (IS_MOBILE(dev_priv->dev) && !IS_I830(dev_priv->dev))
1336 assert_panel_unlocked(dev_priv, pipe); 1338 assert_panel_unlocked(dev_priv, crtc->pipe);
1337 1339
1338 reg = DPLL(pipe); 1340 I915_WRITE(reg, dpll);
1339 val = I915_READ(reg); 1341 POSTING_READ(reg);
1340 val |= DPLL_VCO_ENABLE; 1342 udelay(150);
1343
1344 if (wait_for(((I915_READ(reg) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1))
1345 DRM_ERROR("DPLL %d failed to lock\n", crtc->pipe);
1346
1347 I915_WRITE(DPLL_MD(crtc->pipe), crtc->config.dpll_hw_state.dpll_md);
1348 POSTING_READ(DPLL_MD(crtc->pipe));
1341 1349
1342 /* We do this three times for luck */ 1350 /* We do this three times for luck */
1343 I915_WRITE(reg, val); 1351 I915_WRITE(reg, dpll);
1344 POSTING_READ(reg); 1352 POSTING_READ(reg);
1345 udelay(150); /* wait for warmup */ 1353 udelay(150); /* wait for warmup */
1346 I915_WRITE(reg, val); 1354 I915_WRITE(reg, dpll);
1347 POSTING_READ(reg); 1355 POSTING_READ(reg);
1348 udelay(150); /* wait for warmup */ 1356 udelay(150); /* wait for warmup */
1349 I915_WRITE(reg, val); 1357 I915_WRITE(reg, dpll);
1350 POSTING_READ(reg); 1358 POSTING_READ(reg);
1351 udelay(150); /* wait for warmup */ 1359 udelay(150); /* wait for warmup */
1352} 1360}
@@ -3654,7 +3662,7 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc)
3654 if (encoder->pre_pll_enable) 3662 if (encoder->pre_pll_enable)
3655 encoder->pre_pll_enable(encoder); 3663 encoder->pre_pll_enable(encoder);
3656 3664
3657 vlv_enable_pll(dev_priv, pipe); 3665 vlv_enable_pll(intel_crtc);
3658 3666
3659 for_each_encoder_on_crtc(dev, crtc, encoder) 3667 for_each_encoder_on_crtc(dev, crtc, encoder)
3660 if (encoder->pre_enable) 3668 if (encoder->pre_enable)
@@ -4409,7 +4417,6 @@ static void vlv_update_pll(struct intel_crtc *crtc)
4409{ 4417{
4410 struct drm_device *dev = crtc->base.dev; 4418 struct drm_device *dev = crtc->base.dev;
4411 struct drm_i915_private *dev_priv = dev->dev_private; 4419 struct drm_i915_private *dev_priv = dev->dev_private;
4412 struct intel_encoder *encoder;
4413 int pipe = crtc->pipe; 4420 int pipe = crtc->pipe;
4414 u32 dpll, mdiv; 4421 u32 dpll, mdiv;
4415 u32 bestn, bestm1, bestm2, bestp1, bestp2; 4422 u32 bestn, bestm1, bestm2, bestp1, bestp2;
@@ -4498,10 +4505,6 @@ static void vlv_update_pll(struct intel_crtc *crtc)
4498 4505
4499 vlv_dpio_write(dev_priv, DPIO_PLL_CML(pipe), 0x87871000); 4506 vlv_dpio_write(dev_priv, DPIO_PLL_CML(pipe), 0x87871000);
4500 4507
4501 for_each_encoder_on_crtc(dev, &crtc->base, encoder)
4502 if (encoder->pre_pll_enable)
4503 encoder->pre_pll_enable(encoder);
4504
4505 /* Enable DPIO clock input */ 4508 /* Enable DPIO clock input */
4506 dpll = DPLL_EXT_BUFFER_ENABLE_VLV | DPLL_REFA_CLK_ENABLE_VLV | 4509 dpll = DPLL_EXT_BUFFER_ENABLE_VLV | DPLL_REFA_CLK_ENABLE_VLV |
4507 DPLL_VGA_MODE_DIS | DPLL_INTEGRATED_CLOCK_VLV; 4510 DPLL_VGA_MODE_DIS | DPLL_INTEGRATED_CLOCK_VLV;
@@ -4511,20 +4514,10 @@ static void vlv_update_pll(struct intel_crtc *crtc)
4511 dpll |= DPLL_VCO_ENABLE; 4514 dpll |= DPLL_VCO_ENABLE;
4512 crtc->config.dpll_hw_state.dpll = dpll; 4515 crtc->config.dpll_hw_state.dpll = dpll;
4513 4516
4514 I915_WRITE(DPLL(pipe), dpll);
4515 POSTING_READ(DPLL(pipe));
4516 udelay(150);
4517
4518 if (wait_for(((I915_READ(DPLL(pipe)) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1))
4519 DRM_ERROR("DPLL %d failed to lock\n", pipe);
4520
4521 dpll_md = (crtc->config.pixel_multiplier - 1) 4517 dpll_md = (crtc->config.pixel_multiplier - 1)
4522 << DPLL_MD_UDI_MULTIPLIER_SHIFT; 4518 << DPLL_MD_UDI_MULTIPLIER_SHIFT;
4523 crtc->config.dpll_hw_state.dpll_md = dpll_md; 4519 crtc->config.dpll_hw_state.dpll_md = dpll_md;
4524 4520
4525 I915_WRITE(DPLL_MD(pipe), dpll_md);
4526 POSTING_READ(DPLL_MD(pipe));
4527
4528 if (crtc->config.has_dp_encoder) 4521 if (crtc->config.has_dp_encoder)
4529 intel_dp_set_m_n(crtc); 4522 intel_dp_set_m_n(crtc);
4530 4523