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 "core_types.h"
27#include "clk_mgr_internal.h"
28
29#include "dce112/dce112_clk_mgr.h"
30#include "dce110/dce110_clk_mgr.h"
31#include "dce120_clk_mgr.h"
32#include "dce100/dce_clk_mgr.h"
33#include "dce120/dce120_hw_sequencer.h"
34
35static const struct state_dependent_clocks dce120_max_clks_by_state[] = {
36
37{ .display_clk_khz = 0, .pixel_clk_khz = 0 },
38
39{ .display_clk_khz = 0, .pixel_clk_khz = 0 },
40
41{ .display_clk_khz = 460000, .pixel_clk_khz = 400000 },
42
43{ .display_clk_khz = 670000, .pixel_clk_khz = 600000 },
44
45{ .display_clk_khz = 1133000, .pixel_clk_khz = 600000 } };
46
47
48
49
50
51
52
53
54
55
56static void dce121_clock_patch_xgmi_ss_info(struct clk_mgr_internal *clk_mgr_dce)
57{
58 enum bp_result result;
59 struct spread_spectrum_info info = { { 0 } };
60 struct dc_bios *bp = clk_mgr_dce->base.ctx->dc_bios;
61
62 clk_mgr_dce->xgmi_enabled = false;
63
64 result = bp->funcs->get_spread_spectrum_info(bp, AS_SIGNAL_TYPE_XGMI,
65 0, &info);
66 if (result == BP_RESULT_OK && info.spread_spectrum_percentage != 0) {
67 clk_mgr_dce->xgmi_enabled = true;
68 clk_mgr_dce->ss_on_dprefclk = true;
69 clk_mgr_dce->dprefclk_ss_divider =
70 info.spread_percentage_divider;
71
72 if (info.type.CENTER_MODE == 0) {
73
74
75
76
77
78 clk_mgr_dce->dprefclk_ss_percentage =
79 info.spread_spectrum_percentage;
80 }
81 }
82}
83
84static void dce12_update_clocks(struct clk_mgr *clk_mgr_base,
85 struct dc_state *context,
86 bool safe_to_lower)
87{
88 struct clk_mgr_internal *clk_mgr_dce = TO_CLK_MGR_INTERNAL(clk_mgr_base);
89 struct dm_pp_clock_for_voltage_req clock_voltage_req = {0};
90 int max_pix_clk = dce_get_max_pixel_clock_for_all_paths(context);
91 int patched_disp_clk = context->bw_ctx.bw.dce.dispclk_khz;
92
93
94 if (!clk_mgr_dce->dfs_bypass_active)
95 patched_disp_clk = patched_disp_clk * 115 / 100;
96
97 if (should_set_clock(safe_to_lower, patched_disp_clk, clk_mgr_base->clks.dispclk_khz)) {
98 clock_voltage_req.clk_type = DM_PP_CLOCK_TYPE_DISPLAY_CLK;
99
100
101
102
103 if (clk_mgr_dce->xgmi_enabled)
104 patched_disp_clk = dce_adjust_dp_ref_freq_for_ss(
105 clk_mgr_dce, patched_disp_clk);
106 clock_voltage_req.clocks_in_khz = patched_disp_clk;
107 clk_mgr_base->clks.dispclk_khz = dce112_set_clock(clk_mgr_base, patched_disp_clk);
108
109 dm_pp_apply_clock_for_voltage_request(clk_mgr_base->ctx, &clock_voltage_req);
110 }
111
112 if (should_set_clock(safe_to_lower, max_pix_clk, clk_mgr_base->clks.phyclk_khz)) {
113 clock_voltage_req.clk_type = DM_PP_CLOCK_TYPE_DISPLAYPHYCLK;
114 clock_voltage_req.clocks_in_khz = max_pix_clk;
115 clk_mgr_base->clks.phyclk_khz = max_pix_clk;
116
117 dm_pp_apply_clock_for_voltage_request(clk_mgr_base->ctx, &clock_voltage_req);
118 }
119 dce11_pplib_apply_display_requirements(clk_mgr_base->ctx->dc, context);
120}
121
122
123static struct clk_mgr_funcs dce120_funcs = {
124 .get_dp_ref_clk_frequency = dce12_get_dp_ref_freq_khz,
125 .update_clocks = dce12_update_clocks
126};
127
128void dce120_clk_mgr_construct(struct dc_context *ctx, struct clk_mgr_internal *clk_mgr)
129{
130 dce_clk_mgr_construct(ctx, clk_mgr);
131
132 memcpy(clk_mgr->max_clks_by_state,
133 dce120_max_clks_by_state,
134 sizeof(dce120_max_clks_by_state));
135
136 clk_mgr->base.dprefclk_khz = 600000;
137 clk_mgr->base.funcs = &dce120_funcs;
138}
139
140void dce121_clk_mgr_construct(struct dc_context *ctx, struct clk_mgr_internal *clk_mgr)
141{
142 dce120_clk_mgr_construct(ctx, clk_mgr);
143 clk_mgr->base.dprefclk_khz = 625000;
144
145
146
147
148
149 if (dce121_xgmi_enabled(ctx->dc->hwseq))
150 dce121_clock_patch_xgmi_ss_info(clk_mgr);
151
152}
153
154