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 "include/bios_parser_types.h"
32 #include "../command_table_helper.h"
34 static uint8_t phy_id_to_atom(enum transmitter t)
39 case TRANSMITTER_UNIPHY_A:
40 atom_phy_id = ATOM_PHY_ID_UNIPHYA;
42 case TRANSMITTER_UNIPHY_B:
43 atom_phy_id = ATOM_PHY_ID_UNIPHYB;
45 case TRANSMITTER_UNIPHY_C:
46 atom_phy_id = ATOM_PHY_ID_UNIPHYC;
48 case TRANSMITTER_UNIPHY_D:
49 atom_phy_id = ATOM_PHY_ID_UNIPHYD;
51 case TRANSMITTER_UNIPHY_E:
52 atom_phy_id = ATOM_PHY_ID_UNIPHYE;
54 case TRANSMITTER_UNIPHY_F:
55 atom_phy_id = ATOM_PHY_ID_UNIPHYF;
57 case TRANSMITTER_UNIPHY_G:
58 atom_phy_id = ATOM_PHY_ID_UNIPHYG;
61 atom_phy_id = ATOM_PHY_ID_UNIPHYA;
67 static uint8_t signal_type_to_atom_dig_mode(enum signal_type s)
69 uint8_t atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V5_DP;
72 case SIGNAL_TYPE_DISPLAY_PORT:
74 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V5_DP;
76 case SIGNAL_TYPE_LVDS:
77 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V5_LVDS;
79 case SIGNAL_TYPE_DVI_SINGLE_LINK:
80 case SIGNAL_TYPE_DVI_DUAL_LINK:
81 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V5_DVI;
83 case SIGNAL_TYPE_HDMI_TYPE_A:
84 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V5_HDMI;
86 case SIGNAL_TYPE_DISPLAY_PORT_MST:
87 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V5_DP_MST;
90 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V5_DVI;
97 static uint8_t clock_source_id_to_atom_phy_clk_src_id(
98 enum clock_source_id id)
100 uint8_t atom_phy_clk_src_id = 0;
103 case CLOCK_SOURCE_ID_PLL0:
104 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_P0PLL;
106 case CLOCK_SOURCE_ID_PLL1:
107 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_P1PLL;
109 case CLOCK_SOURCE_ID_PLL2:
110 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_P2PLL;
112 case CLOCK_SOURCE_ID_EXTERNAL:
113 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_REFCLK_SRC_EXT;
116 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_P1PLL;
120 return atom_phy_clk_src_id >> 2;
123 static uint8_t hpd_sel_to_atom(enum hpd_source_id id)
125 uint8_t atom_hpd_sel = 0;
129 atom_hpd_sel = ATOM_TRANSMITTER_CONFIG_V5_HPD1_SEL;
132 atom_hpd_sel = ATOM_TRANSMITTER_CONFIG_V5_HPD2_SEL;
135 atom_hpd_sel = ATOM_TRANSMITTER_CONFIG_V5_HPD3_SEL;
138 atom_hpd_sel = ATOM_TRANSMITTER_CONFIG_V5_HPD4_SEL;
141 atom_hpd_sel = ATOM_TRANSMITTER_CONFIG_V5_HPD5_SEL;
144 atom_hpd_sel = ATOM_TRANSMITTER_CONFIG_V5_HPD6_SEL;
146 case HPD_SOURCEID_UNKNOWN:
151 return atom_hpd_sel >> 4;
154 static uint8_t dig_encoder_sel_to_atom(enum engine_id id)
156 uint8_t atom_dig_encoder_sel = 0;
160 atom_dig_encoder_sel = ATOM_TRANMSITTER_V5__DIGA_SEL;
163 atom_dig_encoder_sel = ATOM_TRANMSITTER_V5__DIGB_SEL;
166 atom_dig_encoder_sel = ATOM_TRANMSITTER_V5__DIGC_SEL;
169 atom_dig_encoder_sel = ATOM_TRANMSITTER_V5__DIGD_SEL;
172 atom_dig_encoder_sel = ATOM_TRANMSITTER_V5__DIGE_SEL;
175 atom_dig_encoder_sel = ATOM_TRANMSITTER_V5__DIGF_SEL;
178 atom_dig_encoder_sel = ATOM_TRANMSITTER_V5__DIGG_SEL;
180 case ENGINE_ID_UNKNOWN:
181 /* No DIG_FRONT is associated to DIG_BACKEND */
182 atom_dig_encoder_sel = 0;
185 atom_dig_encoder_sel = ATOM_TRANMSITTER_V5__DIGA_SEL;
192 static bool clock_source_id_to_atom(
193 enum clock_source_id id,
194 uint32_t *atom_pll_id)
198 if (atom_pll_id != NULL)
200 case CLOCK_SOURCE_ID_PLL0:
201 *atom_pll_id = ATOM_PPLL0;
203 case CLOCK_SOURCE_ID_PLL1:
204 *atom_pll_id = ATOM_PPLL1;
206 case CLOCK_SOURCE_ID_PLL2:
207 *atom_pll_id = ATOM_PPLL2;
209 case CLOCK_SOURCE_ID_EXTERNAL:
210 *atom_pll_id = ATOM_PPLL_INVALID;
212 case CLOCK_SOURCE_ID_DFS:
213 *atom_pll_id = ATOM_EXT_PLL1;
215 case CLOCK_SOURCE_ID_VCE:
217 * we need to pass in ATOM_PPLL_INVALID
219 *atom_pll_id = ATOM_PPLL_INVALID;
221 case CLOCK_SOURCE_ID_DP_DTO:
222 /* When programming DP DTO PLL ID should be invalid */
223 *atom_pll_id = ATOM_PPLL_INVALID;
225 case CLOCK_SOURCE_ID_UNDEFINED:
226 /* Should not happen */
227 *atom_pll_id = ATOM_PPLL_INVALID;
238 static bool engine_bp_to_atom(enum engine_id id, uint32_t *atom_engine_id)
242 if (atom_engine_id != NULL)
245 *atom_engine_id = ASIC_INT_DIG1_ENCODER_ID;
249 *atom_engine_id = ASIC_INT_DIG2_ENCODER_ID;
253 *atom_engine_id = ASIC_INT_DIG3_ENCODER_ID;
257 *atom_engine_id = ASIC_INT_DIG4_ENCODER_ID;
261 *atom_engine_id = ASIC_INT_DIG5_ENCODER_ID;
265 *atom_engine_id = ASIC_INT_DIG6_ENCODER_ID;
269 *atom_engine_id = ASIC_INT_DIG7_ENCODER_ID;
273 *atom_engine_id = ASIC_INT_DAC1_ENCODER_ID;
283 static uint8_t encoder_action_to_atom(enum bp_encoder_control_action action)
285 uint8_t atom_action = 0;
288 case ENCODER_CONTROL_ENABLE:
289 atom_action = ATOM_ENABLE;
291 case ENCODER_CONTROL_DISABLE:
292 atom_action = ATOM_DISABLE;
294 case ENCODER_CONTROL_SETUP:
295 atom_action = ATOM_ENCODER_CMD_SETUP;
297 case ENCODER_CONTROL_INIT:
298 atom_action = ATOM_ENCODER_INIT;
301 BREAK_TO_DEBUGGER(); /* Unhandle action in driver.!! */
308 static uint8_t disp_power_gating_action_to_atom(
309 enum bp_pipe_control_action action)
311 uint8_t atom_pipe_action = 0;
314 case ASIC_PIPE_DISABLE:
315 atom_pipe_action = ATOM_DISABLE;
317 case ASIC_PIPE_ENABLE:
318 atom_pipe_action = ATOM_ENABLE;
321 atom_pipe_action = ATOM_INIT;
324 ASSERT_CRITICAL(false); /* Unhandle action in driver! */
328 return atom_pipe_action;
332 static const struct command_table_helper command_table_helper_funcs = {
333 .controller_id_to_atom = dal_cmd_table_helper_controller_id_to_atom,
334 .encoder_action_to_atom = encoder_action_to_atom,
335 .engine_bp_to_atom = engine_bp_to_atom,
336 .clock_source_id_to_atom = clock_source_id_to_atom,
337 .clock_source_id_to_atom_phy_clk_src_id =
338 clock_source_id_to_atom_phy_clk_src_id,
339 .signal_type_to_atom_dig_mode = signal_type_to_atom_dig_mode,
340 .hpd_sel_to_atom = hpd_sel_to_atom,
341 .dig_encoder_sel_to_atom = dig_encoder_sel_to_atom,
342 .phy_id_to_atom = phy_id_to_atom,
343 .disp_power_gating_action_to_atom = disp_power_gating_action_to_atom,
344 .assign_control_parameter = NULL,
345 .clock_source_id_to_ref_clk_src = NULL,
346 .transmitter_bp_to_atom = NULL,
347 .encoder_id_to_atom = dal_cmd_table_helper_encoder_id_to_atom,
348 .encoder_mode_bp_to_atom = dal_cmd_table_helper_encoder_mode_bp_to_atom,
352 * dal_cmd_tbl_helper_dce110_get_table
355 * Initialize command table helper functions
358 * const struct command_table_helper **h - [out] struct of functions
361 const struct command_table_helper *dal_cmd_tbl_helper_dce110_get_table(void)
363 return &command_table_helper_funcs;