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"
29 #include "atomfirmware.h"
31 #include "include/bios_parser_interface.h"
33 #include "command_table2.h"
34 #include "command_table_helper2.h"
35 #include "bios_parser_helper.h"
36 #include "bios_parser_types_internal2.h"
40 #define GET_INDEX_INTO_MASTER_TABLE(MasterOrData, FieldName)\
42 struct atom_master_list_of_##MasterOrData##_functions_v2_1 *)0)\
43 ->FieldName)-(char *)0)/sizeof(uint16_t))
45 #define EXEC_BIOS_CMD_TABLE(fname, params)\
46 (cgs_atom_exec_cmd_table(bp->base.ctx->cgs_device, \
47 GET_INDEX_INTO_MASTER_TABLE(command, fname), \
50 #define BIOS_CMD_TABLE_REVISION(fname, frev, crev)\
51 cgs_atom_get_cmd_table_revs(bp->base.ctx->cgs_device, \
52 GET_INDEX_INTO_MASTER_TABLE(command, fname), &frev, &crev)
54 #define BIOS_CMD_TABLE_PARA_REVISION(fname)\
55 bios_cmd_table_para_revision(bp->base.ctx->cgs_device, \
56 GET_INDEX_INTO_MASTER_TABLE(command, fname))
58 static void init_dig_encoder_control(struct bios_parser *bp);
59 static void init_transmitter_control(struct bios_parser *bp);
60 static void init_set_pixel_clock(struct bios_parser *bp);
62 static void init_set_crtc_timing(struct bios_parser *bp);
64 static void init_select_crtc_source(struct bios_parser *bp);
65 static void init_enable_crtc(struct bios_parser *bp);
67 static void init_external_encoder_control(struct bios_parser *bp);
68 static void init_enable_disp_power_gating(struct bios_parser *bp);
69 static void init_set_dce_clock(struct bios_parser *bp);
70 static void init_get_smu_clock_info(struct bios_parser *bp);
72 void dal_firmware_parser_init_cmd_tbl(struct bios_parser *bp)
74 init_dig_encoder_control(bp);
75 init_transmitter_control(bp);
76 init_set_pixel_clock(bp);
78 init_set_crtc_timing(bp);
80 init_select_crtc_source(bp);
83 init_external_encoder_control(bp);
84 init_enable_disp_power_gating(bp);
85 init_set_dce_clock(bp);
86 init_get_smu_clock_info(bp);
89 static uint32_t bios_cmd_table_para_revision(void *cgs_device,
94 if (cgs_atom_get_cmd_table_revs(cgs_device,
101 /******************************************************************************
102 ******************************************************************************
104 ** D I G E N C O D E R C O N T R O L
106 ******************************************************************************
107 *****************************************************************************/
109 static enum bp_result encoder_control_digx_v1_5(
110 struct bios_parser *bp,
111 struct bp_encoder_control *cntl);
113 static void init_dig_encoder_control(struct bios_parser *bp)
116 BIOS_CMD_TABLE_PARA_REVISION(digxencodercontrol);
120 bp->cmd_tbl.dig_encoder_control = encoder_control_digx_v1_5;
123 dm_output_to_console("Don't have dig_encoder_control for v%d\n", version);
124 bp->cmd_tbl.dig_encoder_control = NULL;
129 static enum bp_result encoder_control_digx_v1_5(
130 struct bios_parser *bp,
131 struct bp_encoder_control *cntl)
133 enum bp_result result = BP_RESULT_FAILURE;
134 struct dig_encoder_stream_setup_parameters_v1_5 params = {0};
136 params.digid = (uint8_t)(cntl->engine_id);
137 params.action = bp->cmd_helper->encoder_action_to_atom(cntl->action);
139 params.pclk_10khz = cntl->pixel_clock / 10;
141 (uint8_t)(bp->cmd_helper->encoder_mode_bp_to_atom(
143 cntl->enable_dp_audio));
144 params.lanenum = (uint8_t)(cntl->lanes_number);
146 switch (cntl->color_depth) {
147 case COLOR_DEPTH_888:
148 params.bitpercolor = PANEL_8BIT_PER_COLOR;
150 case COLOR_DEPTH_101010:
151 params.bitpercolor = PANEL_10BIT_PER_COLOR;
153 case COLOR_DEPTH_121212:
154 params.bitpercolor = PANEL_12BIT_PER_COLOR;
156 case COLOR_DEPTH_161616:
157 params.bitpercolor = PANEL_16BIT_PER_COLOR;
163 if (cntl->signal == SIGNAL_TYPE_HDMI_TYPE_A)
164 switch (cntl->color_depth) {
165 case COLOR_DEPTH_101010:
167 (params.pclk_10khz * 30) / 24;
169 case COLOR_DEPTH_121212:
171 (params.pclk_10khz * 36) / 24;
173 case COLOR_DEPTH_161616:
175 (params.pclk_10khz * 48) / 24;
181 if (EXEC_BIOS_CMD_TABLE(digxencodercontrol, params))
182 result = BP_RESULT_OK;
187 /*****************************************************************************
188 ******************************************************************************
190 ** TRANSMITTER CONTROL
192 ******************************************************************************
193 *****************************************************************************/
195 static enum bp_result transmitter_control_v1_6(
196 struct bios_parser *bp,
197 struct bp_transmitter_control *cntl);
199 static void init_transmitter_control(struct bios_parser *bp)
204 if (BIOS_CMD_TABLE_REVISION(dig1transmittercontrol, frev, crev) != 0)
208 bp->cmd_tbl.transmitter_control = transmitter_control_v1_6;
211 dm_output_to_console("Don't have transmitter_control for v%d\n", crev);
212 bp->cmd_tbl.transmitter_control = NULL;
217 static enum bp_result transmitter_control_v1_6(
218 struct bios_parser *bp,
219 struct bp_transmitter_control *cntl)
221 enum bp_result result = BP_RESULT_FAILURE;
222 const struct command_table_helper *cmd = bp->cmd_helper;
223 struct dig_transmitter_control_ps_allocation_v1_6 ps = { { 0 } };
225 ps.param.phyid = cmd->phy_id_to_atom(cntl->transmitter);
226 ps.param.action = (uint8_t)cntl->action;
228 if (cntl->action == TRANSMITTER_CONTROL_SET_VOLTAGE_AND_PREEMPASIS)
229 ps.param.mode_laneset.dplaneset = (uint8_t)cntl->lane_settings;
231 ps.param.mode_laneset.digmode =
232 cmd->signal_type_to_atom_dig_mode(cntl->signal);
234 ps.param.lanenum = (uint8_t)cntl->lanes_number;
235 ps.param.hpdsel = cmd->hpd_sel_to_atom(cntl->hpd_sel);
236 ps.param.digfe_sel = cmd->dig_encoder_sel_to_atom(cntl->engine_id);
237 ps.param.connobj_id = (uint8_t)cntl->connector_obj_id.id;
238 ps.param.symclk_10khz = cntl->pixel_clock/10;
241 if (cntl->action == TRANSMITTER_CONTROL_ENABLE ||
242 cntl->action == TRANSMITTER_CONTROL_ACTIAVATE ||
243 cntl->action == TRANSMITTER_CONTROL_DEACTIVATE) {
244 DC_LOG_BIOS("%s:ps.param.symclk_10khz = %d\n",\
245 __func__, ps.param.symclk_10khz);
249 /*color_depth not used any more, driver has deep color factor in the Phyclk*/
250 if (EXEC_BIOS_CMD_TABLE(dig1transmittercontrol, ps))
251 result = BP_RESULT_OK;
255 /******************************************************************************
256 ******************************************************************************
260 ******************************************************************************
261 *****************************************************************************/
263 static enum bp_result set_pixel_clock_v7(
264 struct bios_parser *bp,
265 struct bp_pixel_clock_parameters *bp_params);
267 static void init_set_pixel_clock(struct bios_parser *bp)
269 switch (BIOS_CMD_TABLE_PARA_REVISION(setpixelclock)) {
271 bp->cmd_tbl.set_pixel_clock = set_pixel_clock_v7;
274 dm_output_to_console("Don't have set_pixel_clock for v%d\n",
275 BIOS_CMD_TABLE_PARA_REVISION(setpixelclock));
276 bp->cmd_tbl.set_pixel_clock = NULL;
283 static enum bp_result set_pixel_clock_v7(
284 struct bios_parser *bp,
285 struct bp_pixel_clock_parameters *bp_params)
287 enum bp_result result = BP_RESULT_FAILURE;
288 struct set_pixel_clock_parameter_v1_7 clk;
289 uint8_t controller_id;
292 memset(&clk, 0, sizeof(clk));
294 if (bp->cmd_helper->clock_source_id_to_atom(bp_params->pll_id, &pll_id)
295 && bp->cmd_helper->controller_id_to_atom(bp_params->
296 controller_id, &controller_id)) {
297 /* Note: VBIOS still wants to use ucCRTC name which is now
299 *typedef struct _CRTC_PIXEL_CLOCK_FREQ
301 * target the pixel clock to drive the CRTC timing.
302 * ULONG ulPixelClock:24;
303 * 0 means disable PPLL/DCPLL. Expanded to 24 bits comparing to
305 * ATOM_CRTC1~6, indicate the CRTC controller to
307 * drive the pixel clock. not used for DCPLL case.
308 *}CRTC_PIXEL_CLOCK_FREQ;
311 * pixel clock and CRTC id frequency
312 * CRTC_PIXEL_CLOCK_FREQ ulCrtcPclkFreq;
313 * ULONG ulDispEngClkFreq; dispclk frequency
316 clk.crtc_id = controller_id;
317 clk.pll_id = (uint8_t) pll_id;
319 bp->cmd_helper->encoder_id_to_atom(
320 dal_graphics_object_id_get_encoder_id(
321 bp_params->encoder_object_id));
323 clk.encoder_mode = (uint8_t) bp->
324 cmd_helper->encoder_mode_bp_to_atom(
325 bp_params->signal_type, false);
327 /* We need to convert from KHz units into 10KHz units */
328 clk.pixclk_100hz = cpu_to_le32(bp_params->target_pixel_clock *
331 clk.deep_color_ratio =
332 (uint8_t) bp->cmd_helper->
333 transmitter_color_depth_to_atom(
334 bp_params->color_depth);
335 DC_LOG_BIOS("%s:program display clock = %d"\
336 "colorDepth = %d\n", __func__,\
337 bp_params->target_pixel_clock, bp_params->color_depth);
339 if (bp_params->flags.FORCE_PROGRAMMING_OF_PLL)
340 clk.miscinfo |= PIXEL_CLOCK_V7_MISC_FORCE_PROG_PPLL;
342 if (bp_params->flags.PROGRAM_PHY_PLL_ONLY)
343 clk.miscinfo |= PIXEL_CLOCK_V7_MISC_PROG_PHYPLL;
345 if (bp_params->flags.SUPPORT_YUV_420)
346 clk.miscinfo |= PIXEL_CLOCK_V7_MISC_YUV420_MODE;
348 if (bp_params->flags.SET_XTALIN_REF_SRC)
349 clk.miscinfo |= PIXEL_CLOCK_V7_MISC_REF_DIV_SRC_XTALIN;
351 if (bp_params->flags.SET_GENLOCK_REF_DIV_SRC)
352 clk.miscinfo |= PIXEL_CLOCK_V7_MISC_REF_DIV_SRC_GENLK;
354 if (bp_params->signal_type == SIGNAL_TYPE_DVI_DUAL_LINK)
355 clk.miscinfo |= PIXEL_CLOCK_V7_MISC_DVI_DUALLINK_EN;
357 if (EXEC_BIOS_CMD_TABLE(setpixelclock, clk))
358 result = BP_RESULT_OK;
363 /******************************************************************************
364 ******************************************************************************
368 ******************************************************************************
369 *****************************************************************************/
371 static enum bp_result set_crtc_using_dtd_timing_v3(
372 struct bios_parser *bp,
373 struct bp_hw_crtc_timing_parameters *bp_params);
375 static void init_set_crtc_timing(struct bios_parser *bp)
377 uint32_t dtd_version =
378 BIOS_CMD_TABLE_PARA_REVISION(setcrtc_usingdtdtiming);
380 switch (dtd_version) {
382 bp->cmd_tbl.set_crtc_timing =
383 set_crtc_using_dtd_timing_v3;
386 dm_output_to_console("Don't have set_crtc_timing for v%d\n", dtd_version);
387 bp->cmd_tbl.set_crtc_timing = NULL;
392 static enum bp_result set_crtc_using_dtd_timing_v3(
393 struct bios_parser *bp,
394 struct bp_hw_crtc_timing_parameters *bp_params)
396 enum bp_result result = BP_RESULT_FAILURE;
397 struct set_crtc_using_dtd_timing_parameters params = {0};
398 uint8_t atom_controller_id;
400 if (bp->cmd_helper->controller_id_to_atom(
401 bp_params->controller_id, &atom_controller_id))
402 params.crtc_id = atom_controller_id;
404 /* bios usH_Size wants h addressable size */
405 params.h_size = cpu_to_le16((uint16_t)bp_params->h_addressable);
406 /* bios usH_Blanking_Time wants borders included in blanking */
407 params.h_blanking_time =
408 cpu_to_le16((uint16_t)(bp_params->h_total -
409 bp_params->h_addressable));
410 /* bios usV_Size wants v addressable size */
411 params.v_size = cpu_to_le16((uint16_t)bp_params->v_addressable);
412 /* bios usV_Blanking_Time wants borders included in blanking */
413 params.v_blanking_time =
414 cpu_to_le16((uint16_t)(bp_params->v_total -
415 bp_params->v_addressable));
416 /* bios usHSyncOffset is the offset from the end of h addressable,
417 * our horizontalSyncStart is the offset from the beginning
420 params.h_syncoffset =
421 cpu_to_le16((uint16_t)(bp_params->h_sync_start -
422 bp_params->h_addressable));
423 params.h_syncwidth = cpu_to_le16((uint16_t)bp_params->h_sync_width);
424 /* bios usHSyncOffset is the offset from the end of v addressable,
425 * our verticalSyncStart is the offset from the beginning of
428 params.v_syncoffset =
429 cpu_to_le16((uint16_t)(bp_params->v_sync_start -
430 bp_params->v_addressable));
431 params.v_syncwidth = cpu_to_le16((uint16_t)bp_params->v_sync_width);
433 /* we assume that overscan from original timing does not get bigger
435 * we will program all the borders in the Set CRTC Overscan call below
438 if (bp_params->flags.HSYNC_POSITIVE_POLARITY == 0)
439 params.modemiscinfo =
440 cpu_to_le16(le16_to_cpu(params.modemiscinfo) |
441 ATOM_HSYNC_POLARITY);
443 if (bp_params->flags.VSYNC_POSITIVE_POLARITY == 0)
444 params.modemiscinfo =
445 cpu_to_le16(le16_to_cpu(params.modemiscinfo) |
446 ATOM_VSYNC_POLARITY);
448 if (bp_params->flags.INTERLACE) {
449 params.modemiscinfo =
450 cpu_to_le16(le16_to_cpu(params.modemiscinfo) |
453 /* original DAL code has this condition to apply this
455 * due to complex MV testing for possible impact
456 * if ( pACParameters->signal != SignalType_YPbPr &&
457 * pACParameters->signal != SignalType_Composite &&
458 * pACParameters->signal != SignalType_SVideo)
461 /* HW will deduct 0.5 line from 2nd feild.
462 * i.e. for 1080i, it is 2 lines for 1st field,
463 * 2.5 lines for the 2nd feild. we need input as 5
465 * but it is 4 either from Edid data (spec CEA 861)
466 * or CEA timing table.
468 params.v_syncoffset =
469 cpu_to_le16(le16_to_cpu(params.v_syncoffset) +
475 if (bp_params->flags.HORZ_COUNT_BY_TWO)
476 params.modemiscinfo =
477 cpu_to_le16(le16_to_cpu(params.modemiscinfo) |
478 0x100); /* ATOM_DOUBLE_CLOCK_MODE */
480 if (EXEC_BIOS_CMD_TABLE(setcrtc_usingdtdtiming, params))
481 result = BP_RESULT_OK;
486 /******************************************************************************
487 ******************************************************************************
489 ** SELECT CRTC SOURCE
491 ******************************************************************************
492 *****************************************************************************/
495 static enum bp_result select_crtc_source_v3(
496 struct bios_parser *bp,
497 struct bp_crtc_source_select *bp_params);
499 static void init_select_crtc_source(struct bios_parser *bp)
501 switch (BIOS_CMD_TABLE_PARA_REVISION(selectcrtc_source)) {
503 bp->cmd_tbl.select_crtc_source = select_crtc_source_v3;
506 dm_output_to_console("Don't select_crtc_source enable_crtc for v%d\n",
507 BIOS_CMD_TABLE_PARA_REVISION(selectcrtc_source));
508 bp->cmd_tbl.select_crtc_source = NULL;
514 static enum bp_result select_crtc_source_v3(
515 struct bios_parser *bp,
516 struct bp_crtc_source_select *bp_params)
518 bool result = BP_RESULT_FAILURE;
519 struct select_crtc_source_parameters_v2_3 params;
520 uint8_t atom_controller_id;
521 uint32_t atom_engine_id;
522 enum signal_type s = bp_params->signal;
524 memset(¶ms, 0, sizeof(params));
526 if (bp->cmd_helper->controller_id_to_atom(bp_params->controller_id,
527 &atom_controller_id))
528 params.crtc_id = atom_controller_id;
532 if (bp->cmd_helper->engine_bp_to_atom(bp_params->engine_id,
534 params.encoder_id = (uint8_t)atom_engine_id;
538 if (s == SIGNAL_TYPE_EDP ||
539 (s == SIGNAL_TYPE_DISPLAY_PORT && bp_params->sink_signal ==
541 s = SIGNAL_TYPE_LVDS;
544 bp->cmd_helper->encoder_mode_bp_to_atom(
545 s, bp_params->enable_dp_audio);
546 /* Needed for VBIOS Random Spatial Dithering feature */
547 params.dst_bpc = (uint8_t)(bp_params->display_output_bit_depth);
549 if (EXEC_BIOS_CMD_TABLE(selectcrtc_source, params))
550 result = BP_RESULT_OK;
555 /******************************************************************************
556 ******************************************************************************
560 ******************************************************************************
561 *****************************************************************************/
563 static enum bp_result enable_crtc_v1(
564 struct bios_parser *bp,
565 enum controller_id controller_id,
568 static void init_enable_crtc(struct bios_parser *bp)
570 switch (BIOS_CMD_TABLE_PARA_REVISION(enablecrtc)) {
572 bp->cmd_tbl.enable_crtc = enable_crtc_v1;
575 dm_output_to_console("Don't have enable_crtc for v%d\n",
576 BIOS_CMD_TABLE_PARA_REVISION(enablecrtc));
577 bp->cmd_tbl.enable_crtc = NULL;
582 static enum bp_result enable_crtc_v1(
583 struct bios_parser *bp,
584 enum controller_id controller_id,
587 bool result = BP_RESULT_FAILURE;
588 struct enable_crtc_parameters params = {0};
591 if (bp->cmd_helper->controller_id_to_atom(controller_id, &id))
594 return BP_RESULT_BADINPUT;
597 params.enable = ATOM_ENABLE;
599 params.enable = ATOM_DISABLE;
601 if (EXEC_BIOS_CMD_TABLE(enablecrtc, params))
602 result = BP_RESULT_OK;
607 /******************************************************************************
608 ******************************************************************************
612 ******************************************************************************
613 *****************************************************************************/
617 /******************************************************************************
618 ******************************************************************************
620 ** EXTERNAL ENCODER CONTROL
622 ******************************************************************************
623 *****************************************************************************/
625 static enum bp_result external_encoder_control_v3(
626 struct bios_parser *bp,
627 struct bp_external_encoder_control *cntl);
629 static void init_external_encoder_control(
630 struct bios_parser *bp)
632 switch (BIOS_CMD_TABLE_PARA_REVISION(externalencodercontrol)) {
634 bp->cmd_tbl.external_encoder_control =
635 external_encoder_control_v3;
638 bp->cmd_tbl.external_encoder_control = NULL;
643 static enum bp_result external_encoder_control_v3(
644 struct bios_parser *bp,
645 struct bp_external_encoder_control *cntl)
651 /******************************************************************************
652 ******************************************************************************
654 ** ENABLE DISPLAY POWER GATING
656 ******************************************************************************
657 *****************************************************************************/
659 static enum bp_result enable_disp_power_gating_v2_1(
660 struct bios_parser *bp,
661 enum controller_id crtc_id,
662 enum bp_pipe_control_action action);
664 static void init_enable_disp_power_gating(
665 struct bios_parser *bp)
667 switch (BIOS_CMD_TABLE_PARA_REVISION(enabledisppowergating)) {
669 bp->cmd_tbl.enable_disp_power_gating =
670 enable_disp_power_gating_v2_1;
673 dm_output_to_console("Don't enable_disp_power_gating enable_crtc for v%d\n",
674 BIOS_CMD_TABLE_PARA_REVISION(enabledisppowergating));
675 bp->cmd_tbl.enable_disp_power_gating = NULL;
680 static enum bp_result enable_disp_power_gating_v2_1(
681 struct bios_parser *bp,
682 enum controller_id crtc_id,
683 enum bp_pipe_control_action action)
685 enum bp_result result = BP_RESULT_FAILURE;
688 struct enable_disp_power_gating_ps_allocation ps = { { 0 } };
689 uint8_t atom_crtc_id;
691 if (bp->cmd_helper->controller_id_to_atom(crtc_id, &atom_crtc_id))
692 ps.param.disp_pipe_id = atom_crtc_id;
694 return BP_RESULT_BADINPUT;
697 bp->cmd_helper->disp_power_gating_action_to_atom(action);
699 if (EXEC_BIOS_CMD_TABLE(enabledisppowergating, ps.param))
700 result = BP_RESULT_OK;
705 /******************************************************************************
706 *******************************************************************************
710 *******************************************************************************
711 *******************************************************************************/
713 static enum bp_result set_dce_clock_v2_1(
714 struct bios_parser *bp,
715 struct bp_set_dce_clock_parameters *bp_params);
717 static void init_set_dce_clock(struct bios_parser *bp)
719 switch (BIOS_CMD_TABLE_PARA_REVISION(setdceclock)) {
721 bp->cmd_tbl.set_dce_clock = set_dce_clock_v2_1;
724 dm_output_to_console("Don't have set_dce_clock for v%d\n",
725 BIOS_CMD_TABLE_PARA_REVISION(setdceclock));
726 bp->cmd_tbl.set_dce_clock = NULL;
731 static enum bp_result set_dce_clock_v2_1(
732 struct bios_parser *bp,
733 struct bp_set_dce_clock_parameters *bp_params)
735 enum bp_result result = BP_RESULT_FAILURE;
737 struct set_dce_clock_ps_allocation_v2_1 params;
738 uint32_t atom_pll_id;
739 uint32_t atom_clock_type;
740 const struct command_table_helper *cmd = bp->cmd_helper;
742 memset(¶ms, 0, sizeof(params));
744 if (!cmd->clock_source_id_to_atom(bp_params->pll_id, &atom_pll_id) ||
745 !cmd->dc_clock_type_to_atom(bp_params->clock_type,
747 return BP_RESULT_BADINPUT;
749 params.param.dceclksrc = atom_pll_id;
750 params.param.dceclktype = atom_clock_type;
752 if (bp_params->clock_type == DCECLOCK_TYPE_DPREFCLK) {
753 if (bp_params->flags.USE_GENLOCK_AS_SOURCE_FOR_DPREFCLK)
754 params.param.dceclkflag |=
755 DCE_CLOCK_FLAG_PLL_REFCLK_SRC_GENLK;
757 if (bp_params->flags.USE_PCIE_AS_SOURCE_FOR_DPREFCLK)
758 params.param.dceclkflag |=
759 DCE_CLOCK_FLAG_PLL_REFCLK_SRC_PCIE;
761 if (bp_params->flags.USE_XTALIN_AS_SOURCE_FOR_DPREFCLK)
762 params.param.dceclkflag |=
763 DCE_CLOCK_FLAG_PLL_REFCLK_SRC_XTALIN;
765 if (bp_params->flags.USE_GENERICA_AS_SOURCE_FOR_DPREFCLK)
766 params.param.dceclkflag |=
767 DCE_CLOCK_FLAG_PLL_REFCLK_SRC_GENERICA;
769 /* only program clock frequency if display clock is used;
770 * VBIOS will program DPREFCLK
771 * We need to convert from KHz units into 10KHz units
773 params.param.dceclk_10khz = cpu_to_le32(
774 bp_params->target_clock_frequency / 10);
775 DC_LOG_BIOS("%s:target_clock_frequency = %d"\
776 "clock_type = %d \n", __func__,\
777 bp_params->target_clock_frequency,\
778 bp_params->clock_type);
780 if (EXEC_BIOS_CMD_TABLE(setdceclock, params)) {
781 /* Convert from 10KHz units back to KHz */
782 bp_params->target_clock_frequency = le32_to_cpu(
783 params.param.dceclk_10khz) * 10;
784 result = BP_RESULT_OK;
791 /******************************************************************************
792 ******************************************************************************
794 ** GET SMU CLOCK INFO
796 ******************************************************************************
797 *****************************************************************************/
799 static unsigned int get_smu_clock_info_v3_1(struct bios_parser *bp);
801 static void init_get_smu_clock_info(struct bios_parser *bp)
803 /* TODO add switch for table vrsion */
804 bp->cmd_tbl.get_smu_clock_info = get_smu_clock_info_v3_1;
808 static unsigned int get_smu_clock_info_v3_1(struct bios_parser *bp)
810 struct atom_get_smu_clock_info_parameters_v3_1 smu_input = {0};
811 struct atom_get_smu_clock_info_output_parameters_v3_1 smu_output;
813 smu_input.command = GET_SMU_CLOCK_INFO_V3_1_GET_PLLVCO_FREQ;
815 /* Get Specific Clock */
816 if (EXEC_BIOS_CMD_TABLE(getsmuclockinfo, smu_input)) {
817 memmove(&smu_output, &smu_input, sizeof(
818 struct atom_get_smu_clock_info_parameters_v3_1));
819 return smu_output.atom_smu_outputclkfreq.syspllvcofreq_10khz;