1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include "dccg.h"
27#include "clk_mgr_internal.h"
28
29#include "dce100/dce_clk_mgr.h"
30#include "dcn20_clk_mgr.h"
31#include "reg_helper.h"
32#include "core_types.h"
33#include "dm_helpers.h"
34
35#include "navi10_ip_offset.h"
36#include "dcn/dcn_2_0_0_offset.h"
37#include "dcn/dcn_2_0_0_sh_mask.h"
38#include "clk/clk_11_0_0_offset.h"
39#include "clk/clk_11_0_0_sh_mask.h"
40
41
42#undef FN
43#define FN(reg_name, field_name) \
44 clk_mgr->clk_mgr_shift->field_name, clk_mgr->clk_mgr_mask->field_name
45
46#define REG(reg) \
47 (clk_mgr->regs->reg)
48
49#define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg
50
51#define BASE(seg) BASE_INNER(seg)
52
53#define SR(reg_name)\
54 .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
55 mm ## reg_name
56
57#define CLK_BASE_INNER(seg) \
58 CLK_BASE__INST0_SEG ## seg
59
60
61static const struct clk_mgr_registers clk_mgr_regs = {
62 CLK_REG_LIST_NV10()
63};
64
65static const struct clk_mgr_shift clk_mgr_shift = {
66 CLK_MASK_SH_LIST_NV10(__SHIFT)
67};
68
69static const struct clk_mgr_mask clk_mgr_mask = {
70 CLK_MASK_SH_LIST_NV10(_MASK)
71};
72
73uint32_t dentist_get_did_from_divider(int divider)
74{
75 uint32_t divider_id;
76
77
78 if (divider < DENTIST_DIVIDER_RANGE_2_START) {
79 if (divider < DENTIST_DIVIDER_RANGE_1_START)
80 divider_id = DENTIST_BASE_DID_1;
81 else
82 divider_id = DENTIST_BASE_DID_1
83 + (divider - DENTIST_DIVIDER_RANGE_1_START)
84 / DENTIST_DIVIDER_RANGE_1_STEP;
85 } else if (divider < DENTIST_DIVIDER_RANGE_3_START) {
86 divider_id = DENTIST_BASE_DID_2
87 + (divider - DENTIST_DIVIDER_RANGE_2_START)
88 / DENTIST_DIVIDER_RANGE_2_STEP;
89 } else if (divider < DENTIST_DIVIDER_RANGE_4_START) {
90 divider_id = DENTIST_BASE_DID_3
91 + (divider - DENTIST_DIVIDER_RANGE_3_START)
92 / DENTIST_DIVIDER_RANGE_3_STEP;
93 } else {
94 divider_id = DENTIST_BASE_DID_4
95 + (divider - DENTIST_DIVIDER_RANGE_4_START)
96 / DENTIST_DIVIDER_RANGE_4_STEP;
97 if (divider_id > DENTIST_MAX_DID)
98 divider_id = DENTIST_MAX_DID;
99 }
100
101 return divider_id;
102}
103
104void dcn20_update_clocks_update_dpp_dto(struct clk_mgr_internal *clk_mgr,
105 struct dc_state *context, bool safe_to_lower)
106{
107 int i;
108
109 clk_mgr->dccg->ref_dppclk = clk_mgr->base.clks.dppclk_khz;
110 for (i = 0; i < clk_mgr->base.ctx->dc->res_pool->pipe_count; i++) {
111 int dpp_inst, dppclk_khz, prev_dppclk_khz;
112
113
114
115
116 dpp_inst = i;
117 dppclk_khz = context->res_ctx.pipe_ctx[i].plane_res.bw.dppclk_khz;
118
119 prev_dppclk_khz = clk_mgr->dccg->pipe_dppclk_khz[i];
120
121 if (safe_to_lower || prev_dppclk_khz < dppclk_khz)
122 clk_mgr->dccg->funcs->update_dpp_dto(
123 clk_mgr->dccg, dpp_inst, dppclk_khz);
124 }
125}
126
127void dcn20_update_clocks_update_dentist(struct clk_mgr_internal *clk_mgr, struct dc_state *context)
128{
129 int dpp_divider = DENTIST_DIVIDER_RANGE_SCALE_FACTOR
130 * clk_mgr->base.dentist_vco_freq_khz / clk_mgr->base.clks.dppclk_khz;
131 int disp_divider = DENTIST_DIVIDER_RANGE_SCALE_FACTOR
132 * clk_mgr->base.dentist_vco_freq_khz / clk_mgr->base.clks.dispclk_khz;
133
134 uint32_t dppclk_wdivider = dentist_get_did_from_divider(dpp_divider);
135 uint32_t dispclk_wdivider = dentist_get_did_from_divider(disp_divider);
136 uint32_t current_dispclk_wdivider;
137 uint32_t i;
138
139 REG_GET(DENTIST_DISPCLK_CNTL,
140 DENTIST_DISPCLK_WDIVIDER, ¤t_dispclk_wdivider);
141
142
143 if (current_dispclk_wdivider == 127 && dispclk_wdivider != 127) {
144 for (i = 0; i < clk_mgr->base.ctx->dc->res_pool->pipe_count; i++) {
145 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
146 uint32_t fifo_level;
147 struct dccg *dccg = clk_mgr->base.ctx->dc->res_pool->dccg;
148 struct stream_encoder *stream_enc = pipe_ctx->stream_res.stream_enc;
149 int32_t N;
150 int32_t j;
151
152 if (!pipe_ctx->stream)
153 continue;
154
155 if (!stream_enc->funcs->get_fifo_cal_average_level)
156 continue;
157 fifo_level = stream_enc->funcs->get_fifo_cal_average_level(
158 stream_enc);
159 N = fifo_level / 4;
160 dccg->funcs->set_fifo_errdet_ovr_en(
161 dccg,
162 true);
163 for (j = 0; j < N - 4; j++)
164 dccg->funcs->otg_drop_pixel(
165 dccg,
166 pipe_ctx->stream_res.tg->inst);
167 dccg->funcs->set_fifo_errdet_ovr_en(
168 dccg,
169 false);
170 }
171 } else if (dispclk_wdivider == 127 && current_dispclk_wdivider != 127) {
172 REG_UPDATE(DENTIST_DISPCLK_CNTL,
173 DENTIST_DISPCLK_WDIVIDER, 126);
174 REG_WAIT(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, 1, 50, 100);
175 for (i = 0; i < clk_mgr->base.ctx->dc->res_pool->pipe_count; i++) {
176 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
177 struct dccg *dccg = clk_mgr->base.ctx->dc->res_pool->dccg;
178 struct stream_encoder *stream_enc = pipe_ctx->stream_res.stream_enc;
179 uint32_t fifo_level;
180 int32_t N;
181 int32_t j;
182
183 if (!pipe_ctx->stream)
184 continue;
185
186 if (!stream_enc->funcs->get_fifo_cal_average_level)
187 continue;
188 fifo_level = stream_enc->funcs->get_fifo_cal_average_level(
189 stream_enc);
190 N = fifo_level / 4;
191 dccg->funcs->set_fifo_errdet_ovr_en(dccg, true);
192 for (j = 0; j < 12 - N; j++)
193 dccg->funcs->otg_add_pixel(dccg,
194 pipe_ctx->stream_res.tg->inst);
195 dccg->funcs->set_fifo_errdet_ovr_en(dccg, false);
196 }
197 }
198
199 REG_UPDATE(DENTIST_DISPCLK_CNTL,
200 DENTIST_DISPCLK_WDIVIDER, dispclk_wdivider);
201 REG_WAIT(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, 1, 50, 1000);
202 REG_UPDATE(DENTIST_DISPCLK_CNTL,
203 DENTIST_DPPCLK_WDIVIDER, dppclk_wdivider);
204 REG_WAIT(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_CHG_DONE, 1, 5, 100);
205}
206
207
208void dcn2_update_clocks(struct clk_mgr *clk_mgr_base,
209 struct dc_state *context,
210 bool safe_to_lower)
211{
212 struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
213 struct dc_clocks *new_clocks = &context->bw_ctx.bw.dcn.clk;
214 struct dc *dc = clk_mgr_base->ctx->dc;
215 struct pp_smu_funcs_nv *pp_smu = NULL;
216 int display_count;
217 bool update_dppclk = false;
218 bool update_dispclk = false;
219 bool enter_display_off = false;
220 bool dpp_clock_lowered = false;
221 struct dmcu *dmcu = clk_mgr_base->ctx->dc->res_pool->dmcu;
222 bool force_reset = false;
223 bool p_state_change_support;
224 int total_plane_count;
225
226 if (dc->work_arounds.skip_clock_update)
227 return;
228
229 if (clk_mgr_base->clks.dispclk_khz == 0 ||
230 dc->debug.force_clock_mode & 0x1) {
231
232 force_reset = true;
233
234 dcn2_read_clocks_from_hw_dentist(clk_mgr_base);
235
236
237 }
238 display_count = clk_mgr_helper_get_active_display_cnt(dc, context);
239 if (dc->res_pool->pp_smu)
240 pp_smu = &dc->res_pool->pp_smu->nv_funcs;
241
242 if (display_count == 0)
243 enter_display_off = true;
244
245 if (enter_display_off == safe_to_lower) {
246 if (pp_smu && pp_smu->set_display_count)
247 pp_smu->set_display_count(&pp_smu->pp_smu, display_count);
248 }
249
250 if (dc->debug.force_min_dcfclk_mhz > 0)
251 new_clocks->dcfclk_khz = (new_clocks->dcfclk_khz > (dc->debug.force_min_dcfclk_mhz * 1000)) ?
252 new_clocks->dcfclk_khz : (dc->debug.force_min_dcfclk_mhz * 1000);
253
254 if (should_set_clock(safe_to_lower, new_clocks->dcfclk_khz, clk_mgr_base->clks.dcfclk_khz)) {
255 clk_mgr_base->clks.dcfclk_khz = new_clocks->dcfclk_khz;
256 if (pp_smu && pp_smu->set_hard_min_dcfclk_by_freq)
257 pp_smu->set_hard_min_dcfclk_by_freq(&pp_smu->pp_smu, khz_to_mhz_ceil(clk_mgr_base->clks.dcfclk_khz));
258 }
259
260 if (should_set_clock(safe_to_lower,
261 new_clocks->dcfclk_deep_sleep_khz, clk_mgr_base->clks.dcfclk_deep_sleep_khz)) {
262 clk_mgr_base->clks.dcfclk_deep_sleep_khz = new_clocks->dcfclk_deep_sleep_khz;
263 if (pp_smu && pp_smu->set_min_deep_sleep_dcfclk)
264 pp_smu->set_min_deep_sleep_dcfclk(&pp_smu->pp_smu, khz_to_mhz_ceil(clk_mgr_base->clks.dcfclk_deep_sleep_khz));
265 }
266
267 if (should_set_clock(safe_to_lower, new_clocks->socclk_khz, clk_mgr_base->clks.socclk_khz)) {
268 clk_mgr_base->clks.socclk_khz = new_clocks->socclk_khz;
269 if (pp_smu && pp_smu->set_hard_min_socclk_by_freq)
270 pp_smu->set_hard_min_socclk_by_freq(&pp_smu->pp_smu, khz_to_mhz_ceil(clk_mgr_base->clks.socclk_khz));
271 }
272
273 total_plane_count = clk_mgr_helper_get_active_plane_cnt(dc, context);
274 p_state_change_support = new_clocks->p_state_change_support || (total_plane_count == 0);
275 if (should_update_pstate_support(safe_to_lower, p_state_change_support, clk_mgr_base->clks.p_state_change_support)) {
276 clk_mgr_base->clks.prev_p_state_change_support = clk_mgr_base->clks.p_state_change_support;
277 clk_mgr_base->clks.p_state_change_support = p_state_change_support;
278 if (pp_smu && pp_smu->set_pstate_handshake_support)
279 pp_smu->set_pstate_handshake_support(&pp_smu->pp_smu, clk_mgr_base->clks.p_state_change_support);
280 }
281
282 if (should_set_clock(safe_to_lower, new_clocks->dramclk_khz, clk_mgr_base->clks.dramclk_khz)) {
283 clk_mgr_base->clks.dramclk_khz = new_clocks->dramclk_khz;
284 if (pp_smu && pp_smu->set_hard_min_uclk_by_freq)
285 pp_smu->set_hard_min_uclk_by_freq(&pp_smu->pp_smu, khz_to_mhz_ceil(clk_mgr_base->clks.dramclk_khz));
286 }
287
288 if (should_set_clock(safe_to_lower, new_clocks->dppclk_khz, clk_mgr->base.clks.dppclk_khz)) {
289 if (clk_mgr->base.clks.dppclk_khz > new_clocks->dppclk_khz)
290 dpp_clock_lowered = true;
291 clk_mgr->base.clks.dppclk_khz = new_clocks->dppclk_khz;
292
293 update_dppclk = true;
294 }
295
296 if (should_set_clock(safe_to_lower, new_clocks->dispclk_khz, clk_mgr_base->clks.dispclk_khz)) {
297 clk_mgr_base->clks.dispclk_khz = new_clocks->dispclk_khz;
298
299 update_dispclk = true;
300 }
301
302 if (update_dppclk || update_dispclk) {
303 new_clocks->disp_dpp_voltage_level_khz = new_clocks->dppclk_khz;
304
305 if (update_dispclk)
306 new_clocks->disp_dpp_voltage_level_khz = new_clocks->dispclk_khz > new_clocks->dppclk_khz ? new_clocks->dispclk_khz : new_clocks->dppclk_khz;
307
308 clk_mgr_base->clks.disp_dpp_voltage_level_khz = new_clocks->disp_dpp_voltage_level_khz;
309 if (pp_smu && pp_smu->set_voltage_by_freq)
310 pp_smu->set_voltage_by_freq(&pp_smu->pp_smu, PP_SMU_NV_DISPCLK, khz_to_mhz_ceil(clk_mgr_base->clks.disp_dpp_voltage_level_khz));
311 }
312
313 if (dc->config.forced_clocks == false || (force_reset && safe_to_lower)) {
314 if (dpp_clock_lowered) {
315
316 dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);
317 dcn20_update_clocks_update_dentist(clk_mgr, context);
318 } else {
319
320 if (update_dppclk || update_dispclk)
321 dcn20_update_clocks_update_dentist(clk_mgr, context);
322
323 dcn20_update_clocks_update_dpp_dto(clk_mgr, context, safe_to_lower);
324 }
325 }
326
327 if (update_dispclk &&
328 dmcu && dmcu->funcs->is_dmcu_initialized(dmcu)) {
329
330 dmcu->funcs->set_psr_wait_loop(dmcu,
331 clk_mgr_base->clks.dispclk_khz / 1000 / 7);
332 }
333}
334
335void dcn2_update_clocks_fpga(struct clk_mgr *clk_mgr,
336 struct dc_state *context,
337 bool safe_to_lower)
338{
339 struct clk_mgr_internal *clk_mgr_int = TO_CLK_MGR_INTERNAL(clk_mgr);
340
341 struct dc_clocks *new_clocks = &context->bw_ctx.bw.dcn.clk;
342
343 int fclk_adj = new_clocks->fclk_khz > 1200000 ? new_clocks->fclk_khz : 1200000;
344
345 if (should_set_clock(safe_to_lower, new_clocks->phyclk_khz, clk_mgr->clks.phyclk_khz)) {
346 clk_mgr->clks.phyclk_khz = new_clocks->phyclk_khz;
347 }
348
349 if (should_set_clock(safe_to_lower, new_clocks->dcfclk_khz, clk_mgr->clks.dcfclk_khz)) {
350 clk_mgr->clks.dcfclk_khz = new_clocks->dcfclk_khz;
351 }
352
353 if (should_set_clock(safe_to_lower,
354 new_clocks->dcfclk_deep_sleep_khz, clk_mgr->clks.dcfclk_deep_sleep_khz)) {
355 clk_mgr->clks.dcfclk_deep_sleep_khz = new_clocks->dcfclk_deep_sleep_khz;
356 }
357
358 if (should_set_clock(safe_to_lower, new_clocks->socclk_khz, clk_mgr->clks.socclk_khz)) {
359 clk_mgr->clks.socclk_khz = new_clocks->socclk_khz;
360 }
361
362 if (should_set_clock(safe_to_lower, new_clocks->dramclk_khz, clk_mgr->clks.dramclk_khz)) {
363 clk_mgr->clks.dramclk_khz = new_clocks->dramclk_khz;
364 }
365
366 if (should_set_clock(safe_to_lower, new_clocks->dppclk_khz, clk_mgr->clks.dppclk_khz)) {
367 clk_mgr->clks.dppclk_khz = new_clocks->dppclk_khz;
368 }
369
370 if (should_set_clock(safe_to_lower, fclk_adj, clk_mgr->clks.fclk_khz)) {
371 clk_mgr->clks.fclk_khz = fclk_adj;
372 }
373
374 if (should_set_clock(safe_to_lower, new_clocks->dispclk_khz, clk_mgr->clks.dispclk_khz)) {
375 clk_mgr->clks.dispclk_khz = new_clocks->dispclk_khz;
376 }
377
378
379
380
381
382 if (clk_mgr->clks.fclk_khz > clk_mgr->clks.dppclk_khz)
383 clk_mgr->clks.dppclk_khz = clk_mgr->clks.fclk_khz;
384 if (clk_mgr->clks.dppclk_khz > clk_mgr->clks.fclk_khz)
385 clk_mgr->clks.fclk_khz = clk_mgr->clks.dppclk_khz;
386
387
388 clk_mgr_int->dccg->ref_dppclk = clk_mgr->clks.fclk_khz;
389
390
391 clk_mgr->clks.dtbclk_en = false;
392 dm_set_dcn_clocks(clk_mgr->ctx, &clk_mgr->clks);
393}
394
395void dcn2_init_clocks(struct clk_mgr *clk_mgr)
396{
397 memset(&(clk_mgr->clks), 0, sizeof(struct dc_clocks));
398
399 clk_mgr->clks.p_state_change_support = true;
400 clk_mgr->clks.prev_p_state_change_support = true;
401}
402
403static void dcn2_enable_pme_wa(struct clk_mgr *clk_mgr_base)
404{
405 struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
406 struct pp_smu_funcs_nv *pp_smu = NULL;
407
408 if (clk_mgr->pp_smu) {
409 pp_smu = &clk_mgr->pp_smu->nv_funcs;
410
411 if (pp_smu->set_pme_wa_enable)
412 pp_smu->set_pme_wa_enable(&pp_smu->pp_smu);
413 }
414}
415
416
417void dcn2_read_clocks_from_hw_dentist(struct clk_mgr *clk_mgr_base)
418{
419 struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
420 uint32_t dispclk_wdivider;
421 uint32_t dppclk_wdivider;
422 int disp_divider;
423 int dpp_divider;
424
425 REG_GET(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_WDIVIDER, &dispclk_wdivider);
426 REG_GET(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_WDIVIDER, &dppclk_wdivider);
427
428 disp_divider = dentist_get_divider_from_did(dispclk_wdivider);
429 dpp_divider = dentist_get_divider_from_did(dppclk_wdivider);
430
431 if (disp_divider && dpp_divider) {
432
433 clk_mgr_base->clks.dispclk_khz = (DENTIST_DIVIDER_RANGE_SCALE_FACTOR
434 * clk_mgr->base.dentist_vco_freq_khz) / disp_divider;
435
436 clk_mgr_base->clks.dppclk_khz = (DENTIST_DIVIDER_RANGE_SCALE_FACTOR
437 * clk_mgr->base.dentist_vco_freq_khz) / dpp_divider;
438 }
439
440}
441
442void dcn2_get_clock(struct clk_mgr *clk_mgr,
443 struct dc_state *context,
444 enum dc_clock_type clock_type,
445 struct dc_clock_config *clock_cfg)
446{
447
448 if (clock_type == DC_CLOCK_TYPE_DISPCLK) {
449 clock_cfg->max_clock_khz = context->bw_ctx.bw.dcn.clk.max_supported_dispclk_khz;
450 clock_cfg->min_clock_khz = DCN_MINIMUM_DISPCLK_Khz;
451 clock_cfg->current_clock_khz = clk_mgr->clks.dispclk_khz;
452 clock_cfg->bw_requirequired_clock_khz = context->bw_ctx.bw.dcn.clk.bw_dispclk_khz;
453 }
454 if (clock_type == DC_CLOCK_TYPE_DPPCLK) {
455 clock_cfg->max_clock_khz = context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz;
456 clock_cfg->min_clock_khz = DCN_MINIMUM_DPPCLK_Khz;
457 clock_cfg->current_clock_khz = clk_mgr->clks.dppclk_khz;
458 clock_cfg->bw_requirequired_clock_khz = context->bw_ctx.bw.dcn.clk.bw_dppclk_khz;
459 }
460}
461
462static bool dcn2_are_clock_states_equal(struct dc_clocks *a,
463 struct dc_clocks *b)
464{
465 if (a->dispclk_khz != b->dispclk_khz)
466 return false;
467 else if (a->dppclk_khz != b->dppclk_khz)
468 return false;
469 else if (a->disp_dpp_voltage_level_khz != b->disp_dpp_voltage_level_khz)
470 return false;
471 else if (a->dcfclk_khz != b->dcfclk_khz)
472 return false;
473 else if (a->socclk_khz != b->socclk_khz)
474 return false;
475 else if (a->dcfclk_deep_sleep_khz != b->dcfclk_deep_sleep_khz)
476 return false;
477 else if (a->dramclk_khz != b->dramclk_khz)
478 return false;
479 else if (a->p_state_change_support != b->p_state_change_support)
480 return false;
481
482 return true;
483}
484
485
486static void dcn2_notify_link_rate_change(struct clk_mgr *clk_mgr_base, struct dc_link *link)
487{
488 struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
489 unsigned int i, max_phyclk_req = 0;
490 struct pp_smu_funcs_nv *pp_smu = NULL;
491
492 if (!clk_mgr->pp_smu || !clk_mgr->pp_smu->nv_funcs.set_voltage_by_freq)
493 return;
494
495 pp_smu = &clk_mgr->pp_smu->nv_funcs;
496
497 clk_mgr->cur_phyclk_req_table[link->link_index] = link->cur_link_settings.link_rate * LINK_RATE_REF_FREQ_IN_KHZ;
498
499 for (i = 0; i < MAX_PIPES * 2; i++) {
500 if (clk_mgr->cur_phyclk_req_table[i] > max_phyclk_req)
501 max_phyclk_req = clk_mgr->cur_phyclk_req_table[i];
502 }
503
504 if (max_phyclk_req != clk_mgr_base->clks.phyclk_khz) {
505 clk_mgr_base->clks.phyclk_khz = max_phyclk_req;
506 pp_smu->set_voltage_by_freq(&pp_smu->pp_smu, PP_SMU_NV_PHYCLK, khz_to_mhz_ceil(clk_mgr_base->clks.phyclk_khz));
507 }
508}
509
510static struct clk_mgr_funcs dcn2_funcs = {
511 .get_dp_ref_clk_frequency = dce12_get_dp_ref_freq_khz,
512 .update_clocks = dcn2_update_clocks,
513 .init_clocks = dcn2_init_clocks,
514 .enable_pme_wa = dcn2_enable_pme_wa,
515 .get_clock = dcn2_get_clock,
516 .are_clock_states_equal = dcn2_are_clock_states_equal,
517 .notify_link_rate_change = dcn2_notify_link_rate_change,
518};
519
520
521void dcn20_clk_mgr_construct(
522 struct dc_context *ctx,
523 struct clk_mgr_internal *clk_mgr,
524 struct pp_smu_funcs *pp_smu,
525 struct dccg *dccg)
526{
527 clk_mgr->base.ctx = ctx;
528 clk_mgr->pp_smu = pp_smu;
529 clk_mgr->base.funcs = &dcn2_funcs;
530 clk_mgr->regs = &clk_mgr_regs;
531 clk_mgr->clk_mgr_shift = &clk_mgr_shift;
532 clk_mgr->clk_mgr_mask = &clk_mgr_mask;
533
534 clk_mgr->dccg = dccg;
535 clk_mgr->dfs_bypass_disp_clk = 0;
536
537 clk_mgr->dprefclk_ss_percentage = 0;
538 clk_mgr->dprefclk_ss_divider = 1000;
539 clk_mgr->ss_on_dprefclk = false;
540
541 clk_mgr->base.dprefclk_khz = 700000;
542
543 if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) {
544 dcn2_funcs.update_clocks = dcn2_update_clocks_fpga;
545 clk_mgr->base.dentist_vco_freq_khz = 3850000;
546
547 } else {
548
549 int dprefclk_did = REG_READ(CLK3_CLK2_DFS_CNTL);
550
551 int target_div = dentist_get_divider_from_did(dprefclk_did);
552
553
554 uint32_t pll_req_reg = REG_READ(CLK3_CLK_PLL_REQ);
555 struct fixed31_32 pll_req;
556
557
558
559
560
561
562 pll_req = dc_fixpt_from_int(pll_req_reg & clk_mgr->clk_mgr_mask->FbMult_int);
563 pll_req.value |= pll_req_reg & clk_mgr->clk_mgr_mask->FbMult_frac;
564
565
566 pll_req = dc_fixpt_mul_int(pll_req, 100000);
567
568
569 clk_mgr->base.dentist_vco_freq_khz = dc_fixpt_floor(pll_req);
570
571
572 if (clk_mgr->base.dentist_vco_freq_khz == 0)
573 clk_mgr->base.dentist_vco_freq_khz = 3850000;
574
575
576 clk_mgr->base.dprefclk_khz = (DENTIST_DIVIDER_RANGE_SCALE_FACTOR
577 * clk_mgr->base.dentist_vco_freq_khz) / target_div;
578 }
579
580
581
582 clk_mgr->dfs_bypass_enabled = false;
583
584 dce_clock_read_ss_info(clk_mgr);
585}
586
587