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#ifndef __DAL_CLK_MGR_H__
27#define __DAL_CLK_MGR_H__
28
29#include "dc.h"
30#include "dm_pp_smu.h"
31
32#define DCN_MINIMUM_DISPCLK_Khz 100000
33#define DCN_MINIMUM_DPPCLK_Khz 100000
34
35
36#define DDR4_DRAM_WIDTH 64
37#define WM_A 0
38#define WM_B 1
39#define WM_C 2
40#define WM_D 3
41#define WM_SET_COUNT 4
42
43#define DCN_MINIMUM_DISPCLK_Khz 100000
44#define DCN_MINIMUM_DPPCLK_Khz 100000
45
46
47
48#define MAX_NUM_DPM_LVL 8
49#define WM_SET_COUNT 4
50
51
52struct clk_limit_table_entry {
53 unsigned int voltage;
54 unsigned int dcfclk_mhz;
55 unsigned int fclk_mhz;
56 unsigned int memclk_mhz;
57 unsigned int socclk_mhz;
58};
59
60
61struct clk_limit_table {
62 struct clk_limit_table_entry entries[MAX_NUM_DPM_LVL];
63 unsigned int num_entries;
64};
65
66struct wm_range_table_entry {
67 unsigned int wm_inst;
68 unsigned int wm_type;
69 double pstate_latency_us;
70 double sr_exit_time_us;
71 double sr_enter_plus_exit_time_us;
72 bool valid;
73};
74
75
76struct clk_log_info {
77 bool enabled;
78 char *pBuf;
79 unsigned int bufSize;
80 unsigned int *sum_chars_printed;
81};
82
83struct clk_state_registers_and_bypass {
84 uint32_t dcfclk;
85 uint32_t dcf_deep_sleep_divider;
86 uint32_t dcf_deep_sleep_allow;
87 uint32_t dprefclk;
88 uint32_t dispclk;
89 uint32_t dppclk;
90
91 uint32_t dppclk_bypass;
92 uint32_t dcfclk_bypass;
93 uint32_t dprefclk_bypass;
94 uint32_t dispclk_bypass;
95};
96
97struct rv1_clk_internal {
98 uint32_t CLK0_CLK8_CURRENT_CNT;
99 uint32_t CLK0_CLK8_DS_CNTL;
100 uint32_t CLK0_CLK8_ALLOW_DS;
101 uint32_t CLK0_CLK10_CURRENT_CNT;
102 uint32_t CLK0_CLK11_CURRENT_CNT;
103
104 uint32_t CLK0_CLK8_BYPASS_CNTL;
105 uint32_t CLK0_CLK10_BYPASS_CNTL;
106 uint32_t CLK0_CLK11_BYPASS_CNTL;
107};
108
109struct rn_clk_internal {
110 uint32_t CLK1_CLK0_CURRENT_CNT;
111 uint32_t CLK1_CLK1_CURRENT_CNT;
112 uint32_t CLK1_CLK2_CURRENT_CNT;
113 uint32_t CLK1_CLK3_CURRENT_CNT;
114 uint32_t CLK1_CLK3_DS_CNTL;
115 uint32_t CLK1_CLK3_ALLOW_DS;
116
117 uint32_t CLK1_CLK0_BYPASS_CNTL;
118 uint32_t CLK1_CLK1_BYPASS_CNTL;
119 uint32_t CLK1_CLK2_BYPASS_CNTL;
120 uint32_t CLK1_CLK3_BYPASS_CNTL;
121
122};
123
124
125struct clk_state_registers {
126 uint32_t CLK0_CLK8_CURRENT_CNT;
127 uint32_t CLK0_CLK8_DS_CNTL;
128 uint32_t CLK0_CLK8_ALLOW_DS;
129 uint32_t CLK0_CLK10_CURRENT_CNT;
130 uint32_t CLK0_CLK11_CURRENT_CNT;
131};
132
133
134struct clk_bypass {
135 uint32_t dcfclk_bypass;
136 uint32_t dispclk_pypass;
137 uint32_t dprefclk_bypass;
138};
139
140
141
142
143
144
145struct wm_table {
146 struct wm_range_table_entry entries[WM_SET_COUNT];
147};
148
149struct clk_bw_params {
150 unsigned int vram_type;
151 unsigned int num_channels;
152 struct clk_limit_table clk_table;
153 struct wm_table wm_table;
154};
155
156
157struct clk_states {
158 uint32_t dprefclk_khz;
159};
160
161struct clk_mgr_funcs {
162
163
164
165
166
167
168
169 void (*update_clocks)(struct clk_mgr *clk_mgr,
170 struct dc_state *context,
171 bool safe_to_lower);
172
173 int (*get_dp_ref_clk_frequency)(struct clk_mgr *clk_mgr);
174
175 void (*init_clocks)(struct clk_mgr *clk_mgr);
176
177 void (*enable_pme_wa) (struct clk_mgr *clk_mgr);
178 void (*get_clock)(struct clk_mgr *clk_mgr,
179 struct dc_state *context,
180 enum dc_clock_type clock_type,
181 struct dc_clock_config *clock_cfg);
182
183 bool (*are_clock_states_equal) (struct dc_clocks *a,
184 struct dc_clocks *b);
185 void (*notify_wm_ranges)(struct clk_mgr *clk_mgr);
186};
187
188struct clk_mgr {
189 struct dc_context *ctx;
190 struct clk_mgr_funcs *funcs;
191 struct dc_clocks clks;
192 bool psr_allow_active_cache;
193 int dprefclk_khz;
194 int dentist_vco_freq_khz;
195 struct clk_state_registers_and_bypass boot_snapshot;
196 struct clk_bw_params *bw_params;
197 struct pp_smu_wm_range_sets ranges;
198};
199
200
201struct dccg;
202
203struct clk_mgr *dc_clk_mgr_create(struct dc_context *ctx, struct pp_smu_funcs *pp_smu, struct dccg *dccg);
204
205void dc_destroy_clk_mgr(struct clk_mgr *clk_mgr);
206
207void clk_mgr_exit_optimized_pwr_state(const struct dc *dc, struct clk_mgr *clk_mgr);
208
209void clk_mgr_optimize_pwr_state(const struct dc *dc, struct clk_mgr *clk_mgr);
210
211#endif
212