2 * Copyright © 2006-2016 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 * Display PLLs used for driving outputs vary by platform. While some have
30 * per-pipe or per-encoder dedicated PLLs, others allow the use of any PLL
31 * from a pool. In the latter scenario, it is possible that multiple pipes
32 * share a PLL if their configurations match.
34 * This file provides an abstraction over display PLLs. The function
35 * intel_shared_dpll_init() initializes the PLLs for the given platform. The
36 * users of a PLL are tracked and that tracking is integrated with the atomic
37 * modest interface. During an atomic operation, a PLL can be requested for a
38 * given CRTC and encoder configuration by calling intel_get_shared_dpll() and
39 * a previously used PLL can be released with intel_release_shared_dpll().
40 * Changes to the users are first staged in the atomic state, and then made
41 * effective by calling intel_shared_dpll_swap_state() during the atomic
45 struct intel_shared_dpll
*
46 skl_find_link_pll(struct drm_i915_private
*dev_priv
, int clock
)
48 struct intel_shared_dpll
*pll
= NULL
;
49 struct intel_dpll_hw_state dpll_hw_state
;
53 if (!skl_ddi_dp_set_dpll_hw_state(clock
, &dpll_hw_state
))
56 for (i
= DPLL_ID_SKL_DPLL1
; i
<= DPLL_ID_SKL_DPLL3
; i
++) {
57 pll
= &dev_priv
->shared_dplls
[i
];
59 /* Only want to check enabled timings first */
60 if (pll
->state
.crtc_mask
== 0)
63 if (memcmp(&dpll_hw_state
, &pll
->state
.hw_state
,
64 sizeof(pll
->state
.hw_state
)) == 0) {
70 /* Ok no matching timings, maybe there's a free one? */
71 for (i
= DPLL_ID_SKL_DPLL1
;
72 ((found
== false) && (i
<= DPLL_ID_SKL_DPLL3
)); i
++) {
73 pll
= &dev_priv
->shared_dplls
[i
];
74 if (pll
->state
.crtc_mask
== 0) {
75 pll
->state
.hw_state
= dpll_hw_state
;
84 intel_atomic_duplicate_dpll_state(struct drm_i915_private
*dev_priv
,
85 struct intel_shared_dpll_state
*shared_dpll
)
89 /* Copy shared dpll state */
90 for (i
= 0; i
< dev_priv
->num_shared_dpll
; i
++) {
91 struct intel_shared_dpll
*pll
= &dev_priv
->shared_dplls
[i
];
93 shared_dpll
[i
] = pll
->state
;
97 static struct intel_shared_dpll_state
*
98 intel_atomic_get_shared_dpll_state(struct drm_atomic_state
*s
)
100 struct intel_atomic_state
*state
= to_intel_atomic_state(s
);
102 WARN_ON(!drm_modeset_is_locked(&s
->dev
->mode_config
.connection_mutex
));
104 if (!state
->dpll_set
) {
105 state
->dpll_set
= true;
107 intel_atomic_duplicate_dpll_state(to_i915(s
->dev
),
111 return state
->shared_dpll
;
115 * intel_get_shared_dpll_by_id - get a DPLL given its id
116 * @dev_priv: i915 device instance
120 * A pointer to the DPLL with @id
122 struct intel_shared_dpll
*
123 intel_get_shared_dpll_by_id(struct drm_i915_private
*dev_priv
,
124 enum intel_dpll_id id
)
126 return &dev_priv
->shared_dplls
[id
];
130 * intel_get_shared_dpll_id - get the id of a DPLL
131 * @dev_priv: i915 device instance
138 intel_get_shared_dpll_id(struct drm_i915_private
*dev_priv
,
139 struct intel_shared_dpll
*pll
)
141 if (WARN_ON(pll
< dev_priv
->shared_dplls
||
142 pll
> &dev_priv
->shared_dplls
[dev_priv
->num_shared_dpll
]))
145 return (enum intel_dpll_id
) (pll
- dev_priv
->shared_dplls
);
149 void assert_shared_dpll(struct drm_i915_private
*dev_priv
,
150 struct intel_shared_dpll
*pll
,
154 struct intel_dpll_hw_state hw_state
;
156 if (WARN(!pll
, "asserting DPLL %s with no DPLL\n", onoff(state
)))
159 cur_state
= pll
->funcs
.get_hw_state(dev_priv
, pll
, &hw_state
);
160 I915_STATE_WARN(cur_state
!= state
,
161 "%s assertion failure (expected %s, current %s)\n",
162 pll
->name
, onoff(state
), onoff(cur_state
));
166 * intel_prepare_shared_dpll - call a dpll's prepare hook
167 * @crtc: CRTC which has a shared dpll
169 * This calls the PLL's prepare hook if it has one and if the PLL is not
170 * already enabled. The prepare hook is platform specific.
172 void intel_prepare_shared_dpll(struct intel_crtc
*crtc
)
174 struct drm_device
*dev
= crtc
->base
.dev
;
175 struct drm_i915_private
*dev_priv
= to_i915(dev
);
176 struct intel_shared_dpll
*pll
= crtc
->config
->shared_dpll
;
178 if (WARN_ON(pll
== NULL
))
181 mutex_lock(&dev_priv
->dpll_lock
);
182 WARN_ON(!pll
->state
.crtc_mask
);
183 if (!pll
->active_mask
) {
184 DRM_DEBUG_DRIVER("setting up %s\n", pll
->name
);
186 assert_shared_dpll_disabled(dev_priv
, pll
);
188 pll
->funcs
.prepare(dev_priv
, pll
);
190 mutex_unlock(&dev_priv
->dpll_lock
);
194 * intel_enable_shared_dpll - enable a CRTC's shared DPLL
195 * @crtc: CRTC which has a shared DPLL
197 * Enable the shared DPLL used by @crtc.
199 void intel_enable_shared_dpll(struct intel_crtc
*crtc
)
201 struct drm_device
*dev
= crtc
->base
.dev
;
202 struct drm_i915_private
*dev_priv
= to_i915(dev
);
203 struct intel_shared_dpll
*pll
= crtc
->config
->shared_dpll
;
204 unsigned crtc_mask
= 1 << drm_crtc_index(&crtc
->base
);
207 if (WARN_ON(pll
== NULL
))
210 mutex_lock(&dev_priv
->dpll_lock
);
211 old_mask
= pll
->active_mask
;
213 if (WARN_ON(!(pll
->state
.crtc_mask
& crtc_mask
)) ||
214 WARN_ON(pll
->active_mask
& crtc_mask
))
217 pll
->active_mask
|= crtc_mask
;
219 DRM_DEBUG_KMS("enable %s (active %x, on? %d) for crtc %d\n",
220 pll
->name
, pll
->active_mask
, pll
->on
,
225 assert_shared_dpll_enabled(dev_priv
, pll
);
230 DRM_DEBUG_KMS("enabling %s\n", pll
->name
);
231 pll
->funcs
.enable(dev_priv
, pll
);
235 mutex_unlock(&dev_priv
->dpll_lock
);
239 * intel_disable_shared_dpll - disable a CRTC's shared DPLL
240 * @crtc: CRTC which has a shared DPLL
242 * Disable the shared DPLL used by @crtc.
244 void intel_disable_shared_dpll(struct intel_crtc
*crtc
)
246 struct drm_i915_private
*dev_priv
= to_i915(crtc
->base
.dev
);
247 struct intel_shared_dpll
*pll
= crtc
->config
->shared_dpll
;
248 unsigned crtc_mask
= 1 << drm_crtc_index(&crtc
->base
);
250 /* PCH only available on ILK+ */
251 if (INTEL_GEN(dev_priv
) < 5)
257 mutex_lock(&dev_priv
->dpll_lock
);
258 if (WARN_ON(!(pll
->active_mask
& crtc_mask
)))
261 DRM_DEBUG_KMS("disable %s (active %x, on? %d) for crtc %d\n",
262 pll
->name
, pll
->active_mask
, pll
->on
,
265 assert_shared_dpll_enabled(dev_priv
, pll
);
268 pll
->active_mask
&= ~crtc_mask
;
269 if (pll
->active_mask
)
272 DRM_DEBUG_KMS("disabling %s\n", pll
->name
);
273 pll
->funcs
.disable(dev_priv
, pll
);
277 mutex_unlock(&dev_priv
->dpll_lock
);
280 static struct intel_shared_dpll
*
281 intel_find_shared_dpll(struct intel_crtc
*crtc
,
282 struct intel_crtc_state
*crtc_state
,
283 enum intel_dpll_id range_min
,
284 enum intel_dpll_id range_max
)
286 struct drm_i915_private
*dev_priv
= to_i915(crtc
->base
.dev
);
287 struct intel_shared_dpll
*pll
;
288 struct intel_shared_dpll_state
*shared_dpll
;
289 enum intel_dpll_id i
;
291 shared_dpll
= intel_atomic_get_shared_dpll_state(crtc_state
->base
.state
);
293 for (i
= range_min
; i
<= range_max
; i
++) {
294 pll
= &dev_priv
->shared_dplls
[i
];
296 /* Only want to check enabled timings first */
297 if (shared_dpll
[i
].crtc_mask
== 0)
300 if (memcmp(&crtc_state
->dpll_hw_state
,
301 &shared_dpll
[i
].hw_state
,
302 sizeof(crtc_state
->dpll_hw_state
)) == 0) {
303 DRM_DEBUG_KMS("[CRTC:%d:%s] sharing existing %s (crtc mask 0x%08x, active %x)\n",
304 crtc
->base
.base
.id
, crtc
->base
.name
, pll
->name
,
305 shared_dpll
[i
].crtc_mask
,
311 /* Ok no matching timings, maybe there's a free one? */
312 for (i
= range_min
; i
<= range_max
; i
++) {
313 pll
= &dev_priv
->shared_dplls
[i
];
314 if (shared_dpll
[i
].crtc_mask
== 0) {
315 DRM_DEBUG_KMS("[CRTC:%d:%s] allocated %s\n",
316 crtc
->base
.base
.id
, crtc
->base
.name
, pll
->name
);
325 intel_reference_shared_dpll(struct intel_shared_dpll
*pll
,
326 struct intel_crtc_state
*crtc_state
)
328 struct intel_shared_dpll_state
*shared_dpll
;
329 struct intel_crtc
*crtc
= to_intel_crtc(crtc_state
->base
.crtc
);
330 enum intel_dpll_id i
= pll
->id
;
332 shared_dpll
= intel_atomic_get_shared_dpll_state(crtc_state
->base
.state
);
334 if (shared_dpll
[i
].crtc_mask
== 0)
335 shared_dpll
[i
].hw_state
=
336 crtc_state
->dpll_hw_state
;
338 crtc_state
->shared_dpll
= pll
;
339 DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll
->name
,
340 pipe_name(crtc
->pipe
));
342 shared_dpll
[pll
->id
].crtc_mask
|= 1 << crtc
->pipe
;
346 * intel_shared_dpll_swap_state - make atomic DPLL configuration effective
347 * @state: atomic state
349 * This is the dpll version of drm_atomic_helper_swap_state() since the
350 * helper does not handle driver-specific global state.
352 * For consistency with atomic helpers this function does a complete swap,
353 * i.e. it also puts the current state into @state, even though there is no
354 * need for that at this moment.
356 void intel_shared_dpll_swap_state(struct drm_atomic_state
*state
)
358 struct drm_i915_private
*dev_priv
= to_i915(state
->dev
);
359 struct intel_shared_dpll_state
*shared_dpll
;
360 struct intel_shared_dpll
*pll
;
361 enum intel_dpll_id i
;
363 if (!to_intel_atomic_state(state
)->dpll_set
)
366 shared_dpll
= to_intel_atomic_state(state
)->shared_dpll
;
367 for (i
= 0; i
< dev_priv
->num_shared_dpll
; i
++) {
368 struct intel_shared_dpll_state tmp
;
370 pll
= &dev_priv
->shared_dplls
[i
];
373 pll
->state
= shared_dpll
[i
];
374 shared_dpll
[i
] = tmp
;
378 static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private
*dev_priv
,
379 struct intel_shared_dpll
*pll
,
380 struct intel_dpll_hw_state
*hw_state
)
384 if (!intel_display_power_get_if_enabled(dev_priv
, POWER_DOMAIN_PLLS
))
387 val
= I915_READ(PCH_DPLL(pll
->id
));
388 hw_state
->dpll
= val
;
389 hw_state
->fp0
= I915_READ(PCH_FP0(pll
->id
));
390 hw_state
->fp1
= I915_READ(PCH_FP1(pll
->id
));
392 intel_display_power_put(dev_priv
, POWER_DOMAIN_PLLS
);
394 return val
& DPLL_VCO_ENABLE
;
397 static void ibx_pch_dpll_prepare(struct drm_i915_private
*dev_priv
,
398 struct intel_shared_dpll
*pll
)
400 I915_WRITE(PCH_FP0(pll
->id
), pll
->state
.hw_state
.fp0
);
401 I915_WRITE(PCH_FP1(pll
->id
), pll
->state
.hw_state
.fp1
);
404 static void ibx_assert_pch_refclk_enabled(struct drm_i915_private
*dev_priv
)
409 I915_STATE_WARN_ON(!(HAS_PCH_IBX(dev_priv
) || HAS_PCH_CPT(dev_priv
)));
411 val
= I915_READ(PCH_DREF_CONTROL
);
412 enabled
= !!(val
& (DREF_SSC_SOURCE_MASK
| DREF_NONSPREAD_SOURCE_MASK
|
413 DREF_SUPERSPREAD_SOURCE_MASK
));
414 I915_STATE_WARN(!enabled
, "PCH refclk assertion failure, should be active but is disabled\n");
417 static void ibx_pch_dpll_enable(struct drm_i915_private
*dev_priv
,
418 struct intel_shared_dpll
*pll
)
420 /* PCH refclock must be enabled first */
421 ibx_assert_pch_refclk_enabled(dev_priv
);
423 I915_WRITE(PCH_DPLL(pll
->id
), pll
->state
.hw_state
.dpll
);
425 /* Wait for the clocks to stabilize. */
426 POSTING_READ(PCH_DPLL(pll
->id
));
429 /* The pixel multiplier can only be updated once the
430 * DPLL is enabled and the clocks are stable.
434 I915_WRITE(PCH_DPLL(pll
->id
), pll
->state
.hw_state
.dpll
);
435 POSTING_READ(PCH_DPLL(pll
->id
));
439 static void ibx_pch_dpll_disable(struct drm_i915_private
*dev_priv
,
440 struct intel_shared_dpll
*pll
)
442 struct drm_device
*dev
= &dev_priv
->drm
;
443 struct intel_crtc
*crtc
;
445 /* Make sure no transcoder isn't still depending on us. */
446 for_each_intel_crtc(dev
, crtc
) {
447 if (crtc
->config
->shared_dpll
== pll
)
448 assert_pch_transcoder_disabled(dev_priv
, crtc
->pipe
);
451 I915_WRITE(PCH_DPLL(pll
->id
), 0);
452 POSTING_READ(PCH_DPLL(pll
->id
));
456 static struct intel_shared_dpll
*
457 ibx_get_dpll(struct intel_crtc
*crtc
, struct intel_crtc_state
*crtc_state
,
458 struct intel_encoder
*encoder
)
460 struct drm_i915_private
*dev_priv
= to_i915(crtc
->base
.dev
);
461 struct intel_shared_dpll
*pll
;
462 enum intel_dpll_id i
;
464 if (HAS_PCH_IBX(dev_priv
)) {
465 /* Ironlake PCH has a fixed PLL->PCH pipe mapping. */
466 i
= (enum intel_dpll_id
) crtc
->pipe
;
467 pll
= &dev_priv
->shared_dplls
[i
];
469 DRM_DEBUG_KMS("[CRTC:%d:%s] using pre-allocated %s\n",
470 crtc
->base
.base
.id
, crtc
->base
.name
, pll
->name
);
472 pll
= intel_find_shared_dpll(crtc
, crtc_state
,
480 /* reference the pll */
481 intel_reference_shared_dpll(pll
, crtc_state
);
486 static void ibx_dump_hw_state(struct drm_i915_private
*dev_priv
,
487 struct intel_dpll_hw_state
*hw_state
)
489 DRM_DEBUG_KMS("dpll_hw_state: dpll: 0x%x, dpll_md: 0x%x, "
490 "fp0: 0x%x, fp1: 0x%x\n",
497 static const struct intel_shared_dpll_funcs ibx_pch_dpll_funcs
= {
498 .prepare
= ibx_pch_dpll_prepare
,
499 .enable
= ibx_pch_dpll_enable
,
500 .disable
= ibx_pch_dpll_disable
,
501 .get_hw_state
= ibx_pch_dpll_get_hw_state
,
504 static void hsw_ddi_wrpll_enable(struct drm_i915_private
*dev_priv
,
505 struct intel_shared_dpll
*pll
)
507 I915_WRITE(WRPLL_CTL(pll
->id
), pll
->state
.hw_state
.wrpll
);
508 POSTING_READ(WRPLL_CTL(pll
->id
));
512 static void hsw_ddi_spll_enable(struct drm_i915_private
*dev_priv
,
513 struct intel_shared_dpll
*pll
)
515 I915_WRITE(SPLL_CTL
, pll
->state
.hw_state
.spll
);
516 POSTING_READ(SPLL_CTL
);
520 static void hsw_ddi_wrpll_disable(struct drm_i915_private
*dev_priv
,
521 struct intel_shared_dpll
*pll
)
525 val
= I915_READ(WRPLL_CTL(pll
->id
));
526 I915_WRITE(WRPLL_CTL(pll
->id
), val
& ~WRPLL_PLL_ENABLE
);
527 POSTING_READ(WRPLL_CTL(pll
->id
));
530 static void hsw_ddi_spll_disable(struct drm_i915_private
*dev_priv
,
531 struct intel_shared_dpll
*pll
)
535 val
= I915_READ(SPLL_CTL
);
536 I915_WRITE(SPLL_CTL
, val
& ~SPLL_PLL_ENABLE
);
537 POSTING_READ(SPLL_CTL
);
540 static bool hsw_ddi_wrpll_get_hw_state(struct drm_i915_private
*dev_priv
,
541 struct intel_shared_dpll
*pll
,
542 struct intel_dpll_hw_state
*hw_state
)
546 if (!intel_display_power_get_if_enabled(dev_priv
, POWER_DOMAIN_PLLS
))
549 val
= I915_READ(WRPLL_CTL(pll
->id
));
550 hw_state
->wrpll
= val
;
552 intel_display_power_put(dev_priv
, POWER_DOMAIN_PLLS
);
554 return val
& WRPLL_PLL_ENABLE
;
557 static bool hsw_ddi_spll_get_hw_state(struct drm_i915_private
*dev_priv
,
558 struct intel_shared_dpll
*pll
,
559 struct intel_dpll_hw_state
*hw_state
)
563 if (!intel_display_power_get_if_enabled(dev_priv
, POWER_DOMAIN_PLLS
))
566 val
= I915_READ(SPLL_CTL
);
567 hw_state
->spll
= val
;
569 intel_display_power_put(dev_priv
, POWER_DOMAIN_PLLS
);
571 return val
& SPLL_PLL_ENABLE
;
575 #define LC_FREQ_2K U64_C(LC_FREQ * 2000)
581 /* Constraints for PLL good behavior */
587 struct hsw_wrpll_rnp
{
591 static unsigned hsw_wrpll_get_budget_for_freq(int clock
)
665 static void hsw_wrpll_update_rnp(uint64_t freq2k
, unsigned budget
,
666 unsigned r2
, unsigned n2
, unsigned p
,
667 struct hsw_wrpll_rnp
*best
)
669 uint64_t a
, b
, c
, d
, diff
, diff_best
;
671 /* No best (r,n,p) yet */
680 * Output clock is (LC_FREQ_2K / 2000) * N / (P * R), which compares to
684 * abs(freq2k - (LC_FREQ_2K * n2/(p * r2))) /
687 * and we would like delta <= budget.
689 * If the discrepancy is above the PPM-based budget, always prefer to
690 * improve upon the previous solution. However, if you're within the
691 * budget, try to maximize Ref * VCO, that is N / (P * R^2).
693 a
= freq2k
* budget
* p
* r2
;
694 b
= freq2k
* budget
* best
->p
* best
->r2
;
695 diff
= abs_diff(freq2k
* p
* r2
, LC_FREQ_2K
* n2
);
696 diff_best
= abs_diff(freq2k
* best
->p
* best
->r2
,
697 LC_FREQ_2K
* best
->n2
);
699 d
= 1000000 * diff_best
;
701 if (a
< c
&& b
< d
) {
702 /* If both are above the budget, pick the closer */
703 if (best
->p
* best
->r2
* diff
< p
* r2
* diff_best
) {
708 } else if (a
>= c
&& b
< d
) {
709 /* If A is below the threshold but B is above it? Update. */
713 } else if (a
>= c
&& b
>= d
) {
714 /* Both are below the limit, so pick the higher n2/(r2*r2) */
715 if (n2
* best
->r2
* best
->r2
> best
->n2
* r2
* r2
) {
721 /* Otherwise a < c && b >= d, do nothing */
725 hsw_ddi_calculate_wrpll(int clock
/* in Hz */,
726 unsigned *r2_out
, unsigned *n2_out
, unsigned *p_out
)
730 struct hsw_wrpll_rnp best
= { 0, 0, 0 };
733 freq2k
= clock
/ 100;
735 budget
= hsw_wrpll_get_budget_for_freq(clock
);
737 /* Special case handling for 540 pixel clock: bypass WR PLL entirely
738 * and directly pass the LC PLL to it. */
739 if (freq2k
== 5400000) {
747 * Ref = LC_FREQ / R, where Ref is the actual reference input seen by
750 * We want R so that REF_MIN <= Ref <= REF_MAX.
751 * Injecting R2 = 2 * R gives:
752 * REF_MAX * r2 > LC_FREQ * 2 and
753 * REF_MIN * r2 < LC_FREQ * 2
755 * Which means the desired boundaries for r2 are:
756 * LC_FREQ * 2 / REF_MAX < r2 < LC_FREQ * 2 / REF_MIN
759 for (r2
= LC_FREQ
* 2 / REF_MAX
+ 1;
760 r2
<= LC_FREQ
* 2 / REF_MIN
;
764 * VCO = N * Ref, that is: VCO = N * LC_FREQ / R
766 * Once again we want VCO_MIN <= VCO <= VCO_MAX.
767 * Injecting R2 = 2 * R and N2 = 2 * N, we get:
768 * VCO_MAX * r2 > n2 * LC_FREQ and
769 * VCO_MIN * r2 < n2 * LC_FREQ)
771 * Which means the desired boundaries for n2 are:
772 * VCO_MIN * r2 / LC_FREQ < n2 < VCO_MAX * r2 / LC_FREQ
774 for (n2
= VCO_MIN
* r2
/ LC_FREQ
+ 1;
775 n2
<= VCO_MAX
* r2
/ LC_FREQ
;
778 for (p
= P_MIN
; p
<= P_MAX
; p
+= P_INC
)
779 hsw_wrpll_update_rnp(freq2k
, budget
,
789 static struct intel_shared_dpll
*hsw_ddi_hdmi_get_dpll(int clock
,
790 struct intel_crtc
*crtc
,
791 struct intel_crtc_state
*crtc_state
)
793 struct intel_shared_dpll
*pll
;
795 unsigned int p
, n2
, r2
;
797 hsw_ddi_calculate_wrpll(clock
* 1000, &r2
, &n2
, &p
);
799 val
= WRPLL_PLL_ENABLE
| WRPLL_PLL_LCPLL
|
800 WRPLL_DIVIDER_REFERENCE(r2
) | WRPLL_DIVIDER_FEEDBACK(n2
) |
801 WRPLL_DIVIDER_POST(p
);
803 crtc_state
->dpll_hw_state
.wrpll
= val
;
805 pll
= intel_find_shared_dpll(crtc
, crtc_state
,
806 DPLL_ID_WRPLL1
, DPLL_ID_WRPLL2
);
814 struct intel_shared_dpll
*hsw_ddi_dp_get_dpll(struct intel_encoder
*encoder
,
817 struct drm_i915_private
*dev_priv
= to_i915(encoder
->base
.dev
);
818 struct intel_shared_dpll
*pll
;
819 enum intel_dpll_id pll_id
;
823 pll_id
= DPLL_ID_LCPLL_810
;
826 pll_id
= DPLL_ID_LCPLL_1350
;
829 pll_id
= DPLL_ID_LCPLL_2700
;
832 DRM_DEBUG_KMS("Invalid clock for DP: %d\n", clock
);
836 pll
= intel_get_shared_dpll_by_id(dev_priv
, pll_id
);
844 static struct intel_shared_dpll
*
845 hsw_get_dpll(struct intel_crtc
*crtc
, struct intel_crtc_state
*crtc_state
,
846 struct intel_encoder
*encoder
)
848 struct intel_shared_dpll
*pll
;
849 int clock
= crtc_state
->port_clock
;
851 memset(&crtc_state
->dpll_hw_state
, 0,
852 sizeof(crtc_state
->dpll_hw_state
));
854 if (encoder
->type
== INTEL_OUTPUT_HDMI
) {
855 pll
= hsw_ddi_hdmi_get_dpll(clock
, crtc
, crtc_state
);
857 } else if (encoder
->type
== INTEL_OUTPUT_DP
||
858 encoder
->type
== INTEL_OUTPUT_DP_MST
||
859 encoder
->type
== INTEL_OUTPUT_EDP
) {
860 pll
= hsw_ddi_dp_get_dpll(encoder
, clock
);
862 } else if (encoder
->type
== INTEL_OUTPUT_ANALOG
) {
863 if (WARN_ON(crtc_state
->port_clock
/ 2 != 135000))
866 crtc_state
->dpll_hw_state
.spll
=
867 SPLL_PLL_ENABLE
| SPLL_PLL_FREQ_1350MHz
| SPLL_PLL_SSC
;
869 pll
= intel_find_shared_dpll(crtc
, crtc_state
,
870 DPLL_ID_SPLL
, DPLL_ID_SPLL
);
878 intel_reference_shared_dpll(pll
, crtc_state
);
883 static void hsw_dump_hw_state(struct drm_i915_private
*dev_priv
,
884 struct intel_dpll_hw_state
*hw_state
)
886 DRM_DEBUG_KMS("dpll_hw_state: wrpll: 0x%x spll: 0x%x\n",
887 hw_state
->wrpll
, hw_state
->spll
);
890 static const struct intel_shared_dpll_funcs hsw_ddi_wrpll_funcs
= {
891 .enable
= hsw_ddi_wrpll_enable
,
892 .disable
= hsw_ddi_wrpll_disable
,
893 .get_hw_state
= hsw_ddi_wrpll_get_hw_state
,
896 static const struct intel_shared_dpll_funcs hsw_ddi_spll_funcs
= {
897 .enable
= hsw_ddi_spll_enable
,
898 .disable
= hsw_ddi_spll_disable
,
899 .get_hw_state
= hsw_ddi_spll_get_hw_state
,
902 static void hsw_ddi_lcpll_enable(struct drm_i915_private
*dev_priv
,
903 struct intel_shared_dpll
*pll
)
907 static void hsw_ddi_lcpll_disable(struct drm_i915_private
*dev_priv
,
908 struct intel_shared_dpll
*pll
)
912 static bool hsw_ddi_lcpll_get_hw_state(struct drm_i915_private
*dev_priv
,
913 struct intel_shared_dpll
*pll
,
914 struct intel_dpll_hw_state
*hw_state
)
919 static const struct intel_shared_dpll_funcs hsw_ddi_lcpll_funcs
= {
920 .enable
= hsw_ddi_lcpll_enable
,
921 .disable
= hsw_ddi_lcpll_disable
,
922 .get_hw_state
= hsw_ddi_lcpll_get_hw_state
,
925 struct skl_dpll_regs
{
926 i915_reg_t ctl
, cfgcr1
, cfgcr2
;
929 /* this array is indexed by the *shared* pll id */
930 static const struct skl_dpll_regs skl_dpll_regs
[4] = {
934 /* DPLL 0 doesn't support HDMI mode */
939 .cfgcr1
= DPLL_CFGCR1(SKL_DPLL1
),
940 .cfgcr2
= DPLL_CFGCR2(SKL_DPLL1
),
945 .cfgcr1
= DPLL_CFGCR1(SKL_DPLL2
),
946 .cfgcr2
= DPLL_CFGCR2(SKL_DPLL2
),
951 .cfgcr1
= DPLL_CFGCR1(SKL_DPLL3
),
952 .cfgcr2
= DPLL_CFGCR2(SKL_DPLL3
),
956 static void skl_ddi_pll_write_ctrl1(struct drm_i915_private
*dev_priv
,
957 struct intel_shared_dpll
*pll
)
961 val
= I915_READ(DPLL_CTRL1
);
963 val
&= ~(DPLL_CTRL1_HDMI_MODE(pll
->id
) | DPLL_CTRL1_SSC(pll
->id
) |
964 DPLL_CTRL1_LINK_RATE_MASK(pll
->id
));
965 val
|= pll
->state
.hw_state
.ctrl1
<< (pll
->id
* 6);
967 I915_WRITE(DPLL_CTRL1
, val
);
968 POSTING_READ(DPLL_CTRL1
);
971 static void skl_ddi_pll_enable(struct drm_i915_private
*dev_priv
,
972 struct intel_shared_dpll
*pll
)
974 const struct skl_dpll_regs
*regs
= skl_dpll_regs
;
976 skl_ddi_pll_write_ctrl1(dev_priv
, pll
);
978 I915_WRITE(regs
[pll
->id
].cfgcr1
, pll
->state
.hw_state
.cfgcr1
);
979 I915_WRITE(regs
[pll
->id
].cfgcr2
, pll
->state
.hw_state
.cfgcr2
);
980 POSTING_READ(regs
[pll
->id
].cfgcr1
);
981 POSTING_READ(regs
[pll
->id
].cfgcr2
);
983 /* the enable bit is always bit 31 */
984 I915_WRITE(regs
[pll
->id
].ctl
,
985 I915_READ(regs
[pll
->id
].ctl
) | LCPLL_PLL_ENABLE
);
987 if (intel_wait_for_register(dev_priv
,
992 DRM_ERROR("DPLL %d not locked\n", pll
->id
);
995 static void skl_ddi_dpll0_enable(struct drm_i915_private
*dev_priv
,
996 struct intel_shared_dpll
*pll
)
998 skl_ddi_pll_write_ctrl1(dev_priv
, pll
);
1001 static void skl_ddi_pll_disable(struct drm_i915_private
*dev_priv
,
1002 struct intel_shared_dpll
*pll
)
1004 const struct skl_dpll_regs
*regs
= skl_dpll_regs
;
1006 /* the enable bit is always bit 31 */
1007 I915_WRITE(regs
[pll
->id
].ctl
,
1008 I915_READ(regs
[pll
->id
].ctl
) & ~LCPLL_PLL_ENABLE
);
1009 POSTING_READ(regs
[pll
->id
].ctl
);
1012 static void skl_ddi_dpll0_disable(struct drm_i915_private
*dev_priv
,
1013 struct intel_shared_dpll
*pll
)
1017 static bool skl_ddi_pll_get_hw_state(struct drm_i915_private
*dev_priv
,
1018 struct intel_shared_dpll
*pll
,
1019 struct intel_dpll_hw_state
*hw_state
)
1022 const struct skl_dpll_regs
*regs
= skl_dpll_regs
;
1025 if (!intel_display_power_get_if_enabled(dev_priv
, POWER_DOMAIN_PLLS
))
1030 val
= I915_READ(regs
[pll
->id
].ctl
);
1031 if (!(val
& LCPLL_PLL_ENABLE
))
1034 val
= I915_READ(DPLL_CTRL1
);
1035 hw_state
->ctrl1
= (val
>> (pll
->id
* 6)) & 0x3f;
1037 /* avoid reading back stale values if HDMI mode is not enabled */
1038 if (val
& DPLL_CTRL1_HDMI_MODE(pll
->id
)) {
1039 hw_state
->cfgcr1
= I915_READ(regs
[pll
->id
].cfgcr1
);
1040 hw_state
->cfgcr2
= I915_READ(regs
[pll
->id
].cfgcr2
);
1045 intel_display_power_put(dev_priv
, POWER_DOMAIN_PLLS
);
1050 static bool skl_ddi_dpll0_get_hw_state(struct drm_i915_private
*dev_priv
,
1051 struct intel_shared_dpll
*pll
,
1052 struct intel_dpll_hw_state
*hw_state
)
1055 const struct skl_dpll_regs
*regs
= skl_dpll_regs
;
1058 if (!intel_display_power_get_if_enabled(dev_priv
, POWER_DOMAIN_PLLS
))
1063 /* DPLL0 is always enabled since it drives CDCLK */
1064 val
= I915_READ(regs
[pll
->id
].ctl
);
1065 if (WARN_ON(!(val
& LCPLL_PLL_ENABLE
)))
1068 val
= I915_READ(DPLL_CTRL1
);
1069 hw_state
->ctrl1
= (val
>> (pll
->id
* 6)) & 0x3f;
1074 intel_display_power_put(dev_priv
, POWER_DOMAIN_PLLS
);
1079 struct skl_wrpll_context
{
1080 uint64_t min_deviation
; /* current minimal deviation */
1081 uint64_t central_freq
; /* chosen central freq */
1082 uint64_t dco_freq
; /* chosen dco freq */
1083 unsigned int p
; /* chosen divider */
1086 static void skl_wrpll_context_init(struct skl_wrpll_context
*ctx
)
1088 memset(ctx
, 0, sizeof(*ctx
));
1090 ctx
->min_deviation
= U64_MAX
;
1093 /* DCO freq must be within +1%/-6% of the DCO central freq */
1094 #define SKL_DCO_MAX_PDEVIATION 100
1095 #define SKL_DCO_MAX_NDEVIATION 600
1097 static void skl_wrpll_try_divider(struct skl_wrpll_context
*ctx
,
1098 uint64_t central_freq
,
1100 unsigned int divider
)
1104 deviation
= div64_u64(10000 * abs_diff(dco_freq
, central_freq
),
1107 /* positive deviation */
1108 if (dco_freq
>= central_freq
) {
1109 if (deviation
< SKL_DCO_MAX_PDEVIATION
&&
1110 deviation
< ctx
->min_deviation
) {
1111 ctx
->min_deviation
= deviation
;
1112 ctx
->central_freq
= central_freq
;
1113 ctx
->dco_freq
= dco_freq
;
1116 /* negative deviation */
1117 } else if (deviation
< SKL_DCO_MAX_NDEVIATION
&&
1118 deviation
< ctx
->min_deviation
) {
1119 ctx
->min_deviation
= deviation
;
1120 ctx
->central_freq
= central_freq
;
1121 ctx
->dco_freq
= dco_freq
;
1126 static void skl_wrpll_get_multipliers(unsigned int p
,
1127 unsigned int *p0
/* out */,
1128 unsigned int *p1
/* out */,
1129 unsigned int *p2
/* out */)
1133 unsigned int half
= p
/ 2;
1135 if (half
== 1 || half
== 2 || half
== 3 || half
== 5) {
1139 } else if (half
% 2 == 0) {
1143 } else if (half
% 3 == 0) {
1147 } else if (half
% 7 == 0) {
1152 } else if (p
== 3 || p
== 9) { /* 3, 5, 7, 9, 15, 21, 35 */
1156 } else if (p
== 5 || p
== 7) {
1160 } else if (p
== 15) {
1164 } else if (p
== 21) {
1168 } else if (p
== 35) {
1175 struct skl_wrpll_params
{
1176 uint32_t dco_fraction
;
1177 uint32_t dco_integer
;
1178 uint32_t qdiv_ratio
;
1182 uint32_t central_freq
;
1185 static void skl_wrpll_params_populate(struct skl_wrpll_params
*params
,
1187 uint64_t central_freq
,
1188 uint32_t p0
, uint32_t p1
, uint32_t p2
)
1192 switch (central_freq
) {
1194 params
->central_freq
= 0;
1197 params
->central_freq
= 1;
1200 params
->central_freq
= 3;
1217 WARN(1, "Incorrect PDiv\n");
1234 WARN(1, "Incorrect KDiv\n");
1237 params
->qdiv_ratio
= p1
;
1238 params
->qdiv_mode
= (params
->qdiv_ratio
== 1) ? 0 : 1;
1240 dco_freq
= p0
* p1
* p2
* afe_clock
;
1243 * Intermediate values are in Hz.
1244 * Divide by MHz to match bsepc
1246 params
->dco_integer
= div_u64(dco_freq
, 24 * MHz(1));
1247 params
->dco_fraction
=
1248 div_u64((div_u64(dco_freq
, 24) -
1249 params
->dco_integer
* MHz(1)) * 0x8000, MHz(1));
1253 skl_ddi_calculate_wrpll(int clock
/* in Hz */,
1254 struct skl_wrpll_params
*wrpll_params
)
1256 uint64_t afe_clock
= clock
* 5; /* AFE Clock is 5x Pixel clock */
1257 uint64_t dco_central_freq
[3] = {8400000000ULL,
1260 static const int even_dividers
[] = { 4, 6, 8, 10, 12, 14, 16, 18, 20,
1261 24, 28, 30, 32, 36, 40, 42, 44,
1262 48, 52, 54, 56, 60, 64, 66, 68,
1263 70, 72, 76, 78, 80, 84, 88, 90,
1265 static const int odd_dividers
[] = { 3, 5, 7, 9, 15, 21, 35 };
1266 static const struct {
1270 { even_dividers
, ARRAY_SIZE(even_dividers
) },
1271 { odd_dividers
, ARRAY_SIZE(odd_dividers
) },
1273 struct skl_wrpll_context ctx
;
1274 unsigned int dco
, d
, i
;
1275 unsigned int p0
, p1
, p2
;
1277 skl_wrpll_context_init(&ctx
);
1279 for (d
= 0; d
< ARRAY_SIZE(dividers
); d
++) {
1280 for (dco
= 0; dco
< ARRAY_SIZE(dco_central_freq
); dco
++) {
1281 for (i
= 0; i
< dividers
[d
].n_dividers
; i
++) {
1282 unsigned int p
= dividers
[d
].list
[i
];
1283 uint64_t dco_freq
= p
* afe_clock
;
1285 skl_wrpll_try_divider(&ctx
,
1286 dco_central_freq
[dco
],
1290 * Skip the remaining dividers if we're sure to
1291 * have found the definitive divider, we can't
1292 * improve a 0 deviation.
1294 if (ctx
.min_deviation
== 0)
1295 goto skip_remaining_dividers
;
1299 skip_remaining_dividers
:
1301 * If a solution is found with an even divider, prefer
1304 if (d
== 0 && ctx
.p
)
1309 DRM_DEBUG_DRIVER("No valid divider found for %dHz\n", clock
);
1314 * gcc incorrectly analyses that these can be used without being
1315 * initialized. To be fair, it's hard to guess.
1318 skl_wrpll_get_multipliers(ctx
.p
, &p0
, &p1
, &p2
);
1319 skl_wrpll_params_populate(wrpll_params
, afe_clock
, ctx
.central_freq
,
1325 static bool skl_ddi_hdmi_pll_dividers(struct intel_crtc
*crtc
,
1326 struct intel_crtc_state
*crtc_state
,
1329 uint32_t ctrl1
, cfgcr1
, cfgcr2
;
1330 struct skl_wrpll_params wrpll_params
= { 0, };
1333 * See comment in intel_dpll_hw_state to understand why we always use 0
1334 * as the DPLL id in this function.
1336 ctrl1
= DPLL_CTRL1_OVERRIDE(0);
1338 ctrl1
|= DPLL_CTRL1_HDMI_MODE(0);
1340 if (!skl_ddi_calculate_wrpll(clock
* 1000, &wrpll_params
))
1343 cfgcr1
= DPLL_CFGCR1_FREQ_ENABLE
|
1344 DPLL_CFGCR1_DCO_FRACTION(wrpll_params
.dco_fraction
) |
1345 wrpll_params
.dco_integer
;
1347 cfgcr2
= DPLL_CFGCR2_QDIV_RATIO(wrpll_params
.qdiv_ratio
) |
1348 DPLL_CFGCR2_QDIV_MODE(wrpll_params
.qdiv_mode
) |
1349 DPLL_CFGCR2_KDIV(wrpll_params
.kdiv
) |
1350 DPLL_CFGCR2_PDIV(wrpll_params
.pdiv
) |
1351 wrpll_params
.central_freq
;
1353 memset(&crtc_state
->dpll_hw_state
, 0,
1354 sizeof(crtc_state
->dpll_hw_state
));
1356 crtc_state
->dpll_hw_state
.ctrl1
= ctrl1
;
1357 crtc_state
->dpll_hw_state
.cfgcr1
= cfgcr1
;
1358 crtc_state
->dpll_hw_state
.cfgcr2
= cfgcr2
;
1363 bool skl_ddi_dp_set_dpll_hw_state(int clock
,
1364 struct intel_dpll_hw_state
*dpll_hw_state
)
1369 * See comment in intel_dpll_hw_state to understand why we always use 0
1370 * as the DPLL id in this function.
1372 ctrl1
= DPLL_CTRL1_OVERRIDE(0);
1373 switch (clock
/ 2) {
1375 ctrl1
|= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_810
, 0);
1378 ctrl1
|= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1350
, 0);
1381 ctrl1
|= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2700
, 0);
1385 ctrl1
|= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1620
, 0);
1388 ctrl1
|= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1080
, 0);
1391 ctrl1
|= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_2160
, 0);
1395 dpll_hw_state
->ctrl1
= ctrl1
;
1399 static struct intel_shared_dpll
*
1400 skl_get_dpll(struct intel_crtc
*crtc
, struct intel_crtc_state
*crtc_state
,
1401 struct intel_encoder
*encoder
)
1403 struct intel_shared_dpll
*pll
;
1404 int clock
= crtc_state
->port_clock
;
1406 struct intel_dpll_hw_state dpll_hw_state
;
1408 memset(&dpll_hw_state
, 0, sizeof(dpll_hw_state
));
1410 if (encoder
->type
== INTEL_OUTPUT_HDMI
) {
1411 bret
= skl_ddi_hdmi_pll_dividers(crtc
, crtc_state
, clock
);
1413 DRM_DEBUG_KMS("Could not get HDMI pll dividers.\n");
1416 } else if (encoder
->type
== INTEL_OUTPUT_DP
||
1417 encoder
->type
== INTEL_OUTPUT_DP_MST
||
1418 encoder
->type
== INTEL_OUTPUT_EDP
) {
1419 bret
= skl_ddi_dp_set_dpll_hw_state(clock
, &dpll_hw_state
);
1421 DRM_DEBUG_KMS("Could not set DP dpll HW state.\n");
1424 crtc_state
->dpll_hw_state
= dpll_hw_state
;
1429 if (encoder
->type
== INTEL_OUTPUT_EDP
)
1430 pll
= intel_find_shared_dpll(crtc
, crtc_state
,
1434 pll
= intel_find_shared_dpll(crtc
, crtc_state
,
1440 intel_reference_shared_dpll(pll
, crtc_state
);
1445 static void skl_dump_hw_state(struct drm_i915_private
*dev_priv
,
1446 struct intel_dpll_hw_state
*hw_state
)
1448 DRM_DEBUG_KMS("dpll_hw_state: "
1449 "ctrl1: 0x%x, cfgcr1: 0x%x, cfgcr2: 0x%x\n",
1455 static const struct intel_shared_dpll_funcs skl_ddi_pll_funcs
= {
1456 .enable
= skl_ddi_pll_enable
,
1457 .disable
= skl_ddi_pll_disable
,
1458 .get_hw_state
= skl_ddi_pll_get_hw_state
,
1461 static const struct intel_shared_dpll_funcs skl_ddi_dpll0_funcs
= {
1462 .enable
= skl_ddi_dpll0_enable
,
1463 .disable
= skl_ddi_dpll0_disable
,
1464 .get_hw_state
= skl_ddi_dpll0_get_hw_state
,
1467 static void bxt_ddi_pll_enable(struct drm_i915_private
*dev_priv
,
1468 struct intel_shared_dpll
*pll
)
1471 enum port port
= (enum port
)pll
->id
; /* 1:1 port->PLL mapping */
1473 enum dpio_channel ch
;
1475 bxt_port_to_phy_channel(dev_priv
, port
, &phy
, &ch
);
1477 /* Non-SSC reference */
1478 temp
= I915_READ(BXT_PORT_PLL_ENABLE(port
));
1479 temp
|= PORT_PLL_REF_SEL
;
1480 I915_WRITE(BXT_PORT_PLL_ENABLE(port
), temp
);
1482 if (IS_GEMINILAKE(dev_priv
)) {
1483 temp
= I915_READ(BXT_PORT_PLL_ENABLE(port
));
1484 temp
|= PORT_PLL_POWER_ENABLE
;
1485 I915_WRITE(BXT_PORT_PLL_ENABLE(port
), temp
);
1487 if (wait_for_us((I915_READ(BXT_PORT_PLL_ENABLE(port
)) &
1488 PORT_PLL_POWER_STATE
), 200))
1489 DRM_ERROR("Power state not set for PLL:%d\n", port
);
1492 /* Disable 10 bit clock */
1493 temp
= I915_READ(BXT_PORT_PLL_EBB_4(phy
, ch
));
1494 temp
&= ~PORT_PLL_10BIT_CLK_ENABLE
;
1495 I915_WRITE(BXT_PORT_PLL_EBB_4(phy
, ch
), temp
);
1498 temp
= I915_READ(BXT_PORT_PLL_EBB_0(phy
, ch
));
1499 temp
&= ~(PORT_PLL_P1_MASK
| PORT_PLL_P2_MASK
);
1500 temp
|= pll
->state
.hw_state
.ebb0
;
1501 I915_WRITE(BXT_PORT_PLL_EBB_0(phy
, ch
), temp
);
1503 /* Write M2 integer */
1504 temp
= I915_READ(BXT_PORT_PLL(phy
, ch
, 0));
1505 temp
&= ~PORT_PLL_M2_MASK
;
1506 temp
|= pll
->state
.hw_state
.pll0
;
1507 I915_WRITE(BXT_PORT_PLL(phy
, ch
, 0), temp
);
1510 temp
= I915_READ(BXT_PORT_PLL(phy
, ch
, 1));
1511 temp
&= ~PORT_PLL_N_MASK
;
1512 temp
|= pll
->state
.hw_state
.pll1
;
1513 I915_WRITE(BXT_PORT_PLL(phy
, ch
, 1), temp
);
1515 /* Write M2 fraction */
1516 temp
= I915_READ(BXT_PORT_PLL(phy
, ch
, 2));
1517 temp
&= ~PORT_PLL_M2_FRAC_MASK
;
1518 temp
|= pll
->state
.hw_state
.pll2
;
1519 I915_WRITE(BXT_PORT_PLL(phy
, ch
, 2), temp
);
1521 /* Write M2 fraction enable */
1522 temp
= I915_READ(BXT_PORT_PLL(phy
, ch
, 3));
1523 temp
&= ~PORT_PLL_M2_FRAC_ENABLE
;
1524 temp
|= pll
->state
.hw_state
.pll3
;
1525 I915_WRITE(BXT_PORT_PLL(phy
, ch
, 3), temp
);
1528 temp
= I915_READ(BXT_PORT_PLL(phy
, ch
, 6));
1529 temp
&= ~PORT_PLL_PROP_COEFF_MASK
;
1530 temp
&= ~PORT_PLL_INT_COEFF_MASK
;
1531 temp
&= ~PORT_PLL_GAIN_CTL_MASK
;
1532 temp
|= pll
->state
.hw_state
.pll6
;
1533 I915_WRITE(BXT_PORT_PLL(phy
, ch
, 6), temp
);
1535 /* Write calibration val */
1536 temp
= I915_READ(BXT_PORT_PLL(phy
, ch
, 8));
1537 temp
&= ~PORT_PLL_TARGET_CNT_MASK
;
1538 temp
|= pll
->state
.hw_state
.pll8
;
1539 I915_WRITE(BXT_PORT_PLL(phy
, ch
, 8), temp
);
1541 temp
= I915_READ(BXT_PORT_PLL(phy
, ch
, 9));
1542 temp
&= ~PORT_PLL_LOCK_THRESHOLD_MASK
;
1543 temp
|= pll
->state
.hw_state
.pll9
;
1544 I915_WRITE(BXT_PORT_PLL(phy
, ch
, 9), temp
);
1546 temp
= I915_READ(BXT_PORT_PLL(phy
, ch
, 10));
1547 temp
&= ~PORT_PLL_DCO_AMP_OVR_EN_H
;
1548 temp
&= ~PORT_PLL_DCO_AMP_MASK
;
1549 temp
|= pll
->state
.hw_state
.pll10
;
1550 I915_WRITE(BXT_PORT_PLL(phy
, ch
, 10), temp
);
1552 /* Recalibrate with new settings */
1553 temp
= I915_READ(BXT_PORT_PLL_EBB_4(phy
, ch
));
1554 temp
|= PORT_PLL_RECALIBRATE
;
1555 I915_WRITE(BXT_PORT_PLL_EBB_4(phy
, ch
), temp
);
1556 temp
&= ~PORT_PLL_10BIT_CLK_ENABLE
;
1557 temp
|= pll
->state
.hw_state
.ebb4
;
1558 I915_WRITE(BXT_PORT_PLL_EBB_4(phy
, ch
), temp
);
1561 temp
= I915_READ(BXT_PORT_PLL_ENABLE(port
));
1562 temp
|= PORT_PLL_ENABLE
;
1563 I915_WRITE(BXT_PORT_PLL_ENABLE(port
), temp
);
1564 POSTING_READ(BXT_PORT_PLL_ENABLE(port
));
1566 if (wait_for_us((I915_READ(BXT_PORT_PLL_ENABLE(port
)) & PORT_PLL_LOCK
),
1568 DRM_ERROR("PLL %d not locked\n", port
);
1570 if (IS_GEMINILAKE(dev_priv
)) {
1571 temp
= I915_READ(BXT_PORT_TX_DW5_LN0(phy
, ch
));
1572 temp
|= DCC_DELAY_RANGE_2
;
1573 I915_WRITE(BXT_PORT_TX_DW5_GRP(phy
, ch
), temp
);
1577 * While we write to the group register to program all lanes at once we
1578 * can read only lane registers and we pick lanes 0/1 for that.
1580 temp
= I915_READ(BXT_PORT_PCS_DW12_LN01(phy
, ch
));
1581 temp
&= ~LANE_STAGGER_MASK
;
1582 temp
&= ~LANESTAGGER_STRAP_OVRD
;
1583 temp
|= pll
->state
.hw_state
.pcsdw12
;
1584 I915_WRITE(BXT_PORT_PCS_DW12_GRP(phy
, ch
), temp
);
1587 static void bxt_ddi_pll_disable(struct drm_i915_private
*dev_priv
,
1588 struct intel_shared_dpll
*pll
)
1590 enum port port
= (enum port
)pll
->id
; /* 1:1 port->PLL mapping */
1593 temp
= I915_READ(BXT_PORT_PLL_ENABLE(port
));
1594 temp
&= ~PORT_PLL_ENABLE
;
1595 I915_WRITE(BXT_PORT_PLL_ENABLE(port
), temp
);
1596 POSTING_READ(BXT_PORT_PLL_ENABLE(port
));
1598 if (IS_GEMINILAKE(dev_priv
)) {
1599 temp
= I915_READ(BXT_PORT_PLL_ENABLE(port
));
1600 temp
&= ~PORT_PLL_POWER_ENABLE
;
1601 I915_WRITE(BXT_PORT_PLL_ENABLE(port
), temp
);
1603 if (wait_for_us(!(I915_READ(BXT_PORT_PLL_ENABLE(port
)) &
1604 PORT_PLL_POWER_STATE
), 200))
1605 DRM_ERROR("Power state not reset for PLL:%d\n", port
);
1609 static bool bxt_ddi_pll_get_hw_state(struct drm_i915_private
*dev_priv
,
1610 struct intel_shared_dpll
*pll
,
1611 struct intel_dpll_hw_state
*hw_state
)
1613 enum port port
= (enum port
)pll
->id
; /* 1:1 port->PLL mapping */
1617 enum dpio_channel ch
;
1619 bxt_port_to_phy_channel(dev_priv
, port
, &phy
, &ch
);
1621 if (!intel_display_power_get_if_enabled(dev_priv
, POWER_DOMAIN_PLLS
))
1626 val
= I915_READ(BXT_PORT_PLL_ENABLE(port
));
1627 if (!(val
& PORT_PLL_ENABLE
))
1630 hw_state
->ebb0
= I915_READ(BXT_PORT_PLL_EBB_0(phy
, ch
));
1631 hw_state
->ebb0
&= PORT_PLL_P1_MASK
| PORT_PLL_P2_MASK
;
1633 hw_state
->ebb4
= I915_READ(BXT_PORT_PLL_EBB_4(phy
, ch
));
1634 hw_state
->ebb4
&= PORT_PLL_10BIT_CLK_ENABLE
;
1636 hw_state
->pll0
= I915_READ(BXT_PORT_PLL(phy
, ch
, 0));
1637 hw_state
->pll0
&= PORT_PLL_M2_MASK
;
1639 hw_state
->pll1
= I915_READ(BXT_PORT_PLL(phy
, ch
, 1));
1640 hw_state
->pll1
&= PORT_PLL_N_MASK
;
1642 hw_state
->pll2
= I915_READ(BXT_PORT_PLL(phy
, ch
, 2));
1643 hw_state
->pll2
&= PORT_PLL_M2_FRAC_MASK
;
1645 hw_state
->pll3
= I915_READ(BXT_PORT_PLL(phy
, ch
, 3));
1646 hw_state
->pll3
&= PORT_PLL_M2_FRAC_ENABLE
;
1648 hw_state
->pll6
= I915_READ(BXT_PORT_PLL(phy
, ch
, 6));
1649 hw_state
->pll6
&= PORT_PLL_PROP_COEFF_MASK
|
1650 PORT_PLL_INT_COEFF_MASK
|
1651 PORT_PLL_GAIN_CTL_MASK
;
1653 hw_state
->pll8
= I915_READ(BXT_PORT_PLL(phy
, ch
, 8));
1654 hw_state
->pll8
&= PORT_PLL_TARGET_CNT_MASK
;
1656 hw_state
->pll9
= I915_READ(BXT_PORT_PLL(phy
, ch
, 9));
1657 hw_state
->pll9
&= PORT_PLL_LOCK_THRESHOLD_MASK
;
1659 hw_state
->pll10
= I915_READ(BXT_PORT_PLL(phy
, ch
, 10));
1660 hw_state
->pll10
&= PORT_PLL_DCO_AMP_OVR_EN_H
|
1661 PORT_PLL_DCO_AMP_MASK
;
1664 * While we write to the group register to program all lanes at once we
1665 * can read only lane registers. We configure all lanes the same way, so
1666 * here just read out lanes 0/1 and output a note if lanes 2/3 differ.
1668 hw_state
->pcsdw12
= I915_READ(BXT_PORT_PCS_DW12_LN01(phy
, ch
));
1669 if (I915_READ(BXT_PORT_PCS_DW12_LN23(phy
, ch
)) != hw_state
->pcsdw12
)
1670 DRM_DEBUG_DRIVER("lane stagger config different for lane 01 (%08x) and 23 (%08x)\n",
1672 I915_READ(BXT_PORT_PCS_DW12_LN23(phy
, ch
)));
1673 hw_state
->pcsdw12
&= LANE_STAGGER_MASK
| LANESTAGGER_STRAP_OVRD
;
1678 intel_display_power_put(dev_priv
, POWER_DOMAIN_PLLS
);
1683 /* bxt clock parameters */
1684 struct bxt_clk_div
{
1696 /* pre-calculated values for DP linkrates */
1697 static const struct bxt_clk_div bxt_dp_clk_val
[] = {
1698 {162000, 4, 2, 32, 1677722, 1, 1},
1699 {270000, 4, 1, 27, 0, 0, 1},
1700 {540000, 2, 1, 27, 0, 0, 1},
1701 {216000, 3, 2, 32, 1677722, 1, 1},
1702 {243000, 4, 1, 24, 1258291, 1, 1},
1703 {324000, 4, 1, 32, 1677722, 1, 1},
1704 {432000, 3, 1, 32, 1677722, 1, 1}
1708 bxt_ddi_hdmi_pll_dividers(struct intel_crtc
*intel_crtc
,
1709 struct intel_crtc_state
*crtc_state
, int clock
,
1710 struct bxt_clk_div
*clk_div
)
1712 struct dpll best_clock
;
1714 /* Calculate HDMI div */
1716 * FIXME: tie the following calculation into
1717 * i9xx_crtc_compute_clock
1719 if (!bxt_find_best_dpll(crtc_state
, clock
, &best_clock
)) {
1720 DRM_DEBUG_DRIVER("no PLL dividers found for clock %d pipe %c\n",
1721 clock
, pipe_name(intel_crtc
->pipe
));
1725 clk_div
->p1
= best_clock
.p1
;
1726 clk_div
->p2
= best_clock
.p2
;
1727 WARN_ON(best_clock
.m1
!= 2);
1728 clk_div
->n
= best_clock
.n
;
1729 clk_div
->m2_int
= best_clock
.m2
>> 22;
1730 clk_div
->m2_frac
= best_clock
.m2
& ((1 << 22) - 1);
1731 clk_div
->m2_frac_en
= clk_div
->m2_frac
!= 0;
1733 clk_div
->vco
= best_clock
.vco
;
1738 static void bxt_ddi_dp_pll_dividers(int clock
, struct bxt_clk_div
*clk_div
)
1742 *clk_div
= bxt_dp_clk_val
[0];
1743 for (i
= 0; i
< ARRAY_SIZE(bxt_dp_clk_val
); ++i
) {
1744 if (bxt_dp_clk_val
[i
].clock
== clock
) {
1745 *clk_div
= bxt_dp_clk_val
[i
];
1750 clk_div
->vco
= clock
* 10 / 2 * clk_div
->p1
* clk_div
->p2
;
1753 static bool bxt_ddi_set_dpll_hw_state(int clock
,
1754 struct bxt_clk_div
*clk_div
,
1755 struct intel_dpll_hw_state
*dpll_hw_state
)
1757 int vco
= clk_div
->vco
;
1758 uint32_t prop_coef
, int_coef
, gain_ctl
, targ_cnt
;
1759 uint32_t lanestagger
;
1761 if (vco
>= 6200000 && vco
<= 6700000) {
1766 } else if ((vco
> 5400000 && vco
< 6200000) ||
1767 (vco
>= 4800000 && vco
< 5400000)) {
1772 } else if (vco
== 5400000) {
1778 DRM_ERROR("Invalid VCO\n");
1784 else if (clock
> 135000)
1786 else if (clock
> 67000)
1788 else if (clock
> 33000)
1793 dpll_hw_state
->ebb0
= PORT_PLL_P1(clk_div
->p1
) | PORT_PLL_P2(clk_div
->p2
);
1794 dpll_hw_state
->pll0
= clk_div
->m2_int
;
1795 dpll_hw_state
->pll1
= PORT_PLL_N(clk_div
->n
);
1796 dpll_hw_state
->pll2
= clk_div
->m2_frac
;
1798 if (clk_div
->m2_frac_en
)
1799 dpll_hw_state
->pll3
= PORT_PLL_M2_FRAC_ENABLE
;
1801 dpll_hw_state
->pll6
= prop_coef
| PORT_PLL_INT_COEFF(int_coef
);
1802 dpll_hw_state
->pll6
|= PORT_PLL_GAIN_CTL(gain_ctl
);
1804 dpll_hw_state
->pll8
= targ_cnt
;
1806 dpll_hw_state
->pll9
= 5 << PORT_PLL_LOCK_THRESHOLD_SHIFT
;
1808 dpll_hw_state
->pll10
=
1809 PORT_PLL_DCO_AMP(PORT_PLL_DCO_AMP_DEFAULT
)
1810 | PORT_PLL_DCO_AMP_OVR_EN_H
;
1812 dpll_hw_state
->ebb4
= PORT_PLL_10BIT_CLK_ENABLE
;
1814 dpll_hw_state
->pcsdw12
= LANESTAGGER_STRAP_OVRD
| lanestagger
;
1819 bool bxt_ddi_dp_set_dpll_hw_state(int clock
,
1820 struct intel_dpll_hw_state
*dpll_hw_state
)
1822 struct bxt_clk_div clk_div
= {0};
1824 bxt_ddi_dp_pll_dividers(clock
, &clk_div
);
1826 return bxt_ddi_set_dpll_hw_state(clock
, &clk_div
, dpll_hw_state
);
1830 bxt_ddi_hdmi_set_dpll_hw_state(struct intel_crtc
*intel_crtc
,
1831 struct intel_crtc_state
*crtc_state
, int clock
,
1832 struct intel_dpll_hw_state
*dpll_hw_state
)
1834 struct bxt_clk_div clk_div
= { };
1836 bxt_ddi_hdmi_pll_dividers(intel_crtc
, crtc_state
, clock
, &clk_div
);
1838 return bxt_ddi_set_dpll_hw_state(clock
, &clk_div
, dpll_hw_state
);
1841 static struct intel_shared_dpll
*
1842 bxt_get_dpll(struct intel_crtc
*crtc
,
1843 struct intel_crtc_state
*crtc_state
,
1844 struct intel_encoder
*encoder
)
1846 struct intel_dpll_hw_state dpll_hw_state
= { };
1847 struct drm_i915_private
*dev_priv
= to_i915(crtc
->base
.dev
);
1848 struct intel_digital_port
*intel_dig_port
;
1849 struct intel_shared_dpll
*pll
;
1850 int i
, clock
= crtc_state
->port_clock
;
1852 if (encoder
->type
== INTEL_OUTPUT_HDMI
&&
1853 !bxt_ddi_hdmi_set_dpll_hw_state(crtc
, crtc_state
, clock
,
1857 if ((encoder
->type
== INTEL_OUTPUT_DP
||
1858 encoder
->type
== INTEL_OUTPUT_EDP
) &&
1859 !bxt_ddi_dp_set_dpll_hw_state(clock
, &dpll_hw_state
))
1862 memset(&crtc_state
->dpll_hw_state
, 0,
1863 sizeof(crtc_state
->dpll_hw_state
));
1865 crtc_state
->dpll_hw_state
= dpll_hw_state
;
1867 if (encoder
->type
== INTEL_OUTPUT_DP_MST
) {
1868 struct intel_dp_mst_encoder
*intel_mst
= enc_to_mst(&encoder
->base
);
1870 intel_dig_port
= intel_mst
->primary
;
1872 intel_dig_port
= enc_to_dig_port(&encoder
->base
);
1874 /* 1:1 mapping between ports and PLLs */
1875 i
= (enum intel_dpll_id
) intel_dig_port
->port
;
1876 pll
= intel_get_shared_dpll_by_id(dev_priv
, i
);
1878 DRM_DEBUG_KMS("[CRTC:%d:%s] using pre-allocated %s\n",
1879 crtc
->base
.base
.id
, crtc
->base
.name
, pll
->name
);
1881 intel_reference_shared_dpll(pll
, crtc_state
);
1886 static void bxt_dump_hw_state(struct drm_i915_private
*dev_priv
,
1887 struct intel_dpll_hw_state
*hw_state
)
1889 DRM_DEBUG_KMS("dpll_hw_state: ebb0: 0x%x, ebb4: 0x%x,"
1890 "pll0: 0x%x, pll1: 0x%x, pll2: 0x%x, pll3: 0x%x, "
1891 "pll6: 0x%x, pll8: 0x%x, pll9: 0x%x, pll10: 0x%x, pcsdw12: 0x%x\n",
1905 static const struct intel_shared_dpll_funcs bxt_ddi_pll_funcs
= {
1906 .enable
= bxt_ddi_pll_enable
,
1907 .disable
= bxt_ddi_pll_disable
,
1908 .get_hw_state
= bxt_ddi_pll_get_hw_state
,
1911 static void intel_ddi_pll_init(struct drm_device
*dev
)
1913 struct drm_i915_private
*dev_priv
= to_i915(dev
);
1915 if (INTEL_GEN(dev_priv
) < 9) {
1916 uint32_t val
= I915_READ(LCPLL_CTL
);
1919 * The LCPLL register should be turned on by the BIOS. For now
1920 * let's just check its state and print errors in case
1921 * something is wrong. Don't even try to turn it on.
1924 if (val
& LCPLL_CD_SOURCE_FCLK
)
1925 DRM_ERROR("CDCLK source is not LCPLL\n");
1927 if (val
& LCPLL_PLL_DISABLE
)
1928 DRM_ERROR("LCPLL is disabled\n");
1935 const struct intel_shared_dpll_funcs
*funcs
;
1939 struct intel_dpll_mgr
{
1940 const struct dpll_info
*dpll_info
;
1942 struct intel_shared_dpll
*(*get_dpll
)(struct intel_crtc
*crtc
,
1943 struct intel_crtc_state
*crtc_state
,
1944 struct intel_encoder
*encoder
);
1946 void (*dump_hw_state
)(struct drm_i915_private
*dev_priv
,
1947 struct intel_dpll_hw_state
*hw_state
);
1950 static const struct dpll_info pch_plls
[] = {
1951 { "PCH DPLL A", DPLL_ID_PCH_PLL_A
, &ibx_pch_dpll_funcs
, 0 },
1952 { "PCH DPLL B", DPLL_ID_PCH_PLL_B
, &ibx_pch_dpll_funcs
, 0 },
1953 { NULL
, -1, NULL
, 0 },
1956 static const struct intel_dpll_mgr pch_pll_mgr
= {
1957 .dpll_info
= pch_plls
,
1958 .get_dpll
= ibx_get_dpll
,
1959 .dump_hw_state
= ibx_dump_hw_state
,
1962 static const struct dpll_info hsw_plls
[] = {
1963 { "WRPLL 1", DPLL_ID_WRPLL1
, &hsw_ddi_wrpll_funcs
, 0 },
1964 { "WRPLL 2", DPLL_ID_WRPLL2
, &hsw_ddi_wrpll_funcs
, 0 },
1965 { "SPLL", DPLL_ID_SPLL
, &hsw_ddi_spll_funcs
, 0 },
1966 { "LCPLL 810", DPLL_ID_LCPLL_810
, &hsw_ddi_lcpll_funcs
, INTEL_DPLL_ALWAYS_ON
},
1967 { "LCPLL 1350", DPLL_ID_LCPLL_1350
, &hsw_ddi_lcpll_funcs
, INTEL_DPLL_ALWAYS_ON
},
1968 { "LCPLL 2700", DPLL_ID_LCPLL_2700
, &hsw_ddi_lcpll_funcs
, INTEL_DPLL_ALWAYS_ON
},
1969 { NULL
, -1, NULL
, },
1972 static const struct intel_dpll_mgr hsw_pll_mgr
= {
1973 .dpll_info
= hsw_plls
,
1974 .get_dpll
= hsw_get_dpll
,
1975 .dump_hw_state
= hsw_dump_hw_state
,
1978 static const struct dpll_info skl_plls
[] = {
1979 { "DPLL 0", DPLL_ID_SKL_DPLL0
, &skl_ddi_dpll0_funcs
, INTEL_DPLL_ALWAYS_ON
},
1980 { "DPLL 1", DPLL_ID_SKL_DPLL1
, &skl_ddi_pll_funcs
, 0 },
1981 { "DPLL 2", DPLL_ID_SKL_DPLL2
, &skl_ddi_pll_funcs
, 0 },
1982 { "DPLL 3", DPLL_ID_SKL_DPLL3
, &skl_ddi_pll_funcs
, 0 },
1983 { NULL
, -1, NULL
, },
1986 static const struct intel_dpll_mgr skl_pll_mgr
= {
1987 .dpll_info
= skl_plls
,
1988 .get_dpll
= skl_get_dpll
,
1989 .dump_hw_state
= skl_dump_hw_state
,
1992 static const struct dpll_info bxt_plls
[] = {
1993 { "PORT PLL A", DPLL_ID_SKL_DPLL0
, &bxt_ddi_pll_funcs
, 0 },
1994 { "PORT PLL B", DPLL_ID_SKL_DPLL1
, &bxt_ddi_pll_funcs
, 0 },
1995 { "PORT PLL C", DPLL_ID_SKL_DPLL2
, &bxt_ddi_pll_funcs
, 0 },
1996 { NULL
, -1, NULL
, },
1999 static const struct intel_dpll_mgr bxt_pll_mgr
= {
2000 .dpll_info
= bxt_plls
,
2001 .get_dpll
= bxt_get_dpll
,
2002 .dump_hw_state
= bxt_dump_hw_state
,
2006 * intel_shared_dpll_init - Initialize shared DPLLs
2009 * Initialize shared DPLLs for @dev.
2011 void intel_shared_dpll_init(struct drm_device
*dev
)
2013 struct drm_i915_private
*dev_priv
= to_i915(dev
);
2014 const struct intel_dpll_mgr
*dpll_mgr
= NULL
;
2015 const struct dpll_info
*dpll_info
;
2018 if (IS_SKYLAKE(dev_priv
) || IS_KABYLAKE(dev_priv
))
2019 dpll_mgr
= &skl_pll_mgr
;
2020 else if (IS_GEN9_LP(dev_priv
))
2021 dpll_mgr
= &bxt_pll_mgr
;
2022 else if (HAS_DDI(dev_priv
))
2023 dpll_mgr
= &hsw_pll_mgr
;
2024 else if (HAS_PCH_IBX(dev_priv
) || HAS_PCH_CPT(dev_priv
))
2025 dpll_mgr
= &pch_pll_mgr
;
2028 dev_priv
->num_shared_dpll
= 0;
2032 dpll_info
= dpll_mgr
->dpll_info
;
2034 for (i
= 0; dpll_info
[i
].id
>= 0; i
++) {
2035 WARN_ON(i
!= dpll_info
[i
].id
);
2037 dev_priv
->shared_dplls
[i
].id
= dpll_info
[i
].id
;
2038 dev_priv
->shared_dplls
[i
].name
= dpll_info
[i
].name
;
2039 dev_priv
->shared_dplls
[i
].funcs
= *dpll_info
[i
].funcs
;
2040 dev_priv
->shared_dplls
[i
].flags
= dpll_info
[i
].flags
;
2043 dev_priv
->dpll_mgr
= dpll_mgr
;
2044 dev_priv
->num_shared_dpll
= i
;
2045 mutex_init(&dev_priv
->dpll_lock
);
2047 BUG_ON(dev_priv
->num_shared_dpll
> I915_NUM_PLLS
);
2049 /* FIXME: Move this to a more suitable place */
2050 if (HAS_DDI(dev_priv
))
2051 intel_ddi_pll_init(dev
);
2055 * intel_get_shared_dpll - get a shared DPLL for CRTC and encoder combination
2057 * @crtc_state: atomic state for @crtc
2060 * Find an appropriate DPLL for the given CRTC and encoder combination. A
2061 * reference from the @crtc to the returned pll is registered in the atomic
2062 * state. That configuration is made effective by calling
2063 * intel_shared_dpll_swap_state(). The reference should be released by calling
2064 * intel_release_shared_dpll().
2067 * A shared DPLL to be used by @crtc and @encoder with the given @crtc_state.
2069 struct intel_shared_dpll
*
2070 intel_get_shared_dpll(struct intel_crtc
*crtc
,
2071 struct intel_crtc_state
*crtc_state
,
2072 struct intel_encoder
*encoder
)
2074 struct drm_i915_private
*dev_priv
= to_i915(crtc
->base
.dev
);
2075 const struct intel_dpll_mgr
*dpll_mgr
= dev_priv
->dpll_mgr
;
2077 if (WARN_ON(!dpll_mgr
))
2080 return dpll_mgr
->get_dpll(crtc
, crtc_state
, encoder
);
2084 * intel_release_shared_dpll - end use of DPLL by CRTC in atomic state
2085 * @dpll: dpll in use by @crtc
2087 * @state: atomic state
2089 * This function releases the reference from @crtc to @dpll from the
2090 * atomic @state. The new configuration is made effective by calling
2091 * intel_shared_dpll_swap_state().
2093 void intel_release_shared_dpll(struct intel_shared_dpll
*dpll
,
2094 struct intel_crtc
*crtc
,
2095 struct drm_atomic_state
*state
)
2097 struct intel_shared_dpll_state
*shared_dpll_state
;
2099 shared_dpll_state
= intel_atomic_get_shared_dpll_state(state
);
2100 shared_dpll_state
[dpll
->id
].crtc_mask
&= ~(1 << crtc
->pipe
);
2104 * intel_shared_dpll_dump_hw_state - write hw_state to dmesg
2105 * @dev_priv: i915 drm device
2106 * @hw_state: hw state to be written to the log
2108 * Write the relevant values in @hw_state to dmesg using DRM_DEBUG_KMS.
2110 void intel_dpll_dump_hw_state(struct drm_i915_private
*dev_priv
,
2111 struct intel_dpll_hw_state
*hw_state
)
2113 if (dev_priv
->dpll_mgr
) {
2114 dev_priv
->dpll_mgr
->dump_hw_state(dev_priv
, hw_state
);
2116 /* fallback for platforms that don't use the shared dpll
2119 DRM_DEBUG_KMS("dpll_hw_state: dpll: 0x%x, dpll_md: 0x%x, "
2120 "fp0: 0x%x, fp1: 0x%x\n",