1110d3968SNicholas Kazlauskas /*
2110d3968SNicholas Kazlauskas * Copyright 2012-15 Advanced Micro Devices, Inc.
3110d3968SNicholas Kazlauskas *
4110d3968SNicholas Kazlauskas * Permission is hereby granted, free of charge, to any person obtaining a
5110d3968SNicholas Kazlauskas * copy of this software and associated documentation files (the "Software"),
6110d3968SNicholas Kazlauskas * to deal in the Software without restriction, including without limitation
7110d3968SNicholas Kazlauskas * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8110d3968SNicholas Kazlauskas * and/or sell copies of the Software, and to permit persons to whom the
9110d3968SNicholas Kazlauskas * Software is furnished to do so, subject to the following conditions:
10110d3968SNicholas Kazlauskas *
11110d3968SNicholas Kazlauskas * The above copyright notice and this permission notice shall be included in
12110d3968SNicholas Kazlauskas * all copies or substantial portions of the Software.
13110d3968SNicholas Kazlauskas *
14110d3968SNicholas Kazlauskas * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15110d3968SNicholas Kazlauskas * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16110d3968SNicholas Kazlauskas * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17110d3968SNicholas Kazlauskas * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18110d3968SNicholas Kazlauskas * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19110d3968SNicholas Kazlauskas * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20110d3968SNicholas Kazlauskas * OTHER DEALINGS IN THE SOFTWARE.
21110d3968SNicholas Kazlauskas *
22110d3968SNicholas Kazlauskas * Authors: AMD
23110d3968SNicholas Kazlauskas *
24110d3968SNicholas Kazlauskas */
25110d3968SNicholas Kazlauskas
26110d3968SNicholas Kazlauskas #include "dcn31_optc.h"
27110d3968SNicholas Kazlauskas
28110d3968SNicholas Kazlauskas #include "dcn30/dcn30_optc.h"
29110d3968SNicholas Kazlauskas #include "reg_helper.h"
30110d3968SNicholas Kazlauskas #include "dc.h"
31110d3968SNicholas Kazlauskas #include "dcn_calc_math.h"
32110d3968SNicholas Kazlauskas
33110d3968SNicholas Kazlauskas #define REG(reg)\
34110d3968SNicholas Kazlauskas optc1->tg_regs->reg
35110d3968SNicholas Kazlauskas
36110d3968SNicholas Kazlauskas #define CTX \
37110d3968SNicholas Kazlauskas optc1->base.ctx
38110d3968SNicholas Kazlauskas
39110d3968SNicholas Kazlauskas #undef FN
40110d3968SNicholas Kazlauskas #define FN(reg_name, field_name) \
41110d3968SNicholas Kazlauskas optc1->tg_shift->field_name, optc1->tg_mask->field_name
42110d3968SNicholas Kazlauskas
optc31_set_odm_combine(struct timing_generator * optc,int * opp_id,int opp_cnt,int segment_width,int last_segment_width)43110d3968SNicholas Kazlauskas static void optc31_set_odm_combine(struct timing_generator *optc, int *opp_id, int opp_cnt,
44f9d48a88SWenjing Liu int segment_width, int last_segment_width)
45110d3968SNicholas Kazlauskas {
46110d3968SNicholas Kazlauskas struct optc *optc1 = DCN10TG_FROM_TG(optc);
47110d3968SNicholas Kazlauskas uint32_t memory_mask = 0;
48f9d48a88SWenjing Liu int mem_count_per_opp = (segment_width + 2559) / 2560;
49110d3968SNicholas Kazlauskas
50110d3968SNicholas Kazlauskas /* Assume less than 6 pipes */
51110d3968SNicholas Kazlauskas if (opp_cnt == 4) {
52110d3968SNicholas Kazlauskas if (mem_count_per_opp == 1)
53110d3968SNicholas Kazlauskas memory_mask = 0xf;
54110d3968SNicholas Kazlauskas else {
55110d3968SNicholas Kazlauskas ASSERT(mem_count_per_opp == 2);
56110d3968SNicholas Kazlauskas memory_mask = 0xff;
57110d3968SNicholas Kazlauskas }
58110d3968SNicholas Kazlauskas } else if (mem_count_per_opp == 1)
59110d3968SNicholas Kazlauskas memory_mask = 0x1 << (opp_id[0] * 2) | 0x1 << (opp_id[1] * 2);
60110d3968SNicholas Kazlauskas else if (mem_count_per_opp == 2)
61110d3968SNicholas Kazlauskas memory_mask = 0x3 << (opp_id[0] * 2) | 0x3 << (opp_id[1] * 2);
62110d3968SNicholas Kazlauskas else if (mem_count_per_opp == 3)
63110d3968SNicholas Kazlauskas memory_mask = 0x77;
64110d3968SNicholas Kazlauskas else if (mem_count_per_opp == 4)
65110d3968SNicholas Kazlauskas memory_mask = 0xff;
66110d3968SNicholas Kazlauskas
67110d3968SNicholas Kazlauskas if (REG(OPTC_MEMORY_CONFIG))
68110d3968SNicholas Kazlauskas REG_SET(OPTC_MEMORY_CONFIG, 0,
69110d3968SNicholas Kazlauskas OPTC_MEM_SEL, memory_mask);
70110d3968SNicholas Kazlauskas
71110d3968SNicholas Kazlauskas if (opp_cnt == 2) {
72110d3968SNicholas Kazlauskas REG_SET_3(OPTC_DATA_SOURCE_SELECT, 0,
73110d3968SNicholas Kazlauskas OPTC_NUM_OF_INPUT_SEGMENT, 1,
74110d3968SNicholas Kazlauskas OPTC_SEG0_SRC_SEL, opp_id[0],
75110d3968SNicholas Kazlauskas OPTC_SEG1_SRC_SEL, opp_id[1]);
76110d3968SNicholas Kazlauskas } else if (opp_cnt == 4) {
77110d3968SNicholas Kazlauskas REG_SET_5(OPTC_DATA_SOURCE_SELECT, 0,
78110d3968SNicholas Kazlauskas OPTC_NUM_OF_INPUT_SEGMENT, 3,
79110d3968SNicholas Kazlauskas OPTC_SEG0_SRC_SEL, opp_id[0],
80110d3968SNicholas Kazlauskas OPTC_SEG1_SRC_SEL, opp_id[1],
81110d3968SNicholas Kazlauskas OPTC_SEG2_SRC_SEL, opp_id[2],
82110d3968SNicholas Kazlauskas OPTC_SEG3_SRC_SEL, opp_id[3]);
83110d3968SNicholas Kazlauskas }
84110d3968SNicholas Kazlauskas
85110d3968SNicholas Kazlauskas REG_UPDATE(OPTC_WIDTH_CONTROL,
86f9d48a88SWenjing Liu OPTC_SEGMENT_WIDTH, segment_width);
87110d3968SNicholas Kazlauskas
88110d3968SNicholas Kazlauskas REG_SET(OTG_H_TIMING_CNTL, 0, OTG_H_TIMING_DIV_MODE, opp_cnt - 1);
89110d3968SNicholas Kazlauskas optc1->opp_count = opp_cnt;
90110d3968SNicholas Kazlauskas }
91110d3968SNicholas Kazlauskas
926452c544SRandy Dunlap /*
93110d3968SNicholas Kazlauskas * Enable CRTC - call ASIC Control Object to enable Timing generator.
94110d3968SNicholas Kazlauskas */
optc31_enable_crtc(struct timing_generator * optc)95110d3968SNicholas Kazlauskas static bool optc31_enable_crtc(struct timing_generator *optc)
96110d3968SNicholas Kazlauskas {
97110d3968SNicholas Kazlauskas struct optc *optc1 = DCN10TG_FROM_TG(optc);
98110d3968SNicholas Kazlauskas
99110d3968SNicholas Kazlauskas /* opp instance for OTG, 1 to 1 mapping and odm will adjust */
100110d3968SNicholas Kazlauskas REG_UPDATE(OPTC_DATA_SOURCE_SELECT,
101110d3968SNicholas Kazlauskas OPTC_SEG0_SRC_SEL, optc->inst);
102110d3968SNicholas Kazlauskas
103110d3968SNicholas Kazlauskas /* VTG enable first is for HW workaround */
104110d3968SNicholas Kazlauskas REG_UPDATE(CONTROL,
105110d3968SNicholas Kazlauskas VTG0_ENABLE, 1);
106110d3968SNicholas Kazlauskas
107110d3968SNicholas Kazlauskas REG_SEQ_START();
108110d3968SNicholas Kazlauskas
109110d3968SNicholas Kazlauskas /* Enable CRTC */
110110d3968SNicholas Kazlauskas REG_UPDATE_2(OTG_CONTROL,
111110d3968SNicholas Kazlauskas OTG_DISABLE_POINT_CNTL, 2,
112110d3968SNicholas Kazlauskas OTG_MASTER_EN, 1);
113110d3968SNicholas Kazlauskas
114110d3968SNicholas Kazlauskas REG_SEQ_SUBMIT();
115110d3968SNicholas Kazlauskas REG_SEQ_WAIT_DONE();
116110d3968SNicholas Kazlauskas
117110d3968SNicholas Kazlauskas return true;
118110d3968SNicholas Kazlauskas }
119110d3968SNicholas Kazlauskas
120110d3968SNicholas Kazlauskas /* disable_crtc - call ASIC Control Object to disable Timing generator. */
optc31_disable_crtc(struct timing_generator * optc)121110d3968SNicholas Kazlauskas static bool optc31_disable_crtc(struct timing_generator *optc)
122110d3968SNicholas Kazlauskas {
123110d3968SNicholas Kazlauskas struct optc *optc1 = DCN10TG_FROM_TG(optc);
124a8783042SYihan Zhu
125a8783042SYihan Zhu REG_UPDATE_5(OPTC_DATA_SOURCE_SELECT,
126a8783042SYihan Zhu OPTC_SEG0_SRC_SEL, 0xf,
127a8783042SYihan Zhu OPTC_SEG1_SRC_SEL, 0xf,
128a8783042SYihan Zhu OPTC_SEG2_SRC_SEL, 0xf,
129a8783042SYihan Zhu OPTC_SEG3_SRC_SEL, 0xf,
130a8783042SYihan Zhu OPTC_NUM_OF_INPUT_SEGMENT, 0);
131a8783042SYihan Zhu
132a8783042SYihan Zhu REG_UPDATE(OPTC_MEMORY_CONFIG,
133a8783042SYihan Zhu OPTC_MEM_SEL, 0);
134a8783042SYihan Zhu
135110d3968SNicholas Kazlauskas /* disable otg request until end of the first line
136110d3968SNicholas Kazlauskas * in the vertical blank region
137110d3968SNicholas Kazlauskas */
138110d3968SNicholas Kazlauskas REG_UPDATE(OTG_CONTROL,
139110d3968SNicholas Kazlauskas OTG_MASTER_EN, 0);
140110d3968SNicholas Kazlauskas
141110d3968SNicholas Kazlauskas REG_UPDATE(CONTROL,
142110d3968SNicholas Kazlauskas VTG0_ENABLE, 0);
143110d3968SNicholas Kazlauskas
144110d3968SNicholas Kazlauskas /* CRTC disabled, so disable clock. */
145110d3968SNicholas Kazlauskas REG_WAIT(OTG_CLOCK_CONTROL,
146110d3968SNicholas Kazlauskas OTG_BUSY, 0,
147110d3968SNicholas Kazlauskas 1, 100000);
148a905f0b5SCharlene Liu optc1_clear_optc_underflow(optc);
149110d3968SNicholas Kazlauskas
150110d3968SNicholas Kazlauskas return true;
151110d3968SNicholas Kazlauskas }
1529724b849SCharlene Liu /*
1539724b849SCharlene Liu * Immediate_Disable_Crtc - this is to temp disable Timing generator without reset ODM.
1549724b849SCharlene Liu */
optc31_immediate_disable_crtc(struct timing_generator * optc)1552ce0b218SNicholas Kazlauskas bool optc31_immediate_disable_crtc(struct timing_generator *optc)
156110d3968SNicholas Kazlauskas {
157110d3968SNicholas Kazlauskas struct optc *optc1 = DCN10TG_FROM_TG(optc);
158110d3968SNicholas Kazlauskas
159110d3968SNicholas Kazlauskas REG_UPDATE_2(OTG_CONTROL,
160110d3968SNicholas Kazlauskas OTG_DISABLE_POINT_CNTL, 0,
161110d3968SNicholas Kazlauskas OTG_MASTER_EN, 0);
162110d3968SNicholas Kazlauskas
163110d3968SNicholas Kazlauskas REG_UPDATE(CONTROL,
164110d3968SNicholas Kazlauskas VTG0_ENABLE, 0);
165110d3968SNicholas Kazlauskas
166110d3968SNicholas Kazlauskas /* CRTC disabled, so disable clock. */
1679724b849SCharlene Liu if (optc->ctx->dce_environment != DCE_ENV_DIAG)
168110d3968SNicholas Kazlauskas REG_WAIT(OTG_CLOCK_CONTROL,
169110d3968SNicholas Kazlauskas OTG_BUSY, 0,
170110d3968SNicholas Kazlauskas 1, 100000);
171110d3968SNicholas Kazlauskas
1729724b849SCharlene Liu
173a905f0b5SCharlene Liu /* clear the false state */
174a905f0b5SCharlene Liu optc1_clear_optc_underflow(optc);
175a905f0b5SCharlene Liu
176110d3968SNicholas Kazlauskas return true;
177110d3968SNicholas Kazlauskas }
178110d3968SNicholas Kazlauskas
optc31_set_drr(struct timing_generator * optc,const struct drr_params * params)17977a35bb5SEric Bernstein void optc31_set_drr(
180110d3968SNicholas Kazlauskas struct timing_generator *optc,
181110d3968SNicholas Kazlauskas const struct drr_params *params)
182110d3968SNicholas Kazlauskas {
183110d3968SNicholas Kazlauskas struct optc *optc1 = DCN10TG_FROM_TG(optc);
184110d3968SNicholas Kazlauskas
185110d3968SNicholas Kazlauskas if (params != NULL &&
186110d3968SNicholas Kazlauskas params->vertical_total_max > 0 &&
187110d3968SNicholas Kazlauskas params->vertical_total_min > 0) {
188110d3968SNicholas Kazlauskas
189110d3968SNicholas Kazlauskas if (params->vertical_total_mid != 0) {
190110d3968SNicholas Kazlauskas
191110d3968SNicholas Kazlauskas REG_SET(OTG_V_TOTAL_MID, 0,
192110d3968SNicholas Kazlauskas OTG_V_TOTAL_MID, params->vertical_total_mid - 1);
193110d3968SNicholas Kazlauskas
194110d3968SNicholas Kazlauskas REG_UPDATE_2(OTG_V_TOTAL_CONTROL,
195110d3968SNicholas Kazlauskas OTG_VTOTAL_MID_REPLACING_MAX_EN, 1,
196110d3968SNicholas Kazlauskas OTG_VTOTAL_MID_FRAME_NUM,
197110d3968SNicholas Kazlauskas (uint8_t)params->vertical_total_mid_frame_num);
198110d3968SNicholas Kazlauskas
199110d3968SNicholas Kazlauskas }
200110d3968SNicholas Kazlauskas
201110d3968SNicholas Kazlauskas optc->funcs->set_vtotal_min_max(optc, params->vertical_total_min - 1, params->vertical_total_max - 1);
202110d3968SNicholas Kazlauskas
203110d3968SNicholas Kazlauskas /*
204110d3968SNicholas Kazlauskas * MIN_MASK_EN is gone and MASK is now always enabled.
205110d3968SNicholas Kazlauskas *
206110d3968SNicholas Kazlauskas * To get it to it work with manual trigger we need to make sure
207110d3968SNicholas Kazlauskas * we program the correct bit.
208110d3968SNicholas Kazlauskas */
209110d3968SNicholas Kazlauskas REG_UPDATE_4(OTG_V_TOTAL_CONTROL,
210110d3968SNicholas Kazlauskas OTG_V_TOTAL_MIN_SEL, 1,
211110d3968SNicholas Kazlauskas OTG_V_TOTAL_MAX_SEL, 1,
212110d3968SNicholas Kazlauskas OTG_FORCE_LOCK_ON_EVENT, 0,
213110d3968SNicholas Kazlauskas OTG_SET_V_TOTAL_MIN_MASK, (1 << 1)); /* TRIGA */
214110d3968SNicholas Kazlauskas
215110d3968SNicholas Kazlauskas // Setup manual flow control for EOF via TRIG_A
216110d3968SNicholas Kazlauskas optc->funcs->setup_manual_trigger(optc);
217110d3968SNicholas Kazlauskas } else {
218110d3968SNicholas Kazlauskas REG_UPDATE_4(OTG_V_TOTAL_CONTROL,
219110d3968SNicholas Kazlauskas OTG_SET_V_TOTAL_MIN_MASK, 0,
220110d3968SNicholas Kazlauskas OTG_V_TOTAL_MIN_SEL, 0,
221110d3968SNicholas Kazlauskas OTG_V_TOTAL_MAX_SEL, 0,
222110d3968SNicholas Kazlauskas OTG_FORCE_LOCK_ON_EVENT, 0);
223110d3968SNicholas Kazlauskas
224110d3968SNicholas Kazlauskas optc->funcs->set_vtotal_min_max(optc, 0, 0);
225110d3968SNicholas Kazlauskas }
226110d3968SNicholas Kazlauskas }
227110d3968SNicholas Kazlauskas
optc3_init_odm(struct timing_generator * optc)2283e80a5b0SDuncan Ma void optc3_init_odm(struct timing_generator *optc)
2293e80a5b0SDuncan Ma {
2303e80a5b0SDuncan Ma struct optc *optc1 = DCN10TG_FROM_TG(optc);
2313e80a5b0SDuncan Ma
2323e80a5b0SDuncan Ma REG_SET_5(OPTC_DATA_SOURCE_SELECT, 0,
2333e80a5b0SDuncan Ma OPTC_NUM_OF_INPUT_SEGMENT, 0,
2343e80a5b0SDuncan Ma OPTC_SEG0_SRC_SEL, optc->inst,
2353e80a5b0SDuncan Ma OPTC_SEG1_SRC_SEL, 0xf,
2363e80a5b0SDuncan Ma OPTC_SEG2_SRC_SEL, 0xf,
2373e80a5b0SDuncan Ma OPTC_SEG3_SRC_SEL, 0xf
2383e80a5b0SDuncan Ma );
2393e80a5b0SDuncan Ma
2403e80a5b0SDuncan Ma REG_SET(OTG_H_TIMING_CNTL, 0,
2413e80a5b0SDuncan Ma OTG_H_TIMING_DIV_MODE, 0);
2423e80a5b0SDuncan Ma
2433e80a5b0SDuncan Ma REG_SET(OPTC_MEMORY_CONFIG, 0,
2443e80a5b0SDuncan Ma OPTC_MEM_SEL, 0);
2453e80a5b0SDuncan Ma optc1->opp_count = 1;
2463e80a5b0SDuncan Ma }
2473e80a5b0SDuncan Ma
optc31_read_otg_state(struct timing_generator * optc,struct dcn_otg_state * s)24806b0a4adSJosip Pavic void optc31_read_otg_state(struct timing_generator *optc,
24906b0a4adSJosip Pavic struct dcn_otg_state *s)
25006b0a4adSJosip Pavic {
25106b0a4adSJosip Pavic struct optc *optc1 = DCN10TG_FROM_TG(optc);
25206b0a4adSJosip Pavic
25306b0a4adSJosip Pavic REG_GET(OTG_CONTROL,
25406b0a4adSJosip Pavic OTG_MASTER_EN, &s->otg_enabled);
25506b0a4adSJosip Pavic
25606b0a4adSJosip Pavic REG_GET_2(OTG_V_BLANK_START_END,
25706b0a4adSJosip Pavic OTG_V_BLANK_START, &s->v_blank_start,
25806b0a4adSJosip Pavic OTG_V_BLANK_END, &s->v_blank_end);
25906b0a4adSJosip Pavic
26006b0a4adSJosip Pavic REG_GET(OTG_V_SYNC_A_CNTL,
26106b0a4adSJosip Pavic OTG_V_SYNC_A_POL, &s->v_sync_a_pol);
26206b0a4adSJosip Pavic
26306b0a4adSJosip Pavic REG_GET(OTG_V_TOTAL,
26406b0a4adSJosip Pavic OTG_V_TOTAL, &s->v_total);
26506b0a4adSJosip Pavic
26606b0a4adSJosip Pavic REG_GET(OTG_V_TOTAL_MAX,
26706b0a4adSJosip Pavic OTG_V_TOTAL_MAX, &s->v_total_max);
26806b0a4adSJosip Pavic
26906b0a4adSJosip Pavic REG_GET(OTG_V_TOTAL_MIN,
27006b0a4adSJosip Pavic OTG_V_TOTAL_MIN, &s->v_total_min);
27106b0a4adSJosip Pavic
27206b0a4adSJosip Pavic REG_GET(OTG_V_TOTAL_CONTROL,
27306b0a4adSJosip Pavic OTG_V_TOTAL_MAX_SEL, &s->v_total_max_sel);
27406b0a4adSJosip Pavic
27506b0a4adSJosip Pavic REG_GET(OTG_V_TOTAL_CONTROL,
27606b0a4adSJosip Pavic OTG_V_TOTAL_MIN_SEL, &s->v_total_min_sel);
27706b0a4adSJosip Pavic
27806b0a4adSJosip Pavic REG_GET_2(OTG_V_SYNC_A,
27906b0a4adSJosip Pavic OTG_V_SYNC_A_START, &s->v_sync_a_start,
28006b0a4adSJosip Pavic OTG_V_SYNC_A_END, &s->v_sync_a_end);
28106b0a4adSJosip Pavic
28206b0a4adSJosip Pavic REG_GET_2(OTG_H_BLANK_START_END,
28306b0a4adSJosip Pavic OTG_H_BLANK_START, &s->h_blank_start,
28406b0a4adSJosip Pavic OTG_H_BLANK_END, &s->h_blank_end);
28506b0a4adSJosip Pavic
28606b0a4adSJosip Pavic REG_GET_2(OTG_H_SYNC_A,
28706b0a4adSJosip Pavic OTG_H_SYNC_A_START, &s->h_sync_a_start,
28806b0a4adSJosip Pavic OTG_H_SYNC_A_END, &s->h_sync_a_end);
28906b0a4adSJosip Pavic
29006b0a4adSJosip Pavic REG_GET(OTG_H_SYNC_A_CNTL,
29106b0a4adSJosip Pavic OTG_H_SYNC_A_POL, &s->h_sync_a_pol);
29206b0a4adSJosip Pavic
29306b0a4adSJosip Pavic REG_GET(OTG_H_TOTAL,
29406b0a4adSJosip Pavic OTG_H_TOTAL, &s->h_total);
29506b0a4adSJosip Pavic
29606b0a4adSJosip Pavic REG_GET(OPTC_INPUT_GLOBAL_CONTROL,
29706b0a4adSJosip Pavic OPTC_UNDERFLOW_OCCURRED_STATUS, &s->underflow_occurred_status);
29806b0a4adSJosip Pavic
29906b0a4adSJosip Pavic REG_GET(OTG_VERTICAL_INTERRUPT1_CONTROL,
30006b0a4adSJosip Pavic OTG_VERTICAL_INTERRUPT1_INT_ENABLE, &s->vertical_interrupt1_en);
30106b0a4adSJosip Pavic
30206b0a4adSJosip Pavic REG_GET(OTG_VERTICAL_INTERRUPT1_POSITION,
30306b0a4adSJosip Pavic OTG_VERTICAL_INTERRUPT1_LINE_START, &s->vertical_interrupt1_line);
30406b0a4adSJosip Pavic
30506b0a4adSJosip Pavic REG_GET(OTG_VERTICAL_INTERRUPT2_CONTROL,
30606b0a4adSJosip Pavic OTG_VERTICAL_INTERRUPT2_INT_ENABLE, &s->vertical_interrupt2_en);
30706b0a4adSJosip Pavic
30806b0a4adSJosip Pavic REG_GET(OTG_VERTICAL_INTERRUPT2_POSITION,
30906b0a4adSJosip Pavic OTG_VERTICAL_INTERRUPT2_LINE_START, &s->vertical_interrupt2_line);
31006b0a4adSJosip Pavic
31106b0a4adSJosip Pavic REG_GET(INTERRUPT_DEST,
31206b0a4adSJosip Pavic OTG0_IHC_OTG_VERTICAL_INTERRUPT2_DEST, &s->vertical_interrupt2_dest);
31306b0a4adSJosip Pavic
31406b0a4adSJosip Pavic s->otg_master_update_lock = REG_READ(OTG_MASTER_UPDATE_LOCK);
31506b0a4adSJosip Pavic s->otg_double_buffer_control = REG_READ(OTG_DOUBLE_BUFFER_CONTROL);
31606b0a4adSJosip Pavic }
31706b0a4adSJosip Pavic
318*347efe5bSChristophe JAILLET static const struct timing_generator_funcs dcn31_tg_funcs = {
319110d3968SNicholas Kazlauskas .validate_timing = optc1_validate_timing,
320110d3968SNicholas Kazlauskas .program_timing = optc1_program_timing,
321110d3968SNicholas Kazlauskas .setup_vertical_interrupt0 = optc1_setup_vertical_interrupt0,
322110d3968SNicholas Kazlauskas .setup_vertical_interrupt1 = optc1_setup_vertical_interrupt1,
323110d3968SNicholas Kazlauskas .setup_vertical_interrupt2 = optc1_setup_vertical_interrupt2,
324110d3968SNicholas Kazlauskas .program_global_sync = optc1_program_global_sync,
325110d3968SNicholas Kazlauskas .enable_crtc = optc31_enable_crtc,
326110d3968SNicholas Kazlauskas .disable_crtc = optc31_disable_crtc,
327110d3968SNicholas Kazlauskas .immediate_disable_crtc = optc31_immediate_disable_crtc,
328110d3968SNicholas Kazlauskas /* used by enable_timing_synchronization. Not need for FPGA */
329110d3968SNicholas Kazlauskas .is_counter_moving = optc1_is_counter_moving,
330110d3968SNicholas Kazlauskas .get_position = optc1_get_position,
331110d3968SNicholas Kazlauskas .get_frame_count = optc1_get_vblank_counter,
332110d3968SNicholas Kazlauskas .get_scanoutpos = optc1_get_crtc_scanoutpos,
333110d3968SNicholas Kazlauskas .get_otg_active_size = optc1_get_otg_active_size,
334110d3968SNicholas Kazlauskas .set_early_control = optc1_set_early_control,
335110d3968SNicholas Kazlauskas /* used by enable_timing_synchronization. Not need for FPGA */
336110d3968SNicholas Kazlauskas .wait_for_state = optc1_wait_for_state,
337110d3968SNicholas Kazlauskas .set_blank_color = optc3_program_blank_color,
338110d3968SNicholas Kazlauskas .did_triggered_reset_occur = optc1_did_triggered_reset_occur,
339110d3968SNicholas Kazlauskas .triplebuffer_lock = optc3_triplebuffer_lock,
340110d3968SNicholas Kazlauskas .triplebuffer_unlock = optc2_triplebuffer_unlock,
341110d3968SNicholas Kazlauskas .enable_reset_trigger = optc1_enable_reset_trigger,
342110d3968SNicholas Kazlauskas .enable_crtc_reset = optc1_enable_crtc_reset,
343110d3968SNicholas Kazlauskas .disable_reset_trigger = optc1_disable_reset_trigger,
344110d3968SNicholas Kazlauskas .lock = optc3_lock,
345110d3968SNicholas Kazlauskas .unlock = optc1_unlock,
346110d3968SNicholas Kazlauskas .lock_doublebuffer_enable = optc3_lock_doublebuffer_enable,
347110d3968SNicholas Kazlauskas .lock_doublebuffer_disable = optc3_lock_doublebuffer_disable,
348110d3968SNicholas Kazlauskas .enable_optc_clock = optc1_enable_optc_clock,
349110d3968SNicholas Kazlauskas .set_drr = optc31_set_drr,
350d3dfceb5SAurabindo Pillai .get_last_used_drr_vtotal = optc2_get_last_used_drr_vtotal,
351110d3968SNicholas Kazlauskas .set_vtotal_min_max = optc1_set_vtotal_min_max,
3529dc5b360SCharlene Liu .set_static_screen_control = optc1_set_static_screen_control,
353110d3968SNicholas Kazlauskas .program_stereo = optc1_program_stereo,
354110d3968SNicholas Kazlauskas .is_stereo_left_eye = optc1_is_stereo_left_eye,
355110d3968SNicholas Kazlauskas .tg_init = optc3_tg_init,
356110d3968SNicholas Kazlauskas .is_tg_enabled = optc1_is_tg_enabled,
357110d3968SNicholas Kazlauskas .is_optc_underflow_occurred = optc1_is_optc_underflow_occurred,
358110d3968SNicholas Kazlauskas .clear_optc_underflow = optc1_clear_optc_underflow,
359110d3968SNicholas Kazlauskas .setup_global_swap_lock = NULL,
360110d3968SNicholas Kazlauskas .get_crc = optc1_get_crc,
361110d3968SNicholas Kazlauskas .configure_crc = optc2_configure_crc,
362110d3968SNicholas Kazlauskas .set_dsc_config = optc3_set_dsc_config,
3638fa6f4c5SYi-Ling Chen .get_dsc_status = optc2_get_dsc_status,
364110d3968SNicholas Kazlauskas .set_dwb_source = NULL,
365110d3968SNicholas Kazlauskas .set_odm_bypass = optc3_set_odm_bypass,
366110d3968SNicholas Kazlauskas .set_odm_combine = optc31_set_odm_combine,
367110d3968SNicholas Kazlauskas .get_optc_source = optc2_get_optc_source,
368110d3968SNicholas Kazlauskas .set_out_mux = optc3_set_out_mux,
369110d3968SNicholas Kazlauskas .set_drr_trigger_window = optc3_set_drr_trigger_window,
370110d3968SNicholas Kazlauskas .set_vtotal_change_limit = optc3_set_vtotal_change_limit,
371110d3968SNicholas Kazlauskas .set_gsl = optc2_set_gsl,
372110d3968SNicholas Kazlauskas .set_gsl_source_select = optc2_set_gsl_source_select,
373110d3968SNicholas Kazlauskas .set_vtg_params = optc1_set_vtg_params,
374110d3968SNicholas Kazlauskas .program_manual_trigger = optc2_program_manual_trigger,
375110d3968SNicholas Kazlauskas .setup_manual_trigger = optc2_setup_manual_trigger,
376110d3968SNicholas Kazlauskas .get_hw_timing = optc1_get_hw_timing,
3773e80a5b0SDuncan Ma .init_odm = optc3_init_odm,
378e6a901a0SWenjing Liu .is_two_pixels_per_container = optc1_is_two_pixels_per_container,
37906b0a4adSJosip Pavic .read_otg_state = optc31_read_otg_state,
380110d3968SNicholas Kazlauskas };
381110d3968SNicholas Kazlauskas
dcn31_timing_generator_init(struct optc * optc1)382110d3968SNicholas Kazlauskas void dcn31_timing_generator_init(struct optc *optc1)
383110d3968SNicholas Kazlauskas {
384110d3968SNicholas Kazlauskas optc1->base.funcs = &dcn31_tg_funcs;
385110d3968SNicholas Kazlauskas
386110d3968SNicholas Kazlauskas optc1->max_h_total = optc1->tg_mask->OTG_H_TOTAL + 1;
387110d3968SNicholas Kazlauskas optc1->max_v_total = optc1->tg_mask->OTG_V_TOTAL + 1;
388110d3968SNicholas Kazlauskas
389110d3968SNicholas Kazlauskas optc1->min_h_blank = 32;
390110d3968SNicholas Kazlauskas optc1->min_v_blank = 3;
391110d3968SNicholas Kazlauskas optc1->min_v_blank_interlace = 5;
392110d3968SNicholas Kazlauskas optc1->min_h_sync_width = 4;
393110d3968SNicholas Kazlauskas optc1->min_v_sync_width = 1;
394110d3968SNicholas Kazlauskas }
395110d3968SNicholas Kazlauskas
396