2 * Copyright 2012-15 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "dm_services.h"
30 #include "core_types.h"
32 #include "include/grph_object_id.h"
33 #include "include/logger_interface.h"
35 #include "dce_clock_source.h"
37 #include "reg_helper.h"
45 #define DC_LOGGER_INIT()
48 #define FN(reg_name, field_name) \
49 clk_src->cs_shift->field_name, clk_src->cs_mask->field_name
51 #define FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM 6
52 #define CALC_PLL_CLK_SRC_ERR_TOLERANCE 1
53 #define MAX_PLL_CALC_ERROR 0xFFFFFFFF
55 static const struct spread_spectrum_data *get_ss_data_entry(
56 struct dce110_clk_src *clk_src,
57 enum signal_type signal,
63 struct spread_spectrum_data *ss_parm = NULL;
64 struct spread_spectrum_data *ret = NULL;
67 case SIGNAL_TYPE_DVI_SINGLE_LINK:
68 case SIGNAL_TYPE_DVI_DUAL_LINK:
69 ss_parm = clk_src->dvi_ss_params;
70 entrys_num = clk_src->dvi_ss_params_cnt;
73 case SIGNAL_TYPE_HDMI_TYPE_A:
74 ss_parm = clk_src->hdmi_ss_params;
75 entrys_num = clk_src->hdmi_ss_params_cnt;
78 case SIGNAL_TYPE_DISPLAY_PORT:
79 case SIGNAL_TYPE_DISPLAY_PORT_MST:
81 case SIGNAL_TYPE_VIRTUAL:
82 ss_parm = clk_src->dp_ss_params;
83 entrys_num = clk_src->dp_ss_params_cnt;
95 for (i = 0; i < entrys_num; ++i, ++ss_parm) {
96 if (ss_parm->freq_range_khz >= pix_clk_khz) {
106 * Function: calculate_fb_and_fractional_fb_divider
108 * * DESCRIPTION: Calculates feedback and fractional feedback dividers values
111 * targetPixelClock Desired frequency in 10 KHz
112 * ref_divider Reference divider (already known)
113 * postDivider Post Divider (already known)
114 * feedback_divider_param Pointer where to store
115 * calculated feedback divider value
116 * fract_feedback_divider_param Pointer where to store
117 * calculated fract feedback divider value
120 * It fills the locations pointed by feedback_divider_param
121 * and fract_feedback_divider_param
122 * It returns - true if feedback divider not 0
123 * - false should never happen)
125 static bool calculate_fb_and_fractional_fb_divider(
126 struct calc_pll_clock_source *calc_pll_cs,
127 uint32_t target_pix_clk_khz,
128 uint32_t ref_divider,
129 uint32_t post_divider,
130 uint32_t *feedback_divider_param,
131 uint32_t *fract_feedback_divider_param)
133 uint64_t feedback_divider;
136 (uint64_t)(target_pix_clk_khz * ref_divider * post_divider);
137 feedback_divider *= 10;
138 /* additional factor, since we divide by 10 afterwards */
139 feedback_divider *= (uint64_t)(calc_pll_cs->fract_fb_divider_factor);
140 feedback_divider = div_u64(feedback_divider, calc_pll_cs->ref_freq_khz);
142 /*Round to the number of precision
143 * The following code replace the old code (ullfeedbackDivider + 5)/10
144 * for example if the difference between the number
145 * of fractional feedback decimal point and the fractional FB Divider precision
146 * is 2 then the equation becomes (ullfeedbackDivider + 5*100) / (10*100))*/
148 feedback_divider += (uint64_t)
149 (5 * calc_pll_cs->fract_fb_divider_precision_factor);
151 div_u64(feedback_divider,
152 calc_pll_cs->fract_fb_divider_precision_factor * 10);
153 feedback_divider *= (uint64_t)
154 (calc_pll_cs->fract_fb_divider_precision_factor);
156 *feedback_divider_param =
159 calc_pll_cs->fract_fb_divider_factor,
160 fract_feedback_divider_param);
162 if (*feedback_divider_param != 0)
168 *calc_fb_divider_checking_tolerance
170 *DESCRIPTION: Calculates Feedback and Fractional Feedback divider values
171 * for passed Reference and Post divider, checking for tolerance.
173 * pll_settings Pointer to structure
174 * ref_divider Reference divider (already known)
175 * postDivider Post Divider (already known)
176 * tolerance Tolerance for Calculated Pixel Clock to be within
179 * It fills the PLLSettings structure with PLL Dividers values
180 * if calculated values are within required tolerance
181 * It returns - true if eror is within tolerance
182 * - false if eror is not within tolerance
184 static bool calc_fb_divider_checking_tolerance(
185 struct calc_pll_clock_source *calc_pll_cs,
186 struct pll_settings *pll_settings,
187 uint32_t ref_divider,
188 uint32_t post_divider,
191 uint32_t feedback_divider;
192 uint32_t fract_feedback_divider;
193 uint32_t actual_calculated_clock_khz;
195 uint64_t actual_calc_clk_khz;
197 calculate_fb_and_fractional_fb_divider(
199 pll_settings->adjusted_pix_clk,
203 &fract_feedback_divider);
205 /*Actual calculated value*/
206 actual_calc_clk_khz = (uint64_t)(feedback_divider *
207 calc_pll_cs->fract_fb_divider_factor) +
208 fract_feedback_divider;
209 actual_calc_clk_khz *= calc_pll_cs->ref_freq_khz;
210 actual_calc_clk_khz =
211 div_u64(actual_calc_clk_khz,
212 ref_divider * post_divider *
213 calc_pll_cs->fract_fb_divider_factor);
215 actual_calculated_clock_khz = (uint32_t)(actual_calc_clk_khz);
217 abs_err = (actual_calculated_clock_khz >
218 pll_settings->adjusted_pix_clk)
219 ? actual_calculated_clock_khz -
220 pll_settings->adjusted_pix_clk
221 : pll_settings->adjusted_pix_clk -
222 actual_calculated_clock_khz;
224 if (abs_err <= tolerance) {
225 /*found good values*/
226 pll_settings->reference_freq = calc_pll_cs->ref_freq_khz;
227 pll_settings->reference_divider = ref_divider;
228 pll_settings->feedback_divider = feedback_divider;
229 pll_settings->fract_feedback_divider = fract_feedback_divider;
230 pll_settings->pix_clk_post_divider = post_divider;
231 pll_settings->calculated_pix_clk =
232 actual_calculated_clock_khz;
233 pll_settings->vco_freq =
234 actual_calculated_clock_khz * post_divider;
240 static bool calc_pll_dividers_in_range(
241 struct calc_pll_clock_source *calc_pll_cs,
242 struct pll_settings *pll_settings,
243 uint32_t min_ref_divider,
244 uint32_t max_ref_divider,
245 uint32_t min_post_divider,
246 uint32_t max_post_divider,
247 uint32_t err_tolerance)
249 uint32_t ref_divider;
250 uint32_t post_divider;
253 /* This is err_tolerance / 10000 = 0.0025 - acceptable error of 0.25%
254 * This is errorTolerance / 10000 = 0.0001 - acceptable error of 0.01%*/
255 tolerance = (pll_settings->adjusted_pix_clk * err_tolerance) /
257 if (tolerance < CALC_PLL_CLK_SRC_ERR_TOLERANCE)
258 tolerance = CALC_PLL_CLK_SRC_ERR_TOLERANCE;
261 post_divider = max_post_divider;
262 post_divider >= min_post_divider;
265 ref_divider = min_ref_divider;
266 ref_divider <= max_ref_divider;
268 if (calc_fb_divider_checking_tolerance(
282 static uint32_t calculate_pixel_clock_pll_dividers(
283 struct calc_pll_clock_source *calc_pll_cs,
284 struct pll_settings *pll_settings)
286 uint32_t err_tolerance;
287 uint32_t min_post_divider;
288 uint32_t max_post_divider;
289 uint32_t min_ref_divider;
290 uint32_t max_ref_divider;
292 if (pll_settings->adjusted_pix_clk == 0) {
294 "%s Bad requested pixel clock", __func__);
295 return MAX_PLL_CALC_ERROR;
298 /* 1) Find Post divider ranges */
299 if (pll_settings->pix_clk_post_divider) {
300 min_post_divider = pll_settings->pix_clk_post_divider;
301 max_post_divider = pll_settings->pix_clk_post_divider;
303 min_post_divider = calc_pll_cs->min_pix_clock_pll_post_divider;
304 if (min_post_divider * pll_settings->adjusted_pix_clk <
305 calc_pll_cs->min_vco_khz) {
306 min_post_divider = calc_pll_cs->min_vco_khz /
307 pll_settings->adjusted_pix_clk;
308 if ((min_post_divider *
309 pll_settings->adjusted_pix_clk) <
310 calc_pll_cs->min_vco_khz)
314 max_post_divider = calc_pll_cs->max_pix_clock_pll_post_divider;
315 if (max_post_divider * pll_settings->adjusted_pix_clk
316 > calc_pll_cs->max_vco_khz)
317 max_post_divider = calc_pll_cs->max_vco_khz /
318 pll_settings->adjusted_pix_clk;
321 /* 2) Find Reference divider ranges
322 * When SS is enabled, or for Display Port even without SS,
323 * pll_settings->referenceDivider is not zero.
324 * So calculate PPLL FB and fractional FB divider
325 * using the passed reference divider*/
327 if (pll_settings->reference_divider) {
328 min_ref_divider = pll_settings->reference_divider;
329 max_ref_divider = pll_settings->reference_divider;
331 min_ref_divider = ((calc_pll_cs->ref_freq_khz
332 / calc_pll_cs->max_pll_input_freq_khz)
333 > calc_pll_cs->min_pll_ref_divider)
334 ? calc_pll_cs->ref_freq_khz
335 / calc_pll_cs->max_pll_input_freq_khz
336 : calc_pll_cs->min_pll_ref_divider;
338 max_ref_divider = ((calc_pll_cs->ref_freq_khz
339 / calc_pll_cs->min_pll_input_freq_khz)
340 < calc_pll_cs->max_pll_ref_divider)
341 ? calc_pll_cs->ref_freq_khz /
342 calc_pll_cs->min_pll_input_freq_khz
343 : calc_pll_cs->max_pll_ref_divider;
346 /* If some parameters are invalid we could have scenario when "min">"max"
347 * which produced endless loop later.
348 * We should investigate why we get the wrong parameters.
349 * But to follow the similar logic when "adjustedPixelClock" is set to be 0
350 * it is better to return here than cause system hang/watchdog timeout later.
351 * ## SVS Wed 15 Jul 2009 */
353 if (min_post_divider > max_post_divider) {
355 "%s Post divider range is invalid", __func__);
356 return MAX_PLL_CALC_ERROR;
359 if (min_ref_divider > max_ref_divider) {
361 "%s Reference divider range is invalid", __func__);
362 return MAX_PLL_CALC_ERROR;
365 /* 3) Try to find PLL dividers given ranges
366 * starting with minimal error tolerance.
367 * Increase error tolerance until PLL dividers found*/
368 err_tolerance = MAX_PLL_CALC_ERROR;
370 while (!calc_pll_dividers_in_range(
378 err_tolerance += (err_tolerance > 10)
379 ? (err_tolerance / 10)
382 return err_tolerance;
385 static bool pll_adjust_pix_clk(
386 struct dce110_clk_src *clk_src,
387 struct pixel_clk_params *pix_clk_params,
388 struct pll_settings *pll_settings)
390 uint32_t actual_pix_clk_khz = 0;
391 uint32_t requested_clk_khz = 0;
392 struct bp_adjust_pixel_clock_parameters bp_adjust_pixel_clock_params = {
394 enum bp_result bp_result;
395 switch (pix_clk_params->signal_type) {
396 case SIGNAL_TYPE_HDMI_TYPE_A: {
397 requested_clk_khz = pix_clk_params->requested_pix_clk;
398 if (pix_clk_params->pixel_encoding != PIXEL_ENCODING_YCBCR422) {
399 switch (pix_clk_params->color_depth) {
400 case COLOR_DEPTH_101010:
401 requested_clk_khz = (requested_clk_khz * 5) >> 2;
403 case COLOR_DEPTH_121212:
404 requested_clk_khz = (requested_clk_khz * 6) >> 2;
406 case COLOR_DEPTH_161616:
407 requested_clk_khz = requested_clk_khz * 2;
413 actual_pix_clk_khz = requested_clk_khz;
417 case SIGNAL_TYPE_DISPLAY_PORT:
418 case SIGNAL_TYPE_DISPLAY_PORT_MST:
419 case SIGNAL_TYPE_EDP:
420 requested_clk_khz = pix_clk_params->requested_sym_clk;
421 actual_pix_clk_khz = pix_clk_params->requested_pix_clk;
425 requested_clk_khz = pix_clk_params->requested_pix_clk;
426 actual_pix_clk_khz = pix_clk_params->requested_pix_clk;
430 bp_adjust_pixel_clock_params.pixel_clock = requested_clk_khz;
431 bp_adjust_pixel_clock_params.
432 encoder_object_id = pix_clk_params->encoder_object_id;
433 bp_adjust_pixel_clock_params.signal_type = pix_clk_params->signal_type;
434 bp_adjust_pixel_clock_params.
435 ss_enable = pix_clk_params->flags.ENABLE_SS;
436 bp_result = clk_src->bios->funcs->adjust_pixel_clock(
437 clk_src->bios, &bp_adjust_pixel_clock_params);
438 if (bp_result == BP_RESULT_OK) {
439 pll_settings->actual_pix_clk = actual_pix_clk_khz;
440 pll_settings->adjusted_pix_clk =
441 bp_adjust_pixel_clock_params.adjusted_pixel_clock;
442 pll_settings->reference_divider =
443 bp_adjust_pixel_clock_params.reference_divider;
444 pll_settings->pix_clk_post_divider =
445 bp_adjust_pixel_clock_params.pixel_clock_post_divider;
454 * Calculate PLL Dividers for given Clock Value.
455 * First will call VBIOS Adjust Exec table to check if requested Pixel clock
456 * will be Adjusted based on usage.
457 * Then it will calculate PLL Dividers for this Adjusted clock using preferred
458 * method (Maximum VCO frequency).
461 * Calculation error in units of 0.01%
464 static uint32_t dce110_get_pix_clk_dividers_helper (
465 struct dce110_clk_src *clk_src,
466 struct pll_settings *pll_settings,
467 struct pixel_clk_params *pix_clk_params)
470 uint32_t pll_calc_error = MAX_PLL_CALC_ERROR;
472 /* Check if reference clock is external (not pcie/xtalin)
474 * 00 - PCIE_REFCLK, 01 - XTALIN, 02 - GENERICA, 03 - GENERICB
475 * 04 - HSYNCA, 05 - GENLK_CLK, 06 - PCIE_REFCLK, 07 - DVOCLK0 */
476 REG_GET(PLL_CNTL, PLL_REF_DIV_SRC, &field);
477 pll_settings->use_external_clk = (field > 1);
479 /* VBIOS by default enables DP SS (spread on IDCLK) for DCE 8.0 always
480 * (we do not care any more from SI for some older DP Sink which
481 * does not report SS support, no known issues) */
482 if ((pix_clk_params->flags.ENABLE_SS) ||
483 (dc_is_dp_signal(pix_clk_params->signal_type))) {
485 const struct spread_spectrum_data *ss_data = get_ss_data_entry(
487 pix_clk_params->signal_type,
488 pll_settings->adjusted_pix_clk);
491 pll_settings->ss_percentage = ss_data->percentage;
494 /* Check VBIOS AdjustPixelClock Exec table */
495 if (!pll_adjust_pix_clk(clk_src, pix_clk_params, pll_settings)) {
496 /* Should never happen, ASSERT and fill up values to be able
499 "%s: Failed to adjust pixel clock!!", __func__);
500 pll_settings->actual_pix_clk =
501 pix_clk_params->requested_pix_clk;
502 pll_settings->adjusted_pix_clk =
503 pix_clk_params->requested_pix_clk;
505 if (dc_is_dp_signal(pix_clk_params->signal_type))
506 pll_settings->adjusted_pix_clk = 100000;
509 /* Calculate Dividers */
510 if (pix_clk_params->signal_type == SIGNAL_TYPE_HDMI_TYPE_A)
511 /*Calculate Dividers by HDMI object, no SS case or SS case */
513 calculate_pixel_clock_pll_dividers(
514 &clk_src->calc_pll_hdmi,
517 /*Calculate Dividers by default object, no SS case or SS case */
519 calculate_pixel_clock_pll_dividers(
523 return pll_calc_error;
526 static void dce112_get_pix_clk_dividers_helper (
527 struct dce110_clk_src *clk_src,
528 struct pll_settings *pll_settings,
529 struct pixel_clk_params *pix_clk_params)
531 uint32_t actualPixelClockInKHz;
533 actualPixelClockInKHz = pix_clk_params->requested_pix_clk;
534 /* Calculate Dividers */
535 if (pix_clk_params->signal_type == SIGNAL_TYPE_HDMI_TYPE_A) {
536 switch (pix_clk_params->color_depth) {
537 case COLOR_DEPTH_101010:
538 actualPixelClockInKHz = (actualPixelClockInKHz * 5) >> 2;
540 case COLOR_DEPTH_121212:
541 actualPixelClockInKHz = (actualPixelClockInKHz * 6) >> 2;
543 case COLOR_DEPTH_161616:
544 actualPixelClockInKHz = actualPixelClockInKHz * 2;
550 pll_settings->actual_pix_clk = actualPixelClockInKHz;
551 pll_settings->adjusted_pix_clk = actualPixelClockInKHz;
552 pll_settings->calculated_pix_clk = pix_clk_params->requested_pix_clk;
555 static uint32_t dce110_get_pix_clk_dividers(
556 struct clock_source *cs,
557 struct pixel_clk_params *pix_clk_params,
558 struct pll_settings *pll_settings)
560 struct dce110_clk_src *clk_src = TO_DCE110_CLK_SRC(cs);
561 uint32_t pll_calc_error = MAX_PLL_CALC_ERROR;
564 if (pix_clk_params == NULL || pll_settings == NULL
565 || pix_clk_params->requested_pix_clk == 0) {
567 "%s: Invalid parameters!!\n", __func__);
568 return pll_calc_error;
571 memset(pll_settings, 0, sizeof(*pll_settings));
573 if (cs->id == CLOCK_SOURCE_ID_DP_DTO ||
574 cs->id == CLOCK_SOURCE_ID_EXTERNAL) {
575 pll_settings->adjusted_pix_clk = clk_src->ext_clk_khz;
576 pll_settings->calculated_pix_clk = clk_src->ext_clk_khz;
577 pll_settings->actual_pix_clk =
578 pix_clk_params->requested_pix_clk;
582 switch (cs->ctx->dce_version) {
583 case DCE_VERSION_8_0:
584 case DCE_VERSION_8_1:
585 case DCE_VERSION_8_3:
586 case DCE_VERSION_10_0:
587 case DCE_VERSION_11_0:
589 dce110_get_pix_clk_dividers_helper(clk_src,
590 pll_settings, pix_clk_params);
592 case DCE_VERSION_11_2:
593 case DCE_VERSION_11_22:
594 case DCE_VERSION_12_0:
595 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
596 case DCN_VERSION_1_0:
599 dce112_get_pix_clk_dividers_helper(clk_src,
600 pll_settings, pix_clk_params);
606 return pll_calc_error;
609 static uint32_t dce110_get_pll_pixel_rate_in_hz(
610 struct clock_source *cs,
611 struct pixel_clk_params *pix_clk_params,
612 struct pll_settings *pll_settings)
614 uint32_t inst = pix_clk_params->controller_id - CONTROLLER_ID_D0;
615 struct dc *dc_core = cs->ctx->dc;
616 struct dc_state *context = dc_core->current_state;
617 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[inst];
619 /* This function need separate to different DCE version, before separate, just use pixel clock */
620 return pipe_ctx->stream->phy_pix_clk;
624 static uint32_t dce110_get_dp_pixel_rate_from_combo_phy_pll(
625 struct clock_source *cs,
626 struct pixel_clk_params *pix_clk_params,
627 struct pll_settings *pll_settings)
629 uint32_t inst = pix_clk_params->controller_id - CONTROLLER_ID_D0;
630 struct dc *dc_core = cs->ctx->dc;
631 struct dc_state *context = dc_core->current_state;
632 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[inst];
634 /* This function need separate to different DCE version, before separate, just use pixel clock */
635 return pipe_ctx->stream->phy_pix_clk;
638 static uint32_t dce110_get_d_to_pixel_rate_in_hz(
639 struct clock_source *cs,
640 struct pixel_clk_params *pix_clk_params,
641 struct pll_settings *pll_settings)
643 uint32_t inst = pix_clk_params->controller_id - CONTROLLER_ID_D0;
644 struct dce110_clk_src *clk_src = TO_DCE110_CLK_SRC(cs);
646 struct fixed31_32 pix_rate;
648 REG_GET(PIXEL_RATE_CNTL[inst], DP_DTO0_ENABLE, &dto_enabled);
653 REG_GET(PHASE[inst], DP_DTO0_PHASE, &phase);
654 REG_GET(MODULO[inst], DP_DTO0_MODULO, &modulo);
660 pix_rate = dc_fixpt_from_int(clk_src->ref_freq_khz);
661 pix_rate = dc_fixpt_mul_int(pix_rate, 1000);
662 pix_rate = dc_fixpt_mul_int(pix_rate, phase);
663 pix_rate = dc_fixpt_div_int(pix_rate, modulo);
665 return dc_fixpt_round(pix_rate);
667 return dce110_get_dp_pixel_rate_from_combo_phy_pll(cs, pix_clk_params, pll_settings);
671 static uint32_t dce110_get_pix_rate_in_hz(
672 struct clock_source *cs,
673 struct pixel_clk_params *pix_clk_params,
674 struct pll_settings *pll_settings)
676 uint32_t pix_rate = 0;
677 switch (pix_clk_params->signal_type) {
678 case SIGNAL_TYPE_DISPLAY_PORT:
679 case SIGNAL_TYPE_DISPLAY_PORT_MST:
680 case SIGNAL_TYPE_EDP:
681 case SIGNAL_TYPE_VIRTUAL:
682 pix_rate = dce110_get_d_to_pixel_rate_in_hz(cs, pix_clk_params, pll_settings);
684 case SIGNAL_TYPE_HDMI_TYPE_A:
686 pix_rate = dce110_get_pll_pixel_rate_in_hz(cs, pix_clk_params, pll_settings);
693 static bool disable_spread_spectrum(struct dce110_clk_src *clk_src)
695 enum bp_result result;
696 struct bp_spread_spectrum_parameters bp_ss_params = {0};
698 bp_ss_params.pll_id = clk_src->base.id;
700 /*Call ASICControl to process ATOMBIOS Exec table*/
701 result = clk_src->bios->funcs->enable_spread_spectrum_on_ppll(
706 return result == BP_RESULT_OK;
709 static bool calculate_ss(
710 const struct pll_settings *pll_settings,
711 const struct spread_spectrum_data *ss_data,
712 struct delta_sigma_data *ds_data)
714 struct fixed31_32 fb_div;
715 struct fixed31_32 ss_amount;
716 struct fixed31_32 ss_nslip_amount;
717 struct fixed31_32 ss_ds_frac_amount;
718 struct fixed31_32 ss_step_size;
719 struct fixed31_32 modulation_time;
725 if (ss_data->percentage == 0)
727 if (pll_settings == NULL)
730 memset(ds_data, 0, sizeof(struct delta_sigma_data));
732 /* compute SS_AMOUNT_FBDIV & SS_AMOUNT_NFRAC_SLIP & SS_AMOUNT_DSFRAC*/
733 /* 6 decimal point support in fractional feedback divider */
734 fb_div = dc_fixpt_from_fraction(
735 pll_settings->fract_feedback_divider, 1000000);
736 fb_div = dc_fixpt_add_int(fb_div, pll_settings->feedback_divider);
738 ds_data->ds_frac_amount = 0;
739 /*spreadSpectrumPercentage is in the unit of .01%,
740 * so have to divided by 100 * 100*/
741 ss_amount = dc_fixpt_mul(
742 fb_div, dc_fixpt_from_fraction(ss_data->percentage,
743 100 * ss_data->percentage_divider));
744 ds_data->feedback_amount = dc_fixpt_floor(ss_amount);
746 ss_nslip_amount = dc_fixpt_sub(ss_amount,
747 dc_fixpt_from_int(ds_data->feedback_amount));
748 ss_nslip_amount = dc_fixpt_mul_int(ss_nslip_amount, 10);
749 ds_data->nfrac_amount = dc_fixpt_floor(ss_nslip_amount);
751 ss_ds_frac_amount = dc_fixpt_sub(ss_nslip_amount,
752 dc_fixpt_from_int(ds_data->nfrac_amount));
753 ss_ds_frac_amount = dc_fixpt_mul_int(ss_ds_frac_amount, 65536);
754 ds_data->ds_frac_amount = dc_fixpt_floor(ss_ds_frac_amount);
756 /* compute SS_STEP_SIZE_DSFRAC */
757 modulation_time = dc_fixpt_from_fraction(
758 pll_settings->reference_freq * 1000,
759 pll_settings->reference_divider * ss_data->modulation_freq_hz);
761 if (ss_data->flags.CENTER_SPREAD)
762 modulation_time = dc_fixpt_div_int(modulation_time, 4);
764 modulation_time = dc_fixpt_div_int(modulation_time, 2);
766 ss_step_size = dc_fixpt_div(ss_amount, modulation_time);
767 /* SS_STEP_SIZE_DSFRAC_DEC = Int(SS_STEP_SIZE * 2 ^ 16 * 10)*/
768 ss_step_size = dc_fixpt_mul_int(ss_step_size, 65536 * 10);
769 ds_data->ds_frac_size = dc_fixpt_floor(ss_step_size);
774 static bool enable_spread_spectrum(
775 struct dce110_clk_src *clk_src,
776 enum signal_type signal, struct pll_settings *pll_settings)
778 struct bp_spread_spectrum_parameters bp_params = {0};
779 struct delta_sigma_data d_s_data;
780 const struct spread_spectrum_data *ss_data = NULL;
782 ss_data = get_ss_data_entry(
785 pll_settings->calculated_pix_clk);
787 /* Pixel clock PLL has been programmed to generate desired pixel clock,
788 * now enable SS on pixel clock */
789 /* TODO is it OK to return true not doing anything ??*/
790 if (ss_data != NULL && pll_settings->ss_percentage != 0) {
791 if (calculate_ss(pll_settings, ss_data, &d_s_data)) {
792 bp_params.ds.feedback_amount =
793 d_s_data.feedback_amount;
794 bp_params.ds.nfrac_amount =
795 d_s_data.nfrac_amount;
796 bp_params.ds.ds_frac_size = d_s_data.ds_frac_size;
797 bp_params.ds_frac_amount =
798 d_s_data.ds_frac_amount;
799 bp_params.flags.DS_TYPE = 1;
800 bp_params.pll_id = clk_src->base.id;
801 bp_params.percentage = ss_data->percentage;
802 if (ss_data->flags.CENTER_SPREAD)
803 bp_params.flags.CENTER_SPREAD = 1;
804 if (ss_data->flags.EXTERNAL_SS)
805 bp_params.flags.EXTERNAL_SS = 1;
808 clk_src->bios->funcs->
809 enable_spread_spectrum_on_ppll(
820 static void dce110_program_pixel_clk_resync(
821 struct dce110_clk_src *clk_src,
822 enum signal_type signal_type,
823 enum dc_color_depth colordepth)
825 REG_UPDATE(RESYNC_CNTL,
826 DCCG_DEEP_COLOR_CNTL1, 0);
828 24 bit mode: TMDS clock = 1.0 x pixel clock (1:1)
829 30 bit mode: TMDS clock = 1.25 x pixel clock (5:4)
830 36 bit mode: TMDS clock = 1.5 x pixel clock (3:2)
831 48 bit mode: TMDS clock = 2 x pixel clock (2:1)
833 if (signal_type != SIGNAL_TYPE_HDMI_TYPE_A)
836 switch (colordepth) {
837 case COLOR_DEPTH_888:
838 REG_UPDATE(RESYNC_CNTL,
839 DCCG_DEEP_COLOR_CNTL1, 0);
841 case COLOR_DEPTH_101010:
842 REG_UPDATE(RESYNC_CNTL,
843 DCCG_DEEP_COLOR_CNTL1, 1);
845 case COLOR_DEPTH_121212:
846 REG_UPDATE(RESYNC_CNTL,
847 DCCG_DEEP_COLOR_CNTL1, 2);
849 case COLOR_DEPTH_161616:
850 REG_UPDATE(RESYNC_CNTL,
851 DCCG_DEEP_COLOR_CNTL1, 3);
858 static void dce112_program_pixel_clk_resync(
859 struct dce110_clk_src *clk_src,
860 enum signal_type signal_type,
861 enum dc_color_depth colordepth,
862 bool enable_ycbcr420)
864 uint32_t deep_color_cntl = 0;
865 uint32_t double_rate_enable = 0;
868 24 bit mode: TMDS clock = 1.0 x pixel clock (1:1)
869 30 bit mode: TMDS clock = 1.25 x pixel clock (5:4)
870 36 bit mode: TMDS clock = 1.5 x pixel clock (3:2)
871 48 bit mode: TMDS clock = 2 x pixel clock (2:1)
873 if (signal_type == SIGNAL_TYPE_HDMI_TYPE_A) {
874 double_rate_enable = enable_ycbcr420 ? 1 : 0;
876 switch (colordepth) {
877 case COLOR_DEPTH_888:
880 case COLOR_DEPTH_101010:
883 case COLOR_DEPTH_121212:
886 case COLOR_DEPTH_161616:
894 if (clk_src->cs_mask->PHYPLLA_PIXCLK_DOUBLE_RATE_ENABLE)
895 REG_UPDATE_2(PIXCLK_RESYNC_CNTL,
896 PHYPLLA_DCCG_DEEP_COLOR_CNTL, deep_color_cntl,
897 PHYPLLA_PIXCLK_DOUBLE_RATE_ENABLE, double_rate_enable);
899 REG_UPDATE(PIXCLK_RESYNC_CNTL,
900 PHYPLLA_DCCG_DEEP_COLOR_CNTL, deep_color_cntl);
904 static bool dce110_program_pix_clk(
905 struct clock_source *clock_source,
906 struct pixel_clk_params *pix_clk_params,
907 struct pll_settings *pll_settings)
909 struct dce110_clk_src *clk_src = TO_DCE110_CLK_SRC(clock_source);
910 struct bp_pixel_clock_parameters bp_pc_params = {0};
912 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
913 if (IS_FPGA_MAXIMUS_DC(clock_source->ctx->dce_environment)) {
914 unsigned int inst = pix_clk_params->controller_id - CONTROLLER_ID_D0;
915 unsigned dp_dto_ref_kHz = 700000;
916 unsigned clock_kHz = pll_settings->actual_pix_clk;
918 /* Set DTO values: phase = target clock, modulo = reference clock */
919 REG_WRITE(PHASE[inst], clock_kHz);
920 REG_WRITE(MODULO[inst], dp_dto_ref_kHz);
923 REG_UPDATE(PIXEL_RATE_CNTL[inst], DP_DTO0_ENABLE, 1);
928 * ATOMBIOS will enable by default SS on PLL for DP,
929 * do not disable it here
931 if (clock_source->id != CLOCK_SOURCE_ID_EXTERNAL &&
932 !dc_is_dp_signal(pix_clk_params->signal_type) &&
933 clock_source->ctx->dce_version <= DCE_VERSION_11_0)
934 disable_spread_spectrum(clk_src);
936 /*ATOMBIOS expects pixel rate adjusted by deep color ratio)*/
937 bp_pc_params.controller_id = pix_clk_params->controller_id;
938 bp_pc_params.pll_id = clock_source->id;
939 bp_pc_params.target_pixel_clock = pll_settings->actual_pix_clk;
940 bp_pc_params.encoder_object_id = pix_clk_params->encoder_object_id;
941 bp_pc_params.signal_type = pix_clk_params->signal_type;
943 switch (clock_source->ctx->dce_version) {
944 case DCE_VERSION_8_0:
945 case DCE_VERSION_8_1:
946 case DCE_VERSION_8_3:
947 case DCE_VERSION_10_0:
948 case DCE_VERSION_11_0:
949 bp_pc_params.reference_divider = pll_settings->reference_divider;
950 bp_pc_params.feedback_divider = pll_settings->feedback_divider;
951 bp_pc_params.fractional_feedback_divider =
952 pll_settings->fract_feedback_divider;
953 bp_pc_params.pixel_clock_post_divider =
954 pll_settings->pix_clk_post_divider;
955 bp_pc_params.flags.SET_EXTERNAL_REF_DIV_SRC =
956 pll_settings->use_external_clk;
958 if (clk_src->bios->funcs->set_pixel_clock(
959 clk_src->bios, &bp_pc_params) != BP_RESULT_OK)
962 * ATOMBIOS will enable by default SS for DP on PLL ( DP ID clock),
963 * based on HW display PLL team, SS control settings should be programmed
964 * during PLL Reset, but they do not have effect
965 * until SS_EN is asserted.*/
966 if (clock_source->id != CLOCK_SOURCE_ID_EXTERNAL
967 && !dc_is_dp_signal(pix_clk_params->signal_type)) {
969 if (pix_clk_params->flags.ENABLE_SS)
970 if (!enable_spread_spectrum(clk_src,
971 pix_clk_params->signal_type,
975 /* Resync deep color DTO */
976 dce110_program_pixel_clk_resync(clk_src,
977 pix_clk_params->signal_type,
978 pix_clk_params->color_depth);
982 case DCE_VERSION_11_2:
983 case DCE_VERSION_11_22:
984 case DCE_VERSION_12_0:
985 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
986 case DCN_VERSION_1_0:
989 if (clock_source->id != CLOCK_SOURCE_ID_DP_DTO) {
990 bp_pc_params.flags.SET_GENLOCK_REF_DIV_SRC =
991 pll_settings->use_external_clk;
992 bp_pc_params.flags.SET_XTALIN_REF_SRC =
993 !pll_settings->use_external_clk;
994 if (pix_clk_params->flags.SUPPORT_YCBCR420) {
995 bp_pc_params.flags.SUPPORT_YUV_420 = 1;
998 if (clk_src->bios->funcs->set_pixel_clock(
999 clk_src->bios, &bp_pc_params) != BP_RESULT_OK)
1001 /* Resync deep color DTO */
1002 if (clock_source->id != CLOCK_SOURCE_ID_DP_DTO)
1003 dce112_program_pixel_clk_resync(clk_src,
1004 pix_clk_params->signal_type,
1005 pix_clk_params->color_depth,
1006 pix_clk_params->flags.SUPPORT_YCBCR420);
1015 static bool dce110_clock_source_power_down(
1016 struct clock_source *clk_src)
1018 struct dce110_clk_src *dce110_clk_src = TO_DCE110_CLK_SRC(clk_src);
1019 enum bp_result bp_result;
1020 struct bp_pixel_clock_parameters bp_pixel_clock_params = {0};
1022 if (clk_src->dp_clk_src)
1025 /* If Pixel Clock is 0 it means Power Down Pll*/
1026 bp_pixel_clock_params.controller_id = CONTROLLER_ID_UNDEFINED;
1027 bp_pixel_clock_params.pll_id = clk_src->id;
1028 bp_pixel_clock_params.flags.FORCE_PROGRAMMING_OF_PLL = 1;
1030 /*Call ASICControl to process ATOMBIOS Exec table*/
1031 bp_result = dce110_clk_src->bios->funcs->set_pixel_clock(
1032 dce110_clk_src->bios,
1033 &bp_pixel_clock_params);
1035 return bp_result == BP_RESULT_OK;
1038 /*****************************************/
1040 /*****************************************/
1041 static const struct clock_source_funcs dce110_clk_src_funcs = {
1042 .cs_power_down = dce110_clock_source_power_down,
1043 .program_pix_clk = dce110_program_pix_clk,
1044 .get_pix_clk_dividers = dce110_get_pix_clk_dividers,
1045 .get_pix_rate_in_hz = dce110_get_pix_rate_in_hz
1048 static void get_ss_info_from_atombios(
1049 struct dce110_clk_src *clk_src,
1050 enum as_signal_type as_signal,
1051 struct spread_spectrum_data *spread_spectrum_data[],
1052 uint32_t *ss_entries_num)
1054 enum bp_result bp_result = BP_RESULT_FAILURE;
1055 struct spread_spectrum_info *ss_info;
1056 struct spread_spectrum_data *ss_data;
1057 struct spread_spectrum_info *ss_info_cur;
1058 struct spread_spectrum_data *ss_data_cur;
1061 if (ss_entries_num == NULL) {
1063 "Invalid entry !!!\n");
1066 if (spread_spectrum_data == NULL) {
1068 "Invalid array pointer!!!\n");
1072 spread_spectrum_data[0] = NULL;
1073 *ss_entries_num = 0;
1075 *ss_entries_num = clk_src->bios->funcs->get_ss_entry_number(
1079 if (*ss_entries_num == 0)
1082 ss_info = kcalloc(*ss_entries_num,
1083 sizeof(struct spread_spectrum_info),
1085 ss_info_cur = ss_info;
1086 if (ss_info == NULL)
1089 ss_data = kcalloc(*ss_entries_num,
1090 sizeof(struct spread_spectrum_data),
1092 if (ss_data == NULL)
1095 for (i = 0, ss_info_cur = ss_info;
1096 i < (*ss_entries_num);
1097 ++i, ++ss_info_cur) {
1099 bp_result = clk_src->bios->funcs->get_spread_spectrum_info(
1105 if (bp_result != BP_RESULT_OK)
1109 for (i = 0, ss_info_cur = ss_info, ss_data_cur = ss_data;
1110 i < (*ss_entries_num);
1111 ++i, ++ss_info_cur, ++ss_data_cur) {
1113 if (ss_info_cur->type.STEP_AND_DELAY_INFO != false) {
1115 "Invalid ATOMBIOS SS Table!!!\n");
1119 /* for HDMI check SS percentage,
1120 * if it is > 6 (0.06%), the ATOMBIOS table info is invalid*/
1121 if (as_signal == AS_SIGNAL_TYPE_HDMI
1122 && ss_info_cur->spread_spectrum_percentage > 6){
1123 /* invalid input, do nothing */
1125 "Invalid SS percentage ");
1127 "for HDMI in ATOMBIOS info Table!!!\n");
1130 if (ss_info_cur->spread_percentage_divider == 1000) {
1131 /* Keep previous precision from ATOMBIOS for these
1132 * in case new precision set by ATOMBIOS for these
1133 * (otherwise all code in DCE specific classes
1134 * for all previous ASICs would need
1135 * to be updated for SS calculations,
1136 * Audio SS compensation and DP DTO SS compensation
1137 * which assumes fixed SS percentage Divider = 100)*/
1138 ss_info_cur->spread_spectrum_percentage /= 10;
1139 ss_info_cur->spread_percentage_divider = 100;
1142 ss_data_cur->freq_range_khz = ss_info_cur->target_clock_range;
1143 ss_data_cur->percentage =
1144 ss_info_cur->spread_spectrum_percentage;
1145 ss_data_cur->percentage_divider =
1146 ss_info_cur->spread_percentage_divider;
1147 ss_data_cur->modulation_freq_hz =
1148 ss_info_cur->spread_spectrum_range;
1150 if (ss_info_cur->type.CENTER_MODE)
1151 ss_data_cur->flags.CENTER_SPREAD = 1;
1153 if (ss_info_cur->type.EXTERNAL)
1154 ss_data_cur->flags.EXTERNAL_SS = 1;
1158 *spread_spectrum_data = ss_data;
1164 *ss_entries_num = 0;
1169 static void ss_info_from_atombios_create(
1170 struct dce110_clk_src *clk_src)
1172 get_ss_info_from_atombios(
1174 AS_SIGNAL_TYPE_DISPLAY_PORT,
1175 &clk_src->dp_ss_params,
1176 &clk_src->dp_ss_params_cnt);
1177 get_ss_info_from_atombios(
1179 AS_SIGNAL_TYPE_HDMI,
1180 &clk_src->hdmi_ss_params,
1181 &clk_src->hdmi_ss_params_cnt);
1182 get_ss_info_from_atombios(
1185 &clk_src->dvi_ss_params,
1186 &clk_src->dvi_ss_params_cnt);
1189 static bool calc_pll_max_vco_construct(
1190 struct calc_pll_clock_source *calc_pll_cs,
1191 struct calc_pll_clock_source_init_data *init_data)
1194 struct dc_firmware_info fw_info = { { 0 } };
1195 if (calc_pll_cs == NULL ||
1196 init_data == NULL ||
1197 init_data->bp == NULL)
1200 if (init_data->bp->funcs->get_firmware_info(
1202 &fw_info) != BP_RESULT_OK)
1205 calc_pll_cs->ctx = init_data->ctx;
1206 calc_pll_cs->ref_freq_khz = fw_info.pll_info.crystal_frequency;
1207 calc_pll_cs->min_vco_khz =
1208 fw_info.pll_info.min_output_pxl_clk_pll_frequency;
1209 calc_pll_cs->max_vco_khz =
1210 fw_info.pll_info.max_output_pxl_clk_pll_frequency;
1212 if (init_data->max_override_input_pxl_clk_pll_freq_khz != 0)
1213 calc_pll_cs->max_pll_input_freq_khz =
1214 init_data->max_override_input_pxl_clk_pll_freq_khz;
1216 calc_pll_cs->max_pll_input_freq_khz =
1217 fw_info.pll_info.max_input_pxl_clk_pll_frequency;
1219 if (init_data->min_override_input_pxl_clk_pll_freq_khz != 0)
1220 calc_pll_cs->min_pll_input_freq_khz =
1221 init_data->min_override_input_pxl_clk_pll_freq_khz;
1223 calc_pll_cs->min_pll_input_freq_khz =
1224 fw_info.pll_info.min_input_pxl_clk_pll_frequency;
1226 calc_pll_cs->min_pix_clock_pll_post_divider =
1227 init_data->min_pix_clk_pll_post_divider;
1228 calc_pll_cs->max_pix_clock_pll_post_divider =
1229 init_data->max_pix_clk_pll_post_divider;
1230 calc_pll_cs->min_pll_ref_divider =
1231 init_data->min_pll_ref_divider;
1232 calc_pll_cs->max_pll_ref_divider =
1233 init_data->max_pll_ref_divider;
1235 if (init_data->num_fract_fb_divider_decimal_point == 0 ||
1236 init_data->num_fract_fb_divider_decimal_point_precision >
1237 init_data->num_fract_fb_divider_decimal_point) {
1239 "The dec point num or precision is incorrect!");
1242 if (init_data->num_fract_fb_divider_decimal_point_precision == 0) {
1244 "Incorrect fract feedback divider precision num!");
1248 calc_pll_cs->fract_fb_divider_decimal_points_num =
1249 init_data->num_fract_fb_divider_decimal_point;
1250 calc_pll_cs->fract_fb_divider_precision =
1251 init_data->num_fract_fb_divider_decimal_point_precision;
1252 calc_pll_cs->fract_fb_divider_factor = 1;
1253 for (i = 0; i < calc_pll_cs->fract_fb_divider_decimal_points_num; ++i)
1254 calc_pll_cs->fract_fb_divider_factor *= 10;
1256 calc_pll_cs->fract_fb_divider_precision_factor = 1;
1259 i < (calc_pll_cs->fract_fb_divider_decimal_points_num -
1260 calc_pll_cs->fract_fb_divider_precision);
1262 calc_pll_cs->fract_fb_divider_precision_factor *= 10;
1267 bool dce110_clk_src_construct(
1268 struct dce110_clk_src *clk_src,
1269 struct dc_context *ctx,
1270 struct dc_bios *bios,
1271 enum clock_source_id id,
1272 const struct dce110_clk_src_regs *regs,
1273 const struct dce110_clk_src_shift *cs_shift,
1274 const struct dce110_clk_src_mask *cs_mask)
1276 struct dc_firmware_info fw_info = { { 0 } };
1277 struct calc_pll_clock_source_init_data calc_pll_cs_init_data_hdmi;
1278 struct calc_pll_clock_source_init_data calc_pll_cs_init_data;
1280 clk_src->base.ctx = ctx;
1281 clk_src->bios = bios;
1282 clk_src->base.id = id;
1283 clk_src->base.funcs = &dce110_clk_src_funcs;
1285 clk_src->regs = regs;
1286 clk_src->cs_shift = cs_shift;
1287 clk_src->cs_mask = cs_mask;
1289 if (clk_src->bios->funcs->get_firmware_info(
1290 clk_src->bios, &fw_info) != BP_RESULT_OK) {
1291 ASSERT_CRITICAL(false);
1292 goto unexpected_failure;
1295 clk_src->ext_clk_khz =
1296 fw_info.external_clock_source_frequency_for_dp;
1298 switch (clk_src->base.ctx->dce_version) {
1299 case DCE_VERSION_8_0:
1300 case DCE_VERSION_8_1:
1301 case DCE_VERSION_8_3:
1302 case DCE_VERSION_10_0:
1303 case DCE_VERSION_11_0:
1305 /* structure normally used with PLL ranges from ATOMBIOS; DS on by default */
1306 calc_pll_cs_init_data.bp = bios;
1307 calc_pll_cs_init_data.min_pix_clk_pll_post_divider = 1;
1308 calc_pll_cs_init_data.max_pix_clk_pll_post_divider =
1309 clk_src->cs_mask->PLL_POST_DIV_PIXCLK;
1310 calc_pll_cs_init_data.min_pll_ref_divider = 1;
1311 calc_pll_cs_init_data.max_pll_ref_divider = clk_src->cs_mask->PLL_REF_DIV;
1312 /* when 0 use minInputPxlClkPLLFrequencyInKHz from firmwareInfo*/
1313 calc_pll_cs_init_data.min_override_input_pxl_clk_pll_freq_khz = 0;
1314 /* when 0 use maxInputPxlClkPLLFrequencyInKHz from firmwareInfo*/
1315 calc_pll_cs_init_data.max_override_input_pxl_clk_pll_freq_khz = 0;
1316 /*numberOfFractFBDividerDecimalPoints*/
1317 calc_pll_cs_init_data.num_fract_fb_divider_decimal_point =
1318 FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM;
1319 /*number of decimal point to round off for fractional feedback divider value*/
1320 calc_pll_cs_init_data.num_fract_fb_divider_decimal_point_precision =
1321 FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM;
1322 calc_pll_cs_init_data.ctx = ctx;
1324 /*structure for HDMI, no SS or SS% <= 0.06% for 27 MHz Ref clock */
1325 calc_pll_cs_init_data_hdmi.bp = bios;
1326 calc_pll_cs_init_data_hdmi.min_pix_clk_pll_post_divider = 1;
1327 calc_pll_cs_init_data_hdmi.max_pix_clk_pll_post_divider =
1328 clk_src->cs_mask->PLL_POST_DIV_PIXCLK;
1329 calc_pll_cs_init_data_hdmi.min_pll_ref_divider = 1;
1330 calc_pll_cs_init_data_hdmi.max_pll_ref_divider = clk_src->cs_mask->PLL_REF_DIV;
1331 /* when 0 use minInputPxlClkPLLFrequencyInKHz from firmwareInfo*/
1332 calc_pll_cs_init_data_hdmi.min_override_input_pxl_clk_pll_freq_khz = 13500;
1333 /* when 0 use maxInputPxlClkPLLFrequencyInKHz from firmwareInfo*/
1334 calc_pll_cs_init_data_hdmi.max_override_input_pxl_clk_pll_freq_khz = 27000;
1335 /*numberOfFractFBDividerDecimalPoints*/
1336 calc_pll_cs_init_data_hdmi.num_fract_fb_divider_decimal_point =
1337 FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM;
1338 /*number of decimal point to round off for fractional feedback divider value*/
1339 calc_pll_cs_init_data_hdmi.num_fract_fb_divider_decimal_point_precision =
1340 FRACT_FB_DIVIDER_DEC_POINTS_MAX_NUM;
1341 calc_pll_cs_init_data_hdmi.ctx = ctx;
1343 clk_src->ref_freq_khz = fw_info.pll_info.crystal_frequency;
1345 if (clk_src->base.id == CLOCK_SOURCE_ID_EXTERNAL)
1348 /* PLL only from here on */
1349 ss_info_from_atombios_create(clk_src);
1351 if (!calc_pll_max_vco_construct(
1353 &calc_pll_cs_init_data)) {
1354 ASSERT_CRITICAL(false);
1355 goto unexpected_failure;
1359 calc_pll_cs_init_data_hdmi.
1360 min_override_input_pxl_clk_pll_freq_khz = clk_src->ref_freq_khz/2;
1361 calc_pll_cs_init_data_hdmi.
1362 max_override_input_pxl_clk_pll_freq_khz = clk_src->ref_freq_khz;
1365 if (!calc_pll_max_vco_construct(
1366 &clk_src->calc_pll_hdmi, &calc_pll_cs_init_data_hdmi)) {
1367 ASSERT_CRITICAL(false);
1368 goto unexpected_failure;