2 * Copyright 2020 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
27 #include "dm_services.h"
30 #include "dcn301_init.h"
33 #include "include/irq_service_interface.h"
34 #include "dcn30/dcn30_resource.h"
35 #include "dcn301_resource.h"
37 #include "dcn20/dcn20_resource.h"
39 #include "dcn10/dcn10_ipp.h"
40 #include "dcn301/dcn301_hubbub.h"
41 #include "dcn30/dcn30_mpc.h"
42 #include "dcn30/dcn30_hubp.h"
43 #include "irq/dcn30/irq_service_dcn30.h"
44 #include "dcn30/dcn30_dpp.h"
45 #include "dcn30/dcn30_optc.h"
46 #include "dcn20/dcn20_hwseq.h"
47 #include "dcn30/dcn30_hwseq.h"
48 #include "dce110/dce110_hw_sequencer.h"
49 #include "dcn30/dcn30_opp.h"
50 #include "dcn20/dcn20_dsc.h"
51 #include "dcn30/dcn30_vpg.h"
52 #include "dcn30/dcn30_afmt.h"
53 #include "dce/dce_clock_source.h"
54 #include "dce/dce_audio.h"
55 #include "dce/dce_hwseq.h"
57 #include "virtual/virtual_stream_encoder.h"
58 #include "dce110/dce110_resource.h"
59 #include "dml/display_mode_vba.h"
60 #include "dcn301/dcn301_dccg.h"
61 #include "dcn10/dcn10_resource.h"
62 #include "dcn30/dcn30_dio_stream_encoder.h"
63 #include "dcn301/dcn301_dio_link_encoder.h"
64 #include "dcn301_panel_cntl.h"
66 #include "vangogh_ip_offset.h"
68 #include "dcn30/dcn30_dwb.h"
69 #include "dcn30/dcn30_mmhubbub.h"
71 #include "dcn/dcn_3_0_1_offset.h"
72 #include "dcn/dcn_3_0_1_sh_mask.h"
74 #include "nbio/nbio_7_2_0_offset.h"
76 #include "reg_helper.h"
77 #include "dce/dmub_abm.h"
78 #include "dce/dce_aux.h"
79 #include "dce/dce_i2c.h"
81 #include "dml/dcn30/display_mode_vba_30.h"
82 #include "vm_helper.h"
83 #include "dcn20/dcn20_vmid.h"
84 #include "amdgpu_socbb.h"
86 #define TO_DCN301_RES_POOL(pool)\
87 container_of(pool, struct dcn301_resource_pool, base)
89 #define DC_LOGGER_INIT(logger)
91 struct _vcs_dpi_ip_params_st dcn3_01_ip = {
95 .gpuvm_max_page_table_levels = 1,
96 .hostvm_max_page_table_levels = 2,
97 .hostvm_cached_page_table_levels = 0,
98 .pte_group_size_bytes = 2048,
100 .rob_buffer_size_kbytes = 184,
101 .det_buffer_size_kbytes = 184,
102 .dpte_buffer_size_in_pte_reqs_luma = 64,
103 .dpte_buffer_size_in_pte_reqs_chroma = 32,
104 .pde_proc_buffer_size_64k_reqs = 48,
105 .dpp_output_buffer_pixels = 2560,
106 .opp_output_buffer_lines = 1,
107 .pixel_chunk_size_kbytes = 8,
108 .meta_chunk_size_kbytes = 2,
109 .writeback_chunk_size_kbytes = 8,
110 .line_buffer_size_bits = 789504,
111 .is_line_buffer_bpp_fixed = 0, // ?
112 .line_buffer_fixed_bpp = 48, // ?
113 .dcc_supported = true,
114 .writeback_interface_buffer_size_kbytes = 90,
115 .writeback_line_buffer_buffer_size = 656640,
116 .max_line_buffer_lines = 12,
117 .writeback_luma_buffer_size_kbytes = 12, // writeback_line_buffer_buffer_size = 656640
118 .writeback_chroma_buffer_size_kbytes = 8,
119 .writeback_chroma_line_buffer_width_pixels = 4,
120 .writeback_max_hscl_ratio = 1,
121 .writeback_max_vscl_ratio = 1,
122 .writeback_min_hscl_ratio = 1,
123 .writeback_min_vscl_ratio = 1,
124 .writeback_max_hscl_taps = 1,
125 .writeback_max_vscl_taps = 1,
126 .writeback_line_buffer_luma_buffer_size = 0,
127 .writeback_line_buffer_chroma_buffer_size = 14643,
128 .cursor_buffer_size = 8,
129 .cursor_chunk_size = 2,
133 .max_dchub_pscl_bw_pix_per_clk = 4,
134 .max_pscl_lb_bw_pix_per_clk = 2,
135 .max_lb_vscl_bw_pix_per_clk = 4,
136 .max_vscl_hscl_bw_pix_per_clk = 4,
143 .dispclk_ramp_margin_percent = 1,
144 .underscan_factor = 1.11,
145 .min_vblank_lines = 32,
146 .dppclk_delay_subtotal = 46,
147 .dynamic_metadata_vm_enabled = true,
148 .dppclk_delay_scl_lb_only = 16,
149 .dppclk_delay_scl = 50,
150 .dppclk_delay_cnvc_formatter = 27,
151 .dppclk_delay_cnvc_cursor = 6,
152 .dispclk_delay_subtotal = 119,
153 .dcfclk_cstate_latency = 5.2, // SRExitTime
154 .max_inter_dcn_tile_repeaters = 8,
155 .max_num_hdmi_frl_outputs = 0,
156 .odm_combine_4to1_supported = true,
158 .xfc_supported = false,
159 .xfc_fill_bw_overhead_percent = 10.0,
160 .xfc_fill_constant_bytes = 0,
161 .gfx7_compat_tiling_supported = 0,
162 .number_of_cursors = 1,
165 struct _vcs_dpi_soc_bounding_box_st dcn3_01_soc = {
167 /*TODO: fill out defaults once wm plociy is settled*/
171 .fabricclk_mhz = 1200.0,
172 .dispclk_mhz = 1015.0,
173 .dppclk_mhz = 1015.0,
175 .socclk_mhz = 1000.0,
177 .dram_speed_mts = 4266.0,
182 .fabricclk_mhz = 1200.0,
183 .dispclk_mhz = 1015.0,
184 .dppclk_mhz = 1015.0,
186 .socclk_mhz = 1000.0,
188 .dram_speed_mts = 4266.0,
192 .sr_exit_time_us = 9.0,
193 .sr_enter_plus_exit_time_us = 11.0,
194 .urgent_latency_us = 4.0,
195 .urgent_latency_pixel_data_only_us = 4.0,
196 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
197 .urgent_latency_vm_data_only_us = 4.0,
198 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
199 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
200 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
201 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 80.0,
202 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 75.0,
203 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 40.0,
204 .max_avg_sdp_bw_use_normal_percent = 60.0,
205 .max_avg_dram_bw_use_normal_percent = 60.0,
206 .writeback_latency_us = 12.0,
207 .max_request_size_bytes = 256,
208 .dram_channel_width_bytes = 4,
209 .fabric_datapath_to_dcn_data_return_bytes = 32,
210 .dcn_downspread_percent = 0.5,
211 .downspread_percent = 0.38,
212 .dram_page_open_time_ns = 50.0,
213 .dram_rw_turnaround_time_ns = 17.5,
214 .dram_return_buffer_per_channel_bytes = 8192,
215 .round_trip_ping_latency_dcfclk_cycles = 191,
216 .urgent_out_of_order_return_per_channel_bytes = 4096,
217 .channel_interleave_bytes = 256,
220 .gpuvm_min_page_size_bytes = 4096,
221 .hostvm_min_page_size_bytes = 4096,
222 .dram_clock_change_latency_us = 23.84,
223 .writeback_dram_clock_change_latency_us = 23.0,
224 .return_bus_width_bytes = 64,
225 .dispclk_dppclk_vco_speed_mhz = 3550,
226 .xfc_bus_transport_time_us = 20, // ?
227 .xfc_xbuf_latency_tolerance_us = 4, // ?
228 .use_urgent_burst_bw = 1, // ?
230 .do_urgent_latency_adjustment = false,
231 .urgent_latency_adjustment_fabric_clock_component_us = 0,
232 .urgent_latency_adjustment_fabric_clock_reference_mhz = 0,
235 enum dcn301_clk_src_array_id {
243 /* begin *********************
244 * macros to expend register list macro defined in HW object header file
248 /* TODO awful hack. fixup dcn20_dwb.h */
250 #define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg
252 #define BASE(seg) BASE_INNER(seg)
254 #define SR(reg_name)\
255 .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
258 #define SRI(reg_name, block, id)\
259 .reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
260 mm ## block ## id ## _ ## reg_name
262 #define SRI2(reg_name, block, id)\
263 .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
266 #define SRIR(var_name, reg_name, block, id)\
267 .var_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
268 mm ## block ## id ## _ ## reg_name
270 #define SRII(reg_name, block, id)\
271 .reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
272 mm ## block ## id ## _ ## reg_name
274 #define SRII2(reg_name_pre, reg_name_post, id)\
275 .reg_name_pre ## _ ## reg_name_post[id] = BASE(mm ## reg_name_pre \
276 ## id ## _ ## reg_name_post ## _BASE_IDX) + \
277 mm ## reg_name_pre ## id ## _ ## reg_name_post
279 #define SRII_MPC_RMU(reg_name, block, id)\
280 .RMU##_##reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
281 mm ## block ## id ## _ ## reg_name
283 #define SRII_DWB(reg_name, temp_name, block, id)\
284 .reg_name[id] = BASE(mm ## block ## id ## _ ## temp_name ## _BASE_IDX) + \
285 mm ## block ## id ## _ ## temp_name
287 #define DCCG_SRII(reg_name, block, id)\
288 .block ## _ ## reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
289 mm ## block ## id ## _ ## reg_name
291 #define VUPDATE_SRII(reg_name, block, id)\
292 .reg_name[id] = BASE(mm ## reg_name ## _ ## block ## id ## _BASE_IDX) + \
293 mm ## reg_name ## _ ## block ## id
296 #define NBIO_BASE_INNER(seg) \
297 NBIO_BASE__INST0_SEG ## seg
299 #define NBIO_BASE(seg) \
302 #define NBIO_SR(reg_name)\
303 .reg_name = NBIO_BASE(regBIF_BX0_ ## reg_name ## _BASE_IDX) + \
304 regBIF_BX0_ ## reg_name
307 #define MMHUB_BASE_INNER(seg) \
308 MMHUB_BASE__INST0_SEG ## seg
310 #define MMHUB_BASE(seg) \
311 MMHUB_BASE_INNER(seg)
313 #define MMHUB_SR(reg_name)\
314 .reg_name = MMHUB_BASE(regMM ## reg_name ## _BASE_IDX) + \
318 #define CLK_BASE_INNER(seg) \
319 CLK_BASE__INST0_SEG ## seg
321 #define CLK_BASE(seg) \
324 #define CLK_SRI(reg_name, block, inst)\
325 .reg_name = CLK_BASE(mm ## block ## _ ## inst ## _ ## reg_name ## _BASE_IDX) + \
326 mm ## block ## _ ## inst ## _ ## reg_name
328 static const struct bios_registers bios_regs = {
329 NBIO_SR(BIOS_SCRATCH_3),
330 NBIO_SR(BIOS_SCRATCH_6)
333 #define clk_src_regs(index, pllid)\
335 CS_COMMON_REG_LIST_DCN3_01(index, pllid),\
338 static const struct dce110_clk_src_regs clk_src_regs[] = {
345 static const struct dce110_clk_src_shift cs_shift = {
346 CS_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT)
349 static const struct dce110_clk_src_mask cs_mask = {
350 CS_COMMON_MASK_SH_LIST_DCN2_0(_MASK)
353 #define abm_regs(id)\
355 ABM_DCN301_REG_LIST(id)\
358 static const struct dce_abm_registers abm_regs[] = {
365 static const struct dce_abm_shift abm_shift = {
366 ABM_MASK_SH_LIST_DCN301(__SHIFT)
369 static const struct dce_abm_mask abm_mask = {
370 ABM_MASK_SH_LIST_DCN301(_MASK)
373 #define audio_regs(id)\
375 AUD_COMMON_REG_LIST(id)\
378 static const struct dce_audio_registers audio_regs[] = {
388 #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
389 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\
390 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\
391 AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)
393 static const struct dce_audio_shift audio_shift = {
394 DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT)
397 static const struct dce_audio_mask audio_mask = {
398 DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)
401 #define vpg_regs(id)\
403 VPG_DCN3_REG_LIST(id)\
406 static const struct dcn30_vpg_registers vpg_regs[] = {
413 static const struct dcn30_vpg_shift vpg_shift = {
414 DCN3_VPG_MASK_SH_LIST(__SHIFT)
417 static const struct dcn30_vpg_mask vpg_mask = {
418 DCN3_VPG_MASK_SH_LIST(_MASK)
421 #define afmt_regs(id)\
423 AFMT_DCN3_REG_LIST(id)\
426 static const struct dcn30_afmt_registers afmt_regs[] = {
433 static const struct dcn30_afmt_shift afmt_shift = {
434 DCN3_AFMT_MASK_SH_LIST(__SHIFT)
437 static const struct dcn30_afmt_mask afmt_mask = {
438 DCN3_AFMT_MASK_SH_LIST(_MASK)
441 #define stream_enc_regs(id)\
443 SE_DCN3_REG_LIST(id)\
446 static const struct dcn10_stream_enc_registers stream_enc_regs[] = {
453 static const struct dcn10_stream_encoder_shift se_shift = {
454 SE_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
457 static const struct dcn10_stream_encoder_mask se_mask = {
458 SE_COMMON_MASK_SH_LIST_DCN30(_MASK)
462 #define aux_regs(id)\
464 DCN2_AUX_REG_LIST(id)\
467 static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = {
474 #define hpd_regs(id)\
479 static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {
486 #define link_regs(id, phyid)\
488 LE_DCN301_REG_LIST(id), \
489 UNIPHY_DCN2_REG_LIST(phyid), \
492 static const struct dce110_aux_registers_shift aux_shift = {
493 DCN_AUX_MASK_SH_LIST(__SHIFT)
496 static const struct dce110_aux_registers_mask aux_mask = {
497 DCN_AUX_MASK_SH_LIST(_MASK)
500 static const struct dcn10_link_enc_registers link_enc_regs[] = {
507 static const struct dcn10_link_enc_shift le_shift = {
508 LINK_ENCODER_MASK_SH_LIST_DCN301(__SHIFT)
511 static const struct dcn10_link_enc_mask le_mask = {
512 LINK_ENCODER_MASK_SH_LIST_DCN301(_MASK)
515 #define panel_cntl_regs(id)\
517 DCN301_PANEL_CNTL_REG_LIST(id),\
520 static const struct dce_panel_cntl_registers panel_cntl_regs[] = {
525 static const struct dcn301_panel_cntl_shift panel_cntl_shift = {
526 DCN301_PANEL_CNTL_MASK_SH_LIST(__SHIFT)
529 static const struct dcn301_panel_cntl_mask panel_cntl_mask = {
530 DCN301_PANEL_CNTL_MASK_SH_LIST(_MASK)
533 #define dpp_regs(id)\
535 DPP_REG_LIST_DCN30(id),\
538 static const struct dcn3_dpp_registers dpp_regs[] = {
545 static const struct dcn3_dpp_shift tf_shift = {
546 DPP_REG_LIST_SH_MASK_DCN30(__SHIFT)
549 static const struct dcn3_dpp_mask tf_mask = {
550 DPP_REG_LIST_SH_MASK_DCN30(_MASK)
553 #define opp_regs(id)\
555 OPP_REG_LIST_DCN30(id),\
558 static const struct dcn20_opp_registers opp_regs[] = {
565 static const struct dcn20_opp_shift opp_shift = {
566 OPP_MASK_SH_LIST_DCN20(__SHIFT)
569 static const struct dcn20_opp_mask opp_mask = {
570 OPP_MASK_SH_LIST_DCN20(_MASK)
573 #define aux_engine_regs(id)\
575 AUX_COMMON_REG_LIST0(id), \
578 .AUX_RESET_MASK = DP_AUX0_AUX_CONTROL__AUX_RESET_MASK, \
581 static const struct dce110_aux_registers aux_engine_regs[] = {
588 #define dwbc_regs_dcn3(id)\
590 DWBC_COMMON_REG_LIST_DCN30(id),\
593 static const struct dcn30_dwbc_registers dwbc30_regs[] = {
597 static const struct dcn30_dwbc_shift dwbc30_shift = {
598 DWBC_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
601 static const struct dcn30_dwbc_mask dwbc30_mask = {
602 DWBC_COMMON_MASK_SH_LIST_DCN30(_MASK)
605 #define mcif_wb_regs_dcn3(id)\
607 MCIF_WB_COMMON_REG_LIST_DCN30(id),\
610 static const struct dcn30_mmhubbub_registers mcif_wb30_regs[] = {
614 static const struct dcn30_mmhubbub_shift mcif_wb30_shift = {
615 MCIF_WB_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
618 static const struct dcn30_mmhubbub_mask mcif_wb30_mask = {
619 MCIF_WB_COMMON_MASK_SH_LIST_DCN30(_MASK)
622 #define dsc_regsDCN20(id)\
624 DSC_REG_LIST_DCN20(id)\
627 static const struct dcn20_dsc_registers dsc_regs[] = {
633 static const struct dcn20_dsc_shift dsc_shift = {
634 DSC_REG_LIST_SH_MASK_DCN20(__SHIFT)
637 static const struct dcn20_dsc_mask dsc_mask = {
638 DSC_REG_LIST_SH_MASK_DCN20(_MASK)
641 static const struct dcn30_mpc_registers mpc_regs = {
642 MPC_REG_LIST_DCN3_0(0),
643 MPC_REG_LIST_DCN3_0(1),
644 MPC_REG_LIST_DCN3_0(2),
645 MPC_REG_LIST_DCN3_0(3),
646 MPC_OUT_MUX_REG_LIST_DCN3_0(0),
647 MPC_OUT_MUX_REG_LIST_DCN3_0(1),
648 MPC_OUT_MUX_REG_LIST_DCN3_0(2),
649 MPC_OUT_MUX_REG_LIST_DCN3_0(3),
650 MPC_RMU_GLOBAL_REG_LIST_DCN3AG,
651 MPC_RMU_REG_LIST_DCN3AG(0),
652 MPC_RMU_REG_LIST_DCN3AG(1),
653 MPC_DWB_MUX_REG_LIST_DCN3_0(0),
656 static const struct dcn30_mpc_shift mpc_shift = {
657 MPC_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
660 static const struct dcn30_mpc_mask mpc_mask = {
661 MPC_COMMON_MASK_SH_LIST_DCN30(_MASK)
664 #define optc_regs(id)\
665 [id] = {OPTC_COMMON_REG_LIST_DCN3_0(id)}
668 static const struct dcn_optc_registers optc_regs[] = {
675 static const struct dcn_optc_shift optc_shift = {
676 OPTC_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
679 static const struct dcn_optc_mask optc_mask = {
680 OPTC_COMMON_MASK_SH_LIST_DCN30(_MASK)
683 #define hubp_regs(id)\
685 HUBP_REG_LIST_DCN30(id)\
688 static const struct dcn_hubp2_registers hubp_regs[] = {
695 static const struct dcn_hubp2_shift hubp_shift = {
696 HUBP_MASK_SH_LIST_DCN30(__SHIFT)
699 static const struct dcn_hubp2_mask hubp_mask = {
700 HUBP_MASK_SH_LIST_DCN30(_MASK)
703 static const struct dcn_hubbub_registers hubbub_reg = {
704 HUBBUB_REG_LIST_DCN301(0)
707 static const struct dcn_hubbub_shift hubbub_shift = {
708 HUBBUB_MASK_SH_LIST_DCN301(__SHIFT)
711 static const struct dcn_hubbub_mask hubbub_mask = {
712 HUBBUB_MASK_SH_LIST_DCN301(_MASK)
715 static const struct dccg_registers dccg_regs = {
716 DCCG_REG_LIST_DCN301()
719 static const struct dccg_shift dccg_shift = {
720 DCCG_MASK_SH_LIST_DCN301(__SHIFT)
723 static const struct dccg_mask dccg_mask = {
724 DCCG_MASK_SH_LIST_DCN301(_MASK)
727 static const struct dce_hwseq_registers hwseq_reg = {
728 HWSEQ_DCN301_REG_LIST()
731 static const struct dce_hwseq_shift hwseq_shift = {
732 HWSEQ_DCN301_MASK_SH_LIST(__SHIFT)
735 static const struct dce_hwseq_mask hwseq_mask = {
736 HWSEQ_DCN301_MASK_SH_LIST(_MASK)
738 #define vmid_regs(id)\
740 DCN20_VMID_REG_LIST(id)\
743 static const struct dcn_vmid_registers vmid_regs[] = {
762 static const struct dcn20_vmid_shift vmid_shifts = {
763 DCN20_VMID_MASK_SH_LIST(__SHIFT)
766 static const struct dcn20_vmid_mask vmid_masks = {
767 DCN20_VMID_MASK_SH_LIST(_MASK)
770 static const struct resource_caps res_cap_dcn301 = {
771 .num_timing_generator = 4,
773 .num_video_plane = 4,
775 .num_stream_encoder = 4,
784 static const struct dc_plane_cap plane_cap = {
785 .type = DC_PLANE_TYPE_DCN_UNIVERSAL,
786 .blends_with_above = true,
787 .blends_with_below = true,
788 .per_pixel_alpha = true,
790 .pixel_format_support = {
798 .max_upscale_factor = {
804 .max_downscale_factor = {
813 static const struct dc_debug_options debug_defaults_drv = {
814 .disable_dmcu = true,
815 .force_abm_enable = false,
816 .timing_trace = false,
818 .disable_dpp_power_gate = true,
819 .disable_hubp_power_gate = true,
820 .disable_clock_gate = true,
821 .disable_pplib_clock_request = true,
822 .disable_pplib_wm_range = true,
823 .disable_stutter = true,
824 .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
825 .force_single_disp_pipe_split = false,
826 .disable_dcc = DCC_ENABLE,
828 .performance_trace = false,
829 .max_downscale_src_width = 7680,/*upto 8K*/
830 .scl_reset_length10 = true,
831 .sanity_checks = false,
832 .underflow_assert_delay_us = 0xFFFFFFFF,
833 .dwb_fi_phase = -1, // -1 = disable
834 .dmub_command_table = true,
837 static const struct dc_debug_options debug_defaults_diags = {
838 .disable_dmcu = true,
839 .force_abm_enable = false,
840 .timing_trace = true,
842 .disable_dpp_power_gate = true,
843 .disable_hubp_power_gate = true,
844 .disable_clock_gate = true,
845 .disable_pplib_clock_request = true,
846 .disable_pplib_wm_range = true,
847 .disable_stutter = true,
848 .scl_reset_length10 = true,
849 .dwb_fi_phase = -1, // -1 = disable
850 .dmub_command_table = true,
853 void dcn301_dpp_destroy(struct dpp **dpp)
855 kfree(TO_DCN20_DPP(*dpp));
859 struct dpp *dcn301_dpp_create(
860 struct dc_context *ctx,
863 struct dcn3_dpp *dpp =
864 kzalloc(sizeof(struct dcn3_dpp), GFP_KERNEL);
869 if (dpp3_construct(dpp, ctx, inst,
870 &dpp_regs[inst], &tf_shift, &tf_mask))
877 struct output_pixel_processor *dcn301_opp_create(
878 struct dc_context *ctx, uint32_t inst)
880 struct dcn20_opp *opp =
881 kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
888 dcn20_opp_construct(opp, ctx, inst,
889 &opp_regs[inst], &opp_shift, &opp_mask);
893 struct dce_aux *dcn301_aux_engine_create(
894 struct dc_context *ctx,
897 struct aux_engine_dce110 *aux_engine =
898 kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
903 dce110_aux_engine_construct(aux_engine, ctx, inst,
904 SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD,
905 &aux_engine_regs[inst],
908 ctx->dc->caps.extended_aux_timeout_support);
910 return &aux_engine->base;
912 #define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) }
914 static const struct dce_i2c_registers i2c_hw_regs[] = {
921 static const struct dce_i2c_shift i2c_shifts = {
922 I2C_COMMON_MASK_SH_LIST_DCN2(__SHIFT)
925 static const struct dce_i2c_mask i2c_masks = {
926 I2C_COMMON_MASK_SH_LIST_DCN2(_MASK)
929 struct dce_i2c_hw *dcn301_i2c_hw_create(
930 struct dc_context *ctx,
933 struct dce_i2c_hw *dce_i2c_hw =
934 kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
939 dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst,
940 &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks);
944 static struct mpc *dcn301_mpc_create(
945 struct dc_context *ctx,
949 struct dcn30_mpc *mpc30 = kzalloc(sizeof(struct dcn30_mpc),
955 dcn30_mpc_construct(mpc30, ctx,
965 struct hubbub *dcn301_hubbub_create(struct dc_context *ctx)
969 struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub),
975 hubbub301_construct(hubbub3, ctx,
981 for (i = 0; i < res_cap_dcn301.num_vmid; i++) {
982 struct dcn20_vmid *vmid = &hubbub3->vmid[i];
986 vmid->regs = &vmid_regs[i];
987 vmid->shifts = &vmid_shifts;
988 vmid->masks = &vmid_masks;
991 hubbub3->num_vmid = res_cap_dcn301.num_vmid;
993 return &hubbub3->base;
996 struct timing_generator *dcn301_timing_generator_create(
997 struct dc_context *ctx,
1000 struct optc *tgn10 =
1001 kzalloc(sizeof(struct optc), GFP_KERNEL);
1006 tgn10->base.inst = instance;
1007 tgn10->base.ctx = ctx;
1009 tgn10->tg_regs = &optc_regs[instance];
1010 tgn10->tg_shift = &optc_shift;
1011 tgn10->tg_mask = &optc_mask;
1013 dcn30_timing_generator_init(tgn10);
1015 return &tgn10->base;
1018 static const struct encoder_feature_support link_enc_feature = {
1019 .max_hdmi_deep_color = COLOR_DEPTH_121212,
1020 .max_hdmi_pixel_clock = 600000,
1021 .hdmi_ycbcr420_supported = true,
1022 .dp_ycbcr420_supported = true,
1023 .fec_supported = true,
1024 .flags.bits.IS_HBR2_CAPABLE = true,
1025 .flags.bits.IS_HBR3_CAPABLE = true,
1026 .flags.bits.IS_TPS3_CAPABLE = true,
1027 .flags.bits.IS_TPS4_CAPABLE = true
1030 struct link_encoder *dcn301_link_encoder_create(
1031 const struct encoder_init_data *enc_init_data)
1033 struct dcn20_link_encoder *enc20 =
1034 kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
1039 dcn301_link_encoder_construct(enc20,
1042 &link_enc_regs[enc_init_data->transmitter],
1043 &link_enc_aux_regs[enc_init_data->channel - 1],
1044 &link_enc_hpd_regs[enc_init_data->hpd_source],
1048 return &enc20->enc10.base;
1051 struct panel_cntl *dcn301_panel_cntl_create(const struct panel_cntl_init_data *init_data)
1053 struct dcn301_panel_cntl *panel_cntl =
1054 kzalloc(sizeof(struct dcn301_panel_cntl), GFP_KERNEL);
1059 dcn301_panel_cntl_construct(panel_cntl,
1061 &panel_cntl_regs[init_data->inst],
1065 return &panel_cntl->base;
1071 #define REG(reg_name) \
1072 (DCN_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## reg_name)
1074 static uint32_t read_pipe_fuses(struct dc_context *ctx)
1076 uint32_t value = REG_READ(CC_DC_PIPE_DIS);
1077 /* RV1 support max 4 pipes */
1078 value = value & 0xf;
1083 static void read_dce_straps(
1084 struct dc_context *ctx,
1085 struct resource_straps *straps)
1087 generic_reg_get(ctx, mmDC_PINSTRAPS + BASE(mmDC_PINSTRAPS_BASE_IDX),
1088 FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio);
1092 static struct audio *dcn301_create_audio(
1093 struct dc_context *ctx, unsigned int inst)
1095 return dce_audio_create(ctx, inst,
1096 &audio_regs[inst], &audio_shift, &audio_mask);
1099 static struct vpg *dcn301_vpg_create(
1100 struct dc_context *ctx,
1103 struct dcn30_vpg *vpg3 = kzalloc(sizeof(struct dcn30_vpg), GFP_KERNEL);
1108 vpg3_construct(vpg3, ctx, inst,
1116 static struct afmt *dcn301_afmt_create(
1117 struct dc_context *ctx,
1120 struct dcn30_afmt *afmt3 = kzalloc(sizeof(struct dcn30_afmt), GFP_KERNEL);
1125 afmt3_construct(afmt3, ctx, inst,
1130 return &afmt3->base;
1133 struct stream_encoder *dcn301_stream_encoder_create(
1134 enum engine_id eng_id,
1135 struct dc_context *ctx)
1137 struct dcn10_stream_encoder *enc1;
1143 /* Mapping of VPG, AFMT, DME register blocks to DIO block instance */
1144 if (eng_id <= ENGINE_ID_DIGF) {
1150 enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
1151 vpg = dcn301_vpg_create(ctx, vpg_inst);
1152 afmt = dcn301_afmt_create(ctx, afmt_inst);
1154 if (!enc1 || !vpg || !afmt)
1157 dcn30_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios,
1159 &stream_enc_regs[eng_id],
1160 &se_shift, &se_mask);
1165 struct dce_hwseq *dcn301_hwseq_create(
1166 struct dc_context *ctx)
1168 struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
1172 hws->regs = &hwseq_reg;
1173 hws->shifts = &hwseq_shift;
1174 hws->masks = &hwseq_mask;
1178 static const struct resource_create_funcs res_create_funcs = {
1179 .read_dce_straps = read_dce_straps,
1180 .create_audio = dcn301_create_audio,
1181 .create_stream_encoder = dcn301_stream_encoder_create,
1182 .create_hwseq = dcn301_hwseq_create,
1185 static const struct resource_create_funcs res_create_maximus_funcs = {
1186 .read_dce_straps = NULL,
1187 .create_audio = NULL,
1188 .create_stream_encoder = NULL,
1189 .create_hwseq = dcn301_hwseq_create,
1192 static void dcn301_pp_smu_destroy(struct pp_smu_funcs **pp_smu);
1194 static void dcn301_destruct(struct dcn301_resource_pool *pool)
1198 for (i = 0; i < pool->base.stream_enc_count; i++) {
1199 if (pool->base.stream_enc[i] != NULL) {
1200 if (pool->base.stream_enc[i]->vpg != NULL) {
1201 kfree(DCN30_VPG_FROM_VPG(pool->base.stream_enc[i]->vpg));
1202 pool->base.stream_enc[i]->vpg = NULL;
1204 if (pool->base.stream_enc[i]->afmt != NULL) {
1205 kfree(DCN30_AFMT_FROM_AFMT(pool->base.stream_enc[i]->afmt));
1206 pool->base.stream_enc[i]->afmt = NULL;
1208 kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i]));
1209 pool->base.stream_enc[i] = NULL;
1213 for (i = 0; i < pool->base.res_cap->num_dsc; i++) {
1214 if (pool->base.dscs[i] != NULL)
1215 dcn20_dsc_destroy(&pool->base.dscs[i]);
1218 if (pool->base.mpc != NULL) {
1219 kfree(TO_DCN20_MPC(pool->base.mpc));
1220 pool->base.mpc = NULL;
1222 if (pool->base.hubbub != NULL) {
1223 kfree(pool->base.hubbub);
1224 pool->base.hubbub = NULL;
1226 for (i = 0; i < pool->base.pipe_count; i++) {
1227 if (pool->base.dpps[i] != NULL)
1228 dcn301_dpp_destroy(&pool->base.dpps[i]);
1230 if (pool->base.ipps[i] != NULL)
1231 pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]);
1233 if (pool->base.hubps[i] != NULL) {
1234 kfree(TO_DCN20_HUBP(pool->base.hubps[i]));
1235 pool->base.hubps[i] = NULL;
1238 if (pool->base.irqs != NULL) {
1239 dal_irq_service_destroy(&pool->base.irqs);
1243 for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
1244 if (pool->base.engines[i] != NULL)
1245 dce110_engine_destroy(&pool->base.engines[i]);
1246 if (pool->base.hw_i2cs[i] != NULL) {
1247 kfree(pool->base.hw_i2cs[i]);
1248 pool->base.hw_i2cs[i] = NULL;
1250 if (pool->base.sw_i2cs[i] != NULL) {
1251 kfree(pool->base.sw_i2cs[i]);
1252 pool->base.sw_i2cs[i] = NULL;
1256 for (i = 0; i < pool->base.res_cap->num_opp; i++) {
1257 if (pool->base.opps[i] != NULL)
1258 pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]);
1261 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
1262 if (pool->base.timing_generators[i] != NULL) {
1263 kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
1264 pool->base.timing_generators[i] = NULL;
1268 for (i = 0; i < pool->base.res_cap->num_dwb; i++) {
1269 if (pool->base.dwbc[i] != NULL) {
1270 kfree(TO_DCN30_DWBC(pool->base.dwbc[i]));
1271 pool->base.dwbc[i] = NULL;
1273 if (pool->base.mcif_wb[i] != NULL) {
1274 kfree(TO_DCN30_MMHUBBUB(pool->base.mcif_wb[i]));
1275 pool->base.mcif_wb[i] = NULL;
1279 for (i = 0; i < pool->base.audio_count; i++) {
1280 if (pool->base.audios[i])
1281 dce_aud_destroy(&pool->base.audios[i]);
1284 for (i = 0; i < pool->base.clk_src_count; i++) {
1285 if (pool->base.clock_sources[i] != NULL) {
1286 dcn20_clock_source_destroy(&pool->base.clock_sources[i]);
1287 pool->base.clock_sources[i] = NULL;
1291 for (i = 0; i < pool->base.res_cap->num_mpc_3dlut; i++) {
1292 if (pool->base.mpc_lut[i] != NULL) {
1293 dc_3dlut_func_release(pool->base.mpc_lut[i]);
1294 pool->base.mpc_lut[i] = NULL;
1296 if (pool->base.mpc_shaper[i] != NULL) {
1297 dc_transfer_func_release(pool->base.mpc_shaper[i]);
1298 pool->base.mpc_shaper[i] = NULL;
1302 if (pool->base.dp_clock_source != NULL) {
1303 dcn20_clock_source_destroy(&pool->base.dp_clock_source);
1304 pool->base.dp_clock_source = NULL;
1307 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
1308 if (pool->base.multiple_abms[i] != NULL)
1309 dce_abm_destroy(&pool->base.multiple_abms[i]);
1312 if (pool->base.dccg != NULL)
1313 dcn_dccg_destroy(&pool->base.dccg);
1315 if (pool->base.pp_smu != NULL)
1316 dcn301_pp_smu_destroy(&pool->base.pp_smu);
1319 struct hubp *dcn301_hubp_create(
1320 struct dc_context *ctx,
1323 struct dcn20_hubp *hubp2 =
1324 kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
1329 if (hubp3_construct(hubp2, ctx, inst,
1330 &hubp_regs[inst], &hubp_shift, &hubp_mask))
1331 return &hubp2->base;
1333 BREAK_TO_DEBUGGER();
1338 bool dcn301_dwbc_create(struct dc_context *ctx, struct resource_pool *pool)
1341 uint32_t pipe_count = pool->res_cap->num_dwb;
1343 for (i = 0; i < pipe_count; i++) {
1344 struct dcn30_dwbc *dwbc30 = kzalloc(sizeof(struct dcn30_dwbc),
1348 dm_error("DC: failed to create dwbc30!\n");
1352 dcn30_dwbc_construct(dwbc30, ctx,
1358 pool->dwbc[i] = &dwbc30->base;
1363 bool dcn301_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool)
1366 uint32_t pipe_count = pool->res_cap->num_dwb;
1368 for (i = 0; i < pipe_count; i++) {
1369 struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub),
1373 dm_error("DC: failed to create mcif_wb30!\n");
1377 dcn30_mmhubbub_construct(mcif_wb30, ctx,
1383 pool->mcif_wb[i] = &mcif_wb30->base;
1388 static struct display_stream_compressor *dcn301_dsc_create(
1389 struct dc_context *ctx, uint32_t inst)
1391 struct dcn20_dsc *dsc =
1392 kzalloc(sizeof(struct dcn20_dsc), GFP_KERNEL);
1395 BREAK_TO_DEBUGGER();
1399 dsc2_construct(dsc, ctx, inst, &dsc_regs[inst], &dsc_shift, &dsc_mask);
1404 static void dcn301_destroy_resource_pool(struct resource_pool **pool)
1406 struct dcn301_resource_pool *dcn301_pool = TO_DCN301_RES_POOL(*pool);
1408 dcn301_destruct(dcn301_pool);
1413 static struct clock_source *dcn301_clock_source_create(
1414 struct dc_context *ctx,
1415 struct dc_bios *bios,
1416 enum clock_source_id id,
1417 const struct dce110_clk_src_regs *regs,
1420 struct dce110_clk_src *clk_src =
1421 kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
1426 if (dcn301_clk_src_construct(clk_src, ctx, bios, id,
1427 regs, &cs_shift, &cs_mask)) {
1428 clk_src->base.dp_clk_src = dp_clk_src;
1429 return &clk_src->base;
1432 BREAK_TO_DEBUGGER();
1436 static struct dc_cap_funcs cap_funcs = {
1437 .get_dcc_compression_cap = dcn20_get_dcc_compression_cap
1440 #define fixed16_to_double(x) (((double) x) / ((double) (1 << 16)))
1441 #define fixed16_to_double_to_cpu(x) fixed16_to_double(le32_to_cpu(x))
1443 static bool is_soc_bounding_box_valid(struct dc *dc)
1445 uint32_t hw_internal_rev = dc->ctx->asic_id.hw_internal_rev;
1447 if (ASICREV_IS_VANGOGH(hw_internal_rev))
1453 static bool init_soc_bounding_box(struct dc *dc,
1454 struct dcn301_resource_pool *pool)
1456 const struct gpu_info_soc_bounding_box_v1_0 *bb = dc->soc_bounding_box;
1457 struct _vcs_dpi_soc_bounding_box_st *loaded_bb = &dcn3_01_soc;
1458 struct _vcs_dpi_ip_params_st *loaded_ip = &dcn3_01_ip;
1460 DC_LOGGER_INIT(dc->ctx->logger);
1462 if (!bb && !is_soc_bounding_box_valid(dc)) {
1463 DC_LOG_ERROR("%s: not valid soc bounding box/n", __func__);
1467 if (bb && !is_soc_bounding_box_valid(dc)) {
1470 dcn3_01_soc.sr_exit_time_us =
1471 fixed16_to_double_to_cpu(bb->sr_exit_time_us);
1472 dcn3_01_soc.sr_enter_plus_exit_time_us =
1473 fixed16_to_double_to_cpu(bb->sr_enter_plus_exit_time_us);
1474 dcn3_01_soc.urgent_latency_us =
1475 fixed16_to_double_to_cpu(bb->urgent_latency_us);
1476 dcn3_01_soc.urgent_latency_pixel_data_only_us =
1477 fixed16_to_double_to_cpu(bb->urgent_latency_pixel_data_only_us);
1478 dcn3_01_soc.urgent_latency_pixel_mixed_with_vm_data_us =
1479 fixed16_to_double_to_cpu(bb->urgent_latency_pixel_mixed_with_vm_data_us);
1480 dcn3_01_soc.urgent_latency_vm_data_only_us =
1481 fixed16_to_double_to_cpu(bb->urgent_latency_vm_data_only_us);
1482 dcn3_01_soc.urgent_out_of_order_return_per_channel_pixel_only_bytes =
1483 le32_to_cpu(bb->urgent_out_of_order_return_per_channel_pixel_only_bytes);
1484 dcn3_01_soc.urgent_out_of_order_return_per_channel_pixel_and_vm_bytes =
1485 le32_to_cpu(bb->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes);
1486 dcn3_01_soc.urgent_out_of_order_return_per_channel_vm_only_bytes =
1487 le32_to_cpu(bb->urgent_out_of_order_return_per_channel_vm_only_bytes);
1488 dcn3_01_soc.pct_ideal_dram_sdp_bw_after_urgent_pixel_only =
1489 fixed16_to_double_to_cpu(bb->pct_ideal_dram_sdp_bw_after_urgent_pixel_only);
1490 dcn3_01_soc.pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm =
1491 fixed16_to_double_to_cpu(bb->pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm);
1492 dcn3_01_soc.pct_ideal_dram_sdp_bw_after_urgent_vm_only =
1493 fixed16_to_double_to_cpu(bb->pct_ideal_dram_sdp_bw_after_urgent_vm_only);
1494 dcn3_01_soc.max_avg_sdp_bw_use_normal_percent =
1495 fixed16_to_double_to_cpu(bb->max_avg_sdp_bw_use_normal_percent);
1496 dcn3_01_soc.max_avg_dram_bw_use_normal_percent =
1497 fixed16_to_double_to_cpu(bb->max_avg_dram_bw_use_normal_percent);
1498 dcn3_01_soc.writeback_latency_us =
1499 fixed16_to_double_to_cpu(bb->writeback_latency_us);
1500 dcn3_01_soc.ideal_dram_bw_after_urgent_percent =
1501 fixed16_to_double_to_cpu(bb->ideal_dram_bw_after_urgent_percent);
1502 dcn3_01_soc.max_request_size_bytes =
1503 le32_to_cpu(bb->max_request_size_bytes);
1504 dcn3_01_soc.dram_channel_width_bytes =
1505 le32_to_cpu(bb->dram_channel_width_bytes);
1506 dcn3_01_soc.fabric_datapath_to_dcn_data_return_bytes =
1507 le32_to_cpu(bb->fabric_datapath_to_dcn_data_return_bytes);
1508 dcn3_01_soc.dcn_downspread_percent =
1509 fixed16_to_double_to_cpu(bb->dcn_downspread_percent);
1510 dcn3_01_soc.downspread_percent =
1511 fixed16_to_double_to_cpu(bb->downspread_percent);
1512 dcn3_01_soc.dram_page_open_time_ns =
1513 fixed16_to_double_to_cpu(bb->dram_page_open_time_ns);
1514 dcn3_01_soc.dram_rw_turnaround_time_ns =
1515 fixed16_to_double_to_cpu(bb->dram_rw_turnaround_time_ns);
1516 dcn3_01_soc.dram_return_buffer_per_channel_bytes =
1517 le32_to_cpu(bb->dram_return_buffer_per_channel_bytes);
1518 dcn3_01_soc.round_trip_ping_latency_dcfclk_cycles =
1519 le32_to_cpu(bb->round_trip_ping_latency_dcfclk_cycles);
1520 dcn3_01_soc.urgent_out_of_order_return_per_channel_bytes =
1521 le32_to_cpu(bb->urgent_out_of_order_return_per_channel_bytes);
1522 dcn3_01_soc.channel_interleave_bytes =
1523 le32_to_cpu(bb->channel_interleave_bytes);
1524 dcn3_01_soc.num_banks =
1525 le32_to_cpu(bb->num_banks);
1526 dcn3_01_soc.num_chans =
1527 le32_to_cpu(bb->num_chans);
1528 dcn3_01_soc.gpuvm_min_page_size_bytes =
1529 le32_to_cpu(bb->vmm_page_size_bytes);
1530 dcn3_01_soc.dram_clock_change_latency_us =
1531 fixed16_to_double_to_cpu(bb->dram_clock_change_latency_us);
1532 dcn3_01_soc.writeback_dram_clock_change_latency_us =
1533 fixed16_to_double_to_cpu(bb->writeback_dram_clock_change_latency_us);
1534 dcn3_01_soc.return_bus_width_bytes =
1535 le32_to_cpu(bb->return_bus_width_bytes);
1536 dcn3_01_soc.dispclk_dppclk_vco_speed_mhz =
1537 le32_to_cpu(bb->dispclk_dppclk_vco_speed_mhz);
1538 dcn3_01_soc.xfc_bus_transport_time_us =
1539 le32_to_cpu(bb->xfc_bus_transport_time_us);
1540 dcn3_01_soc.xfc_xbuf_latency_tolerance_us =
1541 le32_to_cpu(bb->xfc_xbuf_latency_tolerance_us);
1542 dcn3_01_soc.use_urgent_burst_bw =
1543 le32_to_cpu(bb->use_urgent_burst_bw);
1544 dcn3_01_soc.num_states =
1545 le32_to_cpu(bb->num_states);
1547 for (i = 0; i < dcn3_01_soc.num_states; i++) {
1548 dcn3_01_soc.clock_limits[i].state =
1549 le32_to_cpu(bb->clock_limits[i].state);
1550 dcn3_01_soc.clock_limits[i].dcfclk_mhz =
1551 fixed16_to_double_to_cpu(bb->clock_limits[i].dcfclk_mhz);
1552 dcn3_01_soc.clock_limits[i].fabricclk_mhz =
1553 fixed16_to_double_to_cpu(bb->clock_limits[i].fabricclk_mhz);
1554 dcn3_01_soc.clock_limits[i].dispclk_mhz =
1555 fixed16_to_double_to_cpu(bb->clock_limits[i].dispclk_mhz);
1556 dcn3_01_soc.clock_limits[i].dppclk_mhz =
1557 fixed16_to_double_to_cpu(bb->clock_limits[i].dppclk_mhz);
1558 dcn3_01_soc.clock_limits[i].phyclk_mhz =
1559 fixed16_to_double_to_cpu(bb->clock_limits[i].phyclk_mhz);
1560 dcn3_01_soc.clock_limits[i].socclk_mhz =
1561 fixed16_to_double_to_cpu(bb->clock_limits[i].socclk_mhz);
1562 dcn3_01_soc.clock_limits[i].dscclk_mhz =
1563 fixed16_to_double_to_cpu(bb->clock_limits[i].dscclk_mhz);
1564 dcn3_01_soc.clock_limits[i].dram_speed_mts =
1565 fixed16_to_double_to_cpu(bb->clock_limits[i].dram_speed_mts);
1569 if (pool->base.pp_smu) {
1570 struct pp_smu_nv_clock_table max_clocks = {0};
1571 unsigned int uclk_states[8] = {0};
1572 unsigned int num_states = 0;
1573 enum pp_smu_status status;
1574 bool clock_limits_available = false;
1575 bool uclk_states_available = false;
1577 if (pool->base.pp_smu->nv_funcs.get_uclk_dpm_states) {
1578 status = (pool->base.pp_smu->nv_funcs.get_uclk_dpm_states)
1579 (&pool->base.pp_smu->nv_funcs.pp_smu, uclk_states, &num_states);
1581 uclk_states_available = (status == PP_SMU_RESULT_OK);
1584 if (pool->base.pp_smu->nv_funcs.get_maximum_sustainable_clocks) {
1585 status = (*pool->base.pp_smu->nv_funcs.get_maximum_sustainable_clocks)
1586 (&pool->base.pp_smu->nv_funcs.pp_smu, &max_clocks);
1587 /* SMU cannot set DCF clock to anything equal to or higher than SOC clock
1589 if (max_clocks.dcfClockInKhz >= max_clocks.socClockInKhz)
1590 max_clocks.dcfClockInKhz = max_clocks.socClockInKhz - 1000;
1591 clock_limits_available = (status == PP_SMU_RESULT_OK);
1594 if (clock_limits_available && uclk_states_available && num_states)
1595 dcn20_update_bounding_box(dc, loaded_bb, &max_clocks, uclk_states, num_states);
1596 else if (clock_limits_available)
1597 dcn20_cap_soc_clocks(loaded_bb, max_clocks);
1600 loaded_ip->max_num_otg = pool->base.res_cap->num_timing_generator;
1601 loaded_ip->max_num_dpp = pool->base.pipe_count;
1602 dcn20_patch_bounding_box(dc, loaded_bb);
1607 static void set_wm_ranges(
1608 struct pp_smu_funcs *pp_smu,
1609 struct _vcs_dpi_soc_bounding_box_st *loaded_bb)
1611 struct pp_smu_wm_range_sets ranges = {0};
1614 ranges.num_reader_wm_sets = 0;
1616 if (loaded_bb->num_states == 1) {
1617 ranges.reader_wm_sets[0].wm_inst = 0;
1618 ranges.reader_wm_sets[0].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
1619 ranges.reader_wm_sets[0].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
1620 ranges.reader_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
1621 ranges.reader_wm_sets[0].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
1623 ranges.num_reader_wm_sets = 1;
1624 } else if (loaded_bb->num_states > 1) {
1625 for (i = 0; i < 4 && i < loaded_bb->num_states; i++) {
1626 ranges.reader_wm_sets[i].wm_inst = i;
1627 ranges.reader_wm_sets[i].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
1628 ranges.reader_wm_sets[i].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
1629 ranges.reader_wm_sets[i].min_fill_clk_mhz = (i > 0) ? (loaded_bb->clock_limits[i - 1].dram_speed_mts / 16) + 1 : 0;
1630 ranges.reader_wm_sets[i].max_fill_clk_mhz = loaded_bb->clock_limits[i].dram_speed_mts / 16;
1632 ranges.num_reader_wm_sets = i + 1;
1635 ranges.reader_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
1636 ranges.reader_wm_sets[ranges.num_reader_wm_sets - 1].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
1639 ranges.num_writer_wm_sets = 1;
1641 ranges.writer_wm_sets[0].wm_inst = 0;
1642 ranges.writer_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
1643 ranges.writer_wm_sets[0].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
1644 ranges.writer_wm_sets[0].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
1645 ranges.writer_wm_sets[0].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
1647 /* Notify PP Lib/SMU which Watermarks to use for which clock ranges */
1648 pp_smu->nv_funcs.set_wm_ranges(&pp_smu->nv_funcs.pp_smu, &ranges);
1651 static struct pp_smu_funcs *dcn301_pp_smu_create(struct dc_context *ctx)
1653 struct pp_smu_funcs *pp_smu = kzalloc(sizeof(*pp_smu), GFP_KERNEL);
1658 if (!IS_FPGA_MAXIMUS_DC(ctx->dce_environment) && !IS_DIAG_DC(ctx->dce_environment)) {
1659 dm_pp_get_funcs(ctx, pp_smu);
1661 /* TODO: update once we have n21 smu*/
1662 if (pp_smu->ctx.ver != PP_SMU_VER_NV)
1663 pp_smu = memset(pp_smu, 0, sizeof(struct pp_smu_funcs));
1669 static void dcn301_pp_smu_destroy(struct pp_smu_funcs **pp_smu)
1671 if (pp_smu && *pp_smu) {
1677 static void dcn301_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
1679 dcn3_01_soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0;
1680 dc->dml.soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0;
1683 static struct resource_funcs dcn301_res_pool_funcs = {
1684 .destroy = dcn301_destroy_resource_pool,
1685 .link_enc_create = dcn301_link_encoder_create,
1686 .panel_cntl_create = dcn301_panel_cntl_create,
1687 .validate_bandwidth = dcn30_validate_bandwidth,
1688 .calculate_wm_and_dlg = dcn30_calculate_wm_and_dlg,
1689 .populate_dml_pipes = dcn30_populate_dml_pipes_from_context,
1690 .acquire_idle_pipe_for_layer = dcn20_acquire_idle_pipe_for_layer,
1691 .add_stream_to_ctx = dcn30_add_stream_to_ctx,
1692 .remove_stream_from_ctx = dcn20_remove_stream_from_ctx,
1693 .populate_dml_writeback_from_context = dcn30_populate_dml_writeback_from_context,
1694 .set_mcif_arb_params = dcn30_set_mcif_arb_params,
1695 .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link,
1696 .acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut,
1697 .release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut,
1698 .update_bw_bounding_box = dcn301_update_bw_bounding_box
1701 static bool dcn301_resource_construct(
1702 uint8_t num_virtual_links,
1704 struct dcn301_resource_pool *pool)
1707 struct dc_context *ctx = dc->ctx;
1708 struct irq_service_init_data init_data;
1709 uint32_t pipe_fuses = read_pipe_fuses(ctx);
1710 uint32_t num_pipes = 0;
1712 DC_LOGGER_INIT(dc->ctx->logger);
1714 ctx->dc_bios->regs = &bios_regs;
1716 pool->base.res_cap = &res_cap_dcn301;
1718 pool->base.funcs = &dcn301_res_pool_funcs;
1720 /*************************************************
1721 * Resource + asic cap harcoding *
1722 *************************************************/
1723 pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
1724 pool->base.pipe_count = pool->base.res_cap->num_timing_generator;
1725 pool->base.mpcc_count = pool->base.res_cap->num_timing_generator;
1726 dc->caps.max_downscale_ratio = 600;
1727 dc->caps.i2c_speed_in_khz = 100;
1728 dc->caps.max_cursor_size = 256;
1729 dc->caps.dmdata_alloc_size = 2048;
1730 dc->caps.max_slave_planes = 1;
1731 dc->caps.is_apu = true;
1732 dc->caps.post_blend_color_processing = true;
1733 dc->caps.force_dp_tps4_for_cp2520 = true;
1734 dc->caps.extended_aux_timeout_support = true;
1735 #ifdef CONFIG_DRM_AMD_DC_DMUB
1736 dc->caps.dmcub_support = true;
1739 /* Color pipeline capabilities */
1740 dc->caps.color.dpp.dcn_arch = 1;
1741 dc->caps.color.dpp.input_lut_shared = 0;
1742 dc->caps.color.dpp.icsc = 1;
1743 dc->caps.color.dpp.dgam_ram = 0; // must use gamma_corr
1744 dc->caps.color.dpp.dgam_rom_caps.srgb = 1;
1745 dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1;
1746 dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 1;
1747 dc->caps.color.dpp.dgam_rom_caps.pq = 1;
1748 dc->caps.color.dpp.dgam_rom_caps.hlg = 1;
1749 dc->caps.color.dpp.post_csc = 1;
1750 dc->caps.color.dpp.gamma_corr = 1;
1752 dc->caps.color.dpp.hw_3d_lut = 1;
1753 dc->caps.color.dpp.ogam_ram = 1;
1754 // no OGAM ROM on DCN301
1755 dc->caps.color.dpp.ogam_rom_caps.srgb = 0;
1756 dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0;
1757 dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0;
1758 dc->caps.color.dpp.ogam_rom_caps.pq = 0;
1759 dc->caps.color.dpp.ogam_rom_caps.hlg = 0;
1760 dc->caps.color.dpp.ocsc = 0;
1762 dc->caps.color.mpc.gamut_remap = 1;
1763 dc->caps.color.mpc.num_3dluts = pool->base.res_cap->num_mpc_3dlut; //2
1764 dc->caps.color.mpc.ogam_ram = 1;
1765 dc->caps.color.mpc.ogam_rom_caps.srgb = 0;
1766 dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0;
1767 dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0;
1768 dc->caps.color.mpc.ogam_rom_caps.pq = 0;
1769 dc->caps.color.mpc.ogam_rom_caps.hlg = 0;
1770 dc->caps.color.mpc.ocsc = 1;
1772 if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
1773 dc->debug = debug_defaults_drv;
1774 else if (dc->ctx->dce_environment == DCE_ENV_FPGA_MAXIMUS) {
1775 dc->debug = debug_defaults_diags;
1777 dc->debug = debug_defaults_diags;
1778 // Init the vm_helper
1780 vm_helper_init(dc->vm_helper, 16);
1782 /*************************************************
1783 * Create resources *
1784 *************************************************/
1786 /* Clock Sources for Pixel Clock*/
1787 pool->base.clock_sources[DCN301_CLK_SRC_PLL0] =
1788 dcn301_clock_source_create(ctx, ctx->dc_bios,
1789 CLOCK_SOURCE_COMBO_PHY_PLL0,
1790 &clk_src_regs[0], false);
1791 pool->base.clock_sources[DCN301_CLK_SRC_PLL1] =
1792 dcn301_clock_source_create(ctx, ctx->dc_bios,
1793 CLOCK_SOURCE_COMBO_PHY_PLL1,
1794 &clk_src_regs[1], false);
1795 pool->base.clock_sources[DCN301_CLK_SRC_PLL2] =
1796 dcn301_clock_source_create(ctx, ctx->dc_bios,
1797 CLOCK_SOURCE_COMBO_PHY_PLL2,
1798 &clk_src_regs[2], false);
1799 pool->base.clock_sources[DCN301_CLK_SRC_PLL3] =
1800 dcn301_clock_source_create(ctx, ctx->dc_bios,
1801 CLOCK_SOURCE_COMBO_PHY_PLL3,
1802 &clk_src_regs[3], false);
1804 pool->base.clk_src_count = DCN301_CLK_SRC_TOTAL;
1806 /* todo: not reuse phy_pll registers */
1807 pool->base.dp_clock_source =
1808 dcn301_clock_source_create(ctx, ctx->dc_bios,
1809 CLOCK_SOURCE_ID_DP_DTO,
1810 &clk_src_regs[0], true);
1812 for (i = 0; i < pool->base.clk_src_count; i++) {
1813 if (pool->base.clock_sources[i] == NULL) {
1814 dm_error("DC: failed to create clock sources!\n");
1815 BREAK_TO_DEBUGGER();
1821 pool->base.dccg = dccg301_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask);
1822 if (pool->base.dccg == NULL) {
1823 dm_error("DC: failed to create dccg!\n");
1824 BREAK_TO_DEBUGGER();
1828 /* PP Lib and SMU interfaces */
1829 pool->base.pp_smu = dcn301_pp_smu_create(ctx);
1830 init_soc_bounding_box(dc, pool);
1831 if (!dc->debug.disable_pplib_wm_range && pool->base.pp_smu->nv_funcs.set_wm_ranges)
1832 set_wm_ranges(pool->base.pp_smu, &dcn3_01_soc);
1834 num_pipes = dcn3_01_ip.max_num_dpp;
1836 for (i = 0; i < dcn3_01_ip.max_num_dpp; i++)
1837 if (pipe_fuses & 1 << i)
1839 dcn3_01_ip.max_num_dpp = num_pipes;
1840 dcn3_01_ip.max_num_otg = num_pipes;
1843 dml_init_instance(&dc->dml, &dcn3_01_soc, &dcn3_01_ip, DML_PROJECT_DCN30);
1846 init_data.ctx = dc->ctx;
1847 pool->base.irqs = dal_irq_service_dcn30_create(&init_data);
1848 if (!pool->base.irqs)
1852 pool->base.hubbub = dcn301_hubbub_create(ctx);
1853 if (pool->base.hubbub == NULL) {
1854 BREAK_TO_DEBUGGER();
1855 dm_error("DC: failed to create hubbub!\n");
1860 /* HUBPs, DPPs, OPPs and TGs */
1861 for (i = 0; i < pool->base.pipe_count; i++) {
1863 /* if pipe is disabled, skip instance of HW pipe,
1864 * i.e, skip ASIC register instance
1866 if ((pipe_fuses & (1 << i)) != 0) {
1867 DC_LOG_DEBUG("%s: fusing pipe %d\n", __func__, i);
1871 pool->base.hubps[j] = dcn301_hubp_create(ctx, i);
1872 if (pool->base.hubps[j] == NULL) {
1873 BREAK_TO_DEBUGGER();
1875 "DC: failed to create hubps!\n");
1879 pool->base.dpps[j] = dcn301_dpp_create(ctx, i);
1880 if (pool->base.dpps[j] == NULL) {
1881 BREAK_TO_DEBUGGER();
1883 "DC: failed to create dpps!\n");
1887 pool->base.opps[j] = dcn301_opp_create(ctx, i);
1888 if (pool->base.opps[j] == NULL) {
1889 BREAK_TO_DEBUGGER();
1891 "DC: failed to create output pixel processor!\n");
1895 pool->base.timing_generators[j] = dcn301_timing_generator_create(ctx, i);
1896 if (pool->base.timing_generators[j] == NULL) {
1897 BREAK_TO_DEBUGGER();
1898 dm_error("DC: failed to create tg!\n");
1903 pool->base.timing_generator_count = j;
1904 pool->base.pipe_count = j;
1905 pool->base.mpcc_count = j;
1907 /* ABM (or ABMs for NV2x) */
1909 for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
1910 pool->base.multiple_abms[i] = dmub_abm_create(ctx,
1914 if (pool->base.multiple_abms[i] == NULL) {
1915 dm_error("DC: failed to create abm for pipe %d!\n", i);
1916 BREAK_TO_DEBUGGER();
1922 pool->base.mpc = dcn301_mpc_create(ctx, pool->base.mpcc_count, pool->base.res_cap->num_mpc_3dlut);
1923 if (pool->base.mpc == NULL) {
1924 BREAK_TO_DEBUGGER();
1925 dm_error("DC: failed to create mpc!\n");
1929 for (i = 0; i < pool->base.res_cap->num_dsc; i++) {
1930 pool->base.dscs[i] = dcn301_dsc_create(ctx, i);
1931 if (pool->base.dscs[i] == NULL) {
1932 BREAK_TO_DEBUGGER();
1933 dm_error("DC: failed to create display stream compressor %d!\n", i);
1938 /* DWB and MMHUBBUB */
1939 if (!dcn301_dwbc_create(ctx, &pool->base)) {
1940 BREAK_TO_DEBUGGER();
1941 dm_error("DC: failed to create dwbc!\n");
1945 if (!dcn301_mmhubbub_create(ctx, &pool->base)) {
1946 BREAK_TO_DEBUGGER();
1947 dm_error("DC: failed to create mcif_wb!\n");
1952 for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
1953 pool->base.engines[i] = dcn301_aux_engine_create(ctx, i);
1954 if (pool->base.engines[i] == NULL) {
1955 BREAK_TO_DEBUGGER();
1957 "DC:failed to create aux engine!!\n");
1960 pool->base.hw_i2cs[i] = dcn301_i2c_hw_create(ctx, i);
1961 if (pool->base.hw_i2cs[i] == NULL) {
1962 BREAK_TO_DEBUGGER();
1964 "DC:failed to create hw i2c!!\n");
1967 pool->base.sw_i2cs[i] = NULL;
1970 /* Audio, Stream Encoders including HPO and virtual, MPC 3D LUTs */
1971 if (!resource_construct(num_virtual_links, dc, &pool->base,
1972 (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ?
1973 &res_create_funcs : &res_create_maximus_funcs)))
1976 /* HW Sequencer and Plane caps */
1977 dcn301_hw_sequencer_construct(dc);
1979 dc->caps.max_planes = pool->base.pipe_count;
1981 for (i = 0; i < dc->caps.max_planes; ++i)
1982 dc->caps.planes[i] = plane_cap;
1984 dc->cap_funcs = cap_funcs;
1990 dcn301_destruct(pool);
1995 struct resource_pool *dcn301_create_resource_pool(
1996 const struct dc_init_data *init_data,
1999 struct dcn301_resource_pool *pool =
2000 kzalloc(sizeof(struct dcn301_resource_pool), GFP_KERNEL);
2005 if (dcn301_resource_construct(init_data->num_virtual_links, dc, pool))
2008 BREAK_TO_DEBUGGER();