Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/pch: convert intel_pch_refclk.c to struct intel_display

Going forward, struct intel_display is the main display device data
pointer. Convert as much as possible of intel_pch_refclk.[ch] to struct
intel_display.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://lore.kernel.org/r/1bf35f05dc921e0ca548b0d0d8d7f5b7098e8140.1742554320.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

+85 -81
+1 -1
drivers/gpu/drm/i915/display/intel_display.c
··· 7815 7815 intel_encoder_possible_clones(encoder); 7816 7816 } 7817 7817 7818 - intel_init_pch_refclk(dev_priv); 7818 + intel_init_pch_refclk(display); 7819 7819 7820 7820 drm_helper_move_panel_connectors_to_head(display->drm); 7821 7821 }
+3 -3
drivers/gpu/drm/i915/display/intel_display_power.c
··· 1373 1373 intel_de_rmw(display, SOUTH_DSPCLK_GATE_D, 1374 1374 PCH_LP_PARTITION_LEVEL_DISABLE, 0); 1375 1375 1376 - lpt_disable_clkout_dp(dev_priv); 1376 + lpt_disable_clkout_dp(display); 1377 1377 hsw_disable_lcpll(display, true, true); 1378 1378 } 1379 1379 1380 1380 static void hsw_disable_pc8(struct intel_display *display) 1381 1381 { 1382 - struct drm_i915_private *dev_priv = to_i915(display->drm); 1382 + struct drm_i915_private __maybe_unused *dev_priv = to_i915(display->drm); 1383 1383 1384 1384 drm_dbg_kms(display->drm, "Disabling package C8+\n"); 1385 1385 1386 1386 hsw_restore_lcpll(display); 1387 - intel_init_pch_refclk(dev_priv); 1387 + intel_init_pch_refclk(display); 1388 1388 1389 1389 /* Many display registers don't survive PC8+ */ 1390 1390 #ifdef I915 /* FIXME */
+2 -4
drivers/gpu/drm/i915/display/intel_dpll_mgr.c
··· 715 715 static void hsw_ddi_wrpll_disable(struct intel_display *display, 716 716 struct intel_shared_dpll *pll) 717 717 { 718 - struct drm_i915_private *i915 = to_i915(display->drm); 719 718 const enum intel_dpll_id id = pll->info->id; 720 719 721 720 intel_de_rmw(display, WRPLL_CTL(id), WRPLL_PLL_ENABLE, 0); ··· 725 726 * that depend on it have been shut down. 726 727 */ 727 728 if (display->dpll.pch_ssc_use & BIT(id)) 728 - intel_init_pch_refclk(i915); 729 + intel_init_pch_refclk(display); 729 730 } 730 731 731 732 static void hsw_ddi_spll_disable(struct intel_display *display, 732 733 struct intel_shared_dpll *pll) 733 734 { 734 - struct drm_i915_private *i915 = to_i915(display->drm); 735 735 enum intel_dpll_id id = pll->info->id; 736 736 737 737 intel_de_rmw(display, SPLL_CTL, SPLL_PLL_ENABLE, 0); ··· 741 743 * that depend on it have been shut down. 742 744 */ 743 745 if (display->dpll.pch_ssc_use & BIT(id)) 744 - intel_init_pch_refclk(i915); 746 + intel_init_pch_refclk(display); 745 747 } 746 748 747 749 static bool hsw_ddi_wrpll_get_hw_state(struct intel_display *display,
+2 -4
drivers/gpu/drm/i915/display/intel_pch_display.c
··· 613 613 struct intel_crtc *crtc) 614 614 { 615 615 struct intel_display *display = to_intel_display(crtc); 616 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 617 616 618 617 lpt_disable_pch_transcoder(display); 619 618 620 - lpt_disable_iclkip(dev_priv); 619 + lpt_disable_iclkip(display); 621 620 } 622 621 623 622 void lpt_pch_get_config(struct intel_crtc_state *crtc_state) 624 623 { 625 624 struct intel_display *display = to_intel_display(crtc_state); 626 625 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 627 - struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 628 626 u32 tmp; 629 627 630 628 if ((intel_de_read(display, LPT_TRANSCONF) & TRANS_ENABLE) == 0) ··· 637 639 intel_cpu_transcoder_get_m1_n1(crtc, crtc_state->cpu_transcoder, 638 640 &crtc_state->fdi_m_n); 639 641 640 - crtc_state->hw.adjusted_mode.crtc_clock = lpt_get_iclkip(dev_priv); 642 + crtc_state->hw.adjusted_mode.crtc_clock = lpt_get_iclkip(display); 641 643 } 642 644 643 645 void intel_pch_sanitize(struct intel_display *display)
+67 -59
drivers/gpu/drm/i915/display/intel_pch_refclk.c
··· 11 11 #include "intel_pch_refclk.h" 12 12 #include "intel_sbi.h" 13 13 14 - static void lpt_fdi_reset_mphy(struct drm_i915_private *dev_priv) 14 + static void lpt_fdi_reset_mphy(struct intel_display *display) 15 15 { 16 - intel_de_rmw(dev_priv, SOUTH_CHICKEN2, 0, FDI_MPHY_IOSFSB_RESET_CTL); 16 + intel_de_rmw(display, SOUTH_CHICKEN2, 0, FDI_MPHY_IOSFSB_RESET_CTL); 17 17 18 - if (wait_for_us(intel_de_read(dev_priv, SOUTH_CHICKEN2) & 18 + if (wait_for_us(intel_de_read(display, SOUTH_CHICKEN2) & 19 19 FDI_MPHY_IOSFSB_RESET_STATUS, 100)) 20 - drm_err(&dev_priv->drm, "FDI mPHY reset assert timeout\n"); 20 + drm_err(display->drm, "FDI mPHY reset assert timeout\n"); 21 21 22 - intel_de_rmw(dev_priv, SOUTH_CHICKEN2, FDI_MPHY_IOSFSB_RESET_CTL, 0); 22 + intel_de_rmw(display, SOUTH_CHICKEN2, FDI_MPHY_IOSFSB_RESET_CTL, 0); 23 23 24 - if (wait_for_us((intel_de_read(dev_priv, SOUTH_CHICKEN2) & 24 + if (wait_for_us((intel_de_read(display, SOUTH_CHICKEN2) & 25 25 FDI_MPHY_IOSFSB_RESET_STATUS) == 0, 100)) 26 - drm_err(&dev_priv->drm, "FDI mPHY reset de-assert timeout\n"); 26 + drm_err(display->drm, "FDI mPHY reset de-assert timeout\n"); 27 27 } 28 28 29 29 /* WaMPhyProgramming:hsw */ 30 - static void lpt_fdi_program_mphy(struct drm_i915_private *dev_priv) 30 + static void lpt_fdi_program_mphy(struct intel_display *display) 31 31 { 32 + struct drm_i915_private *dev_priv = to_i915(display->drm); 32 33 u32 tmp; 33 34 34 - lpt_fdi_reset_mphy(dev_priv); 35 + lpt_fdi_reset_mphy(display); 35 36 36 37 tmp = intel_sbi_read(dev_priv, 0x8008, SBI_MPHY); 37 38 tmp &= ~(0xFF << 24); ··· 104 103 intel_sbi_write(dev_priv, 0x21EC, tmp, SBI_MPHY); 105 104 } 106 105 107 - void lpt_disable_iclkip(struct drm_i915_private *dev_priv) 106 + void lpt_disable_iclkip(struct intel_display *display) 108 107 { 108 + struct drm_i915_private *dev_priv = to_i915(display->drm); 109 109 u32 temp; 110 110 111 - intel_de_write(dev_priv, PIXCLK_GATE, PIXCLK_GATE_GATE); 111 + intel_de_write(display, PIXCLK_GATE, PIXCLK_GATE_GATE); 112 112 113 113 intel_sbi_lock(dev_priv); 114 114 ··· 177 175 /* Program iCLKIP clock to the desired frequency */ 178 176 void lpt_program_iclkip(const struct intel_crtc_state *crtc_state) 179 177 { 178 + struct intel_display *display = to_intel_display(crtc_state); 180 179 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); 181 180 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 182 181 int clock = crtc_state->hw.adjusted_mode.crtc_clock; 183 182 struct iclkip_params p; 184 183 u32 temp; 185 184 186 - lpt_disable_iclkip(dev_priv); 185 + lpt_disable_iclkip(display); 187 186 188 187 lpt_compute_iclkip(&p, clock); 189 - drm_WARN_ON(&dev_priv->drm, lpt_iclkip_freq(&p) != clock); 188 + drm_WARN_ON(display->drm, lpt_iclkip_freq(&p) != clock); 190 189 191 190 /* This should not happen with any sane values */ 192 - drm_WARN_ON(&dev_priv->drm, SBI_SSCDIVINTPHASE_DIVSEL(p.divsel) & 191 + drm_WARN_ON(display->drm, SBI_SSCDIVINTPHASE_DIVSEL(p.divsel) & 193 192 ~SBI_SSCDIVINTPHASE_DIVSEL_MASK); 194 - drm_WARN_ON(&dev_priv->drm, SBI_SSCDIVINTPHASE_DIR(p.phasedir) & 193 + drm_WARN_ON(display->drm, SBI_SSCDIVINTPHASE_DIR(p.phasedir) & 195 194 ~SBI_SSCDIVINTPHASE_INCVAL_MASK); 196 195 197 - drm_dbg_kms(&dev_priv->drm, 196 + drm_dbg_kms(display->drm, 198 197 "iCLKIP clock: found settings for %dKHz refresh rate: auxdiv=%x, divsel=%x, phasedir=%x, phaseinc=%x\n", 199 198 clock, p.auxdiv, p.divsel, p.phasedir, p.phaseinc); 200 199 ··· 227 224 /* Wait for initialization time */ 228 225 udelay(24); 229 226 230 - intel_de_write(dev_priv, PIXCLK_GATE, PIXCLK_GATE_UNGATE); 227 + intel_de_write(display, PIXCLK_GATE, PIXCLK_GATE_UNGATE); 231 228 } 232 229 233 - int lpt_get_iclkip(struct drm_i915_private *dev_priv) 230 + int lpt_get_iclkip(struct intel_display *display) 234 231 { 232 + struct drm_i915_private *dev_priv = to_i915(display->drm); 235 233 struct iclkip_params p; 236 234 u32 temp; 237 235 238 - if ((intel_de_read(dev_priv, PIXCLK_GATE) & PIXCLK_GATE_UNGATE) == 0) 236 + if ((intel_de_read(display, PIXCLK_GATE) & PIXCLK_GATE_UNGATE) == 0) 239 237 return 0; 240 238 241 239 iclkip_params_init(&p); ··· 272 268 * - Sequence to enable CLKOUT_DP without spread 273 269 * - Sequence to enable CLKOUT_DP for FDI usage and configure PCH FDI I/O 274 270 */ 275 - static void lpt_enable_clkout_dp(struct drm_i915_private *dev_priv, 271 + static void lpt_enable_clkout_dp(struct intel_display *display, 276 272 bool with_spread, bool with_fdi) 277 273 { 274 + struct drm_i915_private *dev_priv = to_i915(display->drm); 278 275 u32 reg, tmp; 279 276 280 - if (drm_WARN(&dev_priv->drm, with_fdi && !with_spread, 277 + if (drm_WARN(display->drm, with_fdi && !with_spread, 281 278 "FDI requires downspread\n")) 282 279 with_spread = true; 283 - if (drm_WARN(&dev_priv->drm, HAS_PCH_LPT_LP(dev_priv) && 280 + if (drm_WARN(display->drm, HAS_PCH_LPT_LP(dev_priv) && 284 281 with_fdi, "LP PCH doesn't have FDI\n")) 285 282 with_fdi = false; 286 283 ··· 300 295 intel_sbi_write(dev_priv, SBI_SSCCTL, tmp, SBI_ICLK); 301 296 302 297 if (with_fdi) 303 - lpt_fdi_program_mphy(dev_priv); 298 + lpt_fdi_program_mphy(display); 304 299 } 305 300 306 301 reg = HAS_PCH_LPT_LP(dev_priv) ? SBI_GEN0 : SBI_DBUFF0; ··· 312 307 } 313 308 314 309 /* Sequence to disable CLKOUT_DP */ 315 - void lpt_disable_clkout_dp(struct drm_i915_private *dev_priv) 310 + void lpt_disable_clkout_dp(struct intel_display *display) 316 311 { 312 + struct drm_i915_private *dev_priv = to_i915(display->drm); 317 313 u32 reg, tmp; 318 314 319 315 intel_sbi_lock(dev_priv); ··· 370 364 * < 0 slow down the clock, > 0 speed up the clock, 0 == no bend (135MHz) 371 365 * change in clock period = -(steps / 10) * 5.787 ps 372 366 */ 373 - static void lpt_bend_clkout_dp(struct drm_i915_private *dev_priv, int steps) 367 + static void lpt_bend_clkout_dp(struct intel_display *display, int steps) 374 368 { 369 + struct drm_i915_private *dev_priv = to_i915(display->drm); 375 370 u32 tmp; 376 371 int idx = BEND_IDX(steps); 377 372 378 - if (drm_WARN_ON(&dev_priv->drm, steps % 5 != 0)) 373 + if (drm_WARN_ON(display->drm, steps % 5 != 0)) 379 374 return; 380 375 381 - if (drm_WARN_ON(&dev_priv->drm, idx >= ARRAY_SIZE(sscdivintphase))) 376 + if (drm_WARN_ON(display->drm, idx >= ARRAY_SIZE(sscdivintphase))) 382 377 return; 383 378 384 379 intel_sbi_lock(dev_priv); ··· 400 393 401 394 #undef BEND_IDX 402 395 403 - static bool spll_uses_pch_ssc(struct drm_i915_private *dev_priv) 396 + static bool spll_uses_pch_ssc(struct intel_display *display) 404 397 { 405 - u32 fuse_strap = intel_de_read(dev_priv, FUSE_STRAP); 406 - u32 ctl = intel_de_read(dev_priv, SPLL_CTL); 398 + u32 fuse_strap = intel_de_read(display, FUSE_STRAP); 399 + u32 ctl = intel_de_read(display, SPLL_CTL); 407 400 408 401 if ((ctl & SPLL_PLL_ENABLE) == 0) 409 402 return false; ··· 412 405 (fuse_strap & HSW_CPU_SSC_ENABLE) == 0) 413 406 return true; 414 407 415 - if (IS_BROADWELL(dev_priv) && 408 + if (display->platform.broadwell && 416 409 (ctl & SPLL_REF_MASK) == SPLL_REF_PCH_SSC_BDW) 417 410 return true; 418 411 419 412 return false; 420 413 } 421 414 422 - static bool wrpll_uses_pch_ssc(struct drm_i915_private *dev_priv, 423 - enum intel_dpll_id id) 415 + static bool wrpll_uses_pch_ssc(struct intel_display *display, enum intel_dpll_id id) 424 416 { 425 - u32 fuse_strap = intel_de_read(dev_priv, FUSE_STRAP); 426 - u32 ctl = intel_de_read(dev_priv, WRPLL_CTL(id)); 417 + u32 fuse_strap = intel_de_read(display, FUSE_STRAP); 418 + u32 ctl = intel_de_read(display, WRPLL_CTL(id)); 427 419 428 420 if ((ctl & WRPLL_PLL_ENABLE) == 0) 429 421 return false; ··· 430 424 if ((ctl & WRPLL_REF_MASK) == WRPLL_REF_PCH_SSC) 431 425 return true; 432 426 433 - if ((IS_BROADWELL(dev_priv) || IS_HASWELL_ULT(dev_priv)) && 427 + if ((display->platform.broadwell || display->platform.haswell_ult) && 434 428 (ctl & WRPLL_REF_MASK) == WRPLL_REF_MUXED_SSC_BDW && 435 429 (fuse_strap & HSW_CPU_SSC_ENABLE) == 0) 436 430 return true; ··· 438 432 return false; 439 433 } 440 434 441 - static void lpt_init_pch_refclk(struct drm_i915_private *dev_priv) 435 + static void lpt_init_pch_refclk(struct intel_display *display) 442 436 { 443 437 struct intel_encoder *encoder; 444 438 bool has_fdi = false; 445 439 446 - for_each_intel_encoder(&dev_priv->drm, encoder) { 440 + for_each_intel_encoder(display->drm, encoder) { 447 441 switch (encoder->type) { 448 442 case INTEL_OUTPUT_ANALOG: 449 443 has_fdi = true; ··· 468 462 * clock hierarchy. That would also allow us to do 469 463 * clock bending finally. 470 464 */ 471 - dev_priv->display.dpll.pch_ssc_use = 0; 465 + display->dpll.pch_ssc_use = 0; 472 466 473 - if (spll_uses_pch_ssc(dev_priv)) { 474 - drm_dbg_kms(&dev_priv->drm, "SPLL using PCH SSC\n"); 475 - dev_priv->display.dpll.pch_ssc_use |= BIT(DPLL_ID_SPLL); 467 + if (spll_uses_pch_ssc(display)) { 468 + drm_dbg_kms(display->drm, "SPLL using PCH SSC\n"); 469 + display->dpll.pch_ssc_use |= BIT(DPLL_ID_SPLL); 476 470 } 477 471 478 - if (wrpll_uses_pch_ssc(dev_priv, DPLL_ID_WRPLL1)) { 479 - drm_dbg_kms(&dev_priv->drm, "WRPLL1 using PCH SSC\n"); 480 - dev_priv->display.dpll.pch_ssc_use |= BIT(DPLL_ID_WRPLL1); 472 + if (wrpll_uses_pch_ssc(display, DPLL_ID_WRPLL1)) { 473 + drm_dbg_kms(display->drm, "WRPLL1 using PCH SSC\n"); 474 + display->dpll.pch_ssc_use |= BIT(DPLL_ID_WRPLL1); 481 475 } 482 476 483 - if (wrpll_uses_pch_ssc(dev_priv, DPLL_ID_WRPLL2)) { 484 - drm_dbg_kms(&dev_priv->drm, "WRPLL2 using PCH SSC\n"); 485 - dev_priv->display.dpll.pch_ssc_use |= BIT(DPLL_ID_WRPLL2); 477 + if (wrpll_uses_pch_ssc(display, DPLL_ID_WRPLL2)) { 478 + drm_dbg_kms(display->drm, "WRPLL2 using PCH SSC\n"); 479 + display->dpll.pch_ssc_use |= BIT(DPLL_ID_WRPLL2); 486 480 } 487 481 488 - if (dev_priv->display.dpll.pch_ssc_use) 482 + if (display->dpll.pch_ssc_use) 489 483 return; 490 484 491 485 if (has_fdi) { 492 - lpt_bend_clkout_dp(dev_priv, 0); 493 - lpt_enable_clkout_dp(dev_priv, true, true); 486 + lpt_bend_clkout_dp(display, 0); 487 + lpt_enable_clkout_dp(display, true, true); 494 488 } else { 495 - lpt_disable_clkout_dp(dev_priv); 489 + lpt_disable_clkout_dp(display); 496 490 } 497 491 } 498 492 499 - static void ilk_init_pch_refclk(struct drm_i915_private *dev_priv) 493 + static void ilk_init_pch_refclk(struct intel_display *display) 500 494 { 501 - struct intel_display *display = &dev_priv->display; 495 + struct drm_i915_private *dev_priv = to_i915(display->drm); 502 496 struct intel_encoder *encoder; 503 497 struct intel_shared_dpll *pll; 504 498 int i; ··· 613 607 614 608 /* SSC must be turned on before enabling the CPU output */ 615 609 if (intel_panel_use_ssc(display) && can_ssc) { 616 - drm_dbg_kms(&dev_priv->drm, "Using SSC on panel\n"); 610 + drm_dbg_kms(display->drm, "Using SSC on panel\n"); 617 611 val |= DREF_SSC1_ENABLE; 618 612 } else { 619 613 val &= ~DREF_SSC1_ENABLE; ··· 629 623 /* Enable CPU source on CPU attached eDP */ 630 624 if (has_cpu_edp) { 631 625 if (intel_panel_use_ssc(display) && can_ssc) { 632 - drm_dbg_kms(&dev_priv->drm, 626 + drm_dbg_kms(display->drm, 633 627 "Using SSC on eDP\n"); 634 628 val |= DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD; 635 629 } else { ··· 676 670 /* 677 671 * Initialize reference clocks when the driver loads 678 672 */ 679 - void intel_init_pch_refclk(struct drm_i915_private *dev_priv) 673 + void intel_init_pch_refclk(struct intel_display *display) 680 674 { 675 + struct drm_i915_private *dev_priv = to_i915(display->drm); 676 + 681 677 if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv)) 682 - ilk_init_pch_refclk(dev_priv); 678 + ilk_init_pch_refclk(display); 683 679 else if (HAS_PCH_LPT(dev_priv)) 684 - lpt_init_pch_refclk(dev_priv); 680 + lpt_init_pch_refclk(display); 685 681 }
+9 -9
drivers/gpu/drm/i915/display/intel_pch_refclk.h
··· 8 8 9 9 #include <linux/types.h> 10 10 11 - struct drm_i915_private; 12 11 struct intel_crtc_state; 12 + struct intel_display; 13 13 14 14 #ifdef I915 15 15 void lpt_program_iclkip(const struct intel_crtc_state *crtc_state); 16 - void lpt_disable_iclkip(struct drm_i915_private *dev_priv); 17 - int lpt_get_iclkip(struct drm_i915_private *dev_priv); 16 + void lpt_disable_iclkip(struct intel_display *display); 17 + int lpt_get_iclkip(struct intel_display *display); 18 18 int lpt_iclkip(const struct intel_crtc_state *crtc_state); 19 19 20 - void intel_init_pch_refclk(struct drm_i915_private *dev_priv); 21 - void lpt_disable_clkout_dp(struct drm_i915_private *dev_priv); 20 + void intel_init_pch_refclk(struct intel_display *display); 21 + void lpt_disable_clkout_dp(struct intel_display *display); 22 22 #else 23 23 static inline void lpt_program_iclkip(const struct intel_crtc_state *crtc_state) 24 24 { 25 25 } 26 - static inline void lpt_disable_iclkip(struct drm_i915_private *dev_priv) 26 + static inline void lpt_disable_iclkip(struct intel_display *display) 27 27 { 28 28 } 29 - static inline int lpt_get_iclkip(struct drm_i915_private *dev_priv) 29 + static inline int lpt_get_iclkip(struct intel_display *display) 30 30 { 31 31 return 0; 32 32 } ··· 34 34 { 35 35 return 0; 36 36 } 37 - static inline void intel_init_pch_refclk(struct drm_i915_private *dev_priv) 37 + static inline void intel_init_pch_refclk(struct intel_display *display) 38 38 { 39 39 } 40 - static inline void lpt_disable_clkout_dp(struct drm_i915_private *dev_priv) 40 + static inline void lpt_disable_clkout_dp(struct intel_display *display) 41 41 { 42 42 } 43 43 #endif
+1 -1
drivers/gpu/drm/i915/i915_driver.c
··· 1211 1211 1212 1212 intel_pps_unlock_regs_wa(display); 1213 1213 1214 - intel_init_pch_refclk(dev_priv); 1214 + intel_init_pch_refclk(display); 1215 1215 1216 1216 /* 1217 1217 * Interrupts have to be enabled before any batches are run. If not the