1 // SPDX-License-Identifier: MIT
3 * Copyright © 2020 Intel Corporation
5 #include <linux/kernel.h>
6 #include "intel_crtc.h"
8 #include "intel_display_types.h"
9 #include "intel_display.h"
10 #include "intel_dpll.h"
11 #include "intel_lvds.h"
12 #include "intel_panel.h"
13 #include "intel_sideband.h"
14 #include "display/intel_snps_phy.h"
19 } dot, vco, n, m, m1, m2, p, p1;
26 static const struct intel_limit intel_limits_i8xx_dac = {
27 .dot = { .min = 25000, .max = 350000 },
28 .vco = { .min = 908000, .max = 1512000 },
29 .n = { .min = 2, .max = 16 },
30 .m = { .min = 96, .max = 140 },
31 .m1 = { .min = 18, .max = 26 },
32 .m2 = { .min = 6, .max = 16 },
33 .p = { .min = 4, .max = 128 },
34 .p1 = { .min = 2, .max = 33 },
35 .p2 = { .dot_limit = 165000,
36 .p2_slow = 4, .p2_fast = 2 },
39 static const struct intel_limit intel_limits_i8xx_dvo = {
40 .dot = { .min = 25000, .max = 350000 },
41 .vco = { .min = 908000, .max = 1512000 },
42 .n = { .min = 2, .max = 16 },
43 .m = { .min = 96, .max = 140 },
44 .m1 = { .min = 18, .max = 26 },
45 .m2 = { .min = 6, .max = 16 },
46 .p = { .min = 4, .max = 128 },
47 .p1 = { .min = 2, .max = 33 },
48 .p2 = { .dot_limit = 165000,
49 .p2_slow = 4, .p2_fast = 4 },
52 static const struct intel_limit intel_limits_i8xx_lvds = {
53 .dot = { .min = 25000, .max = 350000 },
54 .vco = { .min = 908000, .max = 1512000 },
55 .n = { .min = 2, .max = 16 },
56 .m = { .min = 96, .max = 140 },
57 .m1 = { .min = 18, .max = 26 },
58 .m2 = { .min = 6, .max = 16 },
59 .p = { .min = 4, .max = 128 },
60 .p1 = { .min = 1, .max = 6 },
61 .p2 = { .dot_limit = 165000,
62 .p2_slow = 14, .p2_fast = 7 },
65 static const struct intel_limit intel_limits_i9xx_sdvo = {
66 .dot = { .min = 20000, .max = 400000 },
67 .vco = { .min = 1400000, .max = 2800000 },
68 .n = { .min = 1, .max = 6 },
69 .m = { .min = 70, .max = 120 },
70 .m1 = { .min = 8, .max = 18 },
71 .m2 = { .min = 3, .max = 7 },
72 .p = { .min = 5, .max = 80 },
73 .p1 = { .min = 1, .max = 8 },
74 .p2 = { .dot_limit = 200000,
75 .p2_slow = 10, .p2_fast = 5 },
78 static const struct intel_limit intel_limits_i9xx_lvds = {
79 .dot = { .min = 20000, .max = 400000 },
80 .vco = { .min = 1400000, .max = 2800000 },
81 .n = { .min = 1, .max = 6 },
82 .m = { .min = 70, .max = 120 },
83 .m1 = { .min = 8, .max = 18 },
84 .m2 = { .min = 3, .max = 7 },
85 .p = { .min = 7, .max = 98 },
86 .p1 = { .min = 1, .max = 8 },
87 .p2 = { .dot_limit = 112000,
88 .p2_slow = 14, .p2_fast = 7 },
92 static const struct intel_limit intel_limits_g4x_sdvo = {
93 .dot = { .min = 25000, .max = 270000 },
94 .vco = { .min = 1750000, .max = 3500000},
95 .n = { .min = 1, .max = 4 },
96 .m = { .min = 104, .max = 138 },
97 .m1 = { .min = 17, .max = 23 },
98 .m2 = { .min = 5, .max = 11 },
99 .p = { .min = 10, .max = 30 },
100 .p1 = { .min = 1, .max = 3},
101 .p2 = { .dot_limit = 270000,
107 static const struct intel_limit intel_limits_g4x_hdmi = {
108 .dot = { .min = 22000, .max = 400000 },
109 .vco = { .min = 1750000, .max = 3500000},
110 .n = { .min = 1, .max = 4 },
111 .m = { .min = 104, .max = 138 },
112 .m1 = { .min = 16, .max = 23 },
113 .m2 = { .min = 5, .max = 11 },
114 .p = { .min = 5, .max = 80 },
115 .p1 = { .min = 1, .max = 8},
116 .p2 = { .dot_limit = 165000,
117 .p2_slow = 10, .p2_fast = 5 },
120 static const struct intel_limit intel_limits_g4x_single_channel_lvds = {
121 .dot = { .min = 20000, .max = 115000 },
122 .vco = { .min = 1750000, .max = 3500000 },
123 .n = { .min = 1, .max = 3 },
124 .m = { .min = 104, .max = 138 },
125 .m1 = { .min = 17, .max = 23 },
126 .m2 = { .min = 5, .max = 11 },
127 .p = { .min = 28, .max = 112 },
128 .p1 = { .min = 2, .max = 8 },
129 .p2 = { .dot_limit = 0,
130 .p2_slow = 14, .p2_fast = 14
134 static const struct intel_limit intel_limits_g4x_dual_channel_lvds = {
135 .dot = { .min = 80000, .max = 224000 },
136 .vco = { .min = 1750000, .max = 3500000 },
137 .n = { .min = 1, .max = 3 },
138 .m = { .min = 104, .max = 138 },
139 .m1 = { .min = 17, .max = 23 },
140 .m2 = { .min = 5, .max = 11 },
141 .p = { .min = 14, .max = 42 },
142 .p1 = { .min = 2, .max = 6 },
143 .p2 = { .dot_limit = 0,
144 .p2_slow = 7, .p2_fast = 7
148 static const struct intel_limit pnv_limits_sdvo = {
149 .dot = { .min = 20000, .max = 400000},
150 .vco = { .min = 1700000, .max = 3500000 },
151 /* Pineview's Ncounter is a ring counter */
152 .n = { .min = 3, .max = 6 },
153 .m = { .min = 2, .max = 256 },
154 /* Pineview only has one combined m divider, which we treat as m2. */
155 .m1 = { .min = 0, .max = 0 },
156 .m2 = { .min = 0, .max = 254 },
157 .p = { .min = 5, .max = 80 },
158 .p1 = { .min = 1, .max = 8 },
159 .p2 = { .dot_limit = 200000,
160 .p2_slow = 10, .p2_fast = 5 },
163 static const struct intel_limit pnv_limits_lvds = {
164 .dot = { .min = 20000, .max = 400000 },
165 .vco = { .min = 1700000, .max = 3500000 },
166 .n = { .min = 3, .max = 6 },
167 .m = { .min = 2, .max = 256 },
168 .m1 = { .min = 0, .max = 0 },
169 .m2 = { .min = 0, .max = 254 },
170 .p = { .min = 7, .max = 112 },
171 .p1 = { .min = 1, .max = 8 },
172 .p2 = { .dot_limit = 112000,
173 .p2_slow = 14, .p2_fast = 14 },
176 /* Ironlake / Sandybridge
178 * We calculate clock using (register_value + 2) for N/M1/M2, so here
179 * the range value for them is (actual_value - 2).
181 static const struct intel_limit ilk_limits_dac = {
182 .dot = { .min = 25000, .max = 350000 },
183 .vco = { .min = 1760000, .max = 3510000 },
184 .n = { .min = 1, .max = 5 },
185 .m = { .min = 79, .max = 127 },
186 .m1 = { .min = 12, .max = 22 },
187 .m2 = { .min = 5, .max = 9 },
188 .p = { .min = 5, .max = 80 },
189 .p1 = { .min = 1, .max = 8 },
190 .p2 = { .dot_limit = 225000,
191 .p2_slow = 10, .p2_fast = 5 },
194 static const struct intel_limit ilk_limits_single_lvds = {
195 .dot = { .min = 25000, .max = 350000 },
196 .vco = { .min = 1760000, .max = 3510000 },
197 .n = { .min = 1, .max = 3 },
198 .m = { .min = 79, .max = 118 },
199 .m1 = { .min = 12, .max = 22 },
200 .m2 = { .min = 5, .max = 9 },
201 .p = { .min = 28, .max = 112 },
202 .p1 = { .min = 2, .max = 8 },
203 .p2 = { .dot_limit = 225000,
204 .p2_slow = 14, .p2_fast = 14 },
207 static const struct intel_limit ilk_limits_dual_lvds = {
208 .dot = { .min = 25000, .max = 350000 },
209 .vco = { .min = 1760000, .max = 3510000 },
210 .n = { .min = 1, .max = 3 },
211 .m = { .min = 79, .max = 127 },
212 .m1 = { .min = 12, .max = 22 },
213 .m2 = { .min = 5, .max = 9 },
214 .p = { .min = 14, .max = 56 },
215 .p1 = { .min = 2, .max = 8 },
216 .p2 = { .dot_limit = 225000,
217 .p2_slow = 7, .p2_fast = 7 },
220 /* LVDS 100mhz refclk limits. */
221 static const struct intel_limit ilk_limits_single_lvds_100m = {
222 .dot = { .min = 25000, .max = 350000 },
223 .vco = { .min = 1760000, .max = 3510000 },
224 .n = { .min = 1, .max = 2 },
225 .m = { .min = 79, .max = 126 },
226 .m1 = { .min = 12, .max = 22 },
227 .m2 = { .min = 5, .max = 9 },
228 .p = { .min = 28, .max = 112 },
229 .p1 = { .min = 2, .max = 8 },
230 .p2 = { .dot_limit = 225000,
231 .p2_slow = 14, .p2_fast = 14 },
234 static const struct intel_limit ilk_limits_dual_lvds_100m = {
235 .dot = { .min = 25000, .max = 350000 },
236 .vco = { .min = 1760000, .max = 3510000 },
237 .n = { .min = 1, .max = 3 },
238 .m = { .min = 79, .max = 126 },
239 .m1 = { .min = 12, .max = 22 },
240 .m2 = { .min = 5, .max = 9 },
241 .p = { .min = 14, .max = 42 },
242 .p1 = { .min = 2, .max = 6 },
243 .p2 = { .dot_limit = 225000,
244 .p2_slow = 7, .p2_fast = 7 },
247 static const struct intel_limit intel_limits_vlv = {
249 * These are the data rate limits (measured in fast clocks)
250 * since those are the strictest limits we have. The fast
251 * clock and actual rate limits are more relaxed, so checking
252 * them would make no difference.
254 .dot = { .min = 25000 * 5, .max = 270000 * 5 },
255 .vco = { .min = 4000000, .max = 6000000 },
256 .n = { .min = 1, .max = 7 },
257 .m1 = { .min = 2, .max = 3 },
258 .m2 = { .min = 11, .max = 156 },
259 .p1 = { .min = 2, .max = 3 },
260 .p2 = { .p2_slow = 2, .p2_fast = 20 }, /* slow=min, fast=max */
263 static const struct intel_limit intel_limits_chv = {
265 * These are the data rate limits (measured in fast clocks)
266 * since those are the strictest limits we have. The fast
267 * clock and actual rate limits are more relaxed, so checking
268 * them would make no difference.
270 .dot = { .min = 25000 * 5, .max = 540000 * 5},
271 .vco = { .min = 4800000, .max = 6480000 },
272 .n = { .min = 1, .max = 1 },
273 .m1 = { .min = 2, .max = 2 },
274 .m2 = { .min = 24 << 22, .max = 175 << 22 },
275 .p1 = { .min = 2, .max = 4 },
276 .p2 = { .p2_slow = 1, .p2_fast = 14 },
279 static const struct intel_limit intel_limits_bxt = {
280 /* FIXME: find real dot limits */
281 .dot = { .min = 0, .max = INT_MAX },
282 .vco = { .min = 4800000, .max = 6700000 },
283 .n = { .min = 1, .max = 1 },
284 .m1 = { .min = 2, .max = 2 },
285 /* FIXME: find real m2 limits */
286 .m2 = { .min = 2 << 22, .max = 255 << 22 },
287 .p1 = { .min = 2, .max = 4 },
288 .p2 = { .p2_slow = 1, .p2_fast = 20 },
292 * Platform specific helpers to calculate the port PLL loopback- (clock.m),
293 * and post-divider (clock.p) values, pre- (clock.vco) and post-divided fast
294 * (clock.dot) clock rates. This fast dot clock is fed to the port's IO logic.
295 * The helpers' return value is the rate of the clock that is fed to the
296 * display engine's pipe which can be the above fast dot clock rate or a
297 * divided-down version of it.
299 /* m1 is reserved as 0 in Pineview, n is a ring counter */
300 int pnv_calc_dpll_params(int refclk, struct dpll *clock)
302 clock->m = clock->m2 + 2;
303 clock->p = clock->p1 * clock->p2;
304 if (WARN_ON(clock->n == 0 || clock->p == 0))
306 clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n);
307 clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
312 static u32 i9xx_dpll_compute_m(const struct dpll *dpll)
314 return 5 * (dpll->m1 + 2) + (dpll->m2 + 2);
317 int i9xx_calc_dpll_params(int refclk, struct dpll *clock)
319 clock->m = i9xx_dpll_compute_m(clock);
320 clock->p = clock->p1 * clock->p2;
321 if (WARN_ON(clock->n + 2 == 0 || clock->p == 0))
323 clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n + 2);
324 clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
329 int vlv_calc_dpll_params(int refclk, struct dpll *clock)
331 clock->m = clock->m1 * clock->m2;
332 clock->p = clock->p1 * clock->p2;
333 if (WARN_ON(clock->n == 0 || clock->p == 0))
335 clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n);
336 clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
338 return clock->dot / 5;
341 int chv_calc_dpll_params(int refclk, struct dpll *clock)
343 clock->m = clock->m1 * clock->m2;
344 clock->p = clock->p1 * clock->p2;
345 if (WARN_ON(clock->n == 0 || clock->p == 0))
347 clock->vco = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(refclk, clock->m),
349 clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p);
351 return clock->dot / 5;
355 * Returns whether the given set of divisors are valid for a given refclk with
356 * the given connectors.
358 static bool intel_pll_is_valid(struct drm_i915_private *dev_priv,
359 const struct intel_limit *limit,
360 const struct dpll *clock)
362 if (clock->n < limit->n.min || limit->n.max < clock->n)
364 if (clock->p1 < limit->p1.min || limit->p1.max < clock->p1)
366 if (clock->m2 < limit->m2.min || limit->m2.max < clock->m2)
368 if (clock->m1 < limit->m1.min || limit->m1.max < clock->m1)
371 if (!IS_PINEVIEW(dev_priv) && !IS_LP(dev_priv))
372 if (clock->m1 <= clock->m2)
375 if (!IS_LP(dev_priv)) {
376 if (clock->p < limit->p.min || limit->p.max < clock->p)
378 if (clock->m < limit->m.min || limit->m.max < clock->m)
382 if (clock->vco < limit->vco.min || limit->vco.max < clock->vco)
384 /* XXX: We may need to be checking "Dot clock" depending on the multiplier,
385 * connector, etc., rather than just a single range.
387 if (clock->dot < limit->dot.min || limit->dot.max < clock->dot)
394 i9xx_select_p2_div(const struct intel_limit *limit,
395 const struct intel_crtc_state *crtc_state,
398 struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
400 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) {
402 * For LVDS just rely on its current settings for dual-channel.
403 * We haven't figured out how to reliably set up different
404 * single/dual channel state, if we even can.
406 if (intel_is_dual_link_lvds(dev_priv))
407 return limit->p2.p2_fast;
409 return limit->p2.p2_slow;
411 if (target < limit->p2.dot_limit)
412 return limit->p2.p2_slow;
414 return limit->p2.p2_fast;
419 * Returns a set of divisors for the desired target clock with the given
420 * refclk, or FALSE. The returned values represent the clock equation:
421 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
423 * Target and reference clocks are specified in kHz.
425 * If match_clock is provided, then best_clock P divider must match the P
426 * divider from @match_clock used for LVDS downclocking.
429 i9xx_find_best_dpll(const struct intel_limit *limit,
430 struct intel_crtc_state *crtc_state,
431 int target, int refclk,
432 const struct dpll *match_clock,
433 struct dpll *best_clock)
435 struct drm_device *dev = crtc_state->uapi.crtc->dev;
439 memset(best_clock, 0, sizeof(*best_clock));
441 clock.p2 = i9xx_select_p2_div(limit, crtc_state, target);
443 for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max;
445 for (clock.m2 = limit->m2.min;
446 clock.m2 <= limit->m2.max; clock.m2++) {
447 if (clock.m2 >= clock.m1)
449 for (clock.n = limit->n.min;
450 clock.n <= limit->n.max; clock.n++) {
451 for (clock.p1 = limit->p1.min;
452 clock.p1 <= limit->p1.max; clock.p1++) {
455 i9xx_calc_dpll_params(refclk, &clock);
456 if (!intel_pll_is_valid(to_i915(dev),
461 clock.p != match_clock->p)
464 this_err = abs(clock.dot - target);
465 if (this_err < err) {
474 return (err != target);
478 * Returns a set of divisors for the desired target clock with the given
479 * refclk, or FALSE. The returned values represent the clock equation:
480 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
482 * Target and reference clocks are specified in kHz.
484 * If match_clock is provided, then best_clock P divider must match the P
485 * divider from @match_clock used for LVDS downclocking.
488 pnv_find_best_dpll(const struct intel_limit *limit,
489 struct intel_crtc_state *crtc_state,
490 int target, int refclk,
491 const struct dpll *match_clock,
492 struct dpll *best_clock)
494 struct drm_device *dev = crtc_state->uapi.crtc->dev;
498 memset(best_clock, 0, sizeof(*best_clock));
500 clock.p2 = i9xx_select_p2_div(limit, crtc_state, target);
502 for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max;
504 for (clock.m2 = limit->m2.min;
505 clock.m2 <= limit->m2.max; clock.m2++) {
506 for (clock.n = limit->n.min;
507 clock.n <= limit->n.max; clock.n++) {
508 for (clock.p1 = limit->p1.min;
509 clock.p1 <= limit->p1.max; clock.p1++) {
512 pnv_calc_dpll_params(refclk, &clock);
513 if (!intel_pll_is_valid(to_i915(dev),
518 clock.p != match_clock->p)
521 this_err = abs(clock.dot - target);
522 if (this_err < err) {
531 return (err != target);
535 * Returns a set of divisors for the desired target clock with the given
536 * refclk, or FALSE. The returned values represent the clock equation:
537 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
539 * Target and reference clocks are specified in kHz.
541 * If match_clock is provided, then best_clock P divider must match the P
542 * divider from @match_clock used for LVDS downclocking.
545 g4x_find_best_dpll(const struct intel_limit *limit,
546 struct intel_crtc_state *crtc_state,
547 int target, int refclk,
548 const struct dpll *match_clock,
549 struct dpll *best_clock)
551 struct drm_device *dev = crtc_state->uapi.crtc->dev;
555 /* approximately equals target * 0.00585 */
556 int err_most = (target >> 8) + (target >> 9);
558 memset(best_clock, 0, sizeof(*best_clock));
560 clock.p2 = i9xx_select_p2_div(limit, crtc_state, target);
562 max_n = limit->n.max;
563 /* based on hardware requirement, prefer smaller n to precision */
564 for (clock.n = limit->n.min; clock.n <= max_n; clock.n++) {
565 /* based on hardware requirement, prefere larger m1,m2 */
566 for (clock.m1 = limit->m1.max;
567 clock.m1 >= limit->m1.min; clock.m1--) {
568 for (clock.m2 = limit->m2.max;
569 clock.m2 >= limit->m2.min; clock.m2--) {
570 for (clock.p1 = limit->p1.max;
571 clock.p1 >= limit->p1.min; clock.p1--) {
574 i9xx_calc_dpll_params(refclk, &clock);
575 if (!intel_pll_is_valid(to_i915(dev),
580 this_err = abs(clock.dot - target);
581 if (this_err < err_most) {
595 * Check if the calculated PLL configuration is more optimal compared to the
596 * best configuration and error found so far. Return the calculated error.
598 static bool vlv_PLL_is_optimal(struct drm_device *dev, int target_freq,
599 const struct dpll *calculated_clock,
600 const struct dpll *best_clock,
601 unsigned int best_error_ppm,
602 unsigned int *error_ppm)
605 * For CHV ignore the error and consider only the P value.
606 * Prefer a bigger P value based on HW requirements.
608 if (IS_CHERRYVIEW(to_i915(dev))) {
611 return calculated_clock->p > best_clock->p;
614 if (drm_WARN_ON_ONCE(dev, !target_freq))
617 *error_ppm = div_u64(1000000ULL *
618 abs(target_freq - calculated_clock->dot),
621 * Prefer a better P value over a better (smaller) error if the error
622 * is small. Ensure this preference for future configurations too by
623 * setting the error to 0.
625 if (*error_ppm < 100 && calculated_clock->p > best_clock->p) {
631 return *error_ppm + 10 < best_error_ppm;
635 * Returns a set of divisors for the desired target clock with the given
636 * refclk, or FALSE. The returned values represent the clock equation:
637 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
640 vlv_find_best_dpll(const struct intel_limit *limit,
641 struct intel_crtc_state *crtc_state,
642 int target, int refclk,
643 const struct dpll *match_clock,
644 struct dpll *best_clock)
646 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
647 struct drm_device *dev = crtc->base.dev;
649 unsigned int bestppm = 1000000;
650 /* min update 19.2 MHz */
651 int max_n = min(limit->n.max, refclk / 19200);
654 target *= 5; /* fast clock */
656 memset(best_clock, 0, sizeof(*best_clock));
658 /* based on hardware requirement, prefer smaller n to precision */
659 for (clock.n = limit->n.min; clock.n <= max_n; clock.n++) {
660 for (clock.p1 = limit->p1.max; clock.p1 >= limit->p1.min; clock.p1--) {
661 for (clock.p2 = limit->p2.p2_fast; clock.p2 >= limit->p2.p2_slow;
662 clock.p2 -= clock.p2 > 10 ? 2 : 1) {
663 clock.p = clock.p1 * clock.p2;
664 /* based on hardware requirement, prefer bigger m1,m2 values */
665 for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max; clock.m1++) {
668 clock.m2 = DIV_ROUND_CLOSEST(target * clock.p * clock.n,
671 vlv_calc_dpll_params(refclk, &clock);
673 if (!intel_pll_is_valid(to_i915(dev),
678 if (!vlv_PLL_is_optimal(dev, target,
696 * Returns a set of divisors for the desired target clock with the given
697 * refclk, or FALSE. The returned values represent the clock equation:
698 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
701 chv_find_best_dpll(const struct intel_limit *limit,
702 struct intel_crtc_state *crtc_state,
703 int target, int refclk,
704 const struct dpll *match_clock,
705 struct dpll *best_clock)
707 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
708 struct drm_device *dev = crtc->base.dev;
709 unsigned int best_error_ppm;
714 memset(best_clock, 0, sizeof(*best_clock));
715 best_error_ppm = 1000000;
718 * Based on hardware doc, the n always set to 1, and m1 always
719 * set to 2. If requires to support 200Mhz refclk, we need to
720 * revisit this because n may not 1 anymore.
724 target *= 5; /* fast clock */
726 for (clock.p1 = limit->p1.max; clock.p1 >= limit->p1.min; clock.p1--) {
727 for (clock.p2 = limit->p2.p2_fast;
728 clock.p2 >= limit->p2.p2_slow;
729 clock.p2 -= clock.p2 > 10 ? 2 : 1) {
730 unsigned int error_ppm;
732 clock.p = clock.p1 * clock.p2;
734 m2 = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(target, clock.p * clock.n) << 22,
737 if (m2 > INT_MAX/clock.m1)
742 chv_calc_dpll_params(refclk, &clock);
744 if (!intel_pll_is_valid(to_i915(dev), limit, &clock))
747 if (!vlv_PLL_is_optimal(dev, target, &clock, best_clock,
748 best_error_ppm, &error_ppm))
752 best_error_ppm = error_ppm;
760 bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state,
761 struct dpll *best_clock)
764 const struct intel_limit *limit = &intel_limits_bxt;
766 return chv_find_best_dpll(limit, crtc_state,
767 crtc_state->port_clock, refclk,
771 u32 i9xx_dpll_compute_fp(const struct dpll *dpll)
773 return dpll->n << 16 | dpll->m1 << 8 | dpll->m2;
776 static u32 pnv_dpll_compute_fp(const struct dpll *dpll)
778 return (1 << dpll->n) << 16 | dpll->m2;
781 static void i9xx_update_pll_dividers(struct intel_crtc_state *crtc_state,
782 const struct dpll *clock,
783 const struct dpll *reduced_clock)
785 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
786 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
789 if (IS_PINEVIEW(dev_priv)) {
790 fp = pnv_dpll_compute_fp(clock);
791 fp2 = pnv_dpll_compute_fp(reduced_clock);
793 fp = i9xx_dpll_compute_fp(clock);
794 fp2 = i9xx_dpll_compute_fp(reduced_clock);
797 crtc_state->dpll_hw_state.fp0 = fp;
798 crtc_state->dpll_hw_state.fp1 = fp2;
801 static void i9xx_compute_dpll(struct intel_crtc_state *crtc_state,
802 const struct dpll *clock,
803 const struct dpll *reduced_clock)
805 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
806 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
809 i9xx_update_pll_dividers(crtc_state, clock, reduced_clock);
811 dpll = DPLL_VGA_MODE_DIS;
813 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS))
814 dpll |= DPLLB_MODE_LVDS;
816 dpll |= DPLLB_MODE_DAC_SERIAL;
818 if (IS_I945G(dev_priv) || IS_I945GM(dev_priv) ||
819 IS_G33(dev_priv) || IS_PINEVIEW(dev_priv)) {
820 dpll |= (crtc_state->pixel_multiplier - 1)
821 << SDVO_MULTIPLIER_SHIFT_HIRES;
824 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_SDVO) ||
825 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
826 dpll |= DPLL_SDVO_HIGH_SPEED;
828 if (intel_crtc_has_dp_encoder(crtc_state))
829 dpll |= DPLL_SDVO_HIGH_SPEED;
831 /* compute bitmask from p1 value */
832 if (IS_G4X(dev_priv)) {
833 dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
834 dpll |= (1 << (reduced_clock->p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT;
835 } else if (IS_PINEVIEW(dev_priv)) {
836 dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT_PINEVIEW;
837 WARN_ON(reduced_clock->p1 != clock->p1);
839 dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
840 WARN_ON(reduced_clock->p1 != clock->p1);
845 dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5;
848 dpll |= DPLLB_LVDS_P2_CLOCK_DIV_7;
851 dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_10;
854 dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14;
857 WARN_ON(reduced_clock->p2 != clock->p2);
859 if (DISPLAY_VER(dev_priv) >= 4)
860 dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT);
862 if (crtc_state->sdvo_tv_clock)
863 dpll |= PLL_REF_INPUT_TVCLKINBC;
864 else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS) &&
865 intel_panel_use_ssc(dev_priv))
866 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
868 dpll |= PLL_REF_INPUT_DREFCLK;
870 dpll |= DPLL_VCO_ENABLE;
871 crtc_state->dpll_hw_state.dpll = dpll;
873 if (DISPLAY_VER(dev_priv) >= 4) {
874 u32 dpll_md = (crtc_state->pixel_multiplier - 1)
875 << DPLL_MD_UDI_MULTIPLIER_SHIFT;
876 crtc_state->dpll_hw_state.dpll_md = dpll_md;
880 static void i8xx_compute_dpll(struct intel_crtc_state *crtc_state,
881 const struct dpll *clock,
882 const struct dpll *reduced_clock)
884 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
885 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
888 i9xx_update_pll_dividers(crtc_state, clock, reduced_clock);
890 dpll = DPLL_VGA_MODE_DIS;
892 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) {
893 dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
896 dpll |= PLL_P1_DIVIDE_BY_TWO;
898 dpll |= (clock->p1 - 2) << DPLL_FPA01_P1_POST_DIV_SHIFT;
900 dpll |= PLL_P2_DIVIDE_BY_4;
902 WARN_ON(reduced_clock->p1 != clock->p1);
903 WARN_ON(reduced_clock->p2 != clock->p2);
907 * "[Almador Errata}: For the correct operation of the muxed DVO pins
908 * (GDEVSELB/I2Cdata, GIRDBY/I2CClk) and (GFRAMEB/DVI_Data,
909 * GTRDYB/DVI_Clk): Bit 31 (DPLL VCO Enable) and Bit 30 (2X Clock
910 * Enable) must be set to “1” in both the DPLL A Control Register
911 * (06014h-06017h) and DPLL B Control Register (06018h-0601Bh)."
913 * For simplicity We simply keep both bits always enabled in
914 * both DPLLS. The spec says we should disable the DVO 2X clock
915 * when not needed, but this seems to work fine in practice.
917 if (IS_I830(dev_priv) ||
918 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DVO))
919 dpll |= DPLL_DVO_2X_MODE;
921 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS) &&
922 intel_panel_use_ssc(dev_priv))
923 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
925 dpll |= PLL_REF_INPUT_DREFCLK;
927 dpll |= DPLL_VCO_ENABLE;
928 crtc_state->dpll_hw_state.dpll = dpll;
931 static int hsw_crtc_compute_clock(struct intel_crtc_state *crtc_state)
933 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
934 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
935 struct intel_atomic_state *state =
936 to_intel_atomic_state(crtc_state->uapi.state);
937 struct intel_encoder *encoder =
938 intel_get_crtc_new_encoder(state, crtc_state);
940 if (IS_DG2(dev_priv))
941 return intel_mpllb_calc_state(crtc_state, encoder);
943 if (DISPLAY_VER(dev_priv) < 11 &&
944 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI))
947 if (!intel_reserve_shared_dplls(state, crtc, encoder)) {
948 drm_dbg_kms(&dev_priv->drm,
949 "failed to find PLL for pipe %c\n",
950 pipe_name(crtc->pipe));
957 static bool ilk_needs_fb_cb_tune(const struct dpll *dpll, int factor)
959 return dpll->m < factor * dpll->n;
962 static void ilk_update_pll_dividers(struct intel_crtc_state *crtc_state,
963 const struct dpll *clock,
964 const struct dpll *reduced_clock)
966 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
967 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
971 /* Enable autotuning of the PLL clock (if permissible) */
973 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) {
974 if ((intel_panel_use_ssc(dev_priv) &&
975 dev_priv->vbt.lvds_ssc_freq == 100000) ||
976 (HAS_PCH_IBX(dev_priv) &&
977 intel_is_dual_link_lvds(dev_priv)))
979 } else if (crtc_state->sdvo_tv_clock) {
983 fp = i9xx_dpll_compute_fp(clock);
984 if (ilk_needs_fb_cb_tune(clock, factor))
987 fp2 = i9xx_dpll_compute_fp(reduced_clock);
988 if (ilk_needs_fb_cb_tune(reduced_clock, factor))
991 crtc_state->dpll_hw_state.fp0 = fp;
992 crtc_state->dpll_hw_state.fp1 = fp2;
995 static void ilk_compute_dpll(struct intel_crtc_state *crtc_state,
996 const struct dpll *clock,
997 const struct dpll *reduced_clock)
999 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1000 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1003 ilk_update_pll_dividers(crtc_state, clock, reduced_clock);
1007 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS))
1008 dpll |= DPLLB_MODE_LVDS;
1010 dpll |= DPLLB_MODE_DAC_SERIAL;
1012 dpll |= (crtc_state->pixel_multiplier - 1)
1013 << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT;
1015 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_SDVO) ||
1016 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
1017 dpll |= DPLL_SDVO_HIGH_SPEED;
1019 if (intel_crtc_has_dp_encoder(crtc_state))
1020 dpll |= DPLL_SDVO_HIGH_SPEED;
1023 * The high speed IO clock is only really required for
1024 * SDVO/HDMI/DP, but we also enable it for CRT to make it
1025 * possible to share the DPLL between CRT and HDMI. Enabling
1026 * the clock needlessly does no real harm, except use up a
1027 * bit of power potentially.
1029 * We'll limit this to IVB with 3 pipes, since it has only two
1030 * DPLLs and so DPLL sharing is the only way to get three pipes
1031 * driving PCH ports at the same time. On SNB we could do this,
1032 * and potentially avoid enabling the second DPLL, but it's not
1033 * clear if it''s a win or loss power wise. No point in doing
1034 * this on ILK at all since it has a fixed DPLL<->pipe mapping.
1036 if (INTEL_NUM_PIPES(dev_priv) == 3 &&
1037 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_ANALOG))
1038 dpll |= DPLL_SDVO_HIGH_SPEED;
1040 /* compute bitmask from p1 value */
1041 dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT;
1043 dpll |= (1 << (reduced_clock->p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT;
1045 switch (clock->p2) {
1047 dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5;
1050 dpll |= DPLLB_LVDS_P2_CLOCK_DIV_7;
1053 dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_10;
1056 dpll |= DPLLB_LVDS_P2_CLOCK_DIV_14;
1059 WARN_ON(reduced_clock->p2 != clock->p2);
1061 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS) &&
1062 intel_panel_use_ssc(dev_priv))
1063 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
1065 dpll |= PLL_REF_INPUT_DREFCLK;
1067 dpll |= DPLL_VCO_ENABLE;
1069 crtc_state->dpll_hw_state.dpll = dpll;
1072 static int ilk_crtc_compute_clock(struct intel_crtc_state *crtc_state)
1074 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1075 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1076 struct intel_atomic_state *state =
1077 to_intel_atomic_state(crtc_state->uapi.state);
1078 const struct intel_limit *limit;
1079 int refclk = 120000;
1081 memset(&crtc_state->dpll_hw_state, 0,
1082 sizeof(crtc_state->dpll_hw_state));
1084 /* CPU eDP is the only output that doesn't need a PCH PLL of its own. */
1085 if (!crtc_state->has_pch_encoder)
1088 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) {
1089 if (intel_panel_use_ssc(dev_priv)) {
1090 drm_dbg_kms(&dev_priv->drm,
1091 "using SSC reference clock of %d kHz\n",
1092 dev_priv->vbt.lvds_ssc_freq);
1093 refclk = dev_priv->vbt.lvds_ssc_freq;
1096 if (intel_is_dual_link_lvds(dev_priv)) {
1097 if (refclk == 100000)
1098 limit = &ilk_limits_dual_lvds_100m;
1100 limit = &ilk_limits_dual_lvds;
1102 if (refclk == 100000)
1103 limit = &ilk_limits_single_lvds_100m;
1105 limit = &ilk_limits_single_lvds;
1108 limit = &ilk_limits_dac;
1111 if (!crtc_state->clock_set &&
1112 !g4x_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
1113 refclk, NULL, &crtc_state->dpll)) {
1114 drm_err(&dev_priv->drm,
1115 "Couldn't find PLL settings for mode!\n");
1119 ilk_compute_dpll(crtc_state, &crtc_state->dpll,
1122 if (!intel_reserve_shared_dplls(state, crtc, NULL)) {
1123 drm_dbg_kms(&dev_priv->drm,
1124 "failed to find PLL for pipe %c\n",
1125 pipe_name(crtc->pipe));
1132 void vlv_compute_dpll(struct intel_crtc_state *crtc_state)
1134 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1136 crtc_state->dpll_hw_state.dpll = DPLL_INTEGRATED_REF_CLK_VLV |
1137 DPLL_REF_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS;
1138 if (crtc->pipe != PIPE_A)
1139 crtc_state->dpll_hw_state.dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
1141 /* DPLL not used with DSI, but still need the rest set up */
1142 if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI))
1143 crtc_state->dpll_hw_state.dpll |= DPLL_VCO_ENABLE |
1144 DPLL_EXT_BUFFER_ENABLE_VLV;
1146 crtc_state->dpll_hw_state.dpll_md =
1147 (crtc_state->pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT;
1150 void chv_compute_dpll(struct intel_crtc_state *crtc_state)
1152 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1154 crtc_state->dpll_hw_state.dpll = DPLL_SSC_REF_CLK_CHV |
1155 DPLL_REF_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS;
1156 if (crtc->pipe != PIPE_A)
1157 crtc_state->dpll_hw_state.dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
1159 /* DPLL not used with DSI, but still need the rest set up */
1160 if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI))
1161 crtc_state->dpll_hw_state.dpll |= DPLL_VCO_ENABLE;
1163 crtc_state->dpll_hw_state.dpll_md =
1164 (crtc_state->pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT;
1167 static int chv_crtc_compute_clock(struct intel_crtc_state *crtc_state)
1169 int refclk = 100000;
1170 const struct intel_limit *limit = &intel_limits_chv;
1171 struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
1173 memset(&crtc_state->dpll_hw_state, 0,
1174 sizeof(crtc_state->dpll_hw_state));
1176 if (!crtc_state->clock_set &&
1177 !chv_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
1178 refclk, NULL, &crtc_state->dpll)) {
1179 drm_err(&i915->drm, "Couldn't find PLL settings for mode!\n");
1183 chv_compute_dpll(crtc_state);
1188 static int vlv_crtc_compute_clock(struct intel_crtc_state *crtc_state)
1190 int refclk = 100000;
1191 const struct intel_limit *limit = &intel_limits_vlv;
1192 struct drm_i915_private *i915 = to_i915(crtc_state->uapi.crtc->dev);
1194 memset(&crtc_state->dpll_hw_state, 0,
1195 sizeof(crtc_state->dpll_hw_state));
1197 if (!crtc_state->clock_set &&
1198 !vlv_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
1199 refclk, NULL, &crtc_state->dpll)) {
1200 drm_err(&i915->drm, "Couldn't find PLL settings for mode!\n");
1204 vlv_compute_dpll(crtc_state);
1209 static int g4x_crtc_compute_clock(struct intel_crtc_state *crtc_state)
1211 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1212 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1213 const struct intel_limit *limit;
1216 memset(&crtc_state->dpll_hw_state, 0,
1217 sizeof(crtc_state->dpll_hw_state));
1219 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) {
1220 if (intel_panel_use_ssc(dev_priv)) {
1221 refclk = dev_priv->vbt.lvds_ssc_freq;
1222 drm_dbg_kms(&dev_priv->drm,
1223 "using SSC reference clock of %d kHz\n",
1227 if (intel_is_dual_link_lvds(dev_priv))
1228 limit = &intel_limits_g4x_dual_channel_lvds;
1230 limit = &intel_limits_g4x_single_channel_lvds;
1231 } else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI) ||
1232 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_ANALOG)) {
1233 limit = &intel_limits_g4x_hdmi;
1234 } else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_SDVO)) {
1235 limit = &intel_limits_g4x_sdvo;
1237 /* The option is for other outputs */
1238 limit = &intel_limits_i9xx_sdvo;
1241 if (!crtc_state->clock_set &&
1242 !g4x_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
1243 refclk, NULL, &crtc_state->dpll)) {
1244 drm_err(&dev_priv->drm,
1245 "Couldn't find PLL settings for mode!\n");
1249 i9xx_compute_dpll(crtc_state, &crtc_state->dpll,
1255 static int pnv_crtc_compute_clock(struct intel_crtc_state *crtc_state)
1257 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1258 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1259 const struct intel_limit *limit;
1262 memset(&crtc_state->dpll_hw_state, 0,
1263 sizeof(crtc_state->dpll_hw_state));
1265 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) {
1266 if (intel_panel_use_ssc(dev_priv)) {
1267 refclk = dev_priv->vbt.lvds_ssc_freq;
1268 drm_dbg_kms(&dev_priv->drm,
1269 "using SSC reference clock of %d kHz\n",
1273 limit = &pnv_limits_lvds;
1275 limit = &pnv_limits_sdvo;
1278 if (!crtc_state->clock_set &&
1279 !pnv_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
1280 refclk, NULL, &crtc_state->dpll)) {
1281 drm_err(&dev_priv->drm,
1282 "Couldn't find PLL settings for mode!\n");
1286 i9xx_compute_dpll(crtc_state, &crtc_state->dpll,
1292 static int i9xx_crtc_compute_clock(struct intel_crtc_state *crtc_state)
1294 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1295 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1296 const struct intel_limit *limit;
1299 memset(&crtc_state->dpll_hw_state, 0,
1300 sizeof(crtc_state->dpll_hw_state));
1302 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) {
1303 if (intel_panel_use_ssc(dev_priv)) {
1304 refclk = dev_priv->vbt.lvds_ssc_freq;
1305 drm_dbg_kms(&dev_priv->drm,
1306 "using SSC reference clock of %d kHz\n",
1310 limit = &intel_limits_i9xx_lvds;
1312 limit = &intel_limits_i9xx_sdvo;
1315 if (!crtc_state->clock_set &&
1316 !i9xx_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
1317 refclk, NULL, &crtc_state->dpll)) {
1318 drm_err(&dev_priv->drm,
1319 "Couldn't find PLL settings for mode!\n");
1323 i9xx_compute_dpll(crtc_state, &crtc_state->dpll,
1329 static int i8xx_crtc_compute_clock(struct intel_crtc_state *crtc_state)
1331 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1332 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1333 const struct intel_limit *limit;
1336 memset(&crtc_state->dpll_hw_state, 0,
1337 sizeof(crtc_state->dpll_hw_state));
1339 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_LVDS)) {
1340 if (intel_panel_use_ssc(dev_priv)) {
1341 refclk = dev_priv->vbt.lvds_ssc_freq;
1342 drm_dbg_kms(&dev_priv->drm,
1343 "using SSC reference clock of %d kHz\n",
1347 limit = &intel_limits_i8xx_lvds;
1348 } else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DVO)) {
1349 limit = &intel_limits_i8xx_dvo;
1351 limit = &intel_limits_i8xx_dac;
1354 if (!crtc_state->clock_set &&
1355 !i9xx_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
1356 refclk, NULL, &crtc_state->dpll)) {
1357 drm_err(&dev_priv->drm,
1358 "Couldn't find PLL settings for mode!\n");
1362 i8xx_compute_dpll(crtc_state, &crtc_state->dpll,
1368 static const struct intel_dpll_funcs hsw_dpll_funcs = {
1369 .crtc_compute_clock = hsw_crtc_compute_clock,
1372 static const struct intel_dpll_funcs ilk_dpll_funcs = {
1373 .crtc_compute_clock = ilk_crtc_compute_clock,
1376 static const struct intel_dpll_funcs chv_dpll_funcs = {
1377 .crtc_compute_clock = chv_crtc_compute_clock,
1380 static const struct intel_dpll_funcs vlv_dpll_funcs = {
1381 .crtc_compute_clock = vlv_crtc_compute_clock,
1384 static const struct intel_dpll_funcs g4x_dpll_funcs = {
1385 .crtc_compute_clock = g4x_crtc_compute_clock,
1388 static const struct intel_dpll_funcs pnv_dpll_funcs = {
1389 .crtc_compute_clock = pnv_crtc_compute_clock,
1392 static const struct intel_dpll_funcs i9xx_dpll_funcs = {
1393 .crtc_compute_clock = i9xx_crtc_compute_clock,
1396 static const struct intel_dpll_funcs i8xx_dpll_funcs = {
1397 .crtc_compute_clock = i8xx_crtc_compute_clock,
1401 intel_dpll_init_clock_hook(struct drm_i915_private *dev_priv)
1403 if (DISPLAY_VER(dev_priv) >= 9 || HAS_DDI(dev_priv))
1404 dev_priv->dpll_funcs = &hsw_dpll_funcs;
1405 else if (HAS_PCH_SPLIT(dev_priv))
1406 dev_priv->dpll_funcs = &ilk_dpll_funcs;
1407 else if (IS_CHERRYVIEW(dev_priv))
1408 dev_priv->dpll_funcs = &chv_dpll_funcs;
1409 else if (IS_VALLEYVIEW(dev_priv))
1410 dev_priv->dpll_funcs = &vlv_dpll_funcs;
1411 else if (IS_G4X(dev_priv))
1412 dev_priv->dpll_funcs = &g4x_dpll_funcs;
1413 else if (IS_PINEVIEW(dev_priv))
1414 dev_priv->dpll_funcs = &pnv_dpll_funcs;
1415 else if (DISPLAY_VER(dev_priv) != 2)
1416 dev_priv->dpll_funcs = &i9xx_dpll_funcs;
1418 dev_priv->dpll_funcs = &i8xx_dpll_funcs;
1421 static bool i9xx_has_pps(struct drm_i915_private *dev_priv)
1423 if (IS_I830(dev_priv))
1426 return IS_PINEVIEW(dev_priv) || IS_MOBILE(dev_priv);
1429 void i9xx_enable_pll(const struct intel_crtc_state *crtc_state)
1431 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1432 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1433 u32 dpll = crtc_state->dpll_hw_state.dpll;
1434 enum pipe pipe = crtc->pipe;
1437 assert_transcoder_disabled(dev_priv, crtc_state->cpu_transcoder);
1439 /* PLL is protected by panel, make sure we can write it */
1440 if (i9xx_has_pps(dev_priv))
1441 assert_panel_unlocked(dev_priv, pipe);
1443 intel_de_write(dev_priv, FP0(pipe), crtc_state->dpll_hw_state.fp0);
1444 intel_de_write(dev_priv, FP1(pipe), crtc_state->dpll_hw_state.fp1);
1447 * Apparently we need to have VGA mode enabled prior to changing
1448 * the P1/P2 dividers. Otherwise the DPLL will keep using the old
1449 * dividers, even though the register value does change.
1451 intel_de_write(dev_priv, DPLL(pipe), dpll & ~DPLL_VGA_MODE_DIS);
1452 intel_de_write(dev_priv, DPLL(pipe), dpll);
1454 /* Wait for the clocks to stabilize. */
1455 intel_de_posting_read(dev_priv, DPLL(pipe));
1458 if (DISPLAY_VER(dev_priv) >= 4) {
1459 intel_de_write(dev_priv, DPLL_MD(pipe),
1460 crtc_state->dpll_hw_state.dpll_md);
1462 /* The pixel multiplier can only be updated once the
1463 * DPLL is enabled and the clocks are stable.
1465 * So write it again.
1467 intel_de_write(dev_priv, DPLL(pipe), dpll);
1470 /* We do this three times for luck */
1471 for (i = 0; i < 3; i++) {
1472 intel_de_write(dev_priv, DPLL(pipe), dpll);
1473 intel_de_posting_read(dev_priv, DPLL(pipe));
1474 udelay(150); /* wait for warmup */
1478 static void vlv_pllb_recal_opamp(struct drm_i915_private *dev_priv,
1484 * PLLB opamp always calibrates to max value of 0x3f, force enable it
1485 * and set it to a reasonable value instead.
1487 reg_val = vlv_dpio_read(dev_priv, pipe, VLV_PLL_DW9(1));
1488 reg_val &= 0xffffff00;
1489 reg_val |= 0x00000030;
1490 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW9(1), reg_val);
1492 reg_val = vlv_dpio_read(dev_priv, pipe, VLV_REF_DW13);
1493 reg_val &= 0x00ffffff;
1494 reg_val |= 0x8c000000;
1495 vlv_dpio_write(dev_priv, pipe, VLV_REF_DW13, reg_val);
1497 reg_val = vlv_dpio_read(dev_priv, pipe, VLV_PLL_DW9(1));
1498 reg_val &= 0xffffff00;
1499 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW9(1), reg_val);
1501 reg_val = vlv_dpio_read(dev_priv, pipe, VLV_REF_DW13);
1502 reg_val &= 0x00ffffff;
1503 reg_val |= 0xb0000000;
1504 vlv_dpio_write(dev_priv, pipe, VLV_REF_DW13, reg_val);
1507 static void vlv_prepare_pll(const struct intel_crtc_state *crtc_state)
1509 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1510 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1511 enum pipe pipe = crtc->pipe;
1513 u32 bestn, bestm1, bestm2, bestp1, bestp2;
1514 u32 coreclk, reg_val;
1516 vlv_dpio_get(dev_priv);
1518 bestn = crtc_state->dpll.n;
1519 bestm1 = crtc_state->dpll.m1;
1520 bestm2 = crtc_state->dpll.m2;
1521 bestp1 = crtc_state->dpll.p1;
1522 bestp2 = crtc_state->dpll.p2;
1524 /* See eDP HDMI DPIO driver vbios notes doc */
1526 /* PLL B needs special handling */
1528 vlv_pllb_recal_opamp(dev_priv, pipe);
1530 /* Set up Tx target for periodic Rcomp update */
1531 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW9_BCAST, 0x0100000f);
1533 /* Disable target IRef on PLL */
1534 reg_val = vlv_dpio_read(dev_priv, pipe, VLV_PLL_DW8(pipe));
1535 reg_val &= 0x00ffffff;
1536 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW8(pipe), reg_val);
1538 /* Disable fast lock */
1539 vlv_dpio_write(dev_priv, pipe, VLV_CMN_DW0, 0x610);
1541 /* Set idtafcrecal before PLL is enabled */
1542 mdiv = ((bestm1 << DPIO_M1DIV_SHIFT) | (bestm2 & DPIO_M2DIV_MASK));
1543 mdiv |= ((bestp1 << DPIO_P1_SHIFT) | (bestp2 << DPIO_P2_SHIFT));
1544 mdiv |= ((bestn << DPIO_N_SHIFT));
1545 mdiv |= (1 << DPIO_K_SHIFT);
1548 * Post divider depends on pixel clock rate, DAC vs digital (and LVDS,
1549 * but we don't support that).
1550 * Note: don't use the DAC post divider as it seems unstable.
1552 mdiv |= (DPIO_POST_DIV_HDMIDP << DPIO_POST_DIV_SHIFT);
1553 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW3(pipe), mdiv);
1555 mdiv |= DPIO_ENABLE_CALIBRATION;
1556 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW3(pipe), mdiv);
1558 /* Set HBR and RBR LPF coefficients */
1559 if (crtc_state->port_clock == 162000 ||
1560 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_ANALOG) ||
1561 intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
1562 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe),
1565 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe),
1568 if (intel_crtc_has_dp_encoder(crtc_state)) {
1569 /* Use SSC source */
1571 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW5(pipe),
1574 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW5(pipe),
1576 } else { /* HDMI or VGA */
1577 /* Use bend source */
1579 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW5(pipe),
1582 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW5(pipe),
1586 coreclk = vlv_dpio_read(dev_priv, pipe, VLV_PLL_DW7(pipe));
1587 coreclk = (coreclk & 0x0000ff00) | 0x01c00000;
1588 if (intel_crtc_has_dp_encoder(crtc_state))
1589 coreclk |= 0x01000000;
1590 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW7(pipe), coreclk);
1592 vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW11(pipe), 0x87871000);
1594 vlv_dpio_put(dev_priv);
1597 static void _vlv_enable_pll(const struct intel_crtc_state *crtc_state)
1599 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1600 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1601 enum pipe pipe = crtc->pipe;
1603 intel_de_write(dev_priv, DPLL(pipe), crtc_state->dpll_hw_state.dpll);
1604 intel_de_posting_read(dev_priv, DPLL(pipe));
1607 if (intel_de_wait_for_set(dev_priv, DPLL(pipe), DPLL_LOCK_VLV, 1))
1608 drm_err(&dev_priv->drm, "DPLL %d failed to lock\n", pipe);
1611 void vlv_enable_pll(const struct intel_crtc_state *crtc_state)
1613 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1614 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1615 enum pipe pipe = crtc->pipe;
1617 assert_transcoder_disabled(dev_priv, crtc_state->cpu_transcoder);
1619 /* PLL is protected by panel, make sure we can write it */
1620 assert_panel_unlocked(dev_priv, pipe);
1623 intel_de_write(dev_priv, DPLL(pipe),
1624 crtc_state->dpll_hw_state.dpll &
1625 ~(DPLL_VCO_ENABLE | DPLL_EXT_BUFFER_ENABLE_VLV));
1627 if (crtc_state->dpll_hw_state.dpll & DPLL_VCO_ENABLE) {
1628 vlv_prepare_pll(crtc_state);
1629 _vlv_enable_pll(crtc_state);
1632 intel_de_write(dev_priv, DPLL_MD(pipe),
1633 crtc_state->dpll_hw_state.dpll_md);
1634 intel_de_posting_read(dev_priv, DPLL_MD(pipe));
1637 static void chv_prepare_pll(const struct intel_crtc_state *crtc_state)
1639 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1640 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1641 enum pipe pipe = crtc->pipe;
1642 enum dpio_channel port = vlv_pipe_to_channel(pipe);
1643 u32 loopfilter, tribuf_calcntr;
1644 u32 bestn, bestm1, bestm2, bestp1, bestp2, bestm2_frac;
1648 bestn = crtc_state->dpll.n;
1649 bestm2_frac = crtc_state->dpll.m2 & 0x3fffff;
1650 bestm1 = crtc_state->dpll.m1;
1651 bestm2 = crtc_state->dpll.m2 >> 22;
1652 bestp1 = crtc_state->dpll.p1;
1653 bestp2 = crtc_state->dpll.p2;
1654 vco = crtc_state->dpll.vco;
1658 vlv_dpio_get(dev_priv);
1660 /* p1 and p2 divider */
1661 vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW13(port),
1662 5 << DPIO_CHV_S1_DIV_SHIFT |
1663 bestp1 << DPIO_CHV_P1_DIV_SHIFT |
1664 bestp2 << DPIO_CHV_P2_DIV_SHIFT |
1665 1 << DPIO_CHV_K_DIV_SHIFT);
1667 /* Feedback post-divider - m2 */
1668 vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW0(port), bestm2);
1670 /* Feedback refclk divider - n and m1 */
1671 vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW1(port),
1672 DPIO_CHV_M1_DIV_BY_2 |
1673 1 << DPIO_CHV_N_DIV_SHIFT);
1675 /* M2 fraction division */
1676 vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW2(port), bestm2_frac);
1678 /* M2 fraction division enable */
1679 dpio_val = vlv_dpio_read(dev_priv, pipe, CHV_PLL_DW3(port));
1680 dpio_val &= ~(DPIO_CHV_FEEDFWD_GAIN_MASK | DPIO_CHV_FRAC_DIV_EN);
1681 dpio_val |= (2 << DPIO_CHV_FEEDFWD_GAIN_SHIFT);
1683 dpio_val |= DPIO_CHV_FRAC_DIV_EN;
1684 vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW3(port), dpio_val);
1686 /* Program digital lock detect threshold */
1687 dpio_val = vlv_dpio_read(dev_priv, pipe, CHV_PLL_DW9(port));
1688 dpio_val &= ~(DPIO_CHV_INT_LOCK_THRESHOLD_MASK |
1689 DPIO_CHV_INT_LOCK_THRESHOLD_SEL_COARSE);
1690 dpio_val |= (0x5 << DPIO_CHV_INT_LOCK_THRESHOLD_SHIFT);
1692 dpio_val |= DPIO_CHV_INT_LOCK_THRESHOLD_SEL_COARSE;
1693 vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW9(port), dpio_val);
1696 if (vco == 5400000) {
1697 loopfilter |= (0x3 << DPIO_CHV_PROP_COEFF_SHIFT);
1698 loopfilter |= (0x8 << DPIO_CHV_INT_COEFF_SHIFT);
1699 loopfilter |= (0x1 << DPIO_CHV_GAIN_CTRL_SHIFT);
1700 tribuf_calcntr = 0x9;
1701 } else if (vco <= 6200000) {
1702 loopfilter |= (0x5 << DPIO_CHV_PROP_COEFF_SHIFT);
1703 loopfilter |= (0xB << DPIO_CHV_INT_COEFF_SHIFT);
1704 loopfilter |= (0x3 << DPIO_CHV_GAIN_CTRL_SHIFT);
1705 tribuf_calcntr = 0x9;
1706 } else if (vco <= 6480000) {
1707 loopfilter |= (0x4 << DPIO_CHV_PROP_COEFF_SHIFT);
1708 loopfilter |= (0x9 << DPIO_CHV_INT_COEFF_SHIFT);
1709 loopfilter |= (0x3 << DPIO_CHV_GAIN_CTRL_SHIFT);
1710 tribuf_calcntr = 0x8;
1712 /* Not supported. Apply the same limits as in the max case */
1713 loopfilter |= (0x4 << DPIO_CHV_PROP_COEFF_SHIFT);
1714 loopfilter |= (0x9 << DPIO_CHV_INT_COEFF_SHIFT);
1715 loopfilter |= (0x3 << DPIO_CHV_GAIN_CTRL_SHIFT);
1718 vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW6(port), loopfilter);
1720 dpio_val = vlv_dpio_read(dev_priv, pipe, CHV_PLL_DW8(port));
1721 dpio_val &= ~DPIO_CHV_TDC_TARGET_CNT_MASK;
1722 dpio_val |= (tribuf_calcntr << DPIO_CHV_TDC_TARGET_CNT_SHIFT);
1723 vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW8(port), dpio_val);
1726 vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW14(port),
1727 vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW14(port)) |
1730 vlv_dpio_put(dev_priv);
1733 static void _chv_enable_pll(const struct intel_crtc_state *crtc_state)
1735 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1736 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1737 enum pipe pipe = crtc->pipe;
1738 enum dpio_channel port = vlv_pipe_to_channel(pipe);
1741 vlv_dpio_get(dev_priv);
1743 /* Enable back the 10bit clock to display controller */
1744 tmp = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW14(port));
1745 tmp |= DPIO_DCLKP_EN;
1746 vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW14(port), tmp);
1748 vlv_dpio_put(dev_priv);
1751 * Need to wait > 100ns between dclkp clock enable bit and PLL enable.
1756 intel_de_write(dev_priv, DPLL(pipe), crtc_state->dpll_hw_state.dpll);
1758 /* Check PLL is locked */
1759 if (intel_de_wait_for_set(dev_priv, DPLL(pipe), DPLL_LOCK_VLV, 1))
1760 drm_err(&dev_priv->drm, "PLL %d failed to lock\n", pipe);
1763 void chv_enable_pll(const struct intel_crtc_state *crtc_state)
1765 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1766 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1767 enum pipe pipe = crtc->pipe;
1769 assert_transcoder_disabled(dev_priv, crtc_state->cpu_transcoder);
1771 /* PLL is protected by panel, make sure we can write it */
1772 assert_panel_unlocked(dev_priv, pipe);
1774 /* Enable Refclk and SSC */
1775 intel_de_write(dev_priv, DPLL(pipe),
1776 crtc_state->dpll_hw_state.dpll & ~DPLL_VCO_ENABLE);
1778 if (crtc_state->dpll_hw_state.dpll & DPLL_VCO_ENABLE) {
1779 chv_prepare_pll(crtc_state);
1780 _chv_enable_pll(crtc_state);
1783 if (pipe != PIPE_A) {
1785 * WaPixelRepeatModeFixForC0:chv
1787 * DPLLCMD is AWOL. Use chicken bits to propagate
1788 * the value from DPLLBMD to either pipe B or C.
1790 intel_de_write(dev_priv, CBR4_VLV, CBR_DPLLBMD_PIPE(pipe));
1791 intel_de_write(dev_priv, DPLL_MD(PIPE_B),
1792 crtc_state->dpll_hw_state.dpll_md);
1793 intel_de_write(dev_priv, CBR4_VLV, 0);
1794 dev_priv->chv_dpll_md[pipe] = crtc_state->dpll_hw_state.dpll_md;
1797 * DPLLB VGA mode also seems to cause problems.
1798 * We should always have it disabled.
1800 drm_WARN_ON(&dev_priv->drm,
1801 (intel_de_read(dev_priv, DPLL(PIPE_B)) &
1802 DPLL_VGA_MODE_DIS) == 0);
1804 intel_de_write(dev_priv, DPLL_MD(pipe),
1805 crtc_state->dpll_hw_state.dpll_md);
1806 intel_de_posting_read(dev_priv, DPLL_MD(pipe));
1811 * vlv_force_pll_on - forcibly enable just the PLL
1812 * @dev_priv: i915 private structure
1813 * @pipe: pipe PLL to enable
1814 * @dpll: PLL configuration
1816 * Enable the PLL for @pipe using the supplied @dpll config. To be used
1817 * in cases where we need the PLL enabled even when @pipe is not going to
1820 int vlv_force_pll_on(struct drm_i915_private *dev_priv, enum pipe pipe,
1821 const struct dpll *dpll)
1823 struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
1824 struct intel_crtc_state *crtc_state;
1826 crtc_state = intel_crtc_state_alloc(crtc);
1830 crtc_state->cpu_transcoder = (enum transcoder)pipe;
1831 crtc_state->pixel_multiplier = 1;
1832 crtc_state->dpll = *dpll;
1833 crtc_state->output_types = BIT(INTEL_OUTPUT_EDP);
1835 if (IS_CHERRYVIEW(dev_priv)) {
1836 chv_compute_dpll(crtc_state);
1837 chv_enable_pll(crtc_state);
1839 vlv_compute_dpll(crtc_state);
1840 vlv_enable_pll(crtc_state);
1848 void vlv_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe)
1852 /* Make sure the pipe isn't still relying on us */
1853 assert_transcoder_disabled(dev_priv, (enum transcoder)pipe);
1855 val = DPLL_INTEGRATED_REF_CLK_VLV |
1856 DPLL_REF_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS;
1858 val |= DPLL_INTEGRATED_CRI_CLK_VLV;
1860 intel_de_write(dev_priv, DPLL(pipe), val);
1861 intel_de_posting_read(dev_priv, DPLL(pipe));
1864 void chv_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe)
1866 enum dpio_channel port = vlv_pipe_to_channel(pipe);
1869 /* Make sure the pipe isn't still relying on us */
1870 assert_transcoder_disabled(dev_priv, (enum transcoder)pipe);
1872 val = DPLL_SSC_REF_CLK_CHV |
1873 DPLL_REF_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS;
1875 val |= DPLL_INTEGRATED_CRI_CLK_VLV;
1877 intel_de_write(dev_priv, DPLL(pipe), val);
1878 intel_de_posting_read(dev_priv, DPLL(pipe));
1880 vlv_dpio_get(dev_priv);
1882 /* Disable 10bit clock to display controller */
1883 val = vlv_dpio_read(dev_priv, pipe, CHV_CMN_DW14(port));
1884 val &= ~DPIO_DCLKP_EN;
1885 vlv_dpio_write(dev_priv, pipe, CHV_CMN_DW14(port), val);
1887 vlv_dpio_put(dev_priv);
1890 void i9xx_disable_pll(const struct intel_crtc_state *crtc_state)
1892 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
1893 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
1894 enum pipe pipe = crtc->pipe;
1896 /* Don't disable pipe or pipe PLLs if needed */
1897 if (IS_I830(dev_priv))
1900 /* Make sure the pipe isn't still relying on us */
1901 assert_transcoder_disabled(dev_priv, crtc_state->cpu_transcoder);
1903 intel_de_write(dev_priv, DPLL(pipe), DPLL_VGA_MODE_DIS);
1904 intel_de_posting_read(dev_priv, DPLL(pipe));
1909 * vlv_force_pll_off - forcibly disable just the PLL
1910 * @dev_priv: i915 private structure
1911 * @pipe: pipe PLL to disable
1913 * Disable the PLL for @pipe. To be used in cases where we need
1914 * the PLL enabled even when @pipe is not going to be enabled.
1916 void vlv_force_pll_off(struct drm_i915_private *dev_priv, enum pipe pipe)
1918 if (IS_CHERRYVIEW(dev_priv))
1919 chv_disable_pll(dev_priv, pipe);
1921 vlv_disable_pll(dev_priv, pipe);