1 // SPDX-License-Identifier: MIT
3 * Copyright 2022 Advanced Micro Devices, Inc.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
28 #include "dm_services.h"
31 #include "dcn31/dcn31_init.h"
32 #include "dcn314/dcn314_init.h"
35 #include "include/irq_service_interface.h"
36 #include "dcn314_resource.h"
38 #include "dcn20/dcn20_resource.h"
39 #include "dcn30/dcn30_resource.h"
40 #include "dcn31/dcn31_resource.h"
42 #include "dcn10/dcn10_ipp.h"
43 #include "dcn30/dcn30_hubbub.h"
44 #include "dcn31/dcn31_hubbub.h"
45 #include "dcn30/dcn30_mpc.h"
46 #include "dcn31/dcn31_hubp.h"
47 #include "irq/dcn31/irq_service_dcn31.h"
48 #include "irq/dcn314/irq_service_dcn314.h"
49 #include "dcn30/dcn30_dpp.h"
50 #include "dcn314/dcn314_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 "dcn31/dcn31_dio_link_encoder.h"
59 #include "dcn314/dcn314_dio_stream_encoder.h"
60 #include "dcn31/dcn31_hpo_dp_stream_encoder.h"
61 #include "dcn31/dcn31_hpo_dp_link_encoder.h"
62 #include "dcn31/dcn31_apg.h"
63 #include "dcn31/dcn31_vpg.h"
64 #include "dcn31/dcn31_afmt.h"
65 #include "dce/dce_clock_source.h"
66 #include "dce/dce_audio.h"
67 #include "dce/dce_hwseq.h"
69 #include "virtual/virtual_stream_encoder.h"
70 #include "dce110/dce110_resource.h"
71 #include "dml/display_mode_vba.h"
72 #include "dml/dcn31/dcn31_fpu.h"
73 #include "dcn314/dcn314_dccg.h"
74 #include "dcn10/dcn10_resource.h"
75 #include "dcn31/dcn31_panel_cntl.h"
76 #include "dcn314/dcn314_hwseq.h"
78 #include "dcn30/dcn30_dwb.h"
79 #include "dcn30/dcn30_mmhubbub.h"
81 #include "dcn/dcn_3_1_4_offset.h"
82 #include "dcn/dcn_3_1_4_sh_mask.h"
83 #include "dpcs/dpcs_3_1_4_offset.h"
84 #include "dpcs/dpcs_3_1_4_sh_mask.h"
86 #define DCHUBBUB_DEBUG_CTRL_0__DET_DEPTH__SHIFT 0x10
87 #define DCHUBBUB_DEBUG_CTRL_0__DET_DEPTH_MASK 0x01FF0000L
89 #include "reg_helper.h"
90 #include "dce/dmub_abm.h"
91 #include "dce/dmub_psr.h"
92 #include "dce/dce_aux.h"
93 #include "dce/dce_i2c.h"
94 #include "dml/dcn314/display_mode_vba_314.h"
95 #include "vm_helper.h"
96 #include "dcn20/dcn20_vmid.h"
98 #include "link_enc_cfg.h"
100 #define DCN_BASE__INST0_SEG1 0x000000C0
101 #define DCN_BASE__INST0_SEG2 0x000034C0
102 #define DCN_BASE__INST0_SEG3 0x00009000
104 #define NBIO_BASE__INST0_SEG1 0x00000014
106 #define MAX_INSTANCE 7
107 #define MAX_SEGMENT 8
109 #define regBIF_BX2_BIOS_SCRATCH_2 0x003a
110 #define regBIF_BX2_BIOS_SCRATCH_2_BASE_IDX 1
111 #define regBIF_BX2_BIOS_SCRATCH_3 0x003b
112 #define regBIF_BX2_BIOS_SCRATCH_3_BASE_IDX 1
113 #define regBIF_BX2_BIOS_SCRATCH_6 0x003e
114 #define regBIF_BX2_BIOS_SCRATCH_6_BASE_IDX 1
116 struct IP_BASE_INSTANCE {
117 unsigned int segment[MAX_SEGMENT];
121 struct IP_BASE_INSTANCE instance[MAX_INSTANCE];
124 static const struct IP_BASE DCN_BASE = { { { { 0x00000012, 0x000000C0, 0x000034C0, 0x00009000, 0x02403C00, 0, 0, 0 } },
125 { { 0, 0, 0, 0, 0, 0, 0, 0 } },
126 { { 0, 0, 0, 0, 0, 0, 0, 0 } },
127 { { 0, 0, 0, 0, 0, 0, 0, 0 } },
128 { { 0, 0, 0, 0, 0, 0, 0, 0 } },
129 { { 0, 0, 0, 0, 0, 0, 0, 0 } },
130 { { 0, 0, 0, 0, 0, 0, 0, 0 } } } };
133 #define DC_LOGGER_INIT(logger)
135 #define DCN3_14_DEFAULT_DET_SIZE 384
136 #define DCN3_14_MAX_DET_SIZE 384
137 #define DCN3_14_MIN_COMPBUF_SIZE_KB 128
138 #define DCN3_14_CRB_SEGMENT_SIZE_KB 64
139 struct _vcs_dpi_ip_params_st dcn3_14_ip = {
140 .VBlankNomDefaultUS = 668,
142 .gpuvm_max_page_table_levels = 1,
144 .hostvm_max_page_table_levels = 2,
145 .rob_buffer_size_kbytes = 64,
146 .det_buffer_size_kbytes = DCN3_14_DEFAULT_DET_SIZE,
147 .config_return_buffer_size_in_kbytes = 1792,
148 .compressed_buffer_segment_size_in_kbytes = 64,
149 .meta_fifo_size_in_kentries = 32,
150 .zero_size_buffer_entries = 512,
151 .compbuf_reserved_space_64b = 256,
152 .compbuf_reserved_space_zs = 64,
153 .dpp_output_buffer_pixels = 2560,
154 .opp_output_buffer_lines = 1,
155 .pixel_chunk_size_kbytes = 8,
156 .meta_chunk_size_kbytes = 2,
157 .min_meta_chunk_size_bytes = 256,
158 .writeback_chunk_size_kbytes = 8,
159 .ptoi_supported = false,
161 .maximum_dsc_bits_per_component = 10,
162 .dsc422_native_support = false,
163 .is_line_buffer_bpp_fixed = true,
164 .line_buffer_fixed_bpp = 48,
165 .line_buffer_size_bits = 789504,
166 .max_line_buffer_lines = 12,
167 .writeback_interface_buffer_size_kbytes = 90,
170 .max_num_hdmi_frl_outputs = 1,
172 .max_dchub_pscl_bw_pix_per_clk = 4,
173 .max_pscl_lb_bw_pix_per_clk = 2,
174 .max_lb_vscl_bw_pix_per_clk = 4,
175 .max_vscl_hscl_bw_pix_per_clk = 4,
180 .dpte_buffer_size_in_pte_reqs_luma = 64,
181 .dpte_buffer_size_in_pte_reqs_chroma = 34,
182 .dispclk_ramp_margin_percent = 1,
183 .max_inter_dcn_tile_repeaters = 8,
184 .cursor_buffer_size = 16,
185 .cursor_chunk_size = 2,
186 .writeback_line_buffer_buffer_size = 0,
187 .writeback_min_hscl_ratio = 1,
188 .writeback_min_vscl_ratio = 1,
189 .writeback_max_hscl_ratio = 1,
190 .writeback_max_vscl_ratio = 1,
191 .writeback_max_hscl_taps = 1,
192 .writeback_max_vscl_taps = 1,
193 .dppclk_delay_subtotal = 46,
194 .dppclk_delay_scl = 50,
195 .dppclk_delay_scl_lb_only = 16,
196 .dppclk_delay_cnvc_formatter = 27,
197 .dppclk_delay_cnvc_cursor = 6,
198 .dispclk_delay_subtotal = 119,
199 .dynamic_metadata_vm_enabled = false,
200 .odm_combine_4to1_supported = false,
201 .dcc_supported = true,
204 struct _vcs_dpi_soc_bounding_box_st dcn3_14_soc = {
205 /*TODO: correct dispclk/dppclk voltage level determination*/
209 .dispclk_mhz = 1200.0,
210 .dppclk_mhz = 1200.0,
212 .phyclk_d18_mhz = 667.0,
218 .dispclk_mhz = 1200.0,
219 .dppclk_mhz = 1200.0,
221 .phyclk_d18_mhz = 667.0,
227 .dispclk_mhz = 1200.0,
228 .dppclk_mhz = 1200.0,
230 .phyclk_d18_mhz = 667.0,
236 .dispclk_mhz = 1200.0,
237 .dppclk_mhz = 1200.0,
239 .phyclk_d18_mhz = 667.0,
245 .dispclk_mhz = 1200.0,
246 .dppclk_mhz = 1200.0,
248 .phyclk_d18_mhz = 667.0,
254 .sr_exit_time_us = 9.0,
255 .sr_enter_plus_exit_time_us = 11.0,
256 .sr_exit_z8_time_us = 442.0,
257 .sr_enter_plus_exit_z8_time_us = 560.0,
258 .writeback_latency_us = 12.0,
259 .dram_channel_width_bytes = 4,
260 .round_trip_ping_latency_dcfclk_cycles = 106,
261 .urgent_latency_pixel_data_only_us = 4.0,
262 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
263 .urgent_latency_vm_data_only_us = 4.0,
264 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
265 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
266 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
267 .pct_ideal_sdp_bw_after_urgent = 80.0,
268 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 65.0,
269 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 60.0,
270 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 30.0,
271 .max_avg_sdp_bw_use_normal_percent = 60.0,
272 .max_avg_dram_bw_use_normal_percent = 60.0,
273 .fabric_datapath_to_dcn_data_return_bytes = 32,
274 .return_bus_width_bytes = 64,
275 .downspread_percent = 0.38,
276 .dcn_downspread_percent = 0.5,
277 .gpuvm_min_page_size_bytes = 4096,
278 .hostvm_min_page_size_bytes = 4096,
279 .do_urgent_latency_adjustment = false,
280 .urgent_latency_adjustment_fabric_clock_component_us = 0,
281 .urgent_latency_adjustment_fabric_clock_reference_mhz = 0,
284 enum dcn31_clk_src_array_id {
293 /* begin *********************
294 * macros to expend register list macro defined in HW object header file
298 /* TODO awful hack. fixup dcn20_dwb.h */
300 #define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg
302 #define BASE(seg) BASE_INNER(seg)
304 #define SR(reg_name)\
305 .reg_name = BASE(reg ## reg_name ## _BASE_IDX) + \
308 #define SRI(reg_name, block, id)\
309 .reg_name = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
310 reg ## block ## id ## _ ## reg_name
312 #define SRI2(reg_name, block, id)\
313 .reg_name = BASE(reg ## reg_name ## _BASE_IDX) + \
316 #define SRIR(var_name, reg_name, block, id)\
317 .var_name = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
318 reg ## block ## id ## _ ## reg_name
320 #define SRII(reg_name, block, id)\
321 .reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
322 reg ## block ## id ## _ ## reg_name
324 #define SRII_MPC_RMU(reg_name, block, id)\
325 .RMU##_##reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
326 reg ## block ## id ## _ ## reg_name
328 #define SRII_DWB(reg_name, temp_name, block, id)\
329 .reg_name[id] = BASE(reg ## block ## id ## _ ## temp_name ## _BASE_IDX) + \
330 reg ## block ## id ## _ ## temp_name
332 #define DCCG_SRII(reg_name, block, id)\
333 .block ## _ ## reg_name[id] = BASE(reg ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
334 reg ## block ## id ## _ ## reg_name
336 #define VUPDATE_SRII(reg_name, block, id)\
337 .reg_name[id] = BASE(reg ## reg_name ## _ ## block ## id ## _BASE_IDX) + \
338 reg ## reg_name ## _ ## block ## id
341 #define NBIO_BASE_INNER(seg) \
342 NBIO_BASE__INST0_SEG ## seg
344 #define NBIO_BASE(seg) \
347 #define NBIO_SR(reg_name)\
348 .reg_name = NBIO_BASE(regBIF_BX2_ ## reg_name ## _BASE_IDX) + \
349 regBIF_BX2_ ## reg_name
352 #define MMHUB_BASE_INNER(seg) \
353 MMHUB_BASE__INST0_SEG ## seg
355 #define MMHUB_BASE(seg) \
356 MMHUB_BASE_INNER(seg)
358 #define MMHUB_SR(reg_name)\
359 .reg_name = MMHUB_BASE(reg ## reg_name ## _BASE_IDX) + \
363 #define CLK_BASE_INNER(seg) \
364 CLK_BASE__INST0_SEG ## seg
366 #define CLK_BASE(seg) \
369 #define CLK_SRI(reg_name, block, inst)\
370 .reg_name = CLK_BASE(reg ## block ## _ ## inst ## _ ## reg_name ## _BASE_IDX) + \
371 reg ## block ## _ ## inst ## _ ## reg_name
374 static const struct bios_registers bios_regs = {
375 NBIO_SR(BIOS_SCRATCH_3),
376 NBIO_SR(BIOS_SCRATCH_6)
379 #define clk_src_regs(index, pllid)\
381 CS_COMMON_REG_LIST_DCN3_0(index, pllid),\
384 static const struct dce110_clk_src_regs clk_src_regs[] = {
392 static const struct dce110_clk_src_shift cs_shift = {
393 CS_COMMON_MASK_SH_LIST_DCN3_1_4(__SHIFT)
396 static const struct dce110_clk_src_mask cs_mask = {
397 CS_COMMON_MASK_SH_LIST_DCN3_1_4(_MASK)
400 #define abm_regs(id)\
402 ABM_DCN302_REG_LIST(id)\
405 static const struct dce_abm_registers abm_regs[] = {
412 static const struct dce_abm_shift abm_shift = {
413 ABM_MASK_SH_LIST_DCN30(__SHIFT)
416 static const struct dce_abm_mask abm_mask = {
417 ABM_MASK_SH_LIST_DCN30(_MASK)
420 #define audio_regs(id)\
422 AUD_COMMON_REG_LIST(id)\
425 static const struct dce_audio_registers audio_regs[] = {
435 #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
436 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\
437 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\
438 AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)
440 static const struct dce_audio_shift audio_shift = {
441 DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT)
444 static const struct dce_audio_mask audio_mask = {
445 DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)
448 #define vpg_regs(id)\
450 VPG_DCN31_REG_LIST(id)\
453 static const struct dcn31_vpg_registers vpg_regs[] = {
466 static const struct dcn31_vpg_shift vpg_shift = {
467 DCN31_VPG_MASK_SH_LIST(__SHIFT)
470 static const struct dcn31_vpg_mask vpg_mask = {
471 DCN31_VPG_MASK_SH_LIST(_MASK)
474 #define afmt_regs(id)\
476 AFMT_DCN31_REG_LIST(id)\
479 static const struct dcn31_afmt_registers afmt_regs[] = {
488 static const struct dcn31_afmt_shift afmt_shift = {
489 DCN31_AFMT_MASK_SH_LIST(__SHIFT)
492 static const struct dcn31_afmt_mask afmt_mask = {
493 DCN31_AFMT_MASK_SH_LIST(_MASK)
496 #define apg_regs(id)\
498 APG_DCN31_REG_LIST(id)\
501 static const struct dcn31_apg_registers apg_regs[] = {
508 static const struct dcn31_apg_shift apg_shift = {
509 DCN31_APG_MASK_SH_LIST(__SHIFT)
512 static const struct dcn31_apg_mask apg_mask = {
513 DCN31_APG_MASK_SH_LIST(_MASK)
516 #define stream_enc_regs(id)\
518 SE_DCN314_REG_LIST(id)\
521 static const struct dcn10_stream_enc_registers stream_enc_regs[] = {
529 static const struct dcn10_stream_encoder_shift se_shift = {
530 SE_COMMON_MASK_SH_LIST_DCN314(__SHIFT)
533 static const struct dcn10_stream_encoder_mask se_mask = {
534 SE_COMMON_MASK_SH_LIST_DCN314(_MASK)
538 #define aux_regs(id)\
540 DCN2_AUX_REG_LIST(id)\
543 static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = {
551 #define hpd_regs(id)\
556 static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {
564 #define link_regs(id, phyid)\
566 LE_DCN31_REG_LIST(id), \
567 UNIPHY_DCN2_REG_LIST(phyid), \
570 static const struct dce110_aux_registers_shift aux_shift = {
571 DCN_AUX_MASK_SH_LIST(__SHIFT)
574 static const struct dce110_aux_registers_mask aux_mask = {
575 DCN_AUX_MASK_SH_LIST(_MASK)
578 static const struct dcn10_link_enc_registers link_enc_regs[] = {
586 static const struct dcn10_link_enc_shift le_shift = {
587 LINK_ENCODER_MASK_SH_LIST_DCN31(__SHIFT),
588 DPCS_DCN31_MASK_SH_LIST(__SHIFT)
591 static const struct dcn10_link_enc_mask le_mask = {
592 LINK_ENCODER_MASK_SH_LIST_DCN31(_MASK),
593 DPCS_DCN31_MASK_SH_LIST(_MASK)
596 #define hpo_dp_stream_encoder_reg_list(id)\
598 DCN3_1_HPO_DP_STREAM_ENC_REG_LIST(id)\
601 static const struct dcn31_hpo_dp_stream_encoder_registers hpo_dp_stream_enc_regs[] = {
602 hpo_dp_stream_encoder_reg_list(0),
603 hpo_dp_stream_encoder_reg_list(1),
604 hpo_dp_stream_encoder_reg_list(2),
607 static const struct dcn31_hpo_dp_stream_encoder_shift hpo_dp_se_shift = {
608 DCN3_1_HPO_DP_STREAM_ENC_MASK_SH_LIST(__SHIFT)
611 static const struct dcn31_hpo_dp_stream_encoder_mask hpo_dp_se_mask = {
612 DCN3_1_HPO_DP_STREAM_ENC_MASK_SH_LIST(_MASK)
616 #define hpo_dp_link_encoder_reg_list(id)\
618 DCN3_1_HPO_DP_LINK_ENC_REG_LIST(id),\
619 DCN3_1_RDPCSTX_REG_LIST(0),\
620 DCN3_1_RDPCSTX_REG_LIST(1),\
621 DCN3_1_RDPCSTX_REG_LIST(2),\
624 static const struct dcn31_hpo_dp_link_encoder_registers hpo_dp_link_enc_regs[] = {
625 hpo_dp_link_encoder_reg_list(0),
626 hpo_dp_link_encoder_reg_list(1),
629 static const struct dcn31_hpo_dp_link_encoder_shift hpo_dp_le_shift = {
630 DCN3_1_HPO_DP_LINK_ENC_MASK_SH_LIST(__SHIFT)
633 static const struct dcn31_hpo_dp_link_encoder_mask hpo_dp_le_mask = {
634 DCN3_1_HPO_DP_LINK_ENC_MASK_SH_LIST(_MASK)
637 #define dpp_regs(id)\
639 DPP_REG_LIST_DCN30(id),\
642 static const struct dcn3_dpp_registers dpp_regs[] = {
649 static const struct dcn3_dpp_shift tf_shift = {
650 DPP_REG_LIST_SH_MASK_DCN30(__SHIFT)
653 static const struct dcn3_dpp_mask tf_mask = {
654 DPP_REG_LIST_SH_MASK_DCN30(_MASK)
657 #define opp_regs(id)\
659 OPP_REG_LIST_DCN30(id),\
662 static const struct dcn20_opp_registers opp_regs[] = {
669 static const struct dcn20_opp_shift opp_shift = {
670 OPP_MASK_SH_LIST_DCN20(__SHIFT)
673 static const struct dcn20_opp_mask opp_mask = {
674 OPP_MASK_SH_LIST_DCN20(_MASK)
677 #define aux_engine_regs(id)\
679 AUX_COMMON_REG_LIST0(id), \
682 .AUX_RESET_MASK = DP_AUX0_AUX_CONTROL__AUX_RESET_MASK, \
685 static const struct dce110_aux_registers aux_engine_regs[] = {
693 #define dwbc_regs_dcn3(id)\
695 DWBC_COMMON_REG_LIST_DCN30(id),\
698 static const struct dcn30_dwbc_registers dwbc30_regs[] = {
702 static const struct dcn30_dwbc_shift dwbc30_shift = {
703 DWBC_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
706 static const struct dcn30_dwbc_mask dwbc30_mask = {
707 DWBC_COMMON_MASK_SH_LIST_DCN30(_MASK)
710 #define mcif_wb_regs_dcn3(id)\
712 MCIF_WB_COMMON_REG_LIST_DCN30(id),\
715 static const struct dcn30_mmhubbub_registers mcif_wb30_regs[] = {
719 static const struct dcn30_mmhubbub_shift mcif_wb30_shift = {
720 MCIF_WB_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
723 static const struct dcn30_mmhubbub_mask mcif_wb30_mask = {
724 MCIF_WB_COMMON_MASK_SH_LIST_DCN30(_MASK)
727 #define dsc_regsDCN314(id)\
729 DSC_REG_LIST_DCN314(id)\
732 static const struct dcn20_dsc_registers dsc_regs[] = {
739 static const struct dcn20_dsc_shift dsc_shift = {
740 DSC_REG_LIST_SH_MASK_DCN314(__SHIFT)
743 static const struct dcn20_dsc_mask dsc_mask = {
744 DSC_REG_LIST_SH_MASK_DCN314(_MASK)
747 static const struct dcn30_mpc_registers mpc_regs = {
748 MPC_REG_LIST_DCN3_0(0),
749 MPC_REG_LIST_DCN3_0(1),
750 MPC_REG_LIST_DCN3_0(2),
751 MPC_REG_LIST_DCN3_0(3),
752 MPC_OUT_MUX_REG_LIST_DCN3_0(0),
753 MPC_OUT_MUX_REG_LIST_DCN3_0(1),
754 MPC_OUT_MUX_REG_LIST_DCN3_0(2),
755 MPC_OUT_MUX_REG_LIST_DCN3_0(3),
756 MPC_RMU_GLOBAL_REG_LIST_DCN3AG,
757 MPC_RMU_REG_LIST_DCN3AG(0),
758 MPC_RMU_REG_LIST_DCN3AG(1),
759 //MPC_RMU_REG_LIST_DCN3AG(2),
760 MPC_DWB_MUX_REG_LIST_DCN3_0(0),
763 static const struct dcn30_mpc_shift mpc_shift = {
764 MPC_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
767 static const struct dcn30_mpc_mask mpc_mask = {
768 MPC_COMMON_MASK_SH_LIST_DCN30(_MASK)
771 #define optc_regs(id)\
772 [id] = {OPTC_COMMON_REG_LIST_DCN3_14(id)}
774 static const struct dcn_optc_registers optc_regs[] = {
781 static const struct dcn_optc_shift optc_shift = {
782 OPTC_COMMON_MASK_SH_LIST_DCN3_14(__SHIFT)
785 static const struct dcn_optc_mask optc_mask = {
786 OPTC_COMMON_MASK_SH_LIST_DCN3_14(_MASK)
789 #define hubp_regs(id)\
791 HUBP_REG_LIST_DCN30(id)\
794 static const struct dcn_hubp2_registers hubp_regs[] = {
802 static const struct dcn_hubp2_shift hubp_shift = {
803 HUBP_MASK_SH_LIST_DCN31(__SHIFT)
806 static const struct dcn_hubp2_mask hubp_mask = {
807 HUBP_MASK_SH_LIST_DCN31(_MASK)
809 static const struct dcn_hubbub_registers hubbub_reg = {
810 HUBBUB_REG_LIST_DCN31(0)
813 static const struct dcn_hubbub_shift hubbub_shift = {
814 HUBBUB_MASK_SH_LIST_DCN31(__SHIFT)
817 static const struct dcn_hubbub_mask hubbub_mask = {
818 HUBBUB_MASK_SH_LIST_DCN31(_MASK)
821 static const struct dccg_registers dccg_regs = {
822 DCCG_REG_LIST_DCN314()
825 static const struct dccg_shift dccg_shift = {
826 DCCG_MASK_SH_LIST_DCN314(__SHIFT)
829 static const struct dccg_mask dccg_mask = {
830 DCCG_MASK_SH_LIST_DCN314(_MASK)
834 #define SRII2(reg_name_pre, reg_name_post, id)\
835 .reg_name_pre ## _ ## reg_name_post[id] = BASE(reg ## reg_name_pre \
836 ## id ## _ ## reg_name_post ## _BASE_IDX) + \
837 reg ## reg_name_pre ## id ## _ ## reg_name_post
840 #define HWSEQ_DCN31_REG_LIST()\
841 SR(DCHUBBUB_GLOBAL_TIMER_CNTL), \
842 SR(DCHUBBUB_ARB_HOSTVM_CNTL), \
843 SR(DIO_MEM_PWR_CTRL), \
844 SR(ODM_MEM_PWR_CTRL3), \
845 SR(DMU_MEM_PWR_CNTL), \
846 SR(MMHUBBUB_MEM_PWR_CNTL), \
847 SR(DCCG_GATE_DISABLE_CNTL), \
848 SR(DCCG_GATE_DISABLE_CNTL2), \
850 SR(DC_MEM_GLOBAL_PWR_REQ_CNTL), \
851 SRII(PIXEL_RATE_CNTL, OTG, 0), \
852 SRII(PIXEL_RATE_CNTL, OTG, 1),\
853 SRII(PIXEL_RATE_CNTL, OTG, 2),\
854 SRII(PIXEL_RATE_CNTL, OTG, 3),\
855 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 0),\
856 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 1),\
857 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 2),\
858 SRII(PHYPLL_PIXEL_RATE_CNTL, OTG, 3),\
859 SR(MICROSECOND_TIME_BASE_DIV), \
860 SR(MILLISECOND_TIME_BASE_DIV), \
861 SR(DISPCLK_FREQ_CHANGE_CNTL), \
862 SR(RBBMIF_TIMEOUT_DIS), \
863 SR(RBBMIF_TIMEOUT_DIS_2), \
864 SR(DCHUBBUB_CRC_CTRL), \
865 SR(DPP_TOP0_DPP_CRC_CTRL), \
866 SR(DPP_TOP0_DPP_CRC_VAL_B_A), \
867 SR(DPP_TOP0_DPP_CRC_VAL_R_G), \
869 SR(MPC_CRC_RESULT_GB), \
870 SR(MPC_CRC_RESULT_C), \
871 SR(MPC_CRC_RESULT_AR), \
872 SR(DOMAIN0_PG_CONFIG), \
873 SR(DOMAIN1_PG_CONFIG), \
874 SR(DOMAIN2_PG_CONFIG), \
875 SR(DOMAIN3_PG_CONFIG), \
876 SR(DOMAIN16_PG_CONFIG), \
877 SR(DOMAIN17_PG_CONFIG), \
878 SR(DOMAIN18_PG_CONFIG), \
879 SR(DOMAIN19_PG_CONFIG), \
880 SR(DOMAIN0_PG_STATUS), \
881 SR(DOMAIN1_PG_STATUS), \
882 SR(DOMAIN2_PG_STATUS), \
883 SR(DOMAIN3_PG_STATUS), \
884 SR(DOMAIN16_PG_STATUS), \
885 SR(DOMAIN17_PG_STATUS), \
886 SR(DOMAIN18_PG_STATUS), \
887 SR(DOMAIN19_PG_STATUS), \
894 SR(DC_IP_REQUEST_CNTL), \
895 SR(AZALIA_AUDIO_DTO), \
896 SR(AZALIA_CONTROLLER_CLOCK_GATING), \
897 SR(HPO_TOP_HW_CONTROL)
899 static const struct dce_hwseq_registers hwseq_reg = {
900 HWSEQ_DCN31_REG_LIST()
903 #define HWSEQ_DCN31_MASK_SH_LIST(mask_sh)\
904 HWSEQ_DCN_MASK_SH_LIST(mask_sh), \
905 HWS_SF(, DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, mask_sh), \
906 HWS_SF(, DCHUBBUB_ARB_HOSTVM_CNTL, DISABLE_HOSTVM_FORCE_ALLOW_PSTATE, mask_sh), \
907 HWS_SF(, DOMAIN0_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \
908 HWS_SF(, DOMAIN0_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \
909 HWS_SF(, DOMAIN1_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \
910 HWS_SF(, DOMAIN1_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \
911 HWS_SF(, DOMAIN2_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \
912 HWS_SF(, DOMAIN2_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \
913 HWS_SF(, DOMAIN3_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \
914 HWS_SF(, DOMAIN3_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \
915 HWS_SF(, DOMAIN16_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \
916 HWS_SF(, DOMAIN16_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \
917 HWS_SF(, DOMAIN17_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \
918 HWS_SF(, DOMAIN17_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \
919 HWS_SF(, DOMAIN18_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \
920 HWS_SF(, DOMAIN18_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \
921 HWS_SF(, DOMAIN19_PG_CONFIG, DOMAIN_POWER_FORCEON, mask_sh), \
922 HWS_SF(, DOMAIN19_PG_CONFIG, DOMAIN_POWER_GATE, mask_sh), \
923 HWS_SF(, DOMAIN0_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \
924 HWS_SF(, DOMAIN1_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \
925 HWS_SF(, DOMAIN2_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \
926 HWS_SF(, DOMAIN3_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \
927 HWS_SF(, DOMAIN16_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \
928 HWS_SF(, DOMAIN17_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \
929 HWS_SF(, DOMAIN18_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \
930 HWS_SF(, DOMAIN19_PG_STATUS, DOMAIN_PGFSM_PWR_STATUS, mask_sh), \
931 HWS_SF(, DC_IP_REQUEST_CNTL, IP_REQUEST_EN, mask_sh), \
932 HWS_SF(, AZALIA_AUDIO_DTO, AZALIA_AUDIO_DTO_MODULE, mask_sh), \
933 HWS_SF(, HPO_TOP_CLOCK_CONTROL, HPO_HDMISTREAMCLK_G_GATE_DIS, mask_sh), \
934 HWS_SF(, DMU_MEM_PWR_CNTL, DMCU_ERAM_MEM_PWR_FORCE, mask_sh), \
935 HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_UNASSIGNED_PWR_MODE, mask_sh), \
936 HWS_SF(, ODM_MEM_PWR_CTRL3, ODM_MEM_VBLANK_PWR_MODE, mask_sh), \
937 HWS_SF(, MMHUBBUB_MEM_PWR_CNTL, VGA_MEM_PWR_FORCE, mask_sh), \
938 HWS_SF(, DIO_MEM_PWR_CTRL, I2C_LIGHT_SLEEP_FORCE, mask_sh), \
939 HWS_SF(, HPO_TOP_HW_CONTROL, HPO_IO_EN, mask_sh)
941 static const struct dce_hwseq_shift hwseq_shift = {
942 HWSEQ_DCN31_MASK_SH_LIST(__SHIFT)
945 static const struct dce_hwseq_mask hwseq_mask = {
946 HWSEQ_DCN31_MASK_SH_LIST(_MASK)
948 #define vmid_regs(id)\
950 DCN20_VMID_REG_LIST(id)\
953 static const struct dcn_vmid_registers vmid_regs[] = {
972 static const struct dcn20_vmid_shift vmid_shifts = {
973 DCN20_VMID_MASK_SH_LIST(__SHIFT)
976 static const struct dcn20_vmid_mask vmid_masks = {
977 DCN20_VMID_MASK_SH_LIST(_MASK)
980 static const struct resource_caps res_cap_dcn314 = {
981 .num_timing_generator = 4,
983 .num_video_plane = 4,
985 .num_stream_encoder = 5,
986 .num_dig_link_enc = 5,
987 .num_hpo_dp_stream_encoder = 4,
988 .num_hpo_dp_link_encoder = 2,
997 static const struct dc_plane_cap plane_cap = {
998 .type = DC_PLANE_TYPE_DCN_UNIVERSAL,
999 .blends_with_above = true,
1000 .blends_with_below = true,
1001 .per_pixel_alpha = true,
1003 .pixel_format_support = {
1011 .max_upscale_factor = {
1017 // 6:1 downscaling ratio: 1000/6 = 166.666
1018 .max_downscale_factor = {
1027 static const struct dc_debug_options debug_defaults_drv = {
1028 .disable_z10 = true, /*hw not support it*/
1029 .disable_dmcu = true,
1030 .force_abm_enable = false,
1031 .timing_trace = false,
1032 .clock_trace = true,
1033 .disable_pplib_clock_request = false,
1034 .pipe_split_policy = MPC_SPLIT_DYNAMIC,
1035 .force_single_disp_pipe_split = false,
1036 .disable_dcc = DCC_ENABLE,
1037 .vsr_support = true,
1038 .performance_trace = false,
1039 .max_downscale_src_width = 4096,/*upto true 4k*/
1040 .disable_pplib_wm_range = false,
1041 .scl_reset_length10 = true,
1042 .sanity_checks = false,
1043 .underflow_assert_delay_us = 0xFFFFFFFF,
1044 .dwb_fi_phase = -1, // -1 = disable,
1045 .dmub_command_table = true,
1046 .pstate_enabled = true,
1048 .enable_mem_low_power = {
1052 .dmcu = false, // This is previously known to cause hang on S3 cycles if enabled
1061 .optimize_edp_link_rate = true,
1062 .enable_sw_cntl_psr = true,
1063 .seamless_boot_odm_combine = true
1066 static const struct dc_debug_options debug_defaults_diags = {
1067 .disable_dmcu = true,
1068 .force_abm_enable = false,
1069 .timing_trace = true,
1070 .clock_trace = true,
1071 .disable_dpp_power_gate = true,
1072 .disable_hubp_power_gate = true,
1073 .disable_clock_gate = true,
1074 .disable_pplib_clock_request = true,
1075 .disable_pplib_wm_range = true,
1076 .disable_stutter = false,
1077 .scl_reset_length10 = true,
1078 .dwb_fi_phase = -1, // -1 = disable
1079 .dmub_command_table = true,
1080 .enable_tri_buf = true,
1084 static void dcn31_dpp_destroy(struct dpp **dpp)
1086 kfree(TO_DCN20_DPP(*dpp));
1090 static struct dpp *dcn31_dpp_create(
1091 struct dc_context *ctx,
1094 struct dcn3_dpp *dpp =
1095 kzalloc(sizeof(struct dcn3_dpp), GFP_KERNEL);
1100 if (dpp3_construct(dpp, ctx, inst,
1101 &dpp_regs[inst], &tf_shift, &tf_mask))
1104 BREAK_TO_DEBUGGER();
1109 static struct output_pixel_processor *dcn31_opp_create(
1110 struct dc_context *ctx, uint32_t inst)
1112 struct dcn20_opp *opp =
1113 kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
1116 BREAK_TO_DEBUGGER();
1120 dcn20_opp_construct(opp, ctx, inst,
1121 &opp_regs[inst], &opp_shift, &opp_mask);
1125 static struct dce_aux *dcn31_aux_engine_create(
1126 struct dc_context *ctx,
1129 struct aux_engine_dce110 *aux_engine =
1130 kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
1135 dce110_aux_engine_construct(aux_engine, ctx, inst,
1136 SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD,
1137 &aux_engine_regs[inst],
1140 ctx->dc->caps.extended_aux_timeout_support);
1142 return &aux_engine->base;
1144 #define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST_DCN30(id) }
1146 static const struct dce_i2c_registers i2c_hw_regs[] = {
1154 static const struct dce_i2c_shift i2c_shifts = {
1155 I2C_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
1158 static const struct dce_i2c_mask i2c_masks = {
1159 I2C_COMMON_MASK_SH_LIST_DCN30(_MASK)
1162 static struct dce_i2c_hw *dcn31_i2c_hw_create(
1163 struct dc_context *ctx,
1166 struct dce_i2c_hw *dce_i2c_hw =
1167 kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
1172 dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst,
1173 &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks);
1177 static struct mpc *dcn31_mpc_create(
1178 struct dc_context *ctx,
1182 struct dcn30_mpc *mpc30 = kzalloc(sizeof(struct dcn30_mpc),
1188 dcn30_mpc_construct(mpc30, ctx,
1195 return &mpc30->base;
1198 static struct hubbub *dcn31_hubbub_create(struct dc_context *ctx)
1202 struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub),
1208 hubbub31_construct(hubbub3, ctx,
1212 dcn3_14_ip.det_buffer_size_kbytes,
1213 dcn3_14_ip.pixel_chunk_size_kbytes,
1214 dcn3_14_ip.config_return_buffer_size_in_kbytes);
1217 for (i = 0; i < res_cap_dcn314.num_vmid; i++) {
1218 struct dcn20_vmid *vmid = &hubbub3->vmid[i];
1222 vmid->regs = &vmid_regs[i];
1223 vmid->shifts = &vmid_shifts;
1224 vmid->masks = &vmid_masks;
1227 return &hubbub3->base;
1230 static struct timing_generator *dcn31_timing_generator_create(
1231 struct dc_context *ctx,
1234 struct optc *tgn10 =
1235 kzalloc(sizeof(struct optc), GFP_KERNEL);
1240 tgn10->base.inst = instance;
1241 tgn10->base.ctx = ctx;
1243 tgn10->tg_regs = &optc_regs[instance];
1244 tgn10->tg_shift = &optc_shift;
1245 tgn10->tg_mask = &optc_mask;
1247 dcn314_timing_generator_init(tgn10);
1249 return &tgn10->base;
1252 static const struct encoder_feature_support link_enc_feature = {
1253 .max_hdmi_deep_color = COLOR_DEPTH_121212,
1254 .max_hdmi_pixel_clock = 600000,
1255 .hdmi_ycbcr420_supported = true,
1256 .dp_ycbcr420_supported = true,
1257 .fec_supported = true,
1258 .flags.bits.IS_HBR2_CAPABLE = true,
1259 .flags.bits.IS_HBR3_CAPABLE = true,
1260 .flags.bits.IS_TPS3_CAPABLE = true,
1261 .flags.bits.IS_TPS4_CAPABLE = true
1264 static struct link_encoder *dcn31_link_encoder_create(
1265 struct dc_context *ctx,
1266 const struct encoder_init_data *enc_init_data)
1268 struct dcn20_link_encoder *enc20 =
1269 kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
1274 dcn31_link_encoder_construct(enc20,
1277 &link_enc_regs[enc_init_data->transmitter],
1278 &link_enc_aux_regs[enc_init_data->channel - 1],
1279 &link_enc_hpd_regs[enc_init_data->hpd_source],
1283 return &enc20->enc10.base;
1286 /* Create a minimal link encoder object not associated with a particular
1287 * physical connector.
1288 * resource_funcs.link_enc_create_minimal
1290 static struct link_encoder *dcn31_link_enc_create_minimal(
1291 struct dc_context *ctx, enum engine_id eng_id)
1293 struct dcn20_link_encoder *enc20;
1295 if ((eng_id - ENGINE_ID_DIGA) > ctx->dc->res_pool->res_cap->num_dig_link_enc)
1298 enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
1302 dcn31_link_encoder_construct_minimal(
1306 &link_enc_regs[eng_id - ENGINE_ID_DIGA],
1309 return &enc20->enc10.base;
1312 static struct panel_cntl *dcn31_panel_cntl_create(const struct panel_cntl_init_data *init_data)
1314 struct dcn31_panel_cntl *panel_cntl =
1315 kzalloc(sizeof(struct dcn31_panel_cntl), GFP_KERNEL);
1320 dcn31_panel_cntl_construct(panel_cntl, init_data);
1322 return &panel_cntl->base;
1325 static void read_dce_straps(
1326 struct dc_context *ctx,
1327 struct resource_straps *straps)
1329 generic_reg_get(ctx, regDC_PINSTRAPS + BASE(regDC_PINSTRAPS_BASE_IDX),
1330 FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio);
1334 static struct audio *dcn31_create_audio(
1335 struct dc_context *ctx, unsigned int inst)
1337 return dce_audio_create(ctx, inst,
1338 &audio_regs[inst], &audio_shift, &audio_mask);
1341 static struct vpg *dcn31_vpg_create(
1342 struct dc_context *ctx,
1345 struct dcn31_vpg *vpg31 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL);
1350 vpg31_construct(vpg31, ctx, inst,
1355 return &vpg31->base;
1358 static struct afmt *dcn31_afmt_create(
1359 struct dc_context *ctx,
1362 struct dcn31_afmt *afmt31 = kzalloc(sizeof(struct dcn31_afmt), GFP_KERNEL);
1367 afmt31_construct(afmt31, ctx, inst,
1372 // Light sleep by default, no need to power down here
1374 return &afmt31->base;
1377 static struct apg *dcn31_apg_create(
1378 struct dc_context *ctx,
1381 struct dcn31_apg *apg31 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL);
1386 apg31_construct(apg31, ctx, inst,
1391 return &apg31->base;
1394 static struct stream_encoder *dcn314_stream_encoder_create(
1395 enum engine_id eng_id,
1396 struct dc_context *ctx)
1398 struct dcn10_stream_encoder *enc1;
1404 /* Mapping of VPG, AFMT, DME register blocks to DIO block instance */
1405 if (eng_id <= ENGINE_ID_DIGF) {
1411 enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
1412 vpg = dcn31_vpg_create(ctx, vpg_inst);
1413 afmt = dcn31_afmt_create(ctx, afmt_inst);
1415 if (!enc1 || !vpg || !afmt) {
1422 dcn314_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios,
1424 &stream_enc_regs[eng_id],
1425 &se_shift, &se_mask);
1430 static struct hpo_dp_stream_encoder *dcn31_hpo_dp_stream_encoder_create(
1431 enum engine_id eng_id,
1432 struct dc_context *ctx)
1434 struct dcn31_hpo_dp_stream_encoder *hpo_dp_enc31;
1437 uint32_t hpo_dp_inst;
1441 ASSERT((eng_id >= ENGINE_ID_HPO_DP_0) && (eng_id <= ENGINE_ID_HPO_DP_3));
1442 hpo_dp_inst = eng_id - ENGINE_ID_HPO_DP_0;
1444 /* Mapping of VPG register blocks to HPO DP block instance:
1445 * VPG[6] -> HPO_DP[0]
1446 * VPG[7] -> HPO_DP[1]
1447 * VPG[8] -> HPO_DP[2]
1448 * VPG[9] -> HPO_DP[3]
1450 vpg_inst = hpo_dp_inst + 6;
1452 /* Mapping of APG register blocks to HPO DP block instance:
1453 * APG[0] -> HPO_DP[0]
1454 * APG[1] -> HPO_DP[1]
1455 * APG[2] -> HPO_DP[2]
1456 * APG[3] -> HPO_DP[3]
1458 apg_inst = hpo_dp_inst;
1460 /* allocate HPO stream encoder and create VPG sub-block */
1461 hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL);
1462 vpg = dcn31_vpg_create(ctx, vpg_inst);
1463 apg = dcn31_apg_create(ctx, apg_inst);
1465 if (!hpo_dp_enc31 || !vpg || !apg) {
1466 kfree(hpo_dp_enc31);
1472 dcn31_hpo_dp_stream_encoder_construct(hpo_dp_enc31, ctx, ctx->dc_bios,
1473 hpo_dp_inst, eng_id, vpg, apg,
1474 &hpo_dp_stream_enc_regs[hpo_dp_inst],
1475 &hpo_dp_se_shift, &hpo_dp_se_mask);
1477 return &hpo_dp_enc31->base;
1480 static struct hpo_dp_link_encoder *dcn31_hpo_dp_link_encoder_create(
1482 struct dc_context *ctx)
1484 struct dcn31_hpo_dp_link_encoder *hpo_dp_enc31;
1486 /* allocate HPO link encoder */
1487 hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
1489 hpo_dp_link_encoder31_construct(hpo_dp_enc31, ctx, inst,
1490 &hpo_dp_link_enc_regs[inst],
1491 &hpo_dp_le_shift, &hpo_dp_le_mask);
1493 return &hpo_dp_enc31->base;
1496 static struct dce_hwseq *dcn314_hwseq_create(
1497 struct dc_context *ctx)
1499 struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
1503 hws->regs = &hwseq_reg;
1504 hws->shifts = &hwseq_shift;
1505 hws->masks = &hwseq_mask;
1506 /* DCN3.1 FPGA Workaround
1507 * Need to enable HPO DP Stream Encoder before setting OTG master enable.
1508 * To do so, move calling function enable_stream_timing to only be done AFTER calling
1509 * function core_link_enable_stream
1511 if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment))
1512 hws->wa.dp_hpo_and_otg_sequence = true;
1516 static const struct resource_create_funcs res_create_funcs = {
1517 .read_dce_straps = read_dce_straps,
1518 .create_audio = dcn31_create_audio,
1519 .create_stream_encoder = dcn314_stream_encoder_create,
1520 .create_hpo_dp_stream_encoder = dcn31_hpo_dp_stream_encoder_create,
1521 .create_hpo_dp_link_encoder = dcn31_hpo_dp_link_encoder_create,
1522 .create_hwseq = dcn314_hwseq_create,
1525 static const struct resource_create_funcs res_create_maximus_funcs = {
1526 .read_dce_straps = NULL,
1527 .create_audio = NULL,
1528 .create_stream_encoder = NULL,
1529 .create_hpo_dp_stream_encoder = dcn31_hpo_dp_stream_encoder_create,
1530 .create_hpo_dp_link_encoder = dcn31_hpo_dp_link_encoder_create,
1531 .create_hwseq = dcn314_hwseq_create,
1534 static void dcn314_resource_destruct(struct dcn314_resource_pool *pool)
1538 for (i = 0; i < pool->base.stream_enc_count; i++) {
1539 if (pool->base.stream_enc[i] != NULL) {
1540 if (pool->base.stream_enc[i]->vpg != NULL) {
1541 kfree(DCN30_VPG_FROM_VPG(pool->base.stream_enc[i]->vpg));
1542 pool->base.stream_enc[i]->vpg = NULL;
1544 if (pool->base.stream_enc[i]->afmt != NULL) {
1545 kfree(DCN30_AFMT_FROM_AFMT(pool->base.stream_enc[i]->afmt));
1546 pool->base.stream_enc[i]->afmt = NULL;
1548 kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i]));
1549 pool->base.stream_enc[i] = NULL;
1553 for (i = 0; i < pool->base.hpo_dp_stream_enc_count; i++) {
1554 if (pool->base.hpo_dp_stream_enc[i] != NULL) {
1555 if (pool->base.hpo_dp_stream_enc[i]->vpg != NULL) {
1556 kfree(DCN30_VPG_FROM_VPG(pool->base.hpo_dp_stream_enc[i]->vpg));
1557 pool->base.hpo_dp_stream_enc[i]->vpg = NULL;
1559 if (pool->base.hpo_dp_stream_enc[i]->apg != NULL) {
1560 kfree(DCN31_APG_FROM_APG(pool->base.hpo_dp_stream_enc[i]->apg));
1561 pool->base.hpo_dp_stream_enc[i]->apg = NULL;
1563 kfree(DCN3_1_HPO_DP_STREAM_ENC_FROM_HPO_STREAM_ENC(pool->base.hpo_dp_stream_enc[i]));
1564 pool->base.hpo_dp_stream_enc[i] = NULL;
1568 for (i = 0; i < pool->base.hpo_dp_link_enc_count; i++) {
1569 if (pool->base.hpo_dp_link_enc[i] != NULL) {
1570 kfree(DCN3_1_HPO_DP_LINK_ENC_FROM_HPO_LINK_ENC(pool->base.hpo_dp_link_enc[i]));
1571 pool->base.hpo_dp_link_enc[i] = NULL;
1575 for (i = 0; i < pool->base.res_cap->num_dsc; i++) {
1576 if (pool->base.dscs[i] != NULL)
1577 dcn20_dsc_destroy(&pool->base.dscs[i]);
1580 if (pool->base.mpc != NULL) {
1581 kfree(TO_DCN20_MPC(pool->base.mpc));
1582 pool->base.mpc = NULL;
1584 if (pool->base.hubbub != NULL) {
1585 kfree(pool->base.hubbub);
1586 pool->base.hubbub = NULL;
1588 for (i = 0; i < pool->base.pipe_count; i++) {
1589 if (pool->base.dpps[i] != NULL)
1590 dcn31_dpp_destroy(&pool->base.dpps[i]);
1592 if (pool->base.ipps[i] != NULL)
1593 pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]);
1595 if (pool->base.hubps[i] != NULL) {
1596 kfree(TO_DCN20_HUBP(pool->base.hubps[i]));
1597 pool->base.hubps[i] = NULL;
1600 if (pool->base.irqs != NULL)
1601 dal_irq_service_destroy(&pool->base.irqs);
1604 for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
1605 if (pool->base.engines[i] != NULL)
1606 dce110_engine_destroy(&pool->base.engines[i]);
1607 if (pool->base.hw_i2cs[i] != NULL) {
1608 kfree(pool->base.hw_i2cs[i]);
1609 pool->base.hw_i2cs[i] = NULL;
1611 if (pool->base.sw_i2cs[i] != NULL) {
1612 kfree(pool->base.sw_i2cs[i]);
1613 pool->base.sw_i2cs[i] = NULL;
1617 for (i = 0; i < pool->base.res_cap->num_opp; i++) {
1618 if (pool->base.opps[i] != NULL)
1619 pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]);
1622 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
1623 if (pool->base.timing_generators[i] != NULL) {
1624 kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
1625 pool->base.timing_generators[i] = NULL;
1629 for (i = 0; i < pool->base.res_cap->num_dwb; i++) {
1630 if (pool->base.dwbc[i] != NULL) {
1631 kfree(TO_DCN30_DWBC(pool->base.dwbc[i]));
1632 pool->base.dwbc[i] = NULL;
1634 if (pool->base.mcif_wb[i] != NULL) {
1635 kfree(TO_DCN30_MMHUBBUB(pool->base.mcif_wb[i]));
1636 pool->base.mcif_wb[i] = NULL;
1640 for (i = 0; i < pool->base.audio_count; i++) {
1641 if (pool->base.audios[i])
1642 dce_aud_destroy(&pool->base.audios[i]);
1645 for (i = 0; i < pool->base.clk_src_count; i++) {
1646 if (pool->base.clock_sources[i] != NULL) {
1647 dcn20_clock_source_destroy(&pool->base.clock_sources[i]);
1648 pool->base.clock_sources[i] = NULL;
1652 for (i = 0; i < pool->base.res_cap->num_mpc_3dlut; i++) {
1653 if (pool->base.mpc_lut[i] != NULL) {
1654 dc_3dlut_func_release(pool->base.mpc_lut[i]);
1655 pool->base.mpc_lut[i] = NULL;
1657 if (pool->base.mpc_shaper[i] != NULL) {
1658 dc_transfer_func_release(pool->base.mpc_shaper[i]);
1659 pool->base.mpc_shaper[i] = NULL;
1663 if (pool->base.dp_clock_source != NULL) {
1664 dcn20_clock_source_destroy(&pool->base.dp_clock_source);
1665 pool->base.dp_clock_source = NULL;
1668 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
1669 if (pool->base.multiple_abms[i] != NULL)
1670 dce_abm_destroy(&pool->base.multiple_abms[i]);
1673 if (pool->base.psr != NULL)
1674 dmub_psr_destroy(&pool->base.psr);
1676 if (pool->base.dccg != NULL)
1677 dcn_dccg_destroy(&pool->base.dccg);
1680 static struct hubp *dcn31_hubp_create(
1681 struct dc_context *ctx,
1684 struct dcn20_hubp *hubp2 =
1685 kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
1690 if (hubp31_construct(hubp2, ctx, inst,
1691 &hubp_regs[inst], &hubp_shift, &hubp_mask))
1692 return &hubp2->base;
1694 BREAK_TO_DEBUGGER();
1699 static bool dcn31_dwbc_create(struct dc_context *ctx, struct resource_pool *pool)
1702 uint32_t pipe_count = pool->res_cap->num_dwb;
1704 for (i = 0; i < pipe_count; i++) {
1705 struct dcn30_dwbc *dwbc30 = kzalloc(sizeof(struct dcn30_dwbc),
1709 dm_error("DC: failed to create dwbc30!\n");
1713 dcn30_dwbc_construct(dwbc30, ctx,
1719 pool->dwbc[i] = &dwbc30->base;
1724 static bool dcn31_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool)
1727 uint32_t pipe_count = pool->res_cap->num_dwb;
1729 for (i = 0; i < pipe_count; i++) {
1730 struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub),
1734 dm_error("DC: failed to create mcif_wb30!\n");
1738 dcn30_mmhubbub_construct(mcif_wb30, ctx,
1744 pool->mcif_wb[i] = &mcif_wb30->base;
1749 static struct display_stream_compressor *dcn314_dsc_create(
1750 struct dc_context *ctx, uint32_t inst)
1752 struct dcn20_dsc *dsc =
1753 kzalloc(sizeof(struct dcn20_dsc), GFP_KERNEL);
1756 BREAK_TO_DEBUGGER();
1760 dsc2_construct(dsc, ctx, inst, &dsc_regs[inst], &dsc_shift, &dsc_mask);
1764 static void dcn314_destroy_resource_pool(struct resource_pool **pool)
1766 struct dcn314_resource_pool *dcn314_pool = TO_DCN314_RES_POOL(*pool);
1768 dcn314_resource_destruct(dcn314_pool);
1773 static struct clock_source *dcn31_clock_source_create(
1774 struct dc_context *ctx,
1775 struct dc_bios *bios,
1776 enum clock_source_id id,
1777 const struct dce110_clk_src_regs *regs,
1780 struct dce110_clk_src *clk_src =
1781 kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
1786 if (dcn31_clk_src_construct(clk_src, ctx, bios, id,
1787 regs, &cs_shift, &cs_mask)) {
1788 clk_src->base.dp_clk_src = dp_clk_src;
1789 return &clk_src->base;
1792 BREAK_TO_DEBUGGER();
1796 static bool is_dual_plane(enum surface_pixel_format format)
1798 return format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN || format == SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA;
1801 static int dcn314_populate_dml_pipes_from_context(
1802 struct dc *dc, struct dc_state *context,
1803 display_e2e_pipe_params_st *pipes,
1807 struct resource_context *res_ctx = &context->res_ctx;
1808 struct pipe_ctx *pipe;
1809 bool upscaled = false;
1811 dcn20_populate_dml_pipes_from_context(dc, context, pipes, fast_validate);
1813 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
1814 struct dc_crtc_timing *timing;
1816 if (!res_ctx->pipe_ctx[i].stream)
1818 pipe = &res_ctx->pipe_ctx[i];
1819 timing = &pipe->stream->timing;
1821 if (dc_extended_blank_supported(dc) && pipe->stream->adjust.v_total_max == pipe->stream->adjust.v_total_min
1822 && pipe->stream->adjust.v_total_min > timing->v_total)
1823 pipes[pipe_cnt].pipe.dest.vtotal = pipe->stream->adjust.v_total_min;
1825 if (pipe->plane_state &&
1826 (pipe->plane_state->src_rect.height < pipe->plane_state->dst_rect.height ||
1827 pipe->plane_state->src_rect.width < pipe->plane_state->dst_rect.width))
1831 * Immediate flip can be set dynamically after enabling the plane.
1832 * We need to require support for immediate flip or underflow can be
1833 * intermittently experienced depending on peak b/w requirements.
1835 pipes[pipe_cnt].pipe.src.immediate_flip = true;
1837 pipes[pipe_cnt].pipe.src.unbounded_req_mode = false;
1838 pipes[pipe_cnt].pipe.src.hostvm = dc->res_pool->hubbub->riommu_active;
1839 pipes[pipe_cnt].pipe.src.gpuvm = true;
1840 pipes[pipe_cnt].pipe.src.dcc_fraction_of_zs_req_luma = 0;
1841 pipes[pipe_cnt].pipe.src.dcc_fraction_of_zs_req_chroma = 0;
1842 pipes[pipe_cnt].pipe.dest.vfront_porch = timing->v_front_porch;
1843 pipes[pipe_cnt].pipe.src.dcc_rate = 3;
1844 pipes[pipe_cnt].dout.dsc_input_bpc = 0;
1846 if (pipes[pipe_cnt].dout.dsc_enable) {
1847 switch (timing->display_color_depth) {
1848 case COLOR_DEPTH_888:
1849 pipes[pipe_cnt].dout.dsc_input_bpc = 8;
1851 case COLOR_DEPTH_101010:
1852 pipes[pipe_cnt].dout.dsc_input_bpc = 10;
1854 case COLOR_DEPTH_121212:
1855 pipes[pipe_cnt].dout.dsc_input_bpc = 12;
1865 context->bw_ctx.dml.ip.det_buffer_size_kbytes = DCN3_14_DEFAULT_DET_SIZE;
1867 dc->config.enable_4to1MPC = false;
1868 if (pipe_cnt == 1 && pipe->plane_state && !dc->debug.disable_z9_mpc) {
1869 if (is_dual_plane(pipe->plane_state->format)
1870 && pipe->plane_state->src_rect.width <= 1920 && pipe->plane_state->src_rect.height <= 1080) {
1871 dc->config.enable_4to1MPC = true;
1872 } else if (!is_dual_plane(pipe->plane_state->format) && pipe->plane_state->src_rect.width <= 5120) {
1873 /* Limit to 5k max to avoid forced pipe split when there is not enough detile for swath */
1874 context->bw_ctx.dml.ip.det_buffer_size_kbytes = 192;
1875 pipes[0].pipe.src.unbounded_req_mode = true;
1877 } else if (context->stream_count >= dc->debug.crb_alloc_policy_min_disp_count
1878 && dc->debug.crb_alloc_policy > DET_SIZE_DEFAULT) {
1879 context->bw_ctx.dml.ip.det_buffer_size_kbytes = dc->debug.crb_alloc_policy * 64;
1880 } else if (context->stream_count >= 3 && upscaled) {
1881 context->bw_ctx.dml.ip.det_buffer_size_kbytes = 192;
1884 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1885 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
1890 if (pipe->stream->signal == SIGNAL_TYPE_EDP && dc->debug.seamless_boot_odm_combine &&
1891 pipe->stream->apply_seamless_boot_optimization) {
1893 if (pipe->stream->apply_boot_odm_mode == dm_odm_combine_policy_2to1) {
1894 context->bw_ctx.dml.vba.ODMCombinePolicy = dm_odm_combine_policy_2to1;
1903 static struct dc_cap_funcs cap_funcs = {
1904 .get_dcc_compression_cap = dcn20_get_dcc_compression_cap
1907 static void dcn314_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
1909 struct clk_limit_table *clk_table = &bw_params->clk_table;
1910 struct _vcs_dpi_voltage_scaling_st *clock_tmp = dcn3_14_soc._clock_tmp;
1911 unsigned int i, closest_clk_lvl;
1912 int max_dispclk_mhz = 0, max_dppclk_mhz = 0;
1915 // Default clock levels are used for diags, which may lead to overclocking.
1916 if (!IS_DIAG_DC(dc->ctx->dce_environment)) {
1918 dcn3_14_ip.max_num_otg = dc->res_pool->res_cap->num_timing_generator;
1919 dcn3_14_ip.max_num_dpp = dc->res_pool->pipe_count;
1921 if (bw_params->num_channels > 0)
1922 dcn3_14_soc.num_chans = bw_params->num_channels;
1924 ASSERT(dcn3_14_soc.num_chans);
1925 ASSERT(clk_table->num_entries);
1927 /* Prepass to find max clocks independent of voltage level. */
1928 for (i = 0; i < clk_table->num_entries; ++i) {
1929 if (clk_table->entries[i].dispclk_mhz > max_dispclk_mhz)
1930 max_dispclk_mhz = clk_table->entries[i].dispclk_mhz;
1931 if (clk_table->entries[i].dppclk_mhz > max_dppclk_mhz)
1932 max_dppclk_mhz = clk_table->entries[i].dppclk_mhz;
1935 for (i = 0; i < clk_table->num_entries; i++) {
1937 for (closest_clk_lvl = 0, j = dcn3_14_soc.num_states - 1; j >= 0; j--) {
1938 if ((unsigned int) dcn3_14_soc.clock_limits[j].dcfclk_mhz <= clk_table->entries[i].dcfclk_mhz) {
1939 closest_clk_lvl = j;
1943 if (clk_table->num_entries == 1) {
1944 /*smu gives one DPM level, let's take the highest one*/
1945 closest_clk_lvl = dcn3_14_soc.num_states - 1;
1948 clock_tmp[i].state = i;
1950 /* Clocks dependent on voltage level. */
1951 clock_tmp[i].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
1952 if (clk_table->num_entries == 1 &&
1953 clock_tmp[i].dcfclk_mhz < dcn3_14_soc.clock_limits[closest_clk_lvl].dcfclk_mhz) {
1954 /*SMU fix not released yet*/
1955 clock_tmp[i].dcfclk_mhz = dcn3_14_soc.clock_limits[closest_clk_lvl].dcfclk_mhz;
1957 clock_tmp[i].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
1958 clock_tmp[i].socclk_mhz = clk_table->entries[i].socclk_mhz;
1960 if (clk_table->entries[i].memclk_mhz && clk_table->entries[i].wck_ratio)
1961 clock_tmp[i].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2 * clk_table->entries[i].wck_ratio;
1963 /* Clocks independent of voltage level. */
1964 clock_tmp[i].dispclk_mhz = max_dispclk_mhz ? max_dispclk_mhz :
1965 dcn3_14_soc.clock_limits[closest_clk_lvl].dispclk_mhz;
1967 clock_tmp[i].dppclk_mhz = max_dppclk_mhz ? max_dppclk_mhz :
1968 dcn3_14_soc.clock_limits[closest_clk_lvl].dppclk_mhz;
1970 clock_tmp[i].dram_bw_per_chan_gbps = dcn3_14_soc.clock_limits[closest_clk_lvl].dram_bw_per_chan_gbps;
1971 clock_tmp[i].dscclk_mhz = dcn3_14_soc.clock_limits[closest_clk_lvl].dscclk_mhz;
1972 clock_tmp[i].dtbclk_mhz = dcn3_14_soc.clock_limits[closest_clk_lvl].dtbclk_mhz;
1973 clock_tmp[i].phyclk_d18_mhz = dcn3_14_soc.clock_limits[closest_clk_lvl].phyclk_d18_mhz;
1974 clock_tmp[i].phyclk_mhz = dcn3_14_soc.clock_limits[closest_clk_lvl].phyclk_mhz;
1976 for (i = 0; i < clk_table->num_entries; i++)
1977 dcn3_14_soc.clock_limits[i] = clock_tmp[i];
1978 if (clk_table->num_entries)
1979 dcn3_14_soc.num_states = clk_table->num_entries;
1982 if (max_dispclk_mhz) {
1983 dcn3_14_soc.dispclk_dppclk_vco_speed_mhz = max_dispclk_mhz * 2;
1984 dc->dml.soc.dispclk_dppclk_vco_speed_mhz = max_dispclk_mhz * 2;
1987 if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment))
1988 dml_init_instance(&dc->dml, &dcn3_14_soc, &dcn3_14_ip, DML_PROJECT_DCN31);
1990 dml_init_instance(&dc->dml, &dcn3_14_soc, &dcn3_14_ip, DML_PROJECT_DCN31_FPGA);
1993 static struct resource_funcs dcn314_res_pool_funcs = {
1994 .destroy = dcn314_destroy_resource_pool,
1995 .link_enc_create = dcn31_link_encoder_create,
1996 .link_enc_create_minimal = dcn31_link_enc_create_minimal,
1997 .link_encs_assign = link_enc_cfg_link_encs_assign,
1998 .link_enc_unassign = link_enc_cfg_link_enc_unassign,
1999 .panel_cntl_create = dcn31_panel_cntl_create,
2000 .validate_bandwidth = dcn31_validate_bandwidth,
2001 .calculate_wm_and_dlg = dcn31_calculate_wm_and_dlg,
2002 .update_soc_for_wm_a = dcn31_update_soc_for_wm_a,
2003 .populate_dml_pipes = dcn314_populate_dml_pipes_from_context,
2004 .acquire_idle_pipe_for_layer = dcn20_acquire_idle_pipe_for_layer,
2005 .add_stream_to_ctx = dcn30_add_stream_to_ctx,
2006 .add_dsc_to_stream_resource = dcn20_add_dsc_to_stream_resource,
2007 .remove_stream_from_ctx = dcn20_remove_stream_from_ctx,
2008 .populate_dml_writeback_from_context = dcn30_populate_dml_writeback_from_context,
2009 .set_mcif_arb_params = dcn30_set_mcif_arb_params,
2010 .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link,
2011 .acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut,
2012 .release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut,
2013 .update_bw_bounding_box = dcn314_update_bw_bounding_box,
2014 .patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
2017 static struct clock_source *dcn30_clock_source_create(
2018 struct dc_context *ctx,
2019 struct dc_bios *bios,
2020 enum clock_source_id id,
2021 const struct dce110_clk_src_regs *regs,
2024 struct dce110_clk_src *clk_src =
2025 kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
2030 if (dcn31_clk_src_construct(clk_src, ctx, bios, id,
2031 regs, &cs_shift, &cs_mask)) {
2032 clk_src->base.dp_clk_src = dp_clk_src;
2033 return &clk_src->base;
2036 BREAK_TO_DEBUGGER();
2040 static bool dcn314_resource_construct(
2041 uint8_t num_virtual_links,
2043 struct dcn314_resource_pool *pool)
2046 struct dc_context *ctx = dc->ctx;
2047 struct irq_service_init_data init_data;
2049 ctx->dc_bios->regs = &bios_regs;
2051 pool->base.res_cap = &res_cap_dcn314;
2052 pool->base.funcs = &dcn314_res_pool_funcs;
2054 /*************************************************
2055 * Resource + asic cap harcoding *
2056 *************************************************/
2057 pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
2058 pool->base.pipe_count = pool->base.res_cap->num_timing_generator;
2059 pool->base.mpcc_count = pool->base.res_cap->num_timing_generator;
2060 dc->caps.max_downscale_ratio = 600;
2061 dc->caps.i2c_speed_in_khz = 100;
2062 dc->caps.i2c_speed_in_khz_hdcp = 100;
2063 dc->caps.max_cursor_size = 256;
2064 dc->caps.min_horizontal_blanking_period = 80;
2065 dc->caps.dmdata_alloc_size = 2048;
2066 dc->caps.max_slave_planes = 2;
2067 dc->caps.max_slave_yuv_planes = 2;
2068 dc->caps.max_slave_rgb_planes = 2;
2069 dc->caps.post_blend_color_processing = true;
2070 dc->caps.force_dp_tps4_for_cp2520 = true;
2071 dc->caps.dp_hpo = true;
2072 dc->caps.edp_dsc_support = true;
2073 dc->caps.extended_aux_timeout_support = true;
2074 dc->caps.dmcub_support = true;
2075 dc->caps.is_apu = true;
2076 dc->caps.seamless_odm = true;
2078 dc->caps.zstate_support = true;
2080 /* Color pipeline capabilities */
2081 dc->caps.color.dpp.dcn_arch = 1;
2082 dc->caps.color.dpp.input_lut_shared = 0;
2083 dc->caps.color.dpp.icsc = 1;
2084 dc->caps.color.dpp.dgam_ram = 0; // must use gamma_corr
2085 dc->caps.color.dpp.dgam_rom_caps.srgb = 1;
2086 dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1;
2087 dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 1;
2088 dc->caps.color.dpp.dgam_rom_caps.pq = 1;
2089 dc->caps.color.dpp.dgam_rom_caps.hlg = 1;
2090 dc->caps.color.dpp.post_csc = 1;
2091 dc->caps.color.dpp.gamma_corr = 1;
2092 dc->caps.color.dpp.dgam_rom_for_yuv = 0;
2094 dc->caps.color.dpp.hw_3d_lut = 1;
2095 dc->caps.color.dpp.ogam_ram = 1;
2096 // no OGAM ROM on DCN301
2097 dc->caps.color.dpp.ogam_rom_caps.srgb = 0;
2098 dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0;
2099 dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0;
2100 dc->caps.color.dpp.ogam_rom_caps.pq = 0;
2101 dc->caps.color.dpp.ogam_rom_caps.hlg = 0;
2102 dc->caps.color.dpp.ocsc = 0;
2104 dc->caps.color.mpc.gamut_remap = 1;
2105 dc->caps.color.mpc.num_3dluts = pool->base.res_cap->num_mpc_3dlut; //2
2106 dc->caps.color.mpc.ogam_ram = 1;
2107 dc->caps.color.mpc.ogam_rom_caps.srgb = 0;
2108 dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0;
2109 dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0;
2110 dc->caps.color.mpc.ogam_rom_caps.pq = 0;
2111 dc->caps.color.mpc.ogam_rom_caps.hlg = 0;
2112 dc->caps.color.mpc.ocsc = 1;
2114 /* Use pipe context based otg sync logic */
2115 dc->config.use_pipe_ctx_sync_logic = true;
2117 /* read VBIOS LTTPR caps */
2119 if (ctx->dc_bios->funcs->get_lttpr_caps) {
2120 enum bp_result bp_query_result;
2121 uint8_t is_vbios_lttpr_enable = 0;
2123 bp_query_result = ctx->dc_bios->funcs->get_lttpr_caps(ctx->dc_bios, &is_vbios_lttpr_enable);
2124 dc->caps.vbios_lttpr_enable = (bp_query_result == BP_RESULT_OK) && !!is_vbios_lttpr_enable;
2127 /* interop bit is implicit */
2129 dc->caps.vbios_lttpr_aware = true;
2133 if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
2134 dc->debug = debug_defaults_drv;
2135 else if (dc->ctx->dce_environment == DCE_ENV_FPGA_MAXIMUS)
2136 dc->debug = debug_defaults_diags;
2138 dc->debug = debug_defaults_diags;
2139 // Init the vm_helper
2141 vm_helper_init(dc->vm_helper, 16);
2143 /*************************************************
2144 * Create resources *
2145 *************************************************/
2147 /* Clock Sources for Pixel Clock*/
2148 pool->base.clock_sources[DCN31_CLK_SRC_PLL0] =
2149 dcn30_clock_source_create(ctx, ctx->dc_bios,
2150 CLOCK_SOURCE_COMBO_PHY_PLL0,
2151 &clk_src_regs[0], false);
2152 pool->base.clock_sources[DCN31_CLK_SRC_PLL1] =
2153 dcn30_clock_source_create(ctx, ctx->dc_bios,
2154 CLOCK_SOURCE_COMBO_PHY_PLL1,
2155 &clk_src_regs[1], false);
2156 pool->base.clock_sources[DCN31_CLK_SRC_PLL2] =
2157 dcn30_clock_source_create(ctx, ctx->dc_bios,
2158 CLOCK_SOURCE_COMBO_PHY_PLL2,
2159 &clk_src_regs[2], false);
2160 pool->base.clock_sources[DCN31_CLK_SRC_PLL3] =
2161 dcn30_clock_source_create(ctx, ctx->dc_bios,
2162 CLOCK_SOURCE_COMBO_PHY_PLL3,
2163 &clk_src_regs[3], false);
2164 pool->base.clock_sources[DCN31_CLK_SRC_PLL4] =
2165 dcn30_clock_source_create(ctx, ctx->dc_bios,
2166 CLOCK_SOURCE_COMBO_PHY_PLL4,
2167 &clk_src_regs[4], false);
2169 pool->base.clk_src_count = DCN30_CLK_SRC_TOTAL;
2171 /* todo: not reuse phy_pll registers */
2172 pool->base.dp_clock_source =
2173 dcn31_clock_source_create(ctx, ctx->dc_bios,
2174 CLOCK_SOURCE_ID_DP_DTO,
2175 &clk_src_regs[0], true);
2177 for (i = 0; i < pool->base.clk_src_count; i++) {
2178 if (pool->base.clock_sources[i] == NULL) {
2179 dm_error("DC: failed to create clock sources!\n");
2180 BREAK_TO_DEBUGGER();
2185 pool->base.dccg = dccg314_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask);
2186 if (pool->base.dccg == NULL) {
2187 dm_error("DC: failed to create dccg!\n");
2188 BREAK_TO_DEBUGGER();
2192 init_data.ctx = dc->ctx;
2193 pool->base.irqs = dal_irq_service_dcn314_create(&init_data);
2194 if (!pool->base.irqs)
2198 pool->base.hubbub = dcn31_hubbub_create(ctx);
2199 if (pool->base.hubbub == NULL) {
2200 BREAK_TO_DEBUGGER();
2201 dm_error("DC: failed to create hubbub!\n");
2205 /* HUBPs, DPPs, OPPs and TGs */
2206 for (i = 0; i < pool->base.pipe_count; i++) {
2207 pool->base.hubps[i] = dcn31_hubp_create(ctx, i);
2208 if (pool->base.hubps[i] == NULL) {
2209 BREAK_TO_DEBUGGER();
2211 "DC: failed to create hubps!\n");
2215 pool->base.dpps[i] = dcn31_dpp_create(ctx, i);
2216 if (pool->base.dpps[i] == NULL) {
2217 BREAK_TO_DEBUGGER();
2219 "DC: failed to create dpps!\n");
2224 for (i = 0; i < pool->base.res_cap->num_opp; i++) {
2225 pool->base.opps[i] = dcn31_opp_create(ctx, i);
2226 if (pool->base.opps[i] == NULL) {
2227 BREAK_TO_DEBUGGER();
2229 "DC: failed to create output pixel processor!\n");
2234 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
2235 pool->base.timing_generators[i] = dcn31_timing_generator_create(
2237 if (pool->base.timing_generators[i] == NULL) {
2238 BREAK_TO_DEBUGGER();
2239 dm_error("DC: failed to create tg!\n");
2243 pool->base.timing_generator_count = i;
2246 pool->base.psr = dmub_psr_create(ctx);
2247 if (pool->base.psr == NULL) {
2248 dm_error("DC: failed to create psr obj!\n");
2249 BREAK_TO_DEBUGGER();
2254 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
2255 pool->base.multiple_abms[i] = dmub_abm_create(ctx,
2259 if (pool->base.multiple_abms[i] == NULL) {
2260 dm_error("DC: failed to create abm for pipe %d!\n", i);
2261 BREAK_TO_DEBUGGER();
2267 pool->base.mpc = dcn31_mpc_create(ctx, pool->base.mpcc_count, pool->base.res_cap->num_mpc_3dlut);
2268 if (pool->base.mpc == NULL) {
2269 BREAK_TO_DEBUGGER();
2270 dm_error("DC: failed to create mpc!\n");
2274 for (i = 0; i < pool->base.res_cap->num_dsc; i++) {
2275 pool->base.dscs[i] = dcn314_dsc_create(ctx, i);
2276 if (pool->base.dscs[i] == NULL) {
2277 BREAK_TO_DEBUGGER();
2278 dm_error("DC: failed to create display stream compressor %d!\n", i);
2283 /* DWB and MMHUBBUB */
2284 if (!dcn31_dwbc_create(ctx, &pool->base)) {
2285 BREAK_TO_DEBUGGER();
2286 dm_error("DC: failed to create dwbc!\n");
2290 if (!dcn31_mmhubbub_create(ctx, &pool->base)) {
2291 BREAK_TO_DEBUGGER();
2292 dm_error("DC: failed to create mcif_wb!\n");
2297 for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
2298 pool->base.engines[i] = dcn31_aux_engine_create(ctx, i);
2299 if (pool->base.engines[i] == NULL) {
2300 BREAK_TO_DEBUGGER();
2302 "DC:failed to create aux engine!!\n");
2305 pool->base.hw_i2cs[i] = dcn31_i2c_hw_create(ctx, i);
2306 if (pool->base.hw_i2cs[i] == NULL) {
2307 BREAK_TO_DEBUGGER();
2309 "DC:failed to create hw i2c!!\n");
2312 pool->base.sw_i2cs[i] = NULL;
2315 /* DCN314 has 4 DPIA */
2316 pool->base.usb4_dpia_count = 4;
2318 /* Audio, Stream Encoders including HPO and virtual, MPC 3D LUTs */
2319 if (!resource_construct(num_virtual_links, dc, &pool->base,
2320 (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ?
2321 &res_create_funcs : &res_create_maximus_funcs)))
2324 /* HW Sequencer and Plane caps */
2325 dcn314_hw_sequencer_construct(dc);
2327 dc->caps.max_planes = pool->base.pipe_count;
2329 for (i = 0; i < dc->caps.max_planes; ++i)
2330 dc->caps.planes[i] = plane_cap;
2332 dc->cap_funcs = cap_funcs;
2334 dc->dcn_ip->max_num_dpp = dcn3_14_ip.max_num_dpp;
2340 dcn314_resource_destruct(pool);
2345 struct resource_pool *dcn314_create_resource_pool(
2346 const struct dc_init_data *init_data,
2349 struct dcn314_resource_pool *pool =
2350 kzalloc(sizeof(struct dcn314_resource_pool), GFP_KERNEL);
2355 if (dcn314_resource_construct(init_data->num_virtual_links, dc, pool))
2358 BREAK_TO_DEBUGGER();