2 * Copyright © 2006-2017 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include "intel_drv.h"
29 * The display engine uses several different clocks to do its work. There
30 * are two main clocks involved that aren't directly related to the actual
31 * pixel clock or any symbol/bit clock of the actual output port. These
32 * are the core display clock (CDCLK) and RAWCLK.
34 * CDCLK clocks most of the display pipe logic, and thus its frequency
35 * must be high enough to support the rate at which pixels are flowing
36 * through the pipes. Downscaling must also be accounted as that increases
37 * the effective pixel rate.
39 * On several platforms the CDCLK frequency can be changed dynamically
40 * to minimize power consumption for a given display configuration.
41 * Typically changes to the CDCLK frequency require all the display pipes
42 * to be shut down while the frequency is being changed.
44 * On SKL+ the DMC will toggle the CDCLK off/on during DC5/6 entry/exit.
45 * DMC will not change the active CDCLK frequency however, so that part
46 * will still be performed by the driver directly.
48 * RAWCLK is a fixed frequency clock, often used by various auxiliary
49 * blocks such as AUX CH or backlight PWM. Hence the only thing we
50 * really need to know about RAWCLK is its frequency so that various
51 * dividers can be programmed correctly.
54 static void fixed_133mhz_get_cdclk(struct drm_i915_private
*dev_priv
,
55 struct intel_cdclk_state
*cdclk_state
)
57 cdclk_state
->cdclk
= 133333;
60 static void fixed_200mhz_get_cdclk(struct drm_i915_private
*dev_priv
,
61 struct intel_cdclk_state
*cdclk_state
)
63 cdclk_state
->cdclk
= 200000;
66 static void fixed_266mhz_get_cdclk(struct drm_i915_private
*dev_priv
,
67 struct intel_cdclk_state
*cdclk_state
)
69 cdclk_state
->cdclk
= 266667;
72 static void fixed_333mhz_get_cdclk(struct drm_i915_private
*dev_priv
,
73 struct intel_cdclk_state
*cdclk_state
)
75 cdclk_state
->cdclk
= 333333;
78 static void fixed_400mhz_get_cdclk(struct drm_i915_private
*dev_priv
,
79 struct intel_cdclk_state
*cdclk_state
)
81 cdclk_state
->cdclk
= 400000;
84 static void fixed_450mhz_get_cdclk(struct drm_i915_private
*dev_priv
,
85 struct intel_cdclk_state
*cdclk_state
)
87 cdclk_state
->cdclk
= 450000;
90 static void i85x_get_cdclk(struct drm_i915_private
*dev_priv
,
91 struct intel_cdclk_state
*cdclk_state
)
93 struct pci_dev
*pdev
= dev_priv
->drm
.pdev
;
97 * 852GM/852GMV only supports 133 MHz and the HPLLCC
98 * encoding is different :(
99 * FIXME is this the right way to detect 852GM/852GMV?
101 if (pdev
->revision
== 0x1) {
102 cdclk_state
->cdclk
= 133333;
106 pci_bus_read_config_word(pdev
->bus
,
107 PCI_DEVFN(0, 3), HPLLCC
, &hpllcc
);
109 /* Assume that the hardware is in the high speed state. This
110 * should be the default.
112 switch (hpllcc
& GC_CLOCK_CONTROL_MASK
) {
113 case GC_CLOCK_133_200
:
114 case GC_CLOCK_133_200_2
:
115 case GC_CLOCK_100_200
:
116 cdclk_state
->cdclk
= 200000;
118 case GC_CLOCK_166_250
:
119 cdclk_state
->cdclk
= 250000;
121 case GC_CLOCK_100_133
:
122 cdclk_state
->cdclk
= 133333;
124 case GC_CLOCK_133_266
:
125 case GC_CLOCK_133_266_2
:
126 case GC_CLOCK_166_266
:
127 cdclk_state
->cdclk
= 266667;
132 static void i915gm_get_cdclk(struct drm_i915_private
*dev_priv
,
133 struct intel_cdclk_state
*cdclk_state
)
135 struct pci_dev
*pdev
= dev_priv
->drm
.pdev
;
138 pci_read_config_word(pdev
, GCFGC
, &gcfgc
);
140 if (gcfgc
& GC_LOW_FREQUENCY_ENABLE
) {
141 cdclk_state
->cdclk
= 133333;
145 switch (gcfgc
& GC_DISPLAY_CLOCK_MASK
) {
146 case GC_DISPLAY_CLOCK_333_320_MHZ
:
147 cdclk_state
->cdclk
= 333333;
150 case GC_DISPLAY_CLOCK_190_200_MHZ
:
151 cdclk_state
->cdclk
= 190000;
156 static void i945gm_get_cdclk(struct drm_i915_private
*dev_priv
,
157 struct intel_cdclk_state
*cdclk_state
)
159 struct pci_dev
*pdev
= dev_priv
->drm
.pdev
;
162 pci_read_config_word(pdev
, GCFGC
, &gcfgc
);
164 if (gcfgc
& GC_LOW_FREQUENCY_ENABLE
) {
165 cdclk_state
->cdclk
= 133333;
169 switch (gcfgc
& GC_DISPLAY_CLOCK_MASK
) {
170 case GC_DISPLAY_CLOCK_333_320_MHZ
:
171 cdclk_state
->cdclk
= 320000;
174 case GC_DISPLAY_CLOCK_190_200_MHZ
:
175 cdclk_state
->cdclk
= 200000;
180 static unsigned int intel_hpll_vco(struct drm_i915_private
*dev_priv
)
182 static const unsigned int blb_vco
[8] = {
189 static const unsigned int pnv_vco
[8] = {
196 static const unsigned int cl_vco
[8] = {
205 static const unsigned int elk_vco
[8] = {
211 static const unsigned int ctg_vco
[8] = {
219 const unsigned int *vco_table
;
223 /* FIXME other chipsets? */
224 if (IS_GM45(dev_priv
))
226 else if (IS_G45(dev_priv
))
228 else if (IS_I965GM(dev_priv
))
230 else if (IS_PINEVIEW(dev_priv
))
232 else if (IS_G33(dev_priv
))
237 tmp
= I915_READ(IS_MOBILE(dev_priv
) ? HPLLVCO_MOBILE
: HPLLVCO
);
239 vco
= vco_table
[tmp
& 0x7];
241 DRM_ERROR("Bad HPLL VCO (HPLLVCO=0x%02x)\n", tmp
);
243 DRM_DEBUG_KMS("HPLL VCO %u kHz\n", vco
);
248 static void g33_get_cdclk(struct drm_i915_private
*dev_priv
,
249 struct intel_cdclk_state
*cdclk_state
)
251 struct pci_dev
*pdev
= dev_priv
->drm
.pdev
;
252 static const uint8_t div_3200
[] = { 12, 10, 8, 7, 5, 16 };
253 static const uint8_t div_4000
[] = { 14, 12, 10, 8, 6, 20 };
254 static const uint8_t div_4800
[] = { 20, 14, 12, 10, 8, 24 };
255 static const uint8_t div_5333
[] = { 20, 16, 12, 12, 8, 28 };
256 const uint8_t *div_table
;
257 unsigned int cdclk_sel
;
260 cdclk_state
->vco
= intel_hpll_vco(dev_priv
);
262 pci_read_config_word(pdev
, GCFGC
, &tmp
);
264 cdclk_sel
= (tmp
>> 4) & 0x7;
266 if (cdclk_sel
>= ARRAY_SIZE(div_3200
))
269 switch (cdclk_state
->vco
) {
271 div_table
= div_3200
;
274 div_table
= div_4000
;
277 div_table
= div_4800
;
280 div_table
= div_5333
;
286 cdclk_state
->cdclk
= DIV_ROUND_CLOSEST(cdclk_state
->vco
,
287 div_table
[cdclk_sel
]);
291 DRM_ERROR("Unable to determine CDCLK. HPLL VCO=%u kHz, CFGC=0x%08x\n",
292 cdclk_state
->vco
, tmp
);
293 cdclk_state
->cdclk
= 190476;
296 static void pnv_get_cdclk(struct drm_i915_private
*dev_priv
,
297 struct intel_cdclk_state
*cdclk_state
)
299 struct pci_dev
*pdev
= dev_priv
->drm
.pdev
;
302 pci_read_config_word(pdev
, GCFGC
, &gcfgc
);
304 switch (gcfgc
& GC_DISPLAY_CLOCK_MASK
) {
305 case GC_DISPLAY_CLOCK_267_MHZ_PNV
:
306 cdclk_state
->cdclk
= 266667;
308 case GC_DISPLAY_CLOCK_333_MHZ_PNV
:
309 cdclk_state
->cdclk
= 333333;
311 case GC_DISPLAY_CLOCK_444_MHZ_PNV
:
312 cdclk_state
->cdclk
= 444444;
314 case GC_DISPLAY_CLOCK_200_MHZ_PNV
:
315 cdclk_state
->cdclk
= 200000;
318 DRM_ERROR("Unknown pnv display core clock 0x%04x\n", gcfgc
);
320 case GC_DISPLAY_CLOCK_133_MHZ_PNV
:
321 cdclk_state
->cdclk
= 133333;
323 case GC_DISPLAY_CLOCK_167_MHZ_PNV
:
324 cdclk_state
->cdclk
= 166667;
329 static void i965gm_get_cdclk(struct drm_i915_private
*dev_priv
,
330 struct intel_cdclk_state
*cdclk_state
)
332 struct pci_dev
*pdev
= dev_priv
->drm
.pdev
;
333 static const uint8_t div_3200
[] = { 16, 10, 8 };
334 static const uint8_t div_4000
[] = { 20, 12, 10 };
335 static const uint8_t div_5333
[] = { 24, 16, 14 };
336 const uint8_t *div_table
;
337 unsigned int cdclk_sel
;
340 cdclk_state
->vco
= intel_hpll_vco(dev_priv
);
342 pci_read_config_word(pdev
, GCFGC
, &tmp
);
344 cdclk_sel
= ((tmp
>> 8) & 0x1f) - 1;
346 if (cdclk_sel
>= ARRAY_SIZE(div_3200
))
349 switch (cdclk_state
->vco
) {
351 div_table
= div_3200
;
354 div_table
= div_4000
;
357 div_table
= div_5333
;
363 cdclk_state
->cdclk
= DIV_ROUND_CLOSEST(cdclk_state
->vco
,
364 div_table
[cdclk_sel
]);
368 DRM_ERROR("Unable to determine CDCLK. HPLL VCO=%u kHz, CFGC=0x%04x\n",
369 cdclk_state
->vco
, tmp
);
370 cdclk_state
->cdclk
= 200000;
373 static void gm45_get_cdclk(struct drm_i915_private
*dev_priv
,
374 struct intel_cdclk_state
*cdclk_state
)
376 struct pci_dev
*pdev
= dev_priv
->drm
.pdev
;
377 unsigned int cdclk_sel
;
380 cdclk_state
->vco
= intel_hpll_vco(dev_priv
);
382 pci_read_config_word(pdev
, GCFGC
, &tmp
);
384 cdclk_sel
= (tmp
>> 12) & 0x1;
386 switch (cdclk_state
->vco
) {
390 cdclk_state
->cdclk
= cdclk_sel
? 333333 : 222222;
393 cdclk_state
->cdclk
= cdclk_sel
? 320000 : 228571;
396 DRM_ERROR("Unable to determine CDCLK. HPLL VCO=%u, CFGC=0x%04x\n",
397 cdclk_state
->vco
, tmp
);
398 cdclk_state
->cdclk
= 222222;
403 static void hsw_get_cdclk(struct drm_i915_private
*dev_priv
,
404 struct intel_cdclk_state
*cdclk_state
)
406 uint32_t lcpll
= I915_READ(LCPLL_CTL
);
407 uint32_t freq
= lcpll
& LCPLL_CLK_FREQ_MASK
;
409 if (lcpll
& LCPLL_CD_SOURCE_FCLK
)
410 cdclk_state
->cdclk
= 800000;
411 else if (I915_READ(FUSE_STRAP
) & HSW_CDCLK_LIMIT
)
412 cdclk_state
->cdclk
= 450000;
413 else if (freq
== LCPLL_CLK_FREQ_450
)
414 cdclk_state
->cdclk
= 450000;
415 else if (IS_HSW_ULT(dev_priv
))
416 cdclk_state
->cdclk
= 337500;
418 cdclk_state
->cdclk
= 540000;
421 static int vlv_calc_cdclk(struct drm_i915_private
*dev_priv
, int min_cdclk
)
423 int freq_320
= (dev_priv
->hpll_freq
<< 1) % 320000 != 0 ?
427 * We seem to get an unstable or solid color picture at 200MHz.
428 * Not sure what's wrong. For now use 200MHz only when all pipes
431 if (IS_VALLEYVIEW(dev_priv
) && min_cdclk
> freq_320
)
433 else if (min_cdclk
> 266667)
435 else if (min_cdclk
> 0)
441 static u8
vlv_calc_voltage_level(struct drm_i915_private
*dev_priv
, int cdclk
)
443 if (IS_VALLEYVIEW(dev_priv
)) {
444 if (cdclk
>= 320000) /* jump to highest voltage for 400MHz too */
446 else if (cdclk
>= 266667)
452 * Specs are full of misinformation, but testing on actual
453 * hardware has shown that we just need to write the desired
454 * CCK divider into the Punit register.
456 return DIV_ROUND_CLOSEST(dev_priv
->hpll_freq
<< 1, cdclk
) - 1;
460 static void vlv_get_cdclk(struct drm_i915_private
*dev_priv
,
461 struct intel_cdclk_state
*cdclk_state
)
465 cdclk_state
->vco
= vlv_get_hpll_vco(dev_priv
);
466 cdclk_state
->cdclk
= vlv_get_cck_clock(dev_priv
, "cdclk",
467 CCK_DISPLAY_CLOCK_CONTROL
,
470 mutex_lock(&dev_priv
->pcu_lock
);
471 val
= vlv_punit_read(dev_priv
, PUNIT_REG_DSPFREQ
);
472 mutex_unlock(&dev_priv
->pcu_lock
);
474 if (IS_VALLEYVIEW(dev_priv
))
475 cdclk_state
->voltage_level
= (val
& DSPFREQGUAR_MASK
) >>
478 cdclk_state
->voltage_level
= (val
& DSPFREQGUAR_MASK_CHV
) >>
479 DSPFREQGUAR_SHIFT_CHV
;
482 static void vlv_program_pfi_credits(struct drm_i915_private
*dev_priv
)
484 unsigned int credits
, default_credits
;
486 if (IS_CHERRYVIEW(dev_priv
))
487 default_credits
= PFI_CREDIT(12);
489 default_credits
= PFI_CREDIT(8);
491 if (dev_priv
->cdclk
.hw
.cdclk
>= dev_priv
->czclk_freq
) {
492 /* CHV suggested value is 31 or 63 */
493 if (IS_CHERRYVIEW(dev_priv
))
494 credits
= PFI_CREDIT_63
;
496 credits
= PFI_CREDIT(15);
498 credits
= default_credits
;
502 * WA - write default credits before re-programming
503 * FIXME: should we also set the resend bit here?
505 I915_WRITE(GCI_CONTROL
, VGA_FAST_MODE_DISABLE
|
508 I915_WRITE(GCI_CONTROL
, VGA_FAST_MODE_DISABLE
|
509 credits
| PFI_CREDIT_RESEND
);
512 * FIXME is this guaranteed to clear
513 * immediately or should we poll for it?
515 WARN_ON(I915_READ(GCI_CONTROL
) & PFI_CREDIT_RESEND
);
518 static void vlv_set_cdclk(struct drm_i915_private
*dev_priv
,
519 const struct intel_cdclk_state
*cdclk_state
)
521 int cdclk
= cdclk_state
->cdclk
;
522 u32 val
, cmd
= cdclk_state
->voltage_level
;
536 /* There are cases where we can end up here with power domains
537 * off and a CDCLK frequency other than the minimum, like when
538 * issuing a modeset without actually changing any display after
539 * a system suspend. So grab the PIPE-A domain, which covers
540 * the HW blocks needed for the following programming.
542 intel_display_power_get(dev_priv
, POWER_DOMAIN_PIPE_A
);
544 mutex_lock(&dev_priv
->pcu_lock
);
545 val
= vlv_punit_read(dev_priv
, PUNIT_REG_DSPFREQ
);
546 val
&= ~DSPFREQGUAR_MASK
;
547 val
|= (cmd
<< DSPFREQGUAR_SHIFT
);
548 vlv_punit_write(dev_priv
, PUNIT_REG_DSPFREQ
, val
);
549 if (wait_for((vlv_punit_read(dev_priv
, PUNIT_REG_DSPFREQ
) &
550 DSPFREQSTAT_MASK
) == (cmd
<< DSPFREQSTAT_SHIFT
),
552 DRM_ERROR("timed out waiting for CDclk change\n");
554 mutex_unlock(&dev_priv
->pcu_lock
);
556 mutex_lock(&dev_priv
->sb_lock
);
558 if (cdclk
== 400000) {
561 divider
= DIV_ROUND_CLOSEST(dev_priv
->hpll_freq
<< 1,
564 /* adjust cdclk divider */
565 val
= vlv_cck_read(dev_priv
, CCK_DISPLAY_CLOCK_CONTROL
);
566 val
&= ~CCK_FREQUENCY_VALUES
;
568 vlv_cck_write(dev_priv
, CCK_DISPLAY_CLOCK_CONTROL
, val
);
570 if (wait_for((vlv_cck_read(dev_priv
, CCK_DISPLAY_CLOCK_CONTROL
) &
571 CCK_FREQUENCY_STATUS
) == (divider
<< CCK_FREQUENCY_STATUS_SHIFT
),
573 DRM_ERROR("timed out waiting for CDclk change\n");
576 /* adjust self-refresh exit latency value */
577 val
= vlv_bunit_read(dev_priv
, BUNIT_REG_BISOC
);
581 * For high bandwidth configs, we set a higher latency in the bunit
582 * so that the core display fetch happens in time to avoid underruns.
585 val
|= 4500 / 250; /* 4.5 usec */
587 val
|= 3000 / 250; /* 3.0 usec */
588 vlv_bunit_write(dev_priv
, BUNIT_REG_BISOC
, val
);
590 mutex_unlock(&dev_priv
->sb_lock
);
592 intel_update_cdclk(dev_priv
);
594 vlv_program_pfi_credits(dev_priv
);
596 intel_display_power_put(dev_priv
, POWER_DOMAIN_PIPE_A
);
599 static void chv_set_cdclk(struct drm_i915_private
*dev_priv
,
600 const struct intel_cdclk_state
*cdclk_state
)
602 int cdclk
= cdclk_state
->cdclk
;
603 u32 val
, cmd
= cdclk_state
->voltage_level
;
616 /* There are cases where we can end up here with power domains
617 * off and a CDCLK frequency other than the minimum, like when
618 * issuing a modeset without actually changing any display after
619 * a system suspend. So grab the PIPE-A domain, which covers
620 * the HW blocks needed for the following programming.
622 intel_display_power_get(dev_priv
, POWER_DOMAIN_PIPE_A
);
624 mutex_lock(&dev_priv
->pcu_lock
);
625 val
= vlv_punit_read(dev_priv
, PUNIT_REG_DSPFREQ
);
626 val
&= ~DSPFREQGUAR_MASK_CHV
;
627 val
|= (cmd
<< DSPFREQGUAR_SHIFT_CHV
);
628 vlv_punit_write(dev_priv
, PUNIT_REG_DSPFREQ
, val
);
629 if (wait_for((vlv_punit_read(dev_priv
, PUNIT_REG_DSPFREQ
) &
630 DSPFREQSTAT_MASK_CHV
) == (cmd
<< DSPFREQSTAT_SHIFT_CHV
),
632 DRM_ERROR("timed out waiting for CDclk change\n");
634 mutex_unlock(&dev_priv
->pcu_lock
);
636 intel_update_cdclk(dev_priv
);
638 vlv_program_pfi_credits(dev_priv
);
640 intel_display_power_put(dev_priv
, POWER_DOMAIN_PIPE_A
);
643 static int bdw_calc_cdclk(int min_cdclk
)
645 if (min_cdclk
> 540000)
647 else if (min_cdclk
> 450000)
649 else if (min_cdclk
> 337500)
655 static u8
bdw_calc_voltage_level(int cdclk
)
670 static void bdw_get_cdclk(struct drm_i915_private
*dev_priv
,
671 struct intel_cdclk_state
*cdclk_state
)
673 uint32_t lcpll
= I915_READ(LCPLL_CTL
);
674 uint32_t freq
= lcpll
& LCPLL_CLK_FREQ_MASK
;
676 if (lcpll
& LCPLL_CD_SOURCE_FCLK
)
677 cdclk_state
->cdclk
= 800000;
678 else if (I915_READ(FUSE_STRAP
) & HSW_CDCLK_LIMIT
)
679 cdclk_state
->cdclk
= 450000;
680 else if (freq
== LCPLL_CLK_FREQ_450
)
681 cdclk_state
->cdclk
= 450000;
682 else if (freq
== LCPLL_CLK_FREQ_54O_BDW
)
683 cdclk_state
->cdclk
= 540000;
684 else if (freq
== LCPLL_CLK_FREQ_337_5_BDW
)
685 cdclk_state
->cdclk
= 337500;
687 cdclk_state
->cdclk
= 675000;
690 * Can't read this out :( Let's assume it's
691 * at least what the CDCLK frequency requires.
693 cdclk_state
->voltage_level
=
694 bdw_calc_voltage_level(cdclk_state
->cdclk
);
697 static void bdw_set_cdclk(struct drm_i915_private
*dev_priv
,
698 const struct intel_cdclk_state
*cdclk_state
)
700 int cdclk
= cdclk_state
->cdclk
;
704 if (WARN((I915_READ(LCPLL_CTL
) &
705 (LCPLL_PLL_DISABLE
| LCPLL_PLL_LOCK
|
706 LCPLL_CD_CLOCK_DISABLE
| LCPLL_ROOT_CD_CLOCK_DISABLE
|
707 LCPLL_CD2X_CLOCK_DISABLE
| LCPLL_POWER_DOWN_ALLOW
|
708 LCPLL_CD_SOURCE_FCLK
)) != LCPLL_PLL_LOCK
,
709 "trying to change cdclk frequency with cdclk not enabled\n"))
712 mutex_lock(&dev_priv
->pcu_lock
);
713 ret
= sandybridge_pcode_write(dev_priv
,
714 BDW_PCODE_DISPLAY_FREQ_CHANGE_REQ
, 0x0);
715 mutex_unlock(&dev_priv
->pcu_lock
);
717 DRM_ERROR("failed to inform pcode about cdclk change\n");
721 val
= I915_READ(LCPLL_CTL
);
722 val
|= LCPLL_CD_SOURCE_FCLK
;
723 I915_WRITE(LCPLL_CTL
, val
);
726 * According to the spec, it should be enough to poll for this 1 us.
727 * However, extensive testing shows that this can take longer.
729 if (wait_for_us(I915_READ(LCPLL_CTL
) &
730 LCPLL_CD_SOURCE_FCLK_DONE
, 100))
731 DRM_ERROR("Switching to FCLK failed\n");
733 val
= I915_READ(LCPLL_CTL
);
734 val
&= ~LCPLL_CLK_FREQ_MASK
;
741 val
|= LCPLL_CLK_FREQ_337_5_BDW
;
744 val
|= LCPLL_CLK_FREQ_450
;
747 val
|= LCPLL_CLK_FREQ_54O_BDW
;
750 val
|= LCPLL_CLK_FREQ_675_BDW
;
754 I915_WRITE(LCPLL_CTL
, val
);
756 val
= I915_READ(LCPLL_CTL
);
757 val
&= ~LCPLL_CD_SOURCE_FCLK
;
758 I915_WRITE(LCPLL_CTL
, val
);
760 if (wait_for_us((I915_READ(LCPLL_CTL
) &
761 LCPLL_CD_SOURCE_FCLK_DONE
) == 0, 1))
762 DRM_ERROR("Switching back to LCPLL failed\n");
764 mutex_lock(&dev_priv
->pcu_lock
);
765 sandybridge_pcode_write(dev_priv
, HSW_PCODE_DE_WRITE_FREQ_REQ
,
766 cdclk_state
->voltage_level
);
767 mutex_unlock(&dev_priv
->pcu_lock
);
769 I915_WRITE(CDCLK_FREQ
, DIV_ROUND_CLOSEST(cdclk
, 1000) - 1);
771 intel_update_cdclk(dev_priv
);
774 static int skl_calc_cdclk(int min_cdclk
, int vco
)
776 if (vco
== 8640000) {
777 if (min_cdclk
> 540000)
779 else if (min_cdclk
> 432000)
781 else if (min_cdclk
> 308571)
786 if (min_cdclk
> 540000)
788 else if (min_cdclk
> 450000)
790 else if (min_cdclk
> 337500)
797 static u8
skl_calc_voltage_level(int cdclk
)
815 static void skl_dpll0_update(struct drm_i915_private
*dev_priv
,
816 struct intel_cdclk_state
*cdclk_state
)
820 cdclk_state
->ref
= 24000;
821 cdclk_state
->vco
= 0;
823 val
= I915_READ(LCPLL1_CTL
);
824 if ((val
& LCPLL_PLL_ENABLE
) == 0)
827 if (WARN_ON((val
& LCPLL_PLL_LOCK
) == 0))
830 val
= I915_READ(DPLL_CTRL1
);
832 if (WARN_ON((val
& (DPLL_CTRL1_HDMI_MODE(SKL_DPLL0
) |
833 DPLL_CTRL1_SSC(SKL_DPLL0
) |
834 DPLL_CTRL1_OVERRIDE(SKL_DPLL0
))) !=
835 DPLL_CTRL1_OVERRIDE(SKL_DPLL0
)))
838 switch (val
& DPLL_CTRL1_LINK_RATE_MASK(SKL_DPLL0
)) {
839 case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_810
, SKL_DPLL0
):
840 case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1350
, SKL_DPLL0
):
841 case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1620
, SKL_DPLL0
):
842 case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2700
, SKL_DPLL0
):
843 cdclk_state
->vco
= 8100000;
845 case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1080
, SKL_DPLL0
):
846 case DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2160
, SKL_DPLL0
):
847 cdclk_state
->vco
= 8640000;
850 MISSING_CASE(val
& DPLL_CTRL1_LINK_RATE_MASK(SKL_DPLL0
));
855 static void skl_get_cdclk(struct drm_i915_private
*dev_priv
,
856 struct intel_cdclk_state
*cdclk_state
)
860 skl_dpll0_update(dev_priv
, cdclk_state
);
862 cdclk_state
->cdclk
= cdclk_state
->bypass
= cdclk_state
->ref
;
864 if (cdclk_state
->vco
== 0)
867 cdctl
= I915_READ(CDCLK_CTL
);
869 if (cdclk_state
->vco
== 8640000) {
870 switch (cdctl
& CDCLK_FREQ_SEL_MASK
) {
871 case CDCLK_FREQ_450_432
:
872 cdclk_state
->cdclk
= 432000;
874 case CDCLK_FREQ_337_308
:
875 cdclk_state
->cdclk
= 308571;
878 cdclk_state
->cdclk
= 540000;
880 case CDCLK_FREQ_675_617
:
881 cdclk_state
->cdclk
= 617143;
884 MISSING_CASE(cdctl
& CDCLK_FREQ_SEL_MASK
);
888 switch (cdctl
& CDCLK_FREQ_SEL_MASK
) {
889 case CDCLK_FREQ_450_432
:
890 cdclk_state
->cdclk
= 450000;
892 case CDCLK_FREQ_337_308
:
893 cdclk_state
->cdclk
= 337500;
896 cdclk_state
->cdclk
= 540000;
898 case CDCLK_FREQ_675_617
:
899 cdclk_state
->cdclk
= 675000;
902 MISSING_CASE(cdctl
& CDCLK_FREQ_SEL_MASK
);
909 * Can't read this out :( Let's assume it's
910 * at least what the CDCLK frequency requires.
912 cdclk_state
->voltage_level
=
913 skl_calc_voltage_level(cdclk_state
->cdclk
);
916 /* convert from kHz to .1 fixpoint MHz with -1MHz offset */
917 static int skl_cdclk_decimal(int cdclk
)
919 return DIV_ROUND_CLOSEST(cdclk
- 1000, 500);
922 static void skl_set_preferred_cdclk_vco(struct drm_i915_private
*dev_priv
,
925 bool changed
= dev_priv
->skl_preferred_vco_freq
!= vco
;
927 dev_priv
->skl_preferred_vco_freq
= vco
;
930 intel_update_max_cdclk(dev_priv
);
933 static void skl_dpll0_enable(struct drm_i915_private
*dev_priv
, int vco
)
937 WARN_ON(vco
!= 8100000 && vco
!= 8640000);
940 * We always enable DPLL0 with the lowest link rate possible, but still
941 * taking into account the VCO required to operate the eDP panel at the
942 * desired frequency. The usual DP link rates operate with a VCO of
943 * 8100 while the eDP 1.4 alternate link rates need a VCO of 8640.
944 * The modeset code is responsible for the selection of the exact link
945 * rate later on, with the constraint of choosing a frequency that
948 val
= I915_READ(DPLL_CTRL1
);
950 val
&= ~(DPLL_CTRL1_HDMI_MODE(SKL_DPLL0
) | DPLL_CTRL1_SSC(SKL_DPLL0
) |
951 DPLL_CTRL1_LINK_RATE_MASK(SKL_DPLL0
));
952 val
|= DPLL_CTRL1_OVERRIDE(SKL_DPLL0
);
954 val
|= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1080
,
957 val
|= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_810
,
960 I915_WRITE(DPLL_CTRL1
, val
);
961 POSTING_READ(DPLL_CTRL1
);
963 I915_WRITE(LCPLL1_CTL
, I915_READ(LCPLL1_CTL
) | LCPLL_PLL_ENABLE
);
965 if (intel_wait_for_register(dev_priv
,
966 LCPLL1_CTL
, LCPLL_PLL_LOCK
, LCPLL_PLL_LOCK
,
968 DRM_ERROR("DPLL0 not locked\n");
970 dev_priv
->cdclk
.hw
.vco
= vco
;
972 /* We'll want to keep using the current vco from now on. */
973 skl_set_preferred_cdclk_vco(dev_priv
, vco
);
976 static void skl_dpll0_disable(struct drm_i915_private
*dev_priv
)
978 I915_WRITE(LCPLL1_CTL
, I915_READ(LCPLL1_CTL
) & ~LCPLL_PLL_ENABLE
);
979 if (intel_wait_for_register(dev_priv
,
980 LCPLL1_CTL
, LCPLL_PLL_LOCK
, 0,
982 DRM_ERROR("Couldn't disable DPLL0\n");
984 dev_priv
->cdclk
.hw
.vco
= 0;
987 static void skl_set_cdclk(struct drm_i915_private
*dev_priv
,
988 const struct intel_cdclk_state
*cdclk_state
)
990 int cdclk
= cdclk_state
->cdclk
;
991 int vco
= cdclk_state
->vco
;
992 u32 freq_select
, cdclk_ctl
;
996 * Based on WA#1183 CDCLK rates 308 and 617MHz CDCLK rates are
997 * unsupported on SKL. In theory this should never happen since only
998 * the eDP1.4 2.16 and 4.32Gbps rates require it, but eDP1.4 is not
999 * supported on SKL either, see the above WA. WARN whenever trying to
1000 * use the corresponding VCO freq as that always leads to using the
1001 * minimum 308MHz CDCLK.
1003 WARN_ON_ONCE(IS_SKYLAKE(dev_priv
) && vco
== 8640000);
1005 mutex_lock(&dev_priv
->pcu_lock
);
1006 ret
= skl_pcode_request(dev_priv
, SKL_PCODE_CDCLK_CONTROL
,
1007 SKL_CDCLK_PREPARE_FOR_CHANGE
,
1008 SKL_CDCLK_READY_FOR_CHANGE
,
1009 SKL_CDCLK_READY_FOR_CHANGE
, 3);
1010 mutex_unlock(&dev_priv
->pcu_lock
);
1012 DRM_ERROR("Failed to inform PCU about cdclk change (%d)\n",
1017 /* Choose frequency for this cdclk */
1020 WARN_ON(cdclk
!= dev_priv
->cdclk
.hw
.bypass
);
1025 freq_select
= CDCLK_FREQ_337_308
;
1029 freq_select
= CDCLK_FREQ_450_432
;
1032 freq_select
= CDCLK_FREQ_540
;
1036 freq_select
= CDCLK_FREQ_675_617
;
1040 if (dev_priv
->cdclk
.hw
.vco
!= 0 &&
1041 dev_priv
->cdclk
.hw
.vco
!= vco
)
1042 skl_dpll0_disable(dev_priv
);
1044 cdclk_ctl
= I915_READ(CDCLK_CTL
);
1046 if (dev_priv
->cdclk
.hw
.vco
!= vco
) {
1047 /* Wa Display #1183: skl,kbl,cfl */
1048 cdclk_ctl
&= ~(CDCLK_FREQ_SEL_MASK
| CDCLK_FREQ_DECIMAL_MASK
);
1049 cdclk_ctl
|= freq_select
| skl_cdclk_decimal(cdclk
);
1050 I915_WRITE(CDCLK_CTL
, cdclk_ctl
);
1053 /* Wa Display #1183: skl,kbl,cfl */
1054 cdclk_ctl
|= CDCLK_DIVMUX_CD_OVERRIDE
;
1055 I915_WRITE(CDCLK_CTL
, cdclk_ctl
);
1056 POSTING_READ(CDCLK_CTL
);
1058 if (dev_priv
->cdclk
.hw
.vco
!= vco
)
1059 skl_dpll0_enable(dev_priv
, vco
);
1061 /* Wa Display #1183: skl,kbl,cfl */
1062 cdclk_ctl
&= ~(CDCLK_FREQ_SEL_MASK
| CDCLK_FREQ_DECIMAL_MASK
);
1063 I915_WRITE(CDCLK_CTL
, cdclk_ctl
);
1065 cdclk_ctl
|= freq_select
| skl_cdclk_decimal(cdclk
);
1066 I915_WRITE(CDCLK_CTL
, cdclk_ctl
);
1068 /* Wa Display #1183: skl,kbl,cfl */
1069 cdclk_ctl
&= ~CDCLK_DIVMUX_CD_OVERRIDE
;
1070 I915_WRITE(CDCLK_CTL
, cdclk_ctl
);
1071 POSTING_READ(CDCLK_CTL
);
1073 /* inform PCU of the change */
1074 mutex_lock(&dev_priv
->pcu_lock
);
1075 sandybridge_pcode_write(dev_priv
, SKL_PCODE_CDCLK_CONTROL
,
1076 cdclk_state
->voltage_level
);
1077 mutex_unlock(&dev_priv
->pcu_lock
);
1079 intel_update_cdclk(dev_priv
);
1082 static void skl_sanitize_cdclk(struct drm_i915_private
*dev_priv
)
1084 uint32_t cdctl
, expected
;
1087 * check if the pre-os initialized the display
1088 * There is SWF18 scratchpad register defined which is set by the
1089 * pre-os which can be used by the OS drivers to check the status
1091 if ((I915_READ(SWF_ILK(0x18)) & 0x00FFFFFF) == 0)
1094 intel_update_cdclk(dev_priv
);
1095 intel_dump_cdclk_state(&dev_priv
->cdclk
.hw
, "Current CDCLK");
1097 /* Is PLL enabled and locked ? */
1098 if (dev_priv
->cdclk
.hw
.vco
== 0 ||
1099 dev_priv
->cdclk
.hw
.cdclk
== dev_priv
->cdclk
.hw
.bypass
)
1102 /* DPLL okay; verify the cdclock
1104 * Noticed in some instances that the freq selection is correct but
1105 * decimal part is programmed wrong from BIOS where pre-os does not
1106 * enable display. Verify the same as well.
1108 cdctl
= I915_READ(CDCLK_CTL
);
1109 expected
= (cdctl
& CDCLK_FREQ_SEL_MASK
) |
1110 skl_cdclk_decimal(dev_priv
->cdclk
.hw
.cdclk
);
1111 if (cdctl
== expected
)
1112 /* All well; nothing to sanitize */
1116 DRM_DEBUG_KMS("Sanitizing cdclk programmed by pre-os\n");
1118 /* force cdclk programming */
1119 dev_priv
->cdclk
.hw
.cdclk
= 0;
1120 /* force full PLL disable + enable */
1121 dev_priv
->cdclk
.hw
.vco
= -1;
1125 * skl_init_cdclk - Initialize CDCLK on SKL
1126 * @dev_priv: i915 device
1128 * Initialize CDCLK for SKL and derivatives. This is generally
1129 * done only during the display core initialization sequence,
1130 * after which the DMC will take care of turning CDCLK off/on
1133 void skl_init_cdclk(struct drm_i915_private
*dev_priv
)
1135 struct intel_cdclk_state cdclk_state
;
1137 skl_sanitize_cdclk(dev_priv
);
1139 if (dev_priv
->cdclk
.hw
.cdclk
!= 0 &&
1140 dev_priv
->cdclk
.hw
.vco
!= 0) {
1142 * Use the current vco as our initial
1143 * guess as to what the preferred vco is.
1145 if (dev_priv
->skl_preferred_vco_freq
== 0)
1146 skl_set_preferred_cdclk_vco(dev_priv
,
1147 dev_priv
->cdclk
.hw
.vco
);
1151 cdclk_state
= dev_priv
->cdclk
.hw
;
1153 cdclk_state
.vco
= dev_priv
->skl_preferred_vco_freq
;
1154 if (cdclk_state
.vco
== 0)
1155 cdclk_state
.vco
= 8100000;
1156 cdclk_state
.cdclk
= skl_calc_cdclk(0, cdclk_state
.vco
);
1157 cdclk_state
.voltage_level
= skl_calc_voltage_level(cdclk_state
.cdclk
);
1159 skl_set_cdclk(dev_priv
, &cdclk_state
);
1163 * skl_uninit_cdclk - Uninitialize CDCLK on SKL
1164 * @dev_priv: i915 device
1166 * Uninitialize CDCLK for SKL and derivatives. This is done only
1167 * during the display core uninitialization sequence.
1169 void skl_uninit_cdclk(struct drm_i915_private
*dev_priv
)
1171 struct intel_cdclk_state cdclk_state
= dev_priv
->cdclk
.hw
;
1173 cdclk_state
.cdclk
= cdclk_state
.bypass
;
1174 cdclk_state
.vco
= 0;
1175 cdclk_state
.voltage_level
= skl_calc_voltage_level(cdclk_state
.cdclk
);
1177 skl_set_cdclk(dev_priv
, &cdclk_state
);
1180 static int bxt_calc_cdclk(int min_cdclk
)
1182 if (min_cdclk
> 576000)
1184 else if (min_cdclk
> 384000)
1186 else if (min_cdclk
> 288000)
1188 else if (min_cdclk
> 144000)
1194 static int glk_calc_cdclk(int min_cdclk
)
1196 if (min_cdclk
> 158400)
1198 else if (min_cdclk
> 79200)
1204 static u8
bxt_calc_voltage_level(int cdclk
)
1206 return DIV_ROUND_UP(cdclk
, 25000);
1209 static int bxt_de_pll_vco(struct drm_i915_private
*dev_priv
, int cdclk
)
1213 if (cdclk
== dev_priv
->cdclk
.hw
.bypass
)
1218 MISSING_CASE(cdclk
);
1231 return dev_priv
->cdclk
.hw
.ref
* ratio
;
1234 static int glk_de_pll_vco(struct drm_i915_private
*dev_priv
, int cdclk
)
1238 if (cdclk
== dev_priv
->cdclk
.hw
.bypass
)
1243 MISSING_CASE(cdclk
);
1252 return dev_priv
->cdclk
.hw
.ref
* ratio
;
1255 static void bxt_de_pll_update(struct drm_i915_private
*dev_priv
,
1256 struct intel_cdclk_state
*cdclk_state
)
1260 cdclk_state
->ref
= 19200;
1261 cdclk_state
->vco
= 0;
1263 val
= I915_READ(BXT_DE_PLL_ENABLE
);
1264 if ((val
& BXT_DE_PLL_PLL_ENABLE
) == 0)
1267 if (WARN_ON((val
& BXT_DE_PLL_LOCK
) == 0))
1270 val
= I915_READ(BXT_DE_PLL_CTL
);
1271 cdclk_state
->vco
= (val
& BXT_DE_PLL_RATIO_MASK
) * cdclk_state
->ref
;
1274 static void bxt_get_cdclk(struct drm_i915_private
*dev_priv
,
1275 struct intel_cdclk_state
*cdclk_state
)
1280 bxt_de_pll_update(dev_priv
, cdclk_state
);
1282 cdclk_state
->cdclk
= cdclk_state
->bypass
= cdclk_state
->ref
;
1284 if (cdclk_state
->vco
== 0)
1287 divider
= I915_READ(CDCLK_CTL
) & BXT_CDCLK_CD2X_DIV_SEL_MASK
;
1290 case BXT_CDCLK_CD2X_DIV_SEL_1
:
1293 case BXT_CDCLK_CD2X_DIV_SEL_1_5
:
1294 WARN(IS_GEMINILAKE(dev_priv
), "Unsupported divider\n");
1297 case BXT_CDCLK_CD2X_DIV_SEL_2
:
1300 case BXT_CDCLK_CD2X_DIV_SEL_4
:
1304 MISSING_CASE(divider
);
1308 cdclk_state
->cdclk
= DIV_ROUND_CLOSEST(cdclk_state
->vco
, div
);
1312 * Can't read this out :( Let's assume it's
1313 * at least what the CDCLK frequency requires.
1315 cdclk_state
->voltage_level
=
1316 bxt_calc_voltage_level(cdclk_state
->cdclk
);
1319 static void bxt_de_pll_disable(struct drm_i915_private
*dev_priv
)
1321 I915_WRITE(BXT_DE_PLL_ENABLE
, 0);
1324 if (intel_wait_for_register(dev_priv
,
1325 BXT_DE_PLL_ENABLE
, BXT_DE_PLL_LOCK
, 0,
1327 DRM_ERROR("timeout waiting for DE PLL unlock\n");
1329 dev_priv
->cdclk
.hw
.vco
= 0;
1332 static void bxt_de_pll_enable(struct drm_i915_private
*dev_priv
, int vco
)
1334 int ratio
= DIV_ROUND_CLOSEST(vco
, dev_priv
->cdclk
.hw
.ref
);
1337 val
= I915_READ(BXT_DE_PLL_CTL
);
1338 val
&= ~BXT_DE_PLL_RATIO_MASK
;
1339 val
|= BXT_DE_PLL_RATIO(ratio
);
1340 I915_WRITE(BXT_DE_PLL_CTL
, val
);
1342 I915_WRITE(BXT_DE_PLL_ENABLE
, BXT_DE_PLL_PLL_ENABLE
);
1345 if (intel_wait_for_register(dev_priv
,
1350 DRM_ERROR("timeout waiting for DE PLL lock\n");
1352 dev_priv
->cdclk
.hw
.vco
= vco
;
1355 static void bxt_set_cdclk(struct drm_i915_private
*dev_priv
,
1356 const struct intel_cdclk_state
*cdclk_state
)
1358 int cdclk
= cdclk_state
->cdclk
;
1359 int vco
= cdclk_state
->vco
;
1363 /* cdclk = vco / 2 / div{1,1.5,2,4} */
1364 switch (DIV_ROUND_CLOSEST(vco
, cdclk
)) {
1366 WARN_ON(cdclk
!= dev_priv
->cdclk
.hw
.bypass
);
1370 divider
= BXT_CDCLK_CD2X_DIV_SEL_1
;
1373 WARN(IS_GEMINILAKE(dev_priv
), "Unsupported divider\n");
1374 divider
= BXT_CDCLK_CD2X_DIV_SEL_1_5
;
1377 divider
= BXT_CDCLK_CD2X_DIV_SEL_2
;
1380 divider
= BXT_CDCLK_CD2X_DIV_SEL_4
;
1385 * Inform power controller of upcoming frequency change. BSpec
1386 * requires us to wait up to 150usec, but that leads to timeouts;
1387 * the 2ms used here is based on experiment.
1389 mutex_lock(&dev_priv
->pcu_lock
);
1390 ret
= sandybridge_pcode_write_timeout(dev_priv
,
1391 HSW_PCODE_DE_WRITE_FREQ_REQ
,
1392 0x80000000, 150, 2);
1393 mutex_unlock(&dev_priv
->pcu_lock
);
1396 DRM_ERROR("PCode CDCLK freq change notify failed (err %d, freq %d)\n",
1401 if (dev_priv
->cdclk
.hw
.vco
!= 0 &&
1402 dev_priv
->cdclk
.hw
.vco
!= vco
)
1403 bxt_de_pll_disable(dev_priv
);
1405 if (dev_priv
->cdclk
.hw
.vco
!= vco
)
1406 bxt_de_pll_enable(dev_priv
, vco
);
1408 val
= divider
| skl_cdclk_decimal(cdclk
);
1410 * FIXME if only the cd2x divider needs changing, it could be done
1411 * without shutting off the pipe (if only one pipe is active).
1413 val
|= BXT_CDCLK_CD2X_PIPE_NONE
;
1415 * Disable SSA Precharge when CD clock frequency < 500 MHz,
1418 if (cdclk
>= 500000)
1419 val
|= BXT_CDCLK_SSA_PRECHARGE_ENABLE
;
1420 I915_WRITE(CDCLK_CTL
, val
);
1422 mutex_lock(&dev_priv
->pcu_lock
);
1424 * The timeout isn't specified, the 2ms used here is based on
1426 * FIXME: Waiting for the request completion could be delayed until
1427 * the next PCODE request based on BSpec.
1429 ret
= sandybridge_pcode_write_timeout(dev_priv
,
1430 HSW_PCODE_DE_WRITE_FREQ_REQ
,
1431 cdclk_state
->voltage_level
, 150, 2);
1432 mutex_unlock(&dev_priv
->pcu_lock
);
1435 DRM_ERROR("PCode CDCLK freq set failed, (err %d, freq %d)\n",
1440 intel_update_cdclk(dev_priv
);
1443 static void bxt_sanitize_cdclk(struct drm_i915_private
*dev_priv
)
1445 u32 cdctl
, expected
;
1447 intel_update_cdclk(dev_priv
);
1448 intel_dump_cdclk_state(&dev_priv
->cdclk
.hw
, "Current CDCLK");
1450 if (dev_priv
->cdclk
.hw
.vco
== 0 ||
1451 dev_priv
->cdclk
.hw
.cdclk
== dev_priv
->cdclk
.hw
.bypass
)
1454 /* DPLL okay; verify the cdclock
1456 * Some BIOS versions leave an incorrect decimal frequency value and
1457 * set reserved MBZ bits in CDCLK_CTL at least during exiting from S4,
1458 * so sanitize this register.
1460 cdctl
= I915_READ(CDCLK_CTL
);
1462 * Let's ignore the pipe field, since BIOS could have configured the
1463 * dividers both synching to an active pipe, or asynchronously
1466 cdctl
&= ~BXT_CDCLK_CD2X_PIPE_NONE
;
1468 expected
= (cdctl
& BXT_CDCLK_CD2X_DIV_SEL_MASK
) |
1469 skl_cdclk_decimal(dev_priv
->cdclk
.hw
.cdclk
);
1471 * Disable SSA Precharge when CD clock frequency < 500 MHz,
1474 if (dev_priv
->cdclk
.hw
.cdclk
>= 500000)
1475 expected
|= BXT_CDCLK_SSA_PRECHARGE_ENABLE
;
1477 if (cdctl
== expected
)
1478 /* All well; nothing to sanitize */
1482 DRM_DEBUG_KMS("Sanitizing cdclk programmed by pre-os\n");
1484 /* force cdclk programming */
1485 dev_priv
->cdclk
.hw
.cdclk
= 0;
1487 /* force full PLL disable + enable */
1488 dev_priv
->cdclk
.hw
.vco
= -1;
1492 * bxt_init_cdclk - Initialize CDCLK on BXT
1493 * @dev_priv: i915 device
1495 * Initialize CDCLK for BXT and derivatives. This is generally
1496 * done only during the display core initialization sequence,
1497 * after which the DMC will take care of turning CDCLK off/on
1500 void bxt_init_cdclk(struct drm_i915_private
*dev_priv
)
1502 struct intel_cdclk_state cdclk_state
;
1504 bxt_sanitize_cdclk(dev_priv
);
1506 if (dev_priv
->cdclk
.hw
.cdclk
!= 0 &&
1507 dev_priv
->cdclk
.hw
.vco
!= 0)
1510 cdclk_state
= dev_priv
->cdclk
.hw
;
1514 * - The initial CDCLK needs to be read from VBT.
1515 * Need to make this change after VBT has changes for BXT.
1517 if (IS_GEMINILAKE(dev_priv
)) {
1518 cdclk_state
.cdclk
= glk_calc_cdclk(0);
1519 cdclk_state
.vco
= glk_de_pll_vco(dev_priv
, cdclk_state
.cdclk
);
1521 cdclk_state
.cdclk
= bxt_calc_cdclk(0);
1522 cdclk_state
.vco
= bxt_de_pll_vco(dev_priv
, cdclk_state
.cdclk
);
1524 cdclk_state
.voltage_level
= bxt_calc_voltage_level(cdclk_state
.cdclk
);
1526 bxt_set_cdclk(dev_priv
, &cdclk_state
);
1530 * bxt_uninit_cdclk - Uninitialize CDCLK on BXT
1531 * @dev_priv: i915 device
1533 * Uninitialize CDCLK for BXT and derivatives. This is done only
1534 * during the display core uninitialization sequence.
1536 void bxt_uninit_cdclk(struct drm_i915_private
*dev_priv
)
1538 struct intel_cdclk_state cdclk_state
= dev_priv
->cdclk
.hw
;
1540 cdclk_state
.cdclk
= cdclk_state
.bypass
;
1541 cdclk_state
.vco
= 0;
1542 cdclk_state
.voltage_level
= bxt_calc_voltage_level(cdclk_state
.cdclk
);
1544 bxt_set_cdclk(dev_priv
, &cdclk_state
);
1547 static int cnl_calc_cdclk(int min_cdclk
)
1549 if (min_cdclk
> 336000)
1551 else if (min_cdclk
> 168000)
1557 static u8
cnl_calc_voltage_level(int cdclk
)
1570 static void cnl_cdclk_pll_update(struct drm_i915_private
*dev_priv
,
1571 struct intel_cdclk_state
*cdclk_state
)
1575 if (I915_READ(SKL_DSSM
) & CNL_DSSM_CDCLK_PLL_REFCLK_24MHz
)
1576 cdclk_state
->ref
= 24000;
1578 cdclk_state
->ref
= 19200;
1580 cdclk_state
->vco
= 0;
1582 val
= I915_READ(BXT_DE_PLL_ENABLE
);
1583 if ((val
& BXT_DE_PLL_PLL_ENABLE
) == 0)
1586 if (WARN_ON((val
& BXT_DE_PLL_LOCK
) == 0))
1589 cdclk_state
->vco
= (val
& CNL_CDCLK_PLL_RATIO_MASK
) * cdclk_state
->ref
;
1592 static void cnl_get_cdclk(struct drm_i915_private
*dev_priv
,
1593 struct intel_cdclk_state
*cdclk_state
)
1598 cnl_cdclk_pll_update(dev_priv
, cdclk_state
);
1600 cdclk_state
->cdclk
= cdclk_state
->bypass
= cdclk_state
->ref
;
1602 if (cdclk_state
->vco
== 0)
1605 divider
= I915_READ(CDCLK_CTL
) & BXT_CDCLK_CD2X_DIV_SEL_MASK
;
1608 case BXT_CDCLK_CD2X_DIV_SEL_1
:
1611 case BXT_CDCLK_CD2X_DIV_SEL_2
:
1615 MISSING_CASE(divider
);
1619 cdclk_state
->cdclk
= DIV_ROUND_CLOSEST(cdclk_state
->vco
, div
);
1623 * Can't read this out :( Let's assume it's
1624 * at least what the CDCLK frequency requires.
1626 cdclk_state
->voltage_level
=
1627 cnl_calc_voltage_level(cdclk_state
->cdclk
);
1630 static void cnl_cdclk_pll_disable(struct drm_i915_private
*dev_priv
)
1634 val
= I915_READ(BXT_DE_PLL_ENABLE
);
1635 val
&= ~BXT_DE_PLL_PLL_ENABLE
;
1636 I915_WRITE(BXT_DE_PLL_ENABLE
, val
);
1639 if (wait_for((I915_READ(BXT_DE_PLL_ENABLE
) & BXT_DE_PLL_LOCK
) == 0, 1))
1640 DRM_ERROR("timeout waiting for CDCLK PLL unlock\n");
1642 dev_priv
->cdclk
.hw
.vco
= 0;
1645 static void cnl_cdclk_pll_enable(struct drm_i915_private
*dev_priv
, int vco
)
1647 int ratio
= DIV_ROUND_CLOSEST(vco
, dev_priv
->cdclk
.hw
.ref
);
1650 val
= CNL_CDCLK_PLL_RATIO(ratio
);
1651 I915_WRITE(BXT_DE_PLL_ENABLE
, val
);
1653 val
|= BXT_DE_PLL_PLL_ENABLE
;
1654 I915_WRITE(BXT_DE_PLL_ENABLE
, val
);
1657 if (wait_for((I915_READ(BXT_DE_PLL_ENABLE
) & BXT_DE_PLL_LOCK
) != 0, 1))
1658 DRM_ERROR("timeout waiting for CDCLK PLL lock\n");
1660 dev_priv
->cdclk
.hw
.vco
= vco
;
1663 static void cnl_set_cdclk(struct drm_i915_private
*dev_priv
,
1664 const struct intel_cdclk_state
*cdclk_state
)
1666 int cdclk
= cdclk_state
->cdclk
;
1667 int vco
= cdclk_state
->vco
;
1671 mutex_lock(&dev_priv
->pcu_lock
);
1672 ret
= skl_pcode_request(dev_priv
, SKL_PCODE_CDCLK_CONTROL
,
1673 SKL_CDCLK_PREPARE_FOR_CHANGE
,
1674 SKL_CDCLK_READY_FOR_CHANGE
,
1675 SKL_CDCLK_READY_FOR_CHANGE
, 3);
1676 mutex_unlock(&dev_priv
->pcu_lock
);
1678 DRM_ERROR("Failed to inform PCU about cdclk change (%d)\n",
1683 /* cdclk = vco / 2 / div{1,2} */
1684 switch (DIV_ROUND_CLOSEST(vco
, cdclk
)) {
1686 WARN_ON(cdclk
!= dev_priv
->cdclk
.hw
.bypass
);
1690 divider
= BXT_CDCLK_CD2X_DIV_SEL_1
;
1693 divider
= BXT_CDCLK_CD2X_DIV_SEL_2
;
1697 if (dev_priv
->cdclk
.hw
.vco
!= 0 &&
1698 dev_priv
->cdclk
.hw
.vco
!= vco
)
1699 cnl_cdclk_pll_disable(dev_priv
);
1701 if (dev_priv
->cdclk
.hw
.vco
!= vco
)
1702 cnl_cdclk_pll_enable(dev_priv
, vco
);
1704 val
= divider
| skl_cdclk_decimal(cdclk
);
1706 * FIXME if only the cd2x divider needs changing, it could be done
1707 * without shutting off the pipe (if only one pipe is active).
1709 val
|= BXT_CDCLK_CD2X_PIPE_NONE
;
1710 I915_WRITE(CDCLK_CTL
, val
);
1712 /* inform PCU of the change */
1713 mutex_lock(&dev_priv
->pcu_lock
);
1714 sandybridge_pcode_write(dev_priv
, SKL_PCODE_CDCLK_CONTROL
,
1715 cdclk_state
->voltage_level
);
1716 mutex_unlock(&dev_priv
->pcu_lock
);
1718 intel_update_cdclk(dev_priv
);
1721 * Can't read out the voltage level :(
1722 * Let's just assume everything is as expected.
1724 dev_priv
->cdclk
.hw
.voltage_level
= cdclk_state
->voltage_level
;
1727 static int cnl_cdclk_pll_vco(struct drm_i915_private
*dev_priv
, int cdclk
)
1731 if (cdclk
== dev_priv
->cdclk
.hw
.bypass
)
1736 MISSING_CASE(cdclk
);
1740 ratio
= dev_priv
->cdclk
.hw
.ref
== 19200 ? 35 : 28;
1743 ratio
= dev_priv
->cdclk
.hw
.ref
== 19200 ? 55 : 44;
1747 return dev_priv
->cdclk
.hw
.ref
* ratio
;
1750 static void cnl_sanitize_cdclk(struct drm_i915_private
*dev_priv
)
1752 u32 cdctl
, expected
;
1754 intel_update_cdclk(dev_priv
);
1755 intel_dump_cdclk_state(&dev_priv
->cdclk
.hw
, "Current CDCLK");
1757 if (dev_priv
->cdclk
.hw
.vco
== 0 ||
1758 dev_priv
->cdclk
.hw
.cdclk
== dev_priv
->cdclk
.hw
.bypass
)
1761 /* DPLL okay; verify the cdclock
1763 * Some BIOS versions leave an incorrect decimal frequency value and
1764 * set reserved MBZ bits in CDCLK_CTL at least during exiting from S4,
1765 * so sanitize this register.
1767 cdctl
= I915_READ(CDCLK_CTL
);
1769 * Let's ignore the pipe field, since BIOS could have configured the
1770 * dividers both synching to an active pipe, or asynchronously
1773 cdctl
&= ~BXT_CDCLK_CD2X_PIPE_NONE
;
1775 expected
= (cdctl
& BXT_CDCLK_CD2X_DIV_SEL_MASK
) |
1776 skl_cdclk_decimal(dev_priv
->cdclk
.hw
.cdclk
);
1778 if (cdctl
== expected
)
1779 /* All well; nothing to sanitize */
1783 DRM_DEBUG_KMS("Sanitizing cdclk programmed by pre-os\n");
1785 /* force cdclk programming */
1786 dev_priv
->cdclk
.hw
.cdclk
= 0;
1788 /* force full PLL disable + enable */
1789 dev_priv
->cdclk
.hw
.vco
= -1;
1792 static int icl_calc_cdclk(int min_cdclk
, unsigned int ref
)
1794 int ranges_24
[] = { 312000, 552000, 648000 };
1795 int ranges_19_38
[] = { 307200, 556800, 652800 };
1807 ranges
= ranges_19_38
;
1811 if (min_cdclk
> ranges
[1])
1813 else if (min_cdclk
> ranges
[0])
1819 static int icl_calc_cdclk_pll_vco(struct drm_i915_private
*dev_priv
, int cdclk
)
1823 if (cdclk
== dev_priv
->cdclk
.hw
.bypass
)
1828 MISSING_CASE(cdclk
);
1833 WARN_ON(dev_priv
->cdclk
.hw
.ref
!= 19200 &&
1834 dev_priv
->cdclk
.hw
.ref
!= 38400);
1839 WARN_ON(dev_priv
->cdclk
.hw
.ref
!= 24000);
1842 ratio
= cdclk
/ (dev_priv
->cdclk
.hw
.ref
/ 2);
1844 return dev_priv
->cdclk
.hw
.ref
* ratio
;
1847 static void icl_set_cdclk(struct drm_i915_private
*dev_priv
,
1848 const struct intel_cdclk_state
*cdclk_state
)
1850 unsigned int cdclk
= cdclk_state
->cdclk
;
1851 unsigned int vco
= cdclk_state
->vco
;
1854 mutex_lock(&dev_priv
->pcu_lock
);
1855 ret
= skl_pcode_request(dev_priv
, SKL_PCODE_CDCLK_CONTROL
,
1856 SKL_CDCLK_PREPARE_FOR_CHANGE
,
1857 SKL_CDCLK_READY_FOR_CHANGE
,
1858 SKL_CDCLK_READY_FOR_CHANGE
, 3);
1859 mutex_unlock(&dev_priv
->pcu_lock
);
1861 DRM_ERROR("Failed to inform PCU about cdclk change (%d)\n",
1866 if (dev_priv
->cdclk
.hw
.vco
!= 0 &&
1867 dev_priv
->cdclk
.hw
.vco
!= vco
)
1868 cnl_cdclk_pll_disable(dev_priv
);
1870 if (dev_priv
->cdclk
.hw
.vco
!= vco
)
1871 cnl_cdclk_pll_enable(dev_priv
, vco
);
1873 I915_WRITE(CDCLK_CTL
, ICL_CDCLK_CD2X_PIPE_NONE
|
1874 skl_cdclk_decimal(cdclk
));
1876 mutex_lock(&dev_priv
->pcu_lock
);
1877 sandybridge_pcode_write(dev_priv
, SKL_PCODE_CDCLK_CONTROL
,
1878 cdclk_state
->voltage_level
);
1879 mutex_unlock(&dev_priv
->pcu_lock
);
1881 intel_update_cdclk(dev_priv
);
1884 * Can't read out the voltage level :(
1885 * Let's just assume everything is as expected.
1887 dev_priv
->cdclk
.hw
.voltage_level
= cdclk_state
->voltage_level
;
1890 static u8
icl_calc_voltage_level(int cdclk
)
1901 MISSING_CASE(cdclk
);
1909 static void icl_get_cdclk(struct drm_i915_private
*dev_priv
,
1910 struct intel_cdclk_state
*cdclk_state
)
1914 cdclk_state
->bypass
= 50000;
1916 val
= I915_READ(SKL_DSSM
);
1917 switch (val
& ICL_DSSM_CDCLK_PLL_REFCLK_MASK
) {
1921 case ICL_DSSM_CDCLK_PLL_REFCLK_24MHz
:
1922 cdclk_state
->ref
= 24000;
1924 case ICL_DSSM_CDCLK_PLL_REFCLK_19_2MHz
:
1925 cdclk_state
->ref
= 19200;
1927 case ICL_DSSM_CDCLK_PLL_REFCLK_38_4MHz
:
1928 cdclk_state
->ref
= 38400;
1932 val
= I915_READ(BXT_DE_PLL_ENABLE
);
1933 if ((val
& BXT_DE_PLL_PLL_ENABLE
) == 0 ||
1934 (val
& BXT_DE_PLL_LOCK
) == 0) {
1936 * CDCLK PLL is disabled, the VCO/ratio doesn't matter, but
1937 * setting it to zero is a way to signal that.
1939 cdclk_state
->vco
= 0;
1940 cdclk_state
->cdclk
= cdclk_state
->bypass
;
1944 cdclk_state
->vco
= (val
& BXT_DE_PLL_RATIO_MASK
) * cdclk_state
->ref
;
1946 val
= I915_READ(CDCLK_CTL
);
1947 WARN_ON((val
& BXT_CDCLK_CD2X_DIV_SEL_MASK
) != 0);
1949 cdclk_state
->cdclk
= cdclk_state
->vco
/ 2;
1953 * Can't read this out :( Let's assume it's
1954 * at least what the CDCLK frequency requires.
1956 cdclk_state
->voltage_level
=
1957 icl_calc_voltage_level(cdclk_state
->cdclk
);
1961 * icl_init_cdclk - Initialize CDCLK on ICL
1962 * @dev_priv: i915 device
1964 * Initialize CDCLK for ICL. This consists mainly of initializing
1965 * dev_priv->cdclk.hw and sanitizing the state of the hardware if needed. This
1966 * is generally done only during the display core initialization sequence, after
1967 * which the DMC will take care of turning CDCLK off/on as needed.
1969 void icl_init_cdclk(struct drm_i915_private
*dev_priv
)
1971 struct intel_cdclk_state sanitized_state
;
1974 /* This sets dev_priv->cdclk.hw. */
1975 intel_update_cdclk(dev_priv
);
1976 intel_dump_cdclk_state(&dev_priv
->cdclk
.hw
, "Current CDCLK");
1978 /* This means CDCLK disabled. */
1979 if (dev_priv
->cdclk
.hw
.cdclk
== dev_priv
->cdclk
.hw
.bypass
)
1982 val
= I915_READ(CDCLK_CTL
);
1984 if ((val
& BXT_CDCLK_CD2X_DIV_SEL_MASK
) != 0)
1987 if ((val
& CDCLK_FREQ_DECIMAL_MASK
) !=
1988 skl_cdclk_decimal(dev_priv
->cdclk
.hw
.cdclk
))
1994 DRM_DEBUG_KMS("Sanitizing cdclk programmed by pre-os\n");
1996 sanitized_state
.ref
= dev_priv
->cdclk
.hw
.ref
;
1997 sanitized_state
.cdclk
= icl_calc_cdclk(0, sanitized_state
.ref
);
1998 sanitized_state
.vco
= icl_calc_cdclk_pll_vco(dev_priv
,
1999 sanitized_state
.cdclk
);
2000 sanitized_state
.voltage_level
=
2001 icl_calc_voltage_level(sanitized_state
.cdclk
);
2003 icl_set_cdclk(dev_priv
, &sanitized_state
);
2007 * icl_uninit_cdclk - Uninitialize CDCLK on ICL
2008 * @dev_priv: i915 device
2010 * Uninitialize CDCLK for ICL. This is done only during the display core
2011 * uninitialization sequence.
2013 void icl_uninit_cdclk(struct drm_i915_private
*dev_priv
)
2015 struct intel_cdclk_state cdclk_state
= dev_priv
->cdclk
.hw
;
2017 cdclk_state
.cdclk
= cdclk_state
.bypass
;
2018 cdclk_state
.vco
= 0;
2019 cdclk_state
.voltage_level
= icl_calc_voltage_level(cdclk_state
.cdclk
);
2021 icl_set_cdclk(dev_priv
, &cdclk_state
);
2025 * cnl_init_cdclk - Initialize CDCLK on CNL
2026 * @dev_priv: i915 device
2028 * Initialize CDCLK for CNL. This is generally
2029 * done only during the display core initialization sequence,
2030 * after which the DMC will take care of turning CDCLK off/on
2033 void cnl_init_cdclk(struct drm_i915_private
*dev_priv
)
2035 struct intel_cdclk_state cdclk_state
;
2037 cnl_sanitize_cdclk(dev_priv
);
2039 if (dev_priv
->cdclk
.hw
.cdclk
!= 0 &&
2040 dev_priv
->cdclk
.hw
.vco
!= 0)
2043 cdclk_state
= dev_priv
->cdclk
.hw
;
2045 cdclk_state
.cdclk
= cnl_calc_cdclk(0);
2046 cdclk_state
.vco
= cnl_cdclk_pll_vco(dev_priv
, cdclk_state
.cdclk
);
2047 cdclk_state
.voltage_level
= cnl_calc_voltage_level(cdclk_state
.cdclk
);
2049 cnl_set_cdclk(dev_priv
, &cdclk_state
);
2053 * cnl_uninit_cdclk - Uninitialize CDCLK on CNL
2054 * @dev_priv: i915 device
2056 * Uninitialize CDCLK for CNL. This is done only
2057 * during the display core uninitialization sequence.
2059 void cnl_uninit_cdclk(struct drm_i915_private
*dev_priv
)
2061 struct intel_cdclk_state cdclk_state
= dev_priv
->cdclk
.hw
;
2063 cdclk_state
.cdclk
= cdclk_state
.bypass
;
2064 cdclk_state
.vco
= 0;
2065 cdclk_state
.voltage_level
= cnl_calc_voltage_level(cdclk_state
.cdclk
);
2067 cnl_set_cdclk(dev_priv
, &cdclk_state
);
2071 * intel_cdclk_needs_modeset - Determine if two CDCLK states require a modeset on all pipes
2072 * @a: first CDCLK state
2073 * @b: second CDCLK state
2076 * True if the CDCLK states require pipes to be off during reprogramming, false if not.
2078 bool intel_cdclk_needs_modeset(const struct intel_cdclk_state
*a
,
2079 const struct intel_cdclk_state
*b
)
2081 return a
->cdclk
!= b
->cdclk
||
2087 * intel_cdclk_changed - Determine if two CDCLK states are different
2088 * @a: first CDCLK state
2089 * @b: second CDCLK state
2092 * True if the CDCLK states don't match, false if they do.
2094 bool intel_cdclk_changed(const struct intel_cdclk_state
*a
,
2095 const struct intel_cdclk_state
*b
)
2097 return intel_cdclk_needs_modeset(a
, b
) ||
2098 a
->voltage_level
!= b
->voltage_level
;
2101 void intel_dump_cdclk_state(const struct intel_cdclk_state
*cdclk_state
,
2102 const char *context
)
2104 DRM_DEBUG_DRIVER("%s %d kHz, VCO %d kHz, ref %d kHz, bypass %d kHz, voltage level %d\n",
2105 context
, cdclk_state
->cdclk
, cdclk_state
->vco
,
2106 cdclk_state
->ref
, cdclk_state
->bypass
,
2107 cdclk_state
->voltage_level
);
2111 * intel_set_cdclk - Push the CDCLK state to the hardware
2112 * @dev_priv: i915 device
2113 * @cdclk_state: new CDCLK state
2115 * Program the hardware based on the passed in CDCLK state,
2118 void intel_set_cdclk(struct drm_i915_private
*dev_priv
,
2119 const struct intel_cdclk_state
*cdclk_state
)
2121 if (!intel_cdclk_changed(&dev_priv
->cdclk
.hw
, cdclk_state
))
2124 if (WARN_ON_ONCE(!dev_priv
->display
.set_cdclk
))
2127 intel_dump_cdclk_state(cdclk_state
, "Changing CDCLK to");
2129 dev_priv
->display
.set_cdclk(dev_priv
, cdclk_state
);
2131 if (WARN(intel_cdclk_changed(&dev_priv
->cdclk
.hw
, cdclk_state
),
2132 "cdclk state doesn't match!\n")) {
2133 intel_dump_cdclk_state(&dev_priv
->cdclk
.hw
, "[hw state]");
2134 intel_dump_cdclk_state(cdclk_state
, "[sw state]");
2138 static int intel_pixel_rate_to_cdclk(struct drm_i915_private
*dev_priv
,
2141 if (INTEL_GEN(dev_priv
) >= 10)
2142 return DIV_ROUND_UP(pixel_rate
, 2);
2143 else if (IS_GEMINILAKE(dev_priv
))
2145 * FIXME: Avoid using a pixel clock that is more than 99% of the cdclk
2146 * as a temporary workaround. Use a higher cdclk instead. (Note that
2147 * intel_compute_max_dotclk() limits the max pixel clock to 99% of max
2150 return DIV_ROUND_UP(pixel_rate
* 100, 2 * 99);
2151 else if (IS_GEN9(dev_priv
) ||
2152 IS_BROADWELL(dev_priv
) || IS_HASWELL(dev_priv
))
2154 else if (IS_CHERRYVIEW(dev_priv
))
2155 return DIV_ROUND_UP(pixel_rate
* 100, 95);
2157 return DIV_ROUND_UP(pixel_rate
* 100, 90);
2160 int intel_crtc_compute_min_cdclk(const struct intel_crtc_state
*crtc_state
)
2162 struct drm_i915_private
*dev_priv
=
2163 to_i915(crtc_state
->base
.crtc
->dev
);
2166 if (!crtc_state
->base
.enable
)
2169 min_cdclk
= intel_pixel_rate_to_cdclk(dev_priv
, crtc_state
->pixel_rate
);
2171 /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
2172 if (IS_BROADWELL(dev_priv
) && hsw_crtc_state_ips_capable(crtc_state
))
2173 min_cdclk
= DIV_ROUND_UP(min_cdclk
* 100, 95);
2175 /* BSpec says "Do not use DisplayPort with CDCLK less than 432 MHz,
2176 * audio enabled, port width x4, and link rate HBR2 (5.4 GHz), or else
2177 * there may be audio corruption or screen corruption." This cdclk
2178 * restriction for GLK is 316.8 MHz.
2180 if (intel_crtc_has_dp_encoder(crtc_state
) &&
2181 crtc_state
->has_audio
&&
2182 crtc_state
->port_clock
>= 540000 &&
2183 crtc_state
->lane_count
== 4) {
2184 if (IS_CANNONLAKE(dev_priv
) || IS_GEMINILAKE(dev_priv
)) {
2185 /* Display WA #1145: glk,cnl */
2186 min_cdclk
= max(316800, min_cdclk
);
2187 } else if (IS_GEN9(dev_priv
) || IS_BROADWELL(dev_priv
)) {
2188 /* Display WA #1144: skl,bxt */
2189 min_cdclk
= max(432000, min_cdclk
);
2194 * According to BSpec, "The CD clock frequency must be at least twice
2195 * the frequency of the Azalia BCLK." and BCLK is 96 MHz by default.
2197 * FIXME: Check the actual, not default, BCLK being used.
2199 * FIXME: This does not depend on ->has_audio because the higher CDCLK
2200 * is required for audio probe, also when there are no audio capable
2201 * displays connected at probe time. This leads to unnecessarily high
2202 * CDCLK when audio is not required.
2204 * FIXME: This limit is only applied when there are displays connected
2205 * at probe time. If we probe without displays, we'll still end up using
2206 * the platform minimum CDCLK, failing audio probe.
2208 if (INTEL_GEN(dev_priv
) >= 9)
2209 min_cdclk
= max(2 * 96000, min_cdclk
);
2212 * "For DP audio configuration, cdclk frequency shall be set to
2213 * meet the following requirements:
2214 * DP Link Frequency(MHz) | Cdclk frequency(MHz)
2215 * 270 | 320 or higher
2216 * 162 | 200 or higher"
2218 if ((IS_VALLEYVIEW(dev_priv
) || IS_CHERRYVIEW(dev_priv
)) &&
2219 intel_crtc_has_dp_encoder(crtc_state
) && crtc_state
->has_audio
)
2220 min_cdclk
= max(crtc_state
->port_clock
, min_cdclk
);
2223 * On Valleyview some DSI panels lose (v|h)sync when the clock is lower
2226 if (intel_crtc_has_type(crtc_state
, INTEL_OUTPUT_DSI
) &&
2227 IS_VALLEYVIEW(dev_priv
))
2228 min_cdclk
= max(320000, min_cdclk
);
2230 if (min_cdclk
> dev_priv
->max_cdclk_freq
) {
2231 DRM_DEBUG_KMS("required cdclk (%d kHz) exceeds max (%d kHz)\n",
2232 min_cdclk
, dev_priv
->max_cdclk_freq
);
2239 static int intel_compute_min_cdclk(struct drm_atomic_state
*state
)
2241 struct intel_atomic_state
*intel_state
= to_intel_atomic_state(state
);
2242 struct drm_i915_private
*dev_priv
= to_i915(state
->dev
);
2243 struct intel_crtc
*crtc
;
2244 struct intel_crtc_state
*crtc_state
;
2248 memcpy(intel_state
->min_cdclk
, dev_priv
->min_cdclk
,
2249 sizeof(intel_state
->min_cdclk
));
2251 for_each_new_intel_crtc_in_state(intel_state
, crtc
, crtc_state
, i
) {
2252 min_cdclk
= intel_crtc_compute_min_cdclk(crtc_state
);
2256 intel_state
->min_cdclk
[i
] = min_cdclk
;
2260 for_each_pipe(dev_priv
, pipe
)
2261 min_cdclk
= max(intel_state
->min_cdclk
[pipe
], min_cdclk
);
2267 * Note that this functions assumes that 0 is
2268 * the lowest voltage value, and higher values
2269 * correspond to increasingly higher voltages.
2271 * Should that relationship no longer hold on
2272 * future platforms this code will need to be
2275 static u8
cnl_compute_min_voltage_level(struct intel_atomic_state
*state
)
2277 struct drm_i915_private
*dev_priv
= to_i915(state
->base
.dev
);
2278 struct intel_crtc
*crtc
;
2279 struct intel_crtc_state
*crtc_state
;
2280 u8 min_voltage_level
;
2284 memcpy(state
->min_voltage_level
, dev_priv
->min_voltage_level
,
2285 sizeof(state
->min_voltage_level
));
2287 for_each_new_intel_crtc_in_state(state
, crtc
, crtc_state
, i
) {
2288 if (crtc_state
->base
.enable
)
2289 state
->min_voltage_level
[i
] =
2290 crtc_state
->min_voltage_level
;
2292 state
->min_voltage_level
[i
] = 0;
2295 min_voltage_level
= 0;
2296 for_each_pipe(dev_priv
, pipe
)
2297 min_voltage_level
= max(state
->min_voltage_level
[pipe
],
2300 return min_voltage_level
;
2303 static int vlv_modeset_calc_cdclk(struct drm_atomic_state
*state
)
2305 struct drm_i915_private
*dev_priv
= to_i915(state
->dev
);
2306 struct intel_atomic_state
*intel_state
= to_intel_atomic_state(state
);
2307 int min_cdclk
, cdclk
;
2309 min_cdclk
= intel_compute_min_cdclk(state
);
2313 cdclk
= vlv_calc_cdclk(dev_priv
, min_cdclk
);
2315 intel_state
->cdclk
.logical
.cdclk
= cdclk
;
2316 intel_state
->cdclk
.logical
.voltage_level
=
2317 vlv_calc_voltage_level(dev_priv
, cdclk
);
2319 if (!intel_state
->active_crtcs
) {
2320 cdclk
= vlv_calc_cdclk(dev_priv
, 0);
2322 intel_state
->cdclk
.actual
.cdclk
= cdclk
;
2323 intel_state
->cdclk
.actual
.voltage_level
=
2324 vlv_calc_voltage_level(dev_priv
, cdclk
);
2326 intel_state
->cdclk
.actual
=
2327 intel_state
->cdclk
.logical
;
2333 static int bdw_modeset_calc_cdclk(struct drm_atomic_state
*state
)
2335 struct intel_atomic_state
*intel_state
= to_intel_atomic_state(state
);
2336 int min_cdclk
, cdclk
;
2338 min_cdclk
= intel_compute_min_cdclk(state
);
2343 * FIXME should also account for plane ratio
2344 * once 64bpp pixel formats are supported.
2346 cdclk
= bdw_calc_cdclk(min_cdclk
);
2348 intel_state
->cdclk
.logical
.cdclk
= cdclk
;
2349 intel_state
->cdclk
.logical
.voltage_level
=
2350 bdw_calc_voltage_level(cdclk
);
2352 if (!intel_state
->active_crtcs
) {
2353 cdclk
= bdw_calc_cdclk(0);
2355 intel_state
->cdclk
.actual
.cdclk
= cdclk
;
2356 intel_state
->cdclk
.actual
.voltage_level
=
2357 bdw_calc_voltage_level(cdclk
);
2359 intel_state
->cdclk
.actual
=
2360 intel_state
->cdclk
.logical
;
2366 static int skl_dpll0_vco(struct intel_atomic_state
*intel_state
)
2368 struct drm_i915_private
*dev_priv
= to_i915(intel_state
->base
.dev
);
2369 struct intel_crtc
*crtc
;
2370 struct intel_crtc_state
*crtc_state
;
2373 vco
= intel_state
->cdclk
.logical
.vco
;
2375 vco
= dev_priv
->skl_preferred_vco_freq
;
2377 for_each_new_intel_crtc_in_state(intel_state
, crtc
, crtc_state
, i
) {
2378 if (!crtc_state
->base
.enable
)
2381 if (!intel_crtc_has_type(crtc_state
, INTEL_OUTPUT_EDP
))
2385 * DPLL0 VCO may need to be adjusted to get the correct
2386 * clock for eDP. This will affect cdclk as well.
2388 switch (crtc_state
->port_clock
/ 2) {
2402 static int skl_modeset_calc_cdclk(struct drm_atomic_state
*state
)
2404 struct intel_atomic_state
*intel_state
= to_intel_atomic_state(state
);
2405 int min_cdclk
, cdclk
, vco
;
2407 min_cdclk
= intel_compute_min_cdclk(state
);
2411 vco
= skl_dpll0_vco(intel_state
);
2414 * FIXME should also account for plane ratio
2415 * once 64bpp pixel formats are supported.
2417 cdclk
= skl_calc_cdclk(min_cdclk
, vco
);
2419 intel_state
->cdclk
.logical
.vco
= vco
;
2420 intel_state
->cdclk
.logical
.cdclk
= cdclk
;
2421 intel_state
->cdclk
.logical
.voltage_level
=
2422 skl_calc_voltage_level(cdclk
);
2424 if (!intel_state
->active_crtcs
) {
2425 cdclk
= skl_calc_cdclk(0, vco
);
2427 intel_state
->cdclk
.actual
.vco
= vco
;
2428 intel_state
->cdclk
.actual
.cdclk
= cdclk
;
2429 intel_state
->cdclk
.actual
.voltage_level
=
2430 skl_calc_voltage_level(cdclk
);
2432 intel_state
->cdclk
.actual
=
2433 intel_state
->cdclk
.logical
;
2439 static int bxt_modeset_calc_cdclk(struct drm_atomic_state
*state
)
2441 struct drm_i915_private
*dev_priv
= to_i915(state
->dev
);
2442 struct intel_atomic_state
*intel_state
= to_intel_atomic_state(state
);
2443 int min_cdclk
, cdclk
, vco
;
2445 min_cdclk
= intel_compute_min_cdclk(state
);
2449 if (IS_GEMINILAKE(dev_priv
)) {
2450 cdclk
= glk_calc_cdclk(min_cdclk
);
2451 vco
= glk_de_pll_vco(dev_priv
, cdclk
);
2453 cdclk
= bxt_calc_cdclk(min_cdclk
);
2454 vco
= bxt_de_pll_vco(dev_priv
, cdclk
);
2457 intel_state
->cdclk
.logical
.vco
= vco
;
2458 intel_state
->cdclk
.logical
.cdclk
= cdclk
;
2459 intel_state
->cdclk
.logical
.voltage_level
=
2460 bxt_calc_voltage_level(cdclk
);
2462 if (!intel_state
->active_crtcs
) {
2463 if (IS_GEMINILAKE(dev_priv
)) {
2464 cdclk
= glk_calc_cdclk(0);
2465 vco
= glk_de_pll_vco(dev_priv
, cdclk
);
2467 cdclk
= bxt_calc_cdclk(0);
2468 vco
= bxt_de_pll_vco(dev_priv
, cdclk
);
2471 intel_state
->cdclk
.actual
.vco
= vco
;
2472 intel_state
->cdclk
.actual
.cdclk
= cdclk
;
2473 intel_state
->cdclk
.actual
.voltage_level
=
2474 bxt_calc_voltage_level(cdclk
);
2476 intel_state
->cdclk
.actual
=
2477 intel_state
->cdclk
.logical
;
2483 static int cnl_modeset_calc_cdclk(struct drm_atomic_state
*state
)
2485 struct drm_i915_private
*dev_priv
= to_i915(state
->dev
);
2486 struct intel_atomic_state
*intel_state
= to_intel_atomic_state(state
);
2487 int min_cdclk
, cdclk
, vco
;
2489 min_cdclk
= intel_compute_min_cdclk(state
);
2493 cdclk
= cnl_calc_cdclk(min_cdclk
);
2494 vco
= cnl_cdclk_pll_vco(dev_priv
, cdclk
);
2496 intel_state
->cdclk
.logical
.vco
= vco
;
2497 intel_state
->cdclk
.logical
.cdclk
= cdclk
;
2498 intel_state
->cdclk
.logical
.voltage_level
=
2499 max(cnl_calc_voltage_level(cdclk
),
2500 cnl_compute_min_voltage_level(intel_state
));
2502 if (!intel_state
->active_crtcs
) {
2503 cdclk
= cnl_calc_cdclk(0);
2504 vco
= cnl_cdclk_pll_vco(dev_priv
, cdclk
);
2506 intel_state
->cdclk
.actual
.vco
= vco
;
2507 intel_state
->cdclk
.actual
.cdclk
= cdclk
;
2508 intel_state
->cdclk
.actual
.voltage_level
=
2509 cnl_calc_voltage_level(cdclk
);
2511 intel_state
->cdclk
.actual
=
2512 intel_state
->cdclk
.logical
;
2518 static int icl_modeset_calc_cdclk(struct drm_atomic_state
*state
)
2520 struct drm_i915_private
*dev_priv
= to_i915(state
->dev
);
2521 struct intel_atomic_state
*intel_state
= to_intel_atomic_state(state
);
2522 unsigned int ref
= intel_state
->cdclk
.logical
.ref
;
2523 int min_cdclk
, cdclk
, vco
;
2525 min_cdclk
= intel_compute_min_cdclk(state
);
2529 cdclk
= icl_calc_cdclk(min_cdclk
, ref
);
2530 vco
= icl_calc_cdclk_pll_vco(dev_priv
, cdclk
);
2532 intel_state
->cdclk
.logical
.vco
= vco
;
2533 intel_state
->cdclk
.logical
.cdclk
= cdclk
;
2534 intel_state
->cdclk
.logical
.voltage_level
=
2535 max(icl_calc_voltage_level(cdclk
),
2536 cnl_compute_min_voltage_level(intel_state
));
2538 if (!intel_state
->active_crtcs
) {
2539 cdclk
= icl_calc_cdclk(0, ref
);
2540 vco
= icl_calc_cdclk_pll_vco(dev_priv
, cdclk
);
2542 intel_state
->cdclk
.actual
.vco
= vco
;
2543 intel_state
->cdclk
.actual
.cdclk
= cdclk
;
2544 intel_state
->cdclk
.actual
.voltage_level
=
2545 icl_calc_voltage_level(cdclk
);
2547 intel_state
->cdclk
.actual
= intel_state
->cdclk
.logical
;
2553 static int intel_compute_max_dotclk(struct drm_i915_private
*dev_priv
)
2555 int max_cdclk_freq
= dev_priv
->max_cdclk_freq
;
2557 if (INTEL_GEN(dev_priv
) >= 10)
2558 return 2 * max_cdclk_freq
;
2559 else if (IS_GEMINILAKE(dev_priv
))
2561 * FIXME: Limiting to 99% as a temporary workaround. See
2562 * intel_min_cdclk() for details.
2564 return 2 * max_cdclk_freq
* 99 / 100;
2565 else if (IS_GEN9(dev_priv
) ||
2566 IS_BROADWELL(dev_priv
) || IS_HASWELL(dev_priv
))
2567 return max_cdclk_freq
;
2568 else if (IS_CHERRYVIEW(dev_priv
))
2569 return max_cdclk_freq
*95/100;
2570 else if (INTEL_GEN(dev_priv
) < 4)
2571 return 2*max_cdclk_freq
*90/100;
2573 return max_cdclk_freq
*90/100;
2577 * intel_update_max_cdclk - Determine the maximum support CDCLK frequency
2578 * @dev_priv: i915 device
2580 * Determine the maximum CDCLK frequency the platform supports, and also
2581 * derive the maximum dot clock frequency the maximum CDCLK frequency
2584 void intel_update_max_cdclk(struct drm_i915_private
*dev_priv
)
2586 if (IS_ICELAKE(dev_priv
)) {
2587 if (dev_priv
->cdclk
.hw
.ref
== 24000)
2588 dev_priv
->max_cdclk_freq
= 648000;
2590 dev_priv
->max_cdclk_freq
= 652800;
2591 } else if (IS_CANNONLAKE(dev_priv
)) {
2592 dev_priv
->max_cdclk_freq
= 528000;
2593 } else if (IS_GEN9_BC(dev_priv
)) {
2594 u32 limit
= I915_READ(SKL_DFSM
) & SKL_DFSM_CDCLK_LIMIT_MASK
;
2597 vco
= dev_priv
->skl_preferred_vco_freq
;
2598 WARN_ON(vco
!= 8100000 && vco
!= 8640000);
2601 * Use the lower (vco 8640) cdclk values as a
2602 * first guess. skl_calc_cdclk() will correct it
2603 * if the preferred vco is 8100 instead.
2605 if (limit
== SKL_DFSM_CDCLK_LIMIT_675
)
2607 else if (limit
== SKL_DFSM_CDCLK_LIMIT_540
)
2609 else if (limit
== SKL_DFSM_CDCLK_LIMIT_450
)
2614 dev_priv
->max_cdclk_freq
= skl_calc_cdclk(max_cdclk
, vco
);
2615 } else if (IS_GEMINILAKE(dev_priv
)) {
2616 dev_priv
->max_cdclk_freq
= 316800;
2617 } else if (IS_BROXTON(dev_priv
)) {
2618 dev_priv
->max_cdclk_freq
= 624000;
2619 } else if (IS_BROADWELL(dev_priv
)) {
2621 * FIXME with extra cooling we can allow
2622 * 540 MHz for ULX and 675 Mhz for ULT.
2623 * How can we know if extra cooling is
2624 * available? PCI ID, VTB, something else?
2626 if (I915_READ(FUSE_STRAP
) & HSW_CDCLK_LIMIT
)
2627 dev_priv
->max_cdclk_freq
= 450000;
2628 else if (IS_BDW_ULX(dev_priv
))
2629 dev_priv
->max_cdclk_freq
= 450000;
2630 else if (IS_BDW_ULT(dev_priv
))
2631 dev_priv
->max_cdclk_freq
= 540000;
2633 dev_priv
->max_cdclk_freq
= 675000;
2634 } else if (IS_CHERRYVIEW(dev_priv
)) {
2635 dev_priv
->max_cdclk_freq
= 320000;
2636 } else if (IS_VALLEYVIEW(dev_priv
)) {
2637 dev_priv
->max_cdclk_freq
= 400000;
2639 /* otherwise assume cdclk is fixed */
2640 dev_priv
->max_cdclk_freq
= dev_priv
->cdclk
.hw
.cdclk
;
2643 dev_priv
->max_dotclk_freq
= intel_compute_max_dotclk(dev_priv
);
2645 DRM_DEBUG_DRIVER("Max CD clock rate: %d kHz\n",
2646 dev_priv
->max_cdclk_freq
);
2648 DRM_DEBUG_DRIVER("Max dotclock rate: %d kHz\n",
2649 dev_priv
->max_dotclk_freq
);
2653 * intel_update_cdclk - Determine the current CDCLK frequency
2654 * @dev_priv: i915 device
2656 * Determine the current CDCLK frequency.
2658 void intel_update_cdclk(struct drm_i915_private
*dev_priv
)
2660 dev_priv
->display
.get_cdclk(dev_priv
, &dev_priv
->cdclk
.hw
);
2663 * 9:0 CMBUS [sic] CDCLK frequency (cdfreq):
2664 * Programmng [sic] note: bit[9:2] should be programmed to the number
2665 * of cdclk that generates 4MHz reference clock freq which is used to
2666 * generate GMBus clock. This will vary with the cdclk freq.
2668 if (IS_VALLEYVIEW(dev_priv
) || IS_CHERRYVIEW(dev_priv
))
2669 I915_WRITE(GMBUSFREQ_VLV
,
2670 DIV_ROUND_UP(dev_priv
->cdclk
.hw
.cdclk
, 1000));
2673 static int cnp_rawclk(struct drm_i915_private
*dev_priv
)
2676 int divider
, fraction
;
2678 if (I915_READ(SFUSE_STRAP
) & SFUSE_STRAP_RAW_FREQUENCY
) {
2688 rawclk
= CNP_RAWCLK_DIV((divider
/ 1000) - 1);
2690 rawclk
|= CNP_RAWCLK_FRAC(DIV_ROUND_CLOSEST(1000,
2693 I915_WRITE(PCH_RAWCLK_FREQ
, rawclk
);
2694 return divider
+ fraction
;
2697 static int icp_rawclk(struct drm_i915_private
*dev_priv
)
2700 int divider
, numerator
, denominator
, frequency
;
2702 if (I915_READ(SFUSE_STRAP
) & SFUSE_STRAP_RAW_FREQUENCY
) {
2714 rawclk
= CNP_RAWCLK_DIV(divider
) | ICP_RAWCLK_NUM(numerator
) |
2715 ICP_RAWCLK_DEN(denominator
);
2717 I915_WRITE(PCH_RAWCLK_FREQ
, rawclk
);
2721 static int pch_rawclk(struct drm_i915_private
*dev_priv
)
2723 return (I915_READ(PCH_RAWCLK_FREQ
) & RAWCLK_FREQ_MASK
) * 1000;
2726 static int vlv_hrawclk(struct drm_i915_private
*dev_priv
)
2728 /* RAWCLK_FREQ_VLV register updated from power well code */
2729 return vlv_get_cck_clock_hpll(dev_priv
, "hrawclk",
2730 CCK_DISPLAY_REF_CLOCK_CONTROL
);
2733 static int g4x_hrawclk(struct drm_i915_private
*dev_priv
)
2737 /* hrawclock is 1/4 the FSB frequency */
2738 clkcfg
= I915_READ(CLKCFG
);
2739 switch (clkcfg
& CLKCFG_FSB_MASK
) {
2740 case CLKCFG_FSB_400
:
2742 case CLKCFG_FSB_533
:
2744 case CLKCFG_FSB_667
:
2746 case CLKCFG_FSB_800
:
2748 case CLKCFG_FSB_1067
:
2749 case CLKCFG_FSB_1067_ALT
:
2751 case CLKCFG_FSB_1333
:
2752 case CLKCFG_FSB_1333_ALT
:
2760 * intel_update_rawclk - Determine the current RAWCLK frequency
2761 * @dev_priv: i915 device
2763 * Determine the current RAWCLK frequency. RAWCLK is a fixed
2764 * frequency clock so this needs to done only once.
2766 void intel_update_rawclk(struct drm_i915_private
*dev_priv
)
2768 if (HAS_PCH_ICP(dev_priv
))
2769 dev_priv
->rawclk_freq
= icp_rawclk(dev_priv
);
2770 else if (HAS_PCH_CNP(dev_priv
))
2771 dev_priv
->rawclk_freq
= cnp_rawclk(dev_priv
);
2772 else if (HAS_PCH_SPLIT(dev_priv
))
2773 dev_priv
->rawclk_freq
= pch_rawclk(dev_priv
);
2774 else if (IS_VALLEYVIEW(dev_priv
) || IS_CHERRYVIEW(dev_priv
))
2775 dev_priv
->rawclk_freq
= vlv_hrawclk(dev_priv
);
2776 else if (IS_G4X(dev_priv
) || IS_PINEVIEW(dev_priv
))
2777 dev_priv
->rawclk_freq
= g4x_hrawclk(dev_priv
);
2779 /* no rawclk on other platforms, or no need to know it */
2782 DRM_DEBUG_DRIVER("rawclk rate: %d kHz\n", dev_priv
->rawclk_freq
);
2786 * intel_init_cdclk_hooks - Initialize CDCLK related modesetting hooks
2787 * @dev_priv: i915 device
2789 void intel_init_cdclk_hooks(struct drm_i915_private
*dev_priv
)
2791 if (IS_CHERRYVIEW(dev_priv
)) {
2792 dev_priv
->display
.set_cdclk
= chv_set_cdclk
;
2793 dev_priv
->display
.modeset_calc_cdclk
=
2794 vlv_modeset_calc_cdclk
;
2795 } else if (IS_VALLEYVIEW(dev_priv
)) {
2796 dev_priv
->display
.set_cdclk
= vlv_set_cdclk
;
2797 dev_priv
->display
.modeset_calc_cdclk
=
2798 vlv_modeset_calc_cdclk
;
2799 } else if (IS_BROADWELL(dev_priv
)) {
2800 dev_priv
->display
.set_cdclk
= bdw_set_cdclk
;
2801 dev_priv
->display
.modeset_calc_cdclk
=
2802 bdw_modeset_calc_cdclk
;
2803 } else if (IS_GEN9_LP(dev_priv
)) {
2804 dev_priv
->display
.set_cdclk
= bxt_set_cdclk
;
2805 dev_priv
->display
.modeset_calc_cdclk
=
2806 bxt_modeset_calc_cdclk
;
2807 } else if (IS_GEN9_BC(dev_priv
)) {
2808 dev_priv
->display
.set_cdclk
= skl_set_cdclk
;
2809 dev_priv
->display
.modeset_calc_cdclk
=
2810 skl_modeset_calc_cdclk
;
2811 } else if (IS_CANNONLAKE(dev_priv
)) {
2812 dev_priv
->display
.set_cdclk
= cnl_set_cdclk
;
2813 dev_priv
->display
.modeset_calc_cdclk
=
2814 cnl_modeset_calc_cdclk
;
2815 } else if (IS_ICELAKE(dev_priv
)) {
2816 dev_priv
->display
.set_cdclk
= icl_set_cdclk
;
2817 dev_priv
->display
.modeset_calc_cdclk
= icl_modeset_calc_cdclk
;
2820 if (IS_ICELAKE(dev_priv
))
2821 dev_priv
->display
.get_cdclk
= icl_get_cdclk
;
2822 else if (IS_CANNONLAKE(dev_priv
))
2823 dev_priv
->display
.get_cdclk
= cnl_get_cdclk
;
2824 else if (IS_GEN9_BC(dev_priv
))
2825 dev_priv
->display
.get_cdclk
= skl_get_cdclk
;
2826 else if (IS_GEN9_LP(dev_priv
))
2827 dev_priv
->display
.get_cdclk
= bxt_get_cdclk
;
2828 else if (IS_BROADWELL(dev_priv
))
2829 dev_priv
->display
.get_cdclk
= bdw_get_cdclk
;
2830 else if (IS_HASWELL(dev_priv
))
2831 dev_priv
->display
.get_cdclk
= hsw_get_cdclk
;
2832 else if (IS_VALLEYVIEW(dev_priv
) || IS_CHERRYVIEW(dev_priv
))
2833 dev_priv
->display
.get_cdclk
= vlv_get_cdclk
;
2834 else if (IS_GEN6(dev_priv
) || IS_IVYBRIDGE(dev_priv
))
2835 dev_priv
->display
.get_cdclk
= fixed_400mhz_get_cdclk
;
2836 else if (IS_GEN5(dev_priv
))
2837 dev_priv
->display
.get_cdclk
= fixed_450mhz_get_cdclk
;
2838 else if (IS_GM45(dev_priv
))
2839 dev_priv
->display
.get_cdclk
= gm45_get_cdclk
;
2840 else if (IS_G45(dev_priv
))
2841 dev_priv
->display
.get_cdclk
= g33_get_cdclk
;
2842 else if (IS_I965GM(dev_priv
))
2843 dev_priv
->display
.get_cdclk
= i965gm_get_cdclk
;
2844 else if (IS_I965G(dev_priv
))
2845 dev_priv
->display
.get_cdclk
= fixed_400mhz_get_cdclk
;
2846 else if (IS_PINEVIEW(dev_priv
))
2847 dev_priv
->display
.get_cdclk
= pnv_get_cdclk
;
2848 else if (IS_G33(dev_priv
))
2849 dev_priv
->display
.get_cdclk
= g33_get_cdclk
;
2850 else if (IS_I945GM(dev_priv
))
2851 dev_priv
->display
.get_cdclk
= i945gm_get_cdclk
;
2852 else if (IS_I945G(dev_priv
))
2853 dev_priv
->display
.get_cdclk
= fixed_400mhz_get_cdclk
;
2854 else if (IS_I915GM(dev_priv
))
2855 dev_priv
->display
.get_cdclk
= i915gm_get_cdclk
;
2856 else if (IS_I915G(dev_priv
))
2857 dev_priv
->display
.get_cdclk
= fixed_333mhz_get_cdclk
;
2858 else if (IS_I865G(dev_priv
))
2859 dev_priv
->display
.get_cdclk
= fixed_266mhz_get_cdclk
;
2860 else if (IS_I85X(dev_priv
))
2861 dev_priv
->display
.get_cdclk
= i85x_get_cdclk
;
2862 else if (IS_I845G(dev_priv
))
2863 dev_priv
->display
.get_cdclk
= fixed_200mhz_get_cdclk
;
2865 WARN(!IS_I830(dev_priv
),
2866 "Unknown platform. Assuming 133 MHz CDCLK\n");
2867 dev_priv
->display
.get_cdclk
= fixed_133mhz_get_cdclk
;