1 /*
2  * Copyright 2012-15 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 "dce/dce_8_0_d.h"
27 #include "dce/dce_8_0_sh_mask.h"
28 
29 #include "dm_services.h"
30 
31 #include "link_encoder.h"
32 #include "stream_encoder.h"
33 
34 #include "resource.h"
35 #include "include/irq_service_interface.h"
36 #include "irq/dce80/irq_service_dce80.h"
37 #include "dce110/dce110_timing_generator.h"
38 #include "dce110/dce110_resource.h"
39 #include "dce80/dce80_timing_generator.h"
40 #include "dce/dce_mem_input.h"
41 #include "dce/dce_link_encoder.h"
42 #include "dce/dce_stream_encoder.h"
43 #include "dce/dce_mem_input.h"
44 #include "dce/dce_ipp.h"
45 #include "dce/dce_transform.h"
46 #include "dce/dce_opp.h"
47 #include "dce/dce_clocks.h"
48 #include "dce/dce_clock_source.h"
49 #include "dce/dce_audio.h"
50 #include "dce/dce_hwseq.h"
51 #include "dce80/dce80_hw_sequencer.h"
52 #include "dce100/dce100_resource.h"
53 
54 #include "reg_helper.h"
55 
56 /* TODO remove this include */
57 
58 #ifndef mmMC_HUB_RDREQ_DMIF_LIMIT
59 #include "gmc/gmc_7_1_d.h"
60 #include "gmc/gmc_7_1_sh_mask.h"
61 #endif
62 
63 #ifndef mmDP_DPHY_INTERNAL_CTRL
64 #define mmDP_DPHY_INTERNAL_CTRL                         0x1CDE
65 #define mmDP0_DP_DPHY_INTERNAL_CTRL                     0x1CDE
66 #define mmDP1_DP_DPHY_INTERNAL_CTRL                     0x1FDE
67 #define mmDP2_DP_DPHY_INTERNAL_CTRL                     0x42DE
68 #define mmDP3_DP_DPHY_INTERNAL_CTRL                     0x45DE
69 #define mmDP4_DP_DPHY_INTERNAL_CTRL                     0x48DE
70 #define mmDP5_DP_DPHY_INTERNAL_CTRL                     0x4BDE
71 #define mmDP6_DP_DPHY_INTERNAL_CTRL                     0x4EDE
72 #endif
73 
74 
75 #ifndef mmBIOS_SCRATCH_2
76 	#define mmBIOS_SCRATCH_2 0x05CB
77 	#define mmBIOS_SCRATCH_6 0x05CF
78 #endif
79 
80 #ifndef mmDP_DPHY_FAST_TRAINING
81 	#define mmDP_DPHY_FAST_TRAINING                         0x1CCE
82 	#define mmDP0_DP_DPHY_FAST_TRAINING                     0x1CCE
83 	#define mmDP1_DP_DPHY_FAST_TRAINING                     0x1FCE
84 	#define mmDP2_DP_DPHY_FAST_TRAINING                     0x42CE
85 	#define mmDP3_DP_DPHY_FAST_TRAINING                     0x45CE
86 	#define mmDP4_DP_DPHY_FAST_TRAINING                     0x48CE
87 	#define mmDP5_DP_DPHY_FAST_TRAINING                     0x4BCE
88 	#define mmDP6_DP_DPHY_FAST_TRAINING                     0x4ECE
89 #endif
90 
91 
92 #ifndef mmHPD_DC_HPD_CONTROL
93 	#define mmHPD_DC_HPD_CONTROL                            0x189A
94 	#define mmHPD0_DC_HPD_CONTROL                           0x189A
95 	#define mmHPD1_DC_HPD_CONTROL                           0x18A2
96 	#define mmHPD2_DC_HPD_CONTROL                           0x18AA
97 	#define mmHPD3_DC_HPD_CONTROL                           0x18B2
98 	#define mmHPD4_DC_HPD_CONTROL                           0x18BA
99 	#define mmHPD5_DC_HPD_CONTROL                           0x18C2
100 #endif
101 
102 #define DCE11_DIG_FE_CNTL 0x4a00
103 #define DCE11_DIG_BE_CNTL 0x4a47
104 #define DCE11_DP_SEC 0x4ac3
105 
106 static const struct dce110_timing_generator_offsets dce80_tg_offsets[] = {
107 		{
108 			.crtc = (mmCRTC0_CRTC_CONTROL - mmCRTC_CONTROL),
109 			.dcp =  (mmGRPH_CONTROL - mmGRPH_CONTROL),
110 			.dmif = (mmDMIF_PG0_DPG_WATERMARK_MASK_CONTROL
111 					- mmDPG_WATERMARK_MASK_CONTROL),
112 		},
113 		{
114 			.crtc = (mmCRTC1_CRTC_CONTROL - mmCRTC_CONTROL),
115 			.dcp = (mmDCP1_GRPH_CONTROL - mmGRPH_CONTROL),
116 			.dmif = (mmDMIF_PG1_DPG_WATERMARK_MASK_CONTROL
117 					- mmDPG_WATERMARK_MASK_CONTROL),
118 		},
119 		{
120 			.crtc = (mmCRTC2_CRTC_CONTROL - mmCRTC_CONTROL),
121 			.dcp = (mmDCP2_GRPH_CONTROL - mmGRPH_CONTROL),
122 			.dmif = (mmDMIF_PG2_DPG_WATERMARK_MASK_CONTROL
123 					- mmDPG_WATERMARK_MASK_CONTROL),
124 		},
125 		{
126 			.crtc = (mmCRTC3_CRTC_CONTROL - mmCRTC_CONTROL),
127 			.dcp = (mmDCP3_GRPH_CONTROL - mmGRPH_CONTROL),
128 			.dmif = (mmDMIF_PG3_DPG_WATERMARK_MASK_CONTROL
129 					- mmDPG_WATERMARK_MASK_CONTROL),
130 		},
131 		{
132 			.crtc = (mmCRTC4_CRTC_CONTROL - mmCRTC_CONTROL),
133 			.dcp = (mmDCP4_GRPH_CONTROL - mmGRPH_CONTROL),
134 			.dmif = (mmDMIF_PG4_DPG_WATERMARK_MASK_CONTROL
135 					- mmDPG_WATERMARK_MASK_CONTROL),
136 		},
137 		{
138 			.crtc = (mmCRTC5_CRTC_CONTROL - mmCRTC_CONTROL),
139 			.dcp = (mmDCP5_GRPH_CONTROL - mmGRPH_CONTROL),
140 			.dmif = (mmDMIF_PG5_DPG_WATERMARK_MASK_CONTROL
141 					- mmDPG_WATERMARK_MASK_CONTROL),
142 		}
143 };
144 
145 /* set register offset */
146 #define SR(reg_name)\
147 	.reg_name = mm ## reg_name
148 
149 /* set register offset with instance */
150 #define SRI(reg_name, block, id)\
151 	.reg_name = mm ## block ## id ## _ ## reg_name
152 
153 
154 static const struct dce_disp_clk_registers disp_clk_regs = {
155 		CLK_COMMON_REG_LIST_DCE_BASE()
156 };
157 
158 static const struct dce_disp_clk_shift disp_clk_shift = {
159 		CLK_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(__SHIFT)
160 };
161 
162 static const struct dce_disp_clk_mask disp_clk_mask = {
163 		CLK_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(_MASK)
164 };
165 
166 #define ipp_regs(id)\
167 [id] = {\
168 		IPP_COMMON_REG_LIST_DCE_BASE(id)\
169 }
170 
171 static const struct dce_ipp_registers ipp_regs[] = {
172 		ipp_regs(0),
173 		ipp_regs(1),
174 		ipp_regs(2),
175 		ipp_regs(3),
176 		ipp_regs(4),
177 		ipp_regs(5)
178 };
179 
180 static const struct dce_ipp_shift ipp_shift = {
181 		IPP_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(__SHIFT)
182 };
183 
184 static const struct dce_ipp_mask ipp_mask = {
185 		IPP_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(_MASK)
186 };
187 
188 #define transform_regs(id)\
189 [id] = {\
190 		XFM_COMMON_REG_LIST_DCE80(id)\
191 }
192 
193 static const struct dce_transform_registers xfm_regs[] = {
194 		transform_regs(0),
195 		transform_regs(1),
196 		transform_regs(2),
197 		transform_regs(3),
198 		transform_regs(4),
199 		transform_regs(5)
200 };
201 
202 static const struct dce_transform_shift xfm_shift = {
203 		XFM_COMMON_MASK_SH_LIST_DCE80(__SHIFT)
204 };
205 
206 static const struct dce_transform_mask xfm_mask = {
207 		XFM_COMMON_MASK_SH_LIST_DCE80(_MASK)
208 };
209 
210 #define aux_regs(id)\
211 [id] = {\
212 	AUX_REG_LIST(id)\
213 }
214 
215 static const struct dce110_link_enc_aux_registers link_enc_aux_regs[] = {
216 	aux_regs(0),
217 	aux_regs(1),
218 	aux_regs(2),
219 	aux_regs(3),
220 	aux_regs(4),
221 	aux_regs(5)
222 };
223 
224 #define hpd_regs(id)\
225 [id] = {\
226 	HPD_REG_LIST(id)\
227 }
228 
229 static const struct dce110_link_enc_hpd_registers link_enc_hpd_regs[] = {
230 		hpd_regs(0),
231 		hpd_regs(1),
232 		hpd_regs(2),
233 		hpd_regs(3),
234 		hpd_regs(4),
235 		hpd_regs(5)
236 };
237 
238 #define link_regs(id)\
239 [id] = {\
240 	LE_DCE80_REG_LIST(id)\
241 }
242 
243 static const struct dce110_link_enc_registers link_enc_regs[] = {
244 	link_regs(0),
245 	link_regs(1),
246 	link_regs(2),
247 	link_regs(3),
248 	link_regs(4),
249 	link_regs(5),
250 	link_regs(6),
251 };
252 
253 #define stream_enc_regs(id)\
254 [id] = {\
255 	SE_COMMON_REG_LIST_DCE_BASE(id),\
256 	.AFMT_CNTL = 0,\
257 }
258 
259 static const struct dce110_stream_enc_registers stream_enc_regs[] = {
260 	stream_enc_regs(0),
261 	stream_enc_regs(1),
262 	stream_enc_regs(2),
263 	stream_enc_regs(3),
264 	stream_enc_regs(4),
265 	stream_enc_regs(5),
266 	stream_enc_regs(6)
267 };
268 
269 static const struct dce_stream_encoder_shift se_shift = {
270 		SE_COMMON_MASK_SH_LIST_DCE80_100(__SHIFT)
271 };
272 
273 static const struct dce_stream_encoder_mask se_mask = {
274 		SE_COMMON_MASK_SH_LIST_DCE80_100(_MASK)
275 };
276 
277 #define opp_regs(id)\
278 [id] = {\
279 	OPP_DCE_80_REG_LIST(id),\
280 }
281 
282 static const struct dce_opp_registers opp_regs[] = {
283 	opp_regs(0),
284 	opp_regs(1),
285 	opp_regs(2),
286 	opp_regs(3),
287 	opp_regs(4),
288 	opp_regs(5)
289 };
290 
291 static const struct dce_opp_shift opp_shift = {
292 	OPP_COMMON_MASK_SH_LIST_DCE_80(__SHIFT)
293 };
294 
295 static const struct dce_opp_mask opp_mask = {
296 	OPP_COMMON_MASK_SH_LIST_DCE_80(_MASK)
297 };
298 
299 #define audio_regs(id)\
300 [id] = {\
301 	AUD_COMMON_REG_LIST(id)\
302 }
303 
304 static const struct dce_audio_registers audio_regs[] = {
305 	audio_regs(0),
306 	audio_regs(1),
307 	audio_regs(2),
308 	audio_regs(3),
309 	audio_regs(4),
310 	audio_regs(5),
311 	audio_regs(6),
312 };
313 
314 static const struct dce_audio_shift audio_shift = {
315 		AUD_COMMON_MASK_SH_LIST(__SHIFT)
316 };
317 
318 static const struct dce_aduio_mask audio_mask = {
319 		AUD_COMMON_MASK_SH_LIST(_MASK)
320 };
321 
322 #define clk_src_regs(id)\
323 [id] = {\
324 	CS_COMMON_REG_LIST_DCE_80(id),\
325 }
326 
327 
328 static const struct dce110_clk_src_regs clk_src_regs[] = {
329 	clk_src_regs(0),
330 	clk_src_regs(1),
331 	clk_src_regs(2)
332 };
333 
334 static const struct dce110_clk_src_shift cs_shift = {
335 		CS_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(__SHIFT)
336 };
337 
338 static const struct dce110_clk_src_mask cs_mask = {
339 		CS_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(_MASK)
340 };
341 
342 static const struct bios_registers bios_regs = {
343 	.BIOS_SCRATCH_6 = mmBIOS_SCRATCH_6
344 };
345 
346 static const struct resource_caps res_cap = {
347 		.num_timing_generator = 6,
348 		.num_audio = 6,
349 		.num_stream_encoder = 6,
350 		.num_pll = 3,
351 };
352 
353 static const struct resource_caps res_cap_81 = {
354 		.num_timing_generator = 4,
355 		.num_audio = 7,
356 		.num_stream_encoder = 7,
357 		.num_pll = 3,
358 };
359 
360 static const struct resource_caps res_cap_83 = {
361 		.num_timing_generator = 2,
362 		.num_audio = 6,
363 		.num_stream_encoder = 6,
364 		.num_pll = 2,
365 };
366 
367 #define CTX  ctx
368 #define REG(reg) mm ## reg
369 
370 #ifndef mmCC_DC_HDMI_STRAPS
371 #define mmCC_DC_HDMI_STRAPS 0x1918
372 #define CC_DC_HDMI_STRAPS__HDMI_DISABLE_MASK 0x40
373 #define CC_DC_HDMI_STRAPS__HDMI_DISABLE__SHIFT 0x6
374 #define CC_DC_HDMI_STRAPS__AUDIO_STREAM_NUMBER_MASK 0x700
375 #define CC_DC_HDMI_STRAPS__AUDIO_STREAM_NUMBER__SHIFT 0x8
376 #endif
377 
378 static void read_dce_straps(
379 	struct dc_context *ctx,
380 	struct resource_straps *straps)
381 {
382 	REG_GET_2(CC_DC_HDMI_STRAPS,
383 			HDMI_DISABLE, &straps->hdmi_disable,
384 			AUDIO_STREAM_NUMBER, &straps->audio_stream_number);
385 
386 	REG_GET(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO, &straps->dc_pinstraps_audio);
387 }
388 
389 static struct audio *create_audio(
390 		struct dc_context *ctx, unsigned int inst)
391 {
392 	return dce_audio_create(ctx, inst,
393 			&audio_regs[inst], &audio_shift, &audio_mask);
394 }
395 
396 static struct timing_generator *dce80_timing_generator_create(
397 		struct dc_context *ctx,
398 		uint32_t instance,
399 		const struct dce110_timing_generator_offsets *offsets)
400 {
401 	struct dce110_timing_generator *tg110 =
402 		kzalloc(sizeof(struct dce110_timing_generator), GFP_KERNEL);
403 
404 	if (!tg110)
405 		return NULL;
406 
407 	dce80_timing_generator_construct(tg110, ctx, instance, offsets);
408 	return &tg110->base;
409 }
410 
411 static struct output_pixel_processor *dce80_opp_create(
412 	struct dc_context *ctx,
413 	uint32_t inst)
414 {
415 	struct dce110_opp *opp =
416 		kzalloc(sizeof(struct dce110_opp), GFP_KERNEL);
417 
418 	if (!opp)
419 		return NULL;
420 
421 	dce110_opp_construct(opp,
422 			     ctx, inst, &opp_regs[inst], &opp_shift, &opp_mask);
423 	return &opp->base;
424 }
425 
426 static struct stream_encoder *dce80_stream_encoder_create(
427 	enum engine_id eng_id,
428 	struct dc_context *ctx)
429 {
430 	struct dce110_stream_encoder *enc110 =
431 		kzalloc(sizeof(struct dce110_stream_encoder), GFP_KERNEL);
432 
433 	if (!enc110)
434 		return NULL;
435 
436 	dce110_stream_encoder_construct(enc110, ctx, ctx->dc_bios, eng_id,
437 					&stream_enc_regs[eng_id],
438 					&se_shift, &se_mask);
439 	return &enc110->base;
440 }
441 
442 #define SRII(reg_name, block, id)\
443 	.reg_name[id] = mm ## block ## id ## _ ## reg_name
444 
445 static const struct dce_hwseq_registers hwseq_reg = {
446 		HWSEQ_DCE8_REG_LIST()
447 };
448 
449 static const struct dce_hwseq_shift hwseq_shift = {
450 		HWSEQ_DCE8_MASK_SH_LIST(__SHIFT)
451 };
452 
453 static const struct dce_hwseq_mask hwseq_mask = {
454 		HWSEQ_DCE8_MASK_SH_LIST(_MASK)
455 };
456 
457 static struct dce_hwseq *dce80_hwseq_create(
458 	struct dc_context *ctx)
459 {
460 	struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
461 
462 	if (hws) {
463 		hws->ctx = ctx;
464 		hws->regs = &hwseq_reg;
465 		hws->shifts = &hwseq_shift;
466 		hws->masks = &hwseq_mask;
467 	}
468 	return hws;
469 }
470 
471 static const struct resource_create_funcs res_create_funcs = {
472 	.read_dce_straps = read_dce_straps,
473 	.create_audio = create_audio,
474 	.create_stream_encoder = dce80_stream_encoder_create,
475 	.create_hwseq = dce80_hwseq_create,
476 };
477 
478 #define mi_inst_regs(id) { \
479 	MI_DCE8_REG_LIST(id), \
480 	.MC_HUB_RDREQ_DMIF_LIMIT = mmMC_HUB_RDREQ_DMIF_LIMIT \
481 }
482 static const struct dce_mem_input_registers mi_regs[] = {
483 		mi_inst_regs(0),
484 		mi_inst_regs(1),
485 		mi_inst_regs(2),
486 		mi_inst_regs(3),
487 		mi_inst_regs(4),
488 		mi_inst_regs(5),
489 };
490 
491 static const struct dce_mem_input_shift mi_shifts = {
492 		MI_DCE8_MASK_SH_LIST(__SHIFT),
493 		.ENABLE = MC_HUB_RDREQ_DMIF_LIMIT__ENABLE__SHIFT
494 };
495 
496 static const struct dce_mem_input_mask mi_masks = {
497 		MI_DCE8_MASK_SH_LIST(_MASK),
498 		.ENABLE = MC_HUB_RDREQ_DMIF_LIMIT__ENABLE_MASK
499 };
500 
501 static struct mem_input *dce80_mem_input_create(
502 	struct dc_context *ctx,
503 	uint32_t inst)
504 {
505 	struct dce_mem_input *dce_mi = kzalloc(sizeof(struct dce_mem_input),
506 					       GFP_KERNEL);
507 
508 	if (!dce_mi) {
509 		BREAK_TO_DEBUGGER();
510 		return NULL;
511 	}
512 
513 	dce_mem_input_construct(dce_mi, ctx, inst, &mi_regs[inst], &mi_shifts, &mi_masks);
514 	dce_mi->wa.single_head_rdreq_dmif_limit = 2;
515 	return &dce_mi->base;
516 }
517 
518 static void dce80_transform_destroy(struct transform **xfm)
519 {
520 	kfree(TO_DCE_TRANSFORM(*xfm));
521 	*xfm = NULL;
522 }
523 
524 static struct transform *dce80_transform_create(
525 	struct dc_context *ctx,
526 	uint32_t inst)
527 {
528 	struct dce_transform *transform =
529 		kzalloc(sizeof(struct dce_transform), GFP_KERNEL);
530 
531 	if (!transform)
532 		return NULL;
533 
534 	dce_transform_construct(transform, ctx, inst,
535 				&xfm_regs[inst], &xfm_shift, &xfm_mask);
536 	transform->prescaler_on = false;
537 	return &transform->base;
538 }
539 
540 static const struct encoder_feature_support link_enc_feature = {
541 		.max_hdmi_deep_color = COLOR_DEPTH_121212,
542 		.max_hdmi_pixel_clock = 297000,
543 		.flags.bits.IS_HBR2_CAPABLE = true,
544 		.flags.bits.IS_TPS3_CAPABLE = true,
545 		.flags.bits.IS_YCBCR_CAPABLE = true
546 };
547 
548 struct link_encoder *dce80_link_encoder_create(
549 	const struct encoder_init_data *enc_init_data)
550 {
551 	struct dce110_link_encoder *enc110 =
552 		kzalloc(sizeof(struct dce110_link_encoder), GFP_KERNEL);
553 
554 	if (!enc110)
555 		return NULL;
556 
557 	dce110_link_encoder_construct(enc110,
558 				      enc_init_data,
559 				      &link_enc_feature,
560 				      &link_enc_regs[enc_init_data->transmitter],
561 				      &link_enc_aux_regs[enc_init_data->channel - 1],
562 				      &link_enc_hpd_regs[enc_init_data->hpd_source]);
563 	return &enc110->base;
564 }
565 
566 struct clock_source *dce80_clock_source_create(
567 	struct dc_context *ctx,
568 	struct dc_bios *bios,
569 	enum clock_source_id id,
570 	const struct dce110_clk_src_regs *regs,
571 	bool dp_clk_src)
572 {
573 	struct dce110_clk_src *clk_src =
574 		kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
575 
576 	if (!clk_src)
577 		return NULL;
578 
579 	if (dce110_clk_src_construct(clk_src, ctx, bios, id,
580 			regs, &cs_shift, &cs_mask)) {
581 		clk_src->base.dp_clk_src = dp_clk_src;
582 		return &clk_src->base;
583 	}
584 
585 	BREAK_TO_DEBUGGER();
586 	return NULL;
587 }
588 
589 void dce80_clock_source_destroy(struct clock_source **clk_src)
590 {
591 	kfree(TO_DCE110_CLK_SRC(*clk_src));
592 	*clk_src = NULL;
593 }
594 
595 static struct input_pixel_processor *dce80_ipp_create(
596 	struct dc_context *ctx, uint32_t inst)
597 {
598 	struct dce_ipp *ipp = kzalloc(sizeof(struct dce_ipp), GFP_KERNEL);
599 
600 	if (!ipp) {
601 		BREAK_TO_DEBUGGER();
602 		return NULL;
603 	}
604 
605 	dce_ipp_construct(ipp, ctx, inst,
606 			&ipp_regs[inst], &ipp_shift, &ipp_mask);
607 	return &ipp->base;
608 }
609 
610 static void destruct(struct dce110_resource_pool *pool)
611 {
612 	unsigned int i;
613 
614 	for (i = 0; i < pool->base.pipe_count; i++) {
615 		if (pool->base.opps[i] != NULL)
616 			dce110_opp_destroy(&pool->base.opps[i]);
617 
618 		if (pool->base.transforms[i] != NULL)
619 			dce80_transform_destroy(&pool->base.transforms[i]);
620 
621 		if (pool->base.ipps[i] != NULL)
622 			dce_ipp_destroy(&pool->base.ipps[i]);
623 
624 		if (pool->base.mis[i] != NULL) {
625 			kfree(TO_DCE_MEM_INPUT(pool->base.mis[i]));
626 			pool->base.mis[i] = NULL;
627 		}
628 
629 		if (pool->base.timing_generators[i] != NULL)	{
630 			kfree(DCE110TG_FROM_TG(pool->base.timing_generators[i]));
631 			pool->base.timing_generators[i] = NULL;
632 		}
633 	}
634 
635 	for (i = 0; i < pool->base.stream_enc_count; i++) {
636 		if (pool->base.stream_enc[i] != NULL)
637 			kfree(DCE110STRENC_FROM_STRENC(pool->base.stream_enc[i]));
638 	}
639 
640 	for (i = 0; i < pool->base.clk_src_count; i++) {
641 		if (pool->base.clock_sources[i] != NULL) {
642 			dce80_clock_source_destroy(&pool->base.clock_sources[i]);
643 		}
644 	}
645 
646 	if (pool->base.dp_clock_source != NULL)
647 		dce80_clock_source_destroy(&pool->base.dp_clock_source);
648 
649 	for (i = 0; i < pool->base.audio_count; i++)	{
650 		if (pool->base.audios[i] != NULL) {
651 			dce_aud_destroy(&pool->base.audios[i]);
652 		}
653 	}
654 
655 	if (pool->base.display_clock != NULL)
656 		dce_disp_clk_destroy(&pool->base.display_clock);
657 
658 	if (pool->base.irqs != NULL) {
659 		dal_irq_service_destroy(&pool->base.irqs);
660 	}
661 }
662 
663 static enum dc_status build_mapped_resource(
664 		const struct dc *dc,
665 		struct dc_state *context,
666 		struct dc_stream_state *stream)
667 {
668 	struct pipe_ctx *pipe_ctx = resource_get_head_pipe_for_stream(&context->res_ctx, stream);
669 
670 	if (!pipe_ctx)
671 		return DC_ERROR_UNEXPECTED;
672 
673 	dce110_resource_build_pipe_hw_param(pipe_ctx);
674 
675 	resource_build_info_frame(pipe_ctx);
676 
677 	return DC_OK;
678 }
679 
680 bool dce80_validate_bandwidth(
681 	struct dc *dc,
682 	struct dc_state *context)
683 {
684 	/* TODO implement when needed but for now hardcode max value*/
685 	context->bw.dce.dispclk_khz = 681000;
686 	context->bw.dce.yclk_khz = 250000 * MEMORY_TYPE_MULTIPLIER;
687 
688 	return true;
689 }
690 
691 static bool dce80_validate_surface_sets(
692 		struct dc_state *context)
693 {
694 	int i;
695 
696 	for (i = 0; i < context->stream_count; i++) {
697 		if (context->stream_status[i].plane_count == 0)
698 			continue;
699 
700 		if (context->stream_status[i].plane_count > 1)
701 			return false;
702 
703 		if (context->stream_status[i].plane_states[0]->format
704 				>= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN)
705 			return false;
706 	}
707 
708 	return true;
709 }
710 
711 enum dc_status dce80_validate_global(
712 		struct dc *dc,
713 		struct dc_state *context)
714 {
715 	if (!dce80_validate_surface_sets(context))
716 		return DC_FAIL_SURFACE_VALIDATE;
717 
718 	return DC_OK;
719 }
720 
721 enum dc_status dce80_validate_guaranteed(
722 		struct dc *dc,
723 		struct dc_stream_state *dc_stream,
724 		struct dc_state *context)
725 {
726 	enum dc_status result = DC_ERROR_UNEXPECTED;
727 
728 	context->streams[0] = dc_stream;
729 	dc_stream_retain(context->streams[0]);
730 	context->stream_count++;
731 
732 	result = resource_map_pool_resources(dc, context, dc_stream);
733 
734 	if (result == DC_OK)
735 		result = resource_map_clock_resources(dc, context, dc_stream);
736 
737 	if (result == DC_OK)
738 		result = build_mapped_resource(dc, context, dc_stream);
739 
740 	if (result == DC_OK) {
741 		validate_guaranteed_copy_streams(
742 				context, dc->caps.max_streams);
743 		result = resource_build_scaling_params_for_context(dc, context);
744 	}
745 
746 	if (result == DC_OK)
747 		result = dce80_validate_bandwidth(dc, context);
748 
749 	return result;
750 }
751 
752 static void dce80_destroy_resource_pool(struct resource_pool **pool)
753 {
754 	struct dce110_resource_pool *dce110_pool = TO_DCE110_RES_POOL(*pool);
755 
756 	destruct(dce110_pool);
757 	kfree(dce110_pool);
758 	*pool = NULL;
759 }
760 
761 static const struct resource_funcs dce80_res_pool_funcs = {
762 	.destroy = dce80_destroy_resource_pool,
763 	.link_enc_create = dce80_link_encoder_create,
764 	.validate_guaranteed = dce80_validate_guaranteed,
765 	.validate_bandwidth = dce80_validate_bandwidth,
766 	.validate_plane = dce100_validate_plane,
767 	.add_stream_to_ctx = dce100_add_stream_to_ctx,
768 	.validate_global = dce80_validate_global
769 };
770 
771 static bool dce80_construct(
772 	uint8_t num_virtual_links,
773 	struct dc *dc,
774 	struct dce110_resource_pool *pool)
775 {
776 	unsigned int i;
777 	struct dc_context *ctx = dc->ctx;
778 	struct dc_firmware_info info;
779 	struct dc_bios *bp;
780 	struct dm_pp_static_clock_info static_clk_info = {0};
781 
782 	ctx->dc_bios->regs = &bios_regs;
783 
784 	pool->base.res_cap = &res_cap;
785 	pool->base.funcs = &dce80_res_pool_funcs;
786 
787 
788 	/*************************************************
789 	 *  Resource + asic cap harcoding                *
790 	 *************************************************/
791 	pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
792 	pool->base.pipe_count = res_cap.num_timing_generator;
793 	dc->caps.max_downscale_ratio = 200;
794 	dc->caps.i2c_speed_in_khz = 40;
795 	dc->caps.max_cursor_size = 128;
796 
797 	/*************************************************
798 	 *  Create resources                             *
799 	 *************************************************/
800 
801 	bp = ctx->dc_bios;
802 
803 	if ((bp->funcs->get_firmware_info(bp, &info) == BP_RESULT_OK) &&
804 		info.external_clock_source_frequency_for_dp != 0) {
805 		pool->base.dp_clock_source =
806 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_EXTERNAL, NULL, true);
807 
808 		pool->base.clock_sources[0] =
809 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL0, &clk_src_regs[0], false);
810 		pool->base.clock_sources[1] =
811 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL1, &clk_src_regs[1], false);
812 		pool->base.clock_sources[2] =
813 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL2, &clk_src_regs[2], false);
814 		pool->base.clk_src_count = 3;
815 
816 	} else {
817 		pool->base.dp_clock_source =
818 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL0, &clk_src_regs[0], true);
819 
820 		pool->base.clock_sources[0] =
821 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL1, &clk_src_regs[1], false);
822 		pool->base.clock_sources[1] =
823 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL2, &clk_src_regs[2], false);
824 		pool->base.clk_src_count = 2;
825 	}
826 
827 	if (pool->base.dp_clock_source == NULL) {
828 		dm_error("DC: failed to create dp clock source!\n");
829 		BREAK_TO_DEBUGGER();
830 		goto res_create_fail;
831 	}
832 
833 	for (i = 0; i < pool->base.clk_src_count; i++) {
834 		if (pool->base.clock_sources[i] == NULL) {
835 			dm_error("DC: failed to create clock sources!\n");
836 			BREAK_TO_DEBUGGER();
837 			goto res_create_fail;
838 		}
839 	}
840 
841 	pool->base.display_clock = dce_disp_clk_create(ctx,
842 			&disp_clk_regs,
843 			&disp_clk_shift,
844 			&disp_clk_mask);
845 	if (pool->base.display_clock == NULL) {
846 		dm_error("DC: failed to create display clock!\n");
847 		BREAK_TO_DEBUGGER();
848 		goto res_create_fail;
849 	}
850 
851 
852 	if (dm_pp_get_static_clocks(ctx, &static_clk_info))
853 		pool->base.display_clock->max_clks_state =
854 					static_clk_info.max_clocks_state;
855 
856 	{
857 		struct irq_service_init_data init_data;
858 		init_data.ctx = dc->ctx;
859 		pool->base.irqs = dal_irq_service_dce80_create(&init_data);
860 		if (!pool->base.irqs)
861 			goto res_create_fail;
862 	}
863 
864 	for (i = 0; i < pool->base.pipe_count; i++) {
865 		pool->base.timing_generators[i] = dce80_timing_generator_create(
866 				ctx, i, &dce80_tg_offsets[i]);
867 		if (pool->base.timing_generators[i] == NULL) {
868 			BREAK_TO_DEBUGGER();
869 			dm_error("DC: failed to create tg!\n");
870 			goto res_create_fail;
871 		}
872 
873 		pool->base.mis[i] = dce80_mem_input_create(ctx, i);
874 		if (pool->base.mis[i] == NULL) {
875 			BREAK_TO_DEBUGGER();
876 			dm_error("DC: failed to create memory input!\n");
877 			goto res_create_fail;
878 		}
879 
880 		pool->base.ipps[i] = dce80_ipp_create(ctx, i);
881 		if (pool->base.ipps[i] == NULL) {
882 			BREAK_TO_DEBUGGER();
883 			dm_error("DC: failed to create input pixel processor!\n");
884 			goto res_create_fail;
885 		}
886 
887 		pool->base.transforms[i] = dce80_transform_create(ctx, i);
888 		if (pool->base.transforms[i] == NULL) {
889 			BREAK_TO_DEBUGGER();
890 			dm_error("DC: failed to create transform!\n");
891 			goto res_create_fail;
892 		}
893 
894 		pool->base.opps[i] = dce80_opp_create(ctx, i);
895 		if (pool->base.opps[i] == NULL) {
896 			BREAK_TO_DEBUGGER();
897 			dm_error("DC: failed to create output pixel processor!\n");
898 			goto res_create_fail;
899 		}
900 	}
901 
902 	dc->caps.max_planes =  pool->base.pipe_count;
903 
904 	if (!resource_construct(num_virtual_links, dc, &pool->base,
905 			&res_create_funcs))
906 		goto res_create_fail;
907 
908 	/* Create hardware sequencer */
909 	dce80_hw_sequencer_construct(dc);
910 
911 	return true;
912 
913 res_create_fail:
914 	destruct(pool);
915 	return false;
916 }
917 
918 struct resource_pool *dce80_create_resource_pool(
919 	uint8_t num_virtual_links,
920 	struct dc *dc)
921 {
922 	struct dce110_resource_pool *pool =
923 		kzalloc(sizeof(struct dce110_resource_pool), GFP_KERNEL);
924 
925 	if (!pool)
926 		return NULL;
927 
928 	if (dce80_construct(num_virtual_links, dc, pool))
929 		return &pool->base;
930 
931 	BREAK_TO_DEBUGGER();
932 	return NULL;
933 }
934 
935 static bool dce81_construct(
936 	uint8_t num_virtual_links,
937 	struct dc *dc,
938 	struct dce110_resource_pool *pool)
939 {
940 	unsigned int i;
941 	struct dc_context *ctx = dc->ctx;
942 	struct dc_firmware_info info;
943 	struct dc_bios *bp;
944 	struct dm_pp_static_clock_info static_clk_info = {0};
945 
946 	ctx->dc_bios->regs = &bios_regs;
947 
948 	pool->base.res_cap = &res_cap_81;
949 	pool->base.funcs = &dce80_res_pool_funcs;
950 
951 
952 	/*************************************************
953 	 *  Resource + asic cap harcoding                *
954 	 *************************************************/
955 	pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
956 	pool->base.pipe_count = res_cap_81.num_timing_generator;
957 	dc->caps.max_downscale_ratio = 200;
958 	dc->caps.i2c_speed_in_khz = 40;
959 	dc->caps.max_cursor_size = 128;
960 	dc->caps.is_apu = true;
961 
962 	/*************************************************
963 	 *  Create resources                             *
964 	 *************************************************/
965 
966 	bp = ctx->dc_bios;
967 
968 	if ((bp->funcs->get_firmware_info(bp, &info) == BP_RESULT_OK) &&
969 		info.external_clock_source_frequency_for_dp != 0) {
970 		pool->base.dp_clock_source =
971 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_EXTERNAL, NULL, true);
972 
973 		pool->base.clock_sources[0] =
974 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL0, &clk_src_regs[0], false);
975 		pool->base.clock_sources[1] =
976 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL1, &clk_src_regs[1], false);
977 		pool->base.clock_sources[2] =
978 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL2, &clk_src_regs[2], false);
979 		pool->base.clk_src_count = 3;
980 
981 	} else {
982 		pool->base.dp_clock_source =
983 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL0, &clk_src_regs[0], true);
984 
985 		pool->base.clock_sources[0] =
986 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL1, &clk_src_regs[1], false);
987 		pool->base.clock_sources[1] =
988 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL2, &clk_src_regs[2], false);
989 		pool->base.clk_src_count = 2;
990 	}
991 
992 	if (pool->base.dp_clock_source == NULL) {
993 		dm_error("DC: failed to create dp clock source!\n");
994 		BREAK_TO_DEBUGGER();
995 		goto res_create_fail;
996 	}
997 
998 	for (i = 0; i < pool->base.clk_src_count; i++) {
999 		if (pool->base.clock_sources[i] == NULL) {
1000 			dm_error("DC: failed to create clock sources!\n");
1001 			BREAK_TO_DEBUGGER();
1002 			goto res_create_fail;
1003 		}
1004 	}
1005 
1006 	pool->base.display_clock = dce_disp_clk_create(ctx,
1007 			&disp_clk_regs,
1008 			&disp_clk_shift,
1009 			&disp_clk_mask);
1010 	if (pool->base.display_clock == NULL) {
1011 		dm_error("DC: failed to create display clock!\n");
1012 		BREAK_TO_DEBUGGER();
1013 		goto res_create_fail;
1014 	}
1015 
1016 
1017 	if (dm_pp_get_static_clocks(ctx, &static_clk_info))
1018 		pool->base.display_clock->max_clks_state =
1019 					static_clk_info.max_clocks_state;
1020 
1021 	{
1022 		struct irq_service_init_data init_data;
1023 		init_data.ctx = dc->ctx;
1024 		pool->base.irqs = dal_irq_service_dce80_create(&init_data);
1025 		if (!pool->base.irqs)
1026 			goto res_create_fail;
1027 	}
1028 
1029 	for (i = 0; i < pool->base.pipe_count; i++) {
1030 		pool->base.timing_generators[i] = dce80_timing_generator_create(
1031 				ctx, i, &dce80_tg_offsets[i]);
1032 		if (pool->base.timing_generators[i] == NULL) {
1033 			BREAK_TO_DEBUGGER();
1034 			dm_error("DC: failed to create tg!\n");
1035 			goto res_create_fail;
1036 		}
1037 
1038 		pool->base.mis[i] = dce80_mem_input_create(ctx, i);
1039 		if (pool->base.mis[i] == NULL) {
1040 			BREAK_TO_DEBUGGER();
1041 			dm_error("DC: failed to create memory input!\n");
1042 			goto res_create_fail;
1043 		}
1044 
1045 		pool->base.ipps[i] = dce80_ipp_create(ctx, i);
1046 		if (pool->base.ipps[i] == NULL) {
1047 			BREAK_TO_DEBUGGER();
1048 			dm_error("DC: failed to create input pixel processor!\n");
1049 			goto res_create_fail;
1050 		}
1051 
1052 		pool->base.transforms[i] = dce80_transform_create(ctx, i);
1053 		if (pool->base.transforms[i] == NULL) {
1054 			BREAK_TO_DEBUGGER();
1055 			dm_error("DC: failed to create transform!\n");
1056 			goto res_create_fail;
1057 		}
1058 
1059 		pool->base.opps[i] = dce80_opp_create(ctx, i);
1060 		if (pool->base.opps[i] == NULL) {
1061 			BREAK_TO_DEBUGGER();
1062 			dm_error("DC: failed to create output pixel processor!\n");
1063 			goto res_create_fail;
1064 		}
1065 	}
1066 
1067 	dc->caps.max_planes =  pool->base.pipe_count;
1068 
1069 	if (!resource_construct(num_virtual_links, dc, &pool->base,
1070 			&res_create_funcs))
1071 		goto res_create_fail;
1072 
1073 	/* Create hardware sequencer */
1074 	dce80_hw_sequencer_construct(dc);
1075 
1076 	return true;
1077 
1078 res_create_fail:
1079 	destruct(pool);
1080 	return false;
1081 }
1082 
1083 struct resource_pool *dce81_create_resource_pool(
1084 	uint8_t num_virtual_links,
1085 	struct dc *dc)
1086 {
1087 	struct dce110_resource_pool *pool =
1088 		kzalloc(sizeof(struct dce110_resource_pool), GFP_KERNEL);
1089 
1090 	if (!pool)
1091 		return NULL;
1092 
1093 	if (dce81_construct(num_virtual_links, dc, pool))
1094 		return &pool->base;
1095 
1096 	BREAK_TO_DEBUGGER();
1097 	return NULL;
1098 }
1099 
1100 static bool dce83_construct(
1101 	uint8_t num_virtual_links,
1102 	struct dc *dc,
1103 	struct dce110_resource_pool *pool)
1104 {
1105 	unsigned int i;
1106 	struct dc_context *ctx = dc->ctx;
1107 	struct dc_firmware_info info;
1108 	struct dc_bios *bp;
1109 	struct dm_pp_static_clock_info static_clk_info = {0};
1110 
1111 	ctx->dc_bios->regs = &bios_regs;
1112 
1113 	pool->base.res_cap = &res_cap_83;
1114 	pool->base.funcs = &dce80_res_pool_funcs;
1115 
1116 
1117 	/*************************************************
1118 	 *  Resource + asic cap harcoding                *
1119 	 *************************************************/
1120 	pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
1121 	pool->base.pipe_count = res_cap_83.num_timing_generator;
1122 	dc->caps.max_downscale_ratio = 200;
1123 	dc->caps.i2c_speed_in_khz = 40;
1124 	dc->caps.max_cursor_size = 128;
1125 	dc->caps.is_apu = true;
1126 
1127 	/*************************************************
1128 	 *  Create resources                             *
1129 	 *************************************************/
1130 
1131 	bp = ctx->dc_bios;
1132 
1133 	if ((bp->funcs->get_firmware_info(bp, &info) == BP_RESULT_OK) &&
1134 		info.external_clock_source_frequency_for_dp != 0) {
1135 		pool->base.dp_clock_source =
1136 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_EXTERNAL, NULL, true);
1137 
1138 		pool->base.clock_sources[0] =
1139 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL1, &clk_src_regs[0], false);
1140 		pool->base.clock_sources[1] =
1141 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL2, &clk_src_regs[1], false);
1142 		pool->base.clk_src_count = 2;
1143 
1144 	} else {
1145 		pool->base.dp_clock_source =
1146 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL1, &clk_src_regs[0], true);
1147 
1148 		pool->base.clock_sources[0] =
1149 				dce80_clock_source_create(ctx, bp, CLOCK_SOURCE_ID_PLL2, &clk_src_regs[1], false);
1150 		pool->base.clk_src_count = 1;
1151 	}
1152 
1153 	if (pool->base.dp_clock_source == NULL) {
1154 		dm_error("DC: failed to create dp clock source!\n");
1155 		BREAK_TO_DEBUGGER();
1156 		goto res_create_fail;
1157 	}
1158 
1159 	for (i = 0; i < pool->base.clk_src_count; i++) {
1160 		if (pool->base.clock_sources[i] == NULL) {
1161 			dm_error("DC: failed to create clock sources!\n");
1162 			BREAK_TO_DEBUGGER();
1163 			goto res_create_fail;
1164 		}
1165 	}
1166 
1167 	pool->base.display_clock = dce_disp_clk_create(ctx,
1168 			&disp_clk_regs,
1169 			&disp_clk_shift,
1170 			&disp_clk_mask);
1171 	if (pool->base.display_clock == NULL) {
1172 		dm_error("DC: failed to create display clock!\n");
1173 		BREAK_TO_DEBUGGER();
1174 		goto res_create_fail;
1175 	}
1176 
1177 
1178 	if (dm_pp_get_static_clocks(ctx, &static_clk_info))
1179 		pool->base.display_clock->max_clks_state =
1180 					static_clk_info.max_clocks_state;
1181 
1182 	{
1183 		struct irq_service_init_data init_data;
1184 		init_data.ctx = dc->ctx;
1185 		pool->base.irqs = dal_irq_service_dce80_create(&init_data);
1186 		if (!pool->base.irqs)
1187 			goto res_create_fail;
1188 	}
1189 
1190 	for (i = 0; i < pool->base.pipe_count; i++) {
1191 		pool->base.timing_generators[i] = dce80_timing_generator_create(
1192 				ctx, i, &dce80_tg_offsets[i]);
1193 		if (pool->base.timing_generators[i] == NULL) {
1194 			BREAK_TO_DEBUGGER();
1195 			dm_error("DC: failed to create tg!\n");
1196 			goto res_create_fail;
1197 		}
1198 
1199 		pool->base.mis[i] = dce80_mem_input_create(ctx, i);
1200 		if (pool->base.mis[i] == NULL) {
1201 			BREAK_TO_DEBUGGER();
1202 			dm_error("DC: failed to create memory input!\n");
1203 			goto res_create_fail;
1204 		}
1205 
1206 		pool->base.ipps[i] = dce80_ipp_create(ctx, i);
1207 		if (pool->base.ipps[i] == NULL) {
1208 			BREAK_TO_DEBUGGER();
1209 			dm_error("DC: failed to create input pixel processor!\n");
1210 			goto res_create_fail;
1211 		}
1212 
1213 		pool->base.transforms[i] = dce80_transform_create(ctx, i);
1214 		if (pool->base.transforms[i] == NULL) {
1215 			BREAK_TO_DEBUGGER();
1216 			dm_error("DC: failed to create transform!\n");
1217 			goto res_create_fail;
1218 		}
1219 
1220 		pool->base.opps[i] = dce80_opp_create(ctx, i);
1221 		if (pool->base.opps[i] == NULL) {
1222 			BREAK_TO_DEBUGGER();
1223 			dm_error("DC: failed to create output pixel processor!\n");
1224 			goto res_create_fail;
1225 		}
1226 	}
1227 
1228 	dc->caps.max_planes =  pool->base.pipe_count;
1229 
1230 	if (!resource_construct(num_virtual_links, dc, &pool->base,
1231 			&res_create_funcs))
1232 		goto res_create_fail;
1233 
1234 	/* Create hardware sequencer */
1235 	dce80_hw_sequencer_construct(dc);
1236 
1237 	return true;
1238 
1239 res_create_fail:
1240 	destruct(pool);
1241 	return false;
1242 }
1243 
1244 struct resource_pool *dce83_create_resource_pool(
1245 	uint8_t num_virtual_links,
1246 	struct dc *dc)
1247 {
1248 	struct dce110_resource_pool *pool =
1249 		kzalloc(sizeof(struct dce110_resource_pool), GFP_KERNEL);
1250 
1251 	if (!pool)
1252 		return NULL;
1253 
1254 	if (dce83_construct(num_virtual_links, dc, pool))
1255 		return &pool->base;
1256 
1257 	BREAK_TO_DEBUGGER();
1258 	return NULL;
1259 }
1260