1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev * Copyright 2012-15 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev *
4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a
5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"),
6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation
7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the
9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions:
10*b843c749SSergey Zigachev *
11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in
12*b843c749SSergey Zigachev * all copies or substantial portions of the Software.
13*b843c749SSergey Zigachev *
14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE.
21*b843c749SSergey Zigachev *
22*b843c749SSergey Zigachev * Authors: AMD
23*b843c749SSergey Zigachev *
24*b843c749SSergey Zigachev */
25*b843c749SSergey Zigachev
26*b843c749SSergey Zigachev #include "reg_helper.h"
27*b843c749SSergey Zigachev
28*b843c749SSergey Zigachev #include "core_types.h"
29*b843c749SSergey Zigachev #include "link_encoder.h"
30*b843c749SSergey Zigachev #include "dce_link_encoder.h"
31*b843c749SSergey Zigachev #include "stream_encoder.h"
32*b843c749SSergey Zigachev #include "i2caux_interface.h"
33*b843c749SSergey Zigachev #include "dc_bios_types.h"
34*b843c749SSergey Zigachev
35*b843c749SSergey Zigachev #include "gpio_service_interface.h"
36*b843c749SSergey Zigachev
37*b843c749SSergey Zigachev #include "dce/dce_11_0_d.h"
38*b843c749SSergey Zigachev #include "dce/dce_11_0_sh_mask.h"
39*b843c749SSergey Zigachev #include "dce/dce_11_0_enum.h"
40*b843c749SSergey Zigachev
41*b843c749SSergey Zigachev #ifndef DMU_MEM_PWR_CNTL__DMCU_IRAM_MEM_PWR_STATE__SHIFT
42*b843c749SSergey Zigachev #define DMU_MEM_PWR_CNTL__DMCU_IRAM_MEM_PWR_STATE__SHIFT 0xa
43*b843c749SSergey Zigachev #endif
44*b843c749SSergey Zigachev
45*b843c749SSergey Zigachev #ifndef DMU_MEM_PWR_CNTL__DMCU_IRAM_MEM_PWR_STATE_MASK
46*b843c749SSergey Zigachev #define DMU_MEM_PWR_CNTL__DMCU_IRAM_MEM_PWR_STATE_MASK 0x00000400L
47*b843c749SSergey Zigachev #endif
48*b843c749SSergey Zigachev
49*b843c749SSergey Zigachev #ifndef HPD0_DC_HPD_CONTROL__DC_HPD_EN_MASK
50*b843c749SSergey Zigachev #define HPD0_DC_HPD_CONTROL__DC_HPD_EN_MASK 0x10000000L
51*b843c749SSergey Zigachev #endif
52*b843c749SSergey Zigachev
53*b843c749SSergey Zigachev #ifndef HPD0_DC_HPD_CONTROL__DC_HPD_EN__SHIFT
54*b843c749SSergey Zigachev #define HPD0_DC_HPD_CONTROL__DC_HPD_EN__SHIFT 0x1c
55*b843c749SSergey Zigachev #endif
56*b843c749SSergey Zigachev
57*b843c749SSergey Zigachev #define CTX \
58*b843c749SSergey Zigachev enc110->base.ctx
59*b843c749SSergey Zigachev #define DC_LOGGER \
60*b843c749SSergey Zigachev enc110->base.ctx->logger
61*b843c749SSergey Zigachev
62*b843c749SSergey Zigachev #define REG(reg)\
63*b843c749SSergey Zigachev (enc110->link_regs->reg)
64*b843c749SSergey Zigachev
65*b843c749SSergey Zigachev #define AUX_REG(reg)\
66*b843c749SSergey Zigachev (enc110->aux_regs->reg)
67*b843c749SSergey Zigachev
68*b843c749SSergey Zigachev #define HPD_REG(reg)\
69*b843c749SSergey Zigachev (enc110->hpd_regs->reg)
70*b843c749SSergey Zigachev
71*b843c749SSergey Zigachev #define DEFAULT_AUX_MAX_DATA_SIZE 16
72*b843c749SSergey Zigachev #define AUX_MAX_DEFER_WRITE_RETRY 20
73*b843c749SSergey Zigachev /*
74*b843c749SSergey Zigachev * @brief
75*b843c749SSergey Zigachev * Trigger Source Select
76*b843c749SSergey Zigachev * ASIC-dependent, actual values for register programming
77*b843c749SSergey Zigachev */
78*b843c749SSergey Zigachev #define DCE110_DIG_FE_SOURCE_SELECT_INVALID 0x0
79*b843c749SSergey Zigachev #define DCE110_DIG_FE_SOURCE_SELECT_DIGA 0x1
80*b843c749SSergey Zigachev #define DCE110_DIG_FE_SOURCE_SELECT_DIGB 0x2
81*b843c749SSergey Zigachev #define DCE110_DIG_FE_SOURCE_SELECT_DIGC 0x4
82*b843c749SSergey Zigachev #define DCE110_DIG_FE_SOURCE_SELECT_DIGD 0x08
83*b843c749SSergey Zigachev #define DCE110_DIG_FE_SOURCE_SELECT_DIGE 0x10
84*b843c749SSergey Zigachev #define DCE110_DIG_FE_SOURCE_SELECT_DIGF 0x20
85*b843c749SSergey Zigachev #define DCE110_DIG_FE_SOURCE_SELECT_DIGG 0x40
86*b843c749SSergey Zigachev
87*b843c749SSergey Zigachev enum {
88*b843c749SSergey Zigachev DP_MST_UPDATE_MAX_RETRY = 50
89*b843c749SSergey Zigachev };
90*b843c749SSergey Zigachev
91*b843c749SSergey Zigachev #define DIG_REG(reg)\
92*b843c749SSergey Zigachev (reg + enc110->offsets.dig)
93*b843c749SSergey Zigachev
94*b843c749SSergey Zigachev #define DP_REG(reg)\
95*b843c749SSergey Zigachev (reg + enc110->offsets.dp)
96*b843c749SSergey Zigachev
97*b843c749SSergey Zigachev static const struct link_encoder_funcs dce110_lnk_enc_funcs = {
98*b843c749SSergey Zigachev .validate_output_with_stream =
99*b843c749SSergey Zigachev dce110_link_encoder_validate_output_with_stream,
100*b843c749SSergey Zigachev .hw_init = dce110_link_encoder_hw_init,
101*b843c749SSergey Zigachev .setup = dce110_link_encoder_setup,
102*b843c749SSergey Zigachev .enable_tmds_output = dce110_link_encoder_enable_tmds_output,
103*b843c749SSergey Zigachev .enable_dp_output = dce110_link_encoder_enable_dp_output,
104*b843c749SSergey Zigachev .enable_dp_mst_output = dce110_link_encoder_enable_dp_mst_output,
105*b843c749SSergey Zigachev .disable_output = dce110_link_encoder_disable_output,
106*b843c749SSergey Zigachev .dp_set_lane_settings = dce110_link_encoder_dp_set_lane_settings,
107*b843c749SSergey Zigachev .dp_set_phy_pattern = dce110_link_encoder_dp_set_phy_pattern,
108*b843c749SSergey Zigachev .update_mst_stream_allocation_table =
109*b843c749SSergey Zigachev dce110_link_encoder_update_mst_stream_allocation_table,
110*b843c749SSergey Zigachev .psr_program_dp_dphy_fast_training =
111*b843c749SSergey Zigachev dce110_psr_program_dp_dphy_fast_training,
112*b843c749SSergey Zigachev .psr_program_secondary_packet = dce110_psr_program_secondary_packet,
113*b843c749SSergey Zigachev .connect_dig_be_to_fe = dce110_link_encoder_connect_dig_be_to_fe,
114*b843c749SSergey Zigachev .enable_hpd = dce110_link_encoder_enable_hpd,
115*b843c749SSergey Zigachev .disable_hpd = dce110_link_encoder_disable_hpd,
116*b843c749SSergey Zigachev .is_dig_enabled = dce110_is_dig_enabled,
117*b843c749SSergey Zigachev .destroy = dce110_link_encoder_destroy
118*b843c749SSergey Zigachev };
119*b843c749SSergey Zigachev
link_transmitter_control(struct dce110_link_encoder * enc110,struct bp_transmitter_control * cntl)120*b843c749SSergey Zigachev static enum bp_result link_transmitter_control(
121*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
122*b843c749SSergey Zigachev struct bp_transmitter_control *cntl)
123*b843c749SSergey Zigachev {
124*b843c749SSergey Zigachev enum bp_result result;
125*b843c749SSergey Zigachev struct dc_bios *bp = enc110->base.ctx->dc_bios;
126*b843c749SSergey Zigachev
127*b843c749SSergey Zigachev result = bp->funcs->transmitter_control(bp, cntl);
128*b843c749SSergey Zigachev
129*b843c749SSergey Zigachev return result;
130*b843c749SSergey Zigachev }
131*b843c749SSergey Zigachev
enable_phy_bypass_mode(struct dce110_link_encoder * enc110,bool enable)132*b843c749SSergey Zigachev static void enable_phy_bypass_mode(
133*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
134*b843c749SSergey Zigachev bool enable)
135*b843c749SSergey Zigachev {
136*b843c749SSergey Zigachev /* This register resides in DP back end block;
137*b843c749SSergey Zigachev * transmitter is used for the offset */
138*b843c749SSergey Zigachev
139*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_CNTL, DPHY_BYPASS, enable);
140*b843c749SSergey Zigachev
141*b843c749SSergey Zigachev }
142*b843c749SSergey Zigachev
disable_prbs_symbols(struct dce110_link_encoder * enc110,bool disable)143*b843c749SSergey Zigachev static void disable_prbs_symbols(
144*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
145*b843c749SSergey Zigachev bool disable)
146*b843c749SSergey Zigachev {
147*b843c749SSergey Zigachev /* This register resides in DP back end block;
148*b843c749SSergey Zigachev * transmitter is used for the offset */
149*b843c749SSergey Zigachev
150*b843c749SSergey Zigachev REG_UPDATE_4(DP_DPHY_CNTL,
151*b843c749SSergey Zigachev DPHY_ATEST_SEL_LANE0, disable,
152*b843c749SSergey Zigachev DPHY_ATEST_SEL_LANE1, disable,
153*b843c749SSergey Zigachev DPHY_ATEST_SEL_LANE2, disable,
154*b843c749SSergey Zigachev DPHY_ATEST_SEL_LANE3, disable);
155*b843c749SSergey Zigachev }
156*b843c749SSergey Zigachev
disable_prbs_mode(struct dce110_link_encoder * enc110)157*b843c749SSergey Zigachev static void disable_prbs_mode(
158*b843c749SSergey Zigachev struct dce110_link_encoder *enc110)
159*b843c749SSergey Zigachev {
160*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_PRBS_CNTL, DPHY_PRBS_EN, 0);
161*b843c749SSergey Zigachev }
162*b843c749SSergey Zigachev
program_pattern_symbols(struct dce110_link_encoder * enc110,uint16_t pattern_symbols[8])163*b843c749SSergey Zigachev static void program_pattern_symbols(
164*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
165*b843c749SSergey Zigachev uint16_t pattern_symbols[8])
166*b843c749SSergey Zigachev {
167*b843c749SSergey Zigachev /* This register resides in DP back end block;
168*b843c749SSergey Zigachev * transmitter is used for the offset */
169*b843c749SSergey Zigachev
170*b843c749SSergey Zigachev REG_SET_3(DP_DPHY_SYM0, 0,
171*b843c749SSergey Zigachev DPHY_SYM1, pattern_symbols[0],
172*b843c749SSergey Zigachev DPHY_SYM2, pattern_symbols[1],
173*b843c749SSergey Zigachev DPHY_SYM3, pattern_symbols[2]);
174*b843c749SSergey Zigachev
175*b843c749SSergey Zigachev /* This register resides in DP back end block;
176*b843c749SSergey Zigachev * transmitter is used for the offset */
177*b843c749SSergey Zigachev
178*b843c749SSergey Zigachev REG_SET_3(DP_DPHY_SYM1, 0,
179*b843c749SSergey Zigachev DPHY_SYM4, pattern_symbols[3],
180*b843c749SSergey Zigachev DPHY_SYM5, pattern_symbols[4],
181*b843c749SSergey Zigachev DPHY_SYM6, pattern_symbols[5]);
182*b843c749SSergey Zigachev
183*b843c749SSergey Zigachev /* This register resides in DP back end block;
184*b843c749SSergey Zigachev * transmitter is used for the offset */
185*b843c749SSergey Zigachev
186*b843c749SSergey Zigachev REG_SET_2(DP_DPHY_SYM2, 0,
187*b843c749SSergey Zigachev DPHY_SYM7, pattern_symbols[6],
188*b843c749SSergey Zigachev DPHY_SYM8, pattern_symbols[7]);
189*b843c749SSergey Zigachev }
190*b843c749SSergey Zigachev
set_dp_phy_pattern_d102(struct dce110_link_encoder * enc110)191*b843c749SSergey Zigachev static void set_dp_phy_pattern_d102(
192*b843c749SSergey Zigachev struct dce110_link_encoder *enc110)
193*b843c749SSergey Zigachev {
194*b843c749SSergey Zigachev /* Disable PHY Bypass mode to setup the test pattern */
195*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, false);
196*b843c749SSergey Zigachev
197*b843c749SSergey Zigachev /* For 10-bit PRBS or debug symbols
198*b843c749SSergey Zigachev * please use the following sequence: */
199*b843c749SSergey Zigachev
200*b843c749SSergey Zigachev /* Enable debug symbols on the lanes */
201*b843c749SSergey Zigachev
202*b843c749SSergey Zigachev disable_prbs_symbols(enc110, true);
203*b843c749SSergey Zigachev
204*b843c749SSergey Zigachev /* Disable PRBS mode */
205*b843c749SSergey Zigachev disable_prbs_mode(enc110);
206*b843c749SSergey Zigachev
207*b843c749SSergey Zigachev /* Program debug symbols to be output */
208*b843c749SSergey Zigachev {
209*b843c749SSergey Zigachev uint16_t pattern_symbols[8] = {
210*b843c749SSergey Zigachev 0x2AA, 0x2AA, 0x2AA, 0x2AA,
211*b843c749SSergey Zigachev 0x2AA, 0x2AA, 0x2AA, 0x2AA
212*b843c749SSergey Zigachev };
213*b843c749SSergey Zigachev
214*b843c749SSergey Zigachev program_pattern_symbols(enc110, pattern_symbols);
215*b843c749SSergey Zigachev }
216*b843c749SSergey Zigachev
217*b843c749SSergey Zigachev /* Enable phy bypass mode to enable the test pattern */
218*b843c749SSergey Zigachev
219*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, true);
220*b843c749SSergey Zigachev }
221*b843c749SSergey Zigachev
set_link_training_complete(struct dce110_link_encoder * enc110,bool complete)222*b843c749SSergey Zigachev static void set_link_training_complete(
223*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
224*b843c749SSergey Zigachev bool complete)
225*b843c749SSergey Zigachev {
226*b843c749SSergey Zigachev /* This register resides in DP back end block;
227*b843c749SSergey Zigachev * transmitter is used for the offset */
228*b843c749SSergey Zigachev
229*b843c749SSergey Zigachev REG_UPDATE(DP_LINK_CNTL, DP_LINK_TRAINING_COMPLETE, complete);
230*b843c749SSergey Zigachev
231*b843c749SSergey Zigachev }
232*b843c749SSergey Zigachev
dce110_link_encoder_set_dp_phy_pattern_training_pattern(struct link_encoder * enc,uint32_t index)233*b843c749SSergey Zigachev void dce110_link_encoder_set_dp_phy_pattern_training_pattern(
234*b843c749SSergey Zigachev struct link_encoder *enc,
235*b843c749SSergey Zigachev uint32_t index)
236*b843c749SSergey Zigachev {
237*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
238*b843c749SSergey Zigachev /* Write Training Pattern */
239*b843c749SSergey Zigachev
240*b843c749SSergey Zigachev REG_WRITE(DP_DPHY_TRAINING_PATTERN_SEL, index);
241*b843c749SSergey Zigachev
242*b843c749SSergey Zigachev /* Set HW Register Training Complete to false */
243*b843c749SSergey Zigachev
244*b843c749SSergey Zigachev set_link_training_complete(enc110, false);
245*b843c749SSergey Zigachev
246*b843c749SSergey Zigachev /* Disable PHY Bypass mode to output Training Pattern */
247*b843c749SSergey Zigachev
248*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, false);
249*b843c749SSergey Zigachev
250*b843c749SSergey Zigachev /* Disable PRBS mode */
251*b843c749SSergey Zigachev disable_prbs_mode(enc110);
252*b843c749SSergey Zigachev }
253*b843c749SSergey Zigachev
setup_panel_mode(struct dce110_link_encoder * enc110,enum dp_panel_mode panel_mode)254*b843c749SSergey Zigachev static void setup_panel_mode(
255*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
256*b843c749SSergey Zigachev enum dp_panel_mode panel_mode)
257*b843c749SSergey Zigachev {
258*b843c749SSergey Zigachev uint32_t value;
259*b843c749SSergey Zigachev struct dc_context *ctx = enc110->base.ctx;
260*b843c749SSergey Zigachev
261*b843c749SSergey Zigachev /* if psp set panel mode, dal should be program it */
262*b843c749SSergey Zigachev if (ctx->dc->caps.psp_setup_panel_mode)
263*b843c749SSergey Zigachev return;
264*b843c749SSergey Zigachev
265*b843c749SSergey Zigachev ASSERT(REG(DP_DPHY_INTERNAL_CTRL));
266*b843c749SSergey Zigachev value = REG_READ(DP_DPHY_INTERNAL_CTRL);
267*b843c749SSergey Zigachev
268*b843c749SSergey Zigachev switch (panel_mode) {
269*b843c749SSergey Zigachev case DP_PANEL_MODE_EDP:
270*b843c749SSergey Zigachev value = 0x1;
271*b843c749SSergey Zigachev break;
272*b843c749SSergey Zigachev case DP_PANEL_MODE_SPECIAL:
273*b843c749SSergey Zigachev value = 0x11;
274*b843c749SSergey Zigachev break;
275*b843c749SSergey Zigachev default:
276*b843c749SSergey Zigachev value = 0x0;
277*b843c749SSergey Zigachev break;
278*b843c749SSergey Zigachev }
279*b843c749SSergey Zigachev
280*b843c749SSergey Zigachev REG_WRITE(DP_DPHY_INTERNAL_CTRL, value);
281*b843c749SSergey Zigachev }
282*b843c749SSergey Zigachev
set_dp_phy_pattern_symbol_error(struct dce110_link_encoder * enc110)283*b843c749SSergey Zigachev static void set_dp_phy_pattern_symbol_error(
284*b843c749SSergey Zigachev struct dce110_link_encoder *enc110)
285*b843c749SSergey Zigachev {
286*b843c749SSergey Zigachev /* Disable PHY Bypass mode to setup the test pattern */
287*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, false);
288*b843c749SSergey Zigachev
289*b843c749SSergey Zigachev /* program correct panel mode*/
290*b843c749SSergey Zigachev setup_panel_mode(enc110, DP_PANEL_MODE_DEFAULT);
291*b843c749SSergey Zigachev
292*b843c749SSergey Zigachev /* A PRBS23 pattern is used for most DP electrical measurements. */
293*b843c749SSergey Zigachev
294*b843c749SSergey Zigachev /* Enable PRBS symbols on the lanes */
295*b843c749SSergey Zigachev disable_prbs_symbols(enc110, false);
296*b843c749SSergey Zigachev
297*b843c749SSergey Zigachev /* For PRBS23 Set bit DPHY_PRBS_SEL=1 and Set bit DPHY_PRBS_EN=1 */
298*b843c749SSergey Zigachev REG_UPDATE_2(DP_DPHY_PRBS_CNTL,
299*b843c749SSergey Zigachev DPHY_PRBS_SEL, 1,
300*b843c749SSergey Zigachev DPHY_PRBS_EN, 1);
301*b843c749SSergey Zigachev
302*b843c749SSergey Zigachev /* Enable phy bypass mode to enable the test pattern */
303*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, true);
304*b843c749SSergey Zigachev }
305*b843c749SSergey Zigachev
set_dp_phy_pattern_prbs7(struct dce110_link_encoder * enc110)306*b843c749SSergey Zigachev static void set_dp_phy_pattern_prbs7(
307*b843c749SSergey Zigachev struct dce110_link_encoder *enc110)
308*b843c749SSergey Zigachev {
309*b843c749SSergey Zigachev /* Disable PHY Bypass mode to setup the test pattern */
310*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, false);
311*b843c749SSergey Zigachev
312*b843c749SSergey Zigachev /* A PRBS7 pattern is used for most DP electrical measurements. */
313*b843c749SSergey Zigachev
314*b843c749SSergey Zigachev /* Enable PRBS symbols on the lanes */
315*b843c749SSergey Zigachev disable_prbs_symbols(enc110, false);
316*b843c749SSergey Zigachev
317*b843c749SSergey Zigachev /* For PRBS7 Set bit DPHY_PRBS_SEL=0 and Set bit DPHY_PRBS_EN=1 */
318*b843c749SSergey Zigachev REG_UPDATE_2(DP_DPHY_PRBS_CNTL,
319*b843c749SSergey Zigachev DPHY_PRBS_SEL, 0,
320*b843c749SSergey Zigachev DPHY_PRBS_EN, 1);
321*b843c749SSergey Zigachev
322*b843c749SSergey Zigachev /* Enable phy bypass mode to enable the test pattern */
323*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, true);
324*b843c749SSergey Zigachev }
325*b843c749SSergey Zigachev
set_dp_phy_pattern_80bit_custom(struct dce110_link_encoder * enc110,const uint8_t * pattern)326*b843c749SSergey Zigachev static void set_dp_phy_pattern_80bit_custom(
327*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
328*b843c749SSergey Zigachev const uint8_t *pattern)
329*b843c749SSergey Zigachev {
330*b843c749SSergey Zigachev /* Disable PHY Bypass mode to setup the test pattern */
331*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, false);
332*b843c749SSergey Zigachev
333*b843c749SSergey Zigachev /* Enable debug symbols on the lanes */
334*b843c749SSergey Zigachev
335*b843c749SSergey Zigachev disable_prbs_symbols(enc110, true);
336*b843c749SSergey Zigachev
337*b843c749SSergey Zigachev /* Enable PHY bypass mode to enable the test pattern */
338*b843c749SSergey Zigachev /* TODO is it really needed ? */
339*b843c749SSergey Zigachev
340*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, true);
341*b843c749SSergey Zigachev
342*b843c749SSergey Zigachev /* Program 80 bit custom pattern */
343*b843c749SSergey Zigachev {
344*b843c749SSergey Zigachev uint16_t pattern_symbols[8];
345*b843c749SSergey Zigachev
346*b843c749SSergey Zigachev pattern_symbols[0] =
347*b843c749SSergey Zigachev ((pattern[1] & 0x03) << 8) | pattern[0];
348*b843c749SSergey Zigachev pattern_symbols[1] =
349*b843c749SSergey Zigachev ((pattern[2] & 0x0f) << 6) | ((pattern[1] >> 2) & 0x3f);
350*b843c749SSergey Zigachev pattern_symbols[2] =
351*b843c749SSergey Zigachev ((pattern[3] & 0x3f) << 4) | ((pattern[2] >> 4) & 0x0f);
352*b843c749SSergey Zigachev pattern_symbols[3] =
353*b843c749SSergey Zigachev (pattern[4] << 2) | ((pattern[3] >> 6) & 0x03);
354*b843c749SSergey Zigachev pattern_symbols[4] =
355*b843c749SSergey Zigachev ((pattern[6] & 0x03) << 8) | pattern[5];
356*b843c749SSergey Zigachev pattern_symbols[5] =
357*b843c749SSergey Zigachev ((pattern[7] & 0x0f) << 6) | ((pattern[6] >> 2) & 0x3f);
358*b843c749SSergey Zigachev pattern_symbols[6] =
359*b843c749SSergey Zigachev ((pattern[8] & 0x3f) << 4) | ((pattern[7] >> 4) & 0x0f);
360*b843c749SSergey Zigachev pattern_symbols[7] =
361*b843c749SSergey Zigachev (pattern[9] << 2) | ((pattern[8] >> 6) & 0x03);
362*b843c749SSergey Zigachev
363*b843c749SSergey Zigachev program_pattern_symbols(enc110, pattern_symbols);
364*b843c749SSergey Zigachev }
365*b843c749SSergey Zigachev
366*b843c749SSergey Zigachev /* Enable phy bypass mode to enable the test pattern */
367*b843c749SSergey Zigachev
368*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, true);
369*b843c749SSergey Zigachev }
370*b843c749SSergey Zigachev
set_dp_phy_pattern_hbr2_compliance_cp2520_2(struct dce110_link_encoder * enc110,unsigned int cp2520_pattern)371*b843c749SSergey Zigachev static void set_dp_phy_pattern_hbr2_compliance_cp2520_2(
372*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
373*b843c749SSergey Zigachev unsigned int cp2520_pattern)
374*b843c749SSergey Zigachev {
375*b843c749SSergey Zigachev
376*b843c749SSergey Zigachev /* previously there is a register DP_HBR2_EYE_PATTERN
377*b843c749SSergey Zigachev * that is enabled to get the pattern.
378*b843c749SSergey Zigachev * But it does not work with the latest spec change,
379*b843c749SSergey Zigachev * so we are programming the following registers manually.
380*b843c749SSergey Zigachev *
381*b843c749SSergey Zigachev * The following settings have been confirmed
382*b843c749SSergey Zigachev * by Nick Chorney and Sandra Liu */
383*b843c749SSergey Zigachev
384*b843c749SSergey Zigachev /* Disable PHY Bypass mode to setup the test pattern */
385*b843c749SSergey Zigachev
386*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, false);
387*b843c749SSergey Zigachev
388*b843c749SSergey Zigachev /* Setup DIG encoder in DP SST mode */
389*b843c749SSergey Zigachev enc110->base.funcs->setup(&enc110->base, SIGNAL_TYPE_DISPLAY_PORT);
390*b843c749SSergey Zigachev
391*b843c749SSergey Zigachev /* ensure normal panel mode. */
392*b843c749SSergey Zigachev setup_panel_mode(enc110, DP_PANEL_MODE_DEFAULT);
393*b843c749SSergey Zigachev
394*b843c749SSergey Zigachev /* no vbid after BS (SR)
395*b843c749SSergey Zigachev * DP_LINK_FRAMING_CNTL changed history Sandra Liu
396*b843c749SSergey Zigachev * 11000260 / 11000104 / 110000FC */
397*b843c749SSergey Zigachev REG_UPDATE_3(DP_LINK_FRAMING_CNTL,
398*b843c749SSergey Zigachev DP_IDLE_BS_INTERVAL, 0xFC,
399*b843c749SSergey Zigachev DP_VBID_DISABLE, 1,
400*b843c749SSergey Zigachev DP_VID_ENHANCED_FRAME_MODE, 1);
401*b843c749SSergey Zigachev
402*b843c749SSergey Zigachev /* swap every BS with SR */
403*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_SCRAM_CNTL, DPHY_SCRAMBLER_BS_COUNT, 0);
404*b843c749SSergey Zigachev
405*b843c749SSergey Zigachev /* select cp2520 patterns */
406*b843c749SSergey Zigachev if (REG(DP_DPHY_HBR2_PATTERN_CONTROL))
407*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_HBR2_PATTERN_CONTROL,
408*b843c749SSergey Zigachev DP_DPHY_HBR2_PATTERN_CONTROL, cp2520_pattern);
409*b843c749SSergey Zigachev else
410*b843c749SSergey Zigachev /* pre-DCE11 can only generate CP2520 pattern 2 */
411*b843c749SSergey Zigachev ASSERT(cp2520_pattern == 2);
412*b843c749SSergey Zigachev
413*b843c749SSergey Zigachev /* set link training complete */
414*b843c749SSergey Zigachev set_link_training_complete(enc110, true);
415*b843c749SSergey Zigachev
416*b843c749SSergey Zigachev /* disable video stream */
417*b843c749SSergey Zigachev REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, 0);
418*b843c749SSergey Zigachev
419*b843c749SSergey Zigachev /* Disable PHY Bypass mode to setup the test pattern */
420*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, false);
421*b843c749SSergey Zigachev }
422*b843c749SSergey Zigachev
set_dp_phy_pattern_passthrough_mode(struct dce110_link_encoder * enc110,enum dp_panel_mode panel_mode)423*b843c749SSergey Zigachev static void set_dp_phy_pattern_passthrough_mode(
424*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
425*b843c749SSergey Zigachev enum dp_panel_mode panel_mode)
426*b843c749SSergey Zigachev {
427*b843c749SSergey Zigachev /* program correct panel mode */
428*b843c749SSergey Zigachev setup_panel_mode(enc110, panel_mode);
429*b843c749SSergey Zigachev
430*b843c749SSergey Zigachev /* restore LINK_FRAMING_CNTL and DPHY_SCRAMBLER_BS_COUNT
431*b843c749SSergey Zigachev * in case we were doing HBR2 compliance pattern before
432*b843c749SSergey Zigachev */
433*b843c749SSergey Zigachev REG_UPDATE_3(DP_LINK_FRAMING_CNTL,
434*b843c749SSergey Zigachev DP_IDLE_BS_INTERVAL, 0x2000,
435*b843c749SSergey Zigachev DP_VBID_DISABLE, 0,
436*b843c749SSergey Zigachev DP_VID_ENHANCED_FRAME_MODE, 1);
437*b843c749SSergey Zigachev
438*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_SCRAM_CNTL, DPHY_SCRAMBLER_BS_COUNT, 0x1FF);
439*b843c749SSergey Zigachev
440*b843c749SSergey Zigachev /* set link training complete */
441*b843c749SSergey Zigachev set_link_training_complete(enc110, true);
442*b843c749SSergey Zigachev
443*b843c749SSergey Zigachev /* Disable PHY Bypass mode to setup the test pattern */
444*b843c749SSergey Zigachev enable_phy_bypass_mode(enc110, false);
445*b843c749SSergey Zigachev
446*b843c749SSergey Zigachev /* Disable PRBS mode */
447*b843c749SSergey Zigachev disable_prbs_mode(enc110);
448*b843c749SSergey Zigachev }
449*b843c749SSergey Zigachev
450*b843c749SSergey Zigachev /* return value is bit-vector */
get_frontend_source(enum engine_id engine)451*b843c749SSergey Zigachev static uint8_t get_frontend_source(
452*b843c749SSergey Zigachev enum engine_id engine)
453*b843c749SSergey Zigachev {
454*b843c749SSergey Zigachev switch (engine) {
455*b843c749SSergey Zigachev case ENGINE_ID_DIGA:
456*b843c749SSergey Zigachev return DCE110_DIG_FE_SOURCE_SELECT_DIGA;
457*b843c749SSergey Zigachev case ENGINE_ID_DIGB:
458*b843c749SSergey Zigachev return DCE110_DIG_FE_SOURCE_SELECT_DIGB;
459*b843c749SSergey Zigachev case ENGINE_ID_DIGC:
460*b843c749SSergey Zigachev return DCE110_DIG_FE_SOURCE_SELECT_DIGC;
461*b843c749SSergey Zigachev case ENGINE_ID_DIGD:
462*b843c749SSergey Zigachev return DCE110_DIG_FE_SOURCE_SELECT_DIGD;
463*b843c749SSergey Zigachev case ENGINE_ID_DIGE:
464*b843c749SSergey Zigachev return DCE110_DIG_FE_SOURCE_SELECT_DIGE;
465*b843c749SSergey Zigachev case ENGINE_ID_DIGF:
466*b843c749SSergey Zigachev return DCE110_DIG_FE_SOURCE_SELECT_DIGF;
467*b843c749SSergey Zigachev case ENGINE_ID_DIGG:
468*b843c749SSergey Zigachev return DCE110_DIG_FE_SOURCE_SELECT_DIGG;
469*b843c749SSergey Zigachev default:
470*b843c749SSergey Zigachev ASSERT_CRITICAL(false);
471*b843c749SSergey Zigachev return DCE110_DIG_FE_SOURCE_SELECT_INVALID;
472*b843c749SSergey Zigachev }
473*b843c749SSergey Zigachev }
474*b843c749SSergey Zigachev
configure_encoder(struct dce110_link_encoder * enc110,const struct dc_link_settings * link_settings)475*b843c749SSergey Zigachev static void configure_encoder(
476*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
477*b843c749SSergey Zigachev const struct dc_link_settings *link_settings)
478*b843c749SSergey Zigachev {
479*b843c749SSergey Zigachev /* set number of lanes */
480*b843c749SSergey Zigachev
481*b843c749SSergey Zigachev REG_SET(DP_CONFIG, 0,
482*b843c749SSergey Zigachev DP_UDI_LANES, link_settings->lane_count - LANE_COUNT_ONE);
483*b843c749SSergey Zigachev
484*b843c749SSergey Zigachev /* setup scrambler */
485*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_SCRAM_CNTL, DPHY_SCRAMBLER_ADVANCE, 1);
486*b843c749SSergey Zigachev }
487*b843c749SSergey Zigachev
aux_initialize(struct dce110_link_encoder * enc110)488*b843c749SSergey Zigachev static void aux_initialize(
489*b843c749SSergey Zigachev struct dce110_link_encoder *enc110)
490*b843c749SSergey Zigachev {
491*b843c749SSergey Zigachev struct dc_context *ctx = enc110->base.ctx;
492*b843c749SSergey Zigachev enum hpd_source_id hpd_source = enc110->base.hpd_source;
493*b843c749SSergey Zigachev uint32_t addr = AUX_REG(AUX_CONTROL);
494*b843c749SSergey Zigachev uint32_t value = dm_read_reg(ctx, addr);
495*b843c749SSergey Zigachev
496*b843c749SSergey Zigachev set_reg_field_value(value, hpd_source, AUX_CONTROL, AUX_HPD_SEL);
497*b843c749SSergey Zigachev set_reg_field_value(value, 0, AUX_CONTROL, AUX_LS_READ_EN);
498*b843c749SSergey Zigachev dm_write_reg(ctx, addr, value);
499*b843c749SSergey Zigachev
500*b843c749SSergey Zigachev addr = AUX_REG(AUX_DPHY_RX_CONTROL0);
501*b843c749SSergey Zigachev value = dm_read_reg(ctx, addr);
502*b843c749SSergey Zigachev
503*b843c749SSergey Zigachev /* 1/4 window (the maximum allowed) */
504*b843c749SSergey Zigachev set_reg_field_value(value, 1,
505*b843c749SSergey Zigachev AUX_DPHY_RX_CONTROL0, AUX_RX_RECEIVE_WINDOW);
506*b843c749SSergey Zigachev dm_write_reg(ctx, addr, value);
507*b843c749SSergey Zigachev
508*b843c749SSergey Zigachev }
509*b843c749SSergey Zigachev
dce110_psr_program_dp_dphy_fast_training(struct link_encoder * enc,bool exit_link_training_required)510*b843c749SSergey Zigachev void dce110_psr_program_dp_dphy_fast_training(struct link_encoder *enc,
511*b843c749SSergey Zigachev bool exit_link_training_required)
512*b843c749SSergey Zigachev {
513*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
514*b843c749SSergey Zigachev
515*b843c749SSergey Zigachev if (exit_link_training_required)
516*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_FAST_TRAINING,
517*b843c749SSergey Zigachev DPHY_RX_FAST_TRAINING_CAPABLE, 1);
518*b843c749SSergey Zigachev else {
519*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_FAST_TRAINING,
520*b843c749SSergey Zigachev DPHY_RX_FAST_TRAINING_CAPABLE, 0);
521*b843c749SSergey Zigachev /*In DCE 11, we are able to pre-program a Force SR register
522*b843c749SSergey Zigachev * to be able to trigger SR symbol after 5 idle patterns
523*b843c749SSergey Zigachev * transmitted. Upon PSR Exit, DMCU can trigger
524*b843c749SSergey Zigachev * DPHY_LOAD_BS_COUNT_START = 1. Upon writing 1 to
525*b843c749SSergey Zigachev * DPHY_LOAD_BS_COUNT_START and the internal counter
526*b843c749SSergey Zigachev * reaches DPHY_LOAD_BS_COUNT, the next BS symbol will be
527*b843c749SSergey Zigachev * replaced by SR symbol once.
528*b843c749SSergey Zigachev */
529*b843c749SSergey Zigachev
530*b843c749SSergey Zigachev REG_UPDATE(DP_DPHY_BS_SR_SWAP_CNTL, DPHY_LOAD_BS_COUNT, 0x5);
531*b843c749SSergey Zigachev }
532*b843c749SSergey Zigachev }
533*b843c749SSergey Zigachev
dce110_psr_program_secondary_packet(struct link_encoder * enc,unsigned int sdp_transmit_line_num_deadline)534*b843c749SSergey Zigachev void dce110_psr_program_secondary_packet(struct link_encoder *enc,
535*b843c749SSergey Zigachev unsigned int sdp_transmit_line_num_deadline)
536*b843c749SSergey Zigachev {
537*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
538*b843c749SSergey Zigachev
539*b843c749SSergey Zigachev REG_UPDATE_2(DP_SEC_CNTL1,
540*b843c749SSergey Zigachev DP_SEC_GSP0_LINE_NUM, sdp_transmit_line_num_deadline,
541*b843c749SSergey Zigachev DP_SEC_GSP0_PRIORITY, 1);
542*b843c749SSergey Zigachev }
543*b843c749SSergey Zigachev
dce110_is_dig_enabled(struct link_encoder * enc)544*b843c749SSergey Zigachev bool dce110_is_dig_enabled(struct link_encoder *enc)
545*b843c749SSergey Zigachev {
546*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
547*b843c749SSergey Zigachev uint32_t value;
548*b843c749SSergey Zigachev
549*b843c749SSergey Zigachev REG_GET(DIG_BE_EN_CNTL, DIG_ENABLE, &value);
550*b843c749SSergey Zigachev return value;
551*b843c749SSergey Zigachev }
552*b843c749SSergey Zigachev
link_encoder_disable(struct dce110_link_encoder * enc110)553*b843c749SSergey Zigachev static void link_encoder_disable(struct dce110_link_encoder *enc110)
554*b843c749SSergey Zigachev {
555*b843c749SSergey Zigachev /* reset training pattern */
556*b843c749SSergey Zigachev REG_SET(DP_DPHY_TRAINING_PATTERN_SEL, 0,
557*b843c749SSergey Zigachev DPHY_TRAINING_PATTERN_SEL, 0);
558*b843c749SSergey Zigachev
559*b843c749SSergey Zigachev /* reset training complete */
560*b843c749SSergey Zigachev REG_UPDATE(DP_LINK_CNTL, DP_LINK_TRAINING_COMPLETE, 0);
561*b843c749SSergey Zigachev
562*b843c749SSergey Zigachev /* reset panel mode */
563*b843c749SSergey Zigachev setup_panel_mode(enc110, DP_PANEL_MODE_DEFAULT);
564*b843c749SSergey Zigachev }
565*b843c749SSergey Zigachev
hpd_initialize(struct dce110_link_encoder * enc110)566*b843c749SSergey Zigachev static void hpd_initialize(
567*b843c749SSergey Zigachev struct dce110_link_encoder *enc110)
568*b843c749SSergey Zigachev {
569*b843c749SSergey Zigachev /* Associate HPD with DIG_BE */
570*b843c749SSergey Zigachev enum hpd_source_id hpd_source = enc110->base.hpd_source;
571*b843c749SSergey Zigachev
572*b843c749SSergey Zigachev REG_UPDATE(DIG_BE_CNTL, DIG_HPD_SELECT, hpd_source);
573*b843c749SSergey Zigachev }
574*b843c749SSergey Zigachev
dce110_link_encoder_validate_dvi_output(const struct dce110_link_encoder * enc110,enum signal_type connector_signal,enum signal_type signal,const struct dc_crtc_timing * crtc_timing)575*b843c749SSergey Zigachev bool dce110_link_encoder_validate_dvi_output(
576*b843c749SSergey Zigachev const struct dce110_link_encoder *enc110,
577*b843c749SSergey Zigachev enum signal_type connector_signal,
578*b843c749SSergey Zigachev enum signal_type signal,
579*b843c749SSergey Zigachev const struct dc_crtc_timing *crtc_timing)
580*b843c749SSergey Zigachev {
581*b843c749SSergey Zigachev uint32_t max_pixel_clock = TMDS_MAX_PIXEL_CLOCK;
582*b843c749SSergey Zigachev
583*b843c749SSergey Zigachev if (signal == SIGNAL_TYPE_DVI_DUAL_LINK)
584*b843c749SSergey Zigachev max_pixel_clock *= 2;
585*b843c749SSergey Zigachev
586*b843c749SSergey Zigachev /* This handles the case of HDMI downgrade to DVI we don't want to
587*b843c749SSergey Zigachev * we don't want to cap the pixel clock if the DDI is not DVI.
588*b843c749SSergey Zigachev */
589*b843c749SSergey Zigachev if (connector_signal != SIGNAL_TYPE_DVI_DUAL_LINK &&
590*b843c749SSergey Zigachev connector_signal != SIGNAL_TYPE_DVI_SINGLE_LINK)
591*b843c749SSergey Zigachev max_pixel_clock = enc110->base.features.max_hdmi_pixel_clock;
592*b843c749SSergey Zigachev
593*b843c749SSergey Zigachev /* DVI only support RGB pixel encoding */
594*b843c749SSergey Zigachev if (crtc_timing->pixel_encoding != PIXEL_ENCODING_RGB)
595*b843c749SSergey Zigachev return false;
596*b843c749SSergey Zigachev
597*b843c749SSergey Zigachev /*connect DVI via adpater's HDMI connector*/
598*b843c749SSergey Zigachev if ((connector_signal == SIGNAL_TYPE_DVI_SINGLE_LINK ||
599*b843c749SSergey Zigachev connector_signal == SIGNAL_TYPE_HDMI_TYPE_A) &&
600*b843c749SSergey Zigachev signal != SIGNAL_TYPE_HDMI_TYPE_A &&
601*b843c749SSergey Zigachev crtc_timing->pix_clk_khz > TMDS_MAX_PIXEL_CLOCK)
602*b843c749SSergey Zigachev return false;
603*b843c749SSergey Zigachev if (crtc_timing->pix_clk_khz < TMDS_MIN_PIXEL_CLOCK)
604*b843c749SSergey Zigachev return false;
605*b843c749SSergey Zigachev
606*b843c749SSergey Zigachev if (crtc_timing->pix_clk_khz > max_pixel_clock)
607*b843c749SSergey Zigachev return false;
608*b843c749SSergey Zigachev
609*b843c749SSergey Zigachev /* DVI supports 6/8bpp single-link and 10/16bpp dual-link */
610*b843c749SSergey Zigachev switch (crtc_timing->display_color_depth) {
611*b843c749SSergey Zigachev case COLOR_DEPTH_666:
612*b843c749SSergey Zigachev case COLOR_DEPTH_888:
613*b843c749SSergey Zigachev break;
614*b843c749SSergey Zigachev case COLOR_DEPTH_101010:
615*b843c749SSergey Zigachev case COLOR_DEPTH_161616:
616*b843c749SSergey Zigachev if (signal != SIGNAL_TYPE_DVI_DUAL_LINK)
617*b843c749SSergey Zigachev return false;
618*b843c749SSergey Zigachev break;
619*b843c749SSergey Zigachev default:
620*b843c749SSergey Zigachev return false;
621*b843c749SSergey Zigachev }
622*b843c749SSergey Zigachev
623*b843c749SSergey Zigachev return true;
624*b843c749SSergey Zigachev }
625*b843c749SSergey Zigachev
dce110_link_encoder_validate_hdmi_output(const struct dce110_link_encoder * enc110,const struct dc_crtc_timing * crtc_timing,int adjusted_pix_clk_khz)626*b843c749SSergey Zigachev static bool dce110_link_encoder_validate_hdmi_output(
627*b843c749SSergey Zigachev const struct dce110_link_encoder *enc110,
628*b843c749SSergey Zigachev const struct dc_crtc_timing *crtc_timing,
629*b843c749SSergey Zigachev int adjusted_pix_clk_khz)
630*b843c749SSergey Zigachev {
631*b843c749SSergey Zigachev enum dc_color_depth max_deep_color =
632*b843c749SSergey Zigachev enc110->base.features.max_hdmi_deep_color;
633*b843c749SSergey Zigachev
634*b843c749SSergey Zigachev if (max_deep_color < crtc_timing->display_color_depth)
635*b843c749SSergey Zigachev return false;
636*b843c749SSergey Zigachev
637*b843c749SSergey Zigachev if (crtc_timing->display_color_depth < COLOR_DEPTH_888)
638*b843c749SSergey Zigachev return false;
639*b843c749SSergey Zigachev if (adjusted_pix_clk_khz < TMDS_MIN_PIXEL_CLOCK)
640*b843c749SSergey Zigachev return false;
641*b843c749SSergey Zigachev
642*b843c749SSergey Zigachev if ((adjusted_pix_clk_khz == 0) ||
643*b843c749SSergey Zigachev (adjusted_pix_clk_khz > enc110->base.features.max_hdmi_pixel_clock))
644*b843c749SSergey Zigachev return false;
645*b843c749SSergey Zigachev
646*b843c749SSergey Zigachev /* DCE11 HW does not support 420 */
647*b843c749SSergey Zigachev if (!enc110->base.features.ycbcr420_supported &&
648*b843c749SSergey Zigachev crtc_timing->pixel_encoding == PIXEL_ENCODING_YCBCR420)
649*b843c749SSergey Zigachev return false;
650*b843c749SSergey Zigachev
651*b843c749SSergey Zigachev if (!enc110->base.features.flags.bits.HDMI_6GB_EN &&
652*b843c749SSergey Zigachev adjusted_pix_clk_khz >= 300000)
653*b843c749SSergey Zigachev return false;
654*b843c749SSergey Zigachev if (enc110->base.ctx->dc->debug.hdmi20_disable &&
655*b843c749SSergey Zigachev crtc_timing->pixel_encoding == PIXEL_ENCODING_YCBCR420)
656*b843c749SSergey Zigachev return false;
657*b843c749SSergey Zigachev return true;
658*b843c749SSergey Zigachev }
659*b843c749SSergey Zigachev
dce110_link_encoder_validate_dp_output(const struct dce110_link_encoder * enc110,const struct dc_crtc_timing * crtc_timing)660*b843c749SSergey Zigachev bool dce110_link_encoder_validate_dp_output(
661*b843c749SSergey Zigachev const struct dce110_link_encoder *enc110,
662*b843c749SSergey Zigachev const struct dc_crtc_timing *crtc_timing)
663*b843c749SSergey Zigachev {
664*b843c749SSergey Zigachev /* default RGB only */
665*b843c749SSergey Zigachev if (crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB)
666*b843c749SSergey Zigachev return true;
667*b843c749SSergey Zigachev
668*b843c749SSergey Zigachev if (enc110->base.features.flags.bits.IS_YCBCR_CAPABLE)
669*b843c749SSergey Zigachev return true;
670*b843c749SSergey Zigachev
671*b843c749SSergey Zigachev /* for DCE 8.x or later DP Y-only feature,
672*b843c749SSergey Zigachev * we need ASIC cap + FeatureSupportDPYonly, not support 666 */
673*b843c749SSergey Zigachev if (crtc_timing->flags.Y_ONLY &&
674*b843c749SSergey Zigachev enc110->base.features.flags.bits.IS_YCBCR_CAPABLE &&
675*b843c749SSergey Zigachev crtc_timing->display_color_depth != COLOR_DEPTH_666)
676*b843c749SSergey Zigachev return true;
677*b843c749SSergey Zigachev
678*b843c749SSergey Zigachev return false;
679*b843c749SSergey Zigachev }
680*b843c749SSergey Zigachev
dce110_link_encoder_construct(struct dce110_link_encoder * enc110,const struct encoder_init_data * init_data,const struct encoder_feature_support * enc_features,const struct dce110_link_enc_registers * link_regs,const struct dce110_link_enc_aux_registers * aux_regs,const struct dce110_link_enc_hpd_registers * hpd_regs)681*b843c749SSergey Zigachev void dce110_link_encoder_construct(
682*b843c749SSergey Zigachev struct dce110_link_encoder *enc110,
683*b843c749SSergey Zigachev const struct encoder_init_data *init_data,
684*b843c749SSergey Zigachev const struct encoder_feature_support *enc_features,
685*b843c749SSergey Zigachev const struct dce110_link_enc_registers *link_regs,
686*b843c749SSergey Zigachev const struct dce110_link_enc_aux_registers *aux_regs,
687*b843c749SSergey Zigachev const struct dce110_link_enc_hpd_registers *hpd_regs)
688*b843c749SSergey Zigachev {
689*b843c749SSergey Zigachev struct bp_encoder_cap_info bp_cap_info = {0};
690*b843c749SSergey Zigachev const struct dc_vbios_funcs *bp_funcs = init_data->ctx->dc_bios->funcs;
691*b843c749SSergey Zigachev enum bp_result result = BP_RESULT_OK;
692*b843c749SSergey Zigachev
693*b843c749SSergey Zigachev enc110->base.funcs = &dce110_lnk_enc_funcs;
694*b843c749SSergey Zigachev enc110->base.ctx = init_data->ctx;
695*b843c749SSergey Zigachev enc110->base.id = init_data->encoder;
696*b843c749SSergey Zigachev
697*b843c749SSergey Zigachev enc110->base.hpd_source = init_data->hpd_source;
698*b843c749SSergey Zigachev enc110->base.connector = init_data->connector;
699*b843c749SSergey Zigachev
700*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_UNKNOWN;
701*b843c749SSergey Zigachev
702*b843c749SSergey Zigachev enc110->base.features = *enc_features;
703*b843c749SSergey Zigachev
704*b843c749SSergey Zigachev enc110->base.transmitter = init_data->transmitter;
705*b843c749SSergey Zigachev
706*b843c749SSergey Zigachev /* set the flag to indicate whether driver poll the I2C data pin
707*b843c749SSergey Zigachev * while doing the DP sink detect
708*b843c749SSergey Zigachev */
709*b843c749SSergey Zigachev
710*b843c749SSergey Zigachev /* if (dal_adapter_service_is_feature_supported(as,
711*b843c749SSergey Zigachev FEATURE_DP_SINK_DETECT_POLL_DATA_PIN))
712*b843c749SSergey Zigachev enc110->base.features.flags.bits.
713*b843c749SSergey Zigachev DP_SINK_DETECT_POLL_DATA_PIN = true;*/
714*b843c749SSergey Zigachev
715*b843c749SSergey Zigachev enc110->base.output_signals =
716*b843c749SSergey Zigachev SIGNAL_TYPE_DVI_SINGLE_LINK |
717*b843c749SSergey Zigachev SIGNAL_TYPE_DVI_DUAL_LINK |
718*b843c749SSergey Zigachev SIGNAL_TYPE_LVDS |
719*b843c749SSergey Zigachev SIGNAL_TYPE_DISPLAY_PORT |
720*b843c749SSergey Zigachev SIGNAL_TYPE_DISPLAY_PORT_MST |
721*b843c749SSergey Zigachev SIGNAL_TYPE_EDP |
722*b843c749SSergey Zigachev SIGNAL_TYPE_HDMI_TYPE_A;
723*b843c749SSergey Zigachev
724*b843c749SSergey Zigachev /* For DCE 8.0 and 8.1, by design, UNIPHY is hardwired to DIG_BE.
725*b843c749SSergey Zigachev * SW always assign DIG_FE 1:1 mapped to DIG_FE for non-MST UNIPHY.
726*b843c749SSergey Zigachev * SW assign DIG_FE to non-MST UNIPHY first and MST last. So prefer
727*b843c749SSergey Zigachev * DIG is per UNIPHY and used by SST DP, eDP, HDMI, DVI and LVDS.
728*b843c749SSergey Zigachev * Prefer DIG assignment is decided by board design.
729*b843c749SSergey Zigachev * For DCE 8.0, there are only max 6 UNIPHYs, we assume board design
730*b843c749SSergey Zigachev * and VBIOS will filter out 7 UNIPHY for DCE 8.0.
731*b843c749SSergey Zigachev * By this, adding DIGG should not hurt DCE 8.0.
732*b843c749SSergey Zigachev * This will let DCE 8.1 share DCE 8.0 as much as possible
733*b843c749SSergey Zigachev */
734*b843c749SSergey Zigachev
735*b843c749SSergey Zigachev enc110->link_regs = link_regs;
736*b843c749SSergey Zigachev enc110->aux_regs = aux_regs;
737*b843c749SSergey Zigachev enc110->hpd_regs = hpd_regs;
738*b843c749SSergey Zigachev
739*b843c749SSergey Zigachev switch (enc110->base.transmitter) {
740*b843c749SSergey Zigachev case TRANSMITTER_UNIPHY_A:
741*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_DIGA;
742*b843c749SSergey Zigachev break;
743*b843c749SSergey Zigachev case TRANSMITTER_UNIPHY_B:
744*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_DIGB;
745*b843c749SSergey Zigachev break;
746*b843c749SSergey Zigachev case TRANSMITTER_UNIPHY_C:
747*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_DIGC;
748*b843c749SSergey Zigachev break;
749*b843c749SSergey Zigachev case TRANSMITTER_UNIPHY_D:
750*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_DIGD;
751*b843c749SSergey Zigachev break;
752*b843c749SSergey Zigachev case TRANSMITTER_UNIPHY_E:
753*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_DIGE;
754*b843c749SSergey Zigachev break;
755*b843c749SSergey Zigachev case TRANSMITTER_UNIPHY_F:
756*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_DIGF;
757*b843c749SSergey Zigachev break;
758*b843c749SSergey Zigachev case TRANSMITTER_UNIPHY_G:
759*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_DIGG;
760*b843c749SSergey Zigachev break;
761*b843c749SSergey Zigachev default:
762*b843c749SSergey Zigachev ASSERT_CRITICAL(false);
763*b843c749SSergey Zigachev enc110->base.preferred_engine = ENGINE_ID_UNKNOWN;
764*b843c749SSergey Zigachev }
765*b843c749SSergey Zigachev
766*b843c749SSergey Zigachev /* default to one to mirror Windows behavior */
767*b843c749SSergey Zigachev enc110->base.features.flags.bits.HDMI_6GB_EN = 1;
768*b843c749SSergey Zigachev
769*b843c749SSergey Zigachev result = bp_funcs->get_encoder_cap_info(enc110->base.ctx->dc_bios,
770*b843c749SSergey Zigachev enc110->base.id, &bp_cap_info);
771*b843c749SSergey Zigachev
772*b843c749SSergey Zigachev /* Override features with DCE-specific values */
773*b843c749SSergey Zigachev if (BP_RESULT_OK == result) {
774*b843c749SSergey Zigachev enc110->base.features.flags.bits.IS_HBR2_CAPABLE =
775*b843c749SSergey Zigachev bp_cap_info.DP_HBR2_EN;
776*b843c749SSergey Zigachev enc110->base.features.flags.bits.IS_HBR3_CAPABLE =
777*b843c749SSergey Zigachev bp_cap_info.DP_HBR3_EN;
778*b843c749SSergey Zigachev enc110->base.features.flags.bits.HDMI_6GB_EN = bp_cap_info.HDMI_6GB_EN;
779*b843c749SSergey Zigachev } else {
780*b843c749SSergey Zigachev DC_LOG_WARNING("%s: Failed to get encoder_cap_info from VBIOS with error code %d!\n",
781*b843c749SSergey Zigachev __func__,
782*b843c749SSergey Zigachev result);
783*b843c749SSergey Zigachev }
784*b843c749SSergey Zigachev if (enc110->base.ctx->dc->debug.hdmi20_disable) {
785*b843c749SSergey Zigachev enc110->base.features.flags.bits.HDMI_6GB_EN = 0;
786*b843c749SSergey Zigachev }
787*b843c749SSergey Zigachev }
788*b843c749SSergey Zigachev
dce110_link_encoder_validate_output_with_stream(struct link_encoder * enc,const struct dc_stream_state * stream)789*b843c749SSergey Zigachev bool dce110_link_encoder_validate_output_with_stream(
790*b843c749SSergey Zigachev struct link_encoder *enc,
791*b843c749SSergey Zigachev const struct dc_stream_state *stream)
792*b843c749SSergey Zigachev {
793*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
794*b843c749SSergey Zigachev bool is_valid;
795*b843c749SSergey Zigachev
796*b843c749SSergey Zigachev switch (stream->signal) {
797*b843c749SSergey Zigachev case SIGNAL_TYPE_DVI_SINGLE_LINK:
798*b843c749SSergey Zigachev case SIGNAL_TYPE_DVI_DUAL_LINK:
799*b843c749SSergey Zigachev is_valid = dce110_link_encoder_validate_dvi_output(
800*b843c749SSergey Zigachev enc110,
801*b843c749SSergey Zigachev stream->sink->link->connector_signal,
802*b843c749SSergey Zigachev stream->signal,
803*b843c749SSergey Zigachev &stream->timing);
804*b843c749SSergey Zigachev break;
805*b843c749SSergey Zigachev case SIGNAL_TYPE_HDMI_TYPE_A:
806*b843c749SSergey Zigachev is_valid = dce110_link_encoder_validate_hdmi_output(
807*b843c749SSergey Zigachev enc110,
808*b843c749SSergey Zigachev &stream->timing,
809*b843c749SSergey Zigachev stream->phy_pix_clk);
810*b843c749SSergey Zigachev break;
811*b843c749SSergey Zigachev case SIGNAL_TYPE_DISPLAY_PORT:
812*b843c749SSergey Zigachev case SIGNAL_TYPE_DISPLAY_PORT_MST:
813*b843c749SSergey Zigachev is_valid = dce110_link_encoder_validate_dp_output(
814*b843c749SSergey Zigachev enc110, &stream->timing);
815*b843c749SSergey Zigachev break;
816*b843c749SSergey Zigachev case SIGNAL_TYPE_EDP:
817*b843c749SSergey Zigachev is_valid =
818*b843c749SSergey Zigachev (stream->timing.
819*b843c749SSergey Zigachev pixel_encoding == PIXEL_ENCODING_RGB) ? true : false;
820*b843c749SSergey Zigachev break;
821*b843c749SSergey Zigachev case SIGNAL_TYPE_VIRTUAL:
822*b843c749SSergey Zigachev is_valid = true;
823*b843c749SSergey Zigachev break;
824*b843c749SSergey Zigachev default:
825*b843c749SSergey Zigachev is_valid = false;
826*b843c749SSergey Zigachev break;
827*b843c749SSergey Zigachev }
828*b843c749SSergey Zigachev
829*b843c749SSergey Zigachev return is_valid;
830*b843c749SSergey Zigachev }
831*b843c749SSergey Zigachev
dce110_link_encoder_hw_init(struct link_encoder * enc)832*b843c749SSergey Zigachev void dce110_link_encoder_hw_init(
833*b843c749SSergey Zigachev struct link_encoder *enc)
834*b843c749SSergey Zigachev {
835*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
836*b843c749SSergey Zigachev struct bp_transmitter_control cntl = { 0 };
837*b843c749SSergey Zigachev enum bp_result result;
838*b843c749SSergey Zigachev
839*b843c749SSergey Zigachev cntl.action = TRANSMITTER_CONTROL_INIT;
840*b843c749SSergey Zigachev cntl.engine_id = ENGINE_ID_UNKNOWN;
841*b843c749SSergey Zigachev cntl.transmitter = enc110->base.transmitter;
842*b843c749SSergey Zigachev cntl.connector_obj_id = enc110->base.connector;
843*b843c749SSergey Zigachev cntl.lanes_number = LANE_COUNT_FOUR;
844*b843c749SSergey Zigachev cntl.coherent = false;
845*b843c749SSergey Zigachev cntl.hpd_sel = enc110->base.hpd_source;
846*b843c749SSergey Zigachev
847*b843c749SSergey Zigachev if (enc110->base.connector.id == CONNECTOR_ID_EDP)
848*b843c749SSergey Zigachev cntl.signal = SIGNAL_TYPE_EDP;
849*b843c749SSergey Zigachev
850*b843c749SSergey Zigachev result = link_transmitter_control(enc110, &cntl);
851*b843c749SSergey Zigachev
852*b843c749SSergey Zigachev if (result != BP_RESULT_OK) {
853*b843c749SSergey Zigachev DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n",
854*b843c749SSergey Zigachev __func__);
855*b843c749SSergey Zigachev BREAK_TO_DEBUGGER();
856*b843c749SSergey Zigachev return;
857*b843c749SSergey Zigachev }
858*b843c749SSergey Zigachev
859*b843c749SSergey Zigachev if (enc110->base.connector.id == CONNECTOR_ID_LVDS) {
860*b843c749SSergey Zigachev cntl.action = TRANSMITTER_CONTROL_BACKLIGHT_BRIGHTNESS;
861*b843c749SSergey Zigachev
862*b843c749SSergey Zigachev result = link_transmitter_control(enc110, &cntl);
863*b843c749SSergey Zigachev
864*b843c749SSergey Zigachev ASSERT(result == BP_RESULT_OK);
865*b843c749SSergey Zigachev
866*b843c749SSergey Zigachev }
867*b843c749SSergey Zigachev aux_initialize(enc110);
868*b843c749SSergey Zigachev
869*b843c749SSergey Zigachev /* reinitialize HPD.
870*b843c749SSergey Zigachev * hpd_initialize() will pass DIG_FE id to HW context.
871*b843c749SSergey Zigachev * All other routine within HW context will use fe_engine_offset
872*b843c749SSergey Zigachev * as DIG_FE id even caller pass DIG_FE id.
873*b843c749SSergey Zigachev * So this routine must be called first. */
874*b843c749SSergey Zigachev hpd_initialize(enc110);
875*b843c749SSergey Zigachev }
876*b843c749SSergey Zigachev
dce110_link_encoder_destroy(struct link_encoder ** enc)877*b843c749SSergey Zigachev void dce110_link_encoder_destroy(struct link_encoder **enc)
878*b843c749SSergey Zigachev {
879*b843c749SSergey Zigachev kfree(TO_DCE110_LINK_ENC(*enc));
880*b843c749SSergey Zigachev *enc = NULL;
881*b843c749SSergey Zigachev }
882*b843c749SSergey Zigachev
dce110_link_encoder_setup(struct link_encoder * enc,enum signal_type signal)883*b843c749SSergey Zigachev void dce110_link_encoder_setup(
884*b843c749SSergey Zigachev struct link_encoder *enc,
885*b843c749SSergey Zigachev enum signal_type signal)
886*b843c749SSergey Zigachev {
887*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
888*b843c749SSergey Zigachev
889*b843c749SSergey Zigachev switch (signal) {
890*b843c749SSergey Zigachev case SIGNAL_TYPE_EDP:
891*b843c749SSergey Zigachev case SIGNAL_TYPE_DISPLAY_PORT:
892*b843c749SSergey Zigachev /* DP SST */
893*b843c749SSergey Zigachev REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 0);
894*b843c749SSergey Zigachev break;
895*b843c749SSergey Zigachev case SIGNAL_TYPE_LVDS:
896*b843c749SSergey Zigachev /* LVDS */
897*b843c749SSergey Zigachev REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 1);
898*b843c749SSergey Zigachev break;
899*b843c749SSergey Zigachev case SIGNAL_TYPE_DVI_SINGLE_LINK:
900*b843c749SSergey Zigachev case SIGNAL_TYPE_DVI_DUAL_LINK:
901*b843c749SSergey Zigachev /* TMDS-DVI */
902*b843c749SSergey Zigachev REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 2);
903*b843c749SSergey Zigachev break;
904*b843c749SSergey Zigachev case SIGNAL_TYPE_HDMI_TYPE_A:
905*b843c749SSergey Zigachev /* TMDS-HDMI */
906*b843c749SSergey Zigachev REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 3);
907*b843c749SSergey Zigachev break;
908*b843c749SSergey Zigachev case SIGNAL_TYPE_DISPLAY_PORT_MST:
909*b843c749SSergey Zigachev /* DP MST */
910*b843c749SSergey Zigachev REG_UPDATE(DIG_BE_CNTL, DIG_MODE, 5);
911*b843c749SSergey Zigachev break;
912*b843c749SSergey Zigachev default:
913*b843c749SSergey Zigachev ASSERT_CRITICAL(false);
914*b843c749SSergey Zigachev /* invalid mode ! */
915*b843c749SSergey Zigachev break;
916*b843c749SSergey Zigachev }
917*b843c749SSergey Zigachev
918*b843c749SSergey Zigachev }
919*b843c749SSergey Zigachev
920*b843c749SSergey Zigachev /* TODO: still need depth or just pass in adjusted pixel clock? */
dce110_link_encoder_enable_tmds_output(struct link_encoder * enc,enum clock_source_id clock_source,enum dc_color_depth color_depth,enum signal_type signal,uint32_t pixel_clock)921*b843c749SSergey Zigachev void dce110_link_encoder_enable_tmds_output(
922*b843c749SSergey Zigachev struct link_encoder *enc,
923*b843c749SSergey Zigachev enum clock_source_id clock_source,
924*b843c749SSergey Zigachev enum dc_color_depth color_depth,
925*b843c749SSergey Zigachev enum signal_type signal,
926*b843c749SSergey Zigachev uint32_t pixel_clock)
927*b843c749SSergey Zigachev {
928*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
929*b843c749SSergey Zigachev struct bp_transmitter_control cntl = { 0 };
930*b843c749SSergey Zigachev enum bp_result result;
931*b843c749SSergey Zigachev
932*b843c749SSergey Zigachev /* Enable the PHY */
933*b843c749SSergey Zigachev cntl.connector_obj_id = enc110->base.connector;
934*b843c749SSergey Zigachev cntl.action = TRANSMITTER_CONTROL_ENABLE;
935*b843c749SSergey Zigachev cntl.engine_id = enc->preferred_engine;
936*b843c749SSergey Zigachev cntl.transmitter = enc110->base.transmitter;
937*b843c749SSergey Zigachev cntl.pll_id = clock_source;
938*b843c749SSergey Zigachev cntl.signal = signal;
939*b843c749SSergey Zigachev if (cntl.signal == SIGNAL_TYPE_DVI_DUAL_LINK)
940*b843c749SSergey Zigachev cntl.lanes_number = 8;
941*b843c749SSergey Zigachev else
942*b843c749SSergey Zigachev cntl.lanes_number = 4;
943*b843c749SSergey Zigachev
944*b843c749SSergey Zigachev cntl.hpd_sel = enc110->base.hpd_source;
945*b843c749SSergey Zigachev
946*b843c749SSergey Zigachev cntl.pixel_clock = pixel_clock;
947*b843c749SSergey Zigachev cntl.color_depth = color_depth;
948*b843c749SSergey Zigachev
949*b843c749SSergey Zigachev result = link_transmitter_control(enc110, &cntl);
950*b843c749SSergey Zigachev
951*b843c749SSergey Zigachev if (result != BP_RESULT_OK) {
952*b843c749SSergey Zigachev DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n",
953*b843c749SSergey Zigachev __func__);
954*b843c749SSergey Zigachev BREAK_TO_DEBUGGER();
955*b843c749SSergey Zigachev }
956*b843c749SSergey Zigachev }
957*b843c749SSergey Zigachev
958*b843c749SSergey Zigachev /* enables DP PHY output */
dce110_link_encoder_enable_dp_output(struct link_encoder * enc,const struct dc_link_settings * link_settings,enum clock_source_id clock_source)959*b843c749SSergey Zigachev void dce110_link_encoder_enable_dp_output(
960*b843c749SSergey Zigachev struct link_encoder *enc,
961*b843c749SSergey Zigachev const struct dc_link_settings *link_settings,
962*b843c749SSergey Zigachev enum clock_source_id clock_source)
963*b843c749SSergey Zigachev {
964*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
965*b843c749SSergey Zigachev struct bp_transmitter_control cntl = { 0 };
966*b843c749SSergey Zigachev enum bp_result result;
967*b843c749SSergey Zigachev
968*b843c749SSergey Zigachev /* Enable the PHY */
969*b843c749SSergey Zigachev
970*b843c749SSergey Zigachev /* number_of_lanes is used for pixel clock adjust,
971*b843c749SSergey Zigachev * but it's not passed to asic_control.
972*b843c749SSergey Zigachev * We need to set number of lanes manually.
973*b843c749SSergey Zigachev */
974*b843c749SSergey Zigachev configure_encoder(enc110, link_settings);
975*b843c749SSergey Zigachev cntl.connector_obj_id = enc110->base.connector;
976*b843c749SSergey Zigachev cntl.action = TRANSMITTER_CONTROL_ENABLE;
977*b843c749SSergey Zigachev cntl.engine_id = enc->preferred_engine;
978*b843c749SSergey Zigachev cntl.transmitter = enc110->base.transmitter;
979*b843c749SSergey Zigachev cntl.pll_id = clock_source;
980*b843c749SSergey Zigachev cntl.signal = SIGNAL_TYPE_DISPLAY_PORT;
981*b843c749SSergey Zigachev cntl.lanes_number = link_settings->lane_count;
982*b843c749SSergey Zigachev cntl.hpd_sel = enc110->base.hpd_source;
983*b843c749SSergey Zigachev cntl.pixel_clock = link_settings->link_rate
984*b843c749SSergey Zigachev * LINK_RATE_REF_FREQ_IN_KHZ;
985*b843c749SSergey Zigachev /* TODO: check if undefined works */
986*b843c749SSergey Zigachev cntl.color_depth = COLOR_DEPTH_UNDEFINED;
987*b843c749SSergey Zigachev
988*b843c749SSergey Zigachev result = link_transmitter_control(enc110, &cntl);
989*b843c749SSergey Zigachev
990*b843c749SSergey Zigachev if (result != BP_RESULT_OK) {
991*b843c749SSergey Zigachev DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n",
992*b843c749SSergey Zigachev __func__);
993*b843c749SSergey Zigachev BREAK_TO_DEBUGGER();
994*b843c749SSergey Zigachev }
995*b843c749SSergey Zigachev }
996*b843c749SSergey Zigachev
997*b843c749SSergey Zigachev /* enables DP PHY output in MST mode */
dce110_link_encoder_enable_dp_mst_output(struct link_encoder * enc,const struct dc_link_settings * link_settings,enum clock_source_id clock_source)998*b843c749SSergey Zigachev void dce110_link_encoder_enable_dp_mst_output(
999*b843c749SSergey Zigachev struct link_encoder *enc,
1000*b843c749SSergey Zigachev const struct dc_link_settings *link_settings,
1001*b843c749SSergey Zigachev enum clock_source_id clock_source)
1002*b843c749SSergey Zigachev {
1003*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
1004*b843c749SSergey Zigachev struct bp_transmitter_control cntl = { 0 };
1005*b843c749SSergey Zigachev enum bp_result result;
1006*b843c749SSergey Zigachev
1007*b843c749SSergey Zigachev /* Enable the PHY */
1008*b843c749SSergey Zigachev
1009*b843c749SSergey Zigachev /* number_of_lanes is used for pixel clock adjust,
1010*b843c749SSergey Zigachev * but it's not passed to asic_control.
1011*b843c749SSergey Zigachev * We need to set number of lanes manually.
1012*b843c749SSergey Zigachev */
1013*b843c749SSergey Zigachev configure_encoder(enc110, link_settings);
1014*b843c749SSergey Zigachev
1015*b843c749SSergey Zigachev cntl.action = TRANSMITTER_CONTROL_ENABLE;
1016*b843c749SSergey Zigachev cntl.engine_id = ENGINE_ID_UNKNOWN;
1017*b843c749SSergey Zigachev cntl.transmitter = enc110->base.transmitter;
1018*b843c749SSergey Zigachev cntl.pll_id = clock_source;
1019*b843c749SSergey Zigachev cntl.signal = SIGNAL_TYPE_DISPLAY_PORT_MST;
1020*b843c749SSergey Zigachev cntl.lanes_number = link_settings->lane_count;
1021*b843c749SSergey Zigachev cntl.hpd_sel = enc110->base.hpd_source;
1022*b843c749SSergey Zigachev cntl.pixel_clock = link_settings->link_rate
1023*b843c749SSergey Zigachev * LINK_RATE_REF_FREQ_IN_KHZ;
1024*b843c749SSergey Zigachev /* TODO: check if undefined works */
1025*b843c749SSergey Zigachev cntl.color_depth = COLOR_DEPTH_UNDEFINED;
1026*b843c749SSergey Zigachev
1027*b843c749SSergey Zigachev result = link_transmitter_control(enc110, &cntl);
1028*b843c749SSergey Zigachev
1029*b843c749SSergey Zigachev if (result != BP_RESULT_OK) {
1030*b843c749SSergey Zigachev DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n",
1031*b843c749SSergey Zigachev __func__);
1032*b843c749SSergey Zigachev BREAK_TO_DEBUGGER();
1033*b843c749SSergey Zigachev }
1034*b843c749SSergey Zigachev }
1035*b843c749SSergey Zigachev /*
1036*b843c749SSergey Zigachev * @brief
1037*b843c749SSergey Zigachev * Disable transmitter and its encoder
1038*b843c749SSergey Zigachev */
dce110_link_encoder_disable_output(struct link_encoder * enc,enum signal_type signal)1039*b843c749SSergey Zigachev void dce110_link_encoder_disable_output(
1040*b843c749SSergey Zigachev struct link_encoder *enc,
1041*b843c749SSergey Zigachev enum signal_type signal)
1042*b843c749SSergey Zigachev {
1043*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
1044*b843c749SSergey Zigachev struct bp_transmitter_control cntl = { 0 };
1045*b843c749SSergey Zigachev enum bp_result result;
1046*b843c749SSergey Zigachev
1047*b843c749SSergey Zigachev if (!dce110_is_dig_enabled(enc)) {
1048*b843c749SSergey Zigachev /* OF_SKIP_POWER_DOWN_INACTIVE_ENCODER */
1049*b843c749SSergey Zigachev return;
1050*b843c749SSergey Zigachev }
1051*b843c749SSergey Zigachev /* Power-down RX and disable GPU PHY should be paired.
1052*b843c749SSergey Zigachev * Disabling PHY without powering down RX may cause
1053*b843c749SSergey Zigachev * symbol lock loss, on which we will get DP Sink interrupt. */
1054*b843c749SSergey Zigachev
1055*b843c749SSergey Zigachev /* There is a case for the DP active dongles
1056*b843c749SSergey Zigachev * where we want to disable the PHY but keep RX powered,
1057*b843c749SSergey Zigachev * for those we need to ignore DP Sink interrupt
1058*b843c749SSergey Zigachev * by checking lane count that has been set
1059*b843c749SSergey Zigachev * on the last do_enable_output(). */
1060*b843c749SSergey Zigachev
1061*b843c749SSergey Zigachev /* disable transmitter */
1062*b843c749SSergey Zigachev cntl.action = TRANSMITTER_CONTROL_DISABLE;
1063*b843c749SSergey Zigachev cntl.transmitter = enc110->base.transmitter;
1064*b843c749SSergey Zigachev cntl.hpd_sel = enc110->base.hpd_source;
1065*b843c749SSergey Zigachev cntl.signal = signal;
1066*b843c749SSergey Zigachev cntl.connector_obj_id = enc110->base.connector;
1067*b843c749SSergey Zigachev
1068*b843c749SSergey Zigachev result = link_transmitter_control(enc110, &cntl);
1069*b843c749SSergey Zigachev
1070*b843c749SSergey Zigachev if (result != BP_RESULT_OK) {
1071*b843c749SSergey Zigachev DC_LOG_ERROR("%s: Failed to execute VBIOS command table!\n",
1072*b843c749SSergey Zigachev __func__);
1073*b843c749SSergey Zigachev BREAK_TO_DEBUGGER();
1074*b843c749SSergey Zigachev return;
1075*b843c749SSergey Zigachev }
1076*b843c749SSergey Zigachev
1077*b843c749SSergey Zigachev /* disable encoder */
1078*b843c749SSergey Zigachev if (dc_is_dp_signal(signal))
1079*b843c749SSergey Zigachev link_encoder_disable(enc110);
1080*b843c749SSergey Zigachev }
1081*b843c749SSergey Zigachev
dce110_link_encoder_dp_set_lane_settings(struct link_encoder * enc,const struct link_training_settings * link_settings)1082*b843c749SSergey Zigachev void dce110_link_encoder_dp_set_lane_settings(
1083*b843c749SSergey Zigachev struct link_encoder *enc,
1084*b843c749SSergey Zigachev const struct link_training_settings *link_settings)
1085*b843c749SSergey Zigachev {
1086*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
1087*b843c749SSergey Zigachev union dpcd_training_lane_set training_lane_set = { { 0 } };
1088*b843c749SSergey Zigachev int32_t lane = 0;
1089*b843c749SSergey Zigachev struct bp_transmitter_control cntl = { 0 };
1090*b843c749SSergey Zigachev
1091*b843c749SSergey Zigachev if (!link_settings) {
1092*b843c749SSergey Zigachev BREAK_TO_DEBUGGER();
1093*b843c749SSergey Zigachev return;
1094*b843c749SSergey Zigachev }
1095*b843c749SSergey Zigachev
1096*b843c749SSergey Zigachev cntl.action = TRANSMITTER_CONTROL_SET_VOLTAGE_AND_PREEMPASIS;
1097*b843c749SSergey Zigachev cntl.transmitter = enc110->base.transmitter;
1098*b843c749SSergey Zigachev cntl.connector_obj_id = enc110->base.connector;
1099*b843c749SSergey Zigachev cntl.lanes_number = link_settings->link_settings.lane_count;
1100*b843c749SSergey Zigachev cntl.hpd_sel = enc110->base.hpd_source;
1101*b843c749SSergey Zigachev cntl.pixel_clock = link_settings->link_settings.link_rate *
1102*b843c749SSergey Zigachev LINK_RATE_REF_FREQ_IN_KHZ;
1103*b843c749SSergey Zigachev
1104*b843c749SSergey Zigachev for (lane = 0; lane < link_settings->link_settings.lane_count; lane++) {
1105*b843c749SSergey Zigachev /* translate lane settings */
1106*b843c749SSergey Zigachev
1107*b843c749SSergey Zigachev training_lane_set.bits.VOLTAGE_SWING_SET =
1108*b843c749SSergey Zigachev link_settings->lane_settings[lane].VOLTAGE_SWING;
1109*b843c749SSergey Zigachev training_lane_set.bits.PRE_EMPHASIS_SET =
1110*b843c749SSergey Zigachev link_settings->lane_settings[lane].PRE_EMPHASIS;
1111*b843c749SSergey Zigachev
1112*b843c749SSergey Zigachev /* post cursor 2 setting only applies to HBR2 link rate */
1113*b843c749SSergey Zigachev if (link_settings->link_settings.link_rate == LINK_RATE_HIGH2) {
1114*b843c749SSergey Zigachev /* this is passed to VBIOS
1115*b843c749SSergey Zigachev * to program post cursor 2 level */
1116*b843c749SSergey Zigachev
1117*b843c749SSergey Zigachev training_lane_set.bits.POST_CURSOR2_SET =
1118*b843c749SSergey Zigachev link_settings->lane_settings[lane].POST_CURSOR2;
1119*b843c749SSergey Zigachev }
1120*b843c749SSergey Zigachev
1121*b843c749SSergey Zigachev cntl.lane_select = lane;
1122*b843c749SSergey Zigachev cntl.lane_settings = training_lane_set.raw;
1123*b843c749SSergey Zigachev
1124*b843c749SSergey Zigachev /* call VBIOS table to set voltage swing and pre-emphasis */
1125*b843c749SSergey Zigachev link_transmitter_control(enc110, &cntl);
1126*b843c749SSergey Zigachev }
1127*b843c749SSergey Zigachev }
1128*b843c749SSergey Zigachev
1129*b843c749SSergey Zigachev /* set DP PHY test and training patterns */
dce110_link_encoder_dp_set_phy_pattern(struct link_encoder * enc,const struct encoder_set_dp_phy_pattern_param * param)1130*b843c749SSergey Zigachev void dce110_link_encoder_dp_set_phy_pattern(
1131*b843c749SSergey Zigachev struct link_encoder *enc,
1132*b843c749SSergey Zigachev const struct encoder_set_dp_phy_pattern_param *param)
1133*b843c749SSergey Zigachev {
1134*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
1135*b843c749SSergey Zigachev
1136*b843c749SSergey Zigachev switch (param->dp_phy_pattern) {
1137*b843c749SSergey Zigachev case DP_TEST_PATTERN_TRAINING_PATTERN1:
1138*b843c749SSergey Zigachev dce110_link_encoder_set_dp_phy_pattern_training_pattern(enc, 0);
1139*b843c749SSergey Zigachev break;
1140*b843c749SSergey Zigachev case DP_TEST_PATTERN_TRAINING_PATTERN2:
1141*b843c749SSergey Zigachev dce110_link_encoder_set_dp_phy_pattern_training_pattern(enc, 1);
1142*b843c749SSergey Zigachev break;
1143*b843c749SSergey Zigachev case DP_TEST_PATTERN_TRAINING_PATTERN3:
1144*b843c749SSergey Zigachev dce110_link_encoder_set_dp_phy_pattern_training_pattern(enc, 2);
1145*b843c749SSergey Zigachev break;
1146*b843c749SSergey Zigachev case DP_TEST_PATTERN_TRAINING_PATTERN4:
1147*b843c749SSergey Zigachev dce110_link_encoder_set_dp_phy_pattern_training_pattern(enc, 3);
1148*b843c749SSergey Zigachev break;
1149*b843c749SSergey Zigachev case DP_TEST_PATTERN_D102:
1150*b843c749SSergey Zigachev set_dp_phy_pattern_d102(enc110);
1151*b843c749SSergey Zigachev break;
1152*b843c749SSergey Zigachev case DP_TEST_PATTERN_SYMBOL_ERROR:
1153*b843c749SSergey Zigachev set_dp_phy_pattern_symbol_error(enc110);
1154*b843c749SSergey Zigachev break;
1155*b843c749SSergey Zigachev case DP_TEST_PATTERN_PRBS7:
1156*b843c749SSergey Zigachev set_dp_phy_pattern_prbs7(enc110);
1157*b843c749SSergey Zigachev break;
1158*b843c749SSergey Zigachev case DP_TEST_PATTERN_80BIT_CUSTOM:
1159*b843c749SSergey Zigachev set_dp_phy_pattern_80bit_custom(
1160*b843c749SSergey Zigachev enc110, param->custom_pattern);
1161*b843c749SSergey Zigachev break;
1162*b843c749SSergey Zigachev case DP_TEST_PATTERN_CP2520_1:
1163*b843c749SSergey Zigachev set_dp_phy_pattern_hbr2_compliance_cp2520_2(enc110, 1);
1164*b843c749SSergey Zigachev break;
1165*b843c749SSergey Zigachev case DP_TEST_PATTERN_CP2520_2:
1166*b843c749SSergey Zigachev set_dp_phy_pattern_hbr2_compliance_cp2520_2(enc110, 2);
1167*b843c749SSergey Zigachev break;
1168*b843c749SSergey Zigachev case DP_TEST_PATTERN_CP2520_3:
1169*b843c749SSergey Zigachev set_dp_phy_pattern_hbr2_compliance_cp2520_2(enc110, 3);
1170*b843c749SSergey Zigachev break;
1171*b843c749SSergey Zigachev case DP_TEST_PATTERN_VIDEO_MODE: {
1172*b843c749SSergey Zigachev set_dp_phy_pattern_passthrough_mode(
1173*b843c749SSergey Zigachev enc110, param->dp_panel_mode);
1174*b843c749SSergey Zigachev break;
1175*b843c749SSergey Zigachev }
1176*b843c749SSergey Zigachev
1177*b843c749SSergey Zigachev default:
1178*b843c749SSergey Zigachev /* invalid phy pattern */
1179*b843c749SSergey Zigachev ASSERT_CRITICAL(false);
1180*b843c749SSergey Zigachev break;
1181*b843c749SSergey Zigachev }
1182*b843c749SSergey Zigachev }
1183*b843c749SSergey Zigachev
fill_stream_allocation_row_info(const struct link_mst_stream_allocation * stream_allocation,uint32_t * src,uint32_t * slots)1184*b843c749SSergey Zigachev static void fill_stream_allocation_row_info(
1185*b843c749SSergey Zigachev const struct link_mst_stream_allocation *stream_allocation,
1186*b843c749SSergey Zigachev uint32_t *src,
1187*b843c749SSergey Zigachev uint32_t *slots)
1188*b843c749SSergey Zigachev {
1189*b843c749SSergey Zigachev const struct stream_encoder *stream_enc = stream_allocation->stream_enc;
1190*b843c749SSergey Zigachev
1191*b843c749SSergey Zigachev if (stream_enc) {
1192*b843c749SSergey Zigachev *src = stream_enc->id;
1193*b843c749SSergey Zigachev *slots = stream_allocation->slot_count;
1194*b843c749SSergey Zigachev } else {
1195*b843c749SSergey Zigachev *src = 0;
1196*b843c749SSergey Zigachev *slots = 0;
1197*b843c749SSergey Zigachev }
1198*b843c749SSergey Zigachev }
1199*b843c749SSergey Zigachev
1200*b843c749SSergey Zigachev /* programs DP MST VC payload allocation */
dce110_link_encoder_update_mst_stream_allocation_table(struct link_encoder * enc,const struct link_mst_stream_allocation_table * table)1201*b843c749SSergey Zigachev void dce110_link_encoder_update_mst_stream_allocation_table(
1202*b843c749SSergey Zigachev struct link_encoder *enc,
1203*b843c749SSergey Zigachev const struct link_mst_stream_allocation_table *table)
1204*b843c749SSergey Zigachev {
1205*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
1206*b843c749SSergey Zigachev uint32_t value0 = 0;
1207*b843c749SSergey Zigachev uint32_t value1 = 0;
1208*b843c749SSergey Zigachev uint32_t value2 = 0;
1209*b843c749SSergey Zigachev uint32_t slots = 0;
1210*b843c749SSergey Zigachev uint32_t src = 0;
1211*b843c749SSergey Zigachev uint32_t retries = 0;
1212*b843c749SSergey Zigachev
1213*b843c749SSergey Zigachev /* For CZ, there are only 3 pipes. So Virtual channel is up 3.*/
1214*b843c749SSergey Zigachev
1215*b843c749SSergey Zigachev /* --- Set MSE Stream Attribute -
1216*b843c749SSergey Zigachev * Setup VC Payload Table on Tx Side,
1217*b843c749SSergey Zigachev * Issue allocation change trigger
1218*b843c749SSergey Zigachev * to commit payload on both tx and rx side */
1219*b843c749SSergey Zigachev
1220*b843c749SSergey Zigachev /* we should clean-up table each time */
1221*b843c749SSergey Zigachev
1222*b843c749SSergey Zigachev if (table->stream_count >= 1) {
1223*b843c749SSergey Zigachev fill_stream_allocation_row_info(
1224*b843c749SSergey Zigachev &table->stream_allocations[0],
1225*b843c749SSergey Zigachev &src,
1226*b843c749SSergey Zigachev &slots);
1227*b843c749SSergey Zigachev } else {
1228*b843c749SSergey Zigachev src = 0;
1229*b843c749SSergey Zigachev slots = 0;
1230*b843c749SSergey Zigachev }
1231*b843c749SSergey Zigachev
1232*b843c749SSergey Zigachev REG_UPDATE_2(DP_MSE_SAT0,
1233*b843c749SSergey Zigachev DP_MSE_SAT_SRC0, src,
1234*b843c749SSergey Zigachev DP_MSE_SAT_SLOT_COUNT0, slots);
1235*b843c749SSergey Zigachev
1236*b843c749SSergey Zigachev if (table->stream_count >= 2) {
1237*b843c749SSergey Zigachev fill_stream_allocation_row_info(
1238*b843c749SSergey Zigachev &table->stream_allocations[1],
1239*b843c749SSergey Zigachev &src,
1240*b843c749SSergey Zigachev &slots);
1241*b843c749SSergey Zigachev } else {
1242*b843c749SSergey Zigachev src = 0;
1243*b843c749SSergey Zigachev slots = 0;
1244*b843c749SSergey Zigachev }
1245*b843c749SSergey Zigachev
1246*b843c749SSergey Zigachev REG_UPDATE_2(DP_MSE_SAT0,
1247*b843c749SSergey Zigachev DP_MSE_SAT_SRC1, src,
1248*b843c749SSergey Zigachev DP_MSE_SAT_SLOT_COUNT1, slots);
1249*b843c749SSergey Zigachev
1250*b843c749SSergey Zigachev if (table->stream_count >= 3) {
1251*b843c749SSergey Zigachev fill_stream_allocation_row_info(
1252*b843c749SSergey Zigachev &table->stream_allocations[2],
1253*b843c749SSergey Zigachev &src,
1254*b843c749SSergey Zigachev &slots);
1255*b843c749SSergey Zigachev } else {
1256*b843c749SSergey Zigachev src = 0;
1257*b843c749SSergey Zigachev slots = 0;
1258*b843c749SSergey Zigachev }
1259*b843c749SSergey Zigachev
1260*b843c749SSergey Zigachev REG_UPDATE_2(DP_MSE_SAT1,
1261*b843c749SSergey Zigachev DP_MSE_SAT_SRC2, src,
1262*b843c749SSergey Zigachev DP_MSE_SAT_SLOT_COUNT2, slots);
1263*b843c749SSergey Zigachev
1264*b843c749SSergey Zigachev if (table->stream_count >= 4) {
1265*b843c749SSergey Zigachev fill_stream_allocation_row_info(
1266*b843c749SSergey Zigachev &table->stream_allocations[3],
1267*b843c749SSergey Zigachev &src,
1268*b843c749SSergey Zigachev &slots);
1269*b843c749SSergey Zigachev } else {
1270*b843c749SSergey Zigachev src = 0;
1271*b843c749SSergey Zigachev slots = 0;
1272*b843c749SSergey Zigachev }
1273*b843c749SSergey Zigachev
1274*b843c749SSergey Zigachev REG_UPDATE_2(DP_MSE_SAT1,
1275*b843c749SSergey Zigachev DP_MSE_SAT_SRC3, src,
1276*b843c749SSergey Zigachev DP_MSE_SAT_SLOT_COUNT3, slots);
1277*b843c749SSergey Zigachev
1278*b843c749SSergey Zigachev /* --- wait for transaction finish */
1279*b843c749SSergey Zigachev
1280*b843c749SSergey Zigachev /* send allocation change trigger (ACT) ?
1281*b843c749SSergey Zigachev * this step first sends the ACT,
1282*b843c749SSergey Zigachev * then double buffers the SAT into the hardware
1283*b843c749SSergey Zigachev * making the new allocation active on the DP MST mode link */
1284*b843c749SSergey Zigachev
1285*b843c749SSergey Zigachev
1286*b843c749SSergey Zigachev /* DP_MSE_SAT_UPDATE:
1287*b843c749SSergey Zigachev * 0 - No Action
1288*b843c749SSergey Zigachev * 1 - Update SAT with trigger
1289*b843c749SSergey Zigachev * 2 - Update SAT without trigger */
1290*b843c749SSergey Zigachev
1291*b843c749SSergey Zigachev REG_UPDATE(DP_MSE_SAT_UPDATE,
1292*b843c749SSergey Zigachev DP_MSE_SAT_UPDATE, 1);
1293*b843c749SSergey Zigachev
1294*b843c749SSergey Zigachev /* wait for update to complete
1295*b843c749SSergey Zigachev * (i.e. DP_MSE_SAT_UPDATE field is reset to 0)
1296*b843c749SSergey Zigachev * then wait for the transmission
1297*b843c749SSergey Zigachev * of at least 16 MTP headers on immediate local link.
1298*b843c749SSergey Zigachev * i.e. DP_MSE_16_MTP_KEEPOUT field (read only) is reset to 0
1299*b843c749SSergey Zigachev * a value of 1 indicates that DP MST mode
1300*b843c749SSergey Zigachev * is in the 16 MTP keepout region after a VC has been added.
1301*b843c749SSergey Zigachev * MST stream bandwidth (VC rate) can be configured
1302*b843c749SSergey Zigachev * after this bit is cleared */
1303*b843c749SSergey Zigachev
1304*b843c749SSergey Zigachev do {
1305*b843c749SSergey Zigachev udelay(10);
1306*b843c749SSergey Zigachev
1307*b843c749SSergey Zigachev value0 = REG_READ(DP_MSE_SAT_UPDATE);
1308*b843c749SSergey Zigachev
1309*b843c749SSergey Zigachev REG_GET(DP_MSE_SAT_UPDATE,
1310*b843c749SSergey Zigachev DP_MSE_SAT_UPDATE, &value1);
1311*b843c749SSergey Zigachev
1312*b843c749SSergey Zigachev REG_GET(DP_MSE_SAT_UPDATE,
1313*b843c749SSergey Zigachev DP_MSE_16_MTP_KEEPOUT, &value2);
1314*b843c749SSergey Zigachev
1315*b843c749SSergey Zigachev /* bit field DP_MSE_SAT_UPDATE is set to 1 already */
1316*b843c749SSergey Zigachev if (!value1 && !value2)
1317*b843c749SSergey Zigachev break;
1318*b843c749SSergey Zigachev ++retries;
1319*b843c749SSergey Zigachev } while (retries < DP_MST_UPDATE_MAX_RETRY);
1320*b843c749SSergey Zigachev }
1321*b843c749SSergey Zigachev
dce110_link_encoder_connect_dig_be_to_fe(struct link_encoder * enc,enum engine_id engine,bool connect)1322*b843c749SSergey Zigachev void dce110_link_encoder_connect_dig_be_to_fe(
1323*b843c749SSergey Zigachev struct link_encoder *enc,
1324*b843c749SSergey Zigachev enum engine_id engine,
1325*b843c749SSergey Zigachev bool connect)
1326*b843c749SSergey Zigachev {
1327*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
1328*b843c749SSergey Zigachev uint32_t field;
1329*b843c749SSergey Zigachev
1330*b843c749SSergey Zigachev if (engine != ENGINE_ID_UNKNOWN) {
1331*b843c749SSergey Zigachev
1332*b843c749SSergey Zigachev REG_GET(DIG_BE_CNTL, DIG_FE_SOURCE_SELECT, &field);
1333*b843c749SSergey Zigachev
1334*b843c749SSergey Zigachev if (connect)
1335*b843c749SSergey Zigachev field |= get_frontend_source(engine);
1336*b843c749SSergey Zigachev else
1337*b843c749SSergey Zigachev field &= ~get_frontend_source(engine);
1338*b843c749SSergey Zigachev
1339*b843c749SSergey Zigachev REG_UPDATE(DIG_BE_CNTL, DIG_FE_SOURCE_SELECT, field);
1340*b843c749SSergey Zigachev }
1341*b843c749SSergey Zigachev }
1342*b843c749SSergey Zigachev
dce110_link_encoder_enable_hpd(struct link_encoder * enc)1343*b843c749SSergey Zigachev void dce110_link_encoder_enable_hpd(struct link_encoder *enc)
1344*b843c749SSergey Zigachev {
1345*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
1346*b843c749SSergey Zigachev struct dc_context *ctx = enc110->base.ctx;
1347*b843c749SSergey Zigachev uint32_t addr = HPD_REG(DC_HPD_CONTROL);
1348*b843c749SSergey Zigachev uint32_t hpd_enable = 0;
1349*b843c749SSergey Zigachev uint32_t value = dm_read_reg(ctx, addr);
1350*b843c749SSergey Zigachev
1351*b843c749SSergey Zigachev get_reg_field_value(hpd_enable, DC_HPD_CONTROL, DC_HPD_EN);
1352*b843c749SSergey Zigachev
1353*b843c749SSergey Zigachev if (hpd_enable == 0)
1354*b843c749SSergey Zigachev set_reg_field_value(value, 1, DC_HPD_CONTROL, DC_HPD_EN);
1355*b843c749SSergey Zigachev }
1356*b843c749SSergey Zigachev
dce110_link_encoder_disable_hpd(struct link_encoder * enc)1357*b843c749SSergey Zigachev void dce110_link_encoder_disable_hpd(struct link_encoder *enc)
1358*b843c749SSergey Zigachev {
1359*b843c749SSergey Zigachev struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
1360*b843c749SSergey Zigachev struct dc_context *ctx = enc110->base.ctx;
1361*b843c749SSergey Zigachev uint32_t addr = HPD_REG(DC_HPD_CONTROL);
1362*b843c749SSergey Zigachev uint32_t value = dm_read_reg(ctx, addr);
1363*b843c749SSergey Zigachev
1364*b843c749SSergey Zigachev set_reg_field_value(value, 0, DC_HPD_CONTROL, DC_HPD_EN);
1365*b843c749SSergey Zigachev }
1366