2 * Copyright 2012-15 Advanced Micro Devices, Inc.cls
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
27 #include "dm_services.h"
30 #include "stream_encoder.h"
32 #include "include/irq_service_interface.h"
33 #include "dce120_resource.h"
34 #include "dce112/dce112_resource.h"
36 #include "dce110/dce110_resource.h"
37 #include "../virtual/virtual_stream_encoder.h"
38 #include "dce120_timing_generator.h"
39 #include "irq/dce120/irq_service_dce120.h"
40 #include "dce/dce_opp.h"
41 #include "dce/dce_clock_source.h"
42 #include "dce/dce_clocks.h"
43 #include "dce/dce_ipp.h"
44 #include "dce/dce_mem_input.h"
46 #include "dce110/dce110_hw_sequencer.h"
47 #include "dce120/dce120_hw_sequencer.h"
48 #include "dce/dce_transform.h"
50 #include "dce/dce_audio.h"
51 #include "dce/dce_link_encoder.h"
52 #include "dce/dce_stream_encoder.h"
53 #include "dce/dce_hwseq.h"
54 #include "dce/dce_abm.h"
55 #include "dce/dce_dmcu.h"
57 #include "vega10/DC/dce_12_0_offset.h"
58 #include "vega10/DC/dce_12_0_sh_mask.h"
59 #include "vega10/soc15ip.h"
60 #include "vega10/NBIO/nbio_6_1_offset.h"
61 #include "reg_helper.h"
63 #include "dce100/dce100_resource.h"
65 #ifndef mmDP0_DP_DPHY_INTERNAL_CTRL
66 #define mmDP0_DP_DPHY_INTERNAL_CTRL 0x210f
67 #define mmDP0_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
68 #define mmDP1_DP_DPHY_INTERNAL_CTRL 0x220f
69 #define mmDP1_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
70 #define mmDP2_DP_DPHY_INTERNAL_CTRL 0x230f
71 #define mmDP2_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
72 #define mmDP3_DP_DPHY_INTERNAL_CTRL 0x240f
73 #define mmDP3_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
74 #define mmDP4_DP_DPHY_INTERNAL_CTRL 0x250f
75 #define mmDP4_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
76 #define mmDP5_DP_DPHY_INTERNAL_CTRL 0x260f
77 #define mmDP5_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
78 #define mmDP6_DP_DPHY_INTERNAL_CTRL 0x270f
79 #define mmDP6_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
82 enum dce120_clk_src_array_id
{
93 static const struct dce110_timing_generator_offsets dce120_tg_offsets
[] = {
95 .crtc
= (mmCRTC0_CRTC_CONTROL
- mmCRTC0_CRTC_CONTROL
),
98 .crtc
= (mmCRTC1_CRTC_CONTROL
- mmCRTC0_CRTC_CONTROL
),
101 .crtc
= (mmCRTC2_CRTC_CONTROL
- mmCRTC0_CRTC_CONTROL
),
104 .crtc
= (mmCRTC3_CRTC_CONTROL
- mmCRTC0_CRTC_CONTROL
),
107 .crtc
= (mmCRTC4_CRTC_CONTROL
- mmCRTC0_CRTC_CONTROL
),
110 .crtc
= (mmCRTC5_CRTC_CONTROL
- mmCRTC0_CRTC_CONTROL
),
114 /* begin *********************
115 * macros to expend register list macro defined in HW object header file */
117 #define BASE_INNER(seg) \
118 DCE_BASE__INST0_SEG ## seg
120 #define NBIO_BASE_INNER(seg) \
121 NBIF_BASE__INST0_SEG ## seg
123 #define NBIO_BASE(seg) \
126 /* compile time expand base address. */
130 #define SR(reg_name)\
131 .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
134 #define SRI(reg_name, block, id)\
135 .reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
136 mm ## block ## id ## _ ## reg_name
138 /* macros to expend register list macro defined in HW object header file
139 * end *********************/
142 static const struct dce_dmcu_registers dmcu_regs
= {
143 DMCU_DCE110_COMMON_REG_LIST()
146 static const struct dce_dmcu_shift dmcu_shift
= {
147 DMCU_MASK_SH_LIST_DCE110(__SHIFT
)
150 static const struct dce_dmcu_mask dmcu_mask
= {
151 DMCU_MASK_SH_LIST_DCE110(_MASK
)
154 static const struct dce_abm_registers abm_regs
= {
155 ABM_DCE110_COMMON_REG_LIST()
158 static const struct dce_abm_shift abm_shift
= {
159 ABM_MASK_SH_LIST_DCE110(__SHIFT
)
162 static const struct dce_abm_mask abm_mask
= {
163 ABM_MASK_SH_LIST_DCE110(_MASK
)
166 #define ipp_regs(id)\
168 IPP_DCE110_REG_LIST_DCE_BASE(id)\
171 static const struct dce_ipp_registers ipp_regs
[] = {
180 static const struct dce_ipp_shift ipp_shift
= {
181 IPP_DCE120_MASK_SH_LIST_SOC_BASE(__SHIFT
)
184 static const struct dce_ipp_mask ipp_mask
= {
185 IPP_DCE120_MASK_SH_LIST_SOC_BASE(_MASK
)
188 #define transform_regs(id)\
190 XFM_COMMON_REG_LIST_DCE110(id)\
193 static const struct dce_transform_registers xfm_regs
[] = {
202 static const struct dce_transform_shift xfm_shift
= {
203 XFM_COMMON_MASK_SH_LIST_SOC_BASE(__SHIFT
)
206 static const struct dce_transform_mask xfm_mask
= {
207 XFM_COMMON_MASK_SH_LIST_SOC_BASE(_MASK
)
210 #define aux_regs(id)\
215 static const struct dce110_link_enc_aux_registers link_enc_aux_regs
[] = {
224 #define hpd_regs(id)\
229 static const struct dce110_link_enc_hpd_registers link_enc_hpd_regs
[] = {
238 #define link_regs(id)\
240 LE_DCE120_REG_LIST(id), \
241 SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \
244 static const struct dce110_link_enc_registers link_enc_regs
[] = {
255 #define stream_enc_regs(id)\
257 SE_COMMON_REG_LIST(id),\
261 static const struct dce110_stream_enc_registers stream_enc_regs
[] = {
270 static const struct dce_stream_encoder_shift se_shift
= {
271 SE_COMMON_MASK_SH_LIST_DCE120(__SHIFT
)
274 static const struct dce_stream_encoder_mask se_mask
= {
275 SE_COMMON_MASK_SH_LIST_DCE120(_MASK
)
278 #define opp_regs(id)\
280 OPP_DCE_120_REG_LIST(id),\
283 static const struct dce_opp_registers opp_regs
[] = {
292 static const struct dce_opp_shift opp_shift
= {
293 OPP_COMMON_MASK_SH_LIST_DCE_120(__SHIFT
)
296 static const struct dce_opp_mask opp_mask
= {
297 OPP_COMMON_MASK_SH_LIST_DCE_120(_MASK
)
300 #define audio_regs(id)\
302 AUD_COMMON_REG_LIST(id)\
305 static struct dce_audio_registers audio_regs
[] = {
314 #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
315 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\
316 SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\
317 AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)
319 static const struct dce_audio_shift audio_shift
= {
320 DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT
)
323 static const struct dce_aduio_mask audio_mask
= {
324 DCE120_AUD_COMMON_MASK_SH_LIST(_MASK
)
327 #define clk_src_regs(index, id)\
329 CS_COMMON_REG_LIST_DCE_112(id),\
332 static const struct dce110_clk_src_regs clk_src_regs
[] = {
341 static const struct dce110_clk_src_shift cs_shift
= {
342 CS_COMMON_MASK_SH_LIST_DCE_112(__SHIFT
)
345 static const struct dce110_clk_src_mask cs_mask
= {
346 CS_COMMON_MASK_SH_LIST_DCE_112(_MASK
)
349 struct output_pixel_processor
*dce120_opp_create(
350 struct dc_context
*ctx
,
353 struct dce110_opp
*opp
=
354 kzalloc(sizeof(struct dce110_opp
), GFP_KERNEL
);
359 if (dce110_opp_construct(opp
,
360 ctx
, inst
, &opp_regs
[inst
], &opp_shift
, &opp_mask
))
368 static const struct bios_registers bios_regs
= {
369 .BIOS_SCRATCH_6
= mmBIOS_SCRATCH_6
+ NBIO_BASE(mmBIOS_SCRATCH_6_BASE_IDX
)
372 static const struct resource_caps res_cap
= {
373 .num_timing_generator
= 6,
375 .num_stream_encoder
= 6,
379 static const struct dc_debug debug_defaults
= {
380 .disable_clock_gate
= true,
383 struct clock_source
*dce120_clock_source_create(
384 struct dc_context
*ctx
,
385 struct dc_bios
*bios
,
386 enum clock_source_id id
,
387 const struct dce110_clk_src_regs
*regs
,
390 struct dce110_clk_src
*clk_src
=
391 kzalloc(sizeof(*clk_src
), GFP_KERNEL
);
396 if (dce110_clk_src_construct(clk_src
, ctx
, bios
, id
,
397 regs
, &cs_shift
, &cs_mask
)) {
398 clk_src
->base
.dp_clk_src
= dp_clk_src
;
399 return &clk_src
->base
;
406 void dce120_clock_source_destroy(struct clock_source
**clk_src
)
408 kfree(TO_DCE110_CLK_SRC(*clk_src
));
413 bool dce120_hw_sequencer_create(struct dc
*dc
)
415 /* All registers used by dce11.2 match those in dce11 in offset and
418 dce120_hw_sequencer_construct(dc
);
420 /*TODO Move to separate file and Override what is needed */
425 static struct timing_generator
*dce120_timing_generator_create(
426 struct dc_context
*ctx
,
428 const struct dce110_timing_generator_offsets
*offsets
)
430 struct dce110_timing_generator
*tg110
=
431 kzalloc(sizeof(struct dce110_timing_generator
), GFP_KERNEL
);
436 if (dce120_timing_generator_construct(tg110
, ctx
, instance
, offsets
))
444 static void dce120_transform_destroy(struct transform
**xfm
)
446 kfree(TO_DCE_TRANSFORM(*xfm
));
450 static void destruct(struct dce110_resource_pool
*pool
)
454 for (i
= 0; i
< pool
->base
.pipe_count
; i
++) {
455 if (pool
->base
.opps
[i
] != NULL
)
456 dce110_opp_destroy(&pool
->base
.opps
[i
]);
458 if (pool
->base
.transforms
[i
] != NULL
)
459 dce120_transform_destroy(&pool
->base
.transforms
[i
]);
461 if (pool
->base
.ipps
[i
] != NULL
)
462 dce_ipp_destroy(&pool
->base
.ipps
[i
]);
464 if (pool
->base
.mis
[i
] != NULL
) {
465 kfree(TO_DCE_MEM_INPUT(pool
->base
.mis
[i
]));
466 pool
->base
.mis
[i
] = NULL
;
469 if (pool
->base
.irqs
!= NULL
) {
470 dal_irq_service_destroy(&pool
->base
.irqs
);
473 if (pool
->base
.timing_generators
[i
] != NULL
) {
474 kfree(DCE110TG_FROM_TG(pool
->base
.timing_generators
[i
]));
475 pool
->base
.timing_generators
[i
] = NULL
;
479 for (i
= 0; i
< pool
->base
.audio_count
; i
++) {
480 if (pool
->base
.audios
[i
])
481 dce_aud_destroy(&pool
->base
.audios
[i
]);
484 for (i
= 0; i
< pool
->base
.stream_enc_count
; i
++) {
485 if (pool
->base
.stream_enc
[i
] != NULL
)
486 kfree(DCE110STRENC_FROM_STRENC(pool
->base
.stream_enc
[i
]));
489 for (i
= 0; i
< pool
->base
.clk_src_count
; i
++) {
490 if (pool
->base
.clock_sources
[i
] != NULL
)
491 dce120_clock_source_destroy(
492 &pool
->base
.clock_sources
[i
]);
495 if (pool
->base
.dp_clock_source
!= NULL
)
496 dce120_clock_source_destroy(&pool
->base
.dp_clock_source
);
498 if (pool
->base
.abm
!= NULL
)
499 dce_abm_destroy(&pool
->base
.abm
);
501 if (pool
->base
.dmcu
!= NULL
)
502 dce_dmcu_destroy(&pool
->base
.dmcu
);
504 if (pool
->base
.display_clock
!= NULL
)
505 dce_disp_clk_destroy(&pool
->base
.display_clock
);
508 static void read_dce_straps(
509 struct dc_context
*ctx
,
510 struct resource_straps
*straps
)
512 /* TODO: Registers are missing */
513 /*REG_GET_2(CC_DC_HDMI_STRAPS,
514 HDMI_DISABLE, &straps->hdmi_disable,
515 AUDIO_STREAM_NUMBER, &straps->audio_stream_number);
517 REG_GET(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO, &straps->dc_pinstraps_audio);*/
520 static struct audio
*create_audio(
521 struct dc_context
*ctx
, unsigned int inst
)
523 return dce_audio_create(ctx
, inst
,
524 &audio_regs
[inst
], &audio_shift
, &audio_mask
);
527 static const struct encoder_feature_support link_enc_feature
= {
528 .max_hdmi_deep_color
= COLOR_DEPTH_121212
,
529 .max_hdmi_pixel_clock
= 600000,
530 .ycbcr420_supported
= true,
531 .flags
.bits
.IS_HBR2_CAPABLE
= true,
532 .flags
.bits
.IS_HBR3_CAPABLE
= true,
533 .flags
.bits
.IS_TPS3_CAPABLE
= true,
534 .flags
.bits
.IS_TPS4_CAPABLE
= true,
535 .flags
.bits
.IS_YCBCR_CAPABLE
= true
538 static struct link_encoder
*dce120_link_encoder_create(
539 const struct encoder_init_data
*enc_init_data
)
541 struct dce110_link_encoder
*enc110
=
542 kzalloc(sizeof(struct dce110_link_encoder
), GFP_KERNEL
);
547 if (dce110_link_encoder_construct(
551 &link_enc_regs
[enc_init_data
->transmitter
],
552 &link_enc_aux_regs
[enc_init_data
->channel
- 1],
553 &link_enc_hpd_regs
[enc_init_data
->hpd_source
])) {
555 return &enc110
->base
;
563 static struct input_pixel_processor
*dce120_ipp_create(
564 struct dc_context
*ctx
, uint32_t inst
)
566 struct dce_ipp
*ipp
= kzalloc(sizeof(struct dce_ipp
), GFP_KERNEL
);
573 dce_ipp_construct(ipp
, ctx
, inst
,
574 &ipp_regs
[inst
], &ipp_shift
, &ipp_mask
);
578 static struct stream_encoder
*dce120_stream_encoder_create(
579 enum engine_id eng_id
,
580 struct dc_context
*ctx
)
582 struct dce110_stream_encoder
*enc110
=
583 kzalloc(sizeof(struct dce110_stream_encoder
), GFP_KERNEL
);
588 if (dce110_stream_encoder_construct(
589 enc110
, ctx
, ctx
->dc_bios
, eng_id
,
590 &stream_enc_regs
[eng_id
], &se_shift
, &se_mask
))
591 return &enc110
->base
;
598 #define SRII(reg_name, block, id)\
599 .reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
600 mm ## block ## id ## _ ## reg_name
602 static const struct dce_hwseq_registers hwseq_reg
= {
603 HWSEQ_DCE120_REG_LIST()
606 static const struct dce_hwseq_shift hwseq_shift
= {
607 HWSEQ_DCE12_MASK_SH_LIST(__SHIFT
)
610 static const struct dce_hwseq_mask hwseq_mask
= {
611 HWSEQ_DCE12_MASK_SH_LIST(_MASK
)
614 static struct dce_hwseq
*dce120_hwseq_create(
615 struct dc_context
*ctx
)
617 struct dce_hwseq
*hws
= kzalloc(sizeof(struct dce_hwseq
), GFP_KERNEL
);
621 hws
->regs
= &hwseq_reg
;
622 hws
->shifts
= &hwseq_shift
;
623 hws
->masks
= &hwseq_mask
;
628 static const struct resource_create_funcs res_create_funcs
= {
629 .read_dce_straps
= read_dce_straps
,
630 .create_audio
= create_audio
,
631 .create_stream_encoder
= dce120_stream_encoder_create
,
632 .create_hwseq
= dce120_hwseq_create
,
635 #define mi_inst_regs(id) { MI_DCE12_REG_LIST(id) }
636 static const struct dce_mem_input_registers mi_regs
[] = {
645 static const struct dce_mem_input_shift mi_shifts
= {
646 MI_DCE12_MASK_SH_LIST(__SHIFT
)
649 static const struct dce_mem_input_mask mi_masks
= {
650 MI_DCE12_MASK_SH_LIST(_MASK
)
653 static struct mem_input
*dce120_mem_input_create(
654 struct dc_context
*ctx
,
657 struct dce_mem_input
*dce_mi
= kzalloc(sizeof(struct dce_mem_input
),
665 dce112_mem_input_construct(dce_mi
, ctx
, inst
, &mi_regs
[inst
], &mi_shifts
, &mi_masks
);
666 return &dce_mi
->base
;
669 static struct transform
*dce120_transform_create(
670 struct dc_context
*ctx
,
673 struct dce_transform
*transform
=
674 kzalloc(sizeof(struct dce_transform
), GFP_KERNEL
);
679 if (dce_transform_construct(transform
, ctx
, inst
,
680 &xfm_regs
[inst
], &xfm_shift
, &xfm_mask
)) {
681 transform
->lb_memory_size
= 0x1404; /*5124*/
682 return &transform
->base
;
690 static void dce120_destroy_resource_pool(struct resource_pool
**pool
)
692 struct dce110_resource_pool
*dce110_pool
= TO_DCE110_RES_POOL(*pool
);
694 destruct(dce110_pool
);
699 static const struct resource_funcs dce120_res_pool_funcs
= {
700 .destroy
= dce120_destroy_resource_pool
,
701 .link_enc_create
= dce120_link_encoder_create
,
702 .validate_guaranteed
= dce112_validate_guaranteed
,
703 .validate_bandwidth
= dce112_validate_bandwidth
,
704 .validate_plane
= dce100_validate_plane
,
705 .add_stream_to_ctx
= dce112_add_stream_to_ctx
708 static void bw_calcs_data_update_from_pplib(struct dc
*dc
)
710 struct dm_pp_clock_levels_with_latency eng_clks
= {0};
711 struct dm_pp_clock_levels_with_latency mem_clks
= {0};
712 struct dm_pp_wm_sets_with_clock_ranges clk_ranges
= {0};
715 unsigned int latency
;
718 if (!dm_pp_get_clock_levels_by_type_with_latency(
720 DM_PP_CLOCK_TYPE_ENGINE_CLK
,
721 &eng_clks
) || eng_clks
.num_levels
== 0) {
723 eng_clks
.num_levels
= 8;
726 for (i
= 0; i
< eng_clks
.num_levels
; i
++) {
727 eng_clks
.data
[i
].clocks_in_khz
= clk
;
732 /* convert all the clock fro kHz to fix point mHz TODO: wloop data */
733 dc
->bw_vbios
->high_sclk
= bw_frc_to_fixed(
734 eng_clks
.data
[eng_clks
.num_levels
-1].clocks_in_khz
, 1000);
735 dc
->bw_vbios
->mid1_sclk
= bw_frc_to_fixed(
736 eng_clks
.data
[eng_clks
.num_levels
/8].clocks_in_khz
, 1000);
737 dc
->bw_vbios
->mid2_sclk
= bw_frc_to_fixed(
738 eng_clks
.data
[eng_clks
.num_levels
*2/8].clocks_in_khz
, 1000);
739 dc
->bw_vbios
->mid3_sclk
= bw_frc_to_fixed(
740 eng_clks
.data
[eng_clks
.num_levels
*3/8].clocks_in_khz
, 1000);
741 dc
->bw_vbios
->mid4_sclk
= bw_frc_to_fixed(
742 eng_clks
.data
[eng_clks
.num_levels
*4/8].clocks_in_khz
, 1000);
743 dc
->bw_vbios
->mid5_sclk
= bw_frc_to_fixed(
744 eng_clks
.data
[eng_clks
.num_levels
*5/8].clocks_in_khz
, 1000);
745 dc
->bw_vbios
->mid6_sclk
= bw_frc_to_fixed(
746 eng_clks
.data
[eng_clks
.num_levels
*6/8].clocks_in_khz
, 1000);
747 dc
->bw_vbios
->low_sclk
= bw_frc_to_fixed(
748 eng_clks
.data
[0].clocks_in_khz
, 1000);
751 if (!dm_pp_get_clock_levels_by_type_with_latency(
753 DM_PP_CLOCK_TYPE_MEMORY_CLK
,
754 &mem_clks
) || mem_clks
.num_levels
== 0) {
756 mem_clks
.num_levels
= 3;
760 for (i
= 0; i
< eng_clks
.num_levels
; i
++) {
761 mem_clks
.data
[i
].clocks_in_khz
= clk
;
762 mem_clks
.data
[i
].latency_in_us
= latency
;
769 /* we don't need to call PPLIB for validation clock since they
770 * also give us the highest sclk and highest mclk (UMA clock).
771 * ALSO always convert UMA clock (from PPLIB) to YCLK (HW formula):
772 * YCLK = UMACLK*m_memoryTypeMultiplier
774 dc
->bw_vbios
->low_yclk
= bw_frc_to_fixed(
775 mem_clks
.data
[0].clocks_in_khz
* MEMORY_TYPE_MULTIPLIER
, 1000);
776 dc
->bw_vbios
->mid_yclk
= bw_frc_to_fixed(
777 mem_clks
.data
[mem_clks
.num_levels
>>1].clocks_in_khz
* MEMORY_TYPE_MULTIPLIER
,
779 dc
->bw_vbios
->high_yclk
= bw_frc_to_fixed(
780 mem_clks
.data
[mem_clks
.num_levels
-1].clocks_in_khz
* MEMORY_TYPE_MULTIPLIER
,
783 /* Now notify PPLib/SMU about which Watermarks sets they should select
784 * depending on DPM state they are in. And update BW MGR GFX Engine and
785 * Memory clock member variables for Watermarks calculations for each
788 clk_ranges
.num_wm_sets
= 4;
789 clk_ranges
.wm_clk_ranges
[0].wm_set_id
= WM_SET_A
;
790 clk_ranges
.wm_clk_ranges
[0].wm_min_eng_clk_in_khz
=
791 eng_clks
.data
[0].clocks_in_khz
;
792 clk_ranges
.wm_clk_ranges
[0].wm_max_eng_clk_in_khz
=
793 eng_clks
.data
[eng_clks
.num_levels
*3/8].clocks_in_khz
- 1;
794 clk_ranges
.wm_clk_ranges
[0].wm_min_memg_clk_in_khz
=
795 mem_clks
.data
[0].clocks_in_khz
;
796 clk_ranges
.wm_clk_ranges
[0].wm_max_mem_clk_in_khz
=
797 mem_clks
.data
[mem_clks
.num_levels
>>1].clocks_in_khz
- 1;
799 clk_ranges
.wm_clk_ranges
[1].wm_set_id
= WM_SET_B
;
800 clk_ranges
.wm_clk_ranges
[1].wm_min_eng_clk_in_khz
=
801 eng_clks
.data
[eng_clks
.num_levels
*3/8].clocks_in_khz
;
802 /* 5 GHz instead of data[7].clockInKHz to cover Overdrive */
803 clk_ranges
.wm_clk_ranges
[1].wm_max_eng_clk_in_khz
= 5000000;
804 clk_ranges
.wm_clk_ranges
[1].wm_min_memg_clk_in_khz
=
805 mem_clks
.data
[0].clocks_in_khz
;
806 clk_ranges
.wm_clk_ranges
[1].wm_max_mem_clk_in_khz
=
807 mem_clks
.data
[mem_clks
.num_levels
>>1].clocks_in_khz
- 1;
809 clk_ranges
.wm_clk_ranges
[2].wm_set_id
= WM_SET_C
;
810 clk_ranges
.wm_clk_ranges
[2].wm_min_eng_clk_in_khz
=
811 eng_clks
.data
[0].clocks_in_khz
;
812 clk_ranges
.wm_clk_ranges
[2].wm_max_eng_clk_in_khz
=
813 eng_clks
.data
[eng_clks
.num_levels
*3/8].clocks_in_khz
- 1;
814 clk_ranges
.wm_clk_ranges
[2].wm_min_memg_clk_in_khz
=
815 mem_clks
.data
[mem_clks
.num_levels
>>1].clocks_in_khz
;
816 /* 5 GHz instead of data[2].clockInKHz to cover Overdrive */
817 clk_ranges
.wm_clk_ranges
[2].wm_max_mem_clk_in_khz
= 5000000;
819 clk_ranges
.wm_clk_ranges
[3].wm_set_id
= WM_SET_D
;
820 clk_ranges
.wm_clk_ranges
[3].wm_min_eng_clk_in_khz
=
821 eng_clks
.data
[eng_clks
.num_levels
*3/8].clocks_in_khz
;
822 /* 5 GHz instead of data[7].clockInKHz to cover Overdrive */
823 clk_ranges
.wm_clk_ranges
[3].wm_max_eng_clk_in_khz
= 5000000;
824 clk_ranges
.wm_clk_ranges
[3].wm_min_memg_clk_in_khz
=
825 mem_clks
.data
[mem_clks
.num_levels
>>1].clocks_in_khz
;
826 /* 5 GHz instead of data[2].clockInKHz to cover Overdrive */
827 clk_ranges
.wm_clk_ranges
[3].wm_max_mem_clk_in_khz
= 5000000;
829 /* Notify PP Lib/SMU which Watermarks to use for which clock ranges */
830 dm_pp_notify_wm_clock_changes(dc
->ctx
, &clk_ranges
);
833 static bool construct(
834 uint8_t num_virtual_links
,
836 struct dce110_resource_pool
*pool
)
839 struct dc_context
*ctx
= dc
->ctx
;
840 struct irq_service_init_data irq_init_data
;
842 ctx
->dc_bios
->regs
= &bios_regs
;
844 pool
->base
.res_cap
= &res_cap
;
845 pool
->base
.funcs
= &dce120_res_pool_funcs
;
847 /* TODO: Fill more data from GreenlandAsicCapability.cpp */
848 pool
->base
.pipe_count
= res_cap
.num_timing_generator
;
849 pool
->base
.underlay_pipe_index
= NO_UNDERLAY_PIPE
;
851 dc
->caps
.max_downscale_ratio
= 200;
852 dc
->caps
.i2c_speed_in_khz
= 100;
853 dc
->caps
.max_cursor_size
= 128;
854 dc
->debug
= debug_defaults
;
856 /*************************************************
858 *************************************************/
860 pool
->base
.clock_sources
[DCE120_CLK_SRC_PLL0
] =
861 dce120_clock_source_create(ctx
, ctx
->dc_bios
,
862 CLOCK_SOURCE_COMBO_PHY_PLL0
,
863 &clk_src_regs
[0], false);
864 pool
->base
.clock_sources
[DCE120_CLK_SRC_PLL1
] =
865 dce120_clock_source_create(ctx
, ctx
->dc_bios
,
866 CLOCK_SOURCE_COMBO_PHY_PLL1
,
867 &clk_src_regs
[1], false);
868 pool
->base
.clock_sources
[DCE120_CLK_SRC_PLL2
] =
869 dce120_clock_source_create(ctx
, ctx
->dc_bios
,
870 CLOCK_SOURCE_COMBO_PHY_PLL2
,
871 &clk_src_regs
[2], false);
872 pool
->base
.clock_sources
[DCE120_CLK_SRC_PLL3
] =
873 dce120_clock_source_create(ctx
, ctx
->dc_bios
,
874 CLOCK_SOURCE_COMBO_PHY_PLL3
,
875 &clk_src_regs
[3], false);
876 pool
->base
.clock_sources
[DCE120_CLK_SRC_PLL4
] =
877 dce120_clock_source_create(ctx
, ctx
->dc_bios
,
878 CLOCK_SOURCE_COMBO_PHY_PLL4
,
879 &clk_src_regs
[4], false);
880 pool
->base
.clock_sources
[DCE120_CLK_SRC_PLL5
] =
881 dce120_clock_source_create(ctx
, ctx
->dc_bios
,
882 CLOCK_SOURCE_COMBO_PHY_PLL5
,
883 &clk_src_regs
[5], false);
884 pool
->base
.clk_src_count
= DCE120_CLK_SRC_TOTAL
;
886 pool
->base
.dp_clock_source
=
887 dce120_clock_source_create(ctx
, ctx
->dc_bios
,
888 CLOCK_SOURCE_ID_DP_DTO
,
889 &clk_src_regs
[0], true);
891 for (i
= 0; i
< pool
->base
.clk_src_count
; i
++) {
892 if (pool
->base
.clock_sources
[i
] == NULL
) {
893 dm_error("DC: failed to create clock sources!\n");
895 goto clk_src_create_fail
;
899 pool
->base
.display_clock
= dce120_disp_clk_create(ctx
);
900 if (pool
->base
.display_clock
== NULL
) {
901 dm_error("DC: failed to create display clock!\n");
903 goto disp_clk_create_fail
;
906 pool
->base
.dmcu
= dce_dmcu_create(ctx
,
910 if (pool
->base
.dmcu
== NULL
) {
911 dm_error("DC: failed to create dmcu!\n");
913 goto res_create_fail
;
916 pool
->base
.abm
= dce_abm_create(ctx
,
920 if (pool
->base
.abm
== NULL
) {
921 dm_error("DC: failed to create abm!\n");
923 goto res_create_fail
;
926 irq_init_data
.ctx
= dc
->ctx
;
927 pool
->base
.irqs
= dal_irq_service_dce120_create(&irq_init_data
);
928 if (!pool
->base
.irqs
)
929 goto irqs_create_fail
;
931 for (i
= 0; i
< pool
->base
.pipe_count
; i
++) {
932 pool
->base
.timing_generators
[i
] =
933 dce120_timing_generator_create(
936 &dce120_tg_offsets
[i
]);
937 if (pool
->base
.timing_generators
[i
] == NULL
) {
939 dm_error("DC: failed to create tg!\n");
940 goto controller_create_fail
;
943 pool
->base
.mis
[i
] = dce120_mem_input_create(ctx
, i
);
945 if (pool
->base
.mis
[i
] == NULL
) {
948 "DC: failed to create memory input!\n");
949 goto controller_create_fail
;
952 pool
->base
.ipps
[i
] = dce120_ipp_create(ctx
, i
);
953 if (pool
->base
.ipps
[i
] == NULL
) {
956 "DC: failed to create input pixel processor!\n");
957 goto controller_create_fail
;
960 pool
->base
.transforms
[i
] = dce120_transform_create(ctx
, i
);
961 if (pool
->base
.transforms
[i
] == NULL
) {
964 "DC: failed to create transform!\n");
965 goto res_create_fail
;
968 pool
->base
.opps
[i
] = dce120_opp_create(
971 if (pool
->base
.opps
[i
] == NULL
) {
974 "DC: failed to create output pixel processor!\n");
978 if (!resource_construct(num_virtual_links
, dc
, &pool
->base
,
980 goto res_create_fail
;
982 /* Create hardware sequencer */
983 if (!dce120_hw_sequencer_create(dc
))
984 goto controller_create_fail
;
986 dc
->caps
.max_planes
= pool
->base
.pipe_count
;
988 bw_calcs_init(dc
->bw_dceip
, dc
->bw_vbios
, dc
->ctx
->asic_id
);
990 bw_calcs_data_update_from_pplib(dc
);
995 controller_create_fail
:
996 disp_clk_create_fail
:
1005 struct resource_pool
*dce120_create_resource_pool(
1006 uint8_t num_virtual_links
,
1009 struct dce110_resource_pool
*pool
=
1010 kzalloc(sizeof(struct dce110_resource_pool
), GFP_KERNEL
);
1015 if (construct(num_virtual_links
, dc
, pool
))
1018 BREAK_TO_DEBUGGER();