aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2014-10-28 07:20:22 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-04 17:22:06 -0500
commitd288f65fe9472501929eb8d63c2b248813b92056 (patch)
tree0990d492dda76c08e109c8f82fba498735eb5316 /drivers/gpu/drm/i915/intel_display.c
parent034e43c6c0dc7e70a6edc96987758237cb92f0cd (diff)
drm/i915: Make sure DPLL is enabled when kicking the power sequencer on VLV/CHV
The power seqeuencer kick procedure requires the DPLL to be running in order to complete successfully. In case the DPLL isn't currently running when we need to kick the power seqeuncer enable it temporarily. This can happen eg. during ->detect() when the pipe is not already active. To avoid needlessly duplicating the DPLL programming re-use the already existing functions by passing a temporary pipe config to them instead of having them consult the current pipe config at crtc->config. v2: Introduce vlv_force_pll_{on,off}() (Daniel) v3: Rebase due to drm_crtc vs. intel_crtc changes Fix a typo in commit msg (checkpatch) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Imre Deak <imre.deak@intel.com> (v1) [danvet: Appease checkpatch.] 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.c131
1 files changed, 93 insertions, 38 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index ee982f5412d6..848f330a931f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -94,8 +94,10 @@ static void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc,
94static void ironlake_set_pipeconf(struct drm_crtc *crtc); 94static void ironlake_set_pipeconf(struct drm_crtc *crtc);
95static void haswell_set_pipeconf(struct drm_crtc *crtc); 95static void haswell_set_pipeconf(struct drm_crtc *crtc);
96static void intel_set_pipe_csc(struct drm_crtc *crtc); 96static void intel_set_pipe_csc(struct drm_crtc *crtc);
97static void vlv_prepare_pll(struct intel_crtc *crtc); 97static void vlv_prepare_pll(struct intel_crtc *crtc,
98static void chv_prepare_pll(struct intel_crtc *crtc); 98 const struct intel_crtc_config *pipe_config);
99static void chv_prepare_pll(struct intel_crtc *crtc,
100 const struct intel_crtc_config *pipe_config);
99 101
100static struct intel_encoder *intel_find_encoder(struct intel_connector *connector, int pipe) 102static struct intel_encoder *intel_find_encoder(struct intel_connector *connector, int pipe)
101{ 103{
@@ -1484,12 +1486,13 @@ static void intel_init_dpio(struct drm_device *dev)
1484 } 1486 }
1485} 1487}
1486 1488
1487static void vlv_enable_pll(struct intel_crtc *crtc) 1489static void vlv_enable_pll(struct intel_crtc *crtc,
1490 const struct intel_crtc_config *pipe_config)
1488{ 1491{
1489 struct drm_device *dev = crtc->base.dev; 1492 struct drm_device *dev = crtc->base.dev;
1490 struct drm_i915_private *dev_priv = dev->dev_private; 1493 struct drm_i915_private *dev_priv = dev->dev_private;
1491 int reg = DPLL(crtc->pipe); 1494 int reg = DPLL(crtc->pipe);
1492 u32 dpll = crtc->config.dpll_hw_state.dpll; 1495 u32 dpll = pipe_config->dpll_hw_state.dpll;
1493 1496
1494 assert_pipe_disabled(dev_priv, crtc->pipe); 1497 assert_pipe_disabled(dev_priv, crtc->pipe);
1495 1498
@@ -1507,7 +1510,7 @@ static void vlv_enable_pll(struct intel_crtc *crtc)
1507 if (wait_for(((I915_READ(reg) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1)) 1510 if (wait_for(((I915_READ(reg) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1))
1508 DRM_ERROR("DPLL %d failed to lock\n", crtc->pipe); 1511 DRM_ERROR("DPLL %d failed to lock\n", crtc->pipe);
1509 1512
1510 I915_WRITE(DPLL_MD(crtc->pipe), crtc->config.dpll_hw_state.dpll_md); 1513 I915_WRITE(DPLL_MD(crtc->pipe), pipe_config->dpll_hw_state.dpll_md);
1511 POSTING_READ(DPLL_MD(crtc->pipe)); 1514 POSTING_READ(DPLL_MD(crtc->pipe));
1512 1515
1513 /* We do this three times for luck */ 1516 /* We do this three times for luck */
@@ -1522,7 +1525,8 @@ static void vlv_enable_pll(struct intel_crtc *crtc)
1522 udelay(150); /* wait for warmup */ 1525 udelay(150); /* wait for warmup */
1523} 1526}
1524 1527
1525static void chv_enable_pll(struct intel_crtc *crtc) 1528static void chv_enable_pll(struct intel_crtc *crtc,
1529 const struct intel_crtc_config *pipe_config)
1526{ 1530{
1527 struct drm_device *dev = crtc->base.dev; 1531 struct drm_device *dev = crtc->base.dev;
1528 struct drm_i915_private *dev_priv = dev->dev_private; 1532 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1547,14 +1551,14 @@ static void chv_enable_pll(struct intel_crtc *crtc)
1547 udelay(1); 1551 udelay(1);
1548 1552
1549 /* Enable PLL */ 1553 /* Enable PLL */
1550 I915_WRITE(DPLL(pipe), crtc->config.dpll_hw_state.dpll); 1554 I915_WRITE(DPLL(pipe), pipe_config->dpll_hw_state.dpll);
1551 1555
1552 /* Check PLL is locked */ 1556 /* Check PLL is locked */
1553 if (wait_for(((I915_READ(DPLL(pipe)) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1)) 1557 if (wait_for(((I915_READ(DPLL(pipe)) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1))
1554 DRM_ERROR("PLL %d failed to lock\n", pipe); 1558 DRM_ERROR("PLL %d failed to lock\n", pipe);
1555 1559
1556 /* not sure when this should be written */ 1560 /* not sure when this should be written */
1557 I915_WRITE(DPLL_MD(pipe), crtc->config.dpll_hw_state.dpll_md); 1561 I915_WRITE(DPLL_MD(pipe), pipe_config->dpll_hw_state.dpll_md);
1558 POSTING_READ(DPLL_MD(pipe)); 1562 POSTING_READ(DPLL_MD(pipe));
1559 1563
1560 mutex_unlock(&dev_priv->dpio_lock); 1564 mutex_unlock(&dev_priv->dpio_lock);
@@ -4842,9 +4846,9 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc)
4842 4846
4843 if (!is_dsi) { 4847 if (!is_dsi) {
4844 if (IS_CHERRYVIEW(dev)) 4848 if (IS_CHERRYVIEW(dev))
4845 chv_prepare_pll(intel_crtc); 4849 chv_prepare_pll(intel_crtc, &intel_crtc->config);
4846 else 4850 else
4847 vlv_prepare_pll(intel_crtc); 4851 vlv_prepare_pll(intel_crtc, &intel_crtc->config);
4848 } 4852 }
4849 4853
4850 if (intel_crtc->config.has_dp_encoder) 4854 if (intel_crtc->config.has_dp_encoder)
@@ -4864,9 +4868,9 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc)
4864 4868
4865 if (!is_dsi) { 4869 if (!is_dsi) {
4866 if (IS_CHERRYVIEW(dev)) 4870 if (IS_CHERRYVIEW(dev))
4867 chv_enable_pll(intel_crtc); 4871 chv_enable_pll(intel_crtc, &intel_crtc->config);
4868 else 4872 else
4869 vlv_enable_pll(intel_crtc); 4873 vlv_enable_pll(intel_crtc, &intel_crtc->config);
4870 } 4874 }
4871 4875
4872 for_each_encoder_on_crtc(dev, crtc, encoder) 4876 for_each_encoder_on_crtc(dev, crtc, encoder)
@@ -5747,7 +5751,8 @@ void intel_dp_set_m_n(struct intel_crtc *crtc)
5747 &crtc->config.dp_m2_n2); 5751 &crtc->config.dp_m2_n2);
5748} 5752}
5749 5753
5750static void vlv_update_pll(struct intel_crtc *crtc) 5754static void vlv_update_pll(struct intel_crtc *crtc,
5755 struct intel_crtc_config *pipe_config)
5751{ 5756{
5752 u32 dpll, dpll_md; 5757 u32 dpll, dpll_md;
5753 5758
@@ -5762,14 +5767,15 @@ static void vlv_update_pll(struct intel_crtc *crtc)
5762 if (crtc->pipe == PIPE_B) 5767 if (crtc->pipe == PIPE_B)
5763 dpll |= DPLL_INTEGRATED_CRI_CLK_VLV; 5768 dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
5764 dpll |= DPLL_VCO_ENABLE; 5769 dpll |= DPLL_VCO_ENABLE;
5765 crtc->config.dpll_hw_state.dpll = dpll; 5770 pipe_config->dpll_hw_state.dpll = dpll;
5766 5771
5767 dpll_md = (crtc->config.pixel_multiplier - 1) 5772 dpll_md = (pipe_config->pixel_multiplier - 1)
5768 << DPLL_MD_UDI_MULTIPLIER_SHIFT; 5773 << DPLL_MD_UDI_MULTIPLIER_SHIFT;
5769 crtc->config.dpll_hw_state.dpll_md = dpll_md; 5774 pipe_config->dpll_hw_state.dpll_md = dpll_md;
5770} 5775}
5771 5776
5772static void vlv_prepare_pll(struct intel_crtc *crtc) 5777static void vlv_prepare_pll(struct intel_crtc *crtc,
5778 const struct intel_crtc_config *pipe_config)
5773{ 5779{
5774 struct drm_device *dev = crtc->base.dev; 5780 struct drm_device *dev = crtc->base.dev;
5775 struct drm_i915_private *dev_priv = dev->dev_private; 5781 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5780,11 +5786,11 @@ static void vlv_prepare_pll(struct intel_crtc *crtc)
5780 5786
5781 mutex_lock(&dev_priv->dpio_lock); 5787 mutex_lock(&dev_priv->dpio_lock);
5782 5788
5783 bestn = crtc->config.dpll.n; 5789 bestn = pipe_config->dpll.n;
5784 bestm1 = crtc->config.dpll.m1; 5790 bestm1 = pipe_config->dpll.m1;
5785 bestm2 = crtc->config.dpll.m2; 5791 bestm2 = pipe_config->dpll.m2;
5786 bestp1 = crtc->config.dpll.p1; 5792 bestp1 = pipe_config->dpll.p1;
5787 bestp2 = crtc->config.dpll.p2; 5793 bestp2 = pipe_config->dpll.p2;
5788 5794
5789 /* See eDP HDMI DPIO driver vbios notes doc */ 5795 /* See eDP HDMI DPIO driver vbios notes doc */
5790 5796
@@ -5821,7 +5827,7 @@ static void vlv_prepare_pll(struct intel_crtc *crtc)
5821 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW3(pipe), mdiv); 5827 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW3(pipe), mdiv);
5822 5828
5823 /* Set HBR and RBR LPF coefficients */ 5829 /* Set HBR and RBR LPF coefficients */
5824 if (crtc->config.port_clock == 162000 || 5830 if (pipe_config->port_clock == 162000 ||
5825 intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG) || 5831 intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG) ||
5826 intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI)) 5832 intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI))
5827 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe), 5833 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe),
@@ -5860,19 +5866,21 @@ static void vlv_prepare_pll(struct intel_crtc *crtc)
5860 mutex_unlock(&dev_priv->dpio_lock); 5866 mutex_unlock(&dev_priv->dpio_lock);
5861} 5867}
5862 5868
5863static void chv_update_pll(struct intel_crtc *crtc) 5869static void chv_update_pll(struct intel_crtc *crtc,
5870 struct intel_crtc_config *pipe_config)
5864{ 5871{
5865 crtc->config.dpll_hw_state.dpll = DPLL_SSC_REF_CLOCK_CHV | 5872 pipe_config->dpll_hw_state.dpll = DPLL_SSC_REF_CLOCK_CHV |
5866 DPLL_REFA_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS | 5873 DPLL_REFA_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS |
5867 DPLL_VCO_ENABLE; 5874 DPLL_VCO_ENABLE;
5868 if (crtc->pipe != PIPE_A) 5875 if (crtc->pipe != PIPE_A)
5869 crtc->config.dpll_hw_state.dpll |= DPLL_INTEGRATED_CRI_CLK_VLV; 5876 pipe_config->dpll_hw_state.dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
5870 5877
5871 crtc->config.dpll_hw_state.dpll_md = 5878 pipe_config->dpll_hw_state.dpll_md =
5872 (crtc->config.pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT; 5879 (pipe_config->pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT;
5873} 5880}
5874 5881
5875static void chv_prepare_pll(struct intel_crtc *crtc) 5882static void chv_prepare_pll(struct intel_crtc *crtc,
5883 const struct intel_crtc_config *pipe_config)
5876{ 5884{
5877 struct drm_device *dev = crtc->base.dev; 5885 struct drm_device *dev = crtc->base.dev;
5878 struct drm_i915_private *dev_priv = dev->dev_private; 5886 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -5883,18 +5891,18 @@ static void chv_prepare_pll(struct intel_crtc *crtc)
5883 u32 bestn, bestm1, bestm2, bestp1, bestp2, bestm2_frac; 5891 u32 bestn, bestm1, bestm2, bestp1, bestp2, bestm2_frac;
5884 int refclk; 5892 int refclk;
5885 5893
5886 bestn = crtc->config.dpll.n; 5894 bestn = pipe_config->dpll.n;
5887 bestm2_frac = crtc->config.dpll.m2 & 0x3fffff; 5895 bestm2_frac = pipe_config->dpll.m2 & 0x3fffff;
5888 bestm1 = crtc->config.dpll.m1; 5896 bestm1 = pipe_config->dpll.m1;
5889 bestm2 = crtc->config.dpll.m2 >> 22; 5897 bestm2 = pipe_config->dpll.m2 >> 22;
5890 bestp1 = crtc->config.dpll.p1; 5898 bestp1 = pipe_config->dpll.p1;
5891 bestp2 = crtc->config.dpll.p2; 5899 bestp2 = pipe_config->dpll.p2;
5892 5900
5893 /* 5901 /*
5894 * Enable Refclk and SSC 5902 * Enable Refclk and SSC
5895 */ 5903 */
5896 I915_WRITE(dpll_reg, 5904 I915_WRITE(dpll_reg,
5897 crtc->config.dpll_hw_state.dpll & ~DPLL_VCO_ENABLE); 5905 pipe_config->dpll_hw_state.dpll & ~DPLL_VCO_ENABLE);
5898 5906
5899 mutex_lock(&dev_priv->dpio_lock); 5907 mutex_lock(&dev_priv->dpio_lock);
5900 5908
@@ -5942,6 +5950,53 @@ static void chv_prepare_pll(struct intel_crtc *crtc)
5942 mutex_unlock(&dev_priv->dpio_lock); 5950 mutex_unlock(&dev_priv->dpio_lock);
5943} 5951}
5944 5952
5953/**
5954 * vlv_force_pll_on - forcibly enable just the PLL
5955 * @dev_priv: i915 private structure
5956 * @pipe: pipe PLL to enable
5957 * @dpll: PLL configuration
5958 *
5959 * Enable the PLL for @pipe using the supplied @dpll config. To be used
5960 * in cases where we need the PLL enabled even when @pipe is not going to
5961 * be enabled.
5962 */
5963void vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
5964 const struct dpll *dpll)
5965{
5966 struct intel_crtc *crtc =
5967 to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
5968 struct intel_crtc_config pipe_config = {
5969 .pixel_multiplier = 1,
5970 .dpll = *dpll,
5971 };
5972
5973 if (IS_CHERRYVIEW(dev)) {
5974 chv_update_pll(crtc, &pipe_config);
5975 chv_prepare_pll(crtc, &pipe_config);
5976 chv_enable_pll(crtc, &pipe_config);
5977 } else {
5978 vlv_update_pll(crtc, &pipe_config);
5979 vlv_prepare_pll(crtc, &pipe_config);
5980 vlv_enable_pll(crtc, &pipe_config);
5981 }
5982}
5983
5984/**
5985 * vlv_force_pll_off - forcibly disable just the PLL
5986 * @dev_priv: i915 private structure
5987 * @pipe: pipe PLL to disable
5988 *
5989 * Disable the PLL for @pipe. To be used in cases where we need
5990 * the PLL enabled even when @pipe is not going to be enabled.
5991 */
5992void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe)
5993{
5994 if (IS_CHERRYVIEW(dev))
5995 chv_disable_pll(to_i915(dev), pipe);
5996 else
5997 vlv_disable_pll(to_i915(dev), pipe);
5998}
5999
5945static void i9xx_update_pll(struct intel_crtc *crtc, 6000static void i9xx_update_pll(struct intel_crtc *crtc,
5946 intel_clock_t *reduced_clock, 6001 intel_clock_t *reduced_clock,
5947 int num_connectors) 6002 int num_connectors)
@@ -6323,9 +6378,9 @@ static int i9xx_crtc_mode_set(struct intel_crtc *crtc,
6323 has_reduced_clock ? &reduced_clock : NULL, 6378 has_reduced_clock ? &reduced_clock : NULL,
6324 num_connectors); 6379 num_connectors);
6325 } else if (IS_CHERRYVIEW(dev)) { 6380 } else if (IS_CHERRYVIEW(dev)) {
6326 chv_update_pll(crtc); 6381 chv_update_pll(crtc, &crtc->config);
6327 } else if (IS_VALLEYVIEW(dev)) { 6382 } else if (IS_VALLEYVIEW(dev)) {
6328 vlv_update_pll(crtc); 6383 vlv_update_pll(crtc, &crtc->config);
6329 } else { 6384 } else {
6330 i9xx_update_pll(crtc, 6385 i9xx_update_pll(crtc,
6331 has_reduced_clock ? &reduced_clock : NULL, 6386 has_reduced_clock ? &reduced_clock : NULL,