aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2016-05-13 16:41:34 -0400
committerVille Syrjälä <ville.syrjala@linux.intel.com>2016-05-23 14:11:15 -0400
commit2b73001e739d3db8474472b7e6585ef9ee4b946e (patch)
treeb663bd2cc0385c4d92af279e366eaac0df83dfb0 /drivers/gpu/drm/i915/intel_display.c
parent709e05c3c46e866243f369a46ca5552a5c1e6b44 (diff)
drm/i915: Extract bxt DE PLL enable/disable from broxton_set_cdclk()
Enabling and disalbing the DE PLL are two nice self contained operations, so let's move them into a few small helper functions. Makes it easier to see the forest from the trees in broxton_set_cdclk(). Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1463172100-24715-16-git-send-email-ville.syrjala@linux.intel.com Reviewed-by: Imre Deak <imre.deak@intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 57771639b94e..521ad133deb8 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5278,6 +5278,31 @@ static int skl_cdclk_decimal(int cdclk)
5278 return DIV_ROUND_CLOSEST(cdclk - 1000, 500); 5278 return DIV_ROUND_CLOSEST(cdclk - 1000, 500);
5279} 5279}
5280 5280
5281static void bxt_de_pll_disable(struct drm_i915_private *dev_priv)
5282{
5283 I915_WRITE(BXT_DE_PLL_ENABLE, 0);
5284
5285 /* Timeout 200us */
5286 if (wait_for((I915_READ(BXT_DE_PLL_ENABLE) & BXT_DE_PLL_LOCK) == 0, 1))
5287 DRM_ERROR("timeout waiting for DE PLL unlock\n");
5288}
5289
5290static void bxt_de_pll_enable(struct drm_i915_private *dev_priv, u32 ratio)
5291{
5292 u32 val;
5293
5294 val = I915_READ(BXT_DE_PLL_CTL);
5295 val &= ~BXT_DE_PLL_RATIO_MASK;
5296 val |= ratio;
5297 I915_WRITE(BXT_DE_PLL_CTL, val);
5298
5299 I915_WRITE(BXT_DE_PLL_ENABLE, BXT_DE_PLL_PLL_ENABLE);
5300
5301 /* Timeout 200us */
5302 if (wait_for((I915_READ(BXT_DE_PLL_ENABLE) & BXT_DE_PLL_LOCK) != 0, 1))
5303 DRM_ERROR("timeout waiting for DE PLL lock\n");
5304}
5305
5281static void broxton_set_cdclk(struct drm_i915_private *dev_priv, int cdclk) 5306static void broxton_set_cdclk(struct drm_i915_private *dev_priv, int cdclk)
5282{ 5307{
5283 uint32_t divider; 5308 uint32_t divider;
@@ -5345,25 +5370,13 @@ static void broxton_set_cdclk(struct drm_i915_private *dev_priv, int cdclk)
5345 */ 5370 */
5346 if (cdclk == 19200 || cdclk == 624000 || 5371 if (cdclk == 19200 || cdclk == 624000 ||
5347 current_cdclk == 624000) { 5372 current_cdclk == 624000) {
5348 I915_WRITE(BXT_DE_PLL_ENABLE, ~BXT_DE_PLL_PLL_ENABLE); 5373 bxt_de_pll_disable(dev_priv);
5349 /* Timeout 200us */
5350 if (wait_for(!(I915_READ(BXT_DE_PLL_ENABLE) & BXT_DE_PLL_LOCK),
5351 1))
5352 DRM_ERROR("timout waiting for DE PLL unlock\n");
5353 } 5374 }
5354 5375
5355 if (cdclk != 19200) { 5376 if (cdclk != 19200) {
5356 uint32_t val; 5377 uint32_t val;
5357 5378
5358 val = I915_READ(BXT_DE_PLL_CTL); 5379 bxt_de_pll_enable(dev_priv, ratio);
5359 val &= ~BXT_DE_PLL_RATIO_MASK;
5360 val |= ratio;
5361 I915_WRITE(BXT_DE_PLL_CTL, val);
5362
5363 I915_WRITE(BXT_DE_PLL_ENABLE, BXT_DE_PLL_PLL_ENABLE);
5364 /* Timeout 200us */
5365 if (wait_for(I915_READ(BXT_DE_PLL_ENABLE) & BXT_DE_PLL_LOCK, 1))
5366 DRM_ERROR("timeout waiting for DE PLL lock\n");
5367 5380
5368 val = divider | skl_cdclk_decimal(cdclk); 5381 val = divider | skl_cdclk_decimal(cdclk);
5369 /* 5382 /*