1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright © 2023 Intel Corporation 4 */ 5 6 #include <linux/log2.h> 7 #include <linux/math64.h> 8 #include "i915_reg.h" 9 #include "intel_cx0_phy.h" 10 #include "intel_cx0_phy_regs.h" 11 #include "intel_ddi.h" 12 #include "intel_ddi_buf_trans.h" 13 #include "intel_de.h" 14 #include "intel_display_types.h" 15 #include "intel_dp.h" 16 #include "intel_hdmi.h" 17 #include "intel_panel.h" 18 #include "intel_psr.h" 19 #include "intel_tc.h" 20 21 #define MB_WRITE_COMMITTED true 22 #define MB_WRITE_UNCOMMITTED false 23 24 #define for_each_cx0_lane_in_mask(__lane_mask, __lane) \ 25 for ((__lane) = 0; (__lane) < 2; (__lane)++) \ 26 for_each_if((__lane_mask) & BIT(__lane)) 27 28 #define INTEL_CX0_LANE0 BIT(0) 29 #define INTEL_CX0_LANE1 BIT(1) 30 #define INTEL_CX0_BOTH_LANES (INTEL_CX0_LANE1 | INTEL_CX0_LANE0) 31 32 bool intel_is_c10phy(struct drm_i915_private *i915, enum phy phy) 33 { 34 if ((IS_LUNARLAKE(i915) || IS_METEORLAKE(i915)) && phy < PHY_C) 35 return true; 36 37 return false; 38 } 39 40 static int lane_mask_to_lane(u8 lane_mask) 41 { 42 if (WARN_ON((lane_mask & ~INTEL_CX0_BOTH_LANES) || 43 hweight8(lane_mask) != 1)) 44 return 0; 45 46 return ilog2(lane_mask); 47 } 48 49 static u8 intel_cx0_get_owned_lane_mask(struct drm_i915_private *i915, 50 struct intel_encoder *encoder) 51 { 52 struct intel_digital_port *dig_port = enc_to_dig_port(encoder); 53 54 if (!intel_tc_port_in_dp_alt_mode(dig_port)) 55 return INTEL_CX0_BOTH_LANES; 56 57 /* 58 * In DP-alt with pin assignment D, only PHY lane 0 is owned 59 * by display and lane 1 is owned by USB. 60 */ 61 return intel_tc_port_max_lane_count(dig_port) > 2 62 ? INTEL_CX0_BOTH_LANES : INTEL_CX0_LANE0; 63 } 64 65 static void 66 assert_dc_off(struct drm_i915_private *i915) 67 { 68 bool enabled; 69 70 enabled = intel_display_power_is_enabled(i915, POWER_DOMAIN_DC_OFF); 71 drm_WARN_ON(&i915->drm, !enabled); 72 } 73 74 static void intel_cx0_program_msgbus_timer(struct intel_encoder *encoder) 75 { 76 int lane; 77 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 78 79 for_each_cx0_lane_in_mask(INTEL_CX0_BOTH_LANES, lane) 80 intel_de_rmw(i915, 81 XELPDP_PORT_MSGBUS_TIMER(encoder->port, lane), 82 XELPDP_PORT_MSGBUS_TIMER_VAL_MASK, 83 XELPDP_PORT_MSGBUS_TIMER_VAL); 84 } 85 86 /* 87 * Prepare HW for CX0 phy transactions. 88 * 89 * It is required that PSR and DC5/6 are disabled before any CX0 message 90 * bus transaction is executed. 91 * 92 * We also do the msgbus timer programming here to ensure that the timer 93 * is already programmed before any access to the msgbus. 94 */ 95 static intel_wakeref_t intel_cx0_phy_transaction_begin(struct intel_encoder *encoder) 96 { 97 intel_wakeref_t wakeref; 98 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 99 struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 100 101 intel_psr_pause(intel_dp); 102 wakeref = intel_display_power_get(i915, POWER_DOMAIN_DC_OFF); 103 intel_cx0_program_msgbus_timer(encoder); 104 105 return wakeref; 106 } 107 108 static void intel_cx0_phy_transaction_end(struct intel_encoder *encoder, intel_wakeref_t wakeref) 109 { 110 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 111 struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 112 113 intel_psr_resume(intel_dp); 114 intel_display_power_put(i915, POWER_DOMAIN_DC_OFF, wakeref); 115 } 116 117 static void intel_clear_response_ready_flag(struct drm_i915_private *i915, 118 enum port port, int lane) 119 { 120 intel_de_rmw(i915, XELPDP_PORT_P2M_MSGBUS_STATUS(port, lane), 121 0, XELPDP_PORT_P2M_RESPONSE_READY | XELPDP_PORT_P2M_ERROR_SET); 122 } 123 124 static void intel_cx0_bus_reset(struct drm_i915_private *i915, enum port port, int lane) 125 { 126 enum phy phy = intel_port_to_phy(i915, port); 127 128 intel_de_write(i915, XELPDP_PORT_M2P_MSGBUS_CTL(port, lane), 129 XELPDP_PORT_M2P_TRANSACTION_RESET); 130 131 if (intel_de_wait_for_clear(i915, XELPDP_PORT_M2P_MSGBUS_CTL(port, lane), 132 XELPDP_PORT_M2P_TRANSACTION_RESET, 133 XELPDP_MSGBUS_TIMEOUT_SLOW)) { 134 drm_err_once(&i915->drm, "Failed to bring PHY %c to idle.\n", phy_name(phy)); 135 return; 136 } 137 138 intel_clear_response_ready_flag(i915, port, lane); 139 } 140 141 static int intel_cx0_wait_for_ack(struct drm_i915_private *i915, enum port port, 142 int command, int lane, u32 *val) 143 { 144 enum phy phy = intel_port_to_phy(i915, port); 145 146 if (__intel_de_wait_for_register(i915, 147 XELPDP_PORT_P2M_MSGBUS_STATUS(port, lane), 148 XELPDP_PORT_P2M_RESPONSE_READY, 149 XELPDP_PORT_P2M_RESPONSE_READY, 150 XELPDP_MSGBUS_TIMEOUT_FAST_US, 151 XELPDP_MSGBUS_TIMEOUT_SLOW, val)) { 152 drm_dbg_kms(&i915->drm, "PHY %c Timeout waiting for message ACK. Status: 0x%x\n", 153 phy_name(phy), *val); 154 155 if (!(intel_de_read(i915, XELPDP_PORT_MSGBUS_TIMER(port, lane)) & 156 XELPDP_PORT_MSGBUS_TIMER_TIMED_OUT)) 157 drm_dbg_kms(&i915->drm, 158 "PHY %c Hardware did not detect a timeout\n", 159 phy_name(phy)); 160 161 intel_cx0_bus_reset(i915, port, lane); 162 return -ETIMEDOUT; 163 } 164 165 if (*val & XELPDP_PORT_P2M_ERROR_SET) { 166 drm_dbg_kms(&i915->drm, "PHY %c Error occurred during %s command. Status: 0x%x\n", phy_name(phy), 167 command == XELPDP_PORT_P2M_COMMAND_READ_ACK ? "read" : "write", *val); 168 intel_cx0_bus_reset(i915, port, lane); 169 return -EINVAL; 170 } 171 172 if (REG_FIELD_GET(XELPDP_PORT_P2M_COMMAND_TYPE_MASK, *val) != command) { 173 drm_dbg_kms(&i915->drm, "PHY %c Not a %s response. MSGBUS Status: 0x%x.\n", phy_name(phy), 174 command == XELPDP_PORT_P2M_COMMAND_READ_ACK ? "read" : "write", *val); 175 intel_cx0_bus_reset(i915, port, lane); 176 return -EINVAL; 177 } 178 179 return 0; 180 } 181 182 static int __intel_cx0_read_once(struct drm_i915_private *i915, enum port port, 183 int lane, u16 addr) 184 { 185 enum phy phy = intel_port_to_phy(i915, port); 186 int ack; 187 u32 val; 188 189 if (intel_de_wait_for_clear(i915, XELPDP_PORT_M2P_MSGBUS_CTL(port, lane), 190 XELPDP_PORT_M2P_TRANSACTION_PENDING, 191 XELPDP_MSGBUS_TIMEOUT_SLOW)) { 192 drm_dbg_kms(&i915->drm, 193 "PHY %c Timeout waiting for previous transaction to complete. Reset the bus and retry.\n", phy_name(phy)); 194 intel_cx0_bus_reset(i915, port, lane); 195 return -ETIMEDOUT; 196 } 197 198 intel_de_write(i915, XELPDP_PORT_M2P_MSGBUS_CTL(port, lane), 199 XELPDP_PORT_M2P_TRANSACTION_PENDING | 200 XELPDP_PORT_M2P_COMMAND_READ | 201 XELPDP_PORT_M2P_ADDRESS(addr)); 202 203 ack = intel_cx0_wait_for_ack(i915, port, XELPDP_PORT_P2M_COMMAND_READ_ACK, lane, &val); 204 if (ack < 0) 205 return ack; 206 207 intel_clear_response_ready_flag(i915, port, lane); 208 209 /* 210 * FIXME: Workaround to let HW to settle 211 * down and let the message bus to end up 212 * in a known state 213 */ 214 intel_cx0_bus_reset(i915, port, lane); 215 216 return REG_FIELD_GET(XELPDP_PORT_P2M_DATA_MASK, val); 217 } 218 219 static u8 __intel_cx0_read(struct drm_i915_private *i915, enum port port, 220 int lane, u16 addr) 221 { 222 enum phy phy = intel_port_to_phy(i915, port); 223 int i, status; 224 225 assert_dc_off(i915); 226 227 /* 3 tries is assumed to be enough to read successfully */ 228 for (i = 0; i < 3; i++) { 229 status = __intel_cx0_read_once(i915, port, lane, addr); 230 231 if (status >= 0) 232 return status; 233 } 234 235 drm_err_once(&i915->drm, "PHY %c Read %04x failed after %d retries.\n", 236 phy_name(phy), addr, i); 237 238 return 0; 239 } 240 241 static u8 intel_cx0_read(struct drm_i915_private *i915, enum port port, 242 u8 lane_mask, u16 addr) 243 { 244 int lane = lane_mask_to_lane(lane_mask); 245 246 return __intel_cx0_read(i915, port, lane, addr); 247 } 248 249 static int __intel_cx0_write_once(struct drm_i915_private *i915, enum port port, 250 int lane, u16 addr, u8 data, bool committed) 251 { 252 enum phy phy = intel_port_to_phy(i915, port); 253 int ack; 254 u32 val; 255 256 if (intel_de_wait_for_clear(i915, XELPDP_PORT_M2P_MSGBUS_CTL(port, lane), 257 XELPDP_PORT_M2P_TRANSACTION_PENDING, 258 XELPDP_MSGBUS_TIMEOUT_SLOW)) { 259 drm_dbg_kms(&i915->drm, 260 "PHY %c Timeout waiting for previous transaction to complete. Resetting the bus.\n", phy_name(phy)); 261 intel_cx0_bus_reset(i915, port, lane); 262 return -ETIMEDOUT; 263 } 264 265 intel_de_write(i915, XELPDP_PORT_M2P_MSGBUS_CTL(port, lane), 266 XELPDP_PORT_M2P_TRANSACTION_PENDING | 267 (committed ? XELPDP_PORT_M2P_COMMAND_WRITE_COMMITTED : 268 XELPDP_PORT_M2P_COMMAND_WRITE_UNCOMMITTED) | 269 XELPDP_PORT_M2P_DATA(data) | 270 XELPDP_PORT_M2P_ADDRESS(addr)); 271 272 if (intel_de_wait_for_clear(i915, XELPDP_PORT_M2P_MSGBUS_CTL(port, lane), 273 XELPDP_PORT_M2P_TRANSACTION_PENDING, 274 XELPDP_MSGBUS_TIMEOUT_SLOW)) { 275 drm_dbg_kms(&i915->drm, 276 "PHY %c Timeout waiting for write to complete. Resetting the bus.\n", phy_name(phy)); 277 intel_cx0_bus_reset(i915, port, lane); 278 return -ETIMEDOUT; 279 } 280 281 if (committed) { 282 ack = intel_cx0_wait_for_ack(i915, port, XELPDP_PORT_P2M_COMMAND_WRITE_ACK, lane, &val); 283 if (ack < 0) 284 return ack; 285 } else if ((intel_de_read(i915, XELPDP_PORT_P2M_MSGBUS_STATUS(port, lane)) & 286 XELPDP_PORT_P2M_ERROR_SET)) { 287 drm_dbg_kms(&i915->drm, 288 "PHY %c Error occurred during write command.\n", phy_name(phy)); 289 intel_cx0_bus_reset(i915, port, lane); 290 return -EINVAL; 291 } 292 293 intel_clear_response_ready_flag(i915, port, lane); 294 295 /* 296 * FIXME: Workaround to let HW to settle 297 * down and let the message bus to end up 298 * in a known state 299 */ 300 intel_cx0_bus_reset(i915, port, lane); 301 302 return 0; 303 } 304 305 static void __intel_cx0_write(struct drm_i915_private *i915, enum port port, 306 int lane, u16 addr, u8 data, bool committed) 307 { 308 enum phy phy = intel_port_to_phy(i915, port); 309 int i, status; 310 311 assert_dc_off(i915); 312 313 /* 3 tries is assumed to be enough to write successfully */ 314 for (i = 0; i < 3; i++) { 315 status = __intel_cx0_write_once(i915, port, lane, addr, data, committed); 316 317 if (status == 0) 318 return; 319 } 320 321 drm_err_once(&i915->drm, 322 "PHY %c Write %04x failed after %d retries.\n", phy_name(phy), addr, i); 323 } 324 325 static void intel_cx0_write(struct drm_i915_private *i915, enum port port, 326 u8 lane_mask, u16 addr, u8 data, bool committed) 327 { 328 int lane; 329 330 for_each_cx0_lane_in_mask(lane_mask, lane) 331 __intel_cx0_write(i915, port, lane, addr, data, committed); 332 } 333 334 static void intel_c20_sram_write(struct drm_i915_private *i915, enum port port, 335 int lane, u16 addr, u16 data) 336 { 337 assert_dc_off(i915); 338 339 intel_cx0_write(i915, port, lane, PHY_C20_WR_ADDRESS_H, addr >> 8, 0); 340 intel_cx0_write(i915, port, lane, PHY_C20_WR_ADDRESS_L, addr & 0xff, 0); 341 342 intel_cx0_write(i915, port, lane, PHY_C20_WR_DATA_H, data >> 8, 0); 343 intel_cx0_write(i915, port, lane, PHY_C20_WR_DATA_L, data & 0xff, 1); 344 } 345 346 static u16 intel_c20_sram_read(struct drm_i915_private *i915, enum port port, 347 int lane, u16 addr) 348 { 349 u16 val; 350 351 assert_dc_off(i915); 352 353 intel_cx0_write(i915, port, lane, PHY_C20_RD_ADDRESS_H, addr >> 8, 0); 354 intel_cx0_write(i915, port, lane, PHY_C20_RD_ADDRESS_L, addr & 0xff, 1); 355 356 val = intel_cx0_read(i915, port, lane, PHY_C20_RD_DATA_H); 357 val <<= 8; 358 val |= intel_cx0_read(i915, port, lane, PHY_C20_RD_DATA_L); 359 360 return val; 361 } 362 363 static void __intel_cx0_rmw(struct drm_i915_private *i915, enum port port, 364 int lane, u16 addr, u8 clear, u8 set, bool committed) 365 { 366 u8 old, val; 367 368 old = __intel_cx0_read(i915, port, lane, addr); 369 val = (old & ~clear) | set; 370 371 if (val != old) 372 __intel_cx0_write(i915, port, lane, addr, val, committed); 373 } 374 375 static void intel_cx0_rmw(struct drm_i915_private *i915, enum port port, 376 u8 lane_mask, u16 addr, u8 clear, u8 set, bool committed) 377 { 378 u8 lane; 379 380 for_each_cx0_lane_in_mask(lane_mask, lane) 381 __intel_cx0_rmw(i915, port, lane, addr, clear, set, committed); 382 } 383 384 static u8 intel_c10_get_tx_vboost_lvl(const struct intel_crtc_state *crtc_state) 385 { 386 if (intel_crtc_has_dp_encoder(crtc_state)) { 387 if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_EDP) && 388 (crtc_state->port_clock == 540000 || 389 crtc_state->port_clock == 810000)) 390 return 5; 391 else 392 return 4; 393 } else { 394 return 5; 395 } 396 } 397 398 static u8 intel_c10_get_tx_term_ctl(const struct intel_crtc_state *crtc_state) 399 { 400 if (intel_crtc_has_dp_encoder(crtc_state)) { 401 if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_EDP) && 402 (crtc_state->port_clock == 540000 || 403 crtc_state->port_clock == 810000)) 404 return 5; 405 else 406 return 2; 407 } else { 408 return 6; 409 } 410 } 411 412 void intel_cx0_phy_set_signal_levels(struct intel_encoder *encoder, 413 const struct intel_crtc_state *crtc_state) 414 { 415 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 416 const struct intel_ddi_buf_trans *trans; 417 enum phy phy = intel_port_to_phy(i915, encoder->port); 418 u8 owned_lane_mask = intel_cx0_get_owned_lane_mask(i915, encoder); 419 intel_wakeref_t wakeref; 420 int n_entries, ln; 421 422 wakeref = intel_cx0_phy_transaction_begin(encoder); 423 424 trans = encoder->get_buf_trans(encoder, crtc_state, &n_entries); 425 if (drm_WARN_ON_ONCE(&i915->drm, !trans)) { 426 intel_cx0_phy_transaction_end(encoder, wakeref); 427 return; 428 } 429 430 if (intel_is_c10phy(i915, phy)) { 431 intel_cx0_rmw(i915, encoder->port, owned_lane_mask, PHY_C10_VDR_CONTROL(1), 432 0, C10_VDR_CTRL_MSGBUS_ACCESS, MB_WRITE_COMMITTED); 433 intel_cx0_rmw(i915, encoder->port, owned_lane_mask, PHY_C10_VDR_CMN(3), 434 C10_CMN3_TXVBOOST_MASK, 435 C10_CMN3_TXVBOOST(intel_c10_get_tx_vboost_lvl(crtc_state)), 436 MB_WRITE_UNCOMMITTED); 437 intel_cx0_rmw(i915, encoder->port, owned_lane_mask, PHY_C10_VDR_TX(1), 438 C10_TX1_TERMCTL_MASK, 439 C10_TX1_TERMCTL(intel_c10_get_tx_term_ctl(crtc_state)), 440 MB_WRITE_COMMITTED); 441 } 442 443 for (ln = 0; ln < crtc_state->lane_count; ln++) { 444 int level = intel_ddi_level(encoder, crtc_state, ln); 445 int lane = ln / 2; 446 int tx = ln % 2; 447 u8 lane_mask = lane == 0 ? INTEL_CX0_LANE0 : INTEL_CX0_LANE1; 448 449 if (!(lane_mask & owned_lane_mask)) 450 continue; 451 452 intel_cx0_rmw(i915, encoder->port, lane_mask, PHY_CX0_VDROVRD_CTL(lane, tx, 0), 453 C10_PHY_OVRD_LEVEL_MASK, 454 C10_PHY_OVRD_LEVEL(trans->entries[level].snps.pre_cursor), 455 MB_WRITE_COMMITTED); 456 intel_cx0_rmw(i915, encoder->port, lane_mask, PHY_CX0_VDROVRD_CTL(lane, tx, 1), 457 C10_PHY_OVRD_LEVEL_MASK, 458 C10_PHY_OVRD_LEVEL(trans->entries[level].snps.vswing), 459 MB_WRITE_COMMITTED); 460 intel_cx0_rmw(i915, encoder->port, lane_mask, PHY_CX0_VDROVRD_CTL(lane, tx, 2), 461 C10_PHY_OVRD_LEVEL_MASK, 462 C10_PHY_OVRD_LEVEL(trans->entries[level].snps.post_cursor), 463 MB_WRITE_COMMITTED); 464 } 465 466 /* Write Override enables in 0xD71 */ 467 intel_cx0_rmw(i915, encoder->port, owned_lane_mask, PHY_C10_VDR_OVRD, 468 0, PHY_C10_VDR_OVRD_TX1 | PHY_C10_VDR_OVRD_TX2, 469 MB_WRITE_COMMITTED); 470 471 if (intel_is_c10phy(i915, phy)) 472 intel_cx0_rmw(i915, encoder->port, owned_lane_mask, PHY_C10_VDR_CONTROL(1), 473 0, C10_VDR_CTRL_UPDATE_CFG, MB_WRITE_COMMITTED); 474 475 intel_cx0_phy_transaction_end(encoder, wakeref); 476 } 477 478 /* 479 * Basic DP link rates with 38.4 MHz reference clock. 480 * Note: The tables below are with SSC. In non-ssc 481 * registers 0xC04 to 0xC08(pll[4] to pll[8]) will be 482 * programmed 0. 483 */ 484 485 static const struct intel_c10pll_state mtl_c10_dp_rbr = { 486 .clock = 162000, 487 .tx = 0x10, 488 .cmn = 0x21, 489 .pll[0] = 0xB4, 490 .pll[1] = 0, 491 .pll[2] = 0x30, 492 .pll[3] = 0x1, 493 .pll[4] = 0x26, 494 .pll[5] = 0x0C, 495 .pll[6] = 0x98, 496 .pll[7] = 0x46, 497 .pll[8] = 0x1, 498 .pll[9] = 0x1, 499 .pll[10] = 0, 500 .pll[11] = 0, 501 .pll[12] = 0xC0, 502 .pll[13] = 0, 503 .pll[14] = 0, 504 .pll[15] = 0x2, 505 .pll[16] = 0x84, 506 .pll[17] = 0x4F, 507 .pll[18] = 0xE5, 508 .pll[19] = 0x23, 509 }; 510 511 static const struct intel_c10pll_state mtl_c10_edp_r216 = { 512 .clock = 216000, 513 .tx = 0x10, 514 .cmn = 0x21, 515 .pll[0] = 0x4, 516 .pll[1] = 0, 517 .pll[2] = 0xA2, 518 .pll[3] = 0x1, 519 .pll[4] = 0x33, 520 .pll[5] = 0x10, 521 .pll[6] = 0x75, 522 .pll[7] = 0xB3, 523 .pll[8] = 0x1, 524 .pll[9] = 0x1, 525 .pll[10] = 0, 526 .pll[11] = 0, 527 .pll[12] = 0, 528 .pll[13] = 0, 529 .pll[14] = 0, 530 .pll[15] = 0x2, 531 .pll[16] = 0x85, 532 .pll[17] = 0x0F, 533 .pll[18] = 0xE6, 534 .pll[19] = 0x23, 535 }; 536 537 static const struct intel_c10pll_state mtl_c10_edp_r243 = { 538 .clock = 243000, 539 .tx = 0x10, 540 .cmn = 0x21, 541 .pll[0] = 0x34, 542 .pll[1] = 0, 543 .pll[2] = 0xDA, 544 .pll[3] = 0x1, 545 .pll[4] = 0x39, 546 .pll[5] = 0x12, 547 .pll[6] = 0xE3, 548 .pll[7] = 0xE9, 549 .pll[8] = 0x1, 550 .pll[9] = 0x1, 551 .pll[10] = 0, 552 .pll[11] = 0, 553 .pll[12] = 0x20, 554 .pll[13] = 0, 555 .pll[14] = 0, 556 .pll[15] = 0x2, 557 .pll[16] = 0x85, 558 .pll[17] = 0x8F, 559 .pll[18] = 0xE6, 560 .pll[19] = 0x23, 561 }; 562 563 static const struct intel_c10pll_state mtl_c10_dp_hbr1 = { 564 .clock = 270000, 565 .tx = 0x10, 566 .cmn = 0x21, 567 .pll[0] = 0xF4, 568 .pll[1] = 0, 569 .pll[2] = 0xF8, 570 .pll[3] = 0x0, 571 .pll[4] = 0x20, 572 .pll[5] = 0x0A, 573 .pll[6] = 0x29, 574 .pll[7] = 0x10, 575 .pll[8] = 0x1, /* Verify */ 576 .pll[9] = 0x1, 577 .pll[10] = 0, 578 .pll[11] = 0, 579 .pll[12] = 0xA0, 580 .pll[13] = 0, 581 .pll[14] = 0, 582 .pll[15] = 0x1, 583 .pll[16] = 0x84, 584 .pll[17] = 0x4F, 585 .pll[18] = 0xE5, 586 .pll[19] = 0x23, 587 }; 588 589 static const struct intel_c10pll_state mtl_c10_edp_r324 = { 590 .clock = 324000, 591 .tx = 0x10, 592 .cmn = 0x21, 593 .pll[0] = 0xB4, 594 .pll[1] = 0, 595 .pll[2] = 0x30, 596 .pll[3] = 0x1, 597 .pll[4] = 0x26, 598 .pll[5] = 0x0C, 599 .pll[6] = 0x98, 600 .pll[7] = 0x46, 601 .pll[8] = 0x1, 602 .pll[9] = 0x1, 603 .pll[10] = 0, 604 .pll[11] = 0, 605 .pll[12] = 0xC0, 606 .pll[13] = 0, 607 .pll[14] = 0, 608 .pll[15] = 0x1, 609 .pll[16] = 0x85, 610 .pll[17] = 0x4F, 611 .pll[18] = 0xE6, 612 .pll[19] = 0x23, 613 }; 614 615 static const struct intel_c10pll_state mtl_c10_edp_r432 = { 616 .clock = 432000, 617 .tx = 0x10, 618 .cmn = 0x21, 619 .pll[0] = 0x4, 620 .pll[1] = 0, 621 .pll[2] = 0xA2, 622 .pll[3] = 0x1, 623 .pll[4] = 0x33, 624 .pll[5] = 0x10, 625 .pll[6] = 0x75, 626 .pll[7] = 0xB3, 627 .pll[8] = 0x1, 628 .pll[9] = 0x1, 629 .pll[10] = 0, 630 .pll[11] = 0, 631 .pll[12] = 0, 632 .pll[13] = 0, 633 .pll[14] = 0, 634 .pll[15] = 0x1, 635 .pll[16] = 0x85, 636 .pll[17] = 0x0F, 637 .pll[18] = 0xE6, 638 .pll[19] = 0x23, 639 }; 640 641 static const struct intel_c10pll_state mtl_c10_dp_hbr2 = { 642 .clock = 540000, 643 .tx = 0x10, 644 .cmn = 0x21, 645 .pll[0] = 0xF4, 646 .pll[1] = 0, 647 .pll[2] = 0xF8, 648 .pll[3] = 0, 649 .pll[4] = 0x20, 650 .pll[5] = 0x0A, 651 .pll[6] = 0x29, 652 .pll[7] = 0x10, 653 .pll[8] = 0x1, 654 .pll[9] = 0x1, 655 .pll[10] = 0, 656 .pll[11] = 0, 657 .pll[12] = 0xA0, 658 .pll[13] = 0, 659 .pll[14] = 0, 660 .pll[15] = 0, 661 .pll[16] = 0x84, 662 .pll[17] = 0x4F, 663 .pll[18] = 0xE5, 664 .pll[19] = 0x23, 665 }; 666 667 static const struct intel_c10pll_state mtl_c10_edp_r675 = { 668 .clock = 675000, 669 .tx = 0x10, 670 .cmn = 0x21, 671 .pll[0] = 0xB4, 672 .pll[1] = 0, 673 .pll[2] = 0x3E, 674 .pll[3] = 0x1, 675 .pll[4] = 0xA8, 676 .pll[5] = 0x0C, 677 .pll[6] = 0x33, 678 .pll[7] = 0x54, 679 .pll[8] = 0x1, 680 .pll[9] = 0x1, 681 .pll[10] = 0, 682 .pll[11] = 0, 683 .pll[12] = 0xC8, 684 .pll[13] = 0, 685 .pll[14] = 0, 686 .pll[15] = 0, 687 .pll[16] = 0x85, 688 .pll[17] = 0x8F, 689 .pll[18] = 0xE6, 690 .pll[19] = 0x23, 691 }; 692 693 static const struct intel_c10pll_state mtl_c10_dp_hbr3 = { 694 .clock = 810000, 695 .tx = 0x10, 696 .cmn = 0x21, 697 .pll[0] = 0x34, 698 .pll[1] = 0, 699 .pll[2] = 0x84, 700 .pll[3] = 0x1, 701 .pll[4] = 0x30, 702 .pll[5] = 0x0F, 703 .pll[6] = 0x3D, 704 .pll[7] = 0x98, 705 .pll[8] = 0x1, 706 .pll[9] = 0x1, 707 .pll[10] = 0, 708 .pll[11] = 0, 709 .pll[12] = 0xF0, 710 .pll[13] = 0, 711 .pll[14] = 0, 712 .pll[15] = 0, 713 .pll[16] = 0x84, 714 .pll[17] = 0x0F, 715 .pll[18] = 0xE5, 716 .pll[19] = 0x23, 717 }; 718 719 static const struct intel_c10pll_state * const mtl_c10_dp_tables[] = { 720 &mtl_c10_dp_rbr, 721 &mtl_c10_dp_hbr1, 722 &mtl_c10_dp_hbr2, 723 &mtl_c10_dp_hbr3, 724 NULL, 725 }; 726 727 static const struct intel_c10pll_state * const mtl_c10_edp_tables[] = { 728 &mtl_c10_dp_rbr, 729 &mtl_c10_edp_r216, 730 &mtl_c10_edp_r243, 731 &mtl_c10_dp_hbr1, 732 &mtl_c10_edp_r324, 733 &mtl_c10_edp_r432, 734 &mtl_c10_dp_hbr2, 735 &mtl_c10_edp_r675, 736 &mtl_c10_dp_hbr3, 737 NULL, 738 }; 739 740 /* C20 basic DP 1.4 tables */ 741 static const struct intel_c20pll_state mtl_c20_dp_rbr = { 742 .link_bit_rate = 162000, 743 .clock = 162000, 744 .tx = { 0xbe88, /* tx cfg0 */ 745 0x5800, /* tx cfg1 */ 746 0x0000, /* tx cfg2 */ 747 }, 748 .cmn = {0x0500, /* cmn cfg0*/ 749 0x0005, /* cmn cfg1 */ 750 0x0000, /* cmn cfg2 */ 751 0x0000, /* cmn cfg3 */ 752 }, 753 .mpllb = { 0x50a8, /* mpllb cfg0 */ 754 0x2120, /* mpllb cfg1 */ 755 0xcd9a, /* mpllb cfg2 */ 756 0xbfc1, /* mpllb cfg3 */ 757 0x5ab8, /* mpllb cfg4 */ 758 0x4c34, /* mpllb cfg5 */ 759 0x2000, /* mpllb cfg6 */ 760 0x0001, /* mpllb cfg7 */ 761 0x6000, /* mpllb cfg8 */ 762 0x0000, /* mpllb cfg9 */ 763 0x0000, /* mpllb cfg10 */ 764 }, 765 }; 766 767 static const struct intel_c20pll_state mtl_c20_dp_hbr1 = { 768 .link_bit_rate = 270000, 769 .clock = 270000, 770 .tx = { 0xbe88, /* tx cfg0 */ 771 0x4800, /* tx cfg1 */ 772 0x0000, /* tx cfg2 */ 773 }, 774 .cmn = {0x0500, /* cmn cfg0*/ 775 0x0005, /* cmn cfg1 */ 776 0x0000, /* cmn cfg2 */ 777 0x0000, /* cmn cfg3 */ 778 }, 779 .mpllb = { 0x308c, /* mpllb cfg0 */ 780 0x2110, /* mpllb cfg1 */ 781 0xcc9c, /* mpllb cfg2 */ 782 0xbfc1, /* mpllb cfg3 */ 783 0x4b9a, /* mpllb cfg4 */ 784 0x3f81, /* mpllb cfg5 */ 785 0x2000, /* mpllb cfg6 */ 786 0x0001, /* mpllb cfg7 */ 787 0x5000, /* mpllb cfg8 */ 788 0x0000, /* mpllb cfg9 */ 789 0x0000, /* mpllb cfg10 */ 790 }, 791 }; 792 793 static const struct intel_c20pll_state mtl_c20_dp_hbr2 = { 794 .link_bit_rate = 540000, 795 .clock = 540000, 796 .tx = { 0xbe88, /* tx cfg0 */ 797 0x4800, /* tx cfg1 */ 798 0x0000, /* tx cfg2 */ 799 }, 800 .cmn = {0x0500, /* cmn cfg0*/ 801 0x0005, /* cmn cfg1 */ 802 0x0000, /* cmn cfg2 */ 803 0x0000, /* cmn cfg3 */ 804 }, 805 .mpllb = { 0x108c, /* mpllb cfg0 */ 806 0x2108, /* mpllb cfg1 */ 807 0xcc9c, /* mpllb cfg2 */ 808 0xbfc1, /* mpllb cfg3 */ 809 0x4b9a, /* mpllb cfg4 */ 810 0x3f81, /* mpllb cfg5 */ 811 0x2000, /* mpllb cfg6 */ 812 0x0001, /* mpllb cfg7 */ 813 0x5000, /* mpllb cfg8 */ 814 0x0000, /* mpllb cfg9 */ 815 0x0000, /* mpllb cfg10 */ 816 }, 817 }; 818 819 static const struct intel_c20pll_state mtl_c20_dp_hbr3 = { 820 .link_bit_rate = 810000, 821 .clock = 810000, 822 .tx = { 0xbe88, /* tx cfg0 */ 823 0x4800, /* tx cfg1 */ 824 0x0000, /* tx cfg2 */ 825 }, 826 .cmn = {0x0500, /* cmn cfg0*/ 827 0x0005, /* cmn cfg1 */ 828 0x0000, /* cmn cfg2 */ 829 0x0000, /* cmn cfg3 */ 830 }, 831 .mpllb = { 0x10d2, /* mpllb cfg0 */ 832 0x2108, /* mpllb cfg1 */ 833 0x8d98, /* mpllb cfg2 */ 834 0xbfc1, /* mpllb cfg3 */ 835 0x7166, /* mpllb cfg4 */ 836 0x5f42, /* mpllb cfg5 */ 837 0x2000, /* mpllb cfg6 */ 838 0x0001, /* mpllb cfg7 */ 839 0x7800, /* mpllb cfg8 */ 840 0x0000, /* mpllb cfg9 */ 841 0x0000, /* mpllb cfg10 */ 842 }, 843 }; 844 845 /* C20 basic DP 2.0 tables */ 846 static const struct intel_c20pll_state mtl_c20_dp_uhbr10 = { 847 .link_bit_rate = 1000000, /* 10 Gbps */ 848 .clock = 312500, 849 .tx = { 0xbe21, /* tx cfg0 */ 850 0x4800, /* tx cfg1 */ 851 0x0000, /* tx cfg2 */ 852 }, 853 .cmn = {0x0500, /* cmn cfg0*/ 854 0x0005, /* cmn cfg1 */ 855 0x0000, /* cmn cfg2 */ 856 0x0000, /* cmn cfg3 */ 857 }, 858 .mplla = { 0x3104, /* mplla cfg0 */ 859 0xd105, /* mplla cfg1 */ 860 0xc025, /* mplla cfg2 */ 861 0xc025, /* mplla cfg3 */ 862 0x8c00, /* mplla cfg4 */ 863 0x759a, /* mplla cfg5 */ 864 0x4000, /* mplla cfg6 */ 865 0x0003, /* mplla cfg7 */ 866 0x3555, /* mplla cfg8 */ 867 0x0001, /* mplla cfg9 */ 868 }, 869 }; 870 871 static const struct intel_c20pll_state mtl_c20_dp_uhbr13_5 = { 872 .link_bit_rate = 1350000, /* 13.5 Gbps */ 873 .clock = 421875, 874 .tx = { 0xbea0, /* tx cfg0 */ 875 0x4800, /* tx cfg1 */ 876 0x0000, /* tx cfg2 */ 877 }, 878 .cmn = {0x0500, /* cmn cfg0*/ 879 0x0005, /* cmn cfg1 */ 880 0x0000, /* cmn cfg2 */ 881 0x0000, /* cmn cfg3 */ 882 }, 883 .mpllb = { 0x015f, /* mpllb cfg0 */ 884 0x2205, /* mpllb cfg1 */ 885 0x1b17, /* mpllb cfg2 */ 886 0xffc1, /* mpllb cfg3 */ 887 0xe100, /* mpllb cfg4 */ 888 0xbd00, /* mpllb cfg5 */ 889 0x2000, /* mpllb cfg6 */ 890 0x0001, /* mpllb cfg7 */ 891 0x4800, /* mpllb cfg8 */ 892 0x0000, /* mpllb cfg9 */ 893 0x0000, /* mpllb cfg10 */ 894 }, 895 }; 896 897 static const struct intel_c20pll_state mtl_c20_dp_uhbr20 = { 898 .link_bit_rate = 2000000, /* 20 Gbps */ 899 .clock = 625000, 900 .tx = { 0xbe20, /* tx cfg0 */ 901 0x4800, /* tx cfg1 */ 902 0x0000, /* tx cfg2 */ 903 }, 904 .cmn = {0x0500, /* cmn cfg0*/ 905 0x0005, /* cmn cfg1 */ 906 0x0000, /* cmn cfg2 */ 907 0x0000, /* cmn cfg3 */ 908 }, 909 .mplla = { 0x3104, /* mplla cfg0 */ 910 0xd105, /* mplla cfg1 */ 911 0xc025, /* mplla cfg2 */ 912 0xc025, /* mplla cfg3 */ 913 0xa6ab, /* mplla cfg4 */ 914 0x8c00, /* mplla cfg5 */ 915 0x4000, /* mplla cfg6 */ 916 0x0003, /* mplla cfg7 */ 917 0x3555, /* mplla cfg8 */ 918 0x0001, /* mplla cfg9 */ 919 }, 920 }; 921 922 static const struct intel_c20pll_state * const mtl_c20_dp_tables[] = { 923 &mtl_c20_dp_rbr, 924 &mtl_c20_dp_hbr1, 925 &mtl_c20_dp_hbr2, 926 &mtl_c20_dp_hbr3, 927 &mtl_c20_dp_uhbr10, 928 &mtl_c20_dp_uhbr13_5, 929 &mtl_c20_dp_uhbr20, 930 NULL, 931 }; 932 933 /* 934 * HDMI link rates with 38.4 MHz reference clock. 935 */ 936 937 static const struct intel_c10pll_state mtl_c10_hdmi_25_2 = { 938 .clock = 25200, 939 .tx = 0x10, 940 .cmn = 0x1, 941 .pll[0] = 0x4, 942 .pll[1] = 0, 943 .pll[2] = 0xB2, 944 .pll[3] = 0, 945 .pll[4] = 0, 946 .pll[5] = 0, 947 .pll[6] = 0, 948 .pll[7] = 0, 949 .pll[8] = 0x20, 950 .pll[9] = 0x1, 951 .pll[10] = 0, 952 .pll[11] = 0, 953 .pll[12] = 0, 954 .pll[13] = 0, 955 .pll[14] = 0, 956 .pll[15] = 0xD, 957 .pll[16] = 0x6, 958 .pll[17] = 0x8F, 959 .pll[18] = 0x84, 960 .pll[19] = 0x23, 961 }; 962 963 static const struct intel_c10pll_state mtl_c10_hdmi_27_0 = { 964 .clock = 27000, 965 .tx = 0x10, 966 .cmn = 0x1, 967 .pll[0] = 0x34, 968 .pll[1] = 0, 969 .pll[2] = 0xC0, 970 .pll[3] = 0, 971 .pll[4] = 0, 972 .pll[5] = 0, 973 .pll[6] = 0, 974 .pll[7] = 0, 975 .pll[8] = 0x20, 976 .pll[9] = 0x1, 977 .pll[10] = 0, 978 .pll[11] = 0, 979 .pll[12] = 0x80, 980 .pll[13] = 0, 981 .pll[14] = 0, 982 .pll[15] = 0xD, 983 .pll[16] = 0x6, 984 .pll[17] = 0xCF, 985 .pll[18] = 0x84, 986 .pll[19] = 0x23, 987 }; 988 989 static const struct intel_c10pll_state mtl_c10_hdmi_74_25 = { 990 .clock = 74250, 991 .tx = 0x10, 992 .cmn = 0x1, 993 .pll[0] = 0xF4, 994 .pll[1] = 0, 995 .pll[2] = 0x7A, 996 .pll[3] = 0, 997 .pll[4] = 0, 998 .pll[5] = 0, 999 .pll[6] = 0, 1000 .pll[7] = 0, 1001 .pll[8] = 0x20, 1002 .pll[9] = 0x1, 1003 .pll[10] = 0, 1004 .pll[11] = 0, 1005 .pll[12] = 0x58, 1006 .pll[13] = 0, 1007 .pll[14] = 0, 1008 .pll[15] = 0xB, 1009 .pll[16] = 0x6, 1010 .pll[17] = 0xF, 1011 .pll[18] = 0x85, 1012 .pll[19] = 0x23, 1013 }; 1014 1015 static const struct intel_c10pll_state mtl_c10_hdmi_148_5 = { 1016 .clock = 148500, 1017 .tx = 0x10, 1018 .cmn = 0x1, 1019 .pll[0] = 0xF4, 1020 .pll[1] = 0, 1021 .pll[2] = 0x7A, 1022 .pll[3] = 0, 1023 .pll[4] = 0, 1024 .pll[5] = 0, 1025 .pll[6] = 0, 1026 .pll[7] = 0, 1027 .pll[8] = 0x20, 1028 .pll[9] = 0x1, 1029 .pll[10] = 0, 1030 .pll[11] = 0, 1031 .pll[12] = 0x58, 1032 .pll[13] = 0, 1033 .pll[14] = 0, 1034 .pll[15] = 0xA, 1035 .pll[16] = 0x6, 1036 .pll[17] = 0xF, 1037 .pll[18] = 0x85, 1038 .pll[19] = 0x23, 1039 }; 1040 1041 static const struct intel_c10pll_state mtl_c10_hdmi_594 = { 1042 .clock = 594000, 1043 .tx = 0x10, 1044 .cmn = 0x1, 1045 .pll[0] = 0xF4, 1046 .pll[1] = 0, 1047 .pll[2] = 0x7A, 1048 .pll[3] = 0, 1049 .pll[4] = 0, 1050 .pll[5] = 0, 1051 .pll[6] = 0, 1052 .pll[7] = 0, 1053 .pll[8] = 0x20, 1054 .pll[9] = 0x1, 1055 .pll[10] = 0, 1056 .pll[11] = 0, 1057 .pll[12] = 0x58, 1058 .pll[13] = 0, 1059 .pll[14] = 0, 1060 .pll[15] = 0x8, 1061 .pll[16] = 0x6, 1062 .pll[17] = 0xF, 1063 .pll[18] = 0x85, 1064 .pll[19] = 0x23, 1065 }; 1066 1067 /* Precomputed C10 HDMI PLL tables */ 1068 static const struct intel_c10pll_state mtl_c10_hdmi_27027 = { 1069 .clock = 27027, 1070 .tx = 0x10, 1071 .cmn = 0x1, 1072 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xC0, .pll[3] = 0x00, .pll[4] = 0x00, 1073 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1074 .pll[10] = 0xFF, .pll[11] = 0xCC, .pll[12] = 0x9C, .pll[13] = 0xCB, .pll[14] = 0xCC, 1075 .pll[15] = 0x0D, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1076 }; 1077 1078 static const struct intel_c10pll_state mtl_c10_hdmi_28320 = { 1079 .clock = 28320, 1080 .tx = 0x10, 1081 .cmn = 0x1, 1082 .pll[0] = 0x04, .pll[1] = 0x00, .pll[2] = 0xCC, .pll[3] = 0x00, .pll[4] = 0x00, 1083 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1084 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x00, .pll[13] = 0x00, .pll[14] = 0x00, 1085 .pll[15] = 0x0D, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1086 }; 1087 1088 static const struct intel_c10pll_state mtl_c10_hdmi_30240 = { 1089 .clock = 30240, 1090 .tx = 0x10, 1091 .cmn = 0x1, 1092 .pll[0] = 0x04, .pll[1] = 0x00, .pll[2] = 0xDC, .pll[3] = 0x00, .pll[4] = 0x00, 1093 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1094 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x00, .pll[13] = 0x00, .pll[14] = 0x00, 1095 .pll[15] = 0x0D, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1096 }; 1097 1098 static const struct intel_c10pll_state mtl_c10_hdmi_31500 = { 1099 .clock = 31500, 1100 .tx = 0x10, 1101 .cmn = 0x1, 1102 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x62, .pll[3] = 0x00, .pll[4] = 0x00, 1103 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1104 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0xA0, .pll[13] = 0x00, .pll[14] = 0x00, 1105 .pll[15] = 0x0C, .pll[16] = 0x09, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1106 }; 1107 1108 static const struct intel_c10pll_state mtl_c10_hdmi_36000 = { 1109 .clock = 36000, 1110 .tx = 0x10, 1111 .cmn = 0x1, 1112 .pll[0] = 0xC4, .pll[1] = 0x00, .pll[2] = 0x76, .pll[3] = 0x00, .pll[4] = 0x00, 1113 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1114 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x00, .pll[13] = 0x00, .pll[14] = 0x00, 1115 .pll[15] = 0x0C, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1116 }; 1117 1118 static const struct intel_c10pll_state mtl_c10_hdmi_40000 = { 1119 .clock = 40000, 1120 .tx = 0x10, 1121 .cmn = 0x1, 1122 .pll[0] = 0xB4, .pll[1] = 0x00, .pll[2] = 0x86, .pll[3] = 0x00, .pll[4] = 0x00, 1123 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1124 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0x55, .pll[13] = 0x55, .pll[14] = 0x55, 1125 .pll[15] = 0x0C, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1126 }; 1127 1128 static const struct intel_c10pll_state mtl_c10_hdmi_49500 = { 1129 .clock = 49500, 1130 .tx = 0x10, 1131 .cmn = 0x1, 1132 .pll[0] = 0x74, .pll[1] = 0x00, .pll[2] = 0xAE, .pll[3] = 0x00, .pll[4] = 0x00, 1133 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1134 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x20, .pll[13] = 0x00, .pll[14] = 0x00, 1135 .pll[15] = 0x0C, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1136 }; 1137 1138 static const struct intel_c10pll_state mtl_c10_hdmi_50000 = { 1139 .clock = 50000, 1140 .tx = 0x10, 1141 .cmn = 0x1, 1142 .pll[0] = 0x74, .pll[1] = 0x00, .pll[2] = 0xB0, .pll[3] = 0x00, .pll[4] = 0x00, 1143 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1144 .pll[10] = 0xFF, .pll[11] = 0xAA, .pll[12] = 0x2A, .pll[13] = 0xA9, .pll[14] = 0xAA, 1145 .pll[15] = 0x0C, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1146 }; 1147 1148 static const struct intel_c10pll_state mtl_c10_hdmi_57284 = { 1149 .clock = 57284, 1150 .tx = 0x10, 1151 .cmn = 0x1, 1152 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xCE, .pll[3] = 0x00, .pll[4] = 0x00, 1153 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1154 .pll[10] = 0xFF, .pll[11] = 0x77, .pll[12] = 0x57, .pll[13] = 0x77, .pll[14] = 0x77, 1155 .pll[15] = 0x0C, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1156 }; 1157 1158 static const struct intel_c10pll_state mtl_c10_hdmi_58000 = { 1159 .clock = 58000, 1160 .tx = 0x10, 1161 .cmn = 0x1, 1162 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xD0, .pll[3] = 0x00, .pll[4] = 0x00, 1163 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1164 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0xD5, .pll[13] = 0x55, .pll[14] = 0x55, 1165 .pll[15] = 0x0C, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1166 }; 1167 1168 static const struct intel_c10pll_state mtl_c10_hdmi_65000 = { 1169 .clock = 65000, 1170 .tx = 0x10, 1171 .cmn = 0x1, 1172 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x66, .pll[3] = 0x00, .pll[4] = 0x00, 1173 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1174 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0xB5, .pll[13] = 0x55, .pll[14] = 0x55, 1175 .pll[15] = 0x0B, .pll[16] = 0x09, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1176 }; 1177 1178 static const struct intel_c10pll_state mtl_c10_hdmi_71000 = { 1179 .clock = 71000, 1180 .tx = 0x10, 1181 .cmn = 0x1, 1182 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x72, .pll[3] = 0x00, .pll[4] = 0x00, 1183 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1184 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0xF5, .pll[13] = 0x55, .pll[14] = 0x55, 1185 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1186 }; 1187 1188 static const struct intel_c10pll_state mtl_c10_hdmi_74176 = { 1189 .clock = 74176, 1190 .tx = 0x10, 1191 .cmn = 0x1, 1192 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x7A, .pll[3] = 0x00, .pll[4] = 0x00, 1193 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1194 .pll[10] = 0xFF, .pll[11] = 0x44, .pll[12] = 0x44, .pll[13] = 0x44, .pll[14] = 0x44, 1195 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1196 }; 1197 1198 static const struct intel_c10pll_state mtl_c10_hdmi_75000 = { 1199 .clock = 75000, 1200 .tx = 0x10, 1201 .cmn = 0x1, 1202 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x7C, .pll[3] = 0x00, .pll[4] = 0x00, 1203 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1204 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x20, .pll[13] = 0x00, .pll[14] = 0x00, 1205 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1206 }; 1207 1208 static const struct intel_c10pll_state mtl_c10_hdmi_78750 = { 1209 .clock = 78750, 1210 .tx = 0x10, 1211 .cmn = 0x1, 1212 .pll[0] = 0xB4, .pll[1] = 0x00, .pll[2] = 0x84, .pll[3] = 0x00, .pll[4] = 0x00, 1213 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1214 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x08, .pll[13] = 0x00, .pll[14] = 0x00, 1215 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1216 }; 1217 1218 static const struct intel_c10pll_state mtl_c10_hdmi_85500 = { 1219 .clock = 85500, 1220 .tx = 0x10, 1221 .cmn = 0x1, 1222 .pll[0] = 0xB4, .pll[1] = 0x00, .pll[2] = 0x92, .pll[3] = 0x00, .pll[4] = 0x00, 1223 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1224 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x10, .pll[13] = 0x00, .pll[14] = 0x00, 1225 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1226 }; 1227 1228 static const struct intel_c10pll_state mtl_c10_hdmi_88750 = { 1229 .clock = 88750, 1230 .tx = 0x10, 1231 .cmn = 0x1, 1232 .pll[0] = 0x74, .pll[1] = 0x00, .pll[2] = 0x98, .pll[3] = 0x00, .pll[4] = 0x00, 1233 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1234 .pll[10] = 0xFF, .pll[11] = 0xAA, .pll[12] = 0x72, .pll[13] = 0xA9, .pll[14] = 0xAA, 1235 .pll[15] = 0x0B, .pll[16] = 0x09, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1236 }; 1237 1238 static const struct intel_c10pll_state mtl_c10_hdmi_106500 = { 1239 .clock = 106500, 1240 .tx = 0x10, 1241 .cmn = 0x1, 1242 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xBC, .pll[3] = 0x00, .pll[4] = 0x00, 1243 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1244 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0xF0, .pll[13] = 0x00, .pll[14] = 0x00, 1245 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1246 }; 1247 1248 static const struct intel_c10pll_state mtl_c10_hdmi_108000 = { 1249 .clock = 108000, 1250 .tx = 0x10, 1251 .cmn = 0x1, 1252 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xC0, .pll[3] = 0x00, .pll[4] = 0x00, 1253 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1254 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x80, .pll[13] = 0x00, .pll[14] = 0x00, 1255 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1256 }; 1257 1258 static const struct intel_c10pll_state mtl_c10_hdmi_115500 = { 1259 .clock = 115500, 1260 .tx = 0x10, 1261 .cmn = 0x1, 1262 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xD0, .pll[3] = 0x00, .pll[4] = 0x00, 1263 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1264 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x50, .pll[13] = 0x00, .pll[14] = 0x00, 1265 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1266 }; 1267 1268 static const struct intel_c10pll_state mtl_c10_hdmi_119000 = { 1269 .clock = 119000, 1270 .tx = 0x10, 1271 .cmn = 0x1, 1272 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xD6, .pll[3] = 0x00, .pll[4] = 0x00, 1273 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1274 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0xF5, .pll[13] = 0x55, .pll[14] = 0x55, 1275 .pll[15] = 0x0B, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1276 }; 1277 1278 static const struct intel_c10pll_state mtl_c10_hdmi_135000 = { 1279 .clock = 135000, 1280 .tx = 0x10, 1281 .cmn = 0x1, 1282 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x6C, .pll[3] = 0x00, .pll[4] = 0x00, 1283 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1284 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x50, .pll[13] = 0x00, .pll[14] = 0x00, 1285 .pll[15] = 0x0A, .pll[16] = 0x09, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1286 }; 1287 1288 static const struct intel_c10pll_state mtl_c10_hdmi_138500 = { 1289 .clock = 138500, 1290 .tx = 0x10, 1291 .cmn = 0x1, 1292 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x70, .pll[3] = 0x00, .pll[4] = 0x00, 1293 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1294 .pll[10] = 0xFF, .pll[11] = 0xAA, .pll[12] = 0x22, .pll[13] = 0xA9, .pll[14] = 0xAA, 1295 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1296 }; 1297 1298 static const struct intel_c10pll_state mtl_c10_hdmi_147160 = { 1299 .clock = 147160, 1300 .tx = 0x10, 1301 .cmn = 0x1, 1302 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x78, .pll[3] = 0x00, .pll[4] = 0x00, 1303 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1304 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0xA5, .pll[13] = 0x55, .pll[14] = 0x55, 1305 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1306 }; 1307 1308 static const struct intel_c10pll_state mtl_c10_hdmi_148352 = { 1309 .clock = 148352, 1310 .tx = 0x10, 1311 .cmn = 0x1, 1312 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x7A, .pll[3] = 0x00, .pll[4] = 0x00, 1313 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1314 .pll[10] = 0xFF, .pll[11] = 0x44, .pll[12] = 0x44, .pll[13] = 0x44, .pll[14] = 0x44, 1315 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1316 }; 1317 1318 static const struct intel_c10pll_state mtl_c10_hdmi_154000 = { 1319 .clock = 154000, 1320 .tx = 0x10, 1321 .cmn = 0x1, 1322 .pll[0] = 0xB4, .pll[1] = 0x00, .pll[2] = 0x80, .pll[3] = 0x00, .pll[4] = 0x00, 1323 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1324 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0x35, .pll[13] = 0x55, .pll[14] = 0x55, 1325 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1326 }; 1327 1328 static const struct intel_c10pll_state mtl_c10_hdmi_162000 = { 1329 .clock = 162000, 1330 .tx = 0x10, 1331 .cmn = 0x1, 1332 .pll[0] = 0xB4, .pll[1] = 0x00, .pll[2] = 0x88, .pll[3] = 0x00, .pll[4] = 0x00, 1333 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1334 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x60, .pll[13] = 0x00, .pll[14] = 0x00, 1335 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1336 }; 1337 1338 static const struct intel_c10pll_state mtl_c10_hdmi_167000 = { 1339 .clock = 167000, 1340 .tx = 0x10, 1341 .cmn = 0x1, 1342 .pll[0] = 0xB4, .pll[1] = 0x00, .pll[2] = 0x8C, .pll[3] = 0x00, .pll[4] = 0x00, 1343 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1344 .pll[10] = 0xFF, .pll[11] = 0xAA, .pll[12] = 0xFA, .pll[13] = 0xA9, .pll[14] = 0xAA, 1345 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1346 }; 1347 1348 static const struct intel_c10pll_state mtl_c10_hdmi_197802 = { 1349 .clock = 197802, 1350 .tx = 0x10, 1351 .cmn = 0x1, 1352 .pll[0] = 0x74, .pll[1] = 0x00, .pll[2] = 0xAE, .pll[3] = 0x00, .pll[4] = 0x00, 1353 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1354 .pll[10] = 0xFF, .pll[11] = 0x99, .pll[12] = 0x05, .pll[13] = 0x98, .pll[14] = 0x99, 1355 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1356 }; 1357 1358 static const struct intel_c10pll_state mtl_c10_hdmi_198000 = { 1359 .clock = 198000, 1360 .tx = 0x10, 1361 .cmn = 0x1, 1362 .pll[0] = 0x74, .pll[1] = 0x00, .pll[2] = 0xAE, .pll[3] = 0x00, .pll[4] = 0x00, 1363 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1364 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x20, .pll[13] = 0x00, .pll[14] = 0x00, 1365 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1366 }; 1367 1368 static const struct intel_c10pll_state mtl_c10_hdmi_209800 = { 1369 .clock = 209800, 1370 .tx = 0x10, 1371 .cmn = 0x1, 1372 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xBA, .pll[3] = 0x00, .pll[4] = 0x00, 1373 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1374 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0x45, .pll[13] = 0x55, .pll[14] = 0x55, 1375 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1376 }; 1377 1378 static const struct intel_c10pll_state mtl_c10_hdmi_241500 = { 1379 .clock = 241500, 1380 .tx = 0x10, 1381 .cmn = 0x1, 1382 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xDA, .pll[3] = 0x00, .pll[4] = 0x00, 1383 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1384 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0xC8, .pll[13] = 0x00, .pll[14] = 0x00, 1385 .pll[15] = 0x0A, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1386 }; 1387 1388 static const struct intel_c10pll_state mtl_c10_hdmi_262750 = { 1389 .clock = 262750, 1390 .tx = 0x10, 1391 .cmn = 0x1, 1392 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x68, .pll[3] = 0x00, .pll[4] = 0x00, 1393 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1394 .pll[10] = 0xFF, .pll[11] = 0xAA, .pll[12] = 0x6C, .pll[13] = 0xA9, .pll[14] = 0xAA, 1395 .pll[15] = 0x09, .pll[16] = 0x09, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1396 }; 1397 1398 static const struct intel_c10pll_state mtl_c10_hdmi_268500 = { 1399 .clock = 268500, 1400 .tx = 0x10, 1401 .cmn = 0x1, 1402 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x6A, .pll[3] = 0x00, .pll[4] = 0x00, 1403 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1404 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0xEC, .pll[13] = 0x00, .pll[14] = 0x00, 1405 .pll[15] = 0x09, .pll[16] = 0x09, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1406 }; 1407 1408 static const struct intel_c10pll_state mtl_c10_hdmi_296703 = { 1409 .clock = 296703, 1410 .tx = 0x10, 1411 .cmn = 0x1, 1412 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x7A, .pll[3] = 0x00, .pll[4] = 0x00, 1413 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1414 .pll[10] = 0xFF, .pll[11] = 0x33, .pll[12] = 0x44, .pll[13] = 0x33, .pll[14] = 0x33, 1415 .pll[15] = 0x09, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1416 }; 1417 1418 static const struct intel_c10pll_state mtl_c10_hdmi_297000 = { 1419 .clock = 297000, 1420 .tx = 0x10, 1421 .cmn = 0x1, 1422 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x7A, .pll[3] = 0x00, .pll[4] = 0x00, 1423 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1424 .pll[10] = 0xFF, .pll[11] = 0x00, .pll[12] = 0x58, .pll[13] = 0x00, .pll[14] = 0x00, 1425 .pll[15] = 0x09, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1426 }; 1427 1428 static const struct intel_c10pll_state mtl_c10_hdmi_319750 = { 1429 .clock = 319750, 1430 .tx = 0x10, 1431 .cmn = 0x1, 1432 .pll[0] = 0xB4, .pll[1] = 0x00, .pll[2] = 0x86, .pll[3] = 0x00, .pll[4] = 0x00, 1433 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1434 .pll[10] = 0xFF, .pll[11] = 0xAA, .pll[12] = 0x44, .pll[13] = 0xA9, .pll[14] = 0xAA, 1435 .pll[15] = 0x09, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1436 }; 1437 1438 static const struct intel_c10pll_state mtl_c10_hdmi_497750 = { 1439 .clock = 497750, 1440 .tx = 0x10, 1441 .cmn = 0x1, 1442 .pll[0] = 0x34, .pll[1] = 0x00, .pll[2] = 0xE2, .pll[3] = 0x00, .pll[4] = 0x00, 1443 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1444 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0x9F, .pll[13] = 0x55, .pll[14] = 0x55, 1445 .pll[15] = 0x09, .pll[16] = 0x08, .pll[17] = 0xCF, .pll[18] = 0x84, .pll[19] = 0x23, 1446 }; 1447 1448 static const struct intel_c10pll_state mtl_c10_hdmi_592000 = { 1449 .clock = 592000, 1450 .tx = 0x10, 1451 .cmn = 0x1, 1452 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x7A, .pll[3] = 0x00, .pll[4] = 0x00, 1453 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1454 .pll[10] = 0xFF, .pll[11] = 0x55, .pll[12] = 0x15, .pll[13] = 0x55, .pll[14] = 0x55, 1455 .pll[15] = 0x08, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1456 }; 1457 1458 static const struct intel_c10pll_state mtl_c10_hdmi_593407 = { 1459 .clock = 593407, 1460 .tx = 0x10, 1461 .cmn = 0x1, 1462 .pll[0] = 0xF4, .pll[1] = 0x00, .pll[2] = 0x7A, .pll[3] = 0x00, .pll[4] = 0x00, 1463 .pll[5] = 0x00, .pll[6] = 0x00, .pll[7] = 0x00, .pll[8] = 0x20, .pll[9] = 0xFF, 1464 .pll[10] = 0xFF, .pll[11] = 0x3B, .pll[12] = 0x44, .pll[13] = 0xBA, .pll[14] = 0xBB, 1465 .pll[15] = 0x08, .pll[16] = 0x08, .pll[17] = 0x8F, .pll[18] = 0x84, .pll[19] = 0x23, 1466 }; 1467 1468 static const struct intel_c10pll_state * const mtl_c10_hdmi_tables[] = { 1469 &mtl_c10_hdmi_25_2, /* Consolidated Table */ 1470 &mtl_c10_hdmi_27_0, /* Consolidated Table */ 1471 &mtl_c10_hdmi_27027, 1472 &mtl_c10_hdmi_28320, 1473 &mtl_c10_hdmi_30240, 1474 &mtl_c10_hdmi_31500, 1475 &mtl_c10_hdmi_36000, 1476 &mtl_c10_hdmi_40000, 1477 &mtl_c10_hdmi_49500, 1478 &mtl_c10_hdmi_50000, 1479 &mtl_c10_hdmi_57284, 1480 &mtl_c10_hdmi_58000, 1481 &mtl_c10_hdmi_65000, 1482 &mtl_c10_hdmi_71000, 1483 &mtl_c10_hdmi_74176, 1484 &mtl_c10_hdmi_74_25, /* Consolidated Table */ 1485 &mtl_c10_hdmi_75000, 1486 &mtl_c10_hdmi_78750, 1487 &mtl_c10_hdmi_85500, 1488 &mtl_c10_hdmi_88750, 1489 &mtl_c10_hdmi_106500, 1490 &mtl_c10_hdmi_108000, 1491 &mtl_c10_hdmi_115500, 1492 &mtl_c10_hdmi_119000, 1493 &mtl_c10_hdmi_135000, 1494 &mtl_c10_hdmi_138500, 1495 &mtl_c10_hdmi_147160, 1496 &mtl_c10_hdmi_148352, 1497 &mtl_c10_hdmi_148_5, /* Consolidated Table */ 1498 &mtl_c10_hdmi_154000, 1499 &mtl_c10_hdmi_162000, 1500 &mtl_c10_hdmi_167000, 1501 &mtl_c10_hdmi_197802, 1502 &mtl_c10_hdmi_198000, 1503 &mtl_c10_hdmi_209800, 1504 &mtl_c10_hdmi_241500, 1505 &mtl_c10_hdmi_262750, 1506 &mtl_c10_hdmi_268500, 1507 &mtl_c10_hdmi_296703, 1508 &mtl_c10_hdmi_297000, 1509 &mtl_c10_hdmi_319750, 1510 &mtl_c10_hdmi_497750, 1511 &mtl_c10_hdmi_592000, 1512 &mtl_c10_hdmi_593407, 1513 &mtl_c10_hdmi_594, /* Consolidated Table */ 1514 NULL, 1515 }; 1516 1517 static const struct intel_c20pll_state mtl_c20_hdmi_25_175 = { 1518 .link_bit_rate = 25175, 1519 .clock = 25175, 1520 .tx = { 0xbe88, /* tx cfg0 */ 1521 0x9800, /* tx cfg1 */ 1522 0x0000, /* tx cfg2 */ 1523 }, 1524 .cmn = { 0x0500, /* cmn cfg0*/ 1525 0x0005, /* cmn cfg1 */ 1526 0x0000, /* cmn cfg2 */ 1527 0x0000, /* cmn cfg3 */ 1528 }, 1529 .mpllb = { 0xa0d2, /* mpllb cfg0 */ 1530 0x7d80, /* mpllb cfg1 */ 1531 0x0906, /* mpllb cfg2 */ 1532 0xbe40, /* mpllb cfg3 */ 1533 0x0000, /* mpllb cfg4 */ 1534 0x0000, /* mpllb cfg5 */ 1535 0x0200, /* mpllb cfg6 */ 1536 0x0001, /* mpllb cfg7 */ 1537 0x0000, /* mpllb cfg8 */ 1538 0x0000, /* mpllb cfg9 */ 1539 0x0001, /* mpllb cfg10 */ 1540 }, 1541 }; 1542 1543 static const struct intel_c20pll_state mtl_c20_hdmi_27_0 = { 1544 .link_bit_rate = 27000, 1545 .clock = 27000, 1546 .tx = { 0xbe88, /* tx cfg0 */ 1547 0x9800, /* tx cfg1 */ 1548 0x0000, /* tx cfg2 */ 1549 }, 1550 .cmn = { 0x0500, /* cmn cfg0*/ 1551 0x0005, /* cmn cfg1 */ 1552 0x0000, /* cmn cfg2 */ 1553 0x0000, /* cmn cfg3 */ 1554 }, 1555 .mpllb = { 0xa0e0, /* mpllb cfg0 */ 1556 0x7d80, /* mpllb cfg1 */ 1557 0x0906, /* mpllb cfg2 */ 1558 0xbe40, /* mpllb cfg3 */ 1559 0x0000, /* mpllb cfg4 */ 1560 0x0000, /* mpllb cfg5 */ 1561 0x2200, /* mpllb cfg6 */ 1562 0x0001, /* mpllb cfg7 */ 1563 0x8000, /* mpllb cfg8 */ 1564 0x0000, /* mpllb cfg9 */ 1565 0x0001, /* mpllb cfg10 */ 1566 }, 1567 }; 1568 1569 static const struct intel_c20pll_state mtl_c20_hdmi_74_25 = { 1570 .link_bit_rate = 74250, 1571 .clock = 74250, 1572 .tx = { 0xbe88, /* tx cfg0 */ 1573 0x9800, /* tx cfg1 */ 1574 0x0000, /* tx cfg2 */ 1575 }, 1576 .cmn = { 0x0500, /* cmn cfg0*/ 1577 0x0005, /* cmn cfg1 */ 1578 0x0000, /* cmn cfg2 */ 1579 0x0000, /* cmn cfg3 */ 1580 }, 1581 .mpllb = { 0x609a, /* mpllb cfg0 */ 1582 0x7d40, /* mpllb cfg1 */ 1583 0xca06, /* mpllb cfg2 */ 1584 0xbe40, /* mpllb cfg3 */ 1585 0x0000, /* mpllb cfg4 */ 1586 0x0000, /* mpllb cfg5 */ 1587 0x2200, /* mpllb cfg6 */ 1588 0x0001, /* mpllb cfg7 */ 1589 0x5800, /* mpllb cfg8 */ 1590 0x0000, /* mpllb cfg9 */ 1591 0x0001, /* mpllb cfg10 */ 1592 }, 1593 }; 1594 1595 static const struct intel_c20pll_state mtl_c20_hdmi_148_5 = { 1596 .link_bit_rate = 148500, 1597 .clock = 148500, 1598 .tx = { 0xbe88, /* tx cfg0 */ 1599 0x9800, /* tx cfg1 */ 1600 0x0000, /* tx cfg2 */ 1601 }, 1602 .cmn = { 0x0500, /* cmn cfg0*/ 1603 0x0005, /* cmn cfg1 */ 1604 0x0000, /* cmn cfg2 */ 1605 0x0000, /* cmn cfg3 */ 1606 }, 1607 .mpllb = { 0x409a, /* mpllb cfg0 */ 1608 0x7d20, /* mpllb cfg1 */ 1609 0xca06, /* mpllb cfg2 */ 1610 0xbe40, /* mpllb cfg3 */ 1611 0x0000, /* mpllb cfg4 */ 1612 0x0000, /* mpllb cfg5 */ 1613 0x2200, /* mpllb cfg6 */ 1614 0x0001, /* mpllb cfg7 */ 1615 0x5800, /* mpllb cfg8 */ 1616 0x0000, /* mpllb cfg9 */ 1617 0x0001, /* mpllb cfg10 */ 1618 }, 1619 }; 1620 1621 static const struct intel_c20pll_state mtl_c20_hdmi_594 = { 1622 .link_bit_rate = 594000, 1623 .clock = 594000, 1624 .tx = { 0xbe88, /* tx cfg0 */ 1625 0x9800, /* tx cfg1 */ 1626 0x0000, /* tx cfg2 */ 1627 }, 1628 .cmn = { 0x0500, /* cmn cfg0*/ 1629 0x0005, /* cmn cfg1 */ 1630 0x0000, /* cmn cfg2 */ 1631 0x0000, /* cmn cfg3 */ 1632 }, 1633 .mpllb = { 0x009a, /* mpllb cfg0 */ 1634 0x7d08, /* mpllb cfg1 */ 1635 0xca06, /* mpllb cfg2 */ 1636 0xbe40, /* mpllb cfg3 */ 1637 0x0000, /* mpllb cfg4 */ 1638 0x0000, /* mpllb cfg5 */ 1639 0x2200, /* mpllb cfg6 */ 1640 0x0001, /* mpllb cfg7 */ 1641 0x5800, /* mpllb cfg8 */ 1642 0x0000, /* mpllb cfg9 */ 1643 0x0001, /* mpllb cfg10 */ 1644 }, 1645 }; 1646 1647 static const struct intel_c20pll_state mtl_c20_hdmi_300 = { 1648 .link_bit_rate = 3000000, 1649 .clock = 166670, 1650 .tx = { 0xbe98, /* tx cfg0 */ 1651 0x9800, /* tx cfg1 */ 1652 0x0000, /* tx cfg2 */ 1653 }, 1654 .cmn = { 0x0500, /* cmn cfg0*/ 1655 0x0005, /* cmn cfg1 */ 1656 0x0000, /* cmn cfg2 */ 1657 0x0000, /* cmn cfg3 */ 1658 }, 1659 .mpllb = { 0x209c, /* mpllb cfg0 */ 1660 0x7d10, /* mpllb cfg1 */ 1661 0xca06, /* mpllb cfg2 */ 1662 0xbe40, /* mpllb cfg3 */ 1663 0x0000, /* mpllb cfg4 */ 1664 0x0000, /* mpllb cfg5 */ 1665 0x2200, /* mpllb cfg6 */ 1666 0x0001, /* mpllb cfg7 */ 1667 0x2000, /* mpllb cfg8 */ 1668 0x0000, /* mpllb cfg9 */ 1669 0x0004, /* mpllb cfg10 */ 1670 }, 1671 }; 1672 1673 static const struct intel_c20pll_state mtl_c20_hdmi_600 = { 1674 .link_bit_rate = 6000000, 1675 .clock = 333330, 1676 .tx = { 0xbe98, /* tx cfg0 */ 1677 0x9800, /* tx cfg1 */ 1678 0x0000, /* tx cfg2 */ 1679 }, 1680 .cmn = { 0x0500, /* cmn cfg0*/ 1681 0x0005, /* cmn cfg1 */ 1682 0x0000, /* cmn cfg2 */ 1683 0x0000, /* cmn cfg3 */ 1684 }, 1685 .mpllb = { 0x009c, /* mpllb cfg0 */ 1686 0x7d08, /* mpllb cfg1 */ 1687 0xca06, /* mpllb cfg2 */ 1688 0xbe40, /* mpllb cfg3 */ 1689 0x0000, /* mpllb cfg4 */ 1690 0x0000, /* mpllb cfg5 */ 1691 0x2200, /* mpllb cfg6 */ 1692 0x0001, /* mpllb cfg7 */ 1693 0x2000, /* mpllb cfg8 */ 1694 0x0000, /* mpllb cfg9 */ 1695 0x0004, /* mpllb cfg10 */ 1696 }, 1697 }; 1698 1699 static const struct intel_c20pll_state mtl_c20_hdmi_800 = { 1700 .link_bit_rate = 8000000, 1701 .clock = 444440, 1702 .tx = { 0xbe98, /* tx cfg0 */ 1703 0x9800, /* tx cfg1 */ 1704 0x0000, /* tx cfg2 */ 1705 }, 1706 .cmn = { 0x0500, /* cmn cfg0*/ 1707 0x0005, /* cmn cfg1 */ 1708 0x0000, /* cmn cfg2 */ 1709 0x0000, /* cmn cfg3 */ 1710 }, 1711 .mpllb = { 0x00d0, /* mpllb cfg0 */ 1712 0x7d08, /* mpllb cfg1 */ 1713 0x4a06, /* mpllb cfg2 */ 1714 0xbe40, /* mpllb cfg3 */ 1715 0x0000, /* mpllb cfg4 */ 1716 0x0000, /* mpllb cfg5 */ 1717 0x2200, /* mpllb cfg6 */ 1718 0x0003, /* mpllb cfg7 */ 1719 0x2aaa, /* mpllb cfg8 */ 1720 0x0002, /* mpllb cfg9 */ 1721 0x0004, /* mpllb cfg10 */ 1722 }, 1723 }; 1724 1725 static const struct intel_c20pll_state mtl_c20_hdmi_1000 = { 1726 .link_bit_rate = 10000000, 1727 .clock = 555560, 1728 .tx = { 0xbe98, /* tx cfg0 */ 1729 0x9800, /* tx cfg1 */ 1730 0x0000, /* tx cfg2 */ 1731 }, 1732 .cmn = { 0x0500, /* cmn cfg0*/ 1733 0x0005, /* cmn cfg1 */ 1734 0x0000, /* cmn cfg2 */ 1735 0x0000, /* cmn cfg3 */ 1736 }, 1737 .mpllb = { 0x1104, /* mpllb cfg0 */ 1738 0x7d08, /* mpllb cfg1 */ 1739 0x0a06, /* mpllb cfg2 */ 1740 0xbe40, /* mpllb cfg3 */ 1741 0x0000, /* mpllb cfg4 */ 1742 0x0000, /* mpllb cfg5 */ 1743 0x2200, /* mpllb cfg6 */ 1744 0x0003, /* mpllb cfg7 */ 1745 0x3555, /* mpllb cfg8 */ 1746 0x0001, /* mpllb cfg9 */ 1747 0x0004, /* mpllb cfg10 */ 1748 }, 1749 }; 1750 1751 static const struct intel_c20pll_state mtl_c20_hdmi_1200 = { 1752 .link_bit_rate = 12000000, 1753 .clock = 666670, 1754 .tx = { 0xbe98, /* tx cfg0 */ 1755 0x9800, /* tx cfg1 */ 1756 0x0000, /* tx cfg2 */ 1757 }, 1758 .cmn = { 0x0500, /* cmn cfg0*/ 1759 0x0005, /* cmn cfg1 */ 1760 0x0000, /* cmn cfg2 */ 1761 0x0000, /* cmn cfg3 */ 1762 }, 1763 .mpllb = { 0x0138, /* mpllb cfg0 */ 1764 0x7d08, /* mpllb cfg1 */ 1765 0x5486, /* mpllb cfg2 */ 1766 0xfe40, /* mpllb cfg3 */ 1767 0x0000, /* mpllb cfg4 */ 1768 0x0000, /* mpllb cfg5 */ 1769 0x2200, /* mpllb cfg6 */ 1770 0x0001, /* mpllb cfg7 */ 1771 0x4000, /* mpllb cfg8 */ 1772 0x0000, /* mpllb cfg9 */ 1773 0x0004, /* mpllb cfg10 */ 1774 }, 1775 }; 1776 1777 static const struct intel_c20pll_state * const mtl_c20_hdmi_tables[] = { 1778 &mtl_c20_hdmi_25_175, 1779 &mtl_c20_hdmi_27_0, 1780 &mtl_c20_hdmi_74_25, 1781 &mtl_c20_hdmi_148_5, 1782 &mtl_c20_hdmi_594, 1783 &mtl_c20_hdmi_300, 1784 &mtl_c20_hdmi_600, 1785 &mtl_c20_hdmi_800, 1786 &mtl_c20_hdmi_1000, 1787 &mtl_c20_hdmi_1200, 1788 NULL, 1789 }; 1790 1791 static int intel_c10_phy_check_hdmi_link_rate(int clock) 1792 { 1793 const struct intel_c10pll_state * const *tables = mtl_c10_hdmi_tables; 1794 int i; 1795 1796 for (i = 0; tables[i]; i++) { 1797 if (clock == tables[i]->clock) 1798 return MODE_OK; 1799 } 1800 1801 return MODE_CLOCK_RANGE; 1802 } 1803 1804 static const struct intel_c10pll_state * const * 1805 intel_c10pll_tables_get(struct intel_crtc_state *crtc_state, 1806 struct intel_encoder *encoder) 1807 { 1808 if (intel_crtc_has_dp_encoder(crtc_state)) { 1809 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_EDP)) 1810 return mtl_c10_edp_tables; 1811 else 1812 return mtl_c10_dp_tables; 1813 } else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) { 1814 return mtl_c10_hdmi_tables; 1815 } 1816 1817 MISSING_CASE(encoder->type); 1818 return NULL; 1819 } 1820 1821 static void intel_c10pll_update_pll(struct intel_crtc_state *crtc_state, 1822 struct intel_encoder *encoder) 1823 { 1824 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 1825 struct intel_cx0pll_state *pll_state = &crtc_state->cx0pll_state; 1826 int i; 1827 1828 if (intel_crtc_has_dp_encoder(crtc_state)) { 1829 if (intel_panel_use_ssc(i915)) { 1830 struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 1831 1832 pll_state->ssc_enabled = 1833 (intel_dp->dpcd[DP_MAX_DOWNSPREAD] & DP_MAX_DOWNSPREAD_0_5); 1834 } 1835 } 1836 1837 if (pll_state->ssc_enabled) 1838 return; 1839 1840 drm_WARN_ON(&i915->drm, ARRAY_SIZE(pll_state->c10.pll) < 9); 1841 for (i = 4; i < 9; i++) 1842 pll_state->c10.pll[i] = 0; 1843 } 1844 1845 static int intel_c10pll_calc_state(struct intel_crtc_state *crtc_state, 1846 struct intel_encoder *encoder) 1847 { 1848 const struct intel_c10pll_state * const *tables; 1849 int i; 1850 1851 tables = intel_c10pll_tables_get(crtc_state, encoder); 1852 if (!tables) 1853 return -EINVAL; 1854 1855 for (i = 0; tables[i]; i++) { 1856 if (crtc_state->port_clock == tables[i]->clock) { 1857 crtc_state->cx0pll_state.c10 = *tables[i]; 1858 intel_c10pll_update_pll(crtc_state, encoder); 1859 1860 return 0; 1861 } 1862 } 1863 1864 return -EINVAL; 1865 } 1866 1867 static void intel_c10pll_readout_hw_state(struct intel_encoder *encoder, 1868 struct intel_c10pll_state *pll_state) 1869 { 1870 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 1871 u8 lane = INTEL_CX0_LANE0; 1872 intel_wakeref_t wakeref; 1873 int i; 1874 1875 wakeref = intel_cx0_phy_transaction_begin(encoder); 1876 1877 /* 1878 * According to C10 VDR Register programming Sequence we need 1879 * to do this to read PHY internal registers from MsgBus. 1880 */ 1881 intel_cx0_rmw(i915, encoder->port, lane, PHY_C10_VDR_CONTROL(1), 1882 0, C10_VDR_CTRL_MSGBUS_ACCESS, 1883 MB_WRITE_COMMITTED); 1884 1885 for (i = 0; i < ARRAY_SIZE(pll_state->pll); i++) 1886 pll_state->pll[i] = intel_cx0_read(i915, encoder->port, lane, 1887 PHY_C10_VDR_PLL(i)); 1888 1889 pll_state->cmn = intel_cx0_read(i915, encoder->port, lane, PHY_C10_VDR_CMN(0)); 1890 pll_state->tx = intel_cx0_read(i915, encoder->port, lane, PHY_C10_VDR_TX(0)); 1891 1892 intel_cx0_phy_transaction_end(encoder, wakeref); 1893 } 1894 1895 static void intel_c10_pll_program(struct drm_i915_private *i915, 1896 const struct intel_crtc_state *crtc_state, 1897 struct intel_encoder *encoder) 1898 { 1899 const struct intel_c10pll_state *pll_state = &crtc_state->cx0pll_state.c10; 1900 int i; 1901 1902 intel_cx0_rmw(i915, encoder->port, INTEL_CX0_BOTH_LANES, PHY_C10_VDR_CONTROL(1), 1903 0, C10_VDR_CTRL_MSGBUS_ACCESS, 1904 MB_WRITE_COMMITTED); 1905 1906 /* Custom width needs to be programmed to 0 for both the phy lanes */ 1907 intel_cx0_rmw(i915, encoder->port, INTEL_CX0_BOTH_LANES, PHY_C10_VDR_CUSTOM_WIDTH, 1908 C10_VDR_CUSTOM_WIDTH_MASK, C10_VDR_CUSTOM_WIDTH_8_10, 1909 MB_WRITE_COMMITTED); 1910 intel_cx0_rmw(i915, encoder->port, INTEL_CX0_BOTH_LANES, PHY_C10_VDR_CONTROL(1), 1911 0, C10_VDR_CTRL_UPDATE_CFG, 1912 MB_WRITE_COMMITTED); 1913 1914 /* Program the pll values only for the master lane */ 1915 for (i = 0; i < ARRAY_SIZE(pll_state->pll); i++) 1916 intel_cx0_write(i915, encoder->port, INTEL_CX0_LANE0, PHY_C10_VDR_PLL(i), 1917 pll_state->pll[i], 1918 (i % 4) ? MB_WRITE_UNCOMMITTED : MB_WRITE_COMMITTED); 1919 1920 intel_cx0_write(i915, encoder->port, INTEL_CX0_LANE0, PHY_C10_VDR_CMN(0), pll_state->cmn, MB_WRITE_COMMITTED); 1921 intel_cx0_write(i915, encoder->port, INTEL_CX0_LANE0, PHY_C10_VDR_TX(0), pll_state->tx, MB_WRITE_COMMITTED); 1922 1923 intel_cx0_rmw(i915, encoder->port, INTEL_CX0_LANE0, PHY_C10_VDR_CONTROL(1), 1924 0, C10_VDR_CTRL_MASTER_LANE | C10_VDR_CTRL_UPDATE_CFG, 1925 MB_WRITE_COMMITTED); 1926 } 1927 1928 void intel_c10pll_dump_hw_state(struct drm_i915_private *i915, 1929 const struct intel_c10pll_state *hw_state) 1930 { 1931 bool fracen; 1932 int i; 1933 unsigned int frac_quot = 0, frac_rem = 0, frac_den = 1; 1934 unsigned int multiplier, tx_clk_div; 1935 1936 fracen = hw_state->pll[0] & C10_PLL0_FRACEN; 1937 drm_dbg_kms(&i915->drm, "c10pll_hw_state: fracen: %s, ", 1938 str_yes_no(fracen)); 1939 1940 if (fracen) { 1941 frac_quot = hw_state->pll[12] << 8 | hw_state->pll[11]; 1942 frac_rem = hw_state->pll[14] << 8 | hw_state->pll[13]; 1943 frac_den = hw_state->pll[10] << 8 | hw_state->pll[9]; 1944 drm_dbg_kms(&i915->drm, "quot: %u, rem: %u, den: %u,\n", 1945 frac_quot, frac_rem, frac_den); 1946 } 1947 1948 multiplier = (REG_FIELD_GET8(C10_PLL3_MULTIPLIERH_MASK, hw_state->pll[3]) << 8 | 1949 hw_state->pll[2]) / 2 + 16; 1950 tx_clk_div = REG_FIELD_GET8(C10_PLL15_TXCLKDIV_MASK, hw_state->pll[15]); 1951 drm_dbg_kms(&i915->drm, 1952 "multiplier: %u, tx_clk_div: %u.\n", multiplier, tx_clk_div); 1953 1954 drm_dbg_kms(&i915->drm, "c10pll_rawhw_state:"); 1955 drm_dbg_kms(&i915->drm, "tx: 0x%x, cmn: 0x%x\n", hw_state->tx, hw_state->cmn); 1956 1957 BUILD_BUG_ON(ARRAY_SIZE(hw_state->pll) % 4); 1958 for (i = 0; i < ARRAY_SIZE(hw_state->pll); i = i + 4) 1959 drm_dbg_kms(&i915->drm, "pll[%d] = 0x%x, pll[%d] = 0x%x, pll[%d] = 0x%x, pll[%d] = 0x%x\n", 1960 i, hw_state->pll[i], i + 1, hw_state->pll[i + 1], 1961 i + 2, hw_state->pll[i + 2], i + 3, hw_state->pll[i + 3]); 1962 } 1963 1964 static int intel_c20_compute_hdmi_tmds_pll(u64 pixel_clock, struct intel_c20pll_state *pll_state) 1965 { 1966 u64 datarate; 1967 u64 mpll_tx_clk_div; 1968 u64 vco_freq_shift; 1969 u64 vco_freq; 1970 u64 multiplier; 1971 u64 mpll_multiplier; 1972 u64 mpll_fracn_quot; 1973 u64 mpll_fracn_rem; 1974 u8 mpllb_ana_freq_vco; 1975 u8 mpll_div_multiplier; 1976 1977 if (pixel_clock < 25175 || pixel_clock > 600000) 1978 return -EINVAL; 1979 1980 datarate = ((u64)pixel_clock * 1000) * 10; 1981 mpll_tx_clk_div = ilog2(div64_u64((u64)CLOCK_9999MHZ, (u64)datarate)); 1982 vco_freq_shift = ilog2(div64_u64((u64)CLOCK_4999MHZ * (u64)256, (u64)datarate)); 1983 vco_freq = (datarate << vco_freq_shift) >> 8; 1984 multiplier = div64_u64((vco_freq << 28), (REFCLK_38_4_MHZ >> 4)); 1985 mpll_multiplier = 2 * (multiplier >> 32); 1986 1987 mpll_fracn_quot = (multiplier >> 16) & 0xFFFF; 1988 mpll_fracn_rem = multiplier & 0xFFFF; 1989 1990 mpll_div_multiplier = min_t(u8, div64_u64((vco_freq * 16 + (datarate >> 1)), 1991 datarate), 255); 1992 1993 if (vco_freq <= DATARATE_3000000000) 1994 mpllb_ana_freq_vco = MPLLB_ANA_FREQ_VCO_3; 1995 else if (vco_freq <= DATARATE_3500000000) 1996 mpllb_ana_freq_vco = MPLLB_ANA_FREQ_VCO_2; 1997 else if (vco_freq <= DATARATE_4000000000) 1998 mpllb_ana_freq_vco = MPLLB_ANA_FREQ_VCO_1; 1999 else 2000 mpllb_ana_freq_vco = MPLLB_ANA_FREQ_VCO_0; 2001 2002 pll_state->link_bit_rate = pixel_clock; 2003 pll_state->clock = pixel_clock; 2004 pll_state->tx[0] = 0xbe88; 2005 pll_state->tx[1] = 0x9800; 2006 pll_state->tx[2] = 0x0000; 2007 pll_state->cmn[0] = 0x0500; 2008 pll_state->cmn[1] = 0x0005; 2009 pll_state->cmn[2] = 0x0000; 2010 pll_state->cmn[3] = 0x0000; 2011 pll_state->mpllb[0] = (MPLL_TX_CLK_DIV(mpll_tx_clk_div) | 2012 MPLL_MULTIPLIER(mpll_multiplier)); 2013 pll_state->mpllb[1] = (CAL_DAC_CODE(CAL_DAC_CODE_31) | 2014 WORD_CLK_DIV | 2015 MPLL_DIV_MULTIPLIER(mpll_div_multiplier)); 2016 pll_state->mpllb[2] = (MPLLB_ANA_FREQ_VCO(mpllb_ana_freq_vco) | 2017 CP_PROP(CP_PROP_20) | 2018 CP_INT(CP_INT_6)); 2019 pll_state->mpllb[3] = (V2I(V2I_2) | 2020 CP_PROP_GS(CP_PROP_GS_30) | 2021 CP_INT_GS(CP_INT_GS_28)); 2022 pll_state->mpllb[4] = 0x0000; 2023 pll_state->mpllb[5] = 0x0000; 2024 pll_state->mpllb[6] = (C20_MPLLB_FRACEN | SSC_UP_SPREAD); 2025 pll_state->mpllb[7] = MPLL_FRACN_DEN; 2026 pll_state->mpllb[8] = mpll_fracn_quot; 2027 pll_state->mpllb[9] = mpll_fracn_rem; 2028 pll_state->mpllb[10] = HDMI_DIV(HDMI_DIV_1); 2029 2030 return 0; 2031 } 2032 2033 static int intel_c20_phy_check_hdmi_link_rate(int clock) 2034 { 2035 const struct intel_c20pll_state * const *tables = mtl_c20_hdmi_tables; 2036 int i; 2037 2038 for (i = 0; tables[i]; i++) { 2039 if (clock == tables[i]->link_bit_rate) 2040 return MODE_OK; 2041 } 2042 2043 if (clock >= 25175 && clock <= 594000) 2044 return MODE_OK; 2045 2046 return MODE_CLOCK_RANGE; 2047 } 2048 2049 int intel_cx0_phy_check_hdmi_link_rate(struct intel_hdmi *hdmi, int clock) 2050 { 2051 struct intel_digital_port *dig_port = hdmi_to_dig_port(hdmi); 2052 struct drm_i915_private *i915 = intel_hdmi_to_i915(hdmi); 2053 enum phy phy = intel_port_to_phy(i915, dig_port->base.port); 2054 2055 if (intel_is_c10phy(i915, phy)) 2056 return intel_c10_phy_check_hdmi_link_rate(clock); 2057 return intel_c20_phy_check_hdmi_link_rate(clock); 2058 } 2059 2060 static const struct intel_c20pll_state * const * 2061 intel_c20_pll_tables_get(struct intel_crtc_state *crtc_state, 2062 struct intel_encoder *encoder) 2063 { 2064 if (intel_crtc_has_dp_encoder(crtc_state)) 2065 return mtl_c20_dp_tables; 2066 else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) 2067 return mtl_c20_hdmi_tables; 2068 2069 MISSING_CASE(encoder->type); 2070 return NULL; 2071 } 2072 2073 static int intel_c20pll_calc_state(struct intel_crtc_state *crtc_state, 2074 struct intel_encoder *encoder) 2075 { 2076 const struct intel_c20pll_state * const *tables; 2077 int i; 2078 2079 /* try computed C20 HDMI tables before using consolidated tables */ 2080 if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) { 2081 if (intel_c20_compute_hdmi_tmds_pll(crtc_state->port_clock, 2082 &crtc_state->cx0pll_state.c20) == 0) 2083 return 0; 2084 } 2085 2086 tables = intel_c20_pll_tables_get(crtc_state, encoder); 2087 if (!tables) 2088 return -EINVAL; 2089 2090 for (i = 0; tables[i]; i++) { 2091 if (crtc_state->port_clock == tables[i]->link_bit_rate) { 2092 crtc_state->cx0pll_state.c20 = *tables[i]; 2093 return 0; 2094 } 2095 } 2096 2097 return -EINVAL; 2098 } 2099 2100 int intel_cx0pll_calc_state(struct intel_crtc_state *crtc_state, 2101 struct intel_encoder *encoder) 2102 { 2103 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 2104 enum phy phy = intel_port_to_phy(i915, encoder->port); 2105 2106 if (intel_is_c10phy(i915, phy)) 2107 return intel_c10pll_calc_state(crtc_state, encoder); 2108 return intel_c20pll_calc_state(crtc_state, encoder); 2109 } 2110 2111 static bool intel_c20_use_mplla(u32 clock) 2112 { 2113 /* 10G and 20G rates use MPLLA */ 2114 if (clock == 312500 || clock == 625000) 2115 return true; 2116 2117 return false; 2118 } 2119 2120 static void intel_c20pll_readout_hw_state(struct intel_encoder *encoder, 2121 struct intel_c20pll_state *pll_state) 2122 { 2123 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 2124 bool cntx; 2125 intel_wakeref_t wakeref; 2126 int i; 2127 2128 wakeref = intel_cx0_phy_transaction_begin(encoder); 2129 2130 /* 1. Read current context selection */ 2131 cntx = intel_cx0_read(i915, encoder->port, INTEL_CX0_LANE0, PHY_C20_VDR_CUSTOM_SERDES_RATE) & PHY_C20_CONTEXT_TOGGLE; 2132 2133 /* Read Tx configuration */ 2134 for (i = 0; i < ARRAY_SIZE(pll_state->tx); i++) { 2135 if (cntx) 2136 pll_state->tx[i] = intel_c20_sram_read(i915, encoder->port, INTEL_CX0_LANE0, 2137 PHY_C20_B_TX_CNTX_CFG(i)); 2138 else 2139 pll_state->tx[i] = intel_c20_sram_read(i915, encoder->port, INTEL_CX0_LANE0, 2140 PHY_C20_A_TX_CNTX_CFG(i)); 2141 } 2142 2143 /* Read common configuration */ 2144 for (i = 0; i < ARRAY_SIZE(pll_state->cmn); i++) { 2145 if (cntx) 2146 pll_state->cmn[i] = intel_c20_sram_read(i915, encoder->port, INTEL_CX0_LANE0, 2147 PHY_C20_B_CMN_CNTX_CFG(i)); 2148 else 2149 pll_state->cmn[i] = intel_c20_sram_read(i915, encoder->port, INTEL_CX0_LANE0, 2150 PHY_C20_A_CMN_CNTX_CFG(i)); 2151 } 2152 2153 if (pll_state->tx[0] & C20_PHY_USE_MPLLB) { 2154 /* MPLLB configuration */ 2155 for (i = 0; i < ARRAY_SIZE(pll_state->mpllb); i++) { 2156 if (cntx) 2157 pll_state->mpllb[i] = intel_c20_sram_read(i915, encoder->port, INTEL_CX0_LANE0, 2158 PHY_C20_B_MPLLB_CNTX_CFG(i)); 2159 else 2160 pll_state->mpllb[i] = intel_c20_sram_read(i915, encoder->port, INTEL_CX0_LANE0, 2161 PHY_C20_A_MPLLB_CNTX_CFG(i)); 2162 } 2163 } else { 2164 /* MPLLA configuration */ 2165 for (i = 0; i < ARRAY_SIZE(pll_state->mplla); i++) { 2166 if (cntx) 2167 pll_state->mplla[i] = intel_c20_sram_read(i915, encoder->port, INTEL_CX0_LANE0, 2168 PHY_C20_B_MPLLA_CNTX_CFG(i)); 2169 else 2170 pll_state->mplla[i] = intel_c20_sram_read(i915, encoder->port, INTEL_CX0_LANE0, 2171 PHY_C20_A_MPLLA_CNTX_CFG(i)); 2172 } 2173 } 2174 2175 intel_cx0_phy_transaction_end(encoder, wakeref); 2176 } 2177 2178 void intel_c20pll_dump_hw_state(struct drm_i915_private *i915, 2179 const struct intel_c20pll_state *hw_state) 2180 { 2181 int i; 2182 2183 drm_dbg_kms(&i915->drm, "c20pll_hw_state:\n"); 2184 drm_dbg_kms(&i915->drm, "tx[0] = 0x%.4x, tx[1] = 0x%.4x, tx[2] = 0x%.4x\n", 2185 hw_state->tx[0], hw_state->tx[1], hw_state->tx[2]); 2186 drm_dbg_kms(&i915->drm, "cmn[0] = 0x%.4x, cmn[1] = 0x%.4x, cmn[2] = 0x%.4x, cmn[3] = 0x%.4x\n", 2187 hw_state->cmn[0], hw_state->cmn[1], hw_state->cmn[2], hw_state->cmn[3]); 2188 2189 if (intel_c20_use_mplla(hw_state->clock)) { 2190 for (i = 0; i < ARRAY_SIZE(hw_state->mplla); i++) 2191 drm_dbg_kms(&i915->drm, "mplla[%d] = 0x%.4x\n", i, hw_state->mplla[i]); 2192 } else { 2193 for (i = 0; i < ARRAY_SIZE(hw_state->mpllb); i++) 2194 drm_dbg_kms(&i915->drm, "mpllb[%d] = 0x%.4x\n", i, hw_state->mpllb[i]); 2195 } 2196 } 2197 2198 static u8 intel_c20_get_dp_rate(u32 clock) 2199 { 2200 switch (clock) { 2201 case 162000: /* 1.62 Gbps DP1.4 */ 2202 return 0; 2203 case 270000: /* 2.7 Gbps DP1.4 */ 2204 return 1; 2205 case 540000: /* 5.4 Gbps DP 1.4 */ 2206 return 2; 2207 case 810000: /* 8.1 Gbps DP1.4 */ 2208 return 3; 2209 case 216000: /* 2.16 Gbps eDP */ 2210 return 4; 2211 case 243000: /* 2.43 Gbps eDP */ 2212 return 5; 2213 case 324000: /* 3.24 Gbps eDP */ 2214 return 6; 2215 case 432000: /* 4.32 Gbps eDP */ 2216 return 7; 2217 case 312500: /* 10 Gbps DP2.0 */ 2218 return 8; 2219 case 421875: /* 13.5 Gbps DP2.0 */ 2220 return 9; 2221 case 625000: /* 20 Gbps DP2.0*/ 2222 return 10; 2223 case 648000: /* 6.48 Gbps eDP*/ 2224 return 11; 2225 case 675000: /* 6.75 Gbps eDP*/ 2226 return 12; 2227 default: 2228 MISSING_CASE(clock); 2229 return 0; 2230 } 2231 } 2232 2233 static u8 intel_c20_get_hdmi_rate(u32 clock) 2234 { 2235 if (clock >= 25175 && clock <= 600000) 2236 return 0; 2237 2238 switch (clock) { 2239 case 166670: /* 3 Gbps */ 2240 case 333330: /* 6 Gbps */ 2241 case 666670: /* 12 Gbps */ 2242 return 1; 2243 case 444440: /* 8 Gbps */ 2244 return 2; 2245 case 555560: /* 10 Gbps */ 2246 return 3; 2247 default: 2248 MISSING_CASE(clock); 2249 return 0; 2250 } 2251 } 2252 2253 static bool is_dp2(u32 clock) 2254 { 2255 /* DP2.0 clock rates */ 2256 if (clock == 312500 || clock == 421875 || clock == 625000) 2257 return true; 2258 2259 return false; 2260 } 2261 2262 static bool is_hdmi_frl(u32 clock) 2263 { 2264 switch (clock) { 2265 case 166670: /* 3 Gbps */ 2266 case 333330: /* 6 Gbps */ 2267 case 444440: /* 8 Gbps */ 2268 case 555560: /* 10 Gbps */ 2269 case 666670: /* 12 Gbps */ 2270 return true; 2271 default: 2272 return false; 2273 } 2274 } 2275 2276 static bool intel_c20_protocol_switch_valid(struct intel_encoder *encoder) 2277 { 2278 struct intel_digital_port *intel_dig_port = enc_to_dig_port(encoder); 2279 2280 /* banks should not be cleared for DPALT/USB4/TBT modes */ 2281 /* TODO: optimize re-calibration in legacy mode */ 2282 return intel_tc_port_in_legacy_mode(intel_dig_port); 2283 } 2284 2285 static int intel_get_c20_custom_width(u32 clock, bool dp) 2286 { 2287 if (dp && is_dp2(clock)) 2288 return 2; 2289 else if (is_hdmi_frl(clock)) 2290 return 1; 2291 else 2292 return 0; 2293 } 2294 2295 static void intel_c20_pll_program(struct drm_i915_private *i915, 2296 const struct intel_crtc_state *crtc_state, 2297 struct intel_encoder *encoder) 2298 { 2299 const struct intel_c20pll_state *pll_state = &crtc_state->cx0pll_state.c20; 2300 bool dp = false; 2301 int lane = crtc_state->lane_count > 2 ? INTEL_CX0_BOTH_LANES : INTEL_CX0_LANE0; 2302 bool cntx; 2303 int i; 2304 2305 if (intel_crtc_has_dp_encoder(crtc_state)) 2306 dp = true; 2307 2308 /* 1. Read current context selection */ 2309 cntx = intel_cx0_read(i915, encoder->port, INTEL_CX0_LANE0, PHY_C20_VDR_CUSTOM_SERDES_RATE) & BIT(0); 2310 2311 /* 2312 * 2. If there is a protocol switch from HDMI to DP or vice versa, clear 2313 * the lane #0 MPLLB CAL_DONE_BANK DP2.0 10G and 20G rates enable MPLLA. 2314 * Protocol switch is only applicable for MPLLA 2315 */ 2316 if (intel_c20_protocol_switch_valid(encoder)) { 2317 for (i = 0; i < 4; i++) 2318 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, RAWLANEAONX_DIG_TX_MPLLB_CAL_DONE_BANK(i), 0); 2319 usleep_range(4000, 4100); 2320 } 2321 2322 /* 3. Write SRAM configuration context. If A in use, write configuration to B context */ 2323 /* 3.1 Tx configuration */ 2324 for (i = 0; i < ARRAY_SIZE(pll_state->tx); i++) { 2325 if (cntx) 2326 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, PHY_C20_A_TX_CNTX_CFG(i), pll_state->tx[i]); 2327 else 2328 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, PHY_C20_B_TX_CNTX_CFG(i), pll_state->tx[i]); 2329 } 2330 2331 /* 3.2 common configuration */ 2332 for (i = 0; i < ARRAY_SIZE(pll_state->cmn); i++) { 2333 if (cntx) 2334 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, PHY_C20_A_CMN_CNTX_CFG(i), pll_state->cmn[i]); 2335 else 2336 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, PHY_C20_B_CMN_CNTX_CFG(i), pll_state->cmn[i]); 2337 } 2338 2339 /* 3.3 mpllb or mplla configuration */ 2340 if (intel_c20_use_mplla(pll_state->clock)) { 2341 for (i = 0; i < ARRAY_SIZE(pll_state->mplla); i++) { 2342 if (cntx) 2343 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, 2344 PHY_C20_A_MPLLA_CNTX_CFG(i), 2345 pll_state->mplla[i]); 2346 else 2347 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, 2348 PHY_C20_B_MPLLA_CNTX_CFG(i), 2349 pll_state->mplla[i]); 2350 } 2351 } else { 2352 for (i = 0; i < ARRAY_SIZE(pll_state->mpllb); i++) { 2353 if (cntx) 2354 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, 2355 PHY_C20_A_MPLLB_CNTX_CFG(i), 2356 pll_state->mpllb[i]); 2357 else 2358 intel_c20_sram_write(i915, encoder->port, INTEL_CX0_LANE0, 2359 PHY_C20_B_MPLLB_CNTX_CFG(i), 2360 pll_state->mpllb[i]); 2361 } 2362 } 2363 2364 /* 4. Program custom width to match the link protocol */ 2365 intel_cx0_rmw(i915, encoder->port, lane, PHY_C20_VDR_CUSTOM_WIDTH, 2366 PHY_C20_CUSTOM_WIDTH_MASK, 2367 PHY_C20_CUSTOM_WIDTH(intel_get_c20_custom_width(pll_state->clock, dp)), 2368 MB_WRITE_COMMITTED); 2369 2370 /* 5. For DP or 6. For HDMI */ 2371 if (dp) { 2372 intel_cx0_rmw(i915, encoder->port, lane, PHY_C20_VDR_CUSTOM_SERDES_RATE, 2373 BIT(6) | PHY_C20_CUSTOM_SERDES_MASK, 2374 BIT(6) | PHY_C20_CUSTOM_SERDES(intel_c20_get_dp_rate(pll_state->clock)), 2375 MB_WRITE_COMMITTED); 2376 } else { 2377 intel_cx0_rmw(i915, encoder->port, lane, PHY_C20_VDR_CUSTOM_SERDES_RATE, 2378 BIT(7) | PHY_C20_CUSTOM_SERDES_MASK, 2379 is_hdmi_frl(pll_state->clock) ? BIT(7) : 0, 2380 MB_WRITE_COMMITTED); 2381 2382 intel_cx0_write(i915, encoder->port, INTEL_CX0_BOTH_LANES, PHY_C20_VDR_HDMI_RATE, 2383 intel_c20_get_hdmi_rate(pll_state->clock), 2384 MB_WRITE_COMMITTED); 2385 } 2386 2387 /* 2388 * 7. Write Vendor specific registers to toggle context setting to load 2389 * the updated programming toggle context bit 2390 */ 2391 intel_cx0_rmw(i915, encoder->port, lane, PHY_C20_VDR_CUSTOM_SERDES_RATE, 2392 BIT(0), cntx ? 0 : 1, MB_WRITE_COMMITTED); 2393 } 2394 2395 static int intel_c10pll_calc_port_clock(struct intel_encoder *encoder, 2396 const struct intel_c10pll_state *pll_state) 2397 { 2398 unsigned int frac_quot = 0, frac_rem = 0, frac_den = 1; 2399 unsigned int multiplier, tx_clk_div, hdmi_div, refclk = 38400; 2400 int tmpclk = 0; 2401 2402 if (pll_state->pll[0] & C10_PLL0_FRACEN) { 2403 frac_quot = pll_state->pll[12] << 8 | pll_state->pll[11]; 2404 frac_rem = pll_state->pll[14] << 8 | pll_state->pll[13]; 2405 frac_den = pll_state->pll[10] << 8 | pll_state->pll[9]; 2406 } 2407 2408 multiplier = (REG_FIELD_GET8(C10_PLL3_MULTIPLIERH_MASK, pll_state->pll[3]) << 8 | 2409 pll_state->pll[2]) / 2 + 16; 2410 2411 tx_clk_div = REG_FIELD_GET8(C10_PLL15_TXCLKDIV_MASK, pll_state->pll[15]); 2412 hdmi_div = REG_FIELD_GET8(C10_PLL15_HDMIDIV_MASK, pll_state->pll[15]); 2413 2414 tmpclk = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(refclk, (multiplier << 16) + frac_quot) + 2415 DIV_ROUND_CLOSEST(refclk * frac_rem, frac_den), 2416 10 << (tx_clk_div + 16)); 2417 tmpclk *= (hdmi_div ? 2 : 1); 2418 2419 return tmpclk; 2420 } 2421 2422 static int intel_c20pll_calc_port_clock(struct intel_encoder *encoder, 2423 const struct intel_c20pll_state *pll_state) 2424 { 2425 unsigned int frac, frac_en, frac_quot, frac_rem, frac_den; 2426 unsigned int multiplier, refclk = 38400; 2427 unsigned int tx_clk_div; 2428 unsigned int ref_clk_mpllb_div; 2429 unsigned int fb_clk_div4_en; 2430 unsigned int ref, vco; 2431 unsigned int tx_rate_mult; 2432 unsigned int tx_rate = REG_FIELD_GET(C20_PHY_TX_RATE, pll_state->tx[0]); 2433 2434 if (pll_state->tx[0] & C20_PHY_USE_MPLLB) { 2435 tx_rate_mult = 1; 2436 frac_en = REG_FIELD_GET(C20_MPLLB_FRACEN, pll_state->mpllb[6]); 2437 frac_quot = pll_state->mpllb[8]; 2438 frac_rem = pll_state->mpllb[9]; 2439 frac_den = pll_state->mpllb[7]; 2440 multiplier = REG_FIELD_GET(C20_MULTIPLIER_MASK, pll_state->mpllb[0]); 2441 tx_clk_div = REG_FIELD_GET(C20_MPLLB_TX_CLK_DIV_MASK, pll_state->mpllb[0]); 2442 ref_clk_mpllb_div = REG_FIELD_GET(C20_REF_CLK_MPLLB_DIV_MASK, pll_state->mpllb[6]); 2443 fb_clk_div4_en = 0; 2444 } else { 2445 tx_rate_mult = 2; 2446 frac_en = REG_FIELD_GET(C20_MPLLA_FRACEN, pll_state->mplla[6]); 2447 frac_quot = pll_state->mplla[8]; 2448 frac_rem = pll_state->mplla[9]; 2449 frac_den = pll_state->mplla[7]; 2450 multiplier = REG_FIELD_GET(C20_MULTIPLIER_MASK, pll_state->mplla[0]); 2451 tx_clk_div = REG_FIELD_GET(C20_MPLLA_TX_CLK_DIV_MASK, pll_state->mplla[1]); 2452 ref_clk_mpllb_div = REG_FIELD_GET(C20_REF_CLK_MPLLB_DIV_MASK, pll_state->mplla[6]); 2453 fb_clk_div4_en = REG_FIELD_GET(C20_FB_CLK_DIV4_EN, pll_state->mplla[0]); 2454 } 2455 2456 if (frac_en) 2457 frac = frac_quot + DIV_ROUND_CLOSEST(frac_rem, frac_den); 2458 else 2459 frac = 0; 2460 2461 ref = DIV_ROUND_CLOSEST(refclk * (1 << (1 + fb_clk_div4_en)), 1 << ref_clk_mpllb_div); 2462 vco = DIV_ROUND_CLOSEST_ULL(mul_u32_u32(ref, (multiplier << (17 - 2)) + frac) >> 17, 10); 2463 2464 return vco << tx_rate_mult >> tx_clk_div >> tx_rate; 2465 } 2466 2467 static void intel_program_port_clock_ctl(struct intel_encoder *encoder, 2468 const struct intel_crtc_state *crtc_state, 2469 bool lane_reversal) 2470 { 2471 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 2472 u32 val = 0; 2473 2474 intel_de_rmw(i915, XELPDP_PORT_BUF_CTL1(encoder->port), XELPDP_PORT_REVERSAL, 2475 lane_reversal ? XELPDP_PORT_REVERSAL : 0); 2476 2477 if (lane_reversal) 2478 val |= XELPDP_LANE1_PHY_CLOCK_SELECT; 2479 2480 val |= XELPDP_FORWARD_CLOCK_UNGATE; 2481 2482 if (is_hdmi_frl(crtc_state->port_clock)) 2483 val |= XELPDP_DDI_CLOCK_SELECT(XELPDP_DDI_CLOCK_SELECT_DIV18CLK); 2484 else 2485 val |= XELPDP_DDI_CLOCK_SELECT(XELPDP_DDI_CLOCK_SELECT_MAXPCLK); 2486 2487 /* TODO: HDMI FRL */ 2488 /* DP2.0 10G and 20G rates enable MPLLA*/ 2489 if (crtc_state->port_clock == 1000000 || crtc_state->port_clock == 2000000) 2490 val |= crtc_state->cx0pll_state.ssc_enabled ? XELPDP_SSC_ENABLE_PLLA : 0; 2491 else 2492 val |= crtc_state->cx0pll_state.ssc_enabled ? XELPDP_SSC_ENABLE_PLLB : 0; 2493 2494 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2495 XELPDP_LANE1_PHY_CLOCK_SELECT | XELPDP_FORWARD_CLOCK_UNGATE | 2496 XELPDP_DDI_CLOCK_SELECT_MASK | XELPDP_SSC_ENABLE_PLLA | 2497 XELPDP_SSC_ENABLE_PLLB, val); 2498 } 2499 2500 static u32 intel_cx0_get_powerdown_update(u8 lane_mask) 2501 { 2502 u32 val = 0; 2503 int lane = 0; 2504 2505 for_each_cx0_lane_in_mask(lane_mask, lane) 2506 val |= XELPDP_LANE_POWERDOWN_UPDATE(lane); 2507 2508 return val; 2509 } 2510 2511 static u32 intel_cx0_get_powerdown_state(u8 lane_mask, u8 state) 2512 { 2513 u32 val = 0; 2514 int lane = 0; 2515 2516 for_each_cx0_lane_in_mask(lane_mask, lane) 2517 val |= XELPDP_LANE_POWERDOWN_NEW_STATE(lane, state); 2518 2519 return val; 2520 } 2521 2522 static void intel_cx0_powerdown_change_sequence(struct drm_i915_private *i915, 2523 enum port port, 2524 u8 lane_mask, u8 state) 2525 { 2526 enum phy phy = intel_port_to_phy(i915, port); 2527 int lane; 2528 2529 intel_de_rmw(i915, XELPDP_PORT_BUF_CTL2(port), 2530 intel_cx0_get_powerdown_state(INTEL_CX0_BOTH_LANES, XELPDP_LANE_POWERDOWN_NEW_STATE_MASK), 2531 intel_cx0_get_powerdown_state(lane_mask, state)); 2532 2533 /* Wait for pending transactions.*/ 2534 for_each_cx0_lane_in_mask(lane_mask, lane) 2535 if (intel_de_wait_for_clear(i915, XELPDP_PORT_M2P_MSGBUS_CTL(port, lane), 2536 XELPDP_PORT_M2P_TRANSACTION_PENDING, 2537 XELPDP_MSGBUS_TIMEOUT_SLOW)) { 2538 drm_dbg_kms(&i915->drm, 2539 "PHY %c Timeout waiting for previous transaction to complete. Reset the bus.\n", 2540 phy_name(phy)); 2541 intel_cx0_bus_reset(i915, port, lane); 2542 } 2543 2544 intel_de_rmw(i915, XELPDP_PORT_BUF_CTL2(port), 2545 intel_cx0_get_powerdown_update(INTEL_CX0_BOTH_LANES), 2546 intel_cx0_get_powerdown_update(lane_mask)); 2547 2548 /* Update Timeout Value */ 2549 if (__intel_de_wait_for_register(i915, XELPDP_PORT_BUF_CTL2(port), 2550 intel_cx0_get_powerdown_update(lane_mask), 0, 2551 XELPDP_PORT_POWERDOWN_UPDATE_TIMEOUT_US, 0, NULL)) 2552 drm_warn(&i915->drm, "PHY %c failed to bring out of Lane reset after %dus.\n", 2553 phy_name(phy), XELPDP_PORT_RESET_START_TIMEOUT_US); 2554 } 2555 2556 static void intel_cx0_setup_powerdown(struct drm_i915_private *i915, enum port port) 2557 { 2558 intel_de_rmw(i915, XELPDP_PORT_BUF_CTL2(port), 2559 XELPDP_POWER_STATE_READY_MASK, 2560 XELPDP_POWER_STATE_READY(CX0_P2_STATE_READY)); 2561 intel_de_rmw(i915, XELPDP_PORT_BUF_CTL3(port), 2562 XELPDP_POWER_STATE_ACTIVE_MASK | 2563 XELPDP_PLL_LANE_STAGGERING_DELAY_MASK, 2564 XELPDP_POWER_STATE_ACTIVE(CX0_P0_STATE_ACTIVE) | 2565 XELPDP_PLL_LANE_STAGGERING_DELAY(0)); 2566 } 2567 2568 static u32 intel_cx0_get_pclk_refclk_request(u8 lane_mask) 2569 { 2570 u32 val = 0; 2571 int lane = 0; 2572 2573 for_each_cx0_lane_in_mask(lane_mask, lane) 2574 val |= XELPDP_LANE_PCLK_REFCLK_REQUEST(lane); 2575 2576 return val; 2577 } 2578 2579 static u32 intel_cx0_get_pclk_refclk_ack(u8 lane_mask) 2580 { 2581 u32 val = 0; 2582 int lane = 0; 2583 2584 for_each_cx0_lane_in_mask(lane_mask, lane) 2585 val |= XELPDP_LANE_PCLK_REFCLK_ACK(lane); 2586 2587 return val; 2588 } 2589 2590 static void intel_cx0_phy_lane_reset(struct drm_i915_private *i915, 2591 struct intel_encoder *encoder, 2592 bool lane_reversal) 2593 { 2594 enum port port = encoder->port; 2595 enum phy phy = intel_port_to_phy(i915, port); 2596 u8 owned_lane_mask = intel_cx0_get_owned_lane_mask(i915, encoder); 2597 u8 lane_mask = lane_reversal ? INTEL_CX0_LANE1 : INTEL_CX0_LANE0; 2598 u32 lane_pipe_reset = owned_lane_mask == INTEL_CX0_BOTH_LANES 2599 ? XELPDP_LANE_PIPE_RESET(0) | XELPDP_LANE_PIPE_RESET(1) 2600 : XELPDP_LANE_PIPE_RESET(0); 2601 u32 lane_phy_current_status = owned_lane_mask == INTEL_CX0_BOTH_LANES 2602 ? (XELPDP_LANE_PHY_CURRENT_STATUS(0) | 2603 XELPDP_LANE_PHY_CURRENT_STATUS(1)) 2604 : XELPDP_LANE_PHY_CURRENT_STATUS(0); 2605 2606 if (__intel_de_wait_for_register(i915, XELPDP_PORT_BUF_CTL1(port), 2607 XELPDP_PORT_BUF_SOC_PHY_READY, 2608 XELPDP_PORT_BUF_SOC_PHY_READY, 2609 XELPDP_PORT_BUF_SOC_READY_TIMEOUT_US, 0, NULL)) 2610 drm_warn(&i915->drm, "PHY %c failed to bring out of SOC reset after %dus.\n", 2611 phy_name(phy), XELPDP_PORT_BUF_SOC_READY_TIMEOUT_US); 2612 2613 intel_de_rmw(i915, XELPDP_PORT_BUF_CTL2(port), lane_pipe_reset, 2614 lane_pipe_reset); 2615 2616 if (__intel_de_wait_for_register(i915, XELPDP_PORT_BUF_CTL2(port), 2617 lane_phy_current_status, lane_phy_current_status, 2618 XELPDP_PORT_RESET_START_TIMEOUT_US, 0, NULL)) 2619 drm_warn(&i915->drm, "PHY %c failed to bring out of Lane reset after %dus.\n", 2620 phy_name(phy), XELPDP_PORT_RESET_START_TIMEOUT_US); 2621 2622 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(port), 2623 intel_cx0_get_pclk_refclk_request(owned_lane_mask), 2624 intel_cx0_get_pclk_refclk_request(lane_mask)); 2625 2626 if (__intel_de_wait_for_register(i915, XELPDP_PORT_CLOCK_CTL(port), 2627 intel_cx0_get_pclk_refclk_ack(owned_lane_mask), 2628 intel_cx0_get_pclk_refclk_ack(lane_mask), 2629 XELPDP_REFCLK_ENABLE_TIMEOUT_US, 0, NULL)) 2630 drm_warn(&i915->drm, "PHY %c failed to request refclk after %dus.\n", 2631 phy_name(phy), XELPDP_REFCLK_ENABLE_TIMEOUT_US); 2632 2633 intel_cx0_powerdown_change_sequence(i915, port, INTEL_CX0_BOTH_LANES, 2634 CX0_P2_STATE_RESET); 2635 intel_cx0_setup_powerdown(i915, port); 2636 2637 intel_de_rmw(i915, XELPDP_PORT_BUF_CTL2(port), lane_pipe_reset, 0); 2638 2639 if (intel_de_wait_for_clear(i915, XELPDP_PORT_BUF_CTL2(port), lane_phy_current_status, 2640 XELPDP_PORT_RESET_END_TIMEOUT)) 2641 drm_warn(&i915->drm, "PHY %c failed to bring out of Lane reset after %dms.\n", 2642 phy_name(phy), XELPDP_PORT_RESET_END_TIMEOUT); 2643 } 2644 2645 static void intel_cx0_program_phy_lane(struct drm_i915_private *i915, 2646 struct intel_encoder *encoder, int lane_count, 2647 bool lane_reversal) 2648 { 2649 int i; 2650 u8 disables; 2651 bool dp_alt_mode = intel_tc_port_in_dp_alt_mode(enc_to_dig_port(encoder)); 2652 u8 owned_lane_mask = intel_cx0_get_owned_lane_mask(i915, encoder); 2653 enum port port = encoder->port; 2654 2655 if (intel_is_c10phy(i915, intel_port_to_phy(i915, port))) 2656 intel_cx0_rmw(i915, port, owned_lane_mask, 2657 PHY_C10_VDR_CONTROL(1), 0, 2658 C10_VDR_CTRL_MSGBUS_ACCESS, 2659 MB_WRITE_COMMITTED); 2660 2661 if (lane_reversal) 2662 disables = REG_GENMASK8(3, 0) >> lane_count; 2663 else 2664 disables = REG_GENMASK8(3, 0) << lane_count; 2665 2666 if (dp_alt_mode && lane_count == 1) { 2667 disables &= ~REG_GENMASK8(1, 0); 2668 disables |= REG_FIELD_PREP8(REG_GENMASK8(1, 0), 0x1); 2669 } 2670 2671 for (i = 0; i < 4; i++) { 2672 int tx = i % 2 + 1; 2673 u8 lane_mask = i < 2 ? INTEL_CX0_LANE0 : INTEL_CX0_LANE1; 2674 2675 if (!(owned_lane_mask & lane_mask)) 2676 continue; 2677 2678 intel_cx0_rmw(i915, port, lane_mask, PHY_CX0_TX_CONTROL(tx, 2), 2679 CONTROL2_DISABLE_SINGLE_TX, 2680 disables & BIT(i) ? CONTROL2_DISABLE_SINGLE_TX : 0, 2681 MB_WRITE_COMMITTED); 2682 } 2683 2684 if (intel_is_c10phy(i915, intel_port_to_phy(i915, port))) 2685 intel_cx0_rmw(i915, port, owned_lane_mask, 2686 PHY_C10_VDR_CONTROL(1), 0, 2687 C10_VDR_CTRL_UPDATE_CFG, 2688 MB_WRITE_COMMITTED); 2689 } 2690 2691 static u32 intel_cx0_get_pclk_pll_request(u8 lane_mask) 2692 { 2693 u32 val = 0; 2694 int lane = 0; 2695 2696 for_each_cx0_lane_in_mask(lane_mask, lane) 2697 val |= XELPDP_LANE_PCLK_PLL_REQUEST(lane); 2698 2699 return val; 2700 } 2701 2702 static u32 intel_cx0_get_pclk_pll_ack(u8 lane_mask) 2703 { 2704 u32 val = 0; 2705 int lane = 0; 2706 2707 for_each_cx0_lane_in_mask(lane_mask, lane) 2708 val |= XELPDP_LANE_PCLK_PLL_ACK(lane); 2709 2710 return val; 2711 } 2712 2713 static void intel_cx0pll_enable(struct intel_encoder *encoder, 2714 const struct intel_crtc_state *crtc_state) 2715 { 2716 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 2717 enum phy phy = intel_port_to_phy(i915, encoder->port); 2718 struct intel_digital_port *dig_port = enc_to_dig_port(encoder); 2719 bool lane_reversal = dig_port->saved_port_bits & DDI_BUF_PORT_REVERSAL; 2720 u8 maxpclk_lane = lane_reversal ? INTEL_CX0_LANE1 : 2721 INTEL_CX0_LANE0; 2722 intel_wakeref_t wakeref = intel_cx0_phy_transaction_begin(encoder); 2723 2724 /* 2725 * 1. Program PORT_CLOCK_CTL REGISTER to configure 2726 * clock muxes, gating and SSC 2727 */ 2728 intel_program_port_clock_ctl(encoder, crtc_state, lane_reversal); 2729 2730 /* 2. Bring PHY out of reset. */ 2731 intel_cx0_phy_lane_reset(i915, encoder, lane_reversal); 2732 2733 /* 2734 * 3. Change Phy power state to Ready. 2735 * TODO: For DP alt mode use only one lane. 2736 */ 2737 intel_cx0_powerdown_change_sequence(i915, encoder->port, INTEL_CX0_BOTH_LANES, 2738 CX0_P2_STATE_READY); 2739 2740 /* 2741 * 4. Program PORT_MSGBUS_TIMER register's Message Bus Timer field to 0xA000. 2742 * (This is done inside intel_cx0_phy_transaction_begin(), since we would need 2743 * the right timer thresholds for readouts too.) 2744 */ 2745 2746 /* 5. Program PHY internal PLL internal registers. */ 2747 if (intel_is_c10phy(i915, phy)) 2748 intel_c10_pll_program(i915, crtc_state, encoder); 2749 else 2750 intel_c20_pll_program(i915, crtc_state, encoder); 2751 2752 /* 2753 * 6. Program the enabled and disabled owned PHY lane 2754 * transmitters over message bus 2755 */ 2756 intel_cx0_program_phy_lane(i915, encoder, crtc_state->lane_count, lane_reversal); 2757 2758 /* 2759 * 7. Follow the Display Voltage Frequency Switching - Sequence 2760 * Before Frequency Change. We handle this step in bxt_set_cdclk(). 2761 */ 2762 2763 /* 2764 * 8. Program DDI_CLK_VALFREQ to match intended DDI 2765 * clock frequency. 2766 */ 2767 intel_de_write(i915, DDI_CLK_VALFREQ(encoder->port), 2768 crtc_state->port_clock); 2769 2770 /* 2771 * 9. Set PORT_CLOCK_CTL register PCLK PLL Request 2772 * LN<Lane for maxPCLK> to "1" to enable PLL. 2773 */ 2774 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2775 intel_cx0_get_pclk_pll_request(INTEL_CX0_BOTH_LANES), 2776 intel_cx0_get_pclk_pll_request(maxpclk_lane)); 2777 2778 /* 10. Poll on PORT_CLOCK_CTL PCLK PLL Ack LN<Lane for maxPCLK> == "1". */ 2779 if (__intel_de_wait_for_register(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2780 intel_cx0_get_pclk_pll_ack(INTEL_CX0_BOTH_LANES), 2781 intel_cx0_get_pclk_pll_ack(maxpclk_lane), 2782 XELPDP_PCLK_PLL_ENABLE_TIMEOUT_US, 0, NULL)) 2783 drm_warn(&i915->drm, "Port %c PLL not locked after %dus.\n", 2784 phy_name(phy), XELPDP_PCLK_PLL_ENABLE_TIMEOUT_US); 2785 2786 /* 2787 * 11. Follow the Display Voltage Frequency Switching Sequence After 2788 * Frequency Change. We handle this step in bxt_set_cdclk(). 2789 */ 2790 2791 /* TODO: enable TBT-ALT mode */ 2792 intel_cx0_phy_transaction_end(encoder, wakeref); 2793 } 2794 2795 int intel_mtl_tbt_calc_port_clock(struct intel_encoder *encoder) 2796 { 2797 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 2798 u32 clock; 2799 u32 val = intel_de_read(i915, XELPDP_PORT_CLOCK_CTL(encoder->port)); 2800 2801 clock = REG_FIELD_GET(XELPDP_DDI_CLOCK_SELECT_MASK, val); 2802 2803 drm_WARN_ON(&i915->drm, !(val & XELPDP_FORWARD_CLOCK_UNGATE)); 2804 drm_WARN_ON(&i915->drm, !(val & XELPDP_TBT_CLOCK_REQUEST)); 2805 drm_WARN_ON(&i915->drm, !(val & XELPDP_TBT_CLOCK_ACK)); 2806 2807 switch (clock) { 2808 case XELPDP_DDI_CLOCK_SELECT_TBT_162: 2809 return 162000; 2810 case XELPDP_DDI_CLOCK_SELECT_TBT_270: 2811 return 270000; 2812 case XELPDP_DDI_CLOCK_SELECT_TBT_540: 2813 return 540000; 2814 case XELPDP_DDI_CLOCK_SELECT_TBT_810: 2815 return 810000; 2816 default: 2817 MISSING_CASE(clock); 2818 return 162000; 2819 } 2820 } 2821 2822 static int intel_mtl_tbt_clock_select(struct drm_i915_private *i915, int clock) 2823 { 2824 switch (clock) { 2825 case 162000: 2826 return XELPDP_DDI_CLOCK_SELECT_TBT_162; 2827 case 270000: 2828 return XELPDP_DDI_CLOCK_SELECT_TBT_270; 2829 case 540000: 2830 return XELPDP_DDI_CLOCK_SELECT_TBT_540; 2831 case 810000: 2832 return XELPDP_DDI_CLOCK_SELECT_TBT_810; 2833 default: 2834 MISSING_CASE(clock); 2835 return XELPDP_DDI_CLOCK_SELECT_TBT_162; 2836 } 2837 } 2838 2839 static void intel_mtl_tbt_pll_enable(struct intel_encoder *encoder, 2840 const struct intel_crtc_state *crtc_state) 2841 { 2842 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 2843 enum phy phy = intel_port_to_phy(i915, encoder->port); 2844 u32 val = 0; 2845 2846 /* 2847 * 1. Program PORT_CLOCK_CTL REGISTER to configure 2848 * clock muxes, gating and SSC 2849 */ 2850 val |= XELPDP_DDI_CLOCK_SELECT(intel_mtl_tbt_clock_select(i915, crtc_state->port_clock)); 2851 val |= XELPDP_FORWARD_CLOCK_UNGATE; 2852 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2853 XELPDP_DDI_CLOCK_SELECT_MASK | XELPDP_FORWARD_CLOCK_UNGATE, val); 2854 2855 /* 2. Read back PORT_CLOCK_CTL REGISTER */ 2856 val = intel_de_read(i915, XELPDP_PORT_CLOCK_CTL(encoder->port)); 2857 2858 /* 2859 * 3. Follow the Display Voltage Frequency Switching - Sequence 2860 * Before Frequency Change. We handle this step in bxt_set_cdclk(). 2861 */ 2862 2863 /* 2864 * 4. Set PORT_CLOCK_CTL register TBT CLOCK Request to "1" to enable PLL. 2865 */ 2866 val |= XELPDP_TBT_CLOCK_REQUEST; 2867 intel_de_write(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), val); 2868 2869 /* 5. Poll on PORT_CLOCK_CTL TBT CLOCK Ack == "1". */ 2870 if (__intel_de_wait_for_register(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2871 XELPDP_TBT_CLOCK_ACK, 2872 XELPDP_TBT_CLOCK_ACK, 2873 100, 0, NULL)) 2874 drm_warn(&i915->drm, "[ENCODER:%d:%s][%c] PHY PLL not locked after 100us.\n", 2875 encoder->base.base.id, encoder->base.name, phy_name(phy)); 2876 2877 /* 2878 * 6. Follow the Display Voltage Frequency Switching Sequence After 2879 * Frequency Change. We handle this step in bxt_set_cdclk(). 2880 */ 2881 2882 /* 2883 * 7. Program DDI_CLK_VALFREQ to match intended DDI 2884 * clock frequency. 2885 */ 2886 intel_de_write(i915, DDI_CLK_VALFREQ(encoder->port), 2887 crtc_state->port_clock); 2888 } 2889 2890 void intel_mtl_pll_enable(struct intel_encoder *encoder, 2891 const struct intel_crtc_state *crtc_state) 2892 { 2893 struct intel_digital_port *dig_port = enc_to_dig_port(encoder); 2894 2895 if (intel_tc_port_in_tbt_alt_mode(dig_port)) 2896 intel_mtl_tbt_pll_enable(encoder, crtc_state); 2897 else 2898 intel_cx0pll_enable(encoder, crtc_state); 2899 } 2900 2901 static void intel_cx0pll_disable(struct intel_encoder *encoder) 2902 { 2903 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 2904 enum phy phy = intel_port_to_phy(i915, encoder->port); 2905 bool is_c10 = intel_is_c10phy(i915, phy); 2906 intel_wakeref_t wakeref = intel_cx0_phy_transaction_begin(encoder); 2907 2908 /* 1. Change owned PHY lane power to Disable state. */ 2909 intel_cx0_powerdown_change_sequence(i915, encoder->port, INTEL_CX0_BOTH_LANES, 2910 is_c10 ? CX0_P2PG_STATE_DISABLE : 2911 CX0_P4PG_STATE_DISABLE); 2912 2913 /* 2914 * 2. Follow the Display Voltage Frequency Switching Sequence Before 2915 * Frequency Change. We handle this step in bxt_set_cdclk(). 2916 */ 2917 2918 /* 2919 * 3. Set PORT_CLOCK_CTL register PCLK PLL Request LN<Lane for maxPCLK> 2920 * to "0" to disable PLL. 2921 */ 2922 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2923 intel_cx0_get_pclk_pll_request(INTEL_CX0_BOTH_LANES) | 2924 intel_cx0_get_pclk_refclk_request(INTEL_CX0_BOTH_LANES), 0); 2925 2926 /* 4. Program DDI_CLK_VALFREQ to 0. */ 2927 intel_de_write(i915, DDI_CLK_VALFREQ(encoder->port), 0); 2928 2929 /* 2930 * 5. Poll on PORT_CLOCK_CTL PCLK PLL Ack LN<Lane for maxPCLK**> == "0". 2931 */ 2932 if (__intel_de_wait_for_register(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2933 intel_cx0_get_pclk_pll_ack(INTEL_CX0_BOTH_LANES) | 2934 intel_cx0_get_pclk_refclk_ack(INTEL_CX0_BOTH_LANES), 0, 2935 XELPDP_PCLK_PLL_DISABLE_TIMEOUT_US, 0, NULL)) 2936 drm_warn(&i915->drm, "Port %c PLL not unlocked after %dus.\n", 2937 phy_name(phy), XELPDP_PCLK_PLL_DISABLE_TIMEOUT_US); 2938 2939 /* 2940 * 6. Follow the Display Voltage Frequency Switching Sequence After 2941 * Frequency Change. We handle this step in bxt_set_cdclk(). 2942 */ 2943 2944 /* 7. Program PORT_CLOCK_CTL register to disable and gate clocks. */ 2945 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2946 XELPDP_DDI_CLOCK_SELECT_MASK, 0); 2947 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2948 XELPDP_FORWARD_CLOCK_UNGATE, 0); 2949 2950 intel_cx0_phy_transaction_end(encoder, wakeref); 2951 } 2952 2953 static void intel_mtl_tbt_pll_disable(struct intel_encoder *encoder) 2954 { 2955 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 2956 enum phy phy = intel_port_to_phy(i915, encoder->port); 2957 2958 /* 2959 * 1. Follow the Display Voltage Frequency Switching Sequence Before 2960 * Frequency Change. We handle this step in bxt_set_cdclk(). 2961 */ 2962 2963 /* 2964 * 2. Set PORT_CLOCK_CTL register TBT CLOCK Request to "0" to disable PLL. 2965 */ 2966 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2967 XELPDP_TBT_CLOCK_REQUEST, 0); 2968 2969 /* 3. Poll on PORT_CLOCK_CTL TBT CLOCK Ack == "0". */ 2970 if (__intel_de_wait_for_register(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2971 XELPDP_TBT_CLOCK_ACK, 0, 10, 0, NULL)) 2972 drm_warn(&i915->drm, "[ENCODER:%d:%s][%c] PHY PLL not unlocked after 10us.\n", 2973 encoder->base.base.id, encoder->base.name, phy_name(phy)); 2974 2975 /* 2976 * 4. Follow the Display Voltage Frequency Switching Sequence After 2977 * Frequency Change. We handle this step in bxt_set_cdclk(). 2978 */ 2979 2980 /* 2981 * 5. Program PORT CLOCK CTRL register to disable and gate clocks 2982 */ 2983 intel_de_rmw(i915, XELPDP_PORT_CLOCK_CTL(encoder->port), 2984 XELPDP_DDI_CLOCK_SELECT_MASK | 2985 XELPDP_FORWARD_CLOCK_UNGATE, 0); 2986 2987 /* 6. Program DDI_CLK_VALFREQ to 0. */ 2988 intel_de_write(i915, DDI_CLK_VALFREQ(encoder->port), 0); 2989 } 2990 2991 void intel_mtl_pll_disable(struct intel_encoder *encoder) 2992 { 2993 struct intel_digital_port *dig_port = enc_to_dig_port(encoder); 2994 2995 if (intel_tc_port_in_tbt_alt_mode(dig_port)) 2996 intel_mtl_tbt_pll_disable(encoder); 2997 else 2998 intel_cx0pll_disable(encoder); 2999 } 3000 3001 enum icl_port_dpll_id 3002 intel_mtl_port_pll_type(struct intel_encoder *encoder, 3003 const struct intel_crtc_state *crtc_state) 3004 { 3005 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 3006 /* 3007 * TODO: Determine the PLL type from the SW state, once MTL PLL 3008 * handling is done via the standard shared DPLL framework. 3009 */ 3010 u32 val = intel_de_read(i915, XELPDP_PORT_CLOCK_CTL(encoder->port)); 3011 u32 clock = REG_FIELD_GET(XELPDP_DDI_CLOCK_SELECT_MASK, val); 3012 3013 if (clock == XELPDP_DDI_CLOCK_SELECT_MAXPCLK || 3014 clock == XELPDP_DDI_CLOCK_SELECT_DIV18CLK) 3015 return ICL_PORT_DPLL_MG_PHY; 3016 else 3017 return ICL_PORT_DPLL_DEFAULT; 3018 } 3019 3020 static void intel_c10pll_state_verify(const struct intel_crtc_state *state, 3021 struct intel_crtc *crtc, 3022 struct intel_encoder *encoder, 3023 struct intel_c10pll_state *mpllb_hw_state) 3024 { 3025 struct drm_i915_private *i915 = to_i915(crtc->base.dev); 3026 const struct intel_c10pll_state *mpllb_sw_state = &state->cx0pll_state.c10; 3027 int i; 3028 3029 for (i = 0; i < ARRAY_SIZE(mpllb_sw_state->pll); i++) { 3030 u8 expected = mpllb_sw_state->pll[i]; 3031 3032 I915_STATE_WARN(i915, mpllb_hw_state->pll[i] != expected, 3033 "[CRTC:%d:%s] mismatch in C10MPLLB: Register[%d] (expected 0x%02x, found 0x%02x)", 3034 crtc->base.base.id, crtc->base.name, i, 3035 expected, mpllb_hw_state->pll[i]); 3036 } 3037 3038 I915_STATE_WARN(i915, mpllb_hw_state->tx != mpllb_sw_state->tx, 3039 "[CRTC:%d:%s] mismatch in C10MPLLB: Register TX0 (expected 0x%02x, found 0x%02x)", 3040 crtc->base.base.id, crtc->base.name, 3041 mpllb_sw_state->tx, mpllb_hw_state->tx); 3042 3043 I915_STATE_WARN(i915, mpllb_hw_state->cmn != mpllb_sw_state->cmn, 3044 "[CRTC:%d:%s] mismatch in C10MPLLB: Register CMN0 (expected 0x%02x, found 0x%02x)", 3045 crtc->base.base.id, crtc->base.name, 3046 mpllb_sw_state->cmn, mpllb_hw_state->cmn); 3047 } 3048 3049 void intel_cx0pll_readout_hw_state(struct intel_encoder *encoder, 3050 struct intel_cx0pll_state *pll_state) 3051 { 3052 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 3053 enum phy phy = intel_port_to_phy(i915, encoder->port); 3054 3055 if (intel_is_c10phy(i915, phy)) 3056 intel_c10pll_readout_hw_state(encoder, &pll_state->c10); 3057 else 3058 intel_c20pll_readout_hw_state(encoder, &pll_state->c20); 3059 } 3060 3061 int intel_cx0pll_calc_port_clock(struct intel_encoder *encoder, 3062 const struct intel_cx0pll_state *pll_state) 3063 { 3064 struct drm_i915_private *i915 = to_i915(encoder->base.dev); 3065 enum phy phy = intel_port_to_phy(i915, encoder->port); 3066 3067 if (intel_is_c10phy(i915, phy)) 3068 return intel_c10pll_calc_port_clock(encoder, &pll_state->c10); 3069 3070 return intel_c20pll_calc_port_clock(encoder, &pll_state->c20); 3071 } 3072 3073 static void intel_c20pll_state_verify(const struct intel_crtc_state *state, 3074 struct intel_crtc *crtc, 3075 struct intel_encoder *encoder, 3076 struct intel_c20pll_state *mpll_hw_state) 3077 { 3078 struct drm_i915_private *i915 = to_i915(crtc->base.dev); 3079 const struct intel_c20pll_state *mpll_sw_state = &state->cx0pll_state.c20; 3080 bool use_mplla; 3081 int i; 3082 3083 use_mplla = intel_c20_use_mplla(mpll_hw_state->clock); 3084 if (use_mplla) { 3085 for (i = 0; i < ARRAY_SIZE(mpll_sw_state->mplla); i++) { 3086 I915_STATE_WARN(i915, mpll_hw_state->mplla[i] != mpll_sw_state->mplla[i], 3087 "[CRTC:%d:%s] mismatch in C20MPLLA: Register[%d] (expected 0x%04x, found 0x%04x)", 3088 crtc->base.base.id, crtc->base.name, i, 3089 mpll_sw_state->mplla[i], mpll_hw_state->mplla[i]); 3090 } 3091 } else { 3092 for (i = 0; i < ARRAY_SIZE(mpll_sw_state->mpllb); i++) { 3093 I915_STATE_WARN(i915, mpll_hw_state->mpllb[i] != mpll_sw_state->mpllb[i], 3094 "[CRTC:%d:%s] mismatch in C20MPLLB: Register[%d] (expected 0x%04x, found 0x%04x)", 3095 crtc->base.base.id, crtc->base.name, i, 3096 mpll_sw_state->mpllb[i], mpll_hw_state->mpllb[i]); 3097 } 3098 } 3099 3100 for (i = 0; i < ARRAY_SIZE(mpll_sw_state->tx); i++) { 3101 I915_STATE_WARN(i915, mpll_hw_state->tx[i] != mpll_sw_state->tx[i], 3102 "[CRTC:%d:%s] mismatch in C20: Register TX[%i] (expected 0x%04x, found 0x%04x)", 3103 crtc->base.base.id, crtc->base.name, i, 3104 mpll_sw_state->tx[i], mpll_hw_state->tx[i]); 3105 } 3106 3107 for (i = 0; i < ARRAY_SIZE(mpll_sw_state->cmn); i++) { 3108 I915_STATE_WARN(i915, mpll_hw_state->cmn[i] != mpll_sw_state->cmn[i], 3109 "[CRTC:%d:%s] mismatch in C20: Register CMN[%i] (expected 0x%04x, found 0x%04x)", 3110 crtc->base.base.id, crtc->base.name, i, 3111 mpll_sw_state->cmn[i], mpll_hw_state->cmn[i]); 3112 } 3113 } 3114 3115 void intel_cx0pll_state_verify(struct intel_atomic_state *state, 3116 struct intel_crtc *crtc) 3117 { 3118 struct drm_i915_private *i915 = to_i915(state->base.dev); 3119 const struct intel_crtc_state *new_crtc_state = 3120 intel_atomic_get_new_crtc_state(state, crtc); 3121 struct intel_encoder *encoder; 3122 struct intel_cx0pll_state mpll_hw_state = {}; 3123 enum phy phy; 3124 3125 if (DISPLAY_VER(i915) < 14) 3126 return; 3127 3128 if (!new_crtc_state->hw.active) 3129 return; 3130 3131 /* intel_get_crtc_new_encoder() only works for modeset/fastset commits */ 3132 if (!intel_crtc_needs_modeset(new_crtc_state) && 3133 !intel_crtc_needs_fastset(new_crtc_state)) 3134 return; 3135 3136 encoder = intel_get_crtc_new_encoder(state, new_crtc_state); 3137 phy = intel_port_to_phy(i915, encoder->port); 3138 3139 intel_cx0pll_readout_hw_state(encoder, &mpll_hw_state); 3140 3141 if (intel_is_c10phy(i915, phy)) 3142 intel_c10pll_state_verify(new_crtc_state, crtc, encoder, &mpll_hw_state.c10); 3143 else 3144 intel_c20pll_state_verify(new_crtc_state, crtc, encoder, &mpll_hw_state.c20); 3145 } 3146