1 /*
2 * Copyright 2016 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25 
26 #include "dm_services.h"
27 #include "dc.h"
28 
29 #include "dcn201_init.h"
30 #include "dml/dcn20/dcn20_fpu.h"
31 #include "resource.h"
32 #include "include/irq_service_interface.h"
33 #include "dcn201_resource.h"
34 
35 #include "dcn20/dcn20_resource.h"
36 
37 #include "dcn10/dcn10_hubp.h"
38 #include "dcn10/dcn10_ipp.h"
39 #include "dcn201_mpc.h"
40 #include "dcn201_hubp.h"
41 #include "irq/dcn201/irq_service_dcn201.h"
42 #include "dcn201/dcn201_dpp.h"
43 #include "dcn201/dcn201_hubbub.h"
44 #include "dcn201_dccg.h"
45 #include "dcn201_optc.h"
46 #include "dcn201_hwseq.h"
47 #include "dce110/dce110_hw_sequencer.h"
48 #include "dcn201_opp.h"
49 #include "dcn201/dcn201_link_encoder.h"
50 #include "dcn20/dcn20_stream_encoder.h"
51 #include "dce/dce_clock_source.h"
52 #include "dce/dce_audio.h"
53 #include "dce/dce_hwseq.h"
54 #include "virtual/virtual_stream_encoder.h"
55 #include "dce110/dce110_resource.h"
56 #include "dce/dce_aux.h"
57 #include "dce/dce_i2c.h"
58 #include "dcn201_hubbub.h"
59 #include "dcn10/dcn10_resource.h"
60 
61 #include "cyan_skillfish_ip_offset.h"
62 
63 #include "dcn/dcn_2_0_3_offset.h"
64 #include "dcn/dcn_2_0_3_sh_mask.h"
65 #include "dpcs/dpcs_2_0_3_offset.h"
66 #include "dpcs/dpcs_2_0_3_sh_mask.h"
67 
68 #include "mmhub/mmhub_2_0_0_offset.h"
69 #include "mmhub/mmhub_2_0_0_sh_mask.h"
70 #include "nbio/nbio_7_4_offset.h"
71 
72 #include "reg_helper.h"
73 
74 #define MIN_DISP_CLK_KHZ 100000
75 #define MIN_DPP_CLK_KHZ 100000
76 
77 static struct _vcs_dpi_ip_params_st dcn201_ip = {
78 	.gpuvm_enable = 0,
79 	.hostvm_enable = 0,
80 	.gpuvm_max_page_table_levels = 4,
81 	.hostvm_max_page_table_levels = 4,
82 	.hostvm_cached_page_table_levels = 0,
83 	.pte_group_size_bytes = 2048,
84 	.rob_buffer_size_kbytes = 168,
85 	.det_buffer_size_kbytes = 164,
86 	.dpte_buffer_size_in_pte_reqs_luma = 84,
87 	.pde_proc_buffer_size_64k_reqs = 48,
88 	.dpp_output_buffer_pixels = 2560,
89 	.opp_output_buffer_lines = 1,
90 	.pixel_chunk_size_kbytes = 8,
91 	.pte_chunk_size_kbytes = 2,
92 	.meta_chunk_size_kbytes = 2,
93 	.writeback_chunk_size_kbytes = 2,
94 	.line_buffer_size_bits = 789504,
95 	.is_line_buffer_bpp_fixed = 0,
96 	.line_buffer_fixed_bpp = 0,
97 	.dcc_supported = true,
98 	.max_line_buffer_lines = 12,
99 	.writeback_luma_buffer_size_kbytes = 12,
100 	.writeback_chroma_buffer_size_kbytes = 8,
101 	.writeback_chroma_line_buffer_width_pixels = 4,
102 	.writeback_max_hscl_ratio = 1,
103 	.writeback_max_vscl_ratio = 1,
104 	.writeback_min_hscl_ratio = 1,
105 	.writeback_min_vscl_ratio = 1,
106 	.writeback_max_hscl_taps = 12,
107 	.writeback_max_vscl_taps = 12,
108 	.writeback_line_buffer_luma_buffer_size = 0,
109 	.writeback_line_buffer_chroma_buffer_size = 9600,
110 	.cursor_buffer_size = 8,
111 	.cursor_chunk_size = 2,
112 	.max_num_otg = 2,
113 	.max_num_dpp = 4,
114 	.max_num_wb = 0,
115 	.max_dchub_pscl_bw_pix_per_clk = 4,
116 	.max_pscl_lb_bw_pix_per_clk = 2,
117 	.max_lb_vscl_bw_pix_per_clk = 4,
118 	.max_vscl_hscl_bw_pix_per_clk = 4,
119 	.max_hscl_ratio = 8,
120 	.max_vscl_ratio = 8,
121 	.hscl_mults = 4,
122 	.vscl_mults = 4,
123 	.max_hscl_taps = 8,
124 	.max_vscl_taps = 8,
125 	.dispclk_ramp_margin_percent = 1,
126 	.underscan_factor = 1.10,
127 	.min_vblank_lines = 30,
128 	.dppclk_delay_subtotal = 77,
129 	.dppclk_delay_scl_lb_only = 16,
130 	.dppclk_delay_scl = 50,
131 	.dppclk_delay_cnvc_formatter = 8,
132 	.dppclk_delay_cnvc_cursor = 6,
133 	.dispclk_delay_subtotal = 87,
134 	.dcfclk_cstate_latency = 10,
135 	.max_inter_dcn_tile_repeaters = 8,
136 	.number_of_cursors = 1,
137 };
138 
139 static struct _vcs_dpi_soc_bounding_box_st dcn201_soc = {
140 	.clock_limits = {
141 			{
142 				.state = 0,
143 				.dscclk_mhz = 400.0,
144 				.dcfclk_mhz = 1000.0,
145 				.fabricclk_mhz = 200.0,
146 				.dispclk_mhz = 300.0,
147 				.dppclk_mhz = 300.0,
148 				.phyclk_mhz = 810.0,
149 				.socclk_mhz = 1254.0,
150 				.dram_speed_mts = 2000.0,
151 			},
152 			{
153 				.state = 1,
154 				.dscclk_mhz = 400.0,
155 				.dcfclk_mhz = 1000.0,
156 				.fabricclk_mhz = 250.0,
157 				.dispclk_mhz = 1200.0,
158 				.dppclk_mhz = 1200.0,
159 				.phyclk_mhz = 810.0,
160 				.socclk_mhz = 1254.0,
161 				.dram_speed_mts = 3600.0,
162 			},
163 			{
164 				.state = 2,
165 				.dscclk_mhz = 400.0,
166 				.dcfclk_mhz = 1000.0,
167 				.fabricclk_mhz = 750.0,
168 				.dispclk_mhz = 1200.0,
169 				.dppclk_mhz = 1200.0,
170 				.phyclk_mhz = 810.0,
171 				.socclk_mhz = 1254.0,
172 				.dram_speed_mts = 6800.0,
173 			},
174 			{
175 				.state = 3,
176 				.dscclk_mhz = 400.0,
177 				.dcfclk_mhz = 1000.0,
178 				.fabricclk_mhz = 250.0,
179 				.dispclk_mhz = 1200.0,
180 				.dppclk_mhz = 1200.0,
181 				.phyclk_mhz = 810.0,
182 				.socclk_mhz = 1254.0,
183 				.dram_speed_mts = 14000.0,
184 			},
185 			{
186 				.state = 4,
187 				.dscclk_mhz = 400.0,
188 				.dcfclk_mhz = 1000.0,
189 				.fabricclk_mhz = 750.0,
190 				.dispclk_mhz = 1200.0,
191 				.dppclk_mhz = 1200.0,
192 				.phyclk_mhz = 810.0,
193 				.socclk_mhz = 1254.0,
194 				.dram_speed_mts = 14000.0,
195 			}
196 		},
197 	.num_states = 4,
198 	.sr_exit_time_us = 9.0,
199 	.sr_enter_plus_exit_time_us = 11.0,
200 	.urgent_latency_us = 4.0,
201 	.urgent_latency_pixel_data_only_us = 4.0,
202 	.urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
203 	.urgent_latency_vm_data_only_us = 4.0,
204 	.urgent_out_of_order_return_per_channel_pixel_only_bytes = 256,
205 	.urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 256,
206 	.urgent_out_of_order_return_per_channel_vm_only_bytes = 256,
207 	.pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 80.0,
208 	.pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 80.0,
209 	.pct_ideal_dram_sdp_bw_after_urgent_vm_only = 80.0,
210 	.max_avg_sdp_bw_use_normal_percent = 80.0,
211 	.max_avg_dram_bw_use_normal_percent = 69.0,
212 	.writeback_latency_us = 12.0,
213 	.ideal_dram_bw_after_urgent_percent = 80.0,
214 	.max_request_size_bytes = 256,
215 	.dram_channel_width_bytes = 2,
216 	.fabric_datapath_to_dcn_data_return_bytes = 64,
217 	.dcn_downspread_percent = 0.3,
218 	.downspread_percent = 0.3,
219 	.dram_page_open_time_ns = 50.0,
220 	.dram_rw_turnaround_time_ns = 17.5,
221 	.dram_return_buffer_per_channel_bytes = 8192,
222 	.round_trip_ping_latency_dcfclk_cycles = 128,
223 	.urgent_out_of_order_return_per_channel_bytes = 256,
224 	.channel_interleave_bytes = 256,
225 	.num_banks = 8,
226 	.num_chans = 16,
227 	.vmm_page_size_bytes = 4096,
228 	.dram_clock_change_latency_us = 250.0,
229 	.writeback_dram_clock_change_latency_us = 23.0,
230 	.return_bus_width_bytes = 64,
231 	.dispclk_dppclk_vco_speed_mhz = 3000,
232 	.use_urgent_burst_bw = 0,
233 };
234 
235 enum dcn20_clk_src_array_id {
236 	DCN20_CLK_SRC_PLL0,
237 	DCN20_CLK_SRC_PLL1,
238 	DCN20_CLK_SRC_TOTAL_DCN201
239 };
240 
241 /* begin *********************
242  * macros to expend register list macro defined in HW object header file */
243 
244 /* DCN */
245 
246 #undef BASE_INNER
247 #define BASE_INNER(seg) DMU_BASE__INST0_SEG ## seg
248 
249 #define BASE(seg) BASE_INNER(seg)
250 
251 #define SR(reg_name)\
252 		.reg_name = BASE(mm ## reg_name ## _BASE_IDX) +  \
253 					mm ## reg_name
254 
255 #define SRI(reg_name, block, id)\
256 	.reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
257 					mm ## block ## id ## _ ## reg_name
258 
259 #define SRIR(var_name, reg_name, block, id)\
260 	.var_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
261 					mm ## block ## id ## _ ## reg_name
262 
263 #define SRII(reg_name, block, id)\
264 	.reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
265 					mm ## block ## id ## _ ## reg_name
266 
267 #define SRI_IX(reg_name, block, id)\
268 	.reg_name = ix ## block ## id ## _ ## reg_name
269 
270 #define DCCG_SRII(reg_name, block, id)\
271 	.block ## _ ## reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
272 					mm ## block ## id ## _ ## reg_name
273 
274 #define VUPDATE_SRII(reg_name, block, id)\
275 	.reg_name[id] = BASE(mm ## reg_name ## _ ## block ## id ## _BASE_IDX) + \
276 					mm ## reg_name ## _ ## block ## id
277 
278 /* NBIO */
279 #define NBIO_BASE_INNER(seg) \
280 	NBIO_BASE__INST0_SEG ## seg
281 
282 #define NBIO_BASE(seg) \
283 	NBIO_BASE_INNER(seg)
284 
285 #define NBIO_SR(reg_name)\
286 		.reg_name = NBIO_BASE(mm ## reg_name ## _BASE_IDX) + \
287 					mm ## reg_name
288 
289 /* MMHUB */
290 #define MMHUB_BASE_INNER(seg) \
291 	MMHUB_BASE__INST0_SEG ## seg
292 
293 #define MMHUB_BASE(seg) \
294 	MMHUB_BASE_INNER(seg)
295 
296 #define MMHUB_SR(reg_name)\
297 		.reg_name = MMHUB_BASE(mmMM ## reg_name ## _BASE_IDX) + \
298 					mmMM ## reg_name
299 
300 static const struct bios_registers bios_regs = {
301 		NBIO_SR(BIOS_SCRATCH_3),
302 		NBIO_SR(BIOS_SCRATCH_6)
303 };
304 
305 #define clk_src_regs(index, pllid)\
306 [index] = {\
307 	CS_COMMON_REG_LIST_DCN201(index, pllid),\
308 }
309 
310 static const struct dce110_clk_src_regs clk_src_regs[] = {
311 	clk_src_regs(0, A),
312 	clk_src_regs(1, B)
313 };
314 
315 static const struct dce110_clk_src_shift cs_shift = {
316 		CS_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT)
317 };
318 
319 static const struct dce110_clk_src_mask cs_mask = {
320 		CS_COMMON_MASK_SH_LIST_DCN2_0(_MASK)
321 };
322 
323 #define audio_regs(id)\
324 [id] = {\
325 		AUD_COMMON_REG_LIST(id)\
326 }
327 
328 static const struct dce_audio_registers audio_regs[] = {
329 	audio_regs(0),
330 	audio_regs(1),
331 };
332 
333 #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
334 		SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\
335 		SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\
336 		AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)
337 
338 static const struct dce_audio_shift audio_shift = {
339 		DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT)
340 };
341 
342 static const struct dce_audio_mask audio_mask = {
343 		DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)
344 };
345 
346 #define stream_enc_regs(id)\
347 [id] = {\
348 	SE_DCN2_REG_LIST(id)\
349 }
350 
351 static const struct dcn10_stream_enc_registers stream_enc_regs[] = {
352 	stream_enc_regs(0),
353 	stream_enc_regs(1)
354 };
355 
356 static const struct dcn10_stream_encoder_shift se_shift = {
357 		SE_COMMON_MASK_SH_LIST_DCN20(__SHIFT)
358 };
359 
360 static const struct dcn10_stream_encoder_mask se_mask = {
361 		SE_COMMON_MASK_SH_LIST_DCN20(_MASK)
362 };
363 
364 static const struct dce110_aux_registers_shift aux_shift = {
365 	DCN_AUX_MASK_SH_LIST(__SHIFT)
366 };
367 
368 static const struct dce110_aux_registers_mask aux_mask = {
369 	DCN_AUX_MASK_SH_LIST(_MASK)
370 };
371 
372 #define aux_regs(id)\
373 [id] = {\
374 	DCN2_AUX_REG_LIST(id)\
375 }
376 
377 static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = {
378 		aux_regs(0),
379 		aux_regs(1),
380 };
381 
382 #define hpd_regs(id)\
383 [id] = {\
384 	HPD_REG_LIST(id)\
385 }
386 
387 static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {
388 		hpd_regs(0),
389 		hpd_regs(1),
390 };
391 
392 #define link_regs(id, phyid)\
393 [id] = {\
394 	LE_DCN_COMMON_REG_LIST(id), \
395 	UNIPHY_DCN2_REG_LIST(phyid) \
396 }
397 
398 static const struct dcn10_link_enc_registers link_enc_regs[] = {
399 	link_regs(0, A),
400 	link_regs(1, B),
401 };
402 
403 #define LINK_ENCODER_MASK_SH_LIST_DCN201(mask_sh)\
404 	LINK_ENCODER_MASK_SH_LIST_DCN20(mask_sh)
405 
406 static const struct dcn10_link_enc_shift le_shift = {
407 		LINK_ENCODER_MASK_SH_LIST_DCN201(__SHIFT)
408 };
409 
410 static const struct dcn10_link_enc_mask le_mask = {
411 		LINK_ENCODER_MASK_SH_LIST_DCN201(_MASK)
412 };
413 
414 #define ipp_regs(id)\
415 [id] = {\
416 		IPP_REG_LIST_DCN201(id),\
417 }
418 
419 static const struct dcn10_ipp_registers ipp_regs[] = {
420 	ipp_regs(0),
421 	ipp_regs(1),
422 	ipp_regs(2),
423 	ipp_regs(3),
424 };
425 
426 static const struct dcn10_ipp_shift ipp_shift = {
427 		IPP_MASK_SH_LIST_DCN201(__SHIFT)
428 };
429 
430 static const struct dcn10_ipp_mask ipp_mask = {
431 		IPP_MASK_SH_LIST_DCN201(_MASK)
432 };
433 
434 #define opp_regs(id)\
435 [id] = {\
436 	OPP_REG_LIST_DCN201(id),\
437 }
438 
439 static const struct dcn201_opp_registers opp_regs[] = {
440 	opp_regs(0),
441 	opp_regs(1),
442 };
443 
444 static const struct dcn201_opp_shift opp_shift = {
445 		OPP_MASK_SH_LIST_DCN201(__SHIFT)
446 };
447 
448 static const struct dcn201_opp_mask opp_mask = {
449 		OPP_MASK_SH_LIST_DCN201(_MASK)
450 };
451 
452 #define aux_engine_regs(id)\
453 [id] = {\
454 	AUX_COMMON_REG_LIST0(id), \
455 	.AUX_RESET_MASK = 0 \
456 }
457 
458 static const struct dce110_aux_registers aux_engine_regs[] = {
459 		aux_engine_regs(0),
460 		aux_engine_regs(1)
461 };
462 
463 #define tf_regs(id)\
464 [id] = {\
465 	TF_REG_LIST_DCN201(id),\
466 }
467 
468 static const struct dcn201_dpp_registers tf_regs[] = {
469 	tf_regs(0),
470 	tf_regs(1),
471 	tf_regs(2),
472 	tf_regs(3),
473 };
474 
475 static const struct dcn201_dpp_shift tf_shift = {
476 		TF_REG_LIST_SH_MASK_DCN201(__SHIFT)
477 };
478 
479 static const struct dcn201_dpp_mask tf_mask = {
480 		TF_REG_LIST_SH_MASK_DCN201(_MASK)
481 };
482 
483 static const struct dcn201_mpc_registers mpc_regs = {
484 		MPC_REG_LIST_DCN201(0),
485 		MPC_REG_LIST_DCN201(1),
486 		MPC_REG_LIST_DCN201(2),
487 		MPC_REG_LIST_DCN201(3),
488 		MPC_REG_LIST_DCN201(4),
489 		MPC_OUT_MUX_REG_LIST_DCN201(0),
490 		MPC_OUT_MUX_REG_LIST_DCN201(1),
491 };
492 
493 static const struct dcn201_mpc_shift mpc_shift = {
494 	MPC_COMMON_MASK_SH_LIST_DCN201(__SHIFT)
495 };
496 
497 static const struct dcn201_mpc_mask mpc_mask = {
498 	MPC_COMMON_MASK_SH_LIST_DCN201(_MASK)
499 };
500 
501 #define tg_regs_dcn201(id)\
502 [id] = {TG_COMMON_REG_LIST_DCN201(id)}
503 
504 static const struct dcn_optc_registers tg_regs[] = {
505 	tg_regs_dcn201(0),
506 	tg_regs_dcn201(1)
507 };
508 
509 static const struct dcn_optc_shift tg_shift = {
510 	TG_COMMON_MASK_SH_LIST_DCN201(__SHIFT)
511 };
512 
513 static const struct dcn_optc_mask tg_mask = {
514 	TG_COMMON_MASK_SH_LIST_DCN201(_MASK)
515 };
516 
517 #define hubp_regsDCN201(id)\
518 [id] = {\
519 	HUBP_REG_LIST_DCN201(id)\
520 }
521 
522 static const struct dcn201_hubp_registers hubp_regs[] = {
523 		hubp_regsDCN201(0),
524 		hubp_regsDCN201(1),
525 		hubp_regsDCN201(2),
526 		hubp_regsDCN201(3)
527 };
528 
529 static const struct dcn201_hubp_shift hubp_shift = {
530 		HUBP_MASK_SH_LIST_DCN201(__SHIFT)
531 };
532 
533 static const struct dcn201_hubp_mask hubp_mask = {
534 		HUBP_MASK_SH_LIST_DCN201(_MASK)
535 };
536 
537 static const struct dcn_hubbub_registers hubbub_reg = {
538 		HUBBUB_REG_LIST_DCN201(0)
539 };
540 
541 static const struct dcn_hubbub_shift hubbub_shift = {
542 		HUBBUB_MASK_SH_LIST_DCN201(__SHIFT)
543 };
544 
545 static const struct dcn_hubbub_mask hubbub_mask = {
546 		HUBBUB_MASK_SH_LIST_DCN201(_MASK)
547 };
548 
549 
550 static const struct dccg_registers dccg_regs = {
551 		DCCG_COMMON_REG_LIST_DCN_BASE()
552 };
553 
554 static const struct dccg_shift dccg_shift = {
555 		DCCG_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(__SHIFT)
556 };
557 
558 static const struct dccg_mask dccg_mask = {
559 		DCCG_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(_MASK)
560 };
561 
562 static const struct resource_caps res_cap_dnc201 = {
563 		.num_timing_generator = 2,
564 		.num_opp = 2,
565 		.num_video_plane = 4,
566 		.num_audio = 2,
567 		.num_stream_encoder = 2,
568 		.num_pll = 2,
569 		.num_ddc = 2,
570 };
571 
572 static const struct dc_plane_cap plane_cap = {
573 	.type = DC_PLANE_TYPE_DCN_UNIVERSAL,
574 	.per_pixel_alpha = true,
575 
576 	.pixel_format_support = {
577 			.argb8888 = true,
578 			.nv12 = false,
579 			.fp16 = true,
580 			.p010 = false,
581 	},
582 
583 	.max_upscale_factor = {
584 			.argb8888 = 16000,
585 			.nv12 = 16000,
586 			.fp16 = 1
587 	},
588 
589 	.max_downscale_factor = {
590 			.argb8888 = 250,
591 			.nv12 = 250,
592 			.fp16 = 250
593 	},
594 	64,
595 	64
596 };
597 
598 static const struct dc_debug_options debug_defaults_drv = {
599 		.disable_dmcu = true,
600 		.force_abm_enable = false,
601 		.timing_trace = false,
602 		.clock_trace = true,
603 		.disable_pplib_clock_request = true,
604 		.pipe_split_policy = MPC_SPLIT_DYNAMIC,
605 		.force_single_disp_pipe_split = false,
606 		.disable_dcc = DCC_ENABLE,
607 		.vsr_support = true,
608 		.performance_trace = false,
609 		.az_endpoint_mute_only = true,
610 		.max_downscale_src_width = 3840,
611 		.disable_pplib_wm_range = true,
612 		.scl_reset_length10 = true,
613 		.sanity_checks = false,
614 		.underflow_assert_delay_us = 0xFFFFFFFF,
615 		.enable_tri_buf = false,
616 };
617 
618 static void dcn201_dpp_destroy(struct dpp **dpp)
619 {
620 	kfree(TO_DCN201_DPP(*dpp));
621 	*dpp = NULL;
622 }
623 
624 static struct dpp *dcn201_dpp_create(
625 	struct dc_context *ctx,
626 	uint32_t inst)
627 {
628 	struct dcn201_dpp *dpp =
629 		kzalloc(sizeof(struct dcn201_dpp), GFP_ATOMIC);
630 
631 	if (!dpp)
632 		return NULL;
633 
634 	if (dpp201_construct(dpp, ctx, inst,
635 			&tf_regs[inst], &tf_shift, &tf_mask))
636 		return &dpp->base;
637 
638 	kfree(dpp);
639 	return NULL;
640 }
641 
642 static struct input_pixel_processor *dcn201_ipp_create(
643 	struct dc_context *ctx, uint32_t inst)
644 {
645 	struct dcn10_ipp *ipp =
646 		kzalloc(sizeof(struct dcn10_ipp), GFP_ATOMIC);
647 
648 	if (!ipp) {
649 		return NULL;
650 	}
651 
652 	dcn20_ipp_construct(ipp, ctx, inst,
653 			&ipp_regs[inst], &ipp_shift, &ipp_mask);
654 	return &ipp->base;
655 }
656 
657 
658 static struct output_pixel_processor *dcn201_opp_create(
659 	struct dc_context *ctx, uint32_t inst)
660 {
661 	struct dcn201_opp *opp =
662 		kzalloc(sizeof(struct dcn201_opp), GFP_ATOMIC);
663 
664 	if (!opp) {
665 		return NULL;
666 	}
667 
668 	dcn201_opp_construct(opp, ctx, inst,
669 			&opp_regs[inst], &opp_shift, &opp_mask);
670 	return &opp->base;
671 }
672 
673 static struct dce_aux *dcn201_aux_engine_create(struct dc_context *ctx,
674 						uint32_t inst)
675 {
676 	struct aux_engine_dce110 *aux_engine =
677 		kzalloc(sizeof(struct aux_engine_dce110), GFP_ATOMIC);
678 
679 	if (!aux_engine)
680 		return NULL;
681 
682 	dce110_aux_engine_construct(aux_engine, ctx, inst,
683 				    SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD,
684 				    &aux_engine_regs[inst],
685 					&aux_mask,
686 					&aux_shift,
687 					ctx->dc->caps.extended_aux_timeout_support);
688 
689 	return &aux_engine->base;
690 }
691 #define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) }
692 
693 static const struct dce_i2c_registers i2c_hw_regs[] = {
694 		i2c_inst_regs(1),
695 		i2c_inst_regs(2),
696 };
697 
698 static const struct dce_i2c_shift i2c_shifts = {
699 		I2C_COMMON_MASK_SH_LIST_DCN2(__SHIFT)
700 };
701 
702 static const struct dce_i2c_mask i2c_masks = {
703 		I2C_COMMON_MASK_SH_LIST_DCN2(_MASK)
704 };
705 
706 static struct dce_i2c_hw *dcn201_i2c_hw_create(struct dc_context *ctx,
707 					       uint32_t inst)
708 {
709 	struct dce_i2c_hw *dce_i2c_hw =
710 		kzalloc(sizeof(struct dce_i2c_hw), GFP_ATOMIC);
711 
712 	if (!dce_i2c_hw)
713 		return NULL;
714 
715 	dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst,
716 				    &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks);
717 
718 	return dce_i2c_hw;
719 }
720 
721 static struct mpc *dcn201_mpc_create(struct dc_context *ctx, uint32_t num_mpcc)
722 {
723 	struct dcn201_mpc *mpc201 = kzalloc(sizeof(struct dcn201_mpc),
724 					    GFP_ATOMIC);
725 
726 	if (!mpc201)
727 		return NULL;
728 
729 	dcn201_mpc_construct(mpc201, ctx,
730 			&mpc_regs,
731 			&mpc_shift,
732 			&mpc_mask,
733 			num_mpcc);
734 
735 	return &mpc201->base;
736 }
737 
738 static struct hubbub *dcn201_hubbub_create(struct dc_context *ctx)
739 {
740 	struct dcn20_hubbub *hubbub = kzalloc(sizeof(struct dcn20_hubbub),
741 					  GFP_ATOMIC);
742 
743 	if (!hubbub)
744 		return NULL;
745 
746 	hubbub201_construct(hubbub, ctx,
747 			&hubbub_reg,
748 			&hubbub_shift,
749 			&hubbub_mask);
750 
751 	return &hubbub->base;
752 }
753 
754 static struct timing_generator *dcn201_timing_generator_create(
755 		struct dc_context *ctx,
756 		uint32_t instance)
757 {
758 	struct optc *tgn10 =
759 		kzalloc(sizeof(struct optc), GFP_ATOMIC);
760 
761 	if (!tgn10)
762 		return NULL;
763 
764 	tgn10->base.inst = instance;
765 	tgn10->base.ctx = ctx;
766 
767 	tgn10->tg_regs = &tg_regs[instance];
768 	tgn10->tg_shift = &tg_shift;
769 	tgn10->tg_mask = &tg_mask;
770 
771 	dcn201_timing_generator_init(tgn10);
772 
773 	return &tgn10->base;
774 }
775 
776 static const struct encoder_feature_support link_enc_feature = {
777 		.max_hdmi_deep_color = COLOR_DEPTH_121212,
778 		.max_hdmi_pixel_clock = 600000,
779 		.hdmi_ycbcr420_supported = true,
780 		.dp_ycbcr420_supported = true,
781 		.fec_supported = true,
782 		.flags.bits.IS_HBR2_CAPABLE = true,
783 		.flags.bits.IS_HBR3_CAPABLE = true,
784 		.flags.bits.IS_TPS3_CAPABLE = true,
785 		.flags.bits.IS_TPS4_CAPABLE = true
786 };
787 
788 static struct link_encoder *dcn201_link_encoder_create(
789 	struct dc_context *ctx,
790 	const struct encoder_init_data *enc_init_data)
791 {
792 	struct dcn20_link_encoder *enc20 =
793 		kzalloc(sizeof(struct dcn20_link_encoder), GFP_ATOMIC);
794 	struct dcn10_link_encoder *enc10 = &enc20->enc10;
795 
796 	if (!enc20)
797 		return NULL;
798 
799 	dcn201_link_encoder_construct(enc20,
800 			enc_init_data,
801 			&link_enc_feature,
802 			&link_enc_regs[enc_init_data->transmitter],
803 			&link_enc_aux_regs[enc_init_data->channel - 1],
804 			&link_enc_hpd_regs[enc_init_data->hpd_source],
805 			&le_shift,
806 			&le_mask);
807 
808 	return &enc10->base;
809 }
810 
811 static struct clock_source *dcn201_clock_source_create(
812 	struct dc_context *ctx,
813 	struct dc_bios *bios,
814 	enum clock_source_id id,
815 	const struct dce110_clk_src_regs *regs,
816 	bool dp_clk_src)
817 {
818 	struct dce110_clk_src *clk_src =
819 		kzalloc(sizeof(struct dce110_clk_src), GFP_ATOMIC);
820 
821 	if (!clk_src)
822 		return NULL;
823 
824 	if (dce112_clk_src_construct(clk_src, ctx, bios, id,
825 			regs, &cs_shift, &cs_mask)) {
826 		clk_src->base.dp_clk_src = dp_clk_src;
827 		return &clk_src->base;
828 	}
829 	kfree(clk_src);
830 	return NULL;
831 }
832 
833 static void read_dce_straps(
834 	struct dc_context *ctx,
835 	struct resource_straps *straps)
836 {
837 	generic_reg_get(ctx, mmDC_PINSTRAPS + BASE(mmDC_PINSTRAPS_BASE_IDX),
838 
839 		FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio);
840 }
841 
842 static struct audio *dcn201_create_audio(
843 		struct dc_context *ctx, unsigned int inst)
844 {
845 	return dce_audio_create(ctx, inst,
846 			&audio_regs[inst], &audio_shift, &audio_mask);
847 }
848 
849 static struct stream_encoder *dcn201_stream_encoder_create(
850 	enum engine_id eng_id,
851 	struct dc_context *ctx)
852 {
853 	struct dcn10_stream_encoder *enc1 =
854 		kzalloc(sizeof(struct dcn10_stream_encoder), GFP_ATOMIC);
855 
856 	if (!enc1)
857 		return NULL;
858 
859 	dcn20_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id,
860 					&stream_enc_regs[eng_id],
861 					&se_shift, &se_mask);
862 
863 	return &enc1->base;
864 }
865 
866 static const struct dce_hwseq_registers hwseq_reg = {
867 		HWSEQ_DCN201_REG_LIST()
868 };
869 
870 static const struct dce_hwseq_shift hwseq_shift = {
871 		HWSEQ_DCN201_MASK_SH_LIST(__SHIFT)
872 };
873 
874 static const struct dce_hwseq_mask hwseq_mask = {
875 		HWSEQ_DCN201_MASK_SH_LIST(_MASK)
876 };
877 
878 static struct dce_hwseq *dcn201_hwseq_create(
879 	struct dc_context *ctx)
880 {
881 	struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_ATOMIC);
882 
883 	if (hws) {
884 		hws->ctx = ctx;
885 		hws->regs = &hwseq_reg;
886 		hws->shifts = &hwseq_shift;
887 		hws->masks = &hwseq_mask;
888 	}
889 	return hws;
890 }
891 
892 static const struct resource_create_funcs res_create_funcs = {
893 	.read_dce_straps = read_dce_straps,
894 	.create_audio = dcn201_create_audio,
895 	.create_stream_encoder = dcn201_stream_encoder_create,
896 	.create_hwseq = dcn201_hwseq_create,
897 };
898 
899 static const struct resource_create_funcs res_create_maximus_funcs = {
900 	.read_dce_straps = NULL,
901 	.create_audio = NULL,
902 	.create_stream_encoder = NULL,
903 	.create_hwseq = dcn201_hwseq_create,
904 };
905 
906 static void dcn201_clock_source_destroy(struct clock_source **clk_src)
907 {
908 	kfree(TO_DCE110_CLK_SRC(*clk_src));
909 	*clk_src = NULL;
910 }
911 
912 static void dcn201_resource_destruct(struct dcn201_resource_pool *pool)
913 {
914 	unsigned int i;
915 
916 	for (i = 0; i < pool->base.stream_enc_count; i++) {
917 		if (pool->base.stream_enc[i] != NULL) {
918 			kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i]));
919 			pool->base.stream_enc[i] = NULL;
920 		}
921 	}
922 
923 
924 	if (pool->base.mpc != NULL) {
925 		kfree(TO_DCN201_MPC(pool->base.mpc));
926 		pool->base.mpc = NULL;
927 	}
928 
929 	if (pool->base.hubbub != NULL) {
930 		kfree(pool->base.hubbub);
931 		pool->base.hubbub = NULL;
932 	}
933 
934 	for (i = 0; i < pool->base.pipe_count; i++) {
935 		if (pool->base.dpps[i] != NULL)
936 			dcn201_dpp_destroy(&pool->base.dpps[i]);
937 
938 		if (pool->base.ipps[i] != NULL)
939 			pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]);
940 
941 		if (pool->base.hubps[i] != NULL) {
942 			kfree(TO_DCN10_HUBP(pool->base.hubps[i]));
943 			pool->base.hubps[i] = NULL;
944 		}
945 
946 		if (pool->base.irqs != NULL) {
947 			dal_irq_service_destroy(&pool->base.irqs);
948 		}
949 	}
950 
951 	for (i = 0; i < pool->base.res_cap->num_opp; i++) {
952 		if (pool->base.opps[i] != NULL)
953 			pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]);
954 	}
955 
956 	for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
957 		if (pool->base.timing_generators[i] != NULL)	{
958 			kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
959 			pool->base.timing_generators[i] = NULL;
960 		}
961 	}
962 	for (i = 0; i < pool->base.audio_count; i++) {
963 		if (pool->base.audios[i])
964 			dce_aud_destroy(&pool->base.audios[i]);
965 	}
966 
967 	for (i = 0; i < pool->base.clk_src_count; i++) {
968 		if (pool->base.clock_sources[i] != NULL) {
969 			dcn201_clock_source_destroy(&pool->base.clock_sources[i]);
970 			pool->base.clock_sources[i] = NULL;
971 		}
972 	}
973 
974 	if (pool->base.dp_clock_source != NULL) {
975 		dcn201_clock_source_destroy(&pool->base.dp_clock_source);
976 		pool->base.dp_clock_source = NULL;
977 	}
978 
979 	if (pool->base.dccg != NULL)
980 		dcn_dccg_destroy(&pool->base.dccg);
981 }
982 
983 static struct hubp *dcn201_hubp_create(
984 	struct dc_context *ctx,
985 	uint32_t inst)
986 {
987 	struct dcn201_hubp *hubp201 =
988 		kzalloc(sizeof(struct dcn201_hubp), GFP_ATOMIC);
989 
990 	if (!hubp201)
991 		return NULL;
992 
993 	if (dcn201_hubp_construct(hubp201, ctx, inst,
994 			&hubp_regs[inst], &hubp_shift, &hubp_mask))
995 		return &hubp201->base;
996 
997 	kfree(hubp201);
998 	return NULL;
999 }
1000 
1001 static struct pipe_ctx *dcn201_acquire_idle_pipe_for_layer(
1002 		struct dc_state *context,
1003 		const struct resource_pool *pool,
1004 		struct dc_stream_state *stream)
1005 {
1006 	struct resource_context *res_ctx = &context->res_ctx;
1007 	struct pipe_ctx *head_pipe = resource_get_head_pipe_for_stream(res_ctx, stream);
1008 	struct pipe_ctx *idle_pipe = find_idle_secondary_pipe(res_ctx, pool, head_pipe);
1009 
1010 	if (!head_pipe)
1011 		ASSERT(0);
1012 
1013 	if (!idle_pipe)
1014 		return NULL;
1015 
1016 	idle_pipe->stream = head_pipe->stream;
1017 	idle_pipe->stream_res.tg = head_pipe->stream_res.tg;
1018 	idle_pipe->stream_res.opp = head_pipe->stream_res.opp;
1019 
1020 	idle_pipe->plane_res.hubp = pool->hubps[idle_pipe->pipe_idx];
1021 	idle_pipe->plane_res.ipp = pool->ipps[idle_pipe->pipe_idx];
1022 	idle_pipe->plane_res.dpp = pool->dpps[idle_pipe->pipe_idx];
1023 	idle_pipe->plane_res.mpcc_inst = pool->dpps[idle_pipe->pipe_idx]->inst;
1024 
1025 	return idle_pipe;
1026 }
1027 
1028 static bool dcn201_get_dcc_compression_cap(const struct dc *dc,
1029 		const struct dc_dcc_surface_param *input,
1030 		struct dc_surface_dcc_cap *output)
1031 {
1032 	return dc->res_pool->hubbub->funcs->get_dcc_compression_cap(
1033 			dc->res_pool->hubbub,
1034 			input,
1035 			output);
1036 }
1037 
1038 static void dcn201_populate_dml_writeback_from_context(struct dc *dc,
1039 						       struct resource_context *res_ctx,
1040 						       display_e2e_pipe_params_st *pipes)
1041 {
1042 	DC_FP_START();
1043 	dcn201_populate_dml_writeback_from_context_fpu(dc, res_ctx, pipes);
1044 	DC_FP_END();
1045 }
1046 
1047 static void dcn201_destroy_resource_pool(struct resource_pool **pool)
1048 {
1049 	struct dcn201_resource_pool *dcn201_pool = TO_DCN201_RES_POOL(*pool);
1050 
1051 	dcn201_resource_destruct(dcn201_pool);
1052 	kfree(dcn201_pool);
1053 	*pool = NULL;
1054 }
1055 
1056 static void dcn201_link_init(struct dc_link *link)
1057 {
1058 	if (link->ctx->dc_bios->integrated_info)
1059 		link->dp_ss_off = !link->ctx->dc_bios->integrated_info->dp_ss_control;
1060 }
1061 
1062 static struct dc_cap_funcs cap_funcs = {
1063 	.get_dcc_compression_cap = dcn201_get_dcc_compression_cap,
1064 };
1065 
1066 static struct resource_funcs dcn201_res_pool_funcs = {
1067 	.link_init = dcn201_link_init,
1068 	.destroy = dcn201_destroy_resource_pool,
1069 	.link_enc_create = dcn201_link_encoder_create,
1070 	.panel_cntl_create = NULL,
1071 	.validate_bandwidth = dcn20_validate_bandwidth,
1072 	.populate_dml_pipes = dcn20_populate_dml_pipes_from_context,
1073 	.add_stream_to_ctx = dcn20_add_stream_to_ctx,
1074 	.add_dsc_to_stream_resource = NULL,
1075 	.remove_stream_from_ctx = dcn20_remove_stream_from_ctx,
1076 	.acquire_idle_pipe_for_layer = dcn201_acquire_idle_pipe_for_layer,
1077 	.populate_dml_writeback_from_context = dcn201_populate_dml_writeback_from_context,
1078 	.patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
1079 	.set_mcif_arb_params = dcn20_set_mcif_arb_params,
1080 	.find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link
1081 };
1082 
1083 static bool dcn201_resource_construct(
1084 	uint8_t num_virtual_links,
1085 	struct dc *dc,
1086 	struct dcn201_resource_pool *pool)
1087 {
1088 	int i;
1089 	struct dc_context *ctx = dc->ctx;
1090 
1091 	ctx->dc_bios->regs = &bios_regs;
1092 
1093 	pool->base.res_cap = &res_cap_dnc201;
1094 	pool->base.funcs = &dcn201_res_pool_funcs;
1095 
1096 	/*************************************************
1097 	 *  Resource + asic cap harcoding                *
1098 	 *************************************************/
1099 	pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
1100 
1101 	pool->base.pipe_count = 4;
1102 	pool->base.mpcc_count = 5;
1103 	dc->caps.max_downscale_ratio = 200;
1104 	dc->caps.i2c_speed_in_khz = 100;
1105 	dc->caps.i2c_speed_in_khz_hdcp = 5; /*1.5 w/a applied by default*/
1106 	dc->caps.max_cursor_size = 256;
1107 	dc->caps.min_horizontal_blanking_period = 80;
1108 	dc->caps.dmdata_alloc_size = 2048;
1109 
1110 	dc->caps.max_slave_planes = 1;
1111 	dc->caps.max_slave_yuv_planes = 1;
1112 	dc->caps.max_slave_rgb_planes = 1;
1113 	dc->caps.post_blend_color_processing = true;
1114 	dc->caps.force_dp_tps4_for_cp2520 = true;
1115 	dc->caps.extended_aux_timeout_support = true;
1116 
1117 	/* Color pipeline capabilities */
1118 	dc->caps.color.dpp.dcn_arch = 1;
1119 	dc->caps.color.dpp.input_lut_shared = 0;
1120 	dc->caps.color.dpp.icsc = 1;
1121 	dc->caps.color.dpp.dgam_ram = 1;
1122 	dc->caps.color.dpp.dgam_rom_caps.srgb = 1;
1123 	dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1;
1124 	dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 0;
1125 	dc->caps.color.dpp.dgam_rom_caps.pq = 0;
1126 	dc->caps.color.dpp.dgam_rom_caps.hlg = 0;
1127 	dc->caps.color.dpp.post_csc = 0;
1128 	dc->caps.color.dpp.gamma_corr = 0;
1129 	dc->caps.color.dpp.dgam_rom_for_yuv = 1;
1130 
1131 	dc->caps.color.dpp.hw_3d_lut = 1;
1132 	dc->caps.color.dpp.ogam_ram = 1;
1133 	// no OGAM ROM on DCN2
1134 	dc->caps.color.dpp.ogam_rom_caps.srgb = 0;
1135 	dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0;
1136 	dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0;
1137 	dc->caps.color.dpp.ogam_rom_caps.pq = 0;
1138 	dc->caps.color.dpp.ogam_rom_caps.hlg = 0;
1139 	dc->caps.color.dpp.ocsc = 0;
1140 
1141 	dc->caps.color.mpc.gamut_remap = 0;
1142 	dc->caps.color.mpc.num_3dluts = 0;
1143 	dc->caps.color.mpc.shared_3d_lut = 0;
1144 	dc->caps.color.mpc.ogam_ram = 1;
1145 	dc->caps.color.mpc.ogam_rom_caps.srgb = 0;
1146 	dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0;
1147 	dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0;
1148 	dc->caps.color.mpc.ogam_rom_caps.pq = 0;
1149 	dc->caps.color.mpc.ogam_rom_caps.hlg = 0;
1150 	dc->caps.color.mpc.ocsc = 1;
1151 
1152 	dc->debug = debug_defaults_drv;
1153 
1154 	/*a0 only, remove later*/
1155 	dc->work_arounds.no_connect_phy_config  = true;
1156 	dc->work_arounds.dedcn20_305_wa = true;
1157 	/*************************************************
1158 	 *  Create resources                             *
1159 	 *************************************************/
1160 
1161 	pool->base.clock_sources[DCN20_CLK_SRC_PLL0] =
1162 			dcn201_clock_source_create(ctx, ctx->dc_bios,
1163 				CLOCK_SOURCE_COMBO_PHY_PLL0,
1164 				&clk_src_regs[0], false);
1165 	pool->base.clock_sources[DCN20_CLK_SRC_PLL1] =
1166 			dcn201_clock_source_create(ctx, ctx->dc_bios,
1167 				CLOCK_SOURCE_COMBO_PHY_PLL1,
1168 				&clk_src_regs[1], false);
1169 
1170 	pool->base.clk_src_count = DCN20_CLK_SRC_TOTAL_DCN201;
1171 
1172 	/* todo: not reuse phy_pll registers */
1173 	pool->base.dp_clock_source =
1174 			dcn201_clock_source_create(ctx, ctx->dc_bios,
1175 				CLOCK_SOURCE_ID_DP_DTO,
1176 				&clk_src_regs[0], true);
1177 
1178 	for (i = 0; i < pool->base.clk_src_count; i++) {
1179 		if (pool->base.clock_sources[i] == NULL) {
1180 			dm_error("DC: failed to create clock sources!\n");
1181 			goto create_fail;
1182 		}
1183 	}
1184 
1185 	pool->base.dccg = dccg201_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask);
1186 	if (pool->base.dccg == NULL) {
1187 		dm_error("DC: failed to create dccg!\n");
1188 		goto create_fail;
1189 	}
1190 
1191 	dcn201_ip.max_num_otg = pool->base.res_cap->num_timing_generator;
1192 	dcn201_ip.max_num_dpp = pool->base.pipe_count;
1193 	dml_init_instance(&dc->dml, &dcn201_soc, &dcn201_ip, DML_PROJECT_DCN201);
1194 	{
1195 		struct irq_service_init_data init_data;
1196 		init_data.ctx = dc->ctx;
1197 		pool->base.irqs = dal_irq_service_dcn201_create(&init_data);
1198 		if (!pool->base.irqs)
1199 			goto create_fail;
1200 	}
1201 
1202 	/* mem input -> ipp -> dpp -> opp -> TG */
1203 	for (i = 0; i < pool->base.pipe_count; i++) {
1204 		pool->base.hubps[i] = dcn201_hubp_create(ctx, i);
1205 		if (pool->base.hubps[i] == NULL) {
1206 			dm_error(
1207 				"DC: failed to create memory input!\n");
1208 			goto create_fail;
1209 		}
1210 
1211 		pool->base.ipps[i] = dcn201_ipp_create(ctx, i);
1212 		if (pool->base.ipps[i] == NULL) {
1213 			dm_error(
1214 				"DC: failed to create input pixel processor!\n");
1215 			goto create_fail;
1216 		}
1217 
1218 		pool->base.dpps[i] = dcn201_dpp_create(ctx, i);
1219 		if (pool->base.dpps[i] == NULL) {
1220 			dm_error(
1221 				"DC: failed to create dpps!\n");
1222 			goto create_fail;
1223 		}
1224 	}
1225 
1226 	for (i = 0; i < pool->base.res_cap->num_opp; i++) {
1227 		pool->base.opps[i] = dcn201_opp_create(ctx, i);
1228 		if (pool->base.opps[i] == NULL) {
1229 			dm_error(
1230 				"DC: failed to create output pixel processor!\n");
1231 			goto create_fail;
1232 		}
1233 	}
1234 
1235 	for (i = 0; i < pool->base.res_cap->num_ddc; i++) {
1236 		pool->base.engines[i] = dcn201_aux_engine_create(ctx, i);
1237 		if (pool->base.engines[i] == NULL) {
1238 			dm_error(
1239 				"DC:failed to create aux engine!!\n");
1240 			goto create_fail;
1241 		}
1242 		pool->base.hw_i2cs[i] = dcn201_i2c_hw_create(ctx, i);
1243 		if (pool->base.hw_i2cs[i] == NULL) {
1244 			dm_error(
1245 				"DC:failed to create hw i2c!!\n");
1246 			goto create_fail;
1247 		}
1248 		pool->base.sw_i2cs[i] = NULL;
1249 	}
1250 
1251 	for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) {
1252 		pool->base.timing_generators[i] = dcn201_timing_generator_create(
1253 				ctx, i);
1254 		if (pool->base.timing_generators[i] == NULL) {
1255 			dm_error("DC: failed to create tg!\n");
1256 			goto create_fail;
1257 		}
1258 	}
1259 
1260 	pool->base.timing_generator_count = i;
1261 
1262 	pool->base.mpc = dcn201_mpc_create(ctx, pool->base.mpcc_count);
1263 	if (pool->base.mpc == NULL) {
1264 		dm_error("DC: failed to create mpc!\n");
1265 		goto create_fail;
1266 	}
1267 
1268 	pool->base.hubbub = dcn201_hubbub_create(ctx);
1269 	if (pool->base.hubbub == NULL) {
1270 		dm_error("DC: failed to create hubbub!\n");
1271 		goto create_fail;
1272 	}
1273 
1274 	if (!resource_construct(num_virtual_links, dc, &pool->base,
1275 			(!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ?
1276 			&res_create_funcs : &res_create_maximus_funcs)))
1277 			goto create_fail;
1278 
1279 	dcn201_hw_sequencer_construct(dc);
1280 
1281 	dc->caps.max_planes =  pool->base.pipe_count;
1282 
1283 	for (i = 0; i < dc->caps.max_planes; ++i)
1284 		dc->caps.planes[i] = plane_cap;
1285 
1286 	dc->cap_funcs = cap_funcs;
1287 
1288 	return true;
1289 
1290 create_fail:
1291 
1292 	dcn201_resource_destruct(pool);
1293 
1294 	return false;
1295 }
1296 
1297 struct resource_pool *dcn201_create_resource_pool(
1298 		const struct dc_init_data *init_data,
1299 		struct dc *dc)
1300 {
1301 	struct dcn201_resource_pool *pool =
1302 		kzalloc(sizeof(struct dcn201_resource_pool), GFP_ATOMIC);
1303 
1304 	if (!pool)
1305 		return NULL;
1306 
1307 	if (dcn201_resource_construct(init_data->num_virtual_links, dc, pool))
1308 		return &pool->base;
1309 
1310 	kfree(pool);
1311 	return NULL;
1312 }
1313