1 /* 2 * Copyright 2019 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * Authors: AMD 23 * 24 */ 25 26 27 #include "dm_services.h" 28 #include "dc.h" 29 30 #include "dcn31/dcn31_init.h" 31 32 #include "resource.h" 33 #include "include/irq_service_interface.h" 34 #include "dcn31_resource.h" 35 36 #include "dcn20/dcn20_resource.h" 37 #include "dcn30/dcn30_resource.h" 38 39 #include "dcn10/dcn10_ipp.h" 40 #include "dcn30/dcn30_hubbub.h" 41 #include "dcn31/dcn31_hubbub.h" 42 #include "dcn30/dcn30_mpc.h" 43 #include "dcn31/dcn31_hubp.h" 44 #include "irq/dcn31/irq_service_dcn31.h" 45 #include "dcn30/dcn30_dpp.h" 46 #include "dcn31/dcn31_optc.h" 47 #include "dcn20/dcn20_hwseq.h" 48 #include "dcn30/dcn30_hwseq.h" 49 #include "dce110/dce110_hw_sequencer.h" 50 #include "dcn30/dcn30_opp.h" 51 #include "dcn20/dcn20_dsc.h" 52 #include "dcn30/dcn30_vpg.h" 53 #include "dcn30/dcn30_afmt.h" 54 #include "dcn30/dcn30_dio_stream_encoder.h" 55 #include "dcn31/dcn31_dio_link_encoder.h" 56 #include "dce/dce_clock_source.h" 57 #include "dce/dce_audio.h" 58 #include "dce/dce_hwseq.h" 59 #include "clk_mgr.h" 60 #include "virtual/virtual_stream_encoder.h" 61 #include "dce110/dce110_resource.h" 62 #include "dml/display_mode_vba.h" 63 #include "dcn31/dcn31_dccg.h" 64 #include "dcn10/dcn10_resource.h" 65 #include "dcn31_panel_cntl.h" 66 67 #include "dcn30/dcn30_dwb.h" 68 #include "dcn30/dcn30_mmhubbub.h" 69 70 // TODO: change include headers /amd/include/asic_reg after upstream 71 #include "yellow_carp_offset.h" 72 #include "dcn/dcn_3_1_2_offset.h" 73 #include "dcn/dcn_3_1_2_sh_mask.h" 74 #include "nbio/nbio_7_2_0_offset.h" 75 #include "dpcs/dpcs_4_2_0_offset.h" 76 #include "dpcs/dpcs_4_2_0_sh_mask.h" 77 #include "mmhub/mmhub_2_3_0_offset.h" 78 #include "mmhub/mmhub_2_3_0_sh_mask.h" 79 80 81 #define regDCHUBBUB_DEBUG_CTRL_0 0x04d6 82 #define regDCHUBBUB_DEBUG_CTRL_0_BASE_IDX 2 83 #define DCHUBBUB_DEBUG_CTRL_0__DET_DEPTH__SHIFT 0x10 84 #define DCHUBBUB_DEBUG_CTRL_0__DET_DEPTH_MASK 0x01FF0000L 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 #include "link_enc_cfg.h" 97 98 #define DC_LOGGER_INIT(logger) 99 #define fixed16_to_double(x) (((double) x) / ((double) (1 << 16))) 100 #define fixed16_to_double_to_cpu(x) fixed16_to_double(le32_to_cpu(x)) 101 102 #define DCN3_1_DEFAULT_DET_SIZE 384 103 104 struct _vcs_dpi_ip_params_st dcn3_1_ip = { 105 .gpuvm_enable = 1, 106 .gpuvm_max_page_table_levels = 1, 107 .hostvm_enable = 1, 108 .hostvm_max_page_table_levels = 2, 109 .rob_buffer_size_kbytes = 64, 110 .det_buffer_size_kbytes = DCN3_1_DEFAULT_DET_SIZE, 111 .config_return_buffer_size_in_kbytes = 1792, 112 .compressed_buffer_segment_size_in_kbytes = 64, 113 .meta_fifo_size_in_kentries = 32, 114 .zero_size_buffer_entries = 512, 115 .compbuf_reserved_space_64b = 256, 116 .compbuf_reserved_space_zs = 64, 117 .dpp_output_buffer_pixels = 2560, 118 .opp_output_buffer_lines = 1, 119 .pixel_chunk_size_kbytes = 8, 120 .meta_chunk_size_kbytes = 2, 121 .min_meta_chunk_size_bytes = 256, 122 .writeback_chunk_size_kbytes = 8, 123 .ptoi_supported = false, 124 .num_dsc = 3, 125 .maximum_dsc_bits_per_component = 10, 126 .dsc422_native_support = false, 127 .is_line_buffer_bpp_fixed = true, 128 .line_buffer_fixed_bpp = 48, 129 .line_buffer_size_bits = 789504, 130 .max_line_buffer_lines = 12, 131 .writeback_interface_buffer_size_kbytes = 90, 132 .max_num_dpp = 4, 133 .max_num_otg = 4, 134 .max_num_hdmi_frl_outputs = 1, 135 .max_num_wb = 1, 136 .max_dchub_pscl_bw_pix_per_clk = 4, 137 .max_pscl_lb_bw_pix_per_clk = 2, 138 .max_lb_vscl_bw_pix_per_clk = 4, 139 .max_vscl_hscl_bw_pix_per_clk = 4, 140 .max_hscl_ratio = 6, 141 .max_vscl_ratio = 6, 142 .max_hscl_taps = 8, 143 .max_vscl_taps = 8, 144 .dpte_buffer_size_in_pte_reqs_luma = 64, 145 .dpte_buffer_size_in_pte_reqs_chroma = 34, 146 .dispclk_ramp_margin_percent = 1, 147 .max_inter_dcn_tile_repeaters = 8, 148 .cursor_buffer_size = 16, 149 .cursor_chunk_size = 2, 150 .writeback_line_buffer_buffer_size = 0, 151 .writeback_min_hscl_ratio = 1, 152 .writeback_min_vscl_ratio = 1, 153 .writeback_max_hscl_ratio = 1, 154 .writeback_max_vscl_ratio = 1, 155 .writeback_max_hscl_taps = 1, 156 .writeback_max_vscl_taps = 1, 157 .dppclk_delay_subtotal = 46, 158 .dppclk_delay_scl = 50, 159 .dppclk_delay_scl_lb_only = 16, 160 .dppclk_delay_cnvc_formatter = 27, 161 .dppclk_delay_cnvc_cursor = 6, 162 .dispclk_delay_subtotal = 119, 163 .dynamic_metadata_vm_enabled = false, 164 .odm_combine_4to1_supported = false, 165 .dcc_supported = true, 166 }; 167 168 struct _vcs_dpi_soc_bounding_box_st dcn3_1_soc = { 169 /*TODO: correct dispclk/dppclk voltage level determination*/ 170 .clock_limits = { 171 { 172 .state = 0, 173 .dispclk_mhz = 1200.0, 174 .dppclk_mhz = 1200.0, 175 .phyclk_mhz = 600.0, 176 .phyclk_d18_mhz = 667.0, 177 .dscclk_mhz = 186.0, 178 .dtbclk_mhz = 625.0, 179 }, 180 { 181 .state = 1, 182 .dispclk_mhz = 1200.0, 183 .dppclk_mhz = 1200.0, 184 .phyclk_mhz = 810.0, 185 .phyclk_d18_mhz = 667.0, 186 .dscclk_mhz = 209.0, 187 .dtbclk_mhz = 625.0, 188 }, 189 { 190 .state = 2, 191 .dispclk_mhz = 1200.0, 192 .dppclk_mhz = 1200.0, 193 .phyclk_mhz = 810.0, 194 .phyclk_d18_mhz = 667.0, 195 .dscclk_mhz = 209.0, 196 .dtbclk_mhz = 625.0, 197 }, 198 { 199 .state = 3, 200 .dispclk_mhz = 1200.0, 201 .dppclk_mhz = 1200.0, 202 .phyclk_mhz = 810.0, 203 .phyclk_d18_mhz = 667.0, 204 .dscclk_mhz = 371.0, 205 .dtbclk_mhz = 625.0, 206 }, 207 { 208 .state = 4, 209 .dispclk_mhz = 1200.0, 210 .dppclk_mhz = 1200.0, 211 .phyclk_mhz = 810.0, 212 .phyclk_d18_mhz = 667.0, 213 .dscclk_mhz = 417.0, 214 .dtbclk_mhz = 625.0, 215 }, 216 }, 217 .num_states = 5, 218 .sr_exit_time_us = 9.0, 219 .sr_enter_plus_exit_time_us = 11.0, 220 .sr_exit_z8_time_us = 402.0, 221 .sr_enter_plus_exit_z8_time_us = 520.0, 222 .writeback_latency_us = 12.0, 223 .dram_channel_width_bytes = 4, 224 .round_trip_ping_latency_dcfclk_cycles = 106, 225 .urgent_latency_pixel_data_only_us = 4.0, 226 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0, 227 .urgent_latency_vm_data_only_us = 4.0, 228 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096, 229 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096, 230 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096, 231 .pct_ideal_sdp_bw_after_urgent = 80.0, 232 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 65.0, 233 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 60.0, 234 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 30.0, 235 .max_avg_sdp_bw_use_normal_percent = 60.0, 236 .max_avg_dram_bw_use_normal_percent = 60.0, 237 .fabric_datapath_to_dcn_data_return_bytes = 32, 238 .return_bus_width_bytes = 64, 239 .downspread_percent = 0.38, 240 .dcn_downspread_percent = 0.5, 241 .gpuvm_min_page_size_bytes = 4096, 242 .hostvm_min_page_size_bytes = 4096, 243 .do_urgent_latency_adjustment = false, 244 .urgent_latency_adjustment_fabric_clock_component_us = 0, 245 .urgent_latency_adjustment_fabric_clock_reference_mhz = 0, 246 }; 247 248 enum dcn31_clk_src_array_id { 249 DCN31_CLK_SRC_PLL0, 250 DCN31_CLK_SRC_PLL1, 251 DCN31_CLK_SRC_PLL2, 252 DCN31_CLK_SRC_PLL3, 253 DCN31_CLK_SRC_PLL4, 254 DCN30_CLK_SRC_TOTAL 255 }; 256 257 /* begin ********************* 258 * macros to expend register list macro defined in HW object header file 259 */ 260 261 /* DCN */ 262 /* TODO awful hack. fixup dcn20_dwb.h */ 263 #undef BASE_INNER 264 #define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg 265 266 #define BASE(seg) BASE_INNER(seg) 267 268 #define SR(reg_name)\ 269 .reg_name = BASE(reg ## reg_name ## _BASE_IDX) + \ 270 reg ## reg_name 271 272 #define SRI(reg_name, block, id)\ 273 .reg_name = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 274 reg ## block ## id ## _ ## reg_name 275 276 #define SRI2(reg_name, block, id)\ 277 .reg_name = BASE(reg ## reg_name ## _BASE_IDX) + \ 278 reg ## reg_name 279 280 #define SRIR(var_name, reg_name, block, id)\ 281 .var_name = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 282 reg ## block ## id ## _ ## reg_name 283 284 #define SRII(reg_name, block, id)\ 285 .reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 286 reg ## block ## id ## _ ## reg_name 287 288 #define SRII_MPC_RMU(reg_name, block, id)\ 289 .RMU##_##reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 290 reg ## block ## id ## _ ## reg_name 291 292 #define SRII_DWB(reg_name, temp_name, block, id)\ 293 .reg_name[id] = BASE(reg ## block ## id ## _ ## temp_name ## _BASE_IDX) + \ 294 reg ## block ## id ## _ ## temp_name 295 296 #define DCCG_SRII(reg_name, block, id)\ 297 .block ## _ ## reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ 298 reg ## block ## id ## _ ## reg_name 299 300 #define VUPDATE_SRII(reg_name, block, id)\ 301 .reg_name[id] = BASE(reg ## reg_name ## _ ## block ## id ## _BASE_IDX) + \ 302 reg ## reg_name ## _ ## block ## id 303 304 /* NBIO */ 305 #define NBIO_BASE_INNER(seg) \ 306 NBIO_BASE__INST0_SEG ## seg 307 308 #define NBIO_BASE(seg) \ 309 NBIO_BASE_INNER(seg) 310 311 #define NBIO_SR(reg_name)\ 312 .reg_name = NBIO_BASE(regBIF_BX1_ ## reg_name ## _BASE_IDX) + \ 313 regBIF_BX1_ ## reg_name 314 315 /* MMHUB */ 316 #define MMHUB_BASE_INNER(seg) \ 317 MMHUB_BASE__INST0_SEG ## seg 318 319 #define MMHUB_BASE(seg) \ 320 MMHUB_BASE_INNER(seg) 321 322 #define MMHUB_SR(reg_name)\ 323 .reg_name = MMHUB_BASE(mm ## reg_name ## _BASE_IDX) + \ 324 mm ## reg_name 325 326 /* CLOCK */ 327 #define CLK_BASE_INNER(seg) \ 328 CLK_BASE__INST0_SEG ## seg 329 330 #define CLK_BASE(seg) \ 331 CLK_BASE_INNER(seg) 332 333 #define CLK_SRI(reg_name, block, inst)\ 334 .reg_name = CLK_BASE(reg ## block ## _ ## inst ## _ ## reg_name ## _BASE_IDX) + \ 335 reg ## block ## _ ## inst ## _ ## reg_name 336 337 338 static const struct bios_registers bios_regs = { 339 NBIO_SR(BIOS_SCRATCH_3), 340 NBIO_SR(BIOS_SCRATCH_6) 341 }; 342 343 #define clk_src_regs(index, pllid)\ 344 [index] = {\ 345 CS_COMMON_REG_LIST_DCN3_0(index, pllid),\ 346 } 347 348 static const struct dce110_clk_src_regs clk_src_regs[] = { 349 clk_src_regs(0, A), 350 clk_src_regs(1, B), 351 clk_src_regs(2, C), 352 clk_src_regs(3, D), 353 clk_src_regs(4, E) 354 }; 355 356 static const struct dce110_clk_src_shift cs_shift = { 357 CS_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT) 358 }; 359 360 static const struct dce110_clk_src_mask cs_mask = { 361 CS_COMMON_MASK_SH_LIST_DCN2_0(_MASK) 362 }; 363 364 #define abm_regs(id)\ 365 [id] = {\ 366 ABM_DCN301_REG_LIST(id)\ 367 } 368 369 static const struct dce_abm_registers abm_regs[] = { 370 abm_regs(0), 371 abm_regs(1), 372 abm_regs(2), 373 abm_regs(3), 374 }; 375 376 static const struct dce_abm_shift abm_shift = { 377 ABM_MASK_SH_LIST_DCN30(__SHIFT) 378 }; 379 380 static const struct dce_abm_mask abm_mask = { 381 ABM_MASK_SH_LIST_DCN30(_MASK) 382 }; 383 384 #define audio_regs(id)\ 385 [id] = {\ 386 AUD_COMMON_REG_LIST(id)\ 387 } 388 389 static const struct dce_audio_registers audio_regs[] = { 390 audio_regs(0), 391 audio_regs(1), 392 audio_regs(2), 393 audio_regs(3), 394 audio_regs(4), 395 audio_regs(5), 396 audio_regs(6) 397 }; 398 399 #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\ 400 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\ 401 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\ 402 AUD_COMMON_MASK_SH_LIST_BASE(mask_sh) 403 404 static const struct dce_audio_shift audio_shift = { 405 DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT) 406 }; 407 408 static const struct dce_audio_mask audio_mask = { 409 DCE120_AUD_COMMON_MASK_SH_LIST(_MASK) 410 }; 411 412 #define vpg_regs(id)\ 413 [id] = {\ 414 VPG_DCN3_REG_LIST(id)\ 415 } 416 417 static const struct dcn30_vpg_registers vpg_regs[] = { 418 vpg_regs(0), 419 vpg_regs(1), 420 vpg_regs(2), 421 vpg_regs(3), 422 vpg_regs(4), 423 vpg_regs(5), 424 vpg_regs(6), 425 vpg_regs(7), 426 vpg_regs(8), 427 vpg_regs(9), 428 }; 429 430 static const struct dcn30_vpg_shift vpg_shift = { 431 DCN3_VPG_MASK_SH_LIST(__SHIFT) 432 }; 433 434 static const struct dcn30_vpg_mask vpg_mask = { 435 DCN3_VPG_MASK_SH_LIST(_MASK) 436 }; 437 438 #define afmt_regs(id)\ 439 [id] = {\ 440 AFMT_DCN3_REG_LIST(id)\ 441 } 442 443 static const struct dcn30_afmt_registers afmt_regs[] = { 444 afmt_regs(0), 445 afmt_regs(1), 446 afmt_regs(2), 447 afmt_regs(3), 448 afmt_regs(4), 449 afmt_regs(5) 450 }; 451 452 static const struct dcn30_afmt_shift afmt_shift = { 453 DCN3_AFMT_MASK_SH_LIST(__SHIFT) 454 }; 455 456 static const struct dcn30_afmt_mask afmt_mask = { 457 DCN3_AFMT_MASK_SH_LIST(_MASK) 458 }; 459 460 #define stream_enc_regs(id)\ 461 [id] = {\ 462 SE_DCN3_REG_LIST(id)\ 463 } 464 465 static const struct dcn10_stream_enc_registers stream_enc_regs[] = { 466 stream_enc_regs(0), 467 stream_enc_regs(1), 468 stream_enc_regs(2), 469 stream_enc_regs(3), 470 stream_enc_regs(4) 471 }; 472 473 static const struct dcn10_stream_encoder_shift se_shift = { 474 SE_COMMON_MASK_SH_LIST_DCN30(__SHIFT) 475 }; 476 477 static const struct dcn10_stream_encoder_mask se_mask = { 478 SE_COMMON_MASK_SH_LIST_DCN30(_MASK) 479 }; 480 481 482 #define aux_regs(id)\ 483 [id] = {\ 484 DCN2_AUX_REG_LIST(id)\ 485 } 486 487 static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = { 488 aux_regs(0), 489 aux_regs(1), 490 aux_regs(2), 491 aux_regs(3), 492 aux_regs(4) 493 }; 494 495 #define hpd_regs(id)\ 496 [id] = {\ 497 HPD_REG_LIST(id)\ 498 } 499 500 static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = { 501 hpd_regs(0), 502 hpd_regs(1), 503 hpd_regs(2), 504 hpd_regs(3), 505 hpd_regs(4) 506 }; 507 508 #define link_regs(id, phyid)\ 509 [id] = {\ 510 LE_DCN31_REG_LIST(id), \ 511 UNIPHY_DCN2_REG_LIST(phyid), \ 512 DPCS_DCN31_REG_LIST(id), \ 513 } 514 515 static const struct dce110_aux_registers_shift aux_shift = { 516 DCN_AUX_MASK_SH_LIST(__SHIFT) 517 }; 518 519 static const struct dce110_aux_registers_mask aux_mask = { 520 DCN_AUX_MASK_SH_LIST(_MASK) 521 }; 522 523 static const struct dcn10_link_enc_registers link_enc_regs[] = { 524 link_regs(0, A), 525 link_regs(1, B), 526 link_regs(2, C), 527 link_regs(3, D), 528 link_regs(4, E) 529 }; 530 531 static const struct dcn10_link_enc_shift le_shift = { 532 LINK_ENCODER_MASK_SH_LIST_DCN31(__SHIFT), \ 533 DPCS_DCN31_MASK_SH_LIST(__SHIFT) 534 }; 535 536 static const struct dcn10_link_enc_mask le_mask = { 537 LINK_ENCODER_MASK_SH_LIST_DCN31(_MASK), \ 538 DPCS_DCN31_MASK_SH_LIST(_MASK) 539 }; 540 541 #define dpp_regs(id)\ 542 [id] = {\ 543 DPP_REG_LIST_DCN30(id),\ 544 } 545 546 static const struct dcn3_dpp_registers dpp_regs[] = { 547 dpp_regs(0), 548 dpp_regs(1), 549 dpp_regs(2), 550 dpp_regs(3) 551 }; 552 553 static const struct dcn3_dpp_shift tf_shift = { 554 DPP_REG_LIST_SH_MASK_DCN30(__SHIFT) 555 }; 556 557 static const struct dcn3_dpp_mask tf_mask = { 558 DPP_REG_LIST_SH_MASK_DCN30(_MASK) 559 }; 560 561 #define opp_regs(id)\ 562 [id] = {\ 563 OPP_REG_LIST_DCN30(id),\ 564 } 565 566 static const struct dcn20_opp_registers opp_regs[] = { 567 opp_regs(0), 568 opp_regs(1), 569 opp_regs(2), 570 opp_regs(3) 571 }; 572 573 static const struct dcn20_opp_shift opp_shift = { 574 OPP_MASK_SH_LIST_DCN20(__SHIFT) 575 }; 576 577 static const struct dcn20_opp_mask opp_mask = { 578 OPP_MASK_SH_LIST_DCN20(_MASK) 579 }; 580 581 #define aux_engine_regs(id)\ 582 [id] = {\ 583 AUX_COMMON_REG_LIST0(id), \ 584 .AUXN_IMPCAL = 0, \ 585 .AUXP_IMPCAL = 0, \ 586 .AUX_RESET_MASK = DP_AUX0_AUX_CONTROL__AUX_RESET_MASK, \ 587 } 588 589 static const struct dce110_aux_registers aux_engine_regs[] = { 590 aux_engine_regs(0), 591 aux_engine_regs(1), 592 aux_engine_regs(2), 593 aux_engine_regs(3), 594 aux_engine_regs(4) 595 }; 596 597 #define dwbc_regs_dcn3(id)\ 598 [id] = {\ 599 DWBC_COMMON_REG_LIST_DCN30(id),\ 600 } 601 602 static const struct dcn30_dwbc_registers dwbc30_regs[] = { 603 dwbc_regs_dcn3(0), 604 }; 605 606 static const struct dcn30_dwbc_shift dwbc30_shift = { 607 DWBC_COMMON_MASK_SH_LIST_DCN30(__SHIFT) 608 }; 609 610 static const struct dcn30_dwbc_mask dwbc30_mask = { 611 DWBC_COMMON_MASK_SH_LIST_DCN30(_MASK) 612 }; 613 614 #define mcif_wb_regs_dcn3(id)\ 615 [id] = {\ 616 MCIF_WB_COMMON_REG_LIST_DCN30(id),\ 617 } 618 619 static const struct dcn30_mmhubbub_registers mcif_wb30_regs[] = { 620 mcif_wb_regs_dcn3(0) 621 }; 622 623 static const struct dcn30_mmhubbub_shift mcif_wb30_shift = { 624 MCIF_WB_COMMON_MASK_SH_LIST_DCN30(__SHIFT) 625 }; 626 627 static const struct dcn30_mmhubbub_mask mcif_wb30_mask = { 628 MCIF_WB_COMMON_MASK_SH_LIST_DCN30(_MASK) 629 }; 630 631 #define dsc_regsDCN20(id)\ 632 [id] = {\ 633 DSC_REG_LIST_DCN20(id)\ 634 } 635 636 static const struct dcn20_dsc_registers dsc_regs[] = { 637 dsc_regsDCN20(0), 638 dsc_regsDCN20(1), 639 dsc_regsDCN20(2) 640 }; 641 642 static const struct dcn20_dsc_shift dsc_shift = { 643 DSC_REG_LIST_SH_MASK_DCN20(__SHIFT) 644 }; 645 646 static const struct dcn20_dsc_mask dsc_mask = { 647 DSC_REG_LIST_SH_MASK_DCN20(_MASK) 648 }; 649 650 static const struct dcn30_mpc_registers mpc_regs = { 651 MPC_REG_LIST_DCN3_0(0), 652 MPC_REG_LIST_DCN3_0(1), 653 MPC_REG_LIST_DCN3_0(2), 654 MPC_REG_LIST_DCN3_0(3), 655 MPC_OUT_MUX_REG_LIST_DCN3_0(0), 656 MPC_OUT_MUX_REG_LIST_DCN3_0(1), 657 MPC_OUT_MUX_REG_LIST_DCN3_0(2), 658 MPC_OUT_MUX_REG_LIST_DCN3_0(3), 659 MPC_RMU_GLOBAL_REG_LIST_DCN3AG, 660 MPC_RMU_REG_LIST_DCN3AG(0), 661 MPC_RMU_REG_LIST_DCN3AG(1), 662 //MPC_RMU_REG_LIST_DCN3AG(2), 663 MPC_DWB_MUX_REG_LIST_DCN3_0(0), 664 }; 665 666 static const struct dcn30_mpc_shift mpc_shift = { 667 MPC_COMMON_MASK_SH_LIST_DCN30(__SHIFT) 668 }; 669 670 static const struct dcn30_mpc_mask mpc_mask = { 671 MPC_COMMON_MASK_SH_LIST_DCN30(_MASK) 672 }; 673 674 #define optc_regs(id)\ 675 [id] = {OPTC_COMMON_REG_LIST_DCN3_1(id)} 676 677 static const struct dcn_optc_registers optc_regs[] = { 678 optc_regs(0), 679 optc_regs(1), 680 optc_regs(2), 681 optc_regs(3) 682 }; 683 684 static const struct dcn_optc_shift optc_shift = { 685 OPTC_COMMON_MASK_SH_LIST_DCN3_1(__SHIFT) 686 }; 687 688 static const struct dcn_optc_mask optc_mask = { 689 OPTC_COMMON_MASK_SH_LIST_DCN3_1(_MASK) 690 }; 691 692 #define hubp_regs(id)\ 693 [id] = {\ 694 HUBP_REG_LIST_DCN30(id)\ 695 } 696 697 static const struct dcn_hubp2_registers hubp_regs[] = { 698 hubp_regs(0), 699 hubp_regs(1), 700 hubp_regs(2), 701 hubp_regs(3) 702 }; 703 704 705 static const struct dcn_hubp2_shift hubp_shift = { 706 HUBP_MASK_SH_LIST_DCN31(__SHIFT) 707 }; 708 709 static const struct dcn_hubp2_mask hubp_mask = { 710 HUBP_MASK_SH_LIST_DCN31(_MASK) 711 }; 712 static const struct dcn_hubbub_registers hubbub_reg = { 713 HUBBUB_REG_LIST_DCN31(0) 714 }; 715 716 static const struct dcn_hubbub_shift hubbub_shift = { 717 HUBBUB_MASK_SH_LIST_DCN31(__SHIFT) 718 }; 719 720 static const struct dcn_hubbub_mask hubbub_mask = { 721 HUBBUB_MASK_SH_LIST_DCN31(_MASK) 722 }; 723 724 static const struct dccg_registers dccg_regs = { 725 DCCG_REG_LIST_DCN31() 726 }; 727 728 static const struct dccg_shift dccg_shift = { 729 DCCG_MASK_SH_LIST_DCN31(__SHIFT) 730 }; 731 732 static const struct dccg_mask dccg_mask = { 733 DCCG_MASK_SH_LIST_DCN31(_MASK) 734 }; 735 736 737 #define SRII2(reg_name_pre, reg_name_post, id)\ 738 .reg_name_pre ## _ ## reg_name_post[id] = BASE(reg ## reg_name_pre \ 739 ## id ## _ ## reg_name_post ## _BASE_IDX) + \ 740 reg ## reg_name_pre ## id ## _ ## reg_name_post 741 742 743 #define HWSEQ_DCN31_REG_LIST()\ 744 SR(DCHUBBUB_GLOBAL_TIMER_CNTL), \ 745 SR(DCHUBBUB_ARB_HOSTVM_CNTL), \ 746 SR(DIO_MEM_PWR_CTRL), \ 747 SR(ODM_MEM_PWR_CTRL3), \ 748 SR(DMU_MEM_PWR_CNTL), \ 749 SR(MMHUBBUB_MEM_PWR_CNTL), \ 750 SR(DCCG_GATE_DISABLE_CNTL), \ 751 SR(DCCG_GATE_DISABLE_CNTL2), \ 752 SR(DCFCLK_CNTL),\ 753 SR(DC_MEM_GLOBAL_PWR_REQ_CNTL), \ 754 SRII(PIXEL_RATE_CNTL, OTG, 0), \ 755 SRII(PIXEL_RATE_CNTL, OTG, 1),\ 756 SRII(PIXEL_RATE_CNTL, OTG, 2),\ 757 SRII(PIXEL_RATE_CNTL, OTG, 3),\ 758 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 0),\ 759 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 1),\ 760 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 2),\ 761 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 3),\ 762 SR(MICROSECOND_TIME_BASE_DIV), \ 763 SR(MILLISECOND_TIME_BASE_DIV), \ 764 SR(DISPCLK_FREQ_CHANGE_CNTL), \ 765 SR(RBBMIF_TIMEOUT_DIS), \ 766 SR(RBBMIF_TIMEOUT_DIS_2), \ 767 SR(DCHUBBUB_CRC_CTRL), \ 768 SR(DPP_TOP0_DPP_CRC_CTRL), \ 769 SR(DPP_TOP0_DPP_CRC_VAL_B_A), \ 770 SR(DPP_TOP0_DPP_CRC_VAL_R_G), \ 771 SR(MPC_CRC_CTRL), \ 772 SR(MPC_CRC_RESULT_GB), \ 773 SR(MPC_CRC_RESULT_C), \ 774 SR(MPC_CRC_RESULT_AR), \ 775 SR(DOMAIN0_PG_CONFIG), \ 776 SR(DOMAIN1_PG_CONFIG), \ 777 SR(DOMAIN2_PG_CONFIG), \ 778 SR(DOMAIN3_PG_CONFIG), \ 779 SR(DOMAIN16_PG_CONFIG), \ 780 SR(DOMAIN17_PG_CONFIG), \ 781 SR(DOMAIN18_PG_CONFIG), \ 782 SR(DOMAIN0_PG_STATUS), \ 783 SR(DOMAIN1_PG_STATUS), \ 784 SR(DOMAIN2_PG_STATUS), \ 785 SR(DOMAIN3_PG_STATUS), \ 786 SR(DOMAIN16_PG_STATUS), \ 787 SR(DOMAIN17_PG_STATUS), \ 788 SR(DOMAIN18_PG_STATUS), \ 789 SR(D1VGA_CONTROL), \ 790 SR(D2VGA_CONTROL), \ 791 SR(D3VGA_CONTROL), \ 792 SR(D4VGA_CONTROL), \ 793 SR(D5VGA_CONTROL), \ 794 SR(D6VGA_CONTROL), \ 795 SR(DC_IP_REQUEST_CNTL), \ 796 SR(AZALIA_AUDIO_DTO), \ 797 SR(AZALIA_CONTROLLER_CLOCK_GATING) 798 799 static const struct dce_hwseq_registers hwseq_reg = { 800 HWSEQ_DCN31_REG_LIST() 801 }; 802 803 #define HWSEQ_DCN31_MASK_SH_LIST(mask_sh)\ 804 HWSEQ_DCN_MASK_SH_LIST(mask_sh), \ 805 HWS_SF(, DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, mask_sh), \ 806 HWS_SF(, DCHUBBUB_ARB_HOSTVM_CNTL, DISABLE_HOSTVM_FORCE_ALLOW_PSTATE, mask_sh), \ 807 HWS_SF(, DOMAIN0_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 808 HWS_SF(, DOMAIN0_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 809 HWS_SF(, DOMAIN1_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 810 HWS_SF(, DOMAIN1_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 811 HWS_SF(, DOMAIN2_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 812 HWS_SF(, DOMAIN2_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 813 HWS_SF(, DOMAIN3_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 814 HWS_SF(, DOMAIN3_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 815 HWS_SF(, DOMAIN16_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 816 HWS_SF(, DOMAIN16_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 817 HWS_SF(, DOMAIN17_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 818 HWS_SF(, DOMAIN17_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 819 HWS_SF(, DOMAIN18_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \ 820 HWS_SF(, DOMAIN18_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \ 821 HWS_SF(, DOMAIN0_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 822 HWS_SF(, DOMAIN1_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 823 HWS_SF(, DOMAIN2_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 824 HWS_SF(, DOMAIN3_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 825 HWS_SF(, DOMAIN16_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 826 HWS_SF(, DOMAIN17_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 827 HWS_SF(, DOMAIN18_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \ 828 HWS_SF(, DC_IP_REQUEST_CNTL, IP_REQUEST_EN, mask_sh), \ 829 HWS_SF(, AZALIA_AUDIO_DTO, AZALIA_AUDIO_DTO_MODULE, mask_sh), \ 830 HWS_SF(, HPO_TOP_CLOCK_CONTROL, HPO_HDMISTREAMCLK_G_GATE_DIS, mask_sh), \ 831 HWS_SF(, DMU_MEM_PWR_CNTL, DMCU_ERAM_MEM_PWR_FORCE, mask_sh), \ 832 HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_UNASSIGNED_PWR_MODE, mask_sh), \ 833 HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_VBLANK_PWR_MODE, mask_sh), \ 834 HWS_SF(, MMHUBBUB_MEM_PWR_CNTL, VGA_MEM_PWR_FORCE, mask_sh) 835 836 static const struct dce_hwseq_shift hwseq_shift = { 837 HWSEQ_DCN31_MASK_SH_LIST(__SHIFT) 838 }; 839 840 static const struct dce_hwseq_mask hwseq_mask = { 841 HWSEQ_DCN31_MASK_SH_LIST(_MASK) 842 }; 843 #define vmid_regs(id)\ 844 [id] = {\ 845 DCN20_VMID_REG_LIST(id)\ 846 } 847 848 static const struct dcn_vmid_registers vmid_regs[] = { 849 vmid_regs(0), 850 vmid_regs(1), 851 vmid_regs(2), 852 vmid_regs(3), 853 vmid_regs(4), 854 vmid_regs(5), 855 vmid_regs(6), 856 vmid_regs(7), 857 vmid_regs(8), 858 vmid_regs(9), 859 vmid_regs(10), 860 vmid_regs(11), 861 vmid_regs(12), 862 vmid_regs(13), 863 vmid_regs(14), 864 vmid_regs(15) 865 }; 866 867 static const struct dcn20_vmid_shift vmid_shifts = { 868 DCN20_VMID_MASK_SH_LIST(__SHIFT) 869 }; 870 871 static const struct dcn20_vmid_mask vmid_masks = { 872 DCN20_VMID_MASK_SH_LIST(_MASK) 873 }; 874 875 static const struct resource_caps res_cap_dcn31 = { 876 .num_timing_generator = 4, 877 .num_opp = 4, 878 .num_video_plane = 4, 879 .num_audio = 5, 880 .num_stream_encoder = 5, 881 .num_dig_link_enc = 5, 882 .num_pll = 5, 883 .num_dwb = 1, 884 .num_ddc = 5, 885 .num_vmid = 16, 886 .num_mpc_3dlut = 2, 887 .num_dsc = 3, 888 }; 889 890 static const struct dc_plane_cap plane_cap = { 891 .type = DC_PLANE_TYPE_DCN_UNIVERSAL, 892 .blends_with_above = true, 893 .blends_with_below = true, 894 .per_pixel_alpha = true, 895 896 .pixel_format_support = { 897 .argb8888 = true, 898 .nv12 = true, 899 .fp16 = true, 900 .p010 = false, 901 .ayuv = false, 902 }, 903 904 .max_upscale_factor = { 905 .argb8888 = 16000, 906 .nv12 = 16000, 907 .fp16 = 16000 908 }, 909 910 // 6:1 downscaling ratio: 1000/6 = 166.666 911 .max_downscale_factor = { 912 .argb8888 = 167, 913 .nv12 = 167, 914 .fp16 = 167 915 }, 916 64, 917 64 918 }; 919 920 static const struct dc_debug_options debug_defaults_drv = { 921 .disable_dmcu = true, 922 .force_abm_enable = false, 923 .timing_trace = false, 924 .clock_trace = true, 925 .disable_pplib_clock_request = false, 926 .pipe_split_policy = MPC_SPLIT_AVOID, 927 .force_single_disp_pipe_split = false, 928 .disable_dcc = DCC_ENABLE, 929 .vsr_support = true, 930 .performance_trace = false, 931 .max_downscale_src_width = 7680,/*upto 8K*/ 932 .disable_pplib_wm_range = false, 933 .scl_reset_length10 = true, 934 .sanity_checks = false, 935 .underflow_assert_delay_us = 0xFFFFFFFF, 936 .dwb_fi_phase = -1, // -1 = disable, 937 .dmub_command_table = true, 938 .pstate_enabled = true, 939 .use_max_lb = true, 940 .enable_mem_low_power = { 941 .bits = { 942 .vga = false, 943 .i2c = false, 944 .dmcu = false, // This is previously known to cause hang on S3 cycles if enabled 945 .dscl = false, 946 .cm = false, 947 .mpc = false, 948 .optc = false, 949 } 950 }, 951 .optimize_edp_link_rate = true, 952 .enable_sw_cntl_psr = true, 953 }; 954 955 static const struct dc_debug_options debug_defaults_diags = { 956 .disable_dmcu = true, 957 .force_abm_enable = false, 958 .timing_trace = true, 959 .clock_trace = true, 960 .disable_dpp_power_gate = true, 961 .disable_hubp_power_gate = true, 962 .disable_clock_gate = true, 963 .disable_pplib_clock_request = true, 964 .disable_pplib_wm_range = true, 965 .disable_stutter = false, 966 .scl_reset_length10 = true, 967 .dwb_fi_phase = -1, // -1 = disable 968 .dmub_command_table = true, 969 .enable_tri_buf = true, 970 .use_max_lb = true 971 }; 972 973 static void dcn31_dpp_destroy(struct dpp **dpp) 974 { 975 kfree(TO_DCN20_DPP(*dpp)); 976 *dpp = NULL; 977 } 978 979 static struct dpp *dcn31_dpp_create( 980 struct dc_context *ctx, 981 uint32_t inst) 982 { 983 struct dcn3_dpp *dpp = 984 kzalloc(sizeof(struct dcn3_dpp), GFP_KERNEL); 985 986 if (!dpp) 987 return NULL; 988 989 if (dpp3_construct(dpp, ctx, inst, 990 &dpp_regs[inst], &tf_shift, &tf_mask)) 991 return &dpp->base; 992 993 BREAK_TO_DEBUGGER(); 994 kfree(dpp); 995 return NULL; 996 } 997 998 static struct output_pixel_processor *dcn31_opp_create( 999 struct dc_context *ctx, uint32_t inst) 1000 { 1001 struct dcn20_opp *opp = 1002 kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL); 1003 1004 if (!opp) { 1005 BREAK_TO_DEBUGGER(); 1006 return NULL; 1007 } 1008 1009 dcn20_opp_construct(opp, ctx, inst, 1010 &opp_regs[inst], &opp_shift, &opp_mask); 1011 return &opp->base; 1012 } 1013 1014 static struct dce_aux *dcn31_aux_engine_create( 1015 struct dc_context *ctx, 1016 uint32_t inst) 1017 { 1018 struct aux_engine_dce110 *aux_engine = 1019 kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL); 1020 1021 if (!aux_engine) 1022 return NULL; 1023 1024 dce110_aux_engine_construct(aux_engine, ctx, inst, 1025 SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD, 1026 &aux_engine_regs[inst], 1027 &aux_mask, 1028 &aux_shift, 1029 ctx->dc->caps.extended_aux_timeout_support); 1030 1031 return &aux_engine->base; 1032 } 1033 #define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST_DCN30(id) } 1034 1035 static const struct dce_i2c_registers i2c_hw_regs[] = { 1036 i2c_inst_regs(1), 1037 i2c_inst_regs(2), 1038 i2c_inst_regs(3), 1039 i2c_inst_regs(4), 1040 i2c_inst_regs(5), 1041 }; 1042 1043 static const struct dce_i2c_shift i2c_shifts = { 1044 I2C_COMMON_MASK_SH_LIST_DCN30(__SHIFT) 1045 }; 1046 1047 static const struct dce_i2c_mask i2c_masks = { 1048 I2C_COMMON_MASK_SH_LIST_DCN30(_MASK) 1049 }; 1050 1051 static struct dce_i2c_hw *dcn31_i2c_hw_create( 1052 struct dc_context *ctx, 1053 uint32_t inst) 1054 { 1055 struct dce_i2c_hw *dce_i2c_hw = 1056 kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL); 1057 1058 if (!dce_i2c_hw) 1059 return NULL; 1060 1061 dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst, 1062 &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); 1063 1064 return dce_i2c_hw; 1065 } 1066 static struct mpc *dcn31_mpc_create( 1067 struct dc_context *ctx, 1068 int num_mpcc, 1069 int num_rmu) 1070 { 1071 struct dcn30_mpc *mpc30 = kzalloc(sizeof(struct dcn30_mpc), 1072 GFP_KERNEL); 1073 1074 if (!mpc30) 1075 return NULL; 1076 1077 dcn30_mpc_construct(mpc30, ctx, 1078 &mpc_regs, 1079 &mpc_shift, 1080 &mpc_mask, 1081 num_mpcc, 1082 num_rmu); 1083 1084 return &mpc30->base; 1085 } 1086 1087 static struct hubbub *dcn31_hubbub_create(struct dc_context *ctx) 1088 { 1089 int i; 1090 1091 struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub), 1092 GFP_KERNEL); 1093 1094 if (!hubbub3) 1095 return NULL; 1096 1097 hubbub31_construct(hubbub3, ctx, 1098 &hubbub_reg, 1099 &hubbub_shift, 1100 &hubbub_mask, 1101 dcn3_1_ip.det_buffer_size_kbytes, 1102 dcn3_1_ip.pixel_chunk_size_kbytes, 1103 dcn3_1_ip.config_return_buffer_size_in_kbytes); 1104 1105 1106 for (i = 0; i < res_cap_dcn31.num_vmid; i++) { 1107 struct dcn20_vmid *vmid = &hubbub3->vmid[i]; 1108 1109 vmid->ctx = ctx; 1110 1111 vmid->regs = &vmid_regs[i]; 1112 vmid->shifts = &vmid_shifts; 1113 vmid->masks = &vmid_masks; 1114 } 1115 1116 return &hubbub3->base; 1117 } 1118 1119 static struct timing_generator *dcn31_timing_generator_create( 1120 struct dc_context *ctx, 1121 uint32_t instance) 1122 { 1123 struct optc *tgn10 = 1124 kzalloc(sizeof(struct optc), GFP_KERNEL); 1125 1126 if (!tgn10) 1127 return NULL; 1128 1129 tgn10->base.inst = instance; 1130 tgn10->base.ctx = ctx; 1131 1132 tgn10->tg_regs = &optc_regs[instance]; 1133 tgn10->tg_shift = &optc_shift; 1134 tgn10->tg_mask = &optc_mask; 1135 1136 dcn31_timing_generator_init(tgn10); 1137 1138 return &tgn10->base; 1139 } 1140 1141 static const struct encoder_feature_support link_enc_feature = { 1142 .max_hdmi_deep_color = COLOR_DEPTH_121212, 1143 .max_hdmi_pixel_clock = 600000, 1144 .hdmi_ycbcr420_supported = true, 1145 .dp_ycbcr420_supported = true, 1146 .fec_supported = true, 1147 .flags.bits.IS_HBR2_CAPABLE = true, 1148 .flags.bits.IS_HBR3_CAPABLE = true, 1149 .flags.bits.IS_TPS3_CAPABLE = true, 1150 .flags.bits.IS_TPS4_CAPABLE = true 1151 }; 1152 1153 static struct link_encoder *dcn31_link_encoder_create( 1154 const struct encoder_init_data *enc_init_data) 1155 { 1156 struct dcn20_link_encoder *enc20 = 1157 kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); 1158 1159 if (!enc20) 1160 return NULL; 1161 1162 dcn31_link_encoder_construct(enc20, 1163 enc_init_data, 1164 &link_enc_feature, 1165 &link_enc_regs[enc_init_data->transmitter], 1166 &link_enc_aux_regs[enc_init_data->channel - 1], 1167 &link_enc_hpd_regs[enc_init_data->hpd_source], 1168 &le_shift, 1169 &le_mask); 1170 1171 return &enc20->enc10.base; 1172 } 1173 1174 /* Create a minimal link encoder object not associated with a particular 1175 * physical connector. 1176 * resource_funcs.link_enc_create_minimal 1177 */ 1178 static struct link_encoder *dcn31_link_enc_create_minimal( 1179 struct dc_context *ctx, enum engine_id eng_id) 1180 { 1181 struct dcn20_link_encoder *enc20; 1182 1183 if ((eng_id - ENGINE_ID_DIGA) > ctx->dc->res_pool->res_cap->num_dig_link_enc) 1184 return NULL; 1185 1186 enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); 1187 if (!enc20) 1188 return NULL; 1189 1190 dcn31_link_encoder_construct_minimal( 1191 enc20, 1192 ctx, 1193 &link_enc_feature, 1194 &link_enc_regs[eng_id - ENGINE_ID_DIGA], 1195 eng_id); 1196 1197 return &enc20->enc10.base; 1198 } 1199 1200 struct panel_cntl *dcn31_panel_cntl_create(const struct panel_cntl_init_data *init_data) 1201 { 1202 struct dcn31_panel_cntl *panel_cntl = 1203 kzalloc(sizeof(struct dcn31_panel_cntl), GFP_KERNEL); 1204 1205 if (!panel_cntl) 1206 return NULL; 1207 1208 dcn31_panel_cntl_construct(panel_cntl, init_data); 1209 1210 return &panel_cntl->base; 1211 } 1212 1213 static void read_dce_straps( 1214 struct dc_context *ctx, 1215 struct resource_straps *straps) 1216 { 1217 generic_reg_get(ctx, regDC_PINSTRAPS + BASE(regDC_PINSTRAPS_BASE_IDX), 1218 FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio); 1219 1220 } 1221 1222 static struct audio *dcn31_create_audio( 1223 struct dc_context *ctx, unsigned int inst) 1224 { 1225 return dce_audio_create(ctx, inst, 1226 &audio_regs[inst], &audio_shift, &audio_mask); 1227 } 1228 1229 static struct vpg *dcn31_vpg_create( 1230 struct dc_context *ctx, 1231 uint32_t inst) 1232 { 1233 struct dcn30_vpg *vpg3 = kzalloc(sizeof(struct dcn30_vpg), GFP_KERNEL); 1234 1235 if (!vpg3) 1236 return NULL; 1237 1238 vpg3_construct(vpg3, ctx, inst, 1239 &vpg_regs[inst], 1240 &vpg_shift, 1241 &vpg_mask); 1242 1243 return &vpg3->base; 1244 } 1245 1246 static struct afmt *dcn31_afmt_create( 1247 struct dc_context *ctx, 1248 uint32_t inst) 1249 { 1250 struct dcn30_afmt *afmt3 = kzalloc(sizeof(struct dcn30_afmt), GFP_KERNEL); 1251 1252 if (!afmt3) 1253 return NULL; 1254 1255 afmt3_construct(afmt3, ctx, inst, 1256 &afmt_regs[inst], 1257 &afmt_shift, 1258 &afmt_mask); 1259 1260 return &afmt3->base; 1261 } 1262 1263 static struct stream_encoder *dcn31_stream_encoder_create( 1264 enum engine_id eng_id, 1265 struct dc_context *ctx) 1266 { 1267 struct dcn10_stream_encoder *enc1; 1268 struct vpg *vpg; 1269 struct afmt *afmt; 1270 int vpg_inst; 1271 int afmt_inst; 1272 1273 /* Mapping of VPG, AFMT, DME register blocks to DIO block instance */ 1274 if (eng_id <= ENGINE_ID_DIGF) { 1275 vpg_inst = eng_id; 1276 afmt_inst = eng_id; 1277 } else 1278 return NULL; 1279 1280 enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL); 1281 vpg = dcn31_vpg_create(ctx, vpg_inst); 1282 afmt = dcn31_afmt_create(ctx, afmt_inst); 1283 1284 if (!enc1 || !vpg || !afmt) 1285 return NULL; 1286 1287 dcn30_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios, 1288 eng_id, vpg, afmt, 1289 &stream_enc_regs[eng_id], 1290 &se_shift, &se_mask); 1291 1292 return &enc1->base; 1293 } 1294 1295 static struct dce_hwseq *dcn31_hwseq_create( 1296 struct dc_context *ctx) 1297 { 1298 struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL); 1299 1300 if (hws) { 1301 hws->ctx = ctx; 1302 hws->regs = &hwseq_reg; 1303 hws->shifts = &hwseq_shift; 1304 hws->masks = &hwseq_mask; 1305 } 1306 return hws; 1307 } 1308 static const struct resource_create_funcs res_create_funcs = { 1309 .read_dce_straps = read_dce_straps, 1310 .create_audio = dcn31_create_audio, 1311 .create_stream_encoder = dcn31_stream_encoder_create, 1312 .create_hwseq = dcn31_hwseq_create, 1313 }; 1314 1315 static const struct resource_create_funcs res_create_maximus_funcs = { 1316 .read_dce_straps = NULL, 1317 .create_audio = NULL, 1318 .create_stream_encoder = NULL, 1319 .create_hwseq = dcn31_hwseq_create, 1320 }; 1321 1322 static void dcn31_resource_destruct(struct dcn31_resource_pool *pool) 1323 { 1324 unsigned int i; 1325 1326 for (i = 0; i < pool->base.stream_enc_count; i++) { 1327 if (pool->base.stream_enc[i] != NULL) { 1328 if (pool->base.stream_enc[i]->vpg != NULL) { 1329 kfree(DCN30_VPG_FROM_VPG(pool->base.stream_enc[i]->vpg)); 1330 pool->base.stream_enc[i]->vpg = NULL; 1331 } 1332 if (pool->base.stream_enc[i]->afmt != NULL) { 1333 kfree(DCN30_AFMT_FROM_AFMT(pool->base.stream_enc[i]->afmt)); 1334 pool->base.stream_enc[i]->afmt = NULL; 1335 } 1336 kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i])); 1337 pool->base.stream_enc[i] = NULL; 1338 } 1339 } 1340 1341 for (i = 0; i < pool->base.res_cap->num_dsc; i++) { 1342 if (pool->base.dscs[i] != NULL) 1343 dcn20_dsc_destroy(&pool->base.dscs[i]); 1344 } 1345 1346 if (pool->base.mpc != NULL) { 1347 kfree(TO_DCN20_MPC(pool->base.mpc)); 1348 pool->base.mpc = NULL; 1349 } 1350 if (pool->base.hubbub != NULL) { 1351 kfree(pool->base.hubbub); 1352 pool->base.hubbub = NULL; 1353 } 1354 for (i = 0; i < pool->base.pipe_count; i++) { 1355 if (pool->base.dpps[i] != NULL) 1356 dcn31_dpp_destroy(&pool->base.dpps[i]); 1357 1358 if (pool->base.ipps[i] != NULL) 1359 pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]); 1360 1361 if (pool->base.hubps[i] != NULL) { 1362 kfree(TO_DCN20_HUBP(pool->base.hubps[i])); 1363 pool->base.hubps[i] = NULL; 1364 } 1365 1366 if (pool->base.irqs != NULL) { 1367 dal_irq_service_destroy(&pool->base.irqs); 1368 } 1369 } 1370 1371 for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 1372 if (pool->base.engines[i] != NULL) 1373 dce110_engine_destroy(&pool->base.engines[i]); 1374 if (pool->base.hw_i2cs[i] != NULL) { 1375 kfree(pool->base.hw_i2cs[i]); 1376 pool->base.hw_i2cs[i] = NULL; 1377 } 1378 if (pool->base.sw_i2cs[i] != NULL) { 1379 kfree(pool->base.sw_i2cs[i]); 1380 pool->base.sw_i2cs[i] = NULL; 1381 } 1382 } 1383 1384 for (i = 0; i < pool->base.res_cap->num_opp; i++) { 1385 if (pool->base.opps[i] != NULL) 1386 pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]); 1387 } 1388 1389 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) { 1390 if (pool->base.timing_generators[i] != NULL) { 1391 kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i])); 1392 pool->base.timing_generators[i] = NULL; 1393 } 1394 } 1395 1396 for (i = 0; i < pool->base.res_cap->num_dwb; i++) { 1397 if (pool->base.dwbc[i] != NULL) { 1398 kfree(TO_DCN30_DWBC(pool->base.dwbc[i])); 1399 pool->base.dwbc[i] = NULL; 1400 } 1401 if (pool->base.mcif_wb[i] != NULL) { 1402 kfree(TO_DCN30_MMHUBBUB(pool->base.mcif_wb[i])); 1403 pool->base.mcif_wb[i] = NULL; 1404 } 1405 } 1406 1407 for (i = 0; i < pool->base.audio_count; i++) { 1408 if (pool->base.audios[i]) 1409 dce_aud_destroy(&pool->base.audios[i]); 1410 } 1411 1412 for (i = 0; i < pool->base.clk_src_count; i++) { 1413 if (pool->base.clock_sources[i] != NULL) { 1414 dcn20_clock_source_destroy(&pool->base.clock_sources[i]); 1415 pool->base.clock_sources[i] = NULL; 1416 } 1417 } 1418 1419 for (i = 0; i < pool->base.res_cap->num_mpc_3dlut; i++) { 1420 if (pool->base.mpc_lut[i] != NULL) { 1421 dc_3dlut_func_release(pool->base.mpc_lut[i]); 1422 pool->base.mpc_lut[i] = NULL; 1423 } 1424 if (pool->base.mpc_shaper[i] != NULL) { 1425 dc_transfer_func_release(pool->base.mpc_shaper[i]); 1426 pool->base.mpc_shaper[i] = NULL; 1427 } 1428 } 1429 1430 if (pool->base.dp_clock_source != NULL) { 1431 dcn20_clock_source_destroy(&pool->base.dp_clock_source); 1432 pool->base.dp_clock_source = NULL; 1433 } 1434 1435 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) { 1436 if (pool->base.multiple_abms[i] != NULL) 1437 dce_abm_destroy(&pool->base.multiple_abms[i]); 1438 } 1439 1440 if (pool->base.psr != NULL) 1441 dmub_psr_destroy(&pool->base.psr); 1442 1443 if (pool->base.dccg != NULL) 1444 dcn_dccg_destroy(&pool->base.dccg); 1445 } 1446 1447 static struct hubp *dcn31_hubp_create( 1448 struct dc_context *ctx, 1449 uint32_t inst) 1450 { 1451 struct dcn20_hubp *hubp2 = 1452 kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL); 1453 1454 if (!hubp2) 1455 return NULL; 1456 1457 if (hubp31_construct(hubp2, ctx, inst, 1458 &hubp_regs[inst], &hubp_shift, &hubp_mask)) 1459 return &hubp2->base; 1460 1461 BREAK_TO_DEBUGGER(); 1462 kfree(hubp2); 1463 return NULL; 1464 } 1465 1466 static bool dcn31_dwbc_create(struct dc_context *ctx, struct resource_pool *pool) 1467 { 1468 int i; 1469 uint32_t pipe_count = pool->res_cap->num_dwb; 1470 1471 for (i = 0; i < pipe_count; i++) { 1472 struct dcn30_dwbc *dwbc30 = kzalloc(sizeof(struct dcn30_dwbc), 1473 GFP_KERNEL); 1474 1475 if (!dwbc30) { 1476 dm_error("DC: failed to create dwbc30!\n"); 1477 return false; 1478 } 1479 1480 dcn30_dwbc_construct(dwbc30, ctx, 1481 &dwbc30_regs[i], 1482 &dwbc30_shift, 1483 &dwbc30_mask, 1484 i); 1485 1486 pool->dwbc[i] = &dwbc30->base; 1487 } 1488 return true; 1489 } 1490 1491 static bool dcn31_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool) 1492 { 1493 int i; 1494 uint32_t pipe_count = pool->res_cap->num_dwb; 1495 1496 for (i = 0; i < pipe_count; i++) { 1497 struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub), 1498 GFP_KERNEL); 1499 1500 if (!mcif_wb30) { 1501 dm_error("DC: failed to create mcif_wb30!\n"); 1502 return false; 1503 } 1504 1505 dcn30_mmhubbub_construct(mcif_wb30, ctx, 1506 &mcif_wb30_regs[i], 1507 &mcif_wb30_shift, 1508 &mcif_wb30_mask, 1509 i); 1510 1511 pool->mcif_wb[i] = &mcif_wb30->base; 1512 } 1513 return true; 1514 } 1515 1516 static struct display_stream_compressor *dcn31_dsc_create( 1517 struct dc_context *ctx, uint32_t inst) 1518 { 1519 struct dcn20_dsc *dsc = 1520 kzalloc(sizeof(struct dcn20_dsc), GFP_KERNEL); 1521 1522 if (!dsc) { 1523 BREAK_TO_DEBUGGER(); 1524 return NULL; 1525 } 1526 1527 dsc2_construct(dsc, ctx, inst, &dsc_regs[inst], &dsc_shift, &dsc_mask); 1528 return &dsc->base; 1529 } 1530 1531 static void dcn31_destroy_resource_pool(struct resource_pool **pool) 1532 { 1533 struct dcn31_resource_pool *dcn31_pool = TO_DCN31_RES_POOL(*pool); 1534 1535 dcn31_resource_destruct(dcn31_pool); 1536 kfree(dcn31_pool); 1537 *pool = NULL; 1538 } 1539 1540 static struct clock_source *dcn31_clock_source_create( 1541 struct dc_context *ctx, 1542 struct dc_bios *bios, 1543 enum clock_source_id id, 1544 const struct dce110_clk_src_regs *regs, 1545 bool dp_clk_src) 1546 { 1547 struct dce110_clk_src *clk_src = 1548 kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL); 1549 1550 if (!clk_src) 1551 return NULL; 1552 1553 if (dcn3_clk_src_construct(clk_src, ctx, bios, id, 1554 regs, &cs_shift, &cs_mask)) { 1555 clk_src->base.dp_clk_src = dp_clk_src; 1556 return &clk_src->base; 1557 } 1558 1559 BREAK_TO_DEBUGGER(); 1560 return NULL; 1561 } 1562 1563 static bool is_dual_plane(enum surface_pixel_format format) 1564 { 1565 return format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN || format == SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA; 1566 } 1567 1568 static int dcn31_populate_dml_pipes_from_context( 1569 struct dc *dc, struct dc_state *context, 1570 display_e2e_pipe_params_st *pipes, 1571 bool fast_validate) 1572 { 1573 int i, pipe_cnt; 1574 struct resource_context *res_ctx = &context->res_ctx; 1575 struct pipe_ctx *pipe; 1576 1577 dcn20_populate_dml_pipes_from_context(dc, context, pipes, fast_validate); 1578 1579 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) { 1580 struct dc_crtc_timing *timing; 1581 1582 if (!res_ctx->pipe_ctx[i].stream) 1583 continue; 1584 pipe = &res_ctx->pipe_ctx[i]; 1585 timing = &pipe->stream->timing; 1586 1587 pipes[pipe_cnt].pipe.src.unbounded_req_mode = false; 1588 pipes[pipe_cnt].pipe.src.gpuvm = true; 1589 pipes[pipe_cnt].pipe.src.dcc_fraction_of_zs_req_luma = 0; 1590 pipes[pipe_cnt].pipe.src.dcc_fraction_of_zs_req_chroma = 0; 1591 pipes[pipe_cnt].pipe.dest.vfront_porch = timing->v_front_porch; 1592 pipes[pipe_cnt].pipe.src.dcc_rate = 3; 1593 pipes[pipe_cnt].dout.dsc_input_bpc = 0; 1594 1595 if (pipes[pipe_cnt].dout.dsc_enable) { 1596 switch (timing->display_color_depth) { 1597 case COLOR_DEPTH_888: 1598 pipes[pipe_cnt].dout.dsc_input_bpc = 8; 1599 break; 1600 case COLOR_DEPTH_101010: 1601 pipes[pipe_cnt].dout.dsc_input_bpc = 10; 1602 break; 1603 case COLOR_DEPTH_121212: 1604 pipes[pipe_cnt].dout.dsc_input_bpc = 12; 1605 break; 1606 default: 1607 ASSERT(0); 1608 break; 1609 } 1610 } 1611 1612 pipe_cnt++; 1613 } 1614 context->bw_ctx.dml.ip.det_buffer_size_kbytes = DCN3_1_DEFAULT_DET_SIZE; 1615 dc->config.enable_4to1MPC = false; 1616 if (pipe_cnt == 1 && pipe->plane_state && !dc->debug.disable_z9_mpc) { 1617 if (is_dual_plane(pipe->plane_state->format) 1618 && pipe->plane_state->src_rect.width <= 1920 && pipe->plane_state->src_rect.height <= 1080) { 1619 dc->config.enable_4to1MPC = true; 1620 } else if (!is_dual_plane(pipe->plane_state->format)) { 1621 context->bw_ctx.dml.ip.det_buffer_size_kbytes = 192; 1622 pipes[0].pipe.src.unbounded_req_mode = true; 1623 } 1624 } 1625 1626 return pipe_cnt; 1627 } 1628 1629 static void dcn31_update_soc_for_wm_a(struct dc *dc, struct dc_state *context) 1630 { 1631 if (dc->clk_mgr->bw_params->wm_table.entries[WM_A].valid) { 1632 context->bw_ctx.dml.soc.dram_clock_change_latency_us = dc->clk_mgr->bw_params->wm_table.entries[WM_A].pstate_latency_us; 1633 context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.entries[WM_A].sr_enter_plus_exit_time_us; 1634 context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.entries[WM_A].sr_exit_time_us; 1635 } 1636 } 1637 1638 static void dcn31_calculate_wm_and_dlg_fp( 1639 struct dc *dc, struct dc_state *context, 1640 display_e2e_pipe_params_st *pipes, 1641 int pipe_cnt, 1642 int vlevel) 1643 { 1644 int i, pipe_idx; 1645 double dcfclk = context->bw_ctx.dml.vba.DCFCLKState[vlevel][context->bw_ctx.dml.vba.maxMpcComb]; 1646 1647 if (context->bw_ctx.dml.soc.min_dcfclk > dcfclk) 1648 dcfclk = context->bw_ctx.dml.soc.min_dcfclk; 1649 1650 pipes[0].clks_cfg.voltage = vlevel; 1651 pipes[0].clks_cfg.dcfclk_mhz = dcfclk; 1652 pipes[0].clks_cfg.socclk_mhz = context->bw_ctx.dml.soc.clock_limits[vlevel].socclk_mhz; 1653 1654 #if 0 // TODO 1655 /* Set B: 1656 * TODO 1657 */ 1658 if (dc->clk_mgr->bw_params->wm_table.nv_entries[WM_B].valid) { 1659 if (vlevel == 0) { 1660 pipes[0].clks_cfg.voltage = 1; 1661 pipes[0].clks_cfg.dcfclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dcfclk_mhz; 1662 } 1663 context->bw_ctx.dml.soc.dram_clock_change_latency_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_B].dml_input.pstate_latency_us; 1664 context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_B].dml_input.sr_enter_plus_exit_time_us; 1665 context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_B].dml_input.sr_exit_time_us; 1666 } 1667 context->bw_ctx.bw.dcn.watermarks.b.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1668 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1669 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1670 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_enter_plus_exit_z8_ns = get_wm_z8_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1671 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_z8_ns = get_wm_z8_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1672 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1673 context->bw_ctx.bw.dcn.watermarks.b.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1674 context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1675 context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1676 context->bw_ctx.bw.dcn.watermarks.b.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1677 1678 pipes[0].clks_cfg.voltage = vlevel; 1679 pipes[0].clks_cfg.dcfclk_mhz = dcfclk; 1680 1681 /* Set C: 1682 * TODO 1683 */ 1684 if (dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].valid) { 1685 context->bw_ctx.dml.soc.dram_clock_change_latency_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].dml_input.pstate_latency_us; 1686 context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].dml_input.sr_enter_plus_exit_time_us; 1687 context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].dml_input.sr_exit_time_us; 1688 } 1689 context->bw_ctx.bw.dcn.watermarks.c.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1690 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1691 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1692 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_z8_ns = get_wm_z8_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1693 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_z8_ns = get_wm_z8_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1694 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1695 context->bw_ctx.bw.dcn.watermarks.c.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1696 context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1697 context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1698 context->bw_ctx.bw.dcn.watermarks.c.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1699 1700 /* Set D: 1701 * TODO 1702 */ 1703 if (dc->clk_mgr->bw_params->wm_table.nv_entries[WM_D].valid) { 1704 context->bw_ctx.dml.soc.dram_clock_change_latency_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_D].dml_input.pstate_latency_us; 1705 context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_D].dml_input.sr_enter_plus_exit_time_us; 1706 context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_D].dml_input.sr_exit_time_us; 1707 } 1708 context->bw_ctx.bw.dcn.watermarks.d.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1709 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1710 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1711 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1712 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_enter_plus_exit_z8_ns = get_wm_z8_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1713 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_z8_ns = get_wm_z8_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1714 context->bw_ctx.bw.dcn.watermarks.d.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1715 context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1716 context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1717 context->bw_ctx.bw.dcn.watermarks.d.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1718 #endif 1719 1720 /* Set A: 1721 * All clocks min required 1722 * 1723 * Set A calculated last so that following calculations are based on Set A 1724 */ 1725 dc->res_pool->funcs->update_soc_for_wm_a(dc, context); 1726 context->bw_ctx.bw.dcn.watermarks.a.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1727 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1728 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1729 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1730 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_z8_ns = get_wm_z8_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1731 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_z8_ns = get_wm_z8_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1732 context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1733 context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1734 context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1735 context->bw_ctx.bw.dcn.watermarks.a.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000; 1736 /* TODO: remove: */ 1737 context->bw_ctx.bw.dcn.watermarks.b = context->bw_ctx.bw.dcn.watermarks.a; 1738 context->bw_ctx.bw.dcn.watermarks.c = context->bw_ctx.bw.dcn.watermarks.a; 1739 context->bw_ctx.bw.dcn.watermarks.d = context->bw_ctx.bw.dcn.watermarks.a; 1740 /* end remove*/ 1741 1742 for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) { 1743 if (!context->res_ctx.pipe_ctx[i].stream) 1744 continue; 1745 1746 pipes[pipe_idx].clks_cfg.dispclk_mhz = get_dispclk_calculated(&context->bw_ctx.dml, pipes, pipe_cnt); 1747 pipes[pipe_idx].clks_cfg.dppclk_mhz = get_dppclk_calculated(&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx); 1748 1749 if (dc->config.forced_clocks) { 1750 pipes[pipe_idx].clks_cfg.dispclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dispclk_mhz; 1751 pipes[pipe_idx].clks_cfg.dppclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dppclk_mhz; 1752 } 1753 if (dc->debug.min_disp_clk_khz > pipes[pipe_idx].clks_cfg.dispclk_mhz * 1000) 1754 pipes[pipe_idx].clks_cfg.dispclk_mhz = dc->debug.min_disp_clk_khz / 1000.0; 1755 if (dc->debug.min_dpp_clk_khz > pipes[pipe_idx].clks_cfg.dppclk_mhz * 1000) 1756 pipes[pipe_idx].clks_cfg.dppclk_mhz = dc->debug.min_dpp_clk_khz / 1000.0; 1757 1758 pipe_idx++; 1759 } 1760 1761 dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel); 1762 } 1763 1764 static void dcn31_calculate_wm_and_dlg( 1765 struct dc *dc, struct dc_state *context, 1766 display_e2e_pipe_params_st *pipes, 1767 int pipe_cnt, 1768 int vlevel) 1769 { 1770 DC_FP_START(); 1771 dcn31_calculate_wm_and_dlg_fp(dc, context, pipes, pipe_cnt, vlevel); 1772 DC_FP_END(); 1773 } 1774 1775 static struct dc_cap_funcs cap_funcs = { 1776 .get_dcc_compression_cap = dcn20_get_dcc_compression_cap 1777 }; 1778 1779 static void dcn31_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params) 1780 { 1781 struct clk_limit_table *clk_table = &bw_params->clk_table; 1782 struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES]; 1783 unsigned int i, closest_clk_lvl; 1784 int j; 1785 1786 // Default clock levels are used for diags, which may lead to overclocking. 1787 if (!IS_DIAG_DC(dc->ctx->dce_environment)) { 1788 int max_dispclk_mhz = 0, max_dppclk_mhz = 0; 1789 1790 dcn3_1_ip.max_num_otg = dc->res_pool->res_cap->num_timing_generator; 1791 dcn3_1_ip.max_num_dpp = dc->res_pool->pipe_count; 1792 dcn3_1_soc.num_chans = bw_params->num_channels; 1793 1794 ASSERT(clk_table->num_entries); 1795 1796 /* Prepass to find max clocks independent of voltage level. */ 1797 for (i = 0; i < clk_table->num_entries; ++i) { 1798 if (clk_table->entries[i].dispclk_mhz > max_dispclk_mhz) 1799 max_dispclk_mhz = clk_table->entries[i].dispclk_mhz; 1800 if (clk_table->entries[i].dppclk_mhz > max_dppclk_mhz) 1801 max_dppclk_mhz = clk_table->entries[i].dppclk_mhz; 1802 } 1803 1804 for (i = 0; i < clk_table->num_entries; i++) { 1805 /* loop backwards*/ 1806 for (closest_clk_lvl = 0, j = dcn3_1_soc.num_states - 1; j >= 0; j--) { 1807 if ((unsigned int) dcn3_1_soc.clock_limits[j].dcfclk_mhz <= clk_table->entries[i].dcfclk_mhz) { 1808 closest_clk_lvl = j; 1809 break; 1810 } 1811 } 1812 1813 clock_limits[i].state = i; 1814 1815 /* Clocks dependent on voltage level. */ 1816 clock_limits[i].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz; 1817 clock_limits[i].fabricclk_mhz = clk_table->entries[i].fclk_mhz; 1818 clock_limits[i].socclk_mhz = clk_table->entries[i].socclk_mhz; 1819 clock_limits[i].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2 * clk_table->entries[i].wck_ratio; 1820 1821 /* Clocks independent of voltage level. */ 1822 clock_limits[i].dispclk_mhz = max_dispclk_mhz ? max_dispclk_mhz : 1823 dcn3_1_soc.clock_limits[closest_clk_lvl].dispclk_mhz; 1824 1825 clock_limits[i].dppclk_mhz = max_dppclk_mhz ? max_dppclk_mhz : 1826 dcn3_1_soc.clock_limits[closest_clk_lvl].dppclk_mhz; 1827 1828 clock_limits[i].dram_bw_per_chan_gbps = dcn3_1_soc.clock_limits[closest_clk_lvl].dram_bw_per_chan_gbps; 1829 clock_limits[i].dscclk_mhz = dcn3_1_soc.clock_limits[closest_clk_lvl].dscclk_mhz; 1830 clock_limits[i].dtbclk_mhz = dcn3_1_soc.clock_limits[closest_clk_lvl].dtbclk_mhz; 1831 clock_limits[i].phyclk_d18_mhz = dcn3_1_soc.clock_limits[closest_clk_lvl].phyclk_d18_mhz; 1832 clock_limits[i].phyclk_mhz = dcn3_1_soc.clock_limits[closest_clk_lvl].phyclk_mhz; 1833 } 1834 for (i = 0; i < clk_table->num_entries; i++) 1835 dcn3_1_soc.clock_limits[i] = clock_limits[i]; 1836 if (clk_table->num_entries) { 1837 dcn3_1_soc.num_states = clk_table->num_entries; 1838 } 1839 } 1840 1841 dcn3_1_soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0; 1842 dc->dml.soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0; 1843 1844 if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) 1845 dml_init_instance(&dc->dml, &dcn3_1_soc, &dcn3_1_ip, DML_PROJECT_DCN31); 1846 else 1847 dml_init_instance(&dc->dml, &dcn3_1_soc, &dcn3_1_ip, DML_PROJECT_DCN31_FPGA); 1848 } 1849 1850 static struct resource_funcs dcn31_res_pool_funcs = { 1851 .destroy = dcn31_destroy_resource_pool, 1852 .link_enc_create = dcn31_link_encoder_create, 1853 .link_enc_create_minimal = dcn31_link_enc_create_minimal, 1854 .link_encs_assign = link_enc_cfg_link_encs_assign, 1855 .link_enc_unassign = link_enc_cfg_link_enc_unassign, 1856 .panel_cntl_create = dcn31_panel_cntl_create, 1857 .validate_bandwidth = dcn30_validate_bandwidth, 1858 .calculate_wm_and_dlg = dcn31_calculate_wm_and_dlg, 1859 .update_soc_for_wm_a = dcn31_update_soc_for_wm_a, 1860 .populate_dml_pipes = dcn31_populate_dml_pipes_from_context, 1861 .acquire_idle_pipe_for_layer = dcn20_acquire_idle_pipe_for_layer, 1862 .add_stream_to_ctx = dcn30_add_stream_to_ctx, 1863 .add_dsc_to_stream_resource = dcn20_add_dsc_to_stream_resource, 1864 .remove_stream_from_ctx = dcn20_remove_stream_from_ctx, 1865 .populate_dml_writeback_from_context = dcn30_populate_dml_writeback_from_context, 1866 .set_mcif_arb_params = dcn30_set_mcif_arb_params, 1867 .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link, 1868 .acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut, 1869 .release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut, 1870 .update_bw_bounding_box = dcn31_update_bw_bounding_box, 1871 .patch_unknown_plane_state = dcn20_patch_unknown_plane_state, 1872 }; 1873 1874 static struct clock_source *dcn30_clock_source_create( 1875 struct dc_context *ctx, 1876 struct dc_bios *bios, 1877 enum clock_source_id id, 1878 const struct dce110_clk_src_regs *regs, 1879 bool dp_clk_src) 1880 { 1881 struct dce110_clk_src *clk_src = 1882 kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL); 1883 1884 if (!clk_src) 1885 return NULL; 1886 1887 if (dcn3_clk_src_construct(clk_src, ctx, bios, id, 1888 regs, &cs_shift, &cs_mask)) { 1889 clk_src->base.dp_clk_src = dp_clk_src; 1890 return &clk_src->base; 1891 } 1892 1893 BREAK_TO_DEBUGGER(); 1894 return NULL; 1895 } 1896 1897 static bool dcn31_resource_construct( 1898 uint8_t num_virtual_links, 1899 struct dc *dc, 1900 struct dcn31_resource_pool *pool) 1901 { 1902 int i; 1903 struct dc_context *ctx = dc->ctx; 1904 struct irq_service_init_data init_data; 1905 1906 DC_FP_START(); 1907 1908 ctx->dc_bios->regs = &bios_regs; 1909 1910 pool->base.res_cap = &res_cap_dcn31; 1911 1912 pool->base.funcs = &dcn31_res_pool_funcs; 1913 1914 /************************************************* 1915 * Resource + asic cap harcoding * 1916 *************************************************/ 1917 pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE; 1918 pool->base.pipe_count = pool->base.res_cap->num_timing_generator; 1919 pool->base.mpcc_count = pool->base.res_cap->num_timing_generator; 1920 dc->caps.max_downscale_ratio = 600; 1921 dc->caps.i2c_speed_in_khz = 100; 1922 dc->caps.i2c_speed_in_khz_hdcp = 5; /*1.4 w/a applied by default*/ 1923 dc->caps.max_cursor_size = 256; 1924 dc->caps.min_horizontal_blanking_period = 80; 1925 dc->caps.dmdata_alloc_size = 2048; 1926 1927 dc->caps.max_slave_planes = 1; 1928 dc->caps.max_slave_yuv_planes = 1; 1929 dc->caps.max_slave_rgb_planes = 1; 1930 dc->caps.post_blend_color_processing = true; 1931 dc->caps.force_dp_tps4_for_cp2520 = true; 1932 dc->caps.extended_aux_timeout_support = true; 1933 dc->caps.dmcub_support = true; 1934 dc->caps.is_apu = true; 1935 1936 /* Color pipeline capabilities */ 1937 dc->caps.color.dpp.dcn_arch = 1; 1938 dc->caps.color.dpp.input_lut_shared = 0; 1939 dc->caps.color.dpp.icsc = 1; 1940 dc->caps.color.dpp.dgam_ram = 0; // must use gamma_corr 1941 dc->caps.color.dpp.dgam_rom_caps.srgb = 1; 1942 dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1; 1943 dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 1; 1944 dc->caps.color.dpp.dgam_rom_caps.pq = 1; 1945 dc->caps.color.dpp.dgam_rom_caps.hlg = 1; 1946 dc->caps.color.dpp.post_csc = 1; 1947 dc->caps.color.dpp.gamma_corr = 1; 1948 dc->caps.color.dpp.dgam_rom_for_yuv = 0; 1949 1950 dc->caps.color.dpp.hw_3d_lut = 1; 1951 dc->caps.color.dpp.ogam_ram = 1; 1952 // no OGAM ROM on DCN301 1953 dc->caps.color.dpp.ogam_rom_caps.srgb = 0; 1954 dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0; 1955 dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0; 1956 dc->caps.color.dpp.ogam_rom_caps.pq = 0; 1957 dc->caps.color.dpp.ogam_rom_caps.hlg = 0; 1958 dc->caps.color.dpp.ocsc = 0; 1959 1960 dc->caps.color.mpc.gamut_remap = 1; 1961 dc->caps.color.mpc.num_3dluts = pool->base.res_cap->num_mpc_3dlut; //2 1962 dc->caps.color.mpc.ogam_ram = 1; 1963 dc->caps.color.mpc.ogam_rom_caps.srgb = 0; 1964 dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0; 1965 dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0; 1966 dc->caps.color.mpc.ogam_rom_caps.pq = 0; 1967 dc->caps.color.mpc.ogam_rom_caps.hlg = 0; 1968 dc->caps.color.mpc.ocsc = 1; 1969 1970 /* read VBIOS LTTPR caps */ 1971 { 1972 if (ctx->dc_bios->funcs->get_lttpr_caps) { 1973 enum bp_result bp_query_result; 1974 uint8_t is_vbios_lttpr_enable = 0; 1975 1976 bp_query_result = ctx->dc_bios->funcs->get_lttpr_caps(ctx->dc_bios, &is_vbios_lttpr_enable); 1977 dc->caps.vbios_lttpr_enable = (bp_query_result == BP_RESULT_OK) && !!is_vbios_lttpr_enable; 1978 } 1979 1980 /* interop bit is implicit */ 1981 { 1982 dc->caps.vbios_lttpr_aware = true; 1983 } 1984 } 1985 1986 if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV) 1987 dc->debug = debug_defaults_drv; 1988 else if (dc->ctx->dce_environment == DCE_ENV_FPGA_MAXIMUS) { 1989 dc->debug = debug_defaults_diags; 1990 } else 1991 dc->debug = debug_defaults_diags; 1992 // Init the vm_helper 1993 if (dc->vm_helper) 1994 vm_helper_init(dc->vm_helper, 16); 1995 1996 /************************************************* 1997 * Create resources * 1998 *************************************************/ 1999 2000 /* Clock Sources for Pixel Clock*/ 2001 pool->base.clock_sources[DCN31_CLK_SRC_PLL0] = 2002 dcn30_clock_source_create(ctx, ctx->dc_bios, 2003 CLOCK_SOURCE_COMBO_PHY_PLL0, 2004 &clk_src_regs[0], false); 2005 pool->base.clock_sources[DCN31_CLK_SRC_PLL1] = 2006 dcn30_clock_source_create(ctx, ctx->dc_bios, 2007 CLOCK_SOURCE_COMBO_PHY_PLL1, 2008 &clk_src_regs[1], false); 2009 pool->base.clock_sources[DCN31_CLK_SRC_PLL2] = 2010 dcn30_clock_source_create(ctx, ctx->dc_bios, 2011 CLOCK_SOURCE_COMBO_PHY_PLL2, 2012 &clk_src_regs[2], false); 2013 pool->base.clock_sources[DCN31_CLK_SRC_PLL3] = 2014 dcn30_clock_source_create(ctx, ctx->dc_bios, 2015 CLOCK_SOURCE_COMBO_PHY_PLL3, 2016 &clk_src_regs[3], false); 2017 pool->base.clock_sources[DCN31_CLK_SRC_PLL4] = 2018 dcn30_clock_source_create(ctx, ctx->dc_bios, 2019 CLOCK_SOURCE_COMBO_PHY_PLL4, 2020 &clk_src_regs[4], false); 2021 2022 pool->base.clk_src_count = DCN30_CLK_SRC_TOTAL; 2023 2024 /* todo: not reuse phy_pll registers */ 2025 pool->base.dp_clock_source = 2026 dcn31_clock_source_create(ctx, ctx->dc_bios, 2027 CLOCK_SOURCE_ID_DP_DTO, 2028 &clk_src_regs[0], true); 2029 2030 for (i = 0; i < pool->base.clk_src_count; i++) { 2031 if (pool->base.clock_sources[i] == NULL) { 2032 dm_error("DC: failed to create clock sources!\n"); 2033 BREAK_TO_DEBUGGER(); 2034 goto create_fail; 2035 } 2036 } 2037 2038 /* TODO: DCCG */ 2039 pool->base.dccg = dccg31_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask); 2040 if (pool->base.dccg == NULL) { 2041 dm_error("DC: failed to create dccg!\n"); 2042 BREAK_TO_DEBUGGER(); 2043 goto create_fail; 2044 } 2045 2046 /* TODO: IRQ */ 2047 init_data.ctx = dc->ctx; 2048 pool->base.irqs = dal_irq_service_dcn31_create(&init_data); 2049 if (!pool->base.irqs) 2050 goto create_fail; 2051 2052 /* HUBBUB */ 2053 pool->base.hubbub = dcn31_hubbub_create(ctx); 2054 if (pool->base.hubbub == NULL) { 2055 BREAK_TO_DEBUGGER(); 2056 dm_error("DC: failed to create hubbub!\n"); 2057 goto create_fail; 2058 } 2059 2060 /* HUBPs, DPPs, OPPs and TGs */ 2061 for (i = 0; i < pool->base.pipe_count; i++) { 2062 pool->base.hubps[i] = dcn31_hubp_create(ctx, i); 2063 if (pool->base.hubps[i] == NULL) { 2064 BREAK_TO_DEBUGGER(); 2065 dm_error( 2066 "DC: failed to create hubps!\n"); 2067 goto create_fail; 2068 } 2069 2070 pool->base.dpps[i] = dcn31_dpp_create(ctx, i); 2071 if (pool->base.dpps[i] == NULL) { 2072 BREAK_TO_DEBUGGER(); 2073 dm_error( 2074 "DC: failed to create dpps!\n"); 2075 goto create_fail; 2076 } 2077 } 2078 2079 for (i = 0; i < pool->base.res_cap->num_opp; i++) { 2080 pool->base.opps[i] = dcn31_opp_create(ctx, i); 2081 if (pool->base.opps[i] == NULL) { 2082 BREAK_TO_DEBUGGER(); 2083 dm_error( 2084 "DC: failed to create output pixel processor!\n"); 2085 goto create_fail; 2086 } 2087 } 2088 2089 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) { 2090 pool->base.timing_generators[i] = dcn31_timing_generator_create( 2091 ctx, i); 2092 if (pool->base.timing_generators[i] == NULL) { 2093 BREAK_TO_DEBUGGER(); 2094 dm_error("DC: failed to create tg!\n"); 2095 goto create_fail; 2096 } 2097 } 2098 pool->base.timing_generator_count = i; 2099 2100 /* PSR */ 2101 pool->base.psr = dmub_psr_create(ctx); 2102 if (pool->base.psr == NULL) { 2103 dm_error("DC: failed to create psr obj!\n"); 2104 BREAK_TO_DEBUGGER(); 2105 goto create_fail; 2106 } 2107 2108 /* ABM */ 2109 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) { 2110 pool->base.multiple_abms[i] = dmub_abm_create(ctx, 2111 &abm_regs[i], 2112 &abm_shift, 2113 &abm_mask); 2114 if (pool->base.multiple_abms[i] == NULL) { 2115 dm_error("DC: failed to create abm for pipe %d!\n", i); 2116 BREAK_TO_DEBUGGER(); 2117 goto create_fail; 2118 } 2119 } 2120 2121 /* MPC and DSC */ 2122 pool->base.mpc = dcn31_mpc_create(ctx, pool->base.mpcc_count, pool->base.res_cap->num_mpc_3dlut); 2123 if (pool->base.mpc == NULL) { 2124 BREAK_TO_DEBUGGER(); 2125 dm_error("DC: failed to create mpc!\n"); 2126 goto create_fail; 2127 } 2128 2129 for (i = 0; i < pool->base.res_cap->num_dsc; i++) { 2130 pool->base.dscs[i] = dcn31_dsc_create(ctx, i); 2131 if (pool->base.dscs[i] == NULL) { 2132 BREAK_TO_DEBUGGER(); 2133 dm_error("DC: failed to create display stream compressor %d!\n", i); 2134 goto create_fail; 2135 } 2136 } 2137 2138 /* DWB and MMHUBBUB */ 2139 if (!dcn31_dwbc_create(ctx, &pool->base)) { 2140 BREAK_TO_DEBUGGER(); 2141 dm_error("DC: failed to create dwbc!\n"); 2142 goto create_fail; 2143 } 2144 2145 if (!dcn31_mmhubbub_create(ctx, &pool->base)) { 2146 BREAK_TO_DEBUGGER(); 2147 dm_error("DC: failed to create mcif_wb!\n"); 2148 goto create_fail; 2149 } 2150 2151 /* AUX and I2C */ 2152 for (i = 0; i < pool->base.res_cap->num_ddc; i++) { 2153 pool->base.engines[i] = dcn31_aux_engine_create(ctx, i); 2154 if (pool->base.engines[i] == NULL) { 2155 BREAK_TO_DEBUGGER(); 2156 dm_error( 2157 "DC:failed to create aux engine!!\n"); 2158 goto create_fail; 2159 } 2160 pool->base.hw_i2cs[i] = dcn31_i2c_hw_create(ctx, i); 2161 if (pool->base.hw_i2cs[i] == NULL) { 2162 BREAK_TO_DEBUGGER(); 2163 dm_error( 2164 "DC:failed to create hw i2c!!\n"); 2165 goto create_fail; 2166 } 2167 pool->base.sw_i2cs[i] = NULL; 2168 } 2169 2170 /* Audio, Stream Encoders including HPO and virtual, MPC 3D LUTs */ 2171 if (!resource_construct(num_virtual_links, dc, &pool->base, 2172 (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ? 2173 &res_create_funcs : &res_create_maximus_funcs))) 2174 goto create_fail; 2175 2176 /* HW Sequencer and Plane caps */ 2177 dcn31_hw_sequencer_construct(dc); 2178 2179 dc->caps.max_planes = pool->base.pipe_count; 2180 2181 for (i = 0; i < dc->caps.max_planes; ++i) 2182 dc->caps.planes[i] = plane_cap; 2183 2184 dc->cap_funcs = cap_funcs; 2185 2186 DC_FP_END(); 2187 2188 return true; 2189 2190 create_fail: 2191 2192 DC_FP_END(); 2193 dcn31_resource_destruct(pool); 2194 2195 return false; 2196 } 2197 2198 struct resource_pool *dcn31_create_resource_pool( 2199 const struct dc_init_data *init_data, 2200 struct dc *dc) 2201 { 2202 struct dcn31_resource_pool *pool = 2203 kzalloc(sizeof(struct dcn31_resource_pool), GFP_KERNEL); 2204 2205 if (!pool) 2206 return NULL; 2207 2208 if (dcn31_resource_construct(init_data->num_virtual_links, dc, pool)) 2209 return &pool->base; 2210 2211 BREAK_TO_DEBUGGER(); 2212 kfree(pool); 2213 return NULL; 2214 } 2215