1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright 2019 Advanced Micro Devices, Inc. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: AMD 24 * 25 */ 26 27 #include "dm_services.h" 28 #include "dc.h" 29 30 #include "dcn32/dcn32_init.h" 31 32 #include "resource.h" 33 #include "include/irq_service_interface.h" 34 #include "dcn32/dcn32_resource.h" 35 #include "dcn321_resource.h" 36 37 #include "dcn20/dcn20_resource.h" 38 #include "dcn30/dcn30_resource.h" 39 40 #include "dml/dcn321/dcn321_fpu.h" 41 42 #include "dcn10/dcn10_ipp.h" 43 #include "dcn30/dcn30_hubbub.h" 44 #include "dcn31/dcn31_hubbub.h" 45 #include "dcn32/dcn32_hubbub.h" 46 #include "dcn32/dcn32_mpc.h" 47 #include "dcn32/dcn32_hubp.h" 48 #include "irq/dcn32/irq_service_dcn32.h" 49 #include "dcn32/dcn32_dpp.h" 50 #include "dcn32/dcn32_optc.h" 51 #include "dcn20/dcn20_hwseq.h" 52 #include "dcn30/dcn30_hwseq.h" 53 #include "dce110/dce110_hw_sequencer.h" 54 #include "dcn30/dcn30_opp.h" 55 #include "dcn20/dcn20_dsc.h" 56 #include "dcn30/dcn30_vpg.h" 57 #include "dcn30/dcn30_afmt.h" 58 #include "dcn30/dcn30_dio_stream_encoder.h" 59 #include "dcn32/dcn32_dio_stream_encoder.h" 60 #include "dcn31/dcn31_hpo_dp_stream_encoder.h" 61 #include "dcn31/dcn31_hpo_dp_link_encoder.h" 62 #include "dcn32/dcn32_hpo_dp_link_encoder.h" 63 #include "dc_link_dp.h" 64 #include "dcn31/dcn31_apg.h" 65 #include "dcn31/dcn31_dio_link_encoder.h" 66 #include "dcn32/dcn32_dio_link_encoder.h" 67 #include "dcn321_dio_link_encoder.h" 68 #include "dce/dce_clock_source.h" 69 #include "dce/dce_audio.h" 70 #include "dce/dce_hwseq.h" 71 #include "clk_mgr.h" 72 #include "virtual/virtual_stream_encoder.h" 73 #include "dml/display_mode_vba.h" 74 #include "dcn32/dcn32_dccg.h" 75 #include "dcn10/dcn10_resource.h" 76 #include "dc_link_ddc.h" 77 #include "dcn31/dcn31_panel_cntl.h" 78 79 #include "dcn30/dcn30_dwb.h" 80 #include "dcn32/dcn32_mmhubbub.h" 81 82 #include "dcn/dcn_3_2_1_offset.h" 83 #include "dcn/dcn_3_2_1_sh_mask.h" 84 #include "nbio/nbio_4_3_0_offset.h" 85 86 #include "reg_helper.h" 87 #include "dce/dmub_abm.h" 88 #include "dce/dmub_psr.h" 89 #include "dce/dce_aux.h" 90 #include "dce/dce_i2c.h" 91 92 #include "dml/dcn30/display_mode_vba_30.h" 93 #include "vm_helper.h" 94 #include "dcn20/dcn20_vmid.h" 95 96 #define DCN_BASE__INST0_SEG1 0x000000C0 97 #define DCN_BASE__INST0_SEG2 0x000034C0 98 #define DCN_BASE__INST0_SEG3 0x00009000 99 #define NBIO_BASE__INST0_SEG1 0x00000014 100 101 #define MAX_INSTANCE 8 102 #define MAX_SEGMENT 6 103 104 struct IP_BASE_INSTANCE { 105 unsigned int segment[MAX_SEGMENT]; 106 }; 107 108 struct IP_BASE { 109 struct IP_BASE_INSTANCE instance[MAX_INSTANCE]; 110 }; 111 112 static const struct IP_BASE DCN_BASE = { { { { 0x00000012, 0x000000C0, 0x000034C0, 0x00009000, 0x02403C00, 0 } }, 113 { { 0, 0, 0, 0, 0, 0 } }, 114 { { 0, 0, 0, 0, 0, 0 } }, 115 { { 0, 0, 0, 0, 0, 0 } }, 116 { { 0, 0, 0, 0, 0, 0 } }, 117 { { 0, 0, 0, 0, 0, 0 } }, 118 { { 0, 0, 0, 0, 0, 0 } }, 119 { { 0, 0, 0, 0, 0, 0 } } } }; 120 121 #define DC_LOGGER_INIT(logger) 122 #define fixed16_to_double(x) (((double)x) / ((double) (1 << 16))) 123 #define fixed16_to_double_to_cpu(x) fixed16_to_double(le32_to_cpu(x)) 124 125 enum dcn321_clk_src_array_id { 126 DCN321_CLK_SRC_PLL0, 127 DCN321_CLK_SRC_PLL1, 128 DCN321_CLK_SRC_PLL2, 129 DCN321_CLK_SRC_PLL3, 130 DCN321_CLK_SRC_PLL4, 131 DCN321_CLK_SRC_TOTAL 132 }; 133 134 /* begin ********************* 135 * macros to expend register list macro defined in HW object header file 136 */ 137 138 /* DCN */ 139 /* TODO awful hack. fixup dcn20_dwb.h */ 140 #undef BASE_INNER 141 #define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg 142 143 #define BASE(seg) BASE_INNER(seg) 144 145 #define SR(reg_name)\ 146 .reg_name = BASE(reg ## reg_name ## _BASE_IDX) + \ 147 reg ## reg_name 148 149 #define SRI(reg_name, block, id)\ 150 .reg_name = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 151 reg ## block ## id ## _ ## reg_name 152 153 #define SRI2(reg_name, block, id)\ 154 .reg_name = BASE(reg ## reg_name ## _BASE_IDX) + \ 155 reg ## reg_name 156 157 #define SRIR(var_name, reg_name, block, id)\ 158 .var_name = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 159 reg ## block ## id ## _ ## reg_name 160 161 #define SRII(reg_name, block, id)\ 162 .reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 163 reg ## block ## id ## _ ## reg_name 164 165 #define SRII_MPC_RMU(reg_name, block, id)\ 166 .RMU##_##reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 167 reg ## block ## id ## _ ## reg_name 168 169 #define SRII_DWB(reg_name, temp_name, block, id)\ 170 .reg_name[id] = BASE(reg ## block ## id ## _ ## temp_name ## _BASE_IDX) + \ 171 reg ## block ## id ## _ ## temp_name 172 173 #define DCCG_SRII(reg_name, block, id)\ 174 .block ## _ ## reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 175 reg ## block ## id ## _ ## reg_name 176 177 #define VUPDATE_SRII(reg_name, block, id)\ 178 .reg_name[id] = BASE(reg ## reg_name ## _ ## block ## id ## _BASE_IDX) + \ 179 reg ## reg_name ## _ ## block ## id 180 181 /* NBIO */ 182 #define NBIO_BASE_INNER(seg) \ 183 NBIO_BASE__INST0_SEG ## seg 184 185 #define NBIO_BASE(seg) \ 186 NBIO_BASE_INNER(seg) 187 188 #define NBIO_SR(reg_name)\ 189 .reg_name = NBIO_BASE(regBIF_BX0_ ## reg_name ## _BASE_IDX) + \ 190 regBIF_BX0_ ## reg_name 191 192 #define CTX ctx 193 #define REG(reg_name) \ 194 (DCN_BASE.instance[0].segment[reg ## reg_name ## _BASE_IDX] + reg ## reg_name) 195 196 static const struct bios_registers bios_regs = { 197 NBIO_SR(BIOS_SCRATCH_3), 198 NBIO_SR(BIOS_SCRATCH_6) 199 }; 200 201 #define clk_src_regs(index, pllid)\ 202 [index] = {\ 203 CS_COMMON_REG_LIST_DCN3_0(index, pllid),\ 204 } 205 206 static const struct dce110_clk_src_regs clk_src_regs[] = { 207 clk_src_regs(0, A), 208 clk_src_regs(1, B), 209 clk_src_regs(2, C), 210 clk_src_regs(3, D), 211 clk_src_regs(4, E) 212 }; 213 214 static const struct dce110_clk_src_shift cs_shift = { 215 CS_COMMON_MASK_SH_LIST_DCN3_2(__SHIFT) 216 }; 217 218 static const struct dce110_clk_src_mask cs_mask = { 219 CS_COMMON_MASK_SH_LIST_DCN3_2(_MASK) 220 }; 221 222 #define abm_regs(id)\ 223 [id] = {\ 224 ABM_DCN32_REG_LIST(id)\ 225 } 226 227 static const struct dce_abm_registers abm_regs[] = { 228 abm_regs(0), 229 abm_regs(1), 230 abm_regs(2), 231 abm_regs(3), 232 }; 233 234 static const struct dce_abm_shift abm_shift = { 235 ABM_MASK_SH_LIST_DCN32(__SHIFT) 236 }; 237 238 static const struct dce_abm_mask abm_mask = { 239 ABM_MASK_SH_LIST_DCN32(_MASK) 240 }; 241 242 #define audio_regs(id)\ 243 [id] = {\ 244 AUD_COMMON_REG_LIST(id)\ 245 } 246 247 static const struct dce_audio_registers audio_regs[] = { 248 audio_regs(0), 249 audio_regs(1), 250 audio_regs(2), 251 audio_regs(3), 252 audio_regs(4) 253 }; 254 255 #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\ 256 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\ 257 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\ 258 AUD_COMMON_MASK_SH_LIST_BASE(mask_sh) 259 260 static const struct dce_audio_shift audio_shift = { 261 DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT) 262 }; 263 264 static const struct dce_audio_mask audio_mask = { 265 DCE120_AUD_COMMON_MASK_SH_LIST(_MASK) 266 }; 267 268 #define vpg_regs(id)\ 269 [id] = {\ 270 VPG_DCN3_REG_LIST(id)\ 271 } 272 273 static const struct dcn30_vpg_registers vpg_regs[] = { 274 vpg_regs(0), 275 vpg_regs(1), 276 vpg_regs(2), 277 vpg_regs(3), 278 vpg_regs(4), 279 vpg_regs(5), 280 vpg_regs(6), 281 vpg_regs(7), 282 vpg_regs(8), 283 vpg_regs(9), 284 }; 285 286 static const struct dcn30_vpg_shift vpg_shift = { 287 DCN3_VPG_MASK_SH_LIST(__SHIFT) 288 }; 289 290 static const struct dcn30_vpg_mask vpg_mask = { 291 DCN3_VPG_MASK_SH_LIST(_MASK) 292 }; 293 294 #define afmt_regs(id)\ 295 [id] = {\ 296 AFMT_DCN3_REG_LIST(id)\ 297 } 298 299 static const struct dcn30_afmt_registers afmt_regs[] = { 300 afmt_regs(0), 301 afmt_regs(1), 302 afmt_regs(2), 303 afmt_regs(3), 304 afmt_regs(4), 305 afmt_regs(5) 306 }; 307 308 static const struct dcn30_afmt_shift afmt_shift = { 309 DCN3_AFMT_MASK_SH_LIST(__SHIFT) 310 }; 311 312 static const struct dcn30_afmt_mask afmt_mask = { 313 DCN3_AFMT_MASK_SH_LIST(_MASK) 314 }; 315 316 #define apg_regs(id)\ 317 [id] = {\ 318 APG_DCN31_REG_LIST(id)\ 319 } 320 321 static const struct dcn31_apg_registers apg_regs[] = { 322 apg_regs(0), 323 apg_regs(1), 324 apg_regs(2), 325 apg_regs(3) 326 }; 327 328 static const struct dcn31_apg_shift apg_shift = { 329 DCN31_APG_MASK_SH_LIST(__SHIFT) 330 }; 331 332 static const struct dcn31_apg_mask apg_mask = { 333 DCN31_APG_MASK_SH_LIST(_MASK) 334 }; 335 336 #define stream_enc_regs(id)\ 337 [id] = {\ 338 SE_DCN32_REG_LIST(id)\ 339 } 340 341 static const struct dcn10_stream_enc_registers stream_enc_regs[] = { 342 stream_enc_regs(0), 343 stream_enc_regs(1), 344 stream_enc_regs(2), 345 stream_enc_regs(3), 346 stream_enc_regs(4) 347 }; 348 349 static const struct dcn10_stream_encoder_shift se_shift = { 350 SE_COMMON_MASK_SH_LIST_DCN32(__SHIFT) 351 }; 352 353 static const struct dcn10_stream_encoder_mask se_mask = { 354 SE_COMMON_MASK_SH_LIST_DCN32(_MASK) 355 }; 356 357 358 #define aux_regs(id)\ 359 [id] = {\ 360 DCN2_AUX_REG_LIST(id)\ 361 } 362 363 static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = { 364 aux_regs(0), 365 aux_regs(1), 366 aux_regs(2), 367 aux_regs(3), 368 aux_regs(4) 369 }; 370 371 #define hpd_regs(id)\ 372 [id] = {\ 373 HPD_REG_LIST(id)\ 374 } 375 376 static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = { 377 hpd_regs(0), 378 hpd_regs(1), 379 hpd_regs(2), 380 hpd_regs(3), 381 hpd_regs(4) 382 }; 383 384 #define link_regs(id, phyid)\ 385 [id] = {\ 386 LE_DCN31_REG_LIST(id), \ 387 UNIPHY_DCN2_REG_LIST(phyid), \ 388 /*DPCS_DCN31_REG_LIST(id),*/ \ 389 } 390 391 static const struct dcn10_link_enc_registers link_enc_regs[] = { 392 link_regs(0, A), 393 link_regs(1, B), 394 link_regs(2, C), 395 link_regs(3, D), 396 link_regs(4, E) 397 }; 398 399 static const struct dcn10_link_enc_shift le_shift = { 400 LINK_ENCODER_MASK_SH_LIST_DCN31(__SHIFT), \ 401 // DPCS_DCN31_MASK_SH_LIST(__SHIFT) 402 }; 403 404 static const struct dcn10_link_enc_mask le_mask = { 405 LINK_ENCODER_MASK_SH_LIST_DCN31(_MASK), \ 406 // DPCS_DCN31_MASK_SH_LIST(_MASK) 407 }; 408 409 #define hpo_dp_stream_encoder_reg_list(id)\ 410 [id] = {\ 411 DCN3_1_HPO_DP_STREAM_ENC_REG_LIST(id)\ 412 } 413 414 static const struct dcn31_hpo_dp_stream_encoder_registers hpo_dp_stream_enc_regs[] = { 415 hpo_dp_stream_encoder_reg_list(0), 416 hpo_dp_stream_encoder_reg_list(1), 417 hpo_dp_stream_encoder_reg_list(2), 418 hpo_dp_stream_encoder_reg_list(3), 419 }; 420 421 static const struct dcn31_hpo_dp_stream_encoder_shift hpo_dp_se_shift = { 422 DCN3_1_HPO_DP_STREAM_ENC_MASK_SH_LIST(__SHIFT) 423 }; 424 425 static const struct dcn31_hpo_dp_stream_encoder_mask hpo_dp_se_mask = { 426 DCN3_1_HPO_DP_STREAM_ENC_MASK_SH_LIST(_MASK) 427 }; 428 429 430 #define hpo_dp_link_encoder_reg_list(id)\ 431 [id] = {\ 432 DCN3_1_HPO_DP_LINK_ENC_REG_LIST(id),\ 433 /*DCN3_1_RDPCSTX_REG_LIST(0),*/\ 434 /*DCN3_1_RDPCSTX_REG_LIST(1),*/\ 435 /*DCN3_1_RDPCSTX_REG_LIST(2),*/\ 436 /*DCN3_1_RDPCSTX_REG_LIST(3),*/\ 437 /*DCN3_1_RDPCSTX_REG_LIST(4)*/\ 438 } 439 440 static const struct dcn31_hpo_dp_link_encoder_registers hpo_dp_link_enc_regs[] = { 441 hpo_dp_link_encoder_reg_list(0), 442 hpo_dp_link_encoder_reg_list(1), 443 }; 444 445 static const struct dcn31_hpo_dp_link_encoder_shift hpo_dp_le_shift = { 446 DCN3_2_HPO_DP_LINK_ENC_MASK_SH_LIST(__SHIFT) 447 }; 448 449 static const struct dcn31_hpo_dp_link_encoder_mask hpo_dp_le_mask = { 450 DCN3_2_HPO_DP_LINK_ENC_MASK_SH_LIST(_MASK) 451 }; 452 453 #define dpp_regs(id)\ 454 [id] = {\ 455 DPP_REG_LIST_DCN30_COMMON(id),\ 456 } 457 458 static const struct dcn3_dpp_registers dpp_regs[] = { 459 dpp_regs(0), 460 dpp_regs(1), 461 dpp_regs(2), 462 dpp_regs(3) 463 }; 464 465 static const struct dcn3_dpp_shift tf_shift = { 466 DPP_REG_LIST_SH_MASK_DCN30_COMMON(__SHIFT) 467 }; 468 469 static const struct dcn3_dpp_mask tf_mask = { 470 DPP_REG_LIST_SH_MASK_DCN30_COMMON(_MASK) 471 }; 472 473 474 #define opp_regs(id)\ 475 [id] = {\ 476 OPP_REG_LIST_DCN30(id),\ 477 } 478 479 static const struct dcn20_opp_registers opp_regs[] = { 480 opp_regs(0), 481 opp_regs(1), 482 opp_regs(2), 483 opp_regs(3) 484 }; 485 486 static const struct dcn20_opp_shift opp_shift = { 487 OPP_MASK_SH_LIST_DCN20(__SHIFT) 488 }; 489 490 static const struct dcn20_opp_mask opp_mask = { 491 OPP_MASK_SH_LIST_DCN20(_MASK) 492 }; 493 494 #define aux_engine_regs(id)\ 495 [id] = {\ 496 AUX_COMMON_REG_LIST0(id), \ 497 .AUXN_IMPCAL = 0, \ 498 .AUXP_IMPCAL = 0, \ 499 .AUX_RESET_MASK = DP_AUX0_AUX_CONTROL__AUX_RESET_MASK, \ 500 } 501 502 static const struct dce110_aux_registers aux_engine_regs[] = { 503 aux_engine_regs(0), 504 aux_engine_regs(1), 505 aux_engine_regs(2), 506 aux_engine_regs(3), 507 aux_engine_regs(4) 508 }; 509 510 static const struct dce110_aux_registers_shift aux_shift = { 511 DCN_AUX_MASK_SH_LIST(__SHIFT) 512 }; 513 514 static const struct dce110_aux_registers_mask aux_mask = { 515 DCN_AUX_MASK_SH_LIST(_MASK) 516 }; 517 518 519 #define dwbc_regs_dcn3(id)\ 520 [id] = {\ 521 DWBC_COMMON_REG_LIST_DCN30(id),\ 522 } 523 524 static const struct dcn30_dwbc_registers dwbc30_regs[] = { 525 dwbc_regs_dcn3(0), 526 }; 527 528 static const struct dcn30_dwbc_shift dwbc30_shift = { 529 DWBC_COMMON_MASK_SH_LIST_DCN30(__SHIFT) 530 }; 531 532 static const struct dcn30_dwbc_mask dwbc30_mask = { 533 DWBC_COMMON_MASK_SH_LIST_DCN30(_MASK) 534 }; 535 536 #define mcif_wb_regs_dcn3(id)\ 537 [id] = {\ 538 MCIF_WB_COMMON_REG_LIST_DCN32(id),\ 539 } 540 541 static const struct dcn30_mmhubbub_registers mcif_wb30_regs[] = { 542 mcif_wb_regs_dcn3(0) 543 }; 544 545 static const struct dcn30_mmhubbub_shift mcif_wb30_shift = { 546 MCIF_WB_COMMON_MASK_SH_LIST_DCN32(__SHIFT) 547 }; 548 549 static const struct dcn30_mmhubbub_mask mcif_wb30_mask = { 550 MCIF_WB_COMMON_MASK_SH_LIST_DCN32(_MASK) 551 }; 552 553 #define dsc_regsDCN20(id)\ 554 [id] = {\ 555 DSC_REG_LIST_DCN20(id)\ 556 } 557 558 static const struct dcn20_dsc_registers dsc_regs[] = { 559 dsc_regsDCN20(0), 560 dsc_regsDCN20(1), 561 dsc_regsDCN20(2), 562 dsc_regsDCN20(3) 563 }; 564 565 static const struct dcn20_dsc_shift dsc_shift = { 566 DSC_REG_LIST_SH_MASK_DCN20(__SHIFT) 567 }; 568 569 static const struct dcn20_dsc_mask dsc_mask = { 570 DSC_REG_LIST_SH_MASK_DCN20(_MASK) 571 }; 572 573 static const struct dcn30_mpc_registers mpc_regs = { 574 MPC_REG_LIST_DCN3_2(0), 575 MPC_REG_LIST_DCN3_2(1), 576 MPC_REG_LIST_DCN3_2(2), 577 MPC_REG_LIST_DCN3_2(3), 578 MPC_OUT_MUX_REG_LIST_DCN3_0(0), 579 MPC_OUT_MUX_REG_LIST_DCN3_0(1), 580 MPC_OUT_MUX_REG_LIST_DCN3_0(2), 581 MPC_OUT_MUX_REG_LIST_DCN3_0(3), 582 MPC_DWB_MUX_REG_LIST_DCN3_0(0), 583 }; 584 585 static const struct dcn30_mpc_shift mpc_shift = { 586 MPC_COMMON_MASK_SH_LIST_DCN32(__SHIFT) 587 }; 588 589 static const struct dcn30_mpc_mask mpc_mask = { 590 MPC_COMMON_MASK_SH_LIST_DCN32(_MASK) 591 }; 592 593 #define optc_regs(id)\ 594 [id] = {OPTC_COMMON_REG_LIST_DCN3_2(id)} 595 596 static const struct dcn_optc_registers optc_regs[] = { 597 optc_regs(0), 598 optc_regs(1), 599 optc_regs(2), 600 optc_regs(3) 601 }; 602 603 static const struct dcn_optc_shift optc_shift = { 604 OPTC_COMMON_MASK_SH_LIST_DCN3_2(__SHIFT) 605 }; 606 607 static const struct dcn_optc_mask optc_mask = { 608 OPTC_COMMON_MASK_SH_LIST_DCN3_2(_MASK) 609 }; 610 611 #define hubp_regs(id)\ 612 [id] = {\ 613 HUBP_REG_LIST_DCN32(id)\ 614 } 615 616 static const struct dcn_hubp2_registers hubp_regs[] = { 617 hubp_regs(0), 618 hubp_regs(1), 619 hubp_regs(2), 620 hubp_regs(3) 621 }; 622 623 624 static const struct dcn_hubp2_shift hubp_shift = { 625 HUBP_MASK_SH_LIST_DCN32(__SHIFT) 626 }; 627 628 static const struct dcn_hubp2_mask hubp_mask = { 629 HUBP_MASK_SH_LIST_DCN32(_MASK) 630 }; 631 static const struct dcn_hubbub_registers hubbub_reg = { 632 HUBBUB_REG_LIST_DCN32(0) 633 }; 634 635 static const struct dcn_hubbub_shift hubbub_shift = { 636 HUBBUB_MASK_SH_LIST_DCN32(__SHIFT) 637 }; 638 639 static const struct dcn_hubbub_mask hubbub_mask = { 640 HUBBUB_MASK_SH_LIST_DCN32(_MASK) 641 }; 642 643 static const struct dccg_registers dccg_regs = { 644 DCCG_REG_LIST_DCN32() 645 }; 646 647 static const struct dccg_shift dccg_shift = { 648 DCCG_MASK_SH_LIST_DCN32(__SHIFT) 649 }; 650 651 static const struct dccg_mask dccg_mask = { 652 DCCG_MASK_SH_LIST_DCN32(_MASK) 653 }; 654 655 656 #define SRII2(reg_name_pre, reg_name_post, id)\ 657 .reg_name_pre ## _ ## reg_name_post[id] = BASE(reg ## reg_name_pre \ 658 ## id ## _ ## reg_name_post ## _BASE_IDX) + \ 659 reg ## reg_name_pre ## id ## _ ## reg_name_post 660 661 662 #define HWSEQ_DCN32_REG_LIST()\ 663 SR(DCHUBBUB_GLOBAL_TIMER_CNTL), \ 664 SR(DIO_MEM_PWR_CTRL), \ 665 SR(ODM_MEM_PWR_CTRL3), \ 666 SR(MMHUBBUB_MEM_PWR_CNTL), \ 667 SR(DCCG_GATE_DISABLE_CNTL), \ 668 SR(DCCG_GATE_DISABLE_CNTL2), \ 669 SR(DCFCLK_CNTL),\ 670 SR(DC_MEM_GLOBAL_PWR_REQ_CNTL), \ 671 SRII(PIXEL_RATE_CNTL, OTG, 0), \ 672 SRII(PIXEL_RATE_CNTL, OTG, 1),\ 673 SRII(PIXEL_RATE_CNTL, OTG, 2),\ 674 SRII(PIXEL_RATE_CNTL, OTG, 3),\ 675 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 0),\ 676 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 1),\ 677 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 2),\ 678 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 3),\ 679 SR(MICROSECOND_TIME_BASE_DIV), \ 680 SR(MILLISECOND_TIME_BASE_DIV), \ 681 SR(DISPCLK_FREQ_CHANGE_CNTL), \ 682 SR(RBBMIF_TIMEOUT_DIS), \ 683 SR(RBBMIF_TIMEOUT_DIS_2), \ 684 SR(DCHUBBUB_CRC_CTRL), \ 685 SR(DPP_TOP0_DPP_CRC_CTRL), \ 686 SR(DPP_TOP0_DPP_CRC_VAL_B_A), \ 687 SR(DPP_TOP0_DPP_CRC_VAL_R_G), \ 688 SR(MPC_CRC_CTRL), \ 689 SR(MPC_CRC_RESULT_GB), \ 690 SR(MPC_CRC_RESULT_C), \ 691 SR(MPC_CRC_RESULT_AR), \ 692 SR(DOMAIN0_PG_CONFIG), \ 693 SR(DOMAIN1_PG_CONFIG), \ 694 SR(DOMAIN2_PG_CONFIG), \ 695 SR(DOMAIN3_PG_CONFIG), \ 696 SR(DOMAIN16_PG_CONFIG), \ 697 SR(DOMAIN17_PG_CONFIG), \ 698 SR(DOMAIN18_PG_CONFIG), \ 699 SR(DOMAIN19_PG_CONFIG), \ 700 SR(DOMAIN0_PG_STATUS), \ 701 SR(DOMAIN1_PG_STATUS), \ 702 SR(DOMAIN2_PG_STATUS), \ 703 SR(DOMAIN3_PG_STATUS), \ 704 SR(DOMAIN16_PG_STATUS), \ 705 SR(DOMAIN17_PG_STATUS), \ 706 SR(DOMAIN18_PG_STATUS), \ 707 SR(DOMAIN19_PG_STATUS), \ 708 SR(D1VGA_CONTROL), \ 709 SR(D2VGA_CONTROL), \ 710 SR(D3VGA_CONTROL), \ 711 SR(D4VGA_CONTROL), \ 712 SR(D5VGA_CONTROL), \ 713 SR(D6VGA_CONTROL), \ 714 SR(DC_IP_REQUEST_CNTL), \ 715 SR(AZALIA_AUDIO_DTO), \ 716 SR(AZALIA_CONTROLLER_CLOCK_GATING) 717 718 static const struct dce_hwseq_registers hwseq_reg = { 719 HWSEQ_DCN32_REG_LIST() 720 }; 721 722 #define HWSEQ_DCN32_MASK_SH_LIST(mask_sh)\ 723 HWSEQ_DCN_MASK_SH_LIST(mask_sh), \ 724 HWS_SF(, DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, mask_sh), \ 725 HWS_SF(, DOMAIN0_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 726 HWS_SF(, DOMAIN0_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 727 HWS_SF(, DOMAIN1_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 728 HWS_SF(, DOMAIN1_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 729 HWS_SF(, DOMAIN2_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 730 HWS_SF(, DOMAIN2_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 731 HWS_SF(, DOMAIN3_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 732 HWS_SF(, DOMAIN3_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 733 HWS_SF(, DOMAIN16_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 734 HWS_SF(, DOMAIN16_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 735 HWS_SF(, DOMAIN17_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 736 HWS_SF(, DOMAIN17_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 737 HWS_SF(, DOMAIN18_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 738 HWS_SF(, DOMAIN18_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 739 HWS_SF(, DOMAIN19_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 740 HWS_SF(, DOMAIN19_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 741 HWS_SF(, DOMAIN0_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 742 HWS_SF(, DOMAIN1_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 743 HWS_SF(, DOMAIN2_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 744 HWS_SF(, DOMAIN3_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 745 HWS_SF(, DOMAIN16_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 746 HWS_SF(, DOMAIN17_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 747 HWS_SF(, DOMAIN18_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 748 HWS_SF(, DOMAIN19_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 749 HWS_SF(, DC_IP_REQUEST_CNTL, IP_REQUEST_EN, mask_sh), \ 750 HWS_SF(, AZALIA_AUDIO_DTO, AZALIA_AUDIO_DTO_MODULE, mask_sh), \ 751 HWS_SF(, HPO_TOP_CLOCK_CONTROL, HPO_HDMISTREAMCLK_G_GATE_DIS, mask_sh), \ 752 HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_UNASSIGNED_PWR_MODE, mask_sh), \ 753 HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_VBLANK_PWR_MODE, mask_sh), \ 754 HWS_SF(, MMHUBBUB_MEM_PWR_CNTL, VGA_MEM_PWR_FORCE, mask_sh) 755 756 static const struct dce_hwseq_shift hwseq_shift = { 757 HWSEQ_DCN32_MASK_SH_LIST(__SHIFT) 758 }; 759 760 static const struct dce_hwseq_mask hwseq_mask = { 761 HWSEQ_DCN32_MASK_SH_LIST(_MASK) 762 }; 763 #define vmid_regs(id)\ 764 [id] = {\ 765 DCN20_VMID_REG_LIST(id)\ 766 } 767 768 static const struct dcn_vmid_registers vmid_regs[] = { 769 vmid_regs(0), 770 vmid_regs(1), 771 vmid_regs(2), 772 vmid_regs(3), 773 vmid_regs(4), 774 vmid_regs(5), 775 vmid_regs(6), 776 vmid_regs(7), 777 vmid_regs(8), 778 vmid_regs(9), 779 vmid_regs(10), 780 vmid_regs(11), 781 vmid_regs(12), 782 vmid_regs(13), 783 vmid_regs(14), 784 vmid_regs(15) 785 }; 786 787 static const struct dcn20_vmid_shift vmid_shifts = { 788 DCN20_VMID_MASK_SH_LIST(__SHIFT) 789 }; 790 791 static const struct dcn20_vmid_mask vmid_masks = { 792 DCN20_VMID_MASK_SH_LIST(_MASK) 793 }; 794 795 static const struct resource_caps res_cap_dcn321 = { 796 .num_timing_generator = 4, 797 .num_opp = 4, 798 .num_video_plane = 4, 799 .num_audio = 5, 800 .num_stream_encoder = 5, 801 .num_hpo_dp_stream_encoder = 4, 802 .num_hpo_dp_link_encoder = 2, 803 .num_pll = 5, 804 .num_dwb = 1, 805 .num_ddc = 5, 806 .num_vmid = 16, 807 .num_mpc_3dlut = 4, 808 .num_dsc = 4, 809 }; 810 811 static const struct dc_plane_cap plane_cap = { 812 .type = DC_PLANE_TYPE_DCN_UNIVERSAL, 813 .blends_with_above = true, 814 .blends_with_below = true, 815 .per_pixel_alpha = true, 816 817 .pixel_format_support = { 818 .argb8888 = true, 819 .nv12 = true, 820 .fp16 = true, 821 .p010 = true, 822 .ayuv = false, 823 }, 824 825 .max_upscale_factor = { 826 .argb8888 = 16000, 827 .nv12 = 16000, 828 .fp16 = 16000 829 }, 830 831 // 6:1 downscaling ratio: 1000/6 = 166.666 832 .max_downscale_factor = { 833 .argb8888 = 167, 834 .nv12 = 167, 835 .fp16 = 167 836 }, 837 64, 838 64 839 }; 840 841 static const struct dc_debug_options debug_defaults_drv = { 842 .disable_dmcu = true, 843 .force_abm_enable = false, 844 .timing_trace = false, 845 .clock_trace = true, 846 .disable_pplib_clock_request = false, 847 .pipe_split_policy = MPC_SPLIT_AVOID, 848 .force_single_disp_pipe_split = false, 849 .disable_dcc = DCC_ENABLE, 850 .vsr_support = true, 851 .performance_trace = false, 852 .max_downscale_src_width = 7680,/*upto 8K*/ 853 .disable_pplib_wm_range = false, 854 .scl_reset_length10 = true, 855 .sanity_checks = false, 856 .underflow_assert_delay_us = 0xFFFFFFFF, 857 .dwb_fi_phase = -1, // -1 = disable, 858 .dmub_command_table = true, 859 .enable_mem_low_power = { 860 .bits = { 861 .vga = false, 862 .i2c = false, 863 .dmcu = false, // This is previously known to cause hang on S3 cycles if enabled 864 .dscl = false, 865 .cm = false, 866 .mpc = false, 867 .optc = true, 868 } 869 }, 870 .use_max_lb = true, 871 .force_disable_subvp = false, 872 .exit_idle_opt_for_cursor_updates = true, 873 .enable_single_display_2to1_odm_policy = true, 874 .enable_dp_dig_pixel_rate_div_policy = 1, 875 .allow_sw_cursor_fallback = false, 876 }; 877 878 static const struct dc_debug_options debug_defaults_diags = { 879 .disable_dmcu = true, 880 .force_abm_enable = false, 881 .timing_trace = true, 882 .clock_trace = true, 883 .disable_dpp_power_gate = true, 884 .disable_hubp_power_gate = true, 885 .disable_dsc_power_gate = true, 886 .disable_clock_gate = true, 887 .disable_pplib_clock_request = true, 888 .disable_pplib_wm_range = true, 889 .disable_stutter = false, 890 .scl_reset_length10 = true, 891 .dwb_fi_phase = -1, // -1 = disable 892 .dmub_command_table = true, 893 .enable_tri_buf = true, 894 .use_max_lb = true, 895 .force_disable_subvp = true 896 }; 897 898 899 static struct dce_aux *dcn321_aux_engine_create( 900 struct dc_context *ctx, 901 uint32_t inst) 902 { 903 struct aux_engine_dce110 *aux_engine = 904 kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL); 905 906 if (!aux_engine) 907 return NULL; 908 909 dce110_aux_engine_construct(aux_engine, ctx, inst, 910 SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD, 911 &aux_engine_regs[inst], 912 &aux_mask, 913 &aux_shift, 914 ctx->dc->caps.extended_aux_timeout_support); 915 916 return &aux_engine->base; 917 } 918 #define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST_DCN30(id) } 919 920 static const struct dce_i2c_registers i2c_hw_regs[] = { 921 i2c_inst_regs(1), 922 i2c_inst_regs(2), 923 i2c_inst_regs(3), 924 i2c_inst_regs(4), 925 i2c_inst_regs(5), 926 }; 927 928 static const struct dce_i2c_shift i2c_shifts = { 929 I2C_COMMON_MASK_SH_LIST_DCN30(__SHIFT) 930 }; 931 932 static const struct dce_i2c_mask i2c_masks = { 933 I2C_COMMON_MASK_SH_LIST_DCN30(_MASK) 934 }; 935 936 static struct dce_i2c_hw *dcn321_i2c_hw_create( 937 struct dc_context *ctx, 938 uint32_t inst) 939 { 940 struct dce_i2c_hw *dce_i2c_hw = 941 kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); 942 943 if (!dce_i2c_hw) 944 return NULL; 945 946 dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst, 947 &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); 948 949 return dce_i2c_hw; 950 } 951 952 static struct clock_source *dcn321_clock_source_create( 953 struct dc_context *ctx, 954 struct dc_bios *bios, 955 enum clock_source_id id, 956 const struct dce110_clk_src_regs *regs, 957 bool dp_clk_src) 958 { 959 struct dce110_clk_src *clk_src = 960 kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL); 961 962 if (!clk_src) 963 return NULL; 964 965 if (dcn31_clk_src_construct(clk_src, ctx, bios, id, 966 regs, &cs_shift, &cs_mask)) { 967 clk_src->base.dp_clk_src = dp_clk_src; 968 return &clk_src->base; 969 } 970 971 BREAK_TO_DEBUGGER(); 972 return NULL; 973 } 974 975 static struct hubbub *dcn321_hubbub_create(struct dc_context *ctx) 976 { 977 int i; 978 979 struct dcn20_hubbub *hubbub2 = kzalloc(sizeof(struct dcn20_hubbub), 980 GFP_KERNEL); 981 982 if (!hubbub2) 983 return NULL; 984 985 hubbub32_construct(hubbub2, ctx, 986 &hubbub_reg, 987 &hubbub_shift, 988 &hubbub_mask, 989 ctx->dc->dml.ip.det_buffer_size_kbytes, 990 ctx->dc->dml.ip.pixel_chunk_size_kbytes, 991 ctx->dc->dml.ip.config_return_buffer_size_in_kbytes); 992 993 994 for (i = 0; i < res_cap_dcn321.num_vmid; i++) { 995 struct dcn20_vmid *vmid = &hubbub2->vmid[i]; 996 997 vmid->ctx = ctx; 998 999 vmid->regs = &vmid_regs[i]; 1000 vmid->shifts = &vmid_shifts; 1001 vmid->masks = &vmid_masks; 1002 } 1003 1004 return &hubbub2->base; 1005 } 1006 1007 static struct hubp *dcn321_hubp_create( 1008 struct dc_context *ctx, 1009 uint32_t inst) 1010 { 1011 struct dcn20_hubp *hubp2 = 1012 kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL); 1013 1014 if (!hubp2) 1015 return NULL; 1016 1017 if (hubp32_construct(hubp2, ctx, inst, 1018 &hubp_regs[inst], &hubp_shift, &hubp_mask)) 1019 return &hubp2->base; 1020 1021 BREAK_TO_DEBUGGER(); 1022 kfree(hubp2); 1023 return NULL; 1024 } 1025 1026 static void dcn321_dpp_destroy(struct dpp **dpp) 1027 { 1028 kfree(TO_DCN30_DPP(*dpp)); 1029 *dpp = NULL; 1030 } 1031 1032 static struct dpp *dcn321_dpp_create( 1033 struct dc_context *ctx, 1034 uint32_t inst) 1035 { 1036 struct dcn3_dpp *dpp3 = 1037 kzalloc(sizeof(struct dcn3_dpp), GFP_KERNEL); 1038 1039 if (!dpp3) 1040 return NULL; 1041 1042 if (dpp32_construct(dpp3, ctx, inst, 1043 &dpp_regs[inst], &tf_shift, &tf_mask)) 1044 return &dpp3->base; 1045 1046 BREAK_TO_DEBUGGER(); 1047 kfree(dpp3); 1048 return NULL; 1049 } 1050 1051 static struct mpc *dcn321_mpc_create( 1052 struct dc_context *ctx, 1053 int num_mpcc, 1054 int num_rmu) 1055 { 1056 struct dcn30_mpc *mpc30 = kzalloc(sizeof(struct dcn30_mpc), 1057 GFP_KERNEL); 1058 1059 if (!mpc30) 1060 return NULL; 1061 1062 dcn32_mpc_construct(mpc30, ctx, 1063 &mpc_regs, 1064 &mpc_shift, 1065 &mpc_mask, 1066 num_mpcc, 1067 num_rmu); 1068 1069 return &mpc30->base; 1070 } 1071 1072 static struct output_pixel_processor *dcn321_opp_create( 1073 struct dc_context *ctx, uint32_t inst) 1074 { 1075 struct dcn20_opp *opp2 = 1076 kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL); 1077 1078 if (!opp2) { 1079 BREAK_TO_DEBUGGER(); 1080 return NULL; 1081 } 1082 1083 dcn20_opp_construct(opp2, ctx, inst, 1084 &opp_regs[inst], &opp_shift, &opp_mask); 1085 return &opp2->base; 1086 } 1087 1088 1089 static struct timing_generator *dcn321_timing_generator_create( 1090 struct dc_context *ctx, 1091 uint32_t instance) 1092 { 1093 struct optc *tgn10 = 1094 kzalloc(sizeof(struct optc), GFP_KERNEL); 1095 1096 if (!tgn10) 1097 return NULL; 1098 1099 tgn10->base.inst = instance; 1100 tgn10->base.ctx = ctx; 1101 1102 tgn10->tg_regs = &optc_regs[instance]; 1103 tgn10->tg_shift = &optc_shift; 1104 tgn10->tg_mask = &optc_mask; 1105 1106 dcn32_timing_generator_init(tgn10); 1107 1108 return &tgn10->base; 1109 } 1110 1111 static const struct encoder_feature_support link_enc_feature = { 1112 .max_hdmi_deep_color = COLOR_DEPTH_121212, 1113 .max_hdmi_pixel_clock = 600000, 1114 .hdmi_ycbcr420_supported = true, 1115 .dp_ycbcr420_supported = true, 1116 .fec_supported = true, 1117 .flags.bits.IS_HBR2_CAPABLE = true, 1118 .flags.bits.IS_HBR3_CAPABLE = true, 1119 .flags.bits.IS_TPS3_CAPABLE = true, 1120 .flags.bits.IS_TPS4_CAPABLE = true 1121 }; 1122 1123 static struct link_encoder *dcn321_link_encoder_create( 1124 struct dc_context *ctx, 1125 const struct encoder_init_data *enc_init_data) 1126 { 1127 struct dcn20_link_encoder *enc20 = 1128 kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); 1129 1130 if (!enc20) 1131 return NULL; 1132 1133 dcn321_link_encoder_construct(enc20, 1134 enc_init_data, 1135 &link_enc_feature, 1136 &link_enc_regs[enc_init_data->transmitter], 1137 &link_enc_aux_regs[enc_init_data->channel - 1], 1138 &link_enc_hpd_regs[enc_init_data->hpd_source], 1139 &le_shift, 1140 &le_mask); 1141 1142 return &enc20->enc10.base; 1143 } 1144 1145 static void read_dce_straps( 1146 struct dc_context *ctx, 1147 struct resource_straps *straps) 1148 { 1149 generic_reg_get(ctx, regDC_PINSTRAPS + BASE(regDC_PINSTRAPS_BASE_IDX), 1150 FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio); 1151 1152 } 1153 1154 static struct audio *dcn321_create_audio( 1155 struct dc_context *ctx, unsigned int inst) 1156 { 1157 return dce_audio_create(ctx, inst, 1158 &audio_regs[inst], &audio_shift, &audio_mask); 1159 } 1160 1161 static struct vpg *dcn321_vpg_create( 1162 struct dc_context *ctx, 1163 uint32_t inst) 1164 { 1165 struct dcn30_vpg *vpg3 = kzalloc(sizeof(struct dcn30_vpg), GFP_KERNEL); 1166 1167 if (!vpg3) 1168 return NULL; 1169 1170 vpg3_construct(vpg3, ctx, inst, 1171 &vpg_regs[inst], 1172 &vpg_shift, 1173 &vpg_mask); 1174 1175 return &vpg3->base; 1176 } 1177 1178 static struct afmt *dcn321_afmt_create( 1179 struct dc_context *ctx, 1180 uint32_t inst) 1181 { 1182 struct dcn30_afmt *afmt3 = kzalloc(sizeof(struct dcn30_afmt), GFP_KERNEL); 1183 1184 if (!afmt3) 1185 return NULL; 1186 1187 afmt3_construct(afmt3, ctx, inst, 1188 &afmt_regs[inst], 1189 &afmt_shift, 1190 &afmt_mask); 1191 1192 return &afmt3->base; 1193 } 1194 1195 static struct apg *dcn321_apg_create( 1196 struct dc_context *ctx, 1197 uint32_t inst) 1198 { 1199 struct dcn31_apg *apg31 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL); 1200 1201 if (!apg31) 1202 return NULL; 1203 1204 apg31_construct(apg31, ctx, inst, 1205 &apg_regs[inst], 1206 &apg_shift, 1207 &apg_mask); 1208 1209 return &apg31->base; 1210 } 1211 1212 static struct stream_encoder *dcn321_stream_encoder_create( 1213 enum engine_id eng_id, 1214 struct dc_context *ctx) 1215 { 1216 struct dcn10_stream_encoder *enc1; 1217 struct vpg *vpg; 1218 struct afmt *afmt; 1219 int vpg_inst; 1220 int afmt_inst; 1221 1222 /* Mapping of VPG, AFMT, DME register blocks to DIO block instance */ 1223 if (eng_id <= ENGINE_ID_DIGF) { 1224 vpg_inst = eng_id; 1225 afmt_inst = eng_id; 1226 } else 1227 return NULL; 1228 1229 enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL); 1230 vpg = dcn321_vpg_create(ctx, vpg_inst); 1231 afmt = dcn321_afmt_create(ctx, afmt_inst); 1232 1233 if (!enc1 || !vpg || !afmt) { 1234 kfree(enc1); 1235 kfree(vpg); 1236 kfree(afmt); 1237 return NULL; 1238 } 1239 1240 dcn32_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios, 1241 eng_id, vpg, afmt, 1242 &stream_enc_regs[eng_id], 1243 &se_shift, &se_mask); 1244 1245 return &enc1->base; 1246 } 1247 1248 static struct hpo_dp_stream_encoder *dcn321_hpo_dp_stream_encoder_create( 1249 enum engine_id eng_id, 1250 struct dc_context *ctx) 1251 { 1252 struct dcn31_hpo_dp_stream_encoder *hpo_dp_enc31; 1253 struct vpg *vpg; 1254 struct apg *apg; 1255 uint32_t hpo_dp_inst; 1256 uint32_t vpg_inst; 1257 uint32_t apg_inst; 1258 1259 ASSERT((eng_id >= ENGINE_ID_HPO_DP_0) && (eng_id <= ENGINE_ID_HPO_DP_3)); 1260 hpo_dp_inst = eng_id - ENGINE_ID_HPO_DP_0; 1261 1262 /* Mapping of VPG register blocks to HPO DP block instance: 1263 * VPG[6] -> HPO_DP[0] 1264 * VPG[7] -> HPO_DP[1] 1265 * VPG[8] -> HPO_DP[2] 1266 * VPG[9] -> HPO_DP[3] 1267 */ 1268 vpg_inst = hpo_dp_inst + 6; 1269 1270 /* Mapping of APG register blocks to HPO DP block instance: 1271 * APG[0] -> HPO_DP[0] 1272 * APG[1] -> HPO_DP[1] 1273 * APG[2] -> HPO_DP[2] 1274 * APG[3] -> HPO_DP[3] 1275 */ 1276 apg_inst = hpo_dp_inst; 1277 1278 /* allocate HPO stream encoder and create VPG sub-block */ 1279 hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL); 1280 vpg = dcn321_vpg_create(ctx, vpg_inst); 1281 apg = dcn321_apg_create(ctx, apg_inst); 1282 1283 if (!hpo_dp_enc31 || !vpg || !apg) { 1284 kfree(hpo_dp_enc31); 1285 kfree(vpg); 1286 kfree(apg); 1287 return NULL; 1288 } 1289 1290 dcn31_hpo_dp_stream_encoder_construct(hpo_dp_enc31, ctx, ctx->dc_bios, 1291 hpo_dp_inst, eng_id, vpg, apg, 1292 &hpo_dp_stream_enc_regs[hpo_dp_inst], 1293 &hpo_dp_se_shift, &hpo_dp_se_mask); 1294 1295 return &hpo_dp_enc31->base; 1296 } 1297 1298 static struct hpo_dp_link_encoder *dcn321_hpo_dp_link_encoder_create( 1299 uint8_t inst, 1300 struct dc_context *ctx) 1301 { 1302 struct dcn31_hpo_dp_link_encoder *hpo_dp_enc31; 1303 1304 /* allocate HPO link encoder */ 1305 hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL); 1306 1307 hpo_dp_link_encoder32_construct(hpo_dp_enc31, ctx, inst, 1308 &hpo_dp_link_enc_regs[inst], 1309 &hpo_dp_le_shift, &hpo_dp_le_mask); 1310 1311 return &hpo_dp_enc31->base; 1312 } 1313 1314 static struct dce_hwseq *dcn321_hwseq_create( 1315 struct dc_context *ctx) 1316 { 1317 struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL); 1318 1319 if (hws) { 1320 hws->ctx = ctx; 1321 hws->regs = &hwseq_reg; 1322 hws->shifts = &hwseq_shift; 1323 hws->masks = &hwseq_mask; 1324 } 1325 return hws; 1326 } 1327 static const struct resource_create_funcs res_create_funcs = { 1328 .read_dce_straps = read_dce_straps, 1329 .create_audio = dcn321_create_audio, 1330 .create_stream_encoder = dcn321_stream_encoder_create, 1331 .create_hpo_dp_stream_encoder = dcn321_hpo_dp_stream_encoder_create, 1332 .create_hpo_dp_link_encoder = dcn321_hpo_dp_link_encoder_create, 1333 .create_hwseq = dcn321_hwseq_create, 1334 }; 1335 1336 static const struct resource_create_funcs res_create_maximus_funcs = { 1337 .read_dce_straps = NULL, 1338 .create_audio = NULL, 1339 .create_stream_encoder = NULL, 1340 .create_hpo_dp_stream_encoder = dcn321_hpo_dp_stream_encoder_create, 1341 .create_hpo_dp_link_encoder = dcn321_hpo_dp_link_encoder_create, 1342 .create_hwseq = dcn321_hwseq_create, 1343 }; 1344 1345 static void dcn321_resource_destruct(struct dcn321_resource_pool *pool) 1346 { 1347 unsigned int i; 1348 1349 for (i = 0; i < pool->base.stream_enc_count; i++) { 1350 if (pool->base.stream_enc[i] != NULL) { 1351 if (pool->base.stream_enc[i]->vpg != NULL) { 1352 kfree(DCN30_VPG_FROM_VPG(pool->base.stream_enc[i]->vpg)); 1353 pool->base.stream_enc[i]->vpg = NULL; 1354 } 1355 if (pool->base.stream_enc[i]->afmt != NULL) { 1356 kfree(DCN30_AFMT_FROM_AFMT(pool->base.stream_enc[i]->afmt)); 1357 pool->base.stream_enc[i]->afmt = NULL; 1358 } 1359 kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i])); 1360 pool->base.stream_enc[i] = NULL; 1361 } 1362 } 1363 1364 for (i = 0; i < pool->base.hpo_dp_stream_enc_count; i++) { 1365 if (pool->base.hpo_dp_stream_enc[i] != NULL) { 1366 if (pool->base.hpo_dp_stream_enc[i]->vpg != NULL) { 1367 kfree(DCN30_VPG_FROM_VPG(pool->base.hpo_dp_stream_enc[i]->vpg)); 1368 pool->base.hpo_dp_stream_enc[i]->vpg = NULL; 1369 } 1370 if (pool->base.hpo_dp_stream_enc[i]->apg != NULL) { 1371 kfree(DCN31_APG_FROM_APG(pool->base.hpo_dp_stream_enc[i]->apg)); 1372 pool->base.hpo_dp_stream_enc[i]->apg = NULL; 1373 } 1374 kfree(DCN3_1_HPO_DP_STREAM_ENC_FROM_HPO_STREAM_ENC(pool->base.hpo_dp_stream_enc[i])); 1375 pool->base.hpo_dp_stream_enc[i] = NULL; 1376 } 1377 } 1378 1379 for (i = 0; i < pool->base.hpo_dp_link_enc_count; i++) { 1380 if (pool->base.hpo_dp_link_enc[i] != NULL) { 1381 kfree(DCN3_1_HPO_DP_LINK_ENC_FROM_HPO_LINK_ENC(pool->base.hpo_dp_link_enc[i])); 1382 pool->base.hpo_dp_link_enc[i] = NULL; 1383 } 1384 } 1385 1386 for (i = 0; i < pool->base.res_cap->num_dsc; i++) { 1387 if (pool->base.dscs[i] != NULL) 1388 dcn20_dsc_destroy(&pool->base.dscs[i]); 1389 } 1390 1391 if (pool->base.mpc != NULL) { 1392 kfree(TO_DCN20_MPC(pool->base.mpc)); 1393 pool->base.mpc = NULL; 1394 } 1395 if (pool->base.hubbub != NULL) { 1396 kfree(TO_DCN20_HUBBUB(pool->base.hubbub)); 1397 pool->base.hubbub = NULL; 1398 } 1399 for (i = 0; i < pool->base.pipe_count; i++) { 1400 if (pool->base.dpps[i] != NULL) 1401 dcn321_dpp_destroy(&pool->base.dpps[i]); 1402 1403 if (pool->base.ipps[i] != NULL) 1404 pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]); 1405 1406 if (pool->base.hubps[i] != NULL) { 1407 kfree(TO_DCN20_HUBP(pool->base.hubps[i])); 1408 pool->base.hubps[i] = NULL; 1409 } 1410 1411 if (pool->base.irqs != NULL) 1412 dal_irq_service_destroy(&pool->base.irqs); 1413 } 1414 1415 for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 1416 if (pool->base.engines[i] != NULL) 1417 dce110_engine_destroy(&pool->base.engines[i]); 1418 if (pool->base.hw_i2cs[i] != NULL) { 1419 kfree(pool->base.hw_i2cs[i]); 1420 pool->base.hw_i2cs[i] = NULL; 1421 } 1422 if (pool->base.sw_i2cs[i] != NULL) { 1423 kfree(pool->base.sw_i2cs[i]); 1424 pool->base.sw_i2cs[i] = NULL; 1425 } 1426 } 1427 1428 for (i = 0; i < pool->base.res_cap->num_opp; i++) { 1429 if (pool->base.opps[i] != NULL) 1430 pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]); 1431 } 1432 1433 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) { 1434 if (pool->base.timing_generators[i] != NULL) { 1435 kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i])); 1436 pool->base.timing_generators[i] = NULL; 1437 } 1438 } 1439 1440 for (i = 0; i < pool->base.res_cap->num_dwb; i++) { 1441 if (pool->base.dwbc[i] != NULL) { 1442 kfree(TO_DCN30_DWBC(pool->base.dwbc[i])); 1443 pool->base.dwbc[i] = NULL; 1444 } 1445 if (pool->base.mcif_wb[i] != NULL) { 1446 kfree(TO_DCN30_MMHUBBUB(pool->base.mcif_wb[i])); 1447 pool->base.mcif_wb[i] = NULL; 1448 } 1449 } 1450 1451 for (i = 0; i < pool->base.audio_count; i++) { 1452 if (pool->base.audios[i]) 1453 dce_aud_destroy(&pool->base.audios[i]); 1454 } 1455 1456 for (i = 0; i < pool->base.clk_src_count; i++) { 1457 if (pool->base.clock_sources[i] != NULL) { 1458 dcn20_clock_source_destroy(&pool->base.clock_sources[i]); 1459 pool->base.clock_sources[i] = NULL; 1460 } 1461 } 1462 1463 for (i = 0; i < pool->base.res_cap->num_mpc_3dlut; i++) { 1464 if (pool->base.mpc_lut[i] != NULL) { 1465 dc_3dlut_func_release(pool->base.mpc_lut[i]); 1466 pool->base.mpc_lut[i] = NULL; 1467 } 1468 if (pool->base.mpc_shaper[i] != NULL) { 1469 dc_transfer_func_release(pool->base.mpc_shaper[i]); 1470 pool->base.mpc_shaper[i] = NULL; 1471 } 1472 } 1473 1474 if (pool->base.dp_clock_source != NULL) { 1475 dcn20_clock_source_destroy(&pool->base.dp_clock_source); 1476 pool->base.dp_clock_source = NULL; 1477 } 1478 1479 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) { 1480 if (pool->base.multiple_abms[i] != NULL) 1481 dce_abm_destroy(&pool->base.multiple_abms[i]); 1482 } 1483 1484 if (pool->base.psr != NULL) 1485 dmub_psr_destroy(&pool->base.psr); 1486 1487 if (pool->base.dccg != NULL) 1488 dcn_dccg_destroy(&pool->base.dccg); 1489 1490 if (pool->base.oem_device != NULL) 1491 dal_ddc_service_destroy(&pool->base.oem_device); 1492 } 1493 1494 1495 static bool dcn321_dwbc_create(struct dc_context *ctx, struct resource_pool *pool) 1496 { 1497 int i; 1498 uint32_t dwb_count = pool->res_cap->num_dwb; 1499 1500 for (i = 0; i < dwb_count; i++) { 1501 struct dcn30_dwbc *dwbc30 = kzalloc(sizeof(struct dcn30_dwbc), 1502 GFP_KERNEL); 1503 1504 if (!dwbc30) { 1505 dm_error("DC: failed to create dwbc30!\n"); 1506 return false; 1507 } 1508 1509 dcn30_dwbc_construct(dwbc30, ctx, 1510 &dwbc30_regs[i], 1511 &dwbc30_shift, 1512 &dwbc30_mask, 1513 i); 1514 1515 pool->dwbc[i] = &dwbc30->base; 1516 } 1517 return true; 1518 } 1519 1520 static bool dcn321_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool) 1521 { 1522 int i; 1523 uint32_t dwb_count = pool->res_cap->num_dwb; 1524 1525 for (i = 0; i < dwb_count; i++) { 1526 struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub), 1527 GFP_KERNEL); 1528 1529 if (!mcif_wb30) { 1530 dm_error("DC: failed to create mcif_wb30!\n"); 1531 return false; 1532 } 1533 1534 dcn32_mmhubbub_construct(mcif_wb30, ctx, 1535 &mcif_wb30_regs[i], 1536 &mcif_wb30_shift, 1537 &mcif_wb30_mask, 1538 i); 1539 1540 pool->mcif_wb[i] = &mcif_wb30->base; 1541 } 1542 return true; 1543 } 1544 1545 static struct display_stream_compressor *dcn321_dsc_create( 1546 struct dc_context *ctx, uint32_t inst) 1547 { 1548 struct dcn20_dsc *dsc = 1549 kzalloc(sizeof(struct dcn20_dsc), GFP_KERNEL); 1550 1551 if (!dsc) { 1552 BREAK_TO_DEBUGGER(); 1553 return NULL; 1554 } 1555 1556 dsc2_construct(dsc, ctx, inst, &dsc_regs[inst], &dsc_shift, &dsc_mask); 1557 1558 dsc->max_image_width = 6016; 1559 1560 return &dsc->base; 1561 } 1562 1563 static void dcn321_destroy_resource_pool(struct resource_pool **pool) 1564 { 1565 struct dcn321_resource_pool *dcn321_pool = TO_DCN321_RES_POOL(*pool); 1566 1567 dcn321_resource_destruct(dcn321_pool); 1568 kfree(dcn321_pool); 1569 *pool = NULL; 1570 } 1571 1572 static struct dc_cap_funcs cap_funcs = { 1573 .get_dcc_compression_cap = dcn20_get_dcc_compression_cap 1574 }; 1575 1576 static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params) 1577 { 1578 DC_FP_START(); 1579 dcn321_update_bw_bounding_box_fpu(dc, bw_params); 1580 DC_FP_END(); 1581 } 1582 1583 static struct resource_funcs dcn321_res_pool_funcs = { 1584 .destroy = dcn321_destroy_resource_pool, 1585 .link_enc_create = dcn321_link_encoder_create, 1586 .link_enc_create_minimal = NULL, 1587 .panel_cntl_create = dcn32_panel_cntl_create, 1588 .validate_bandwidth = dcn32_validate_bandwidth, 1589 .calculate_wm_and_dlg = dcn32_calculate_wm_and_dlg, 1590 .populate_dml_pipes = dcn32_populate_dml_pipes_from_context, 1591 .acquire_idle_pipe_for_layer = dcn20_acquire_idle_pipe_for_layer, 1592 .add_stream_to_ctx = dcn30_add_stream_to_ctx, 1593 .add_dsc_to_stream_resource = dcn20_add_dsc_to_stream_resource, 1594 .remove_stream_from_ctx = dcn20_remove_stream_from_ctx, 1595 .populate_dml_writeback_from_context = dcn30_populate_dml_writeback_from_context, 1596 .set_mcif_arb_params = dcn30_set_mcif_arb_params, 1597 .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link, 1598 .acquire_post_bldn_3dlut = dcn32_acquire_post_bldn_3dlut, 1599 .release_post_bldn_3dlut = dcn32_release_post_bldn_3dlut, 1600 .update_bw_bounding_box = dcn321_update_bw_bounding_box, 1601 .patch_unknown_plane_state = dcn20_patch_unknown_plane_state, 1602 .update_soc_for_wm_a = dcn30_update_soc_for_wm_a, 1603 .add_phantom_pipes = dcn32_add_phantom_pipes, 1604 .remove_phantom_pipes = dcn32_remove_phantom_pipes, 1605 }; 1606 1607 1608 static bool dcn321_resource_construct( 1609 uint8_t num_virtual_links, 1610 struct dc *dc, 1611 struct dcn321_resource_pool *pool) 1612 { 1613 int i, j; 1614 struct dc_context *ctx = dc->ctx; 1615 struct irq_service_init_data init_data; 1616 struct ddc_service_init_data ddc_init_data = {0}; 1617 uint32_t pipe_fuses = 0; 1618 uint32_t num_pipes = 4; 1619 1620 ctx->dc_bios->regs = &bios_regs; 1621 1622 pool->base.res_cap = &res_cap_dcn321; 1623 /* max number of pipes for ASIC before checking for pipe fuses */ 1624 num_pipes = pool->base.res_cap->num_timing_generator; 1625 pipe_fuses = REG_READ(CC_DC_PIPE_DIS); 1626 1627 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) 1628 if (pipe_fuses & 1 << i) 1629 num_pipes--; 1630 1631 if (pipe_fuses & 1) 1632 ASSERT(0); //Unexpected - Pipe 0 should always be fully functional! 1633 1634 if (pipe_fuses & CC_DC_PIPE_DIS__DC_FULL_DIS_MASK) 1635 ASSERT(0); //Entire DCN is harvested! 1636 1637 /* within dml lib, initial value is hard coded, if ASIC pipe is fused, the 1638 * value will be changed, update max_num_dpp and max_num_otg for dml. 1639 */ 1640 dcn3_21_ip.max_num_dpp = num_pipes; 1641 dcn3_21_ip.max_num_otg = num_pipes; 1642 1643 pool->base.funcs = &dcn321_res_pool_funcs; 1644 1645 /************************************************* 1646 * Resource + asic cap harcoding * 1647 *************************************************/ 1648 pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE; 1649 pool->base.timing_generator_count = num_pipes; 1650 pool->base.pipe_count = num_pipes; 1651 pool->base.mpcc_count = num_pipes; 1652 dc->caps.max_downscale_ratio = 600; 1653 dc->caps.i2c_speed_in_khz = 100; 1654 dc->caps.i2c_speed_in_khz_hdcp = 100; /*1.4 w/a applied by default*/ 1655 /* TODO: Bring max cursor size back to 256 after subvp cursor corruption is fixed*/ 1656 dc->caps.max_cursor_size = 64; 1657 dc->caps.min_horizontal_blanking_period = 80; 1658 dc->caps.dmdata_alloc_size = 2048; 1659 dc->caps.mall_size_per_mem_channel = 0; 1660 dc->caps.mall_size_total = 0; 1661 dc->caps.cursor_cache_size = dc->caps.max_cursor_size * dc->caps.max_cursor_size * 8; 1662 dc->caps.cache_line_size = 64; 1663 dc->caps.cache_num_ways = 16; 1664 dc->caps.max_cab_allocation_bytes = 33554432; // 32MB = 1024 * 1024 * 32 1665 dc->caps.subvp_fw_processing_delay_us = 15; 1666 dc->caps.subvp_prefetch_end_to_mall_start_us = 15; 1667 dc->caps.subvp_swath_height_margin_lines = 16; 1668 dc->caps.subvp_pstate_allow_width_us = 20; 1669 dc->caps.subvp_vertical_int_margin_us = 30; 1670 dc->caps.max_slave_planes = 1; 1671 dc->caps.max_slave_yuv_planes = 1; 1672 dc->caps.max_slave_rgb_planes = 1; 1673 dc->caps.post_blend_color_processing = true; 1674 dc->caps.force_dp_tps4_for_cp2520 = true; 1675 dc->caps.dp_hpo = true; 1676 dc->caps.dp_hdmi21_pcon_support = true; 1677 dc->caps.edp_dsc_support = true; 1678 dc->caps.extended_aux_timeout_support = true; 1679 dc->caps.dmcub_support = true; 1680 1681 /* Color pipeline capabilities */ 1682 dc->caps.color.dpp.dcn_arch = 1; 1683 dc->caps.color.dpp.input_lut_shared = 0; 1684 dc->caps.color.dpp.icsc = 1; 1685 dc->caps.color.dpp.dgam_ram = 0; // must use gamma_corr 1686 dc->caps.color.dpp.dgam_rom_caps.srgb = 1; 1687 dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1; 1688 dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 1; 1689 dc->caps.color.dpp.dgam_rom_caps.pq = 1; 1690 dc->caps.color.dpp.dgam_rom_caps.hlg = 1; 1691 dc->caps.color.dpp.post_csc = 1; 1692 dc->caps.color.dpp.gamma_corr = 1; 1693 dc->caps.color.dpp.dgam_rom_for_yuv = 0; 1694 1695 dc->caps.color.dpp.hw_3d_lut = 1; 1696 dc->caps.color.dpp.ogam_ram = 1; 1697 // no OGAM ROM on DCN2 and later ASICs 1698 dc->caps.color.dpp.ogam_rom_caps.srgb = 0; 1699 dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0; 1700 dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0; 1701 dc->caps.color.dpp.ogam_rom_caps.pq = 0; 1702 dc->caps.color.dpp.ogam_rom_caps.hlg = 0; 1703 dc->caps.color.dpp.ocsc = 0; 1704 1705 dc->caps.color.mpc.gamut_remap = 1; 1706 dc->caps.color.mpc.num_3dluts = pool->base.res_cap->num_mpc_3dlut; //4, configurable to be before or after BLND in MPCC 1707 dc->caps.color.mpc.ogam_ram = 1; 1708 dc->caps.color.mpc.ogam_rom_caps.srgb = 0; 1709 dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0; 1710 dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0; 1711 dc->caps.color.mpc.ogam_rom_caps.pq = 0; 1712 dc->caps.color.mpc.ogam_rom_caps.hlg = 0; 1713 dc->caps.color.mpc.ocsc = 1; 1714 1715 /* read VBIOS LTTPR caps */ 1716 { 1717 if (ctx->dc_bios->funcs->get_lttpr_caps) { 1718 enum bp_result bp_query_result; 1719 uint8_t is_vbios_lttpr_enable = 0; 1720 1721 bp_query_result = ctx->dc_bios->funcs->get_lttpr_caps(ctx->dc_bios, &is_vbios_lttpr_enable); 1722 dc->caps.vbios_lttpr_enable = (bp_query_result == BP_RESULT_OK) && !!is_vbios_lttpr_enable; 1723 } 1724 1725 /* interop bit is implicit */ 1726 { 1727 dc->caps.vbios_lttpr_aware = true; 1728 } 1729 } 1730 1731 if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV) 1732 dc->debug = debug_defaults_drv; 1733 else if (dc->ctx->dce_environment == DCE_ENV_FPGA_MAXIMUS) { 1734 dc->debug = debug_defaults_diags; 1735 } else 1736 dc->debug = debug_defaults_diags; 1737 // Init the vm_helper 1738 if (dc->vm_helper) 1739 vm_helper_init(dc->vm_helper, 16); 1740 1741 /************************************************* 1742 * Create resources * 1743 *************************************************/ 1744 1745 /* Clock Sources for Pixel Clock*/ 1746 pool->base.clock_sources[DCN321_CLK_SRC_PLL0] = 1747 dcn321_clock_source_create(ctx, ctx->dc_bios, 1748 CLOCK_SOURCE_COMBO_PHY_PLL0, 1749 &clk_src_regs[0], false); 1750 pool->base.clock_sources[DCN321_CLK_SRC_PLL1] = 1751 dcn321_clock_source_create(ctx, ctx->dc_bios, 1752 CLOCK_SOURCE_COMBO_PHY_PLL1, 1753 &clk_src_regs[1], false); 1754 pool->base.clock_sources[DCN321_CLK_SRC_PLL2] = 1755 dcn321_clock_source_create(ctx, ctx->dc_bios, 1756 CLOCK_SOURCE_COMBO_PHY_PLL2, 1757 &clk_src_regs[2], false); 1758 pool->base.clock_sources[DCN321_CLK_SRC_PLL3] = 1759 dcn321_clock_source_create(ctx, ctx->dc_bios, 1760 CLOCK_SOURCE_COMBO_PHY_PLL3, 1761 &clk_src_regs[3], false); 1762 pool->base.clock_sources[DCN321_CLK_SRC_PLL4] = 1763 dcn321_clock_source_create(ctx, ctx->dc_bios, 1764 CLOCK_SOURCE_COMBO_PHY_PLL4, 1765 &clk_src_regs[4], false); 1766 1767 pool->base.clk_src_count = DCN321_CLK_SRC_TOTAL; 1768 1769 /* todo: not reuse phy_pll registers */ 1770 pool->base.dp_clock_source = 1771 dcn321_clock_source_create(ctx, ctx->dc_bios, 1772 CLOCK_SOURCE_ID_DP_DTO, 1773 &clk_src_regs[0], true); 1774 1775 for (i = 0; i < pool->base.clk_src_count; i++) { 1776 if (pool->base.clock_sources[i] == NULL) { 1777 dm_error("DC: failed to create clock sources!\n"); 1778 BREAK_TO_DEBUGGER(); 1779 goto create_fail; 1780 } 1781 } 1782 1783 /* DCCG */ 1784 pool->base.dccg = dccg32_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask); 1785 if (pool->base.dccg == NULL) { 1786 dm_error("DC: failed to create dccg!\n"); 1787 BREAK_TO_DEBUGGER(); 1788 goto create_fail; 1789 } 1790 1791 /* DML */ 1792 if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) 1793 dml_init_instance(&dc->dml, &dcn3_21_soc, &dcn3_21_ip, DML_PROJECT_DCN32); 1794 1795 /* IRQ Service */ 1796 init_data.ctx = dc->ctx; 1797 pool->base.irqs = dal_irq_service_dcn32_create(&init_data); 1798 if (!pool->base.irqs) 1799 goto create_fail; 1800 1801 /* HUBBUB */ 1802 pool->base.hubbub = dcn321_hubbub_create(ctx); 1803 if (pool->base.hubbub == NULL) { 1804 BREAK_TO_DEBUGGER(); 1805 dm_error("DC: failed to create hubbub!\n"); 1806 goto create_fail; 1807 } 1808 1809 /* HUBPs, DPPs, OPPs, TGs, ABMs */ 1810 for (i = 0, j = 0; i < pool->base.res_cap->num_timing_generator; i++) { 1811 1812 /* if pipe is disabled, skip instance of HW pipe, 1813 * i.e, skip ASIC register instance 1814 */ 1815 if (pipe_fuses & 1 << i) 1816 continue; 1817 1818 pool->base.hubps[j] = dcn321_hubp_create(ctx, i); 1819 if (pool->base.hubps[j] == NULL) { 1820 BREAK_TO_DEBUGGER(); 1821 dm_error( 1822 "DC: failed to create hubps!\n"); 1823 goto create_fail; 1824 } 1825 1826 pool->base.dpps[j] = dcn321_dpp_create(ctx, i); 1827 if (pool->base.dpps[j] == NULL) { 1828 BREAK_TO_DEBUGGER(); 1829 dm_error( 1830 "DC: failed to create dpps!\n"); 1831 goto create_fail; 1832 } 1833 1834 pool->base.opps[j] = dcn321_opp_create(ctx, i); 1835 if (pool->base.opps[j] == NULL) { 1836 BREAK_TO_DEBUGGER(); 1837 dm_error( 1838 "DC: failed to create output pixel processor!\n"); 1839 goto create_fail; 1840 } 1841 1842 pool->base.timing_generators[j] = dcn321_timing_generator_create( 1843 ctx, i); 1844 if (pool->base.timing_generators[j] == NULL) { 1845 BREAK_TO_DEBUGGER(); 1846 dm_error("DC: failed to create tg!\n"); 1847 goto create_fail; 1848 } 1849 1850 pool->base.multiple_abms[j] = dmub_abm_create(ctx, 1851 &abm_regs[i], 1852 &abm_shift, 1853 &abm_mask); 1854 if (pool->base.multiple_abms[j] == NULL) { 1855 dm_error("DC: failed to create abm for pipe %d!\n", i); 1856 BREAK_TO_DEBUGGER(); 1857 goto create_fail; 1858 } 1859 1860 /* index for resource pool arrays for next valid pipe */ 1861 j++; 1862 } 1863 1864 /* PSR */ 1865 pool->base.psr = dmub_psr_create(ctx); 1866 if (pool->base.psr == NULL) { 1867 dm_error("DC: failed to create psr obj!\n"); 1868 BREAK_TO_DEBUGGER(); 1869 goto create_fail; 1870 } 1871 1872 /* MPCCs */ 1873 pool->base.mpc = dcn321_mpc_create(ctx, pool->base.res_cap->num_timing_generator, pool->base.res_cap->num_mpc_3dlut); 1874 if (pool->base.mpc == NULL) { 1875 BREAK_TO_DEBUGGER(); 1876 dm_error("DC: failed to create mpc!\n"); 1877 goto create_fail; 1878 } 1879 1880 /* DSCs */ 1881 for (i = 0; i < pool->base.res_cap->num_dsc; i++) { 1882 pool->base.dscs[i] = dcn321_dsc_create(ctx, i); 1883 if (pool->base.dscs[i] == NULL) { 1884 BREAK_TO_DEBUGGER(); 1885 dm_error("DC: failed to create display stream compressor %d!\n", i); 1886 goto create_fail; 1887 } 1888 } 1889 1890 /* DWB */ 1891 if (!dcn321_dwbc_create(ctx, &pool->base)) { 1892 BREAK_TO_DEBUGGER(); 1893 dm_error("DC: failed to create dwbc!\n"); 1894 goto create_fail; 1895 } 1896 1897 /* MMHUBBUB */ 1898 if (!dcn321_mmhubbub_create(ctx, &pool->base)) { 1899 BREAK_TO_DEBUGGER(); 1900 dm_error("DC: failed to create mcif_wb!\n"); 1901 goto create_fail; 1902 } 1903 1904 /* AUX and I2C */ 1905 for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 1906 pool->base.engines[i] = dcn321_aux_engine_create(ctx, i); 1907 if (pool->base.engines[i] == NULL) { 1908 BREAK_TO_DEBUGGER(); 1909 dm_error( 1910 "DC:failed to create aux engine!!\n"); 1911 goto create_fail; 1912 } 1913 pool->base.hw_i2cs[i] = dcn321_i2c_hw_create(ctx, i); 1914 if (pool->base.hw_i2cs[i] == NULL) { 1915 BREAK_TO_DEBUGGER(); 1916 dm_error( 1917 "DC:failed to create hw i2c!!\n"); 1918 goto create_fail; 1919 } 1920 pool->base.sw_i2cs[i] = NULL; 1921 } 1922 1923 /* Audio, HWSeq, Stream Encoders including HPO and virtual, MPC 3D LUTs */ 1924 if (!resource_construct(num_virtual_links, dc, &pool->base, 1925 (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ? 1926 &res_create_funcs : &res_create_maximus_funcs))) 1927 goto create_fail; 1928 1929 /* HW Sequencer init functions and Plane caps */ 1930 dcn32_hw_sequencer_init_functions(dc); 1931 1932 dc->caps.max_planes = pool->base.pipe_count; 1933 1934 for (i = 0; i < dc->caps.max_planes; ++i) 1935 dc->caps.planes[i] = plane_cap; 1936 1937 dc->cap_funcs = cap_funcs; 1938 1939 if (dc->ctx->dc_bios->fw_info.oem_i2c_present) { 1940 ddc_init_data.ctx = dc->ctx; 1941 ddc_init_data.link = NULL; 1942 ddc_init_data.id.id = dc->ctx->dc_bios->fw_info.oem_i2c_obj_id; 1943 ddc_init_data.id.enum_id = 0; 1944 ddc_init_data.id.type = OBJECT_TYPE_GENERIC; 1945 pool->base.oem_device = dal_ddc_service_create(&ddc_init_data); 1946 } else { 1947 pool->base.oem_device = NULL; 1948 } 1949 1950 return true; 1951 1952 create_fail: 1953 1954 dcn321_resource_destruct(pool); 1955 1956 return false; 1957 } 1958 1959 struct resource_pool *dcn321_create_resource_pool( 1960 const struct dc_init_data *init_data, 1961 struct dc *dc) 1962 { 1963 struct dcn321_resource_pool *pool = 1964 kzalloc(sizeof(struct dcn321_resource_pool), GFP_KERNEL); 1965 1966 if (!pool) 1967 return NULL; 1968 1969 if (dcn321_resource_construct(init_data->num_virtual_links, dc, pool)) 1970 return &pool->base; 1971 1972 BREAK_TO_DEBUGGER(); 1973 kfree(pool); 1974 return NULL; 1975 } 1976