xref: /linux/drivers/gpu/drm/amd/display/dc/resource/dcn301/dcn301_resource.c (revision 260f6f4fda93c8485c8037865c941b42b9cba5d2)
13a83e4e6SRoman Li /*
2ad0d8ebcSHarry Wentland  * Copyright 2019-2021 Advanced Micro Devices, Inc.
33a83e4e6SRoman Li  *
43a83e4e6SRoman Li  * Permission is hereby granted, free of charge, to any person obtaining a
53a83e4e6SRoman Li  * copy of this software and associated documentation files (the "Software"),
63a83e4e6SRoman Li  * to deal in the Software without restriction, including without limitation
73a83e4e6SRoman Li  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
83a83e4e6SRoman Li  * and/or sell copies of the Software, and to permit persons to whom the
93a83e4e6SRoman Li  * Software is furnished to do so, subject to the following conditions:
103a83e4e6SRoman Li  *
113a83e4e6SRoman Li  * The above copyright notice and this permission notice shall be included in
123a83e4e6SRoman Li  * all copies or substantial portions of the Software.
133a83e4e6SRoman Li  *
143a83e4e6SRoman Li  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
153a83e4e6SRoman Li  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
163a83e4e6SRoman Li  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
173a83e4e6SRoman Li  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
183a83e4e6SRoman Li  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
193a83e4e6SRoman Li  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
203a83e4e6SRoman Li  * OTHER DEALINGS IN THE SOFTWARE.
213a83e4e6SRoman Li  *
223a83e4e6SRoman Li  * Authors: AMD
233a83e4e6SRoman Li  *
243a83e4e6SRoman Li  */
253a83e4e6SRoman Li 
263a83e4e6SRoman Li 
273a83e4e6SRoman Li #include "dm_services.h"
283a83e4e6SRoman Li #include "dc.h"
293a83e4e6SRoman Li 
308b8eed05SMounika Adhuri #include "dcn301/dcn301_init.h"
313a83e4e6SRoman Li 
323a83e4e6SRoman Li #include "resource.h"
333a83e4e6SRoman Li #include "include/irq_service_interface.h"
343a83e4e6SRoman Li #include "dcn30/dcn30_resource.h"
353a83e4e6SRoman Li #include "dcn301_resource.h"
363a83e4e6SRoman Li 
373a83e4e6SRoman Li #include "dcn20/dcn20_resource.h"
383a83e4e6SRoman Li 
393a83e4e6SRoman Li #include "dcn10/dcn10_ipp.h"
403a83e4e6SRoman Li #include "dcn301/dcn301_hubbub.h"
413a83e4e6SRoman Li #include "dcn30/dcn30_mpc.h"
423a83e4e6SRoman Li #include "dcn30/dcn30_hubp.h"
433a83e4e6SRoman Li #include "irq/dcn30/irq_service_dcn30.h"
443a83e4e6SRoman Li #include "dcn30/dcn30_dpp.h"
45b188069fSAurabindo Pillai #include "dcn301/dcn301_optc.h"
463a83e4e6SRoman Li #include "dcn20/dcn20_hwseq.h"
473a83e4e6SRoman Li #include "dcn30/dcn30_hwseq.h"
48e53524cdSMounika Adhuri #include "dce110/dce110_hwseq.h"
493a83e4e6SRoman Li #include "dcn30/dcn30_opp.h"
503a83e4e6SRoman Li #include "dcn20/dcn20_dsc.h"
513a83e4e6SRoman Li #include "dcn30/dcn30_vpg.h"
523a83e4e6SRoman Li #include "dcn30/dcn30_afmt.h"
533a83e4e6SRoman Li #include "dce/dce_clock_source.h"
543a83e4e6SRoman Li #include "dce/dce_audio.h"
553a83e4e6SRoman Li #include "dce/dce_hwseq.h"
563a83e4e6SRoman Li #include "clk_mgr.h"
573a83e4e6SRoman Li #include "virtual/virtual_stream_encoder.h"
583a83e4e6SRoman Li #include "dce110/dce110_resource.h"
593a83e4e6SRoman Li #include "dml/display_mode_vba.h"
603a83e4e6SRoman Li #include "dcn301/dcn301_dccg.h"
613a83e4e6SRoman Li #include "dcn10/dcn10_resource.h"
623a83e4e6SRoman Li #include "dcn30/dcn30_dio_stream_encoder.h"
633a83e4e6SRoman Li #include "dcn301/dcn301_dio_link_encoder.h"
648b8eed05SMounika Adhuri #include "dcn301/dcn301_panel_cntl.h"
653a83e4e6SRoman Li 
663a83e4e6SRoman Li #include "vangogh_ip_offset.h"
673a83e4e6SRoman Li 
683a83e4e6SRoman Li #include "dcn30/dcn30_dwb.h"
693a83e4e6SRoman Li #include "dcn30/dcn30_mmhubbub.h"
703a83e4e6SRoman Li 
713a83e4e6SRoman Li #include "dcn/dcn_3_0_1_offset.h"
723a83e4e6SRoman Li #include "dcn/dcn_3_0_1_sh_mask.h"
733a83e4e6SRoman Li 
743a83e4e6SRoman Li #include "nbio/nbio_7_2_0_offset.h"
753a83e4e6SRoman Li 
7668550cbcSAlex Deucher #include "dpcs/dpcs_3_0_0_offset.h"
7768550cbcSAlex Deucher #include "dpcs/dpcs_3_0_0_sh_mask.h"
78f5041bc1SZhan Liu 
793a83e4e6SRoman Li #include "reg_helper.h"
803a83e4e6SRoman Li #include "dce/dmub_abm.h"
813a83e4e6SRoman Li #include "dce/dce_aux.h"
823a83e4e6SRoman Li #include "dce/dce_i2c.h"
833a83e4e6SRoman Li 
84e4b0eac3SJasdeep Dhillon #include "dml/dcn30/dcn30_fpu.h"
85e4b0eac3SJasdeep Dhillon 
863a83e4e6SRoman Li #include "dml/dcn30/display_mode_vba_30.h"
8731484207SQingqing Zhuo #include "dml/dcn301/dcn301_fpu.h"
883a83e4e6SRoman Li #include "vm_helper.h"
893a83e4e6SRoman Li #include "dcn20/dcn20_vmid.h"
903a83e4e6SRoman Li #include "amdgpu_socbb.h"
913a83e4e6SRoman Li 
923a83e4e6SRoman Li #define TO_DCN301_RES_POOL(pool)\
933a83e4e6SRoman Li 	container_of(pool, struct dcn301_resource_pool, base)
943a83e4e6SRoman Li 
955d72e247SHamza Mahfooz #define DC_LOGGER \
965d72e247SHamza Mahfooz 	dc->ctx->logger
973a83e4e6SRoman Li #define DC_LOGGER_INIT(logger)
983a83e4e6SRoman Li 
993a83e4e6SRoman Li enum dcn301_clk_src_array_id {
1003a83e4e6SRoman Li 	DCN301_CLK_SRC_PLL0,
1013a83e4e6SRoman Li 	DCN301_CLK_SRC_PLL1,
1023a83e4e6SRoman Li 	DCN301_CLK_SRC_PLL2,
1033a83e4e6SRoman Li 	DCN301_CLK_SRC_PLL3,
1043a83e4e6SRoman Li 	DCN301_CLK_SRC_TOTAL
1053a83e4e6SRoman Li };
1063a83e4e6SRoman Li 
1073a83e4e6SRoman Li /* begin *********************
1083a83e4e6SRoman Li  * macros to expend register list macro defined in HW object header file
1093a83e4e6SRoman Li  */
1103a83e4e6SRoman Li 
1113a83e4e6SRoman Li /* DCN */
1123a83e4e6SRoman Li #define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg
1133a83e4e6SRoman Li 
1143a83e4e6SRoman Li #define BASE(seg) BASE_INNER(seg)
1153a83e4e6SRoman Li 
1163a83e4e6SRoman Li #define SR(reg_name)\
1173a83e4e6SRoman Li 		.reg_name = BASE(mm ## reg_name ## _BASE_IDX) +  \
1183a83e4e6SRoman Li 					mm ## reg_name
1193a83e4e6SRoman Li 
1203a83e4e6SRoman Li #define SRI(reg_name, block, id)\
1213a83e4e6SRoman Li 	.reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
1223a83e4e6SRoman Li 					mm ## block ## id ## _ ## reg_name
1233a83e4e6SRoman Li 
1243a83e4e6SRoman Li #define SRI2(reg_name, block, id)\
1253a83e4e6SRoman Li 	.reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
1263a83e4e6SRoman Li 					mm ## reg_name
1273a83e4e6SRoman Li 
1283a83e4e6SRoman Li #define SRIR(var_name, reg_name, block, id)\
1293a83e4e6SRoman Li 	.var_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
1303a83e4e6SRoman Li 					mm ## block ## id ## _ ## reg_name
1313a83e4e6SRoman Li 
1323a83e4e6SRoman Li #define SRII(reg_name, block, id)\
1333a83e4e6SRoman Li 	.reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
1343a83e4e6SRoman Li 					mm ## block ## id ## _ ## reg_name
1353a83e4e6SRoman Li 
1363a83e4e6SRoman Li #define SRII2(reg_name_pre, reg_name_post, id)\
1373a83e4e6SRoman Li 	.reg_name_pre ## _ ##  reg_name_post[id] = BASE(mm ## reg_name_pre \
1383a83e4e6SRoman Li 			## id ## _ ## reg_name_post ## _BASE_IDX) + \
1393a83e4e6SRoman Li 			mm ## reg_name_pre ## id ## _ ## reg_name_post
1403a83e4e6SRoman Li 
1413a83e4e6SRoman Li #define SRII_MPC_RMU(reg_name, block, id)\
1423a83e4e6SRoman Li 	.RMU##_##reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
1433a83e4e6SRoman Li 					mm ## block ## id ## _ ## reg_name
1443a83e4e6SRoman Li 
1453a83e4e6SRoman Li #define SRII_DWB(reg_name, temp_name, block, id)\
1463a83e4e6SRoman Li 	.reg_name[id] = BASE(mm ## block ## id ## _ ## temp_name ## _BASE_IDX) + \
1473a83e4e6SRoman Li 					mm ## block ## id ## _ ## temp_name
1483a83e4e6SRoman Li 
149158858bfSAurabindo Pillai #define SF_DWB2(reg_name, block, id, field_name, post_fix)	\
150158858bfSAurabindo Pillai 	.field_name = reg_name ## __ ## field_name ## post_fix
151158858bfSAurabindo Pillai 
1523a83e4e6SRoman Li #define DCCG_SRII(reg_name, block, id)\
1533a83e4e6SRoman Li 	.block ## _ ## reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
1543a83e4e6SRoman Li 					mm ## block ## id ## _ ## reg_name
1553a83e4e6SRoman Li 
1563a83e4e6SRoman Li #define VUPDATE_SRII(reg_name, block, id)\
1573a83e4e6SRoman Li 	.reg_name[id] = BASE(mm ## reg_name ## _ ## block ## id ## _BASE_IDX) + \
1583a83e4e6SRoman Li 					mm ## reg_name ## _ ## block ## id
1593a83e4e6SRoman Li 
1603a83e4e6SRoman Li /* NBIO */
1613a83e4e6SRoman Li #define NBIO_BASE_INNER(seg) \
1623a83e4e6SRoman Li 	NBIO_BASE__INST0_SEG ## seg
1633a83e4e6SRoman Li 
1643a83e4e6SRoman Li #define NBIO_BASE(seg) \
1653a83e4e6SRoman Li 	NBIO_BASE_INNER(seg)
1663a83e4e6SRoman Li 
1673a83e4e6SRoman Li #define NBIO_SR(reg_name)\
1683a83e4e6SRoman Li 		.reg_name = NBIO_BASE(regBIF_BX0_ ## reg_name ## _BASE_IDX) + \
1693a83e4e6SRoman Li 					regBIF_BX0_ ## reg_name
1703a83e4e6SRoman Li 
1713a83e4e6SRoman Li /* MMHUB */
1723a83e4e6SRoman Li #define MMHUB_BASE_INNER(seg) \
1733a83e4e6SRoman Li 	MMHUB_BASE__INST0_SEG ## seg
1743a83e4e6SRoman Li 
1753a83e4e6SRoman Li #define MMHUB_BASE(seg) \
1763a83e4e6SRoman Li 	MMHUB_BASE_INNER(seg)
1773a83e4e6SRoman Li 
1783a83e4e6SRoman Li #define MMHUB_SR(reg_name)\
1793a83e4e6SRoman Li 		.reg_name = MMHUB_BASE(regMM ## reg_name ## _BASE_IDX) + \
1803a83e4e6SRoman Li 					regMM ## reg_name
1813a83e4e6SRoman Li 
1823a83e4e6SRoman Li /* CLOCK */
1833a83e4e6SRoman Li #define CLK_BASE_INNER(seg) \
1843a83e4e6SRoman Li 	CLK_BASE__INST0_SEG ## seg
1853a83e4e6SRoman Li 
1863a83e4e6SRoman Li #define CLK_BASE(seg) \
1873a83e4e6SRoman Li 	CLK_BASE_INNER(seg)
1883a83e4e6SRoman Li 
1893a83e4e6SRoman Li #define CLK_SRI(reg_name, block, inst)\
1903a83e4e6SRoman Li 	.reg_name = CLK_BASE(mm ## block ## _ ## inst ## _ ## reg_name ## _BASE_IDX) + \
1913a83e4e6SRoman Li 					mm ## block ## _ ## inst ## _ ## reg_name
1923a83e4e6SRoman Li 
1933a83e4e6SRoman Li static const struct bios_registers bios_regs = {
1943a83e4e6SRoman Li 		NBIO_SR(BIOS_SCRATCH_3),
1953a83e4e6SRoman Li 		NBIO_SR(BIOS_SCRATCH_6)
1963a83e4e6SRoman Li };
1973a83e4e6SRoman Li 
1983a83e4e6SRoman Li #define clk_src_regs(index, pllid)\
1993a83e4e6SRoman Li [index] = {\
2003a83e4e6SRoman Li 	CS_COMMON_REG_LIST_DCN3_01(index, pllid),\
2013a83e4e6SRoman Li }
2023a83e4e6SRoman Li 
2033a83e4e6SRoman Li static const struct dce110_clk_src_regs clk_src_regs[] = {
2043a83e4e6SRoman Li 	clk_src_regs(0, A),
2053a83e4e6SRoman Li 	clk_src_regs(1, B),
2063a83e4e6SRoman Li 	clk_src_regs(2, C),
2073a83e4e6SRoman Li 	clk_src_regs(3, D)
2083a83e4e6SRoman Li };
2093a83e4e6SRoman Li 
2103a83e4e6SRoman Li static const struct dce110_clk_src_shift cs_shift = {
2113a83e4e6SRoman Li 		CS_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT)
2123a83e4e6SRoman Li };
2133a83e4e6SRoman Li 
2143a83e4e6SRoman Li static const struct dce110_clk_src_mask cs_mask = {
2153a83e4e6SRoman Li 		CS_COMMON_MASK_SH_LIST_DCN2_0(_MASK)
2163a83e4e6SRoman Li };
2173a83e4e6SRoman Li 
2183a83e4e6SRoman Li #define abm_regs(id)\
2193a83e4e6SRoman Li [id] = {\
2203a83e4e6SRoman Li 		ABM_DCN301_REG_LIST(id)\
2213a83e4e6SRoman Li }
2223a83e4e6SRoman Li 
2233a83e4e6SRoman Li static const struct dce_abm_registers abm_regs[] = {
2243a83e4e6SRoman Li 		abm_regs(0),
2253a83e4e6SRoman Li 		abm_regs(1),
2263a83e4e6SRoman Li 		abm_regs(2),
2273a83e4e6SRoman Li 		abm_regs(3),
2283a83e4e6SRoman Li };
2293a83e4e6SRoman Li 
2303a83e4e6SRoman Li static const struct dce_abm_shift abm_shift = {
231df043738SRoman Li 		ABM_MASK_SH_LIST_DCN30(__SHIFT)
2323a83e4e6SRoman Li };
2333a83e4e6SRoman Li 
2343a83e4e6SRoman Li static const struct dce_abm_mask abm_mask = {
235df043738SRoman Li 		ABM_MASK_SH_LIST_DCN30(_MASK)
2363a83e4e6SRoman Li };
2373a83e4e6SRoman Li 
2383a83e4e6SRoman Li #define audio_regs(id)\
2393a83e4e6SRoman Li [id] = {\
2403a83e4e6SRoman Li 		AUD_COMMON_REG_LIST(id)\
2413a83e4e6SRoman Li }
2423a83e4e6SRoman Li 
2433a83e4e6SRoman Li static const struct dce_audio_registers audio_regs[] = {
2443a83e4e6SRoman Li 	audio_regs(0),
2453a83e4e6SRoman Li 	audio_regs(1),
2463a83e4e6SRoman Li 	audio_regs(2),
2473a83e4e6SRoman Li 	audio_regs(3),
2483a83e4e6SRoman Li 	audio_regs(4),
2493a83e4e6SRoman Li 	audio_regs(5),
2503a83e4e6SRoman Li 	audio_regs(6)
2513a83e4e6SRoman Li };
2523a83e4e6SRoman Li 
2533a83e4e6SRoman Li #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
2543a83e4e6SRoman Li 		SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\
2553a83e4e6SRoman Li 		SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\
2563a83e4e6SRoman Li 		AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)
2573a83e4e6SRoman Li 
2583a83e4e6SRoman Li static const struct dce_audio_shift audio_shift = {
2593a83e4e6SRoman Li 		DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT)
2603a83e4e6SRoman Li };
2613a83e4e6SRoman Li 
2623a83e4e6SRoman Li static const struct dce_audio_mask audio_mask = {
2633a83e4e6SRoman Li 		DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)
2643a83e4e6SRoman Li };
2653a83e4e6SRoman Li 
2663a83e4e6SRoman Li #define vpg_regs(id)\
2673a83e4e6SRoman Li [id] = {\
2683a83e4e6SRoman Li 	VPG_DCN3_REG_LIST(id)\
2693a83e4e6SRoman Li }
2703a83e4e6SRoman Li 
2713a83e4e6SRoman Li static const struct dcn30_vpg_registers vpg_regs[] = {
2723a83e4e6SRoman Li 	vpg_regs(0),
2733a83e4e6SRoman Li 	vpg_regs(1),
2743a83e4e6SRoman Li 	vpg_regs(2),
2753a83e4e6SRoman Li 	vpg_regs(3),
2763a83e4e6SRoman Li };
2773a83e4e6SRoman Li 
2783a83e4e6SRoman Li static const struct dcn30_vpg_shift vpg_shift = {
2793a83e4e6SRoman Li 	DCN3_VPG_MASK_SH_LIST(__SHIFT)
2803a83e4e6SRoman Li };
2813a83e4e6SRoman Li 
2823a83e4e6SRoman Li static const struct dcn30_vpg_mask vpg_mask = {
2833a83e4e6SRoman Li 	DCN3_VPG_MASK_SH_LIST(_MASK)
2843a83e4e6SRoman Li };
2853a83e4e6SRoman Li 
2863a83e4e6SRoman Li #define afmt_regs(id)\
2873a83e4e6SRoman Li [id] = {\
2883a83e4e6SRoman Li 	AFMT_DCN3_REG_LIST(id)\
2893a83e4e6SRoman Li }
2903a83e4e6SRoman Li 
2913a83e4e6SRoman Li static const struct dcn30_afmt_registers afmt_regs[] = {
2923a83e4e6SRoman Li 	afmt_regs(0),
2933a83e4e6SRoman Li 	afmt_regs(1),
2943a83e4e6SRoman Li 	afmt_regs(2),
2953a83e4e6SRoman Li 	afmt_regs(3),
2963a83e4e6SRoman Li };
2973a83e4e6SRoman Li 
2983a83e4e6SRoman Li static const struct dcn30_afmt_shift afmt_shift = {
2993a83e4e6SRoman Li 	DCN3_AFMT_MASK_SH_LIST(__SHIFT)
3003a83e4e6SRoman Li };
3013a83e4e6SRoman Li 
3023a83e4e6SRoman Li static const struct dcn30_afmt_mask afmt_mask = {
3033a83e4e6SRoman Li 	DCN3_AFMT_MASK_SH_LIST(_MASK)
3043a83e4e6SRoman Li };
3053a83e4e6SRoman Li 
3063a83e4e6SRoman Li #define stream_enc_regs(id)\
3073a83e4e6SRoman Li [id] = {\
3083a83e4e6SRoman Li 	SE_DCN3_REG_LIST(id)\
3093a83e4e6SRoman Li }
3103a83e4e6SRoman Li 
3113a83e4e6SRoman Li static const struct dcn10_stream_enc_registers stream_enc_regs[] = {
3123a83e4e6SRoman Li 	stream_enc_regs(0),
3133a83e4e6SRoman Li 	stream_enc_regs(1),
3143a83e4e6SRoman Li 	stream_enc_regs(2),
3153a83e4e6SRoman Li 	stream_enc_regs(3),
3163a83e4e6SRoman Li };
3173a83e4e6SRoman Li 
3183a83e4e6SRoman Li static const struct dcn10_stream_encoder_shift se_shift = {
3193a83e4e6SRoman Li 		SE_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
3203a83e4e6SRoman Li };
3213a83e4e6SRoman Li 
3223a83e4e6SRoman Li static const struct dcn10_stream_encoder_mask se_mask = {
3233a83e4e6SRoman Li 		SE_COMMON_MASK_SH_LIST_DCN30(_MASK)
3243a83e4e6SRoman Li };
3253a83e4e6SRoman Li 
3263a83e4e6SRoman Li 
3273a83e4e6SRoman Li #define aux_regs(id)\
3283a83e4e6SRoman Li [id] = {\
3293a83e4e6SRoman Li 	DCN2_AUX_REG_LIST(id)\
3303a83e4e6SRoman Li }
3313a83e4e6SRoman Li 
3323a83e4e6SRoman Li static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = {
3333a83e4e6SRoman Li 		aux_regs(0),
3343a83e4e6SRoman Li 		aux_regs(1),
3353a83e4e6SRoman Li 		aux_regs(2),
3363a83e4e6SRoman Li 		aux_regs(3),
3373a83e4e6SRoman Li };
3383a83e4e6SRoman Li 
3393a83e4e6SRoman Li #define hpd_regs(id)\
3403a83e4e6SRoman Li [id] = {\
3413a83e4e6SRoman Li 	HPD_REG_LIST(id)\
3423a83e4e6SRoman Li }
3433a83e4e6SRoman Li 
3443a83e4e6SRoman Li static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {
3453a83e4e6SRoman Li 		hpd_regs(0),
3463a83e4e6SRoman Li 		hpd_regs(1),
3473a83e4e6SRoman Li 		hpd_regs(2),
3483a83e4e6SRoman Li 		hpd_regs(3),
3493a83e4e6SRoman Li };
3503a83e4e6SRoman Li 
351f5041bc1SZhan Liu 
3523a83e4e6SRoman Li #define link_regs(id, phyid)\
3533a83e4e6SRoman Li [id] = {\
3543a83e4e6SRoman Li 	LE_DCN301_REG_LIST(id), \
3553a83e4e6SRoman Li 	UNIPHY_DCN2_REG_LIST(phyid), \
356f5041bc1SZhan Liu 	DPCS_DCN2_REG_LIST(id), \
35741fd932eSChris Park 	SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \
3583a83e4e6SRoman Li }
3593a83e4e6SRoman Li 
3603a83e4e6SRoman Li static const struct dce110_aux_registers_shift aux_shift = {
3613a83e4e6SRoman Li 	DCN_AUX_MASK_SH_LIST(__SHIFT)
3623a83e4e6SRoman Li };
3633a83e4e6SRoman Li 
3643a83e4e6SRoman Li static const struct dce110_aux_registers_mask aux_mask = {
3653a83e4e6SRoman Li 	DCN_AUX_MASK_SH_LIST(_MASK)
3663a83e4e6SRoman Li };
3673a83e4e6SRoman Li 
3683a83e4e6SRoman Li static const struct dcn10_link_enc_registers link_enc_regs[] = {
3693a83e4e6SRoman Li 	link_regs(0, A),
3703a83e4e6SRoman Li 	link_regs(1, B),
3713a83e4e6SRoman Li 	link_regs(2, C),
3723a83e4e6SRoman Li 	link_regs(3, D),
3733a83e4e6SRoman Li };
3743a83e4e6SRoman Li 
3753a83e4e6SRoman Li static const struct dcn10_link_enc_shift le_shift = {
376f5041bc1SZhan Liu 	LINK_ENCODER_MASK_SH_LIST_DCN301(__SHIFT),\
377f5041bc1SZhan Liu 	DPCS_DCN2_MASK_SH_LIST(__SHIFT)
3783a83e4e6SRoman Li };
3793a83e4e6SRoman Li 
3803a83e4e6SRoman Li static const struct dcn10_link_enc_mask le_mask = {
381f5041bc1SZhan Liu 	LINK_ENCODER_MASK_SH_LIST_DCN301(_MASK),\
382f5041bc1SZhan Liu 	DPCS_DCN2_MASK_SH_LIST(_MASK)
3833a83e4e6SRoman Li };
3843a83e4e6SRoman Li 
3853a83e4e6SRoman Li #define panel_cntl_regs(id)\
3863a83e4e6SRoman Li [id] = {\
3873a83e4e6SRoman Li 	DCN301_PANEL_CNTL_REG_LIST(id),\
3883a83e4e6SRoman Li }
3893a83e4e6SRoman Li 
3903a83e4e6SRoman Li static const struct dce_panel_cntl_registers panel_cntl_regs[] = {
3913a83e4e6SRoman Li 	panel_cntl_regs(0),
3923a83e4e6SRoman Li 	panel_cntl_regs(1),
3933a83e4e6SRoman Li };
3943a83e4e6SRoman Li 
3953a83e4e6SRoman Li static const struct dcn301_panel_cntl_shift panel_cntl_shift = {
3963a83e4e6SRoman Li 	DCN301_PANEL_CNTL_MASK_SH_LIST(__SHIFT)
3973a83e4e6SRoman Li };
3983a83e4e6SRoman Li 
3993a83e4e6SRoman Li static const struct dcn301_panel_cntl_mask panel_cntl_mask = {
4003a83e4e6SRoman Li 	DCN301_PANEL_CNTL_MASK_SH_LIST(_MASK)
4013a83e4e6SRoman Li };
4023a83e4e6SRoman Li 
4033a83e4e6SRoman Li #define dpp_regs(id)\
4043a83e4e6SRoman Li [id] = {\
4053a83e4e6SRoman Li 	DPP_REG_LIST_DCN30(id),\
4063a83e4e6SRoman Li }
4073a83e4e6SRoman Li 
4083a83e4e6SRoman Li static const struct dcn3_dpp_registers dpp_regs[] = {
4093a83e4e6SRoman Li 	dpp_regs(0),
4103a83e4e6SRoman Li 	dpp_regs(1),
4113a83e4e6SRoman Li 	dpp_regs(2),
4123a83e4e6SRoman Li 	dpp_regs(3),
4133a83e4e6SRoman Li };
4143a83e4e6SRoman Li 
4153a83e4e6SRoman Li static const struct dcn3_dpp_shift tf_shift = {
4163a83e4e6SRoman Li 		DPP_REG_LIST_SH_MASK_DCN30(__SHIFT)
4173a83e4e6SRoman Li };
4183a83e4e6SRoman Li 
4193a83e4e6SRoman Li static const struct dcn3_dpp_mask tf_mask = {
4203a83e4e6SRoman Li 		DPP_REG_LIST_SH_MASK_DCN30(_MASK)
4213a83e4e6SRoman Li };
4223a83e4e6SRoman Li 
4233a83e4e6SRoman Li #define opp_regs(id)\
4243a83e4e6SRoman Li [id] = {\
4253a83e4e6SRoman Li 	OPP_REG_LIST_DCN30(id),\
4263a83e4e6SRoman Li }
4273a83e4e6SRoman Li 
4283a83e4e6SRoman Li static const struct dcn20_opp_registers opp_regs[] = {
4293a83e4e6SRoman Li 	opp_regs(0),
4303a83e4e6SRoman Li 	opp_regs(1),
4313a83e4e6SRoman Li 	opp_regs(2),
4323a83e4e6SRoman Li 	opp_regs(3),
4333a83e4e6SRoman Li };
4343a83e4e6SRoman Li 
4353a83e4e6SRoman Li static const struct dcn20_opp_shift opp_shift = {
4363a83e4e6SRoman Li 	OPP_MASK_SH_LIST_DCN20(__SHIFT)
4373a83e4e6SRoman Li };
4383a83e4e6SRoman Li 
4393a83e4e6SRoman Li static const struct dcn20_opp_mask opp_mask = {
4403a83e4e6SRoman Li 	OPP_MASK_SH_LIST_DCN20(_MASK)
4413a83e4e6SRoman Li };
4423a83e4e6SRoman Li 
4433a83e4e6SRoman Li #define aux_engine_regs(id)\
4443a83e4e6SRoman Li [id] = {\
4453a83e4e6SRoman Li 	AUX_COMMON_REG_LIST0(id), \
4463a83e4e6SRoman Li 	.AUXN_IMPCAL = 0, \
4473a83e4e6SRoman Li 	.AUXP_IMPCAL = 0, \
4483a83e4e6SRoman Li 	.AUX_RESET_MASK = DP_AUX0_AUX_CONTROL__AUX_RESET_MASK, \
4493a83e4e6SRoman Li }
4503a83e4e6SRoman Li 
4513a83e4e6SRoman Li static const struct dce110_aux_registers aux_engine_regs[] = {
4523a83e4e6SRoman Li 		aux_engine_regs(0),
4533a83e4e6SRoman Li 		aux_engine_regs(1),
4543a83e4e6SRoman Li 		aux_engine_regs(2),
4553a83e4e6SRoman Li 		aux_engine_regs(3),
4563a83e4e6SRoman Li };
4573a83e4e6SRoman Li 
4583a83e4e6SRoman Li #define dwbc_regs_dcn3(id)\
4593a83e4e6SRoman Li [id] = {\
4603a83e4e6SRoman Li 	DWBC_COMMON_REG_LIST_DCN30(id),\
4613a83e4e6SRoman Li }
4623a83e4e6SRoman Li 
4633a83e4e6SRoman Li static const struct dcn30_dwbc_registers dwbc30_regs[] = {
4643a83e4e6SRoman Li 	dwbc_regs_dcn3(0),
4653a83e4e6SRoman Li };
4663a83e4e6SRoman Li 
4673a83e4e6SRoman Li static const struct dcn30_dwbc_shift dwbc30_shift = {
4683a83e4e6SRoman Li 	DWBC_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
4693a83e4e6SRoman Li };
4703a83e4e6SRoman Li 
4713a83e4e6SRoman Li static const struct dcn30_dwbc_mask dwbc30_mask = {
4723a83e4e6SRoman Li 	DWBC_COMMON_MASK_SH_LIST_DCN30(_MASK)
4733a83e4e6SRoman Li };
4743a83e4e6SRoman Li 
4753a83e4e6SRoman Li #define mcif_wb_regs_dcn3(id)\
4763a83e4e6SRoman Li [id] = {\
4773a83e4e6SRoman Li 	MCIF_WB_COMMON_REG_LIST_DCN30(id),\
4783a83e4e6SRoman Li }
4793a83e4e6SRoman Li 
4803a83e4e6SRoman Li static const struct dcn30_mmhubbub_registers mcif_wb30_regs[] = {
4813a83e4e6SRoman Li 	mcif_wb_regs_dcn3(0)
4823a83e4e6SRoman Li };
4833a83e4e6SRoman Li 
4843a83e4e6SRoman Li static const struct dcn30_mmhubbub_shift mcif_wb30_shift = {
4853a83e4e6SRoman Li 	MCIF_WB_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
4863a83e4e6SRoman Li };
4873a83e4e6SRoman Li 
4883a83e4e6SRoman Li static const struct dcn30_mmhubbub_mask mcif_wb30_mask = {
4893a83e4e6SRoman Li 	MCIF_WB_COMMON_MASK_SH_LIST_DCN30(_MASK)
4903a83e4e6SRoman Li };
4913a83e4e6SRoman Li 
4923a83e4e6SRoman Li #define dsc_regsDCN20(id)\
4933a83e4e6SRoman Li [id] = {\
4943a83e4e6SRoman Li 	DSC_REG_LIST_DCN20(id)\
4953a83e4e6SRoman Li }
4963a83e4e6SRoman Li 
4973a83e4e6SRoman Li static const struct dcn20_dsc_registers dsc_regs[] = {
4983a83e4e6SRoman Li 	dsc_regsDCN20(0),
4993a83e4e6SRoman Li 	dsc_regsDCN20(1),
5003a83e4e6SRoman Li 	dsc_regsDCN20(2),
5013a83e4e6SRoman Li };
5023a83e4e6SRoman Li 
5033a83e4e6SRoman Li static const struct dcn20_dsc_shift dsc_shift = {
5043a83e4e6SRoman Li 	DSC_REG_LIST_SH_MASK_DCN20(__SHIFT)
5053a83e4e6SRoman Li };
5063a83e4e6SRoman Li 
5073a83e4e6SRoman Li static const struct dcn20_dsc_mask dsc_mask = {
5083a83e4e6SRoman Li 	DSC_REG_LIST_SH_MASK_DCN20(_MASK)
5093a83e4e6SRoman Li };
5103a83e4e6SRoman Li 
5113a83e4e6SRoman Li static const struct dcn30_mpc_registers mpc_regs = {
5123a83e4e6SRoman Li 		MPC_REG_LIST_DCN3_0(0),
5133a83e4e6SRoman Li 		MPC_REG_LIST_DCN3_0(1),
5143a83e4e6SRoman Li 		MPC_REG_LIST_DCN3_0(2),
5153a83e4e6SRoman Li 		MPC_REG_LIST_DCN3_0(3),
5163a83e4e6SRoman Li 		MPC_OUT_MUX_REG_LIST_DCN3_0(0),
5173a83e4e6SRoman Li 		MPC_OUT_MUX_REG_LIST_DCN3_0(1),
5183a83e4e6SRoman Li 		MPC_OUT_MUX_REG_LIST_DCN3_0(2),
5193a83e4e6SRoman Li 		MPC_OUT_MUX_REG_LIST_DCN3_0(3),
5203a83e4e6SRoman Li 		MPC_RMU_GLOBAL_REG_LIST_DCN3AG,
5213a83e4e6SRoman Li 		MPC_RMU_REG_LIST_DCN3AG(0),
5223a83e4e6SRoman Li 		MPC_RMU_REG_LIST_DCN3AG(1),
5233a83e4e6SRoman Li 		MPC_DWB_MUX_REG_LIST_DCN3_0(0),
5243a83e4e6SRoman Li };
5253a83e4e6SRoman Li 
5263a83e4e6SRoman Li static const struct dcn30_mpc_shift mpc_shift = {
5273a83e4e6SRoman Li 	MPC_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
5283a83e4e6SRoman Li };
5293a83e4e6SRoman Li 
5303a83e4e6SRoman Li static const struct dcn30_mpc_mask mpc_mask = {
5313a83e4e6SRoman Li 	MPC_COMMON_MASK_SH_LIST_DCN30(_MASK)
5323a83e4e6SRoman Li };
5333a83e4e6SRoman Li 
5343a83e4e6SRoman Li #define optc_regs(id)\
5353a83e4e6SRoman Li [id] = {OPTC_COMMON_REG_LIST_DCN3_0(id)}
5363a83e4e6SRoman Li 
5373a83e4e6SRoman Li 
5383a83e4e6SRoman Li static const struct dcn_optc_registers optc_regs[] = {
5393a83e4e6SRoman Li 	optc_regs(0),
5403a83e4e6SRoman Li 	optc_regs(1),
5413a83e4e6SRoman Li 	optc_regs(2),
5423a83e4e6SRoman Li 	optc_regs(3),
5433a83e4e6SRoman Li };
5443a83e4e6SRoman Li 
5453a83e4e6SRoman Li static const struct dcn_optc_shift optc_shift = {
5463a83e4e6SRoman Li 	OPTC_COMMON_MASK_SH_LIST_DCN30(__SHIFT)
5473a83e4e6SRoman Li };
5483a83e4e6SRoman Li 
5493a83e4e6SRoman Li static const struct dcn_optc_mask optc_mask = {
5503a83e4e6SRoman Li 	OPTC_COMMON_MASK_SH_LIST_DCN30(_MASK)
5513a83e4e6SRoman Li };
5523a83e4e6SRoman Li 
5533a83e4e6SRoman Li #define hubp_regs(id)\
5543a83e4e6SRoman Li [id] = {\
5553a83e4e6SRoman Li 	HUBP_REG_LIST_DCN30(id)\
5563a83e4e6SRoman Li }
5573a83e4e6SRoman Li 
5583a83e4e6SRoman Li static const struct dcn_hubp2_registers hubp_regs[] = {
5593a83e4e6SRoman Li 		hubp_regs(0),
5603a83e4e6SRoman Li 		hubp_regs(1),
5613a83e4e6SRoman Li 		hubp_regs(2),
5623a83e4e6SRoman Li 		hubp_regs(3),
5633a83e4e6SRoman Li };
5643a83e4e6SRoman Li 
5653a83e4e6SRoman Li static const struct dcn_hubp2_shift hubp_shift = {
5663a83e4e6SRoman Li 		HUBP_MASK_SH_LIST_DCN30(__SHIFT)
5673a83e4e6SRoman Li };
5683a83e4e6SRoman Li 
5693a83e4e6SRoman Li static const struct dcn_hubp2_mask hubp_mask = {
5703a83e4e6SRoman Li 		HUBP_MASK_SH_LIST_DCN30(_MASK)
5713a83e4e6SRoman Li };
5723a83e4e6SRoman Li 
5733a83e4e6SRoman Li static const struct dcn_hubbub_registers hubbub_reg = {
5743a83e4e6SRoman Li 		HUBBUB_REG_LIST_DCN301(0)
5753a83e4e6SRoman Li };
5763a83e4e6SRoman Li 
5773a83e4e6SRoman Li static const struct dcn_hubbub_shift hubbub_shift = {
5783a83e4e6SRoman Li 		HUBBUB_MASK_SH_LIST_DCN301(__SHIFT)
5793a83e4e6SRoman Li };
5803a83e4e6SRoman Li 
5813a83e4e6SRoman Li static const struct dcn_hubbub_mask hubbub_mask = {
5823a83e4e6SRoman Li 		HUBBUB_MASK_SH_LIST_DCN301(_MASK)
5833a83e4e6SRoman Li };
5843a83e4e6SRoman Li 
5853a83e4e6SRoman Li static const struct dccg_registers dccg_regs = {
5863a83e4e6SRoman Li 		DCCG_REG_LIST_DCN301()
5873a83e4e6SRoman Li };
5883a83e4e6SRoman Li 
5893a83e4e6SRoman Li static const struct dccg_shift dccg_shift = {
5903a83e4e6SRoman Li 		DCCG_MASK_SH_LIST_DCN301(__SHIFT)
5913a83e4e6SRoman Li };
5923a83e4e6SRoman Li 
5933a83e4e6SRoman Li static const struct dccg_mask dccg_mask = {
5943a83e4e6SRoman Li 		DCCG_MASK_SH_LIST_DCN301(_MASK)
5953a83e4e6SRoman Li };
5963a83e4e6SRoman Li 
5973a83e4e6SRoman Li static const struct dce_hwseq_registers hwseq_reg = {
5983a83e4e6SRoman Li 		HWSEQ_DCN301_REG_LIST()
5993a83e4e6SRoman Li };
6003a83e4e6SRoman Li 
6013a83e4e6SRoman Li static const struct dce_hwseq_shift hwseq_shift = {
6023a83e4e6SRoman Li 		HWSEQ_DCN301_MASK_SH_LIST(__SHIFT)
6033a83e4e6SRoman Li };
6043a83e4e6SRoman Li 
6053a83e4e6SRoman Li static const struct dce_hwseq_mask hwseq_mask = {
6063a83e4e6SRoman Li 		HWSEQ_DCN301_MASK_SH_LIST(_MASK)
6073a83e4e6SRoman Li };
6083a83e4e6SRoman Li #define vmid_regs(id)\
6093a83e4e6SRoman Li [id] = {\
6103a83e4e6SRoman Li 		DCN20_VMID_REG_LIST(id)\
6113a83e4e6SRoman Li }
6123a83e4e6SRoman Li 
6133a83e4e6SRoman Li static const struct dcn_vmid_registers vmid_regs[] = {
6143a83e4e6SRoman Li 	vmid_regs(0),
6153a83e4e6SRoman Li 	vmid_regs(1),
6163a83e4e6SRoman Li 	vmid_regs(2),
6173a83e4e6SRoman Li 	vmid_regs(3),
6183a83e4e6SRoman Li 	vmid_regs(4),
6193a83e4e6SRoman Li 	vmid_regs(5),
6203a83e4e6SRoman Li 	vmid_regs(6),
6213a83e4e6SRoman Li 	vmid_regs(7),
6223a83e4e6SRoman Li 	vmid_regs(8),
6233a83e4e6SRoman Li 	vmid_regs(9),
6243a83e4e6SRoman Li 	vmid_regs(10),
6253a83e4e6SRoman Li 	vmid_regs(11),
6263a83e4e6SRoman Li 	vmid_regs(12),
6273a83e4e6SRoman Li 	vmid_regs(13),
6283a83e4e6SRoman Li 	vmid_regs(14),
6293a83e4e6SRoman Li 	vmid_regs(15)
6303a83e4e6SRoman Li };
6313a83e4e6SRoman Li 
6323a83e4e6SRoman Li static const struct dcn20_vmid_shift vmid_shifts = {
6333a83e4e6SRoman Li 		DCN20_VMID_MASK_SH_LIST(__SHIFT)
6343a83e4e6SRoman Li };
6353a83e4e6SRoman Li 
6363a83e4e6SRoman Li static const struct dcn20_vmid_mask vmid_masks = {
6373a83e4e6SRoman Li 		DCN20_VMID_MASK_SH_LIST(_MASK)
6383a83e4e6SRoman Li };
6393a83e4e6SRoman Li 
640fb579c42SPavle Kotarac static struct resource_caps res_cap_dcn301 = {
6413a83e4e6SRoman Li 	.num_timing_generator = 4,
6423a83e4e6SRoman Li 	.num_opp = 4,
6433a83e4e6SRoman Li 	.num_video_plane = 4,
6443a83e4e6SRoman Li 	.num_audio = 4,
6453a83e4e6SRoman Li 	.num_stream_encoder = 4,
6463a83e4e6SRoman Li 	.num_pll = 4,
6473a83e4e6SRoman Li 	.num_dwb = 1,
6483a83e4e6SRoman Li 	.num_ddc = 4,
6493a83e4e6SRoman Li 	.num_vmid = 16,
6503a83e4e6SRoman Li 	.num_mpc_3dlut = 2,
6513a83e4e6SRoman Li 	.num_dsc = 3,
6523a83e4e6SRoman Li };
6533a83e4e6SRoman Li 
6543a83e4e6SRoman Li static const struct dc_plane_cap plane_cap = {
6553a83e4e6SRoman Li 	.type = DC_PLANE_TYPE_DCN_UNIVERSAL,
6563a83e4e6SRoman Li 	.per_pixel_alpha = true,
6573a83e4e6SRoman Li 
6583a83e4e6SRoman Li 	.pixel_format_support = {
6593a83e4e6SRoman Li 			.argb8888 = true,
6603a83e4e6SRoman Li 			.nv12 = true,
6613a83e4e6SRoman Li 			.fp16 = true,
662ebe5ffd8SStylon Wang 			.p010 = true,
6633a83e4e6SRoman Li 			.ayuv = false,
6643a83e4e6SRoman Li 	},
6653a83e4e6SRoman Li 
6663a83e4e6SRoman Li 	.max_upscale_factor = {
6673a83e4e6SRoman Li 			.argb8888 = 16000,
6683a83e4e6SRoman Li 			.nv12 = 16000,
6693a83e4e6SRoman Li 			.fp16 = 16000
6703a83e4e6SRoman Li 	},
6713a83e4e6SRoman Li 
67260d177fdSNikola Cornij 	/* 6:1 downscaling ratio: 1000/6 = 166.666 */
6733a83e4e6SRoman Li 	.max_downscale_factor = {
674abc0ad6dSGabe Teeger 			.argb8888 = 358,
675abc0ad6dSGabe Teeger 			.nv12 = 358,
676abc0ad6dSGabe Teeger 			.fp16 = 358
6773a83e4e6SRoman Li 	},
6783a83e4e6SRoman Li 	64,
6793a83e4e6SRoman Li 	64
6803a83e4e6SRoman Li };
6813a83e4e6SRoman Li 
6823a83e4e6SRoman Li static const struct dc_debug_options debug_defaults_drv = {
6833a83e4e6SRoman Li 	.disable_dmcu = true,
6843a83e4e6SRoman Li 	.force_abm_enable = false,
6853a83e4e6SRoman Li 	.clock_trace = true,
686823b3169SSung Joon Kim 	.disable_dpp_power_gate = false,
687823b3169SSung Joon Kim 	.disable_hubp_power_gate = false,
6883a83e4e6SRoman Li 	.disable_clock_gate = true,
6893a83e4e6SRoman Li 	.disable_pplib_clock_request = true,
6903a83e4e6SRoman Li 	.disable_pplib_wm_range = true,
69175b204eeSRodrigo Siqueira 	.pipe_split_policy = MPC_SPLIT_DYNAMIC,
6923a83e4e6SRoman Li 	.force_single_disp_pipe_split = false,
6933a83e4e6SRoman Li 	.disable_dcc = DCC_ENABLE,
6943a83e4e6SRoman Li 	.vsr_support = true,
6953a83e4e6SRoman Li 	.performance_trace = false,
696abc0ad6dSGabe Teeger 	.max_downscale_src_width = 4096,/*upto true 4k*/
6973a83e4e6SRoman Li 	.scl_reset_length10 = true,
6983a83e4e6SRoman Li 	.sanity_checks = false,
6993a83e4e6SRoman Li 	.underflow_assert_delay_us = 0xFFFFFFFF,
7003a83e4e6SRoman Li 	.dwb_fi_phase = -1, // -1 = disable
7013a83e4e6SRoman Li 	.dmub_command_table = true,
7020e4c0ae5Scharles sun 	.use_max_lb = false,
70379de4d9aSRodrigo Siqueira 	.exit_idle_opt_for_cursor_updates = true,
704c5a45ee1SRodrigo Siqueira 	.enable_legacy_fast_update = true,
70579de4d9aSRodrigo Siqueira 	.using_dml2 = false,
7063a83e4e6SRoman Li };
7073a83e4e6SRoman Li 
dcn301_dpp_destroy(struct dpp ** dpp)708240e6d25SIsabella Basso static void dcn301_dpp_destroy(struct dpp **dpp)
7093a83e4e6SRoman Li {
7103a83e4e6SRoman Li 	kfree(TO_DCN20_DPP(*dpp));
7113a83e4e6SRoman Li 	*dpp = NULL;
7123a83e4e6SRoman Li }
7133a83e4e6SRoman Li 
dcn301_dpp_create(struct dc_context * ctx,uint32_t inst)714240e6d25SIsabella Basso static struct dpp *dcn301_dpp_create(struct dc_context *ctx, uint32_t inst)
7153a83e4e6SRoman Li {
7163a83e4e6SRoman Li 	struct dcn3_dpp *dpp =
7173a83e4e6SRoman Li 		kzalloc(sizeof(struct dcn3_dpp), GFP_KERNEL);
7183a83e4e6SRoman Li 
7193a83e4e6SRoman Li 	if (!dpp)
7203a83e4e6SRoman Li 		return NULL;
7213a83e4e6SRoman Li 
7223a83e4e6SRoman Li 	if (dpp3_construct(dpp, ctx, inst,
7233a83e4e6SRoman Li 			&dpp_regs[inst], &tf_shift, &tf_mask))
7243a83e4e6SRoman Li 		return &dpp->base;
7253a83e4e6SRoman Li 
7263a83e4e6SRoman Li 	BREAK_TO_DEBUGGER();
7273a83e4e6SRoman Li 	kfree(dpp);
7283a83e4e6SRoman Li 	return NULL;
7293a83e4e6SRoman Li }
dcn301_opp_create(struct dc_context * ctx,uint32_t inst)730240e6d25SIsabella Basso static struct output_pixel_processor *dcn301_opp_create(struct dc_context *ctx,
731240e6d25SIsabella Basso 							uint32_t inst)
7323a83e4e6SRoman Li {
7333a83e4e6SRoman Li 	struct dcn20_opp *opp =
7343a83e4e6SRoman Li 		kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
7353a83e4e6SRoman Li 
7363a83e4e6SRoman Li 	if (!opp) {
7373a83e4e6SRoman Li 		BREAK_TO_DEBUGGER();
7383a83e4e6SRoman Li 		return NULL;
7393a83e4e6SRoman Li 	}
7403a83e4e6SRoman Li 
7413a83e4e6SRoman Li 	dcn20_opp_construct(opp, ctx, inst,
7423a83e4e6SRoman Li 			&opp_regs[inst], &opp_shift, &opp_mask);
7433a83e4e6SRoman Li 	return &opp->base;
7443a83e4e6SRoman Li }
7453a83e4e6SRoman Li 
dcn301_aux_engine_create(struct dc_context * ctx,uint32_t inst)746240e6d25SIsabella Basso static struct dce_aux *dcn301_aux_engine_create(struct dc_context *ctx, uint32_t inst)
7473a83e4e6SRoman Li {
7483a83e4e6SRoman Li 	struct aux_engine_dce110 *aux_engine =
7493a83e4e6SRoman Li 		kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
7503a83e4e6SRoman Li 
7513a83e4e6SRoman Li 	if (!aux_engine)
7523a83e4e6SRoman Li 		return NULL;
7533a83e4e6SRoman Li 
7543a83e4e6SRoman Li 	dce110_aux_engine_construct(aux_engine, ctx, inst,
7553a83e4e6SRoman Li 				    SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD,
7563a83e4e6SRoman Li 				    &aux_engine_regs[inst],
7573a83e4e6SRoman Li 					&aux_mask,
7583a83e4e6SRoman Li 					&aux_shift,
7593a83e4e6SRoman Li 					ctx->dc->caps.extended_aux_timeout_support);
7603a83e4e6SRoman Li 
7613a83e4e6SRoman Li 	return &aux_engine->base;
7623a83e4e6SRoman Li }
7633a83e4e6SRoman Li #define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) }
7643a83e4e6SRoman Li 
7653a83e4e6SRoman Li static const struct dce_i2c_registers i2c_hw_regs[] = {
7663a83e4e6SRoman Li 		i2c_inst_regs(1),
7673a83e4e6SRoman Li 		i2c_inst_regs(2),
7683a83e4e6SRoman Li 		i2c_inst_regs(3),
7693a83e4e6SRoman Li 		i2c_inst_regs(4),
7703a83e4e6SRoman Li };
7713a83e4e6SRoman Li 
7723a83e4e6SRoman Li static const struct dce_i2c_shift i2c_shifts = {
7733a83e4e6SRoman Li 		I2C_COMMON_MASK_SH_LIST_DCN2(__SHIFT)
7743a83e4e6SRoman Li };
7753a83e4e6SRoman Li 
7763a83e4e6SRoman Li static const struct dce_i2c_mask i2c_masks = {
7773a83e4e6SRoman Li 		I2C_COMMON_MASK_SH_LIST_DCN2(_MASK)
7783a83e4e6SRoman Li };
7793a83e4e6SRoman Li 
dcn301_i2c_hw_create(struct dc_context * ctx,uint32_t inst)780240e6d25SIsabella Basso static struct dce_i2c_hw *dcn301_i2c_hw_create(struct dc_context *ctx, uint32_t inst)
7813a83e4e6SRoman Li {
7823a83e4e6SRoman Li 	struct dce_i2c_hw *dce_i2c_hw =
7833a83e4e6SRoman Li 		kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
7843a83e4e6SRoman Li 
7853a83e4e6SRoman Li 	if (!dce_i2c_hw)
7863a83e4e6SRoman Li 		return NULL;
7873a83e4e6SRoman Li 
7883a83e4e6SRoman Li 	dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst,
7893a83e4e6SRoman Li 				    &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks);
7903a83e4e6SRoman Li 
7913a83e4e6SRoman Li 	return dce_i2c_hw;
7923a83e4e6SRoman Li }
dcn301_mpc_create(struct dc_context * ctx,int num_mpcc,int num_rmu)7933a83e4e6SRoman Li static struct mpc *dcn301_mpc_create(
7943a83e4e6SRoman Li 		struct dc_context *ctx,
7953a83e4e6SRoman Li 		int num_mpcc,
7963a83e4e6SRoman Li 		int num_rmu)
7973a83e4e6SRoman Li {
7983a83e4e6SRoman Li 	struct dcn30_mpc *mpc30 = kzalloc(sizeof(struct dcn30_mpc),
7993a83e4e6SRoman Li 					  GFP_KERNEL);
8003a83e4e6SRoman Li 
8013a83e4e6SRoman Li 	if (!mpc30)
8023a83e4e6SRoman Li 		return NULL;
8033a83e4e6SRoman Li 
8043a83e4e6SRoman Li 	dcn30_mpc_construct(mpc30, ctx,
8053a83e4e6SRoman Li 			&mpc_regs,
8063a83e4e6SRoman Li 			&mpc_shift,
8073a83e4e6SRoman Li 			&mpc_mask,
8083a83e4e6SRoman Li 			num_mpcc,
8093a83e4e6SRoman Li 			num_rmu);
8103a83e4e6SRoman Li 
8113a83e4e6SRoman Li 	return &mpc30->base;
8123a83e4e6SRoman Li }
8133a83e4e6SRoman Li 
dcn301_hubbub_create(struct dc_context * ctx)814240e6d25SIsabella Basso static struct hubbub *dcn301_hubbub_create(struct dc_context *ctx)
8153a83e4e6SRoman Li {
8163a83e4e6SRoman Li 	int i;
8173a83e4e6SRoman Li 
8183a83e4e6SRoman Li 	struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub),
8193a83e4e6SRoman Li 					  GFP_KERNEL);
8203a83e4e6SRoman Li 
8213a83e4e6SRoman Li 	if (!hubbub3)
8223a83e4e6SRoman Li 		return NULL;
8233a83e4e6SRoman Li 
8243a83e4e6SRoman Li 	hubbub301_construct(hubbub3, ctx,
8253a83e4e6SRoman Li 			&hubbub_reg,
8263a83e4e6SRoman Li 			&hubbub_shift,
8273a83e4e6SRoman Li 			&hubbub_mask);
8283a83e4e6SRoman Li 
8293a83e4e6SRoman Li 
8303a83e4e6SRoman Li 	for (i = 0; i < res_cap_dcn301.num_vmid; i++) {
8313a83e4e6SRoman Li 		struct dcn20_vmid *vmid = &hubbub3->vmid[i];
8323a83e4e6SRoman Li 
8333a83e4e6SRoman Li 		vmid->ctx = ctx;
8343a83e4e6SRoman Li 
8353a83e4e6SRoman Li 		vmid->regs = &vmid_regs[i];
8363a83e4e6SRoman Li 		vmid->shifts = &vmid_shifts;
8373a83e4e6SRoman Li 		vmid->masks = &vmid_masks;
8383a83e4e6SRoman Li 	}
8393a83e4e6SRoman Li 
8403a83e4e6SRoman Li 	hubbub3->num_vmid = res_cap_dcn301.num_vmid;
8413a83e4e6SRoman Li 
8423a83e4e6SRoman Li 	return &hubbub3->base;
8433a83e4e6SRoman Li }
8443a83e4e6SRoman Li 
dcn301_timing_generator_create(struct dc_context * ctx,uint32_t instance)845240e6d25SIsabella Basso static struct timing_generator *dcn301_timing_generator_create(
846240e6d25SIsabella Basso 	struct dc_context *ctx, uint32_t instance)
8473a83e4e6SRoman Li {
8483a83e4e6SRoman Li 	struct optc *tgn10 =
8493a83e4e6SRoman Li 		kzalloc(sizeof(struct optc), GFP_KERNEL);
8503a83e4e6SRoman Li 
8513a83e4e6SRoman Li 	if (!tgn10)
8523a83e4e6SRoman Li 		return NULL;
8533a83e4e6SRoman Li 
8543a83e4e6SRoman Li 	tgn10->base.inst = instance;
8553a83e4e6SRoman Li 	tgn10->base.ctx = ctx;
8563a83e4e6SRoman Li 
8573a83e4e6SRoman Li 	tgn10->tg_regs = &optc_regs[instance];
8583a83e4e6SRoman Li 	tgn10->tg_shift = &optc_shift;
8593a83e4e6SRoman Li 	tgn10->tg_mask = &optc_mask;
8603a83e4e6SRoman Li 
861b188069fSAurabindo Pillai 	dcn301_timing_generator_init(tgn10);
8623a83e4e6SRoman Li 
8633a83e4e6SRoman Li 	return &tgn10->base;
8643a83e4e6SRoman Li }
8653a83e4e6SRoman Li 
8663a83e4e6SRoman Li static const struct encoder_feature_support link_enc_feature = {
8673a83e4e6SRoman Li 		.max_hdmi_deep_color = COLOR_DEPTH_121212,
8683a83e4e6SRoman Li 		.max_hdmi_pixel_clock = 600000,
8693a83e4e6SRoman Li 		.hdmi_ycbcr420_supported = true,
8703a83e4e6SRoman Li 		.dp_ycbcr420_supported = true,
8713a83e4e6SRoman Li 		.fec_supported = true,
8723a83e4e6SRoman Li 		.flags.bits.IS_HBR2_CAPABLE = true,
8733a83e4e6SRoman Li 		.flags.bits.IS_HBR3_CAPABLE = true,
8743a83e4e6SRoman Li 		.flags.bits.IS_TPS3_CAPABLE = true,
8753a83e4e6SRoman Li 		.flags.bits.IS_TPS4_CAPABLE = true
8763a83e4e6SRoman Li };
8773a83e4e6SRoman Li 
dcn301_link_encoder_create(struct dc_context * ctx,const struct encoder_init_data * enc_init_data)878240e6d25SIsabella Basso static struct link_encoder *dcn301_link_encoder_create(
879e216431bSAurabindo Pillai 	struct dc_context *ctx,
8803a83e4e6SRoman Li 	const struct encoder_init_data *enc_init_data)
8813a83e4e6SRoman Li {
8823a83e4e6SRoman Li 	struct dcn20_link_encoder *enc20 =
8833a83e4e6SRoman Li 		kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
8843a83e4e6SRoman Li 
8851791bd09SSrinivasan Shanmugam 	if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
8863a83e4e6SRoman Li 		return NULL;
8873a83e4e6SRoman Li 
8883a83e4e6SRoman Li 	dcn301_link_encoder_construct(enc20,
8893a83e4e6SRoman Li 			enc_init_data,
8903a83e4e6SRoman Li 			&link_enc_feature,
8913a83e4e6SRoman Li 			&link_enc_regs[enc_init_data->transmitter],
8923a83e4e6SRoman Li 			&link_enc_aux_regs[enc_init_data->channel - 1],
8933a83e4e6SRoman Li 			&link_enc_hpd_regs[enc_init_data->hpd_source],
8943a83e4e6SRoman Li 			&le_shift,
8953a83e4e6SRoman Li 			&le_mask);
8963a83e4e6SRoman Li 
8973a83e4e6SRoman Li 	return &enc20->enc10.base;
8983a83e4e6SRoman Li }
8993a83e4e6SRoman Li 
dcn301_panel_cntl_create(const struct panel_cntl_init_data * init_data)900240e6d25SIsabella Basso static struct panel_cntl *dcn301_panel_cntl_create(const struct panel_cntl_init_data *init_data)
9013a83e4e6SRoman Li {
9023a83e4e6SRoman Li 	struct dcn301_panel_cntl *panel_cntl =
9033a83e4e6SRoman Li 		kzalloc(sizeof(struct dcn301_panel_cntl), GFP_KERNEL);
9043a83e4e6SRoman Li 
9053a83e4e6SRoman Li 	if (!panel_cntl)
9063a83e4e6SRoman Li 		return NULL;
9073a83e4e6SRoman Li 
9083a83e4e6SRoman Li 	dcn301_panel_cntl_construct(panel_cntl,
9093a83e4e6SRoman Li 			init_data,
9103a83e4e6SRoman Li 			&panel_cntl_regs[init_data->inst],
9113a83e4e6SRoman Li 			&panel_cntl_shift,
9123a83e4e6SRoman Li 			&panel_cntl_mask);
9133a83e4e6SRoman Li 
9143a83e4e6SRoman Li 	return &panel_cntl->base;
9153a83e4e6SRoman Li }
9163a83e4e6SRoman Li 
9173a83e4e6SRoman Li 
9183a83e4e6SRoman Li #define CTX ctx
9193a83e4e6SRoman Li 
9203a83e4e6SRoman Li #define REG(reg_name) \
9213a83e4e6SRoman Li 	(DCN_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## reg_name)
9223a83e4e6SRoman Li 
read_pipe_fuses(struct dc_context * ctx)9233a83e4e6SRoman Li static uint32_t read_pipe_fuses(struct dc_context *ctx)
9243a83e4e6SRoman Li {
9253a83e4e6SRoman Li 	uint32_t value = REG_READ(CC_DC_PIPE_DIS);
9263a83e4e6SRoman Li 	/* RV1 support max 4 pipes */
9273a83e4e6SRoman Li 	value = value & 0xf;
9283a83e4e6SRoman Li 	return value;
9293a83e4e6SRoman Li }
9303a83e4e6SRoman Li 
9313a83e4e6SRoman Li 
read_dce_straps(struct dc_context * ctx,struct resource_straps * straps)9323a83e4e6SRoman Li static void read_dce_straps(
9333a83e4e6SRoman Li 	struct dc_context *ctx,
9343a83e4e6SRoman Li 	struct resource_straps *straps)
9353a83e4e6SRoman Li {
9363a83e4e6SRoman Li 	generic_reg_get(ctx, mmDC_PINSTRAPS + BASE(mmDC_PINSTRAPS_BASE_IDX),
9373a83e4e6SRoman Li 		FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio);
9383a83e4e6SRoman Li 
9393a83e4e6SRoman Li }
9403a83e4e6SRoman Li 
dcn301_create_audio(struct dc_context * ctx,unsigned int inst)9413a83e4e6SRoman Li static struct audio *dcn301_create_audio(
9423a83e4e6SRoman Li 		struct dc_context *ctx, unsigned int inst)
9433a83e4e6SRoman Li {
9443a83e4e6SRoman Li 	return dce_audio_create(ctx, inst,
9453a83e4e6SRoman Li 			&audio_regs[inst], &audio_shift, &audio_mask);
9463a83e4e6SRoman Li }
9473a83e4e6SRoman Li 
dcn301_vpg_create(struct dc_context * ctx,uint32_t inst)9483a83e4e6SRoman Li static struct vpg *dcn301_vpg_create(
9493a83e4e6SRoman Li 	struct dc_context *ctx,
9503a83e4e6SRoman Li 	uint32_t inst)
9513a83e4e6SRoman Li {
9523a83e4e6SRoman Li 	struct dcn30_vpg *vpg3 = kzalloc(sizeof(struct dcn30_vpg), GFP_KERNEL);
9533a83e4e6SRoman Li 
9543a83e4e6SRoman Li 	if (!vpg3)
9553a83e4e6SRoman Li 		return NULL;
9563a83e4e6SRoman Li 
9573a83e4e6SRoman Li 	vpg3_construct(vpg3, ctx, inst,
9583a83e4e6SRoman Li 			&vpg_regs[inst],
9593a83e4e6SRoman Li 			&vpg_shift,
9603a83e4e6SRoman Li 			&vpg_mask);
9613a83e4e6SRoman Li 
9623a83e4e6SRoman Li 	return &vpg3->base;
9633a83e4e6SRoman Li }
9643a83e4e6SRoman Li 
dcn301_afmt_create(struct dc_context * ctx,uint32_t inst)9653a83e4e6SRoman Li static struct afmt *dcn301_afmt_create(
9663a83e4e6SRoman Li 	struct dc_context *ctx,
9673a83e4e6SRoman Li 	uint32_t inst)
9683a83e4e6SRoman Li {
9693a83e4e6SRoman Li 	struct dcn30_afmt *afmt3 = kzalloc(sizeof(struct dcn30_afmt), GFP_KERNEL);
9703a83e4e6SRoman Li 
9713a83e4e6SRoman Li 	if (!afmt3)
9723a83e4e6SRoman Li 		return NULL;
9733a83e4e6SRoman Li 
9743a83e4e6SRoman Li 	afmt3_construct(afmt3, ctx, inst,
9753a83e4e6SRoman Li 			&afmt_regs[inst],
9763a83e4e6SRoman Li 			&afmt_shift,
9773a83e4e6SRoman Li 			&afmt_mask);
9783a83e4e6SRoman Li 
9793a83e4e6SRoman Li 	return &afmt3->base;
9803a83e4e6SRoman Li }
9813a83e4e6SRoman Li 
dcn301_stream_encoder_create(enum engine_id eng_id,struct dc_context * ctx)982240e6d25SIsabella Basso static struct stream_encoder *dcn301_stream_encoder_create(enum engine_id eng_id,
9833a83e4e6SRoman Li 							   struct dc_context *ctx)
9843a83e4e6SRoman Li {
9853a83e4e6SRoman Li 	struct dcn10_stream_encoder *enc1;
9863a83e4e6SRoman Li 	struct vpg *vpg;
9873a83e4e6SRoman Li 	struct afmt *afmt;
9883a83e4e6SRoman Li 	int vpg_inst;
9893a83e4e6SRoman Li 	int afmt_inst;
9903a83e4e6SRoman Li 
9913a83e4e6SRoman Li 	/* Mapping of VPG, AFMT, DME register blocks to DIO block instance */
9923a83e4e6SRoman Li 	if (eng_id <= ENGINE_ID_DIGF) {
9933a83e4e6SRoman Li 		vpg_inst = eng_id;
9943a83e4e6SRoman Li 		afmt_inst = eng_id;
9953a83e4e6SRoman Li 	} else
9963a83e4e6SRoman Li 		return NULL;
9973a83e4e6SRoman Li 
9983a83e4e6SRoman Li 	enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
9993a83e4e6SRoman Li 	vpg = dcn301_vpg_create(ctx, vpg_inst);
10003a83e4e6SRoman Li 	afmt = dcn301_afmt_create(ctx, afmt_inst);
10013a83e4e6SRoman Li 
100258fca355SSrinivasan Shanmugam 	if (!enc1 || !vpg || !afmt || eng_id >= ARRAY_SIZE(stream_enc_regs)) {
10037b89bf83SAnson Jacob 		kfree(enc1);
10047b89bf83SAnson Jacob 		kfree(vpg);
10057b89bf83SAnson Jacob 		kfree(afmt);
10063a83e4e6SRoman Li 		return NULL;
10077b89bf83SAnson Jacob 	}
10083a83e4e6SRoman Li 
10093a83e4e6SRoman Li 	dcn30_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios,
10103a83e4e6SRoman Li 					eng_id, vpg, afmt,
10113a83e4e6SRoman Li 					&stream_enc_regs[eng_id],
10123a83e4e6SRoman Li 					&se_shift, &se_mask);
10133a83e4e6SRoman Li 
10143a83e4e6SRoman Li 	return &enc1->base;
10153a83e4e6SRoman Li }
10163a83e4e6SRoman Li 
dcn301_hwseq_create(struct dc_context * ctx)1017240e6d25SIsabella Basso static struct dce_hwseq *dcn301_hwseq_create(struct dc_context *ctx)
10183a83e4e6SRoman Li {
10193a83e4e6SRoman Li 	struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
10203a83e4e6SRoman Li 
10213a83e4e6SRoman Li 	if (hws) {
10223a83e4e6SRoman Li 		hws->ctx = ctx;
10233a83e4e6SRoman Li 		hws->regs = &hwseq_reg;
10243a83e4e6SRoman Li 		hws->shifts = &hwseq_shift;
10253a83e4e6SRoman Li 		hws->masks = &hwseq_mask;
10263a83e4e6SRoman Li 	}
10273a83e4e6SRoman Li 	return hws;
10283a83e4e6SRoman Li }
10293a83e4e6SRoman Li static const struct resource_create_funcs res_create_funcs = {
10303a83e4e6SRoman Li 	.read_dce_straps = read_dce_straps,
10313a83e4e6SRoman Li 	.create_audio = dcn301_create_audio,
10323a83e4e6SRoman Li 	.create_stream_encoder = dcn301_stream_encoder_create,
10333a83e4e6SRoman Li 	.create_hwseq = dcn301_hwseq_create,
10343a83e4e6SRoman Li };
10353a83e4e6SRoman Li 
dcn301_destruct(struct dcn301_resource_pool * pool)10363a83e4e6SRoman Li static void dcn301_destruct(struct dcn301_resource_pool *pool)
10373a83e4e6SRoman Li {
10383a83e4e6SRoman Li 	unsigned int i;
10393a83e4e6SRoman Li 
10403a83e4e6SRoman Li 	for (i = 0; i < pool->base.stream_enc_count; i++) {
10413a83e4e6SRoman Li 		if (pool->base.stream_enc[i] != NULL) {
10423a83e4e6SRoman Li 			if (pool->base.stream_enc[i]->vpg != NULL) {
10433a83e4e6SRoman Li 				kfree(DCN30_VPG_FROM_VPG(pool->base.stream_enc[i]->vpg));
10443a83e4e6SRoman Li 				pool->base.stream_enc[i]->vpg = NULL;
10453a83e4e6SRoman Li 			}
10463a83e4e6SRoman Li 			if (pool->base.stream_enc[i]->afmt != NULL) {
10473a83e4e6SRoman Li 				kfree(DCN30_AFMT_FROM_AFMT(pool->base.stream_enc[i]->afmt));
10483a83e4e6SRoman Li 				pool->base.stream_enc[i]->afmt = NULL;
10493a83e4e6SRoman Li 			}
10503a83e4e6SRoman Li 			kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i]));
10513a83e4e6SRoman Li 			pool->base.stream_enc[i] = NULL;
10523a83e4e6SRoman Li 		}
10533a83e4e6SRoman Li 	}
10543a83e4e6SRoman Li 
10553a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_dsc; i++) {
10563a83e4e6SRoman Li 		if (pool->base.dscs[i] != NULL)
10573a83e4e6SRoman Li 			dcn20_dsc_destroy(&pool->base.dscs[i]);
10583a83e4e6SRoman Li 	}
10593a83e4e6SRoman Li 
10603a83e4e6SRoman Li 	if (pool->base.mpc != NULL) {
10613a83e4e6SRoman Li 		kfree(TO_DCN20_MPC(pool->base.mpc));
10623a83e4e6SRoman Li 		pool->base.mpc = NULL;
10633a83e4e6SRoman Li 	}
10643a83e4e6SRoman Li 	if (pool->base.hubbub != NULL) {
10653a83e4e6SRoman Li 		kfree(pool->base.hubbub);
10663a83e4e6SRoman Li 		pool->base.hubbub = NULL;
10673a83e4e6SRoman Li 	}
10683a83e4e6SRoman Li 	for (i = 0; i < pool->base.pipe_count; i++) {
10693a83e4e6SRoman Li 		if (pool->base.dpps[i] != NULL)
10703a83e4e6SRoman Li 			dcn301_dpp_destroy(&pool->base.dpps[i]);
10713a83e4e6SRoman Li 
10723a83e4e6SRoman Li 		if (pool->base.ipps[i] != NULL)
10733a83e4e6SRoman Li 			pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]);
10743a83e4e6SRoman Li 
10753a83e4e6SRoman Li 		if (pool->base.hubps[i] != NULL) {
10763a83e4e6SRoman Li 			kfree(TO_DCN20_HUBP(pool->base.hubps[i]));
10773a83e4e6SRoman Li 			pool->base.hubps[i] = NULL;
10783a83e4e6SRoman Li 		}
10793a83e4e6SRoman Li 
10803a83e4e6SRoman Li 		if (pool->base.irqs != NULL) {
10813a83e4e6SRoman Li 			dal_irq_service_destroy(&pool->base.irqs);
10823a83e4e6SRoman Li 		}
10833a83e4e6SRoman Li 	}
10843a83e4e6SRoman Li 
10853a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
10863a83e4e6SRoman Li 		if (pool->base.engines[i] != NULL)
10873a83e4e6SRoman Li 			dce110_engine_destroy(&pool->base.engines[i]);
10883a83e4e6SRoman Li 		if (pool->base.hw_i2cs[i] != NULL) {
10893a83e4e6SRoman Li 			kfree(pool->base.hw_i2cs[i]);
10903a83e4e6SRoman Li 			pool->base.hw_i2cs[i] = NULL;
10913a83e4e6SRoman Li 		}
10923a83e4e6SRoman Li 		if (pool->base.sw_i2cs[i] != NULL) {
10933a83e4e6SRoman Li 			kfree(pool->base.sw_i2cs[i]);
10943a83e4e6SRoman Li 			pool->base.sw_i2cs[i] = NULL;
10953a83e4e6SRoman Li 		}
10963a83e4e6SRoman Li 	}
10973a83e4e6SRoman Li 
10983a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_opp; i++) {
10993a83e4e6SRoman Li 		if (pool->base.opps[i] != NULL)
11003a83e4e6SRoman Li 			pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]);
11013a83e4e6SRoman Li 	}
11023a83e4e6SRoman Li 
11033a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
11043a83e4e6SRoman Li 		if (pool->base.timing_generators[i] != NULL)	{
11053a83e4e6SRoman Li 			kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
11063a83e4e6SRoman Li 			pool->base.timing_generators[i] = NULL;
11073a83e4e6SRoman Li 		}
11083a83e4e6SRoman Li 	}
11093a83e4e6SRoman Li 
11103a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_dwb; i++) {
11113a83e4e6SRoman Li 		if (pool->base.dwbc[i] != NULL) {
11123a83e4e6SRoman Li 			kfree(TO_DCN30_DWBC(pool->base.dwbc[i]));
11133a83e4e6SRoman Li 			pool->base.dwbc[i] = NULL;
11143a83e4e6SRoman Li 		}
11153a83e4e6SRoman Li 		if (pool->base.mcif_wb[i] != NULL) {
11163a83e4e6SRoman Li 			kfree(TO_DCN30_MMHUBBUB(pool->base.mcif_wb[i]));
11173a83e4e6SRoman Li 			pool->base.mcif_wb[i] = NULL;
11183a83e4e6SRoman Li 		}
11193a83e4e6SRoman Li 	}
11203a83e4e6SRoman Li 
11213a83e4e6SRoman Li 	for (i = 0; i < pool->base.audio_count; i++) {
11223a83e4e6SRoman Li 		if (pool->base.audios[i])
11233a83e4e6SRoman Li 			dce_aud_destroy(&pool->base.audios[i]);
11243a83e4e6SRoman Li 	}
11253a83e4e6SRoman Li 
11263a83e4e6SRoman Li 	for (i = 0; i < pool->base.clk_src_count; i++) {
11273a83e4e6SRoman Li 		if (pool->base.clock_sources[i] != NULL) {
11283a83e4e6SRoman Li 			dcn20_clock_source_destroy(&pool->base.clock_sources[i]);
11293a83e4e6SRoman Li 			pool->base.clock_sources[i] = NULL;
11303a83e4e6SRoman Li 		}
11313a83e4e6SRoman Li 	}
11323a83e4e6SRoman Li 
11333a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_mpc_3dlut; i++) {
11343a83e4e6SRoman Li 		if (pool->base.mpc_lut[i] != NULL) {
11353a83e4e6SRoman Li 			dc_3dlut_func_release(pool->base.mpc_lut[i]);
11363a83e4e6SRoman Li 			pool->base.mpc_lut[i] = NULL;
11373a83e4e6SRoman Li 		}
11383a83e4e6SRoman Li 		if (pool->base.mpc_shaper[i] != NULL) {
11393a83e4e6SRoman Li 			dc_transfer_func_release(pool->base.mpc_shaper[i]);
11403a83e4e6SRoman Li 			pool->base.mpc_shaper[i] = NULL;
11413a83e4e6SRoman Li 		}
11423a83e4e6SRoman Li 	}
11433a83e4e6SRoman Li 
11443a83e4e6SRoman Li 	if (pool->base.dp_clock_source != NULL) {
11453a83e4e6SRoman Li 		dcn20_clock_source_destroy(&pool->base.dp_clock_source);
11463a83e4e6SRoman Li 		pool->base.dp_clock_source = NULL;
11473a83e4e6SRoman Li 	}
11483a83e4e6SRoman Li 
11493a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
11503a83e4e6SRoman Li 		if (pool->base.multiple_abms[i] != NULL)
11513a83e4e6SRoman Li 			dce_abm_destroy(&pool->base.multiple_abms[i]);
11523a83e4e6SRoman Li 	}
11533a83e4e6SRoman Li 
11543a83e4e6SRoman Li 	if (pool->base.dccg != NULL)
11553a83e4e6SRoman Li 		dcn_dccg_destroy(&pool->base.dccg);
11563a83e4e6SRoman Li }
11573a83e4e6SRoman Li 
dcn301_hubp_create(struct dc_context * ctx,uint32_t inst)1158240e6d25SIsabella Basso static struct hubp *dcn301_hubp_create(struct dc_context *ctx, uint32_t inst)
11593a83e4e6SRoman Li {
11603a83e4e6SRoman Li 	struct dcn20_hubp *hubp2 =
11613a83e4e6SRoman Li 		kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
11623a83e4e6SRoman Li 
11633a83e4e6SRoman Li 	if (!hubp2)
11643a83e4e6SRoman Li 		return NULL;
11653a83e4e6SRoman Li 
11663a83e4e6SRoman Li 	if (hubp3_construct(hubp2, ctx, inst,
11673a83e4e6SRoman Li 			&hubp_regs[inst], &hubp_shift, &hubp_mask))
11683a83e4e6SRoman Li 		return &hubp2->base;
11693a83e4e6SRoman Li 
11703a83e4e6SRoman Li 	BREAK_TO_DEBUGGER();
11713a83e4e6SRoman Li 	kfree(hubp2);
11723a83e4e6SRoman Li 	return NULL;
11733a83e4e6SRoman Li }
11743a83e4e6SRoman Li 
dcn301_dwbc_create(struct dc_context * ctx,struct resource_pool * pool)1175240e6d25SIsabella Basso static bool dcn301_dwbc_create(struct dc_context *ctx, struct resource_pool *pool)
11763a83e4e6SRoman Li {
11773a83e4e6SRoman Li 	int i;
11783a83e4e6SRoman Li 	uint32_t pipe_count = pool->res_cap->num_dwb;
11793a83e4e6SRoman Li 
11803a83e4e6SRoman Li 	for (i = 0; i < pipe_count; i++) {
11813a83e4e6SRoman Li 		struct dcn30_dwbc *dwbc30 = kzalloc(sizeof(struct dcn30_dwbc),
11823a83e4e6SRoman Li 						    GFP_KERNEL);
11833a83e4e6SRoman Li 
11843a83e4e6SRoman Li 		if (!dwbc30) {
11853a83e4e6SRoman Li 			dm_error("DC: failed to create dwbc30!\n");
11863a83e4e6SRoman Li 			return false;
11873a83e4e6SRoman Li 		}
11883a83e4e6SRoman Li 
11893a83e4e6SRoman Li 		dcn30_dwbc_construct(dwbc30, ctx,
11903a83e4e6SRoman Li 				&dwbc30_regs[i],
11913a83e4e6SRoman Li 				&dwbc30_shift,
11923a83e4e6SRoman Li 				&dwbc30_mask,
11933a83e4e6SRoman Li 				i);
11943a83e4e6SRoman Li 
11953a83e4e6SRoman Li 		pool->dwbc[i] = &dwbc30->base;
11963a83e4e6SRoman Li 	}
11973a83e4e6SRoman Li 	return true;
11983a83e4e6SRoman Li }
11993a83e4e6SRoman Li 
dcn301_mmhubbub_create(struct dc_context * ctx,struct resource_pool * pool)1200240e6d25SIsabella Basso static bool dcn301_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool)
12013a83e4e6SRoman Li {
12023a83e4e6SRoman Li 	int i;
12033a83e4e6SRoman Li 	uint32_t pipe_count = pool->res_cap->num_dwb;
12043a83e4e6SRoman Li 
12053a83e4e6SRoman Li 	for (i = 0; i < pipe_count; i++) {
12063a83e4e6SRoman Li 		struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub),
12073a83e4e6SRoman Li 						    GFP_KERNEL);
12083a83e4e6SRoman Li 
12093a83e4e6SRoman Li 		if (!mcif_wb30) {
12103a83e4e6SRoman Li 			dm_error("DC: failed to create mcif_wb30!\n");
12113a83e4e6SRoman Li 			return false;
12123a83e4e6SRoman Li 		}
12133a83e4e6SRoman Li 
12143a83e4e6SRoman Li 		dcn30_mmhubbub_construct(mcif_wb30, ctx,
12153a83e4e6SRoman Li 				&mcif_wb30_regs[i],
12163a83e4e6SRoman Li 				&mcif_wb30_shift,
12173a83e4e6SRoman Li 				&mcif_wb30_mask,
12183a83e4e6SRoman Li 				i);
12193a83e4e6SRoman Li 
12203a83e4e6SRoman Li 		pool->mcif_wb[i] = &mcif_wb30->base;
12213a83e4e6SRoman Li 	}
12223a83e4e6SRoman Li 	return true;
12233a83e4e6SRoman Li }
12243a83e4e6SRoman Li 
dcn301_dsc_create(struct dc_context * ctx,uint32_t inst)12253a83e4e6SRoman Li static struct display_stream_compressor *dcn301_dsc_create(
12263a83e4e6SRoman Li 	struct dc_context *ctx, uint32_t inst)
12273a83e4e6SRoman Li {
12283a83e4e6SRoman Li 	struct dcn20_dsc *dsc =
12293a83e4e6SRoman Li 		kzalloc(sizeof(struct dcn20_dsc), GFP_KERNEL);
12303a83e4e6SRoman Li 
12313a83e4e6SRoman Li 	if (!dsc) {
12323a83e4e6SRoman Li 		BREAK_TO_DEBUGGER();
12333a83e4e6SRoman Li 		return NULL;
12343a83e4e6SRoman Li 	}
12353a83e4e6SRoman Li 
12363a83e4e6SRoman Li 	dsc2_construct(dsc, ctx, inst, &dsc_regs[inst], &dsc_shift, &dsc_mask);
12373a83e4e6SRoman Li 	return &dsc->base;
12383a83e4e6SRoman Li }
12393a83e4e6SRoman Li 
12403a83e4e6SRoman Li 
dcn301_destroy_resource_pool(struct resource_pool ** pool)12413a83e4e6SRoman Li static void dcn301_destroy_resource_pool(struct resource_pool **pool)
12423a83e4e6SRoman Li {
12433a83e4e6SRoman Li 	struct dcn301_resource_pool *dcn301_pool = TO_DCN301_RES_POOL(*pool);
12443a83e4e6SRoman Li 
12453a83e4e6SRoman Li 	dcn301_destruct(dcn301_pool);
12463a83e4e6SRoman Li 	kfree(dcn301_pool);
12473a83e4e6SRoman Li 	*pool = NULL;
12483a83e4e6SRoman Li }
12493a83e4e6SRoman Li 
dcn301_clock_source_create(struct dc_context * ctx,struct dc_bios * bios,enum clock_source_id id,const struct dce110_clk_src_regs * regs,bool dp_clk_src)12503a83e4e6SRoman Li static struct clock_source *dcn301_clock_source_create(
12513a83e4e6SRoman Li 		struct dc_context *ctx,
12523a83e4e6SRoman Li 		struct dc_bios *bios,
12533a83e4e6SRoman Li 		enum clock_source_id id,
12543a83e4e6SRoman Li 		const struct dce110_clk_src_regs *regs,
12553a83e4e6SRoman Li 		bool dp_clk_src)
12563a83e4e6SRoman Li {
12573a83e4e6SRoman Li 	struct dce110_clk_src *clk_src =
12583a83e4e6SRoman Li 		kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
12593a83e4e6SRoman Li 
12603a83e4e6SRoman Li 	if (!clk_src)
12613a83e4e6SRoman Li 		return NULL;
12623a83e4e6SRoman Li 
12633a83e4e6SRoman Li 	if (dcn301_clk_src_construct(clk_src, ctx, bios, id,
12643a83e4e6SRoman Li 			regs, &cs_shift, &cs_mask)) {
12653a83e4e6SRoman Li 		clk_src->base.dp_clk_src = dp_clk_src;
12663a83e4e6SRoman Li 		return &clk_src->base;
12673a83e4e6SRoman Li 	}
12683a83e4e6SRoman Li 
1269fcb4f919SLongJun Tang 	kfree(clk_src);
12703a83e4e6SRoman Li 	BREAK_TO_DEBUGGER();
12713a83e4e6SRoman Li 	return NULL;
12723a83e4e6SRoman Li }
12733a83e4e6SRoman Li 
12743a83e4e6SRoman Li static struct dc_cap_funcs cap_funcs = {
12753a83e4e6SRoman Li 	.get_dcc_compression_cap = dcn20_get_dcc_compression_cap
12763a83e4e6SRoman Li };
12773a83e4e6SRoman Li 
12783a83e4e6SRoman Li 
is_soc_bounding_box_valid(struct dc * dc)12793a83e4e6SRoman Li static bool is_soc_bounding_box_valid(struct dc *dc)
12803a83e4e6SRoman Li {
12813a83e4e6SRoman Li 	uint32_t hw_internal_rev = dc->ctx->asic_id.hw_internal_rev;
12823a83e4e6SRoman Li 
12833a83e4e6SRoman Li 	if (ASICREV_IS_VANGOGH(hw_internal_rev))
12843a83e4e6SRoman Li 		return true;
12853a83e4e6SRoman Li 
12863a83e4e6SRoman Li 	return false;
12873a83e4e6SRoman Li }
12883a83e4e6SRoman Li 
init_soc_bounding_box(struct dc * dc,struct dcn301_resource_pool * pool)12893a83e4e6SRoman Li static bool init_soc_bounding_box(struct dc *dc,
12903a83e4e6SRoman Li 				  struct dcn301_resource_pool *pool)
12913a83e4e6SRoman Li {
12923a83e4e6SRoman Li 	struct _vcs_dpi_soc_bounding_box_st *loaded_bb = &dcn3_01_soc;
12933a83e4e6SRoman Li 	struct _vcs_dpi_ip_params_st *loaded_ip = &dcn3_01_ip;
12943a83e4e6SRoman Li 
12953a83e4e6SRoman Li 	DC_LOGGER_INIT(dc->ctx->logger);
12963a83e4e6SRoman Li 
1297dbb7898aSNicholas Kazlauskas 	if (!is_soc_bounding_box_valid(dc)) {
129849da4c2bSJoe Perches 		DC_LOG_ERROR("%s: not valid soc bounding box\n", __func__);
12993a83e4e6SRoman Li 		return false;
13003a83e4e6SRoman Li 	}
13013a83e4e6SRoman Li 
13023a83e4e6SRoman Li 	loaded_ip->max_num_otg = pool->base.res_cap->num_timing_generator;
13033a83e4e6SRoman Li 	loaded_ip->max_num_dpp = pool->base.pipe_count;
130431484207SQingqing Zhuo 	DC_FP_START();
13053a83e4e6SRoman Li 	dcn20_patch_bounding_box(dc, loaded_bb);
130631484207SQingqing Zhuo 	DC_FP_END();
13073a83e4e6SRoman Li 
1308dbb7898aSNicholas Kazlauskas 	if (dc->ctx->dc_bios->funcs->get_soc_bb_info) {
13099a3e698cSYongqiang Sun 		struct bp_soc_bb_info bb_info = {0};
13109a3e698cSYongqiang Sun 
13119a3e698cSYongqiang Sun 		if (dc->ctx->dc_bios->funcs->get_soc_bb_info(dc->ctx->dc_bios, &bb_info) == BP_RESULT_OK) {
131231484207SQingqing Zhuo 			DC_FP_START();
131331484207SQingqing Zhuo 			dcn301_fpu_init_soc_bounding_box(bb_info);
131431484207SQingqing Zhuo 			DC_FP_END();
13159a3e698cSYongqiang Sun 		}
13169a3e698cSYongqiang Sun 	}
13179a3e698cSYongqiang Sun 
13183a83e4e6SRoman Li 	return true;
13193a83e4e6SRoman Li }
13203a83e4e6SRoman Li 
132131484207SQingqing Zhuo 
set_wm_ranges(struct pp_smu_funcs * pp_smu,struct _vcs_dpi_soc_bounding_box_st * loaded_bb)13223a83e4e6SRoman Li static void set_wm_ranges(
13233a83e4e6SRoman Li 		struct pp_smu_funcs *pp_smu,
13243a83e4e6SRoman Li 		struct _vcs_dpi_soc_bounding_box_st *loaded_bb)
13253a83e4e6SRoman Li {
13263a83e4e6SRoman Li 	struct pp_smu_wm_range_sets ranges = {0};
13273a83e4e6SRoman Li 	int i;
13283a83e4e6SRoman Li 
13293a83e4e6SRoman Li 	ranges.num_reader_wm_sets = 0;
13303a83e4e6SRoman Li 
13313a83e4e6SRoman Li 	if (loaded_bb->num_states == 1) {
13323a83e4e6SRoman Li 		ranges.reader_wm_sets[0].wm_inst = 0;
13333a83e4e6SRoman Li 		ranges.reader_wm_sets[0].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
13343a83e4e6SRoman Li 		ranges.reader_wm_sets[0].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
13353a83e4e6SRoman Li 		ranges.reader_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
13363a83e4e6SRoman Li 		ranges.reader_wm_sets[0].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
13373a83e4e6SRoman Li 
13383a83e4e6SRoman Li 		ranges.num_reader_wm_sets = 1;
13393a83e4e6SRoman Li 	} else if (loaded_bb->num_states > 1) {
13403a83e4e6SRoman Li 		for (i = 0; i < 4 && i < loaded_bb->num_states; i++) {
13413a83e4e6SRoman Li 			ranges.reader_wm_sets[i].wm_inst = i;
13423a83e4e6SRoman Li 			ranges.reader_wm_sets[i].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
13433a83e4e6SRoman Li 			ranges.reader_wm_sets[i].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
134431484207SQingqing Zhuo 			DC_FP_START();
134531484207SQingqing Zhuo 			dcn301_fpu_set_wm_ranges(i, &ranges, loaded_bb);
134631484207SQingqing Zhuo 			DC_FP_END();
13473a83e4e6SRoman Li 			ranges.num_reader_wm_sets = i + 1;
13483a83e4e6SRoman Li 		}
13493a83e4e6SRoman Li 
13503a83e4e6SRoman Li 		ranges.reader_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
13513a83e4e6SRoman Li 		ranges.reader_wm_sets[ranges.num_reader_wm_sets - 1].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
13523a83e4e6SRoman Li 	}
13533a83e4e6SRoman Li 
13543a83e4e6SRoman Li 	ranges.num_writer_wm_sets = 1;
13553a83e4e6SRoman Li 
13563a83e4e6SRoman Li 	ranges.writer_wm_sets[0].wm_inst = 0;
13573a83e4e6SRoman Li 	ranges.writer_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
13583a83e4e6SRoman Li 	ranges.writer_wm_sets[0].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
13593a83e4e6SRoman Li 	ranges.writer_wm_sets[0].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN;
13603a83e4e6SRoman Li 	ranges.writer_wm_sets[0].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX;
13613a83e4e6SRoman Li 
13623a83e4e6SRoman Li 	/* Notify PP Lib/SMU which Watermarks to use for which clock ranges */
13633a83e4e6SRoman Li 	pp_smu->nv_funcs.set_wm_ranges(&pp_smu->nv_funcs.pp_smu, &ranges);
13643a83e4e6SRoman Li }
13653a83e4e6SRoman Li 
dcn301_update_bw_bounding_box(struct dc * dc,struct clk_bw_params * bw_params)1366033656afSRodrigo Siqueira static void dcn301_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
13675e6d72c6SBas Nieuwenhuizen {
13685e6d72c6SBas Nieuwenhuizen 	DC_FP_START();
1369033656afSRodrigo Siqueira 	dcn301_fpu_update_bw_bounding_box(dc, bw_params);
1370033656afSRodrigo Siqueira 	DC_FP_END();
1371033656afSRodrigo Siqueira }
1372033656afSRodrigo Siqueira 
dcn301_calculate_wm_and_dlg(struct dc * dc,struct dc_state * context,display_e2e_pipe_params_st * pipes,int pipe_cnt,int vlevel_req)1373033656afSRodrigo Siqueira static void dcn301_calculate_wm_and_dlg(struct dc *dc,
1374033656afSRodrigo Siqueira 					struct dc_state *context,
1375033656afSRodrigo Siqueira 					display_e2e_pipe_params_st *pipes,
1376033656afSRodrigo Siqueira 					int pipe_cnt,
1377033656afSRodrigo Siqueira 					int vlevel_req)
1378033656afSRodrigo Siqueira {
1379033656afSRodrigo Siqueira 	DC_FP_START();
1380033656afSRodrigo Siqueira 	dcn301_fpu_calculate_wm_and_dlg(dc, context, pipes, pipe_cnt, vlevel_req);
13815e6d72c6SBas Nieuwenhuizen 	DC_FP_END();
13825e6d72c6SBas Nieuwenhuizen }
13835e6d72c6SBas Nieuwenhuizen 
13843a83e4e6SRoman Li static struct resource_funcs dcn301_res_pool_funcs = {
13853a83e4e6SRoman Li 	.destroy = dcn301_destroy_resource_pool,
13863a83e4e6SRoman Li 	.link_enc_create = dcn301_link_encoder_create,
13873a83e4e6SRoman Li 	.panel_cntl_create = dcn301_panel_cntl_create,
13883a83e4e6SRoman Li 	.validate_bandwidth = dcn30_validate_bandwidth,
1389808643eaSNikola Cornij 	.calculate_wm_and_dlg = dcn301_calculate_wm_and_dlg,
1390443dfba0SDmytro Laktyushkin 	.update_soc_for_wm_a = dcn30_update_soc_for_wm_a,
13913a83e4e6SRoman Li 	.populate_dml_pipes = dcn30_populate_dml_pipes_from_context,
1392198f0e89SWenjing Liu 	.acquire_free_pipe_as_secondary_dpp_pipe = dcn20_acquire_free_pipe_for_layer,
139321741810SWenjing Liu 	.release_pipe = dcn20_release_pipe,
13943a83e4e6SRoman Li 	.add_stream_to_ctx = dcn30_add_stream_to_ctx,
139572f6c427SNikola Cornij 	.add_dsc_to_stream_resource = dcn20_add_dsc_to_stream_resource,
13963a83e4e6SRoman Li 	.remove_stream_from_ctx = dcn20_remove_stream_from_ctx,
13973a83e4e6SRoman Li 	.populate_dml_writeback_from_context = dcn30_populate_dml_writeback_from_context,
13983a83e4e6SRoman Li 	.set_mcif_arb_params = dcn30_set_mcif_arb_params,
13993a83e4e6SRoman Li 	.find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link,
14003a83e4e6SRoman Li 	.acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut,
14013a83e4e6SRoman Li 	.release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut,
1402a1cbe691SSwapnil Patel 	.update_bw_bounding_box = dcn301_update_bw_bounding_box,
140363ab80d9SRafal Ostrowski 	.patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
140463ab80d9SRafal Ostrowski 	.get_vstartup_for_pipe = dcn10_get_vstartup_for_pipe
14053a83e4e6SRoman Li };
14063a83e4e6SRoman Li 
dcn301_resource_construct(uint8_t num_virtual_links,struct dc * dc,struct dcn301_resource_pool * pool)14073a83e4e6SRoman Li static bool dcn301_resource_construct(
14083a83e4e6SRoman Li 	uint8_t num_virtual_links,
14093a83e4e6SRoman Li 	struct dc *dc,
14103a83e4e6SRoman Li 	struct dcn301_resource_pool *pool)
14113a83e4e6SRoman Li {
14123a83e4e6SRoman Li 	int i, j;
14133a83e4e6SRoman Li 	struct dc_context *ctx = dc->ctx;
14143a83e4e6SRoman Li 	struct irq_service_init_data init_data;
14153a83e4e6SRoman Li 	uint32_t pipe_fuses = read_pipe_fuses(ctx);
14163a83e4e6SRoman Li 	uint32_t num_pipes = 0;
14173a83e4e6SRoman Li 
14183a83e4e6SRoman Li 	DC_LOGGER_INIT(dc->ctx->logger);
14193a83e4e6SRoman Li 
14203a83e4e6SRoman Li 	ctx->dc_bios->regs = &bios_regs;
14213a83e4e6SRoman Li 
1422fb579c42SPavle Kotarac 	if (dc->ctx->asic_id.chip_id == DEVICE_ID_VGH_1435)
1423fb579c42SPavle Kotarac 		res_cap_dcn301.num_pll = 2;
14243a83e4e6SRoman Li 	pool->base.res_cap = &res_cap_dcn301;
14253a83e4e6SRoman Li 
14263a83e4e6SRoman Li 	pool->base.funcs = &dcn301_res_pool_funcs;
14273a83e4e6SRoman Li 
14283a83e4e6SRoman Li 	/*************************************************
14293a83e4e6SRoman Li 	 *  Resource + asic cap harcoding                *
14303a83e4e6SRoman Li 	 *************************************************/
14313a83e4e6SRoman Li 	pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
14323a83e4e6SRoman Li 	pool->base.pipe_count = pool->base.res_cap->num_timing_generator;
14333a83e4e6SRoman Li 	pool->base.mpcc_count = pool->base.res_cap->num_timing_generator;
14343a83e4e6SRoman Li 	dc->caps.max_downscale_ratio = 600;
14353a83e4e6SRoman Li 	dc->caps.i2c_speed_in_khz = 100;
1436e97978e8SCharlene Liu 	dc->caps.i2c_speed_in_khz_hdcp = 5; /*1.4 w/a enabled by default*/
14373a83e4e6SRoman Li 	dc->caps.max_cursor_size = 256;
143806722b37SAshley Thomas 	dc->caps.min_horizontal_blanking_period = 80;
14393a83e4e6SRoman Li 	dc->caps.dmdata_alloc_size = 2048;
144024b9e4c1SJoshua Ashton 	dc->caps.max_slave_planes = 2;
144124b9e4c1SJoshua Ashton 	dc->caps.max_slave_yuv_planes = 2;
144224b9e4c1SJoshua Ashton 	dc->caps.max_slave_rgb_planes = 2;
14433a83e4e6SRoman Li 	dc->caps.is_apu = true;
14443a83e4e6SRoman Li 	dc->caps.post_blend_color_processing = true;
14453a83e4e6SRoman Li 	dc->caps.force_dp_tps4_for_cp2520 = true;
14463a83e4e6SRoman Li 	dc->caps.extended_aux_timeout_support = true;
14473a83e4e6SRoman Li 	dc->caps.dmcub_support = true;
14483a83e4e6SRoman Li 
14493a83e4e6SRoman Li 	/* Color pipeline capabilities */
14503a83e4e6SRoman Li 	dc->caps.color.dpp.dcn_arch = 1;
14513a83e4e6SRoman Li 	dc->caps.color.dpp.input_lut_shared = 0;
14523a83e4e6SRoman Li 	dc->caps.color.dpp.icsc = 1;
14533a83e4e6SRoman Li 	dc->caps.color.dpp.dgam_ram = 0; // must use gamma_corr
14543a83e4e6SRoman Li 	dc->caps.color.dpp.dgam_rom_caps.srgb = 1;
14553a83e4e6SRoman Li 	dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1;
14563a83e4e6SRoman Li 	dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 1;
14573a83e4e6SRoman Li 	dc->caps.color.dpp.dgam_rom_caps.pq = 1;
14583a83e4e6SRoman Li 	dc->caps.color.dpp.dgam_rom_caps.hlg = 1;
14593a83e4e6SRoman Li 	dc->caps.color.dpp.post_csc = 1;
14603a83e4e6SRoman Li 	dc->caps.color.dpp.gamma_corr = 1;
1461c6160900SJing Zhou 	dc->caps.color.dpp.dgam_rom_for_yuv = 0;
14623a83e4e6SRoman Li 
14633a83e4e6SRoman Li 	dc->caps.color.dpp.hw_3d_lut = 1;
14643a83e4e6SRoman Li 	dc->caps.color.dpp.ogam_ram = 1;
14653a83e4e6SRoman Li 	// no OGAM ROM on DCN301
14663a83e4e6SRoman Li 	dc->caps.color.dpp.ogam_rom_caps.srgb = 0;
14673a83e4e6SRoman Li 	dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0;
14683a83e4e6SRoman Li 	dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0;
14693a83e4e6SRoman Li 	dc->caps.color.dpp.ogam_rom_caps.pq = 0;
14703a83e4e6SRoman Li 	dc->caps.color.dpp.ogam_rom_caps.hlg = 0;
14713a83e4e6SRoman Li 	dc->caps.color.dpp.ocsc = 0;
14723a83e4e6SRoman Li 
14733a83e4e6SRoman Li 	dc->caps.color.mpc.gamut_remap = 1;
14743a83e4e6SRoman Li 	dc->caps.color.mpc.num_3dluts = pool->base.res_cap->num_mpc_3dlut; //2
14753a83e4e6SRoman Li 	dc->caps.color.mpc.ogam_ram = 1;
14763a83e4e6SRoman Li 	dc->caps.color.mpc.ogam_rom_caps.srgb = 0;
14773a83e4e6SRoman Li 	dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0;
14783a83e4e6SRoman Li 	dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0;
14793a83e4e6SRoman Li 	dc->caps.color.mpc.ogam_rom_caps.pq = 0;
14803a83e4e6SRoman Li 	dc->caps.color.mpc.ogam_rom_caps.hlg = 0;
14813a83e4e6SRoman Li 	dc->caps.color.mpc.ocsc = 1;
14823a83e4e6SRoman Li 
148339173f24SDavid Galiffi 	dc->caps.dp_hdmi21_pcon_support = true;
148439173f24SDavid Galiffi 
14852430be71SAngus Wang 	/* read VBIOS LTTPR caps */
14862430be71SAngus Wang 	if (ctx->dc_bios->funcs->get_lttpr_caps) {
14872430be71SAngus Wang 		enum bp_result bp_query_result;
14882430be71SAngus Wang 		uint8_t is_vbios_lttpr_enable = 0;
14892430be71SAngus Wang 
14902430be71SAngus Wang 		bp_query_result = ctx->dc_bios->funcs->get_lttpr_caps(ctx->dc_bios, &is_vbios_lttpr_enable);
14912430be71SAngus Wang 		dc->caps.vbios_lttpr_enable = (bp_query_result == BP_RESULT_OK) && !!is_vbios_lttpr_enable;
14922430be71SAngus Wang 	}
14932430be71SAngus Wang 
14942430be71SAngus Wang 	if (ctx->dc_bios->funcs->get_lttpr_interop) {
14952430be71SAngus Wang 		enum bp_result bp_query_result;
14962430be71SAngus Wang 		uint8_t is_vbios_interop_enabled = 0;
14972430be71SAngus Wang 
14982430be71SAngus Wang 		bp_query_result = ctx->dc_bios->funcs->get_lttpr_interop(ctx->dc_bios, &is_vbios_interop_enabled);
14992430be71SAngus Wang 		dc->caps.vbios_lttpr_aware = (bp_query_result == BP_RESULT_OK) && !!is_vbios_interop_enabled;
15002430be71SAngus Wang 	}
15012430be71SAngus Wang 
15023a83e4e6SRoman Li 	if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
15033a83e4e6SRoman Li 		dc->debug = debug_defaults_drv;
150425879d7bSQingqing Zhuo 
15053a83e4e6SRoman Li 	// Init the vm_helper
15063a83e4e6SRoman Li 	if (dc->vm_helper)
15073a83e4e6SRoman Li 		vm_helper_init(dc->vm_helper, 16);
15083a83e4e6SRoman Li 
15093a83e4e6SRoman Li 	/*************************************************
15103a83e4e6SRoman Li 	 *  Create resources                             *
15113a83e4e6SRoman Li 	 *************************************************/
15123a83e4e6SRoman Li 
15133a83e4e6SRoman Li 	/* Clock Sources for Pixel Clock*/
15143a83e4e6SRoman Li 	pool->base.clock_sources[DCN301_CLK_SRC_PLL0] =
15153a83e4e6SRoman Li 			dcn301_clock_source_create(ctx, ctx->dc_bios,
15163a83e4e6SRoman Li 				CLOCK_SOURCE_COMBO_PHY_PLL0,
15173a83e4e6SRoman Li 				&clk_src_regs[0], false);
15183a83e4e6SRoman Li 	pool->base.clock_sources[DCN301_CLK_SRC_PLL1] =
15193a83e4e6SRoman Li 			dcn301_clock_source_create(ctx, ctx->dc_bios,
15203a83e4e6SRoman Li 				CLOCK_SOURCE_COMBO_PHY_PLL1,
15213a83e4e6SRoman Li 				&clk_src_regs[1], false);
15223a83e4e6SRoman Li 	pool->base.clock_sources[DCN301_CLK_SRC_PLL2] =
15233a83e4e6SRoman Li 			dcn301_clock_source_create(ctx, ctx->dc_bios,
15243a83e4e6SRoman Li 				CLOCK_SOURCE_COMBO_PHY_PLL2,
15253a83e4e6SRoman Li 				&clk_src_regs[2], false);
15263a83e4e6SRoman Li 	pool->base.clock_sources[DCN301_CLK_SRC_PLL3] =
15273a83e4e6SRoman Li 			dcn301_clock_source_create(ctx, ctx->dc_bios,
15283a83e4e6SRoman Li 				CLOCK_SOURCE_COMBO_PHY_PLL3,
15293a83e4e6SRoman Li 				&clk_src_regs[3], false);
15303a83e4e6SRoman Li 
15313a83e4e6SRoman Li 	pool->base.clk_src_count = DCN301_CLK_SRC_TOTAL;
15323a83e4e6SRoman Li 
15333a83e4e6SRoman Li 	/* todo: not reuse phy_pll registers */
15343a83e4e6SRoman Li 	pool->base.dp_clock_source =
15353a83e4e6SRoman Li 			dcn301_clock_source_create(ctx, ctx->dc_bios,
15363a83e4e6SRoman Li 				CLOCK_SOURCE_ID_DP_DTO,
15373a83e4e6SRoman Li 				&clk_src_regs[0], true);
15383a83e4e6SRoman Li 
15393a83e4e6SRoman Li 	for (i = 0; i < pool->base.clk_src_count; i++) {
15403a83e4e6SRoman Li 		if (pool->base.clock_sources[i] == NULL) {
15413a83e4e6SRoman Li 			dm_error("DC: failed to create clock sources!\n");
15423a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
15433a83e4e6SRoman Li 			goto create_fail;
15443a83e4e6SRoman Li 		}
15453a83e4e6SRoman Li 	}
15463a83e4e6SRoman Li 
15473a83e4e6SRoman Li 	/* DCCG */
15483a83e4e6SRoman Li 	pool->base.dccg = dccg301_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask);
15493a83e4e6SRoman Li 	if (pool->base.dccg == NULL) {
15503a83e4e6SRoman Li 		dm_error("DC: failed to create dccg!\n");
15513a83e4e6SRoman Li 		BREAK_TO_DEBUGGER();
15523a83e4e6SRoman Li 		goto create_fail;
15533a83e4e6SRoman Li 	}
15543a83e4e6SRoman Li 
15553a83e4e6SRoman Li 	init_soc_bounding_box(dc, pool);
15569a3e698cSYongqiang Sun 
15573a83e4e6SRoman Li 	if (!dc->debug.disable_pplib_wm_range && pool->base.pp_smu->nv_funcs.set_wm_ranges)
15583a83e4e6SRoman Li 		set_wm_ranges(pool->base.pp_smu, &dcn3_01_soc);
15593a83e4e6SRoman Li 
15603a83e4e6SRoman Li 	num_pipes = dcn3_01_ip.max_num_dpp;
15613a83e4e6SRoman Li 
15623a83e4e6SRoman Li 	for (i = 0; i < dcn3_01_ip.max_num_dpp; i++)
15633a83e4e6SRoman Li 		if (pipe_fuses & 1 << i)
15643a83e4e6SRoman Li 			num_pipes--;
15653a83e4e6SRoman Li 	dcn3_01_ip.max_num_dpp = num_pipes;
15663a83e4e6SRoman Li 	dcn3_01_ip.max_num_otg = num_pipes;
15673a83e4e6SRoman Li 
15683a83e4e6SRoman Li 
15693a83e4e6SRoman Li 	dml_init_instance(&dc->dml, &dcn3_01_soc, &dcn3_01_ip, DML_PROJECT_DCN30);
15703a83e4e6SRoman Li 
15713a83e4e6SRoman Li 	/* IRQ */
15723a83e4e6SRoman Li 	init_data.ctx = dc->ctx;
15733a83e4e6SRoman Li 	pool->base.irqs = dal_irq_service_dcn30_create(&init_data);
15743a83e4e6SRoman Li 	if (!pool->base.irqs)
15753a83e4e6SRoman Li 		goto create_fail;
15763a83e4e6SRoman Li 
15773a83e4e6SRoman Li 	/* HUBBUB */
15783a83e4e6SRoman Li 	pool->base.hubbub = dcn301_hubbub_create(ctx);
15793a83e4e6SRoman Li 	if (pool->base.hubbub == NULL) {
15803a83e4e6SRoman Li 		BREAK_TO_DEBUGGER();
15813a83e4e6SRoman Li 		dm_error("DC: failed to create hubbub!\n");
15823a83e4e6SRoman Li 		goto create_fail;
15833a83e4e6SRoman Li 	}
15843a83e4e6SRoman Li 
15853a83e4e6SRoman Li 	j = 0;
15863a83e4e6SRoman Li 	/* HUBPs, DPPs, OPPs and TGs */
15873a83e4e6SRoman Li 	for (i = 0; i < pool->base.pipe_count; i++) {
15883a83e4e6SRoman Li 
15893a83e4e6SRoman Li 		/* if pipe is disabled, skip instance of HW pipe,
15903a83e4e6SRoman Li 		 * i.e, skip ASIC register instance
15913a83e4e6SRoman Li 		 */
15923a83e4e6SRoman Li 		if ((pipe_fuses & (1 << i)) != 0) {
15933a83e4e6SRoman Li 			DC_LOG_DEBUG("%s: fusing pipe %d\n", __func__, i);
15943a83e4e6SRoman Li 			continue;
15953a83e4e6SRoman Li 		}
15963a83e4e6SRoman Li 
15973a83e4e6SRoman Li 		pool->base.hubps[j] = dcn301_hubp_create(ctx, i);
15983a83e4e6SRoman Li 		if (pool->base.hubps[j] == NULL) {
15993a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
16003a83e4e6SRoman Li 			dm_error(
16013a83e4e6SRoman Li 				"DC: failed to create hubps!\n");
16023a83e4e6SRoman Li 			goto create_fail;
16033a83e4e6SRoman Li 		}
16043a83e4e6SRoman Li 
16053a83e4e6SRoman Li 		pool->base.dpps[j] = dcn301_dpp_create(ctx, i);
16063a83e4e6SRoman Li 		if (pool->base.dpps[j] == NULL) {
16073a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
16083a83e4e6SRoman Li 			dm_error(
16093a83e4e6SRoman Li 				"DC: failed to create dpps!\n");
16103a83e4e6SRoman Li 			goto create_fail;
16113a83e4e6SRoman Li 		}
16123a83e4e6SRoman Li 
16133a83e4e6SRoman Li 		pool->base.opps[j] = dcn301_opp_create(ctx, i);
16143a83e4e6SRoman Li 		if (pool->base.opps[j] == NULL) {
16153a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
16163a83e4e6SRoman Li 			dm_error(
16173a83e4e6SRoman Li 				"DC: failed to create output pixel processor!\n");
16183a83e4e6SRoman Li 			goto create_fail;
16193a83e4e6SRoman Li 		}
16203a83e4e6SRoman Li 
16213a83e4e6SRoman Li 		pool->base.timing_generators[j] = dcn301_timing_generator_create(ctx, i);
16223a83e4e6SRoman Li 		if (pool->base.timing_generators[j] == NULL) {
16233a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
16243a83e4e6SRoman Li 			dm_error("DC: failed to create tg!\n");
16253a83e4e6SRoman Li 			goto create_fail;
16263a83e4e6SRoman Li 		}
16273a83e4e6SRoman Li 		j++;
16283a83e4e6SRoman Li 	}
16293a83e4e6SRoman Li 	pool->base.timing_generator_count = j;
16303a83e4e6SRoman Li 	pool->base.pipe_count = j;
16313a83e4e6SRoman Li 	pool->base.mpcc_count = j;
16323a83e4e6SRoman Li 
16333a83e4e6SRoman Li 	/* ABM (or ABMs for NV2x) */
16343a83e4e6SRoman Li 	/* TODO: */
16353a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
1636f9dbefa8SHuang Rui 		pool->base.multiple_abms[i] = dmub_abm_create(ctx,
16373a83e4e6SRoman Li 				&abm_regs[i],
16383a83e4e6SRoman Li 				&abm_shift,
16393a83e4e6SRoman Li 				&abm_mask);
16403a83e4e6SRoman Li 		if (pool->base.multiple_abms[i] == NULL) {
16413a83e4e6SRoman Li 			dm_error("DC: failed to create abm for pipe %d!\n", i);
16423a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
16433a83e4e6SRoman Li 			goto create_fail;
16443a83e4e6SRoman Li 		}
16453a83e4e6SRoman Li 	}
16463a83e4e6SRoman Li 
16473a83e4e6SRoman Li 	/* MPC and DSC */
16483a83e4e6SRoman Li 	pool->base.mpc = dcn301_mpc_create(ctx, pool->base.mpcc_count, pool->base.res_cap->num_mpc_3dlut);
16493a83e4e6SRoman Li 	if (pool->base.mpc == NULL) {
16503a83e4e6SRoman Li 		BREAK_TO_DEBUGGER();
16513a83e4e6SRoman Li 		dm_error("DC: failed to create mpc!\n");
16523a83e4e6SRoman Li 		goto create_fail;
16533a83e4e6SRoman Li 	}
16543a83e4e6SRoman Li 
16553a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_dsc; i++) {
16563a83e4e6SRoman Li 		pool->base.dscs[i] = dcn301_dsc_create(ctx, i);
16573a83e4e6SRoman Li 		if (pool->base.dscs[i] == NULL) {
16583a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
16593a83e4e6SRoman Li 			dm_error("DC: failed to create display stream compressor %d!\n", i);
16603a83e4e6SRoman Li 			goto create_fail;
16613a83e4e6SRoman Li 		}
16623a83e4e6SRoman Li 	}
16633a83e4e6SRoman Li 
16643a83e4e6SRoman Li 	/* DWB and MMHUBBUB */
16653a83e4e6SRoman Li 	if (!dcn301_dwbc_create(ctx, &pool->base)) {
16663a83e4e6SRoman Li 		BREAK_TO_DEBUGGER();
16673a83e4e6SRoman Li 		dm_error("DC: failed to create dwbc!\n");
16683a83e4e6SRoman Li 		goto create_fail;
16693a83e4e6SRoman Li 	}
16703a83e4e6SRoman Li 
16713a83e4e6SRoman Li 	if (!dcn301_mmhubbub_create(ctx, &pool->base)) {
16723a83e4e6SRoman Li 		BREAK_TO_DEBUGGER();
16733a83e4e6SRoman Li 		dm_error("DC: failed to create mcif_wb!\n");
16743a83e4e6SRoman Li 		goto create_fail;
16753a83e4e6SRoman Li 	}
16763a83e4e6SRoman Li 
16773a83e4e6SRoman Li 	/* AUX and I2C */
16783a83e4e6SRoman Li 	for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
16793a83e4e6SRoman Li 		pool->base.engines[i] = dcn301_aux_engine_create(ctx, i);
16803a83e4e6SRoman Li 		if (pool->base.engines[i] == NULL) {
16813a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
16823a83e4e6SRoman Li 			dm_error(
16833a83e4e6SRoman Li 				"DC:failed to create aux engine!!\n");
16843a83e4e6SRoman Li 			goto create_fail;
16853a83e4e6SRoman Li 		}
16863a83e4e6SRoman Li 		pool->base.hw_i2cs[i] = dcn301_i2c_hw_create(ctx, i);
16873a83e4e6SRoman Li 		if (pool->base.hw_i2cs[i] == NULL) {
16883a83e4e6SRoman Li 			BREAK_TO_DEBUGGER();
16893a83e4e6SRoman Li 			dm_error(
16903a83e4e6SRoman Li 				"DC:failed to create hw i2c!!\n");
16913a83e4e6SRoman Li 			goto create_fail;
16923a83e4e6SRoman Li 		}
16933a83e4e6SRoman Li 		pool->base.sw_i2cs[i] = NULL;
16943a83e4e6SRoman Li 	}
16953a83e4e6SRoman Li 
16963a83e4e6SRoman Li 	/* Audio, Stream Encoders including HPO and virtual, MPC 3D LUTs */
16973a83e4e6SRoman Li 	if (!resource_construct(num_virtual_links, dc, &pool->base,
169825879d7bSQingqing Zhuo 			&res_create_funcs))
16993a83e4e6SRoman Li 		goto create_fail;
17003a83e4e6SRoman Li 
17013a83e4e6SRoman Li 	/* HW Sequencer and Plane caps */
17023a83e4e6SRoman Li 	dcn301_hw_sequencer_construct(dc);
17033a83e4e6SRoman Li 
17043a83e4e6SRoman Li 	dc->caps.max_planes =  pool->base.pipe_count;
17053a83e4e6SRoman Li 
17063a83e4e6SRoman Li 	for (i = 0; i < dc->caps.max_planes; ++i)
17073a83e4e6SRoman Li 		dc->caps.planes[i] = plane_cap;
17083a83e4e6SRoman Li 
1709*d7b618bcSDillon Varone 	dc->caps.max_odm_combine_factor = 4;
1710*d7b618bcSDillon Varone 
17113a83e4e6SRoman Li 	dc->cap_funcs = cap_funcs;
17123a83e4e6SRoman Li 
17133a83e4e6SRoman Li 	return true;
17143a83e4e6SRoman Li 
17153a83e4e6SRoman Li create_fail:
17163a83e4e6SRoman Li 
17173a83e4e6SRoman Li 	dcn301_destruct(pool);
17183a83e4e6SRoman Li 
17193a83e4e6SRoman Li 	return false;
17203a83e4e6SRoman Li }
17213a83e4e6SRoman Li 
dcn301_create_resource_pool(const struct dc_init_data * init_data,struct dc * dc)17223a83e4e6SRoman Li struct resource_pool *dcn301_create_resource_pool(
17233a83e4e6SRoman Li 		const struct dc_init_data *init_data,
17243a83e4e6SRoman Li 		struct dc *dc)
17253a83e4e6SRoman Li {
17263a83e4e6SRoman Li 	struct dcn301_resource_pool *pool =
17273a83e4e6SRoman Li 		kzalloc(sizeof(struct dcn301_resource_pool), GFP_KERNEL);
17283a83e4e6SRoman Li 
17293a83e4e6SRoman Li 	if (!pool)
17303a83e4e6SRoman Li 		return NULL;
17313a83e4e6SRoman Li 
17323a83e4e6SRoman Li 	if (dcn301_resource_construct(init_data->num_virtual_links, dc, pool))
17333a83e4e6SRoman Li 		return &pool->base;
17343a83e4e6SRoman Li 
17353a83e4e6SRoman Li 	BREAK_TO_DEBUGGER();
17363a83e4e6SRoman Li 	kfree(pool);
17373a83e4e6SRoman Li 	return NULL;
17383a83e4e6SRoman Li }
1739