2 * Copyright 2013 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "amdgpu_pm.h"
27 #include "amdgpu_dpm.h"
28 #include "amdgpu_atombios.h"
33 #include "../include/pptable.h"
34 #include <linux/math64.h>
35 #include <linux/seq_file.h>
36 #include <linux/firmware.h>
38 #define MC_CG_ARB_FREQ_F0 0x0a
39 #define MC_CG_ARB_FREQ_F1 0x0b
40 #define MC_CG_ARB_FREQ_F2 0x0c
41 #define MC_CG_ARB_FREQ_F3 0x0d
43 #define SMC_RAM_END 0x20000
45 #define SCLK_MIN_DEEPSLEEP_FREQ 1350
48 /* sizeof(ATOM_PPLIB_EXTENDEDHEADER) */
49 #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 12
50 #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 14
51 #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 16
52 #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 18
53 #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 20
54 #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 22
56 #define BIOS_SCRATCH_4 0x5cd
58 MODULE_FIRMWARE("radeon/tahiti_smc.bin");
59 MODULE_FIRMWARE("radeon/tahiti_k_smc.bin");
60 MODULE_FIRMWARE("radeon/pitcairn_smc.bin");
61 MODULE_FIRMWARE("radeon/pitcairn_k_smc.bin");
62 MODULE_FIRMWARE("radeon/verde_smc.bin");
63 MODULE_FIRMWARE("radeon/verde_k_smc.bin");
64 MODULE_FIRMWARE("radeon/oland_smc.bin");
65 MODULE_FIRMWARE("radeon/oland_k_smc.bin");
66 MODULE_FIRMWARE("radeon/hainan_smc.bin");
67 MODULE_FIRMWARE("radeon/hainan_k_smc.bin");
70 struct _ATOM_POWERPLAY_INFO info;
71 struct _ATOM_POWERPLAY_INFO_V2 info_2;
72 struct _ATOM_POWERPLAY_INFO_V3 info_3;
73 struct _ATOM_PPLIB_POWERPLAYTABLE pplib;
74 struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2;
75 struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3;
76 struct _ATOM_PPLIB_POWERPLAYTABLE4 pplib4;
77 struct _ATOM_PPLIB_POWERPLAYTABLE5 pplib5;
81 struct _ATOM_PPLIB_FANTABLE fan;
82 struct _ATOM_PPLIB_FANTABLE2 fan2;
83 struct _ATOM_PPLIB_FANTABLE3 fan3;
86 union pplib_clock_info {
87 struct _ATOM_PPLIB_R600_CLOCK_INFO r600;
88 struct _ATOM_PPLIB_RS780_CLOCK_INFO rs780;
89 struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen;
90 struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo;
91 struct _ATOM_PPLIB_SI_CLOCK_INFO si;
94 static const u32 r600_utc[R600_PM_NUMBER_OF_TC] =
113 static const u32 r600_dtc[R600_PM_NUMBER_OF_TC] =
132 static const struct si_cac_config_reg cac_weights_tahiti[] =
134 { 0x0, 0x0000ffff, 0, 0xc, SISLANDS_CACCONFIG_CGIND },
135 { 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
136 { 0x1, 0x0000ffff, 0, 0x101, SISLANDS_CACCONFIG_CGIND },
137 { 0x1, 0xffff0000, 16, 0xc, SISLANDS_CACCONFIG_CGIND },
138 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
139 { 0x3, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
140 { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
141 { 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
142 { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
143 { 0x5, 0x0000ffff, 0, 0x8fc, SISLANDS_CACCONFIG_CGIND },
144 { 0x5, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
145 { 0x6, 0x0000ffff, 0, 0x95, SISLANDS_CACCONFIG_CGIND },
146 { 0x6, 0xffff0000, 16, 0x34e, SISLANDS_CACCONFIG_CGIND },
147 { 0x18f, 0x0000ffff, 0, 0x1a1, SISLANDS_CACCONFIG_CGIND },
148 { 0x7, 0x0000ffff, 0, 0xda, SISLANDS_CACCONFIG_CGIND },
149 { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
150 { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
151 { 0x8, 0xffff0000, 16, 0x46, SISLANDS_CACCONFIG_CGIND },
152 { 0x9, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
153 { 0xa, 0x0000ffff, 0, 0x208, SISLANDS_CACCONFIG_CGIND },
154 { 0xb, 0x0000ffff, 0, 0xe7, SISLANDS_CACCONFIG_CGIND },
155 { 0xb, 0xffff0000, 16, 0x948, SISLANDS_CACCONFIG_CGIND },
156 { 0xc, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
157 { 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
158 { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
159 { 0xe, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
160 { 0xf, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
161 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
162 { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
163 { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
164 { 0x11, 0x0000ffff, 0, 0x167, SISLANDS_CACCONFIG_CGIND },
165 { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
166 { 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
167 { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
168 { 0x13, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
169 { 0x14, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
170 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
171 { 0x15, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
172 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
173 { 0x16, 0x0000ffff, 0, 0x31, SISLANDS_CACCONFIG_CGIND },
174 { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
175 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
176 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
177 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
178 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
179 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
180 { 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
181 { 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
182 { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
183 { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
184 { 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
185 { 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
186 { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
187 { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
188 { 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
189 { 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
190 { 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
191 { 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
192 { 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
193 { 0x6d, 0x0000ffff, 0, 0x18e, SISLANDS_CACCONFIG_CGIND },
197 static const struct si_cac_config_reg lcac_tahiti[] =
199 { 0x143, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
200 { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
201 { 0x146, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
202 { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
203 { 0x149, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
204 { 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
205 { 0x14c, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
206 { 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
207 { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
208 { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
209 { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
210 { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
211 { 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
212 { 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
213 { 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
214 { 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
215 { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
216 { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
217 { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
218 { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
219 { 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
220 { 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
221 { 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
222 { 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
223 { 0x8c, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
224 { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
225 { 0x8f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
226 { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
227 { 0x92, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
228 { 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
229 { 0x95, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
230 { 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
231 { 0x14f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
232 { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
233 { 0x152, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
234 { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
235 { 0x155, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
236 { 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
237 { 0x158, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
238 { 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
239 { 0x110, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
240 { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
241 { 0x113, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
242 { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
243 { 0x116, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
244 { 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
245 { 0x119, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
246 { 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
247 { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
248 { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
249 { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
250 { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
251 { 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
252 { 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
253 { 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
254 { 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
255 { 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
256 { 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
257 { 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
258 { 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
259 { 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
260 { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
261 { 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
262 { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
263 { 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
264 { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
265 { 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
266 { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
267 { 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
268 { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
269 { 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
270 { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
271 { 0x16d, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
272 { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
273 { 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
274 { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
275 { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
276 { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
277 { 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
278 { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
279 { 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
280 { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
281 { 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
282 { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
283 { 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
284 { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
289 static const struct si_cac_config_reg cac_override_tahiti[] =
294 static const struct si_powertune_data powertune_data_tahiti =
325 static const struct si_dte_data dte_data_tahiti =
327 { 1159409, 0, 0, 0, 0 },
336 { 27, 31, 35, 39, 43, 47, 54, 61, 67, 74, 81, 88, 95, 0, 0, 0 },
337 { 240888759, 221057860, 235370597, 162287531, 158510299, 131423027, 116673180, 103067515, 87941937, 76209048, 68209175, 64090048, 58301890, 0, 0, 0 },
338 { 12024, 11189, 11451, 8411, 7939, 6666, 5681, 4905, 4241, 3720, 3354, 3122, 2890, 0, 0, 0 },
344 static const struct si_dte_data dte_data_tahiti_le =
346 { 0x1E8480, 0x7A1200, 0x2160EC0, 0x3938700, 0 },
347 { 0x7D, 0x7D, 0x4E4, 0xB00, 0 },
355 { 0x78, 0x7C, 0x82, 0x88, 0x8E, 0x94, 0x9A, 0xA0, 0xA6, 0xAC, 0xB0, 0xB4, 0xB8, 0xBC, 0xC0, 0xC4 },
356 { 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700 },
357 { 0x2AF8, 0x2AF8, 0x29BB, 0x27F9, 0x2637, 0x2475, 0x22B3, 0x20F1, 0x1F2F, 0x1D6D, 0x1734, 0x1414, 0x10F4, 0xDD4, 0xAB4, 0x794 },
363 static const struct si_dte_data dte_data_tahiti_pro =
365 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
366 { 0x0, 0x0, 0x0, 0x0, 0x0 },
374 { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
375 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
376 { 0x7D0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
381 static const struct si_dte_data dte_data_new_zealand =
383 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0 },
384 { 0x29B, 0x3E9, 0x537, 0x7D2, 0 },
392 { 0x82, 0xA0, 0xB4, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE },
393 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
394 { 0xDAC, 0x1388, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685 },
399 static const struct si_dte_data dte_data_aruba_pro =
401 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
402 { 0x0, 0x0, 0x0, 0x0, 0x0 },
410 { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
411 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
412 { 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
417 static const struct si_dte_data dte_data_malta =
419 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
420 { 0x0, 0x0, 0x0, 0x0, 0x0 },
428 { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
429 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
430 { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
435 static const struct si_cac_config_reg cac_weights_pitcairn[] =
437 { 0x0, 0x0000ffff, 0, 0x8a, SISLANDS_CACCONFIG_CGIND },
438 { 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
439 { 0x1, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
440 { 0x1, 0xffff0000, 16, 0x24d, SISLANDS_CACCONFIG_CGIND },
441 { 0x2, 0x0000ffff, 0, 0x19, SISLANDS_CACCONFIG_CGIND },
442 { 0x3, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
443 { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
444 { 0x4, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
445 { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
446 { 0x5, 0x0000ffff, 0, 0xc11, SISLANDS_CACCONFIG_CGIND },
447 { 0x5, 0xffff0000, 16, 0x7f3, SISLANDS_CACCONFIG_CGIND },
448 { 0x6, 0x0000ffff, 0, 0x403, SISLANDS_CACCONFIG_CGIND },
449 { 0x6, 0xffff0000, 16, 0x367, SISLANDS_CACCONFIG_CGIND },
450 { 0x18f, 0x0000ffff, 0, 0x4c9, SISLANDS_CACCONFIG_CGIND },
451 { 0x7, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
452 { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
453 { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
454 { 0x8, 0xffff0000, 16, 0x45d, SISLANDS_CACCONFIG_CGIND },
455 { 0x9, 0x0000ffff, 0, 0x36d, SISLANDS_CACCONFIG_CGIND },
456 { 0xa, 0x0000ffff, 0, 0x534, SISLANDS_CACCONFIG_CGIND },
457 { 0xb, 0x0000ffff, 0, 0x5da, SISLANDS_CACCONFIG_CGIND },
458 { 0xb, 0xffff0000, 16, 0x880, SISLANDS_CACCONFIG_CGIND },
459 { 0xc, 0x0000ffff, 0, 0x201, SISLANDS_CACCONFIG_CGIND },
460 { 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
461 { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
462 { 0xe, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND },
463 { 0xf, 0x0000ffff, 0, 0x1f, SISLANDS_CACCONFIG_CGIND },
464 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
465 { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
466 { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
467 { 0x11, 0x0000ffff, 0, 0x5de, SISLANDS_CACCONFIG_CGIND },
468 { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
469 { 0x12, 0x0000ffff, 0, 0x7b, SISLANDS_CACCONFIG_CGIND },
470 { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
471 { 0x13, 0xffff0000, 16, 0x13, SISLANDS_CACCONFIG_CGIND },
472 { 0x14, 0x0000ffff, 0, 0xf9, SISLANDS_CACCONFIG_CGIND },
473 { 0x15, 0x0000ffff, 0, 0x66, SISLANDS_CACCONFIG_CGIND },
474 { 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
475 { 0x4e, 0x0000ffff, 0, 0x13, SISLANDS_CACCONFIG_CGIND },
476 { 0x16, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
477 { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
478 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
479 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
480 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
481 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
482 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
483 { 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
484 { 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
485 { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
486 { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
487 { 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
488 { 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
489 { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
490 { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
491 { 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
492 { 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
493 { 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
494 { 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
495 { 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
496 { 0x6d, 0x0000ffff, 0, 0x186, SISLANDS_CACCONFIG_CGIND },
500 static const struct si_cac_config_reg lcac_pitcairn[] =
502 { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
503 { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
504 { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
505 { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
506 { 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
507 { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
508 { 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
509 { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
510 { 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
511 { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
512 { 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
513 { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
514 { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
515 { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
516 { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
517 { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
518 { 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
519 { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
520 { 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
521 { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
522 { 0x8f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
523 { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
524 { 0x146, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
525 { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
526 { 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
527 { 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
528 { 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
529 { 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
530 { 0x116, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
531 { 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
532 { 0x155, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
533 { 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
534 { 0x92, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
535 { 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
536 { 0x149, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
537 { 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
538 { 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
539 { 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
540 { 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
541 { 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
542 { 0x119, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
543 { 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
544 { 0x158, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
545 { 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
546 { 0x95, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
547 { 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
548 { 0x14c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
549 { 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
550 { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
551 { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
552 { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
553 { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
554 { 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
555 { 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
556 { 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
557 { 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
558 { 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
559 { 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
560 { 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
561 { 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
562 { 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
563 { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
564 { 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
565 { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
566 { 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
567 { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
568 { 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
569 { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
570 { 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
571 { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
572 { 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
573 { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
574 { 0x16d, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
575 { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
576 { 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
577 { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
578 { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
579 { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
580 { 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
581 { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
582 { 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
583 { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
584 { 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
585 { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
586 { 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
587 { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
591 static const struct si_cac_config_reg cac_override_pitcairn[] =
596 static const struct si_powertune_data powertune_data_pitcairn =
627 static const struct si_dte_data dte_data_pitcairn =
638 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
639 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
640 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
645 static const struct si_dte_data dte_data_curacao_xt =
647 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
648 { 0x0, 0x0, 0x0, 0x0, 0x0 },
656 { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
657 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
658 { 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
663 static const struct si_dte_data dte_data_curacao_pro =
665 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
666 { 0x0, 0x0, 0x0, 0x0, 0x0 },
674 { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
675 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
676 { 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
681 static const struct si_dte_data dte_data_neptune_xt =
683 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
684 { 0x0, 0x0, 0x0, 0x0, 0x0 },
692 { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
693 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
694 { 0x3A2F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
699 static const struct si_cac_config_reg cac_weights_chelsea_pro[] =
701 { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
702 { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
703 { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
704 { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
705 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
706 { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
707 { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
708 { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
709 { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
710 { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
711 { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
712 { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
713 { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
714 { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
715 { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
716 { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
717 { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
718 { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
719 { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
720 { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
721 { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
722 { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
723 { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
724 { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
725 { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
726 { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
727 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
728 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
729 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
730 { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
731 { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
732 { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
733 { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
734 { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
735 { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
736 { 0x14, 0x0000ffff, 0, 0x2BD, SISLANDS_CACCONFIG_CGIND },
737 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
738 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
739 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
740 { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
741 { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
742 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
743 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
744 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
745 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
746 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
747 { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
748 { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
749 { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
750 { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
751 { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
752 { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
753 { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
754 { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
755 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
756 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
757 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
758 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
759 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
760 { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
764 static const struct si_cac_config_reg cac_weights_chelsea_xt[] =
766 { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
767 { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
768 { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
769 { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
770 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
771 { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
772 { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
773 { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
774 { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
775 { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
776 { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
777 { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
778 { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
779 { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
780 { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
781 { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
782 { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
783 { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
784 { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
785 { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
786 { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
787 { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
788 { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
789 { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
790 { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
791 { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
792 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
793 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
794 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
795 { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
796 { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
797 { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
798 { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
799 { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
800 { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
801 { 0x14, 0x0000ffff, 0, 0x30A, SISLANDS_CACCONFIG_CGIND },
802 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
803 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
804 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
805 { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
806 { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
807 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
808 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
809 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
810 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
811 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
812 { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
813 { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
814 { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
815 { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
816 { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
817 { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
818 { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
819 { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
820 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
821 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
822 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
823 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
824 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
825 { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
829 static const struct si_cac_config_reg cac_weights_heathrow[] =
831 { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
832 { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
833 { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
834 { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
835 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
836 { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
837 { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
838 { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
839 { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
840 { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
841 { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
842 { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
843 { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
844 { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
845 { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
846 { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
847 { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
848 { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
849 { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
850 { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
851 { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
852 { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
853 { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
854 { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
855 { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
856 { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
857 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
858 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
859 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
860 { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
861 { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
862 { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
863 { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
864 { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
865 { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
866 { 0x14, 0x0000ffff, 0, 0x362, SISLANDS_CACCONFIG_CGIND },
867 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
868 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
869 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
870 { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
871 { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
872 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
873 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
874 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
875 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
876 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
877 { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
878 { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
879 { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
880 { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
881 { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
882 { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
883 { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
884 { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
885 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
886 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
887 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
888 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
889 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
890 { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
894 static const struct si_cac_config_reg cac_weights_cape_verde_pro[] =
896 { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
897 { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
898 { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
899 { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
900 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
901 { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
902 { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
903 { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
904 { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
905 { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
906 { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
907 { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
908 { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
909 { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
910 { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
911 { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
912 { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
913 { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
914 { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
915 { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
916 { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
917 { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
918 { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
919 { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
920 { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
921 { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
922 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
923 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
924 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
925 { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
926 { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
927 { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
928 { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
929 { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
930 { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
931 { 0x14, 0x0000ffff, 0, 0x315, SISLANDS_CACCONFIG_CGIND },
932 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
933 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
934 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
935 { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
936 { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
937 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
938 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
939 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
940 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
941 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
942 { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
943 { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
944 { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
945 { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
946 { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
947 { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
948 { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
949 { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
950 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
951 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
952 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
953 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
954 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
955 { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
959 static const struct si_cac_config_reg cac_weights_cape_verde[] =
961 { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
962 { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
963 { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
964 { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
965 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
966 { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
967 { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
968 { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
969 { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
970 { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
971 { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
972 { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
973 { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
974 { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
975 { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
976 { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
977 { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
978 { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
979 { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
980 { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
981 { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
982 { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
983 { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
984 { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
985 { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
986 { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
987 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
988 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
989 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
990 { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
991 { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
992 { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
993 { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
994 { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
995 { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
996 { 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND },
997 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
998 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
999 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1000 { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
1001 { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
1002 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1003 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1004 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1005 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1006 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1007 { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1008 { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1009 { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1010 { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1011 { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1012 { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1013 { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1014 { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1015 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1016 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1017 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1018 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1019 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1020 { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
1024 static const struct si_cac_config_reg lcac_cape_verde[] =
1026 { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1027 { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1028 { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1029 { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1030 { 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1031 { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1032 { 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1033 { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1034 { 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1035 { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1036 { 0x143, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1037 { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1038 { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1039 { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1040 { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1041 { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1042 { 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1043 { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1044 { 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1045 { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1046 { 0x8f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1047 { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1048 { 0x146, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1049 { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1050 { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1051 { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1052 { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1053 { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1054 { 0x164, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1055 { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1056 { 0x167, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1057 { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1058 { 0x16a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1059 { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1060 { 0x15e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1061 { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1062 { 0x161, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1063 { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1064 { 0x15b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1065 { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1066 { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1067 { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1068 { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1069 { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1070 { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1071 { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1072 { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1073 { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1074 { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1075 { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1076 { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1077 { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1078 { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1079 { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1083 static const struct si_cac_config_reg cac_override_cape_verde[] =
1088 static const struct si_powertune_data powertune_data_cape_verde =
1090 ((1 << 16) | 0x6993),
1119 static const struct si_dte_data dte_data_cape_verde =
1130 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1131 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1132 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1137 static const struct si_dte_data dte_data_venus_xtx =
1139 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1140 { 0x71C, 0xAAB, 0xE39, 0x11C7, 0x0 },
1148 { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1149 { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1150 { 0xD6D8, 0x88B8, 0x1555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1155 static const struct si_dte_data dte_data_venus_xt =
1157 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1158 { 0xBDA, 0x11C7, 0x17B4, 0x1DA1, 0x0 },
1166 { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1167 { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1168 { 0xAFC8, 0x88B8, 0x238E, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1173 static const struct si_dte_data dte_data_venus_pro =
1175 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1176 { 0x11C7, 0x1AAB, 0x238E, 0x2C72, 0x0 },
1184 { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1185 { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1186 { 0x88B8, 0x88B8, 0x3555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1191 static const struct si_cac_config_reg cac_weights_oland[] =
1193 { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
1194 { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
1195 { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
1196 { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
1197 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1198 { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
1199 { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
1200 { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
1201 { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
1202 { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
1203 { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
1204 { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
1205 { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
1206 { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
1207 { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
1208 { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
1209 { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
1210 { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
1211 { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
1212 { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
1213 { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
1214 { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
1215 { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
1216 { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
1217 { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
1218 { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1219 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1220 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1221 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1222 { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
1223 { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1224 { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
1225 { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
1226 { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
1227 { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1228 { 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND },
1229 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1230 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1231 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1232 { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
1233 { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
1234 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1235 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1236 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1237 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1238 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1239 { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1240 { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1241 { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1242 { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1243 { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1244 { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1245 { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1246 { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1247 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1248 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1249 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1250 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1251 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1252 { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
1256 static const struct si_cac_config_reg cac_weights_mars_pro[] =
1258 { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
1259 { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1260 { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
1261 { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
1262 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1263 { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1264 { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1265 { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1266 { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
1267 { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
1268 { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
1269 { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
1270 { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
1271 { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
1272 { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
1273 { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
1274 { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
1275 { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
1276 { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
1277 { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
1278 { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
1279 { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
1280 { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
1281 { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1282 { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
1283 { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
1284 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1285 { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
1286 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1287 { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1288 { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
1289 { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1290 { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
1291 { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
1292 { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
1293 { 0x14, 0x0000ffff, 0, 0x2, SISLANDS_CACCONFIG_CGIND },
1294 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1295 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1296 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1297 { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
1298 { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
1299 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1300 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1301 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1302 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1303 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1304 { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
1305 { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1306 { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1307 { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1308 { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
1309 { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
1310 { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1311 { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1312 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1313 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1314 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1315 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1316 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1317 { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
1321 static const struct si_cac_config_reg cac_weights_mars_xt[] =
1323 { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
1324 { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1325 { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
1326 { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
1327 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1328 { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1329 { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1330 { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1331 { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
1332 { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
1333 { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
1334 { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
1335 { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
1336 { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
1337 { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
1338 { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
1339 { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
1340 { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
1341 { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
1342 { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
1343 { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
1344 { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
1345 { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
1346 { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1347 { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
1348 { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
1349 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1350 { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
1351 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1352 { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1353 { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
1354 { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1355 { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
1356 { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
1357 { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
1358 { 0x14, 0x0000ffff, 0, 0x60, SISLANDS_CACCONFIG_CGIND },
1359 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1360 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1361 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1362 { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
1363 { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
1364 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1365 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1366 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1367 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1368 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1369 { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
1370 { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1371 { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1372 { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1373 { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
1374 { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
1375 { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1376 { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1377 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1378 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1379 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1380 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1381 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1382 { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
1386 static const struct si_cac_config_reg cac_weights_oland_pro[] =
1388 { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
1389 { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1390 { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
1391 { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
1392 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1393 { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1394 { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1395 { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1396 { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
1397 { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
1398 { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
1399 { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
1400 { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
1401 { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
1402 { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
1403 { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
1404 { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
1405 { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
1406 { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
1407 { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
1408 { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
1409 { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
1410 { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
1411 { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1412 { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
1413 { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
1414 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1415 { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
1416 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1417 { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1418 { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
1419 { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1420 { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
1421 { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
1422 { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
1423 { 0x14, 0x0000ffff, 0, 0x90, SISLANDS_CACCONFIG_CGIND },
1424 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1425 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1426 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1427 { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
1428 { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
1429 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1430 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1431 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1432 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1433 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1434 { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
1435 { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1436 { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1437 { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1438 { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
1439 { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
1440 { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1441 { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1442 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1443 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1444 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1445 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1446 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1447 { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
1451 static const struct si_cac_config_reg cac_weights_oland_xt[] =
1453 { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
1454 { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1455 { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
1456 { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
1457 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1458 { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1459 { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1460 { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1461 { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
1462 { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
1463 { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
1464 { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
1465 { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
1466 { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
1467 { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
1468 { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
1469 { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
1470 { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
1471 { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
1472 { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
1473 { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
1474 { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
1475 { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
1476 { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1477 { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
1478 { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
1479 { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1480 { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
1481 { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1482 { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1483 { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
1484 { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1485 { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
1486 { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
1487 { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
1488 { 0x14, 0x0000ffff, 0, 0x120, SISLANDS_CACCONFIG_CGIND },
1489 { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1490 { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1491 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1492 { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
1493 { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
1494 { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1495 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1496 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1497 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1498 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1499 { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
1500 { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1501 { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1502 { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1503 { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
1504 { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
1505 { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1506 { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1507 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1508 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1509 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1510 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1511 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1512 { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
1516 static const struct si_cac_config_reg lcac_oland[] =
1518 { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1519 { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1520 { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1521 { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1522 { 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1523 { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1524 { 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1525 { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1526 { 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1527 { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1528 { 0x143, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
1529 { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1530 { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1531 { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1532 { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1533 { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1534 { 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1535 { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1536 { 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1537 { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1538 { 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1539 { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1540 { 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1541 { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1542 { 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1543 { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1544 { 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1545 { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1546 { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1547 { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1548 { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1549 { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1550 { 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1551 { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1552 { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1553 { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1554 { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1555 { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1556 { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1557 { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1558 { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1559 { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1563 static const struct si_cac_config_reg lcac_mars_pro[] =
1565 { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1566 { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1567 { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1568 { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1569 { 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1570 { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1571 { 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1572 { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1573 { 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1574 { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1575 { 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1576 { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1577 { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1578 { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1579 { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1580 { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1581 { 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1582 { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1583 { 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1584 { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1585 { 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1586 { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1587 { 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1588 { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1589 { 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1590 { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1591 { 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1592 { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1593 { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1594 { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1595 { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1596 { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1597 { 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1598 { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1599 { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1600 { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1601 { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1602 { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1603 { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1604 { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1605 { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1606 { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1610 static const struct si_cac_config_reg cac_override_oland[] =
1615 static const struct si_powertune_data powertune_data_oland =
1617 ((1 << 16) | 0x6993),
1646 static const struct si_powertune_data powertune_data_mars_pro =
1648 ((1 << 16) | 0x6993),
1677 static const struct si_dte_data dte_data_oland =
1688 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1689 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1690 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1695 static const struct si_dte_data dte_data_mars_pro =
1697 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1698 { 0x0, 0x0, 0x0, 0x0, 0x0 },
1706 { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
1707 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
1708 { 0xF627, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1713 static const struct si_dte_data dte_data_sun_xt =
1715 { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1716 { 0x0, 0x0, 0x0, 0x0, 0x0 },
1724 { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
1725 { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
1726 { 0xD555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1732 static const struct si_cac_config_reg cac_weights_hainan[] =
1734 { 0x0, 0x0000ffff, 0, 0x2d9, SISLANDS_CACCONFIG_CGIND },
1735 { 0x0, 0xffff0000, 16, 0x22b, SISLANDS_CACCONFIG_CGIND },
1736 { 0x1, 0x0000ffff, 0, 0x21c, SISLANDS_CACCONFIG_CGIND },
1737 { 0x1, 0xffff0000, 16, 0x1dc, SISLANDS_CACCONFIG_CGIND },
1738 { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1739 { 0x3, 0x0000ffff, 0, 0x24e, SISLANDS_CACCONFIG_CGIND },
1740 { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1741 { 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1742 { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1743 { 0x5, 0x0000ffff, 0, 0x35e, SISLANDS_CACCONFIG_CGIND },
1744 { 0x5, 0xffff0000, 16, 0x1143, SISLANDS_CACCONFIG_CGIND },
1745 { 0x6, 0x0000ffff, 0, 0xe17, SISLANDS_CACCONFIG_CGIND },
1746 { 0x6, 0xffff0000, 16, 0x441, SISLANDS_CACCONFIG_CGIND },
1747 { 0x18f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1748 { 0x7, 0x0000ffff, 0, 0x28b, SISLANDS_CACCONFIG_CGIND },
1749 { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1750 { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1751 { 0x8, 0xffff0000, 16, 0xabe, SISLANDS_CACCONFIG_CGIND },
1752 { 0x9, 0x0000ffff, 0, 0xf11, SISLANDS_CACCONFIG_CGIND },
1753 { 0xa, 0x0000ffff, 0, 0x907, SISLANDS_CACCONFIG_CGIND },
1754 { 0xb, 0x0000ffff, 0, 0xb45, SISLANDS_CACCONFIG_CGIND },
1755 { 0xb, 0xffff0000, 16, 0xd1e, SISLANDS_CACCONFIG_CGIND },
1756 { 0xc, 0x0000ffff, 0, 0xa2c, SISLANDS_CACCONFIG_CGIND },
1757 { 0xd, 0x0000ffff, 0, 0x62, SISLANDS_CACCONFIG_CGIND },
1758 { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1759 { 0xe, 0x0000ffff, 0, 0x1f3, SISLANDS_CACCONFIG_CGIND },
1760 { 0xf, 0x0000ffff, 0, 0x42, SISLANDS_CACCONFIG_CGIND },
1761 { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1762 { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1763 { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1764 { 0x11, 0x0000ffff, 0, 0x709, SISLANDS_CACCONFIG_CGIND },
1765 { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1766 { 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1767 { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1768 { 0x13, 0xffff0000, 16, 0x3a, SISLANDS_CACCONFIG_CGIND },
1769 { 0x14, 0x0000ffff, 0, 0x357, SISLANDS_CACCONFIG_CGIND },
1770 { 0x15, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND },
1771 { 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1772 { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1773 { 0x16, 0x0000ffff, 0, 0x314, SISLANDS_CACCONFIG_CGIND },
1774 { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1775 { 0x17, 0x0000ffff, 0, 0x6d, SISLANDS_CACCONFIG_CGIND },
1776 { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1777 { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1778 { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1779 { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1780 { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1781 { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1782 { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1783 { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1784 { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1785 { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1786 { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1787 { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1788 { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1789 { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1790 { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1791 { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1792 { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1793 { 0x6d, 0x0000ffff, 0, 0x1b9, SISLANDS_CACCONFIG_CGIND },
1797 static const struct si_powertune_data powertune_data_hainan =
1799 ((1 << 16) | 0x6993),
1828 static struct rv7xx_power_info *rv770_get_pi(struct amdgpu_device *adev);
1829 static struct evergreen_power_info *evergreen_get_pi(struct amdgpu_device *adev);
1830 static struct ni_power_info *ni_get_pi(struct amdgpu_device *adev);
1831 static struct si_ps *si_get_ps(struct amdgpu_ps *rps);
1833 static int si_populate_voltage_value(struct amdgpu_device *adev,
1834 const struct atom_voltage_table *table,
1835 u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage);
1836 static int si_get_std_voltage_value(struct amdgpu_device *adev,
1837 SISLANDS_SMC_VOLTAGE_VALUE *voltage,
1839 static int si_write_smc_soft_register(struct amdgpu_device *adev,
1840 u16 reg_offset, u32 value);
1841 static int si_convert_power_level_to_smc(struct amdgpu_device *adev,
1842 struct rv7xx_pl *pl,
1843 SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level);
1844 static int si_calculate_sclk_params(struct amdgpu_device *adev,
1846 SISLANDS_SMC_SCLK_VALUE *sclk);
1848 static void si_thermal_start_smc_fan_control(struct amdgpu_device *adev);
1849 static void si_fan_ctrl_set_default_mode(struct amdgpu_device *adev);
1850 static void si_dpm_set_dpm_funcs(struct amdgpu_device *adev);
1851 static void si_dpm_set_irq_funcs(struct amdgpu_device *adev);
1853 static struct si_power_info *si_get_pi(struct amdgpu_device *adev)
1855 struct si_power_info *pi = adev->pm.dpm.priv;
1859 static void si_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coeffients *coeff,
1860 u16 v, s32 t, u32 ileakage, u32 *leakage)
1862 s64 kt, kv, leakage_w, i_leakage, vddc;
1863 s64 temperature, t_slope, t_intercept, av, bv, t_ref;
1866 i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
1867 vddc = div64_s64(drm_int2fixp(v), 1000);
1868 temperature = div64_s64(drm_int2fixp(t), 1000);
1870 t_slope = div64_s64(drm_int2fixp(coeff->t_slope), 100000000);
1871 t_intercept = div64_s64(drm_int2fixp(coeff->t_intercept), 100000000);
1872 av = div64_s64(drm_int2fixp(coeff->av), 100000000);
1873 bv = div64_s64(drm_int2fixp(coeff->bv), 100000000);
1874 t_ref = drm_int2fixp(coeff->t_ref);
1876 tmp = drm_fixp_mul(t_slope, vddc) + t_intercept;
1877 kt = drm_fixp_exp(drm_fixp_mul(tmp, temperature));
1878 kt = drm_fixp_div(kt, drm_fixp_exp(drm_fixp_mul(tmp, t_ref)));
1879 kv = drm_fixp_mul(av, drm_fixp_exp(drm_fixp_mul(bv, vddc)));
1881 leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
1883 *leakage = drm_fixp2int(leakage_w * 1000);
1886 static void si_calculate_leakage_for_v_and_t(struct amdgpu_device *adev,
1887 const struct ni_leakage_coeffients *coeff,
1893 si_calculate_leakage_for_v_and_t_formula(coeff, v, t, i_leakage, leakage);
1896 static void si_calculate_leakage_for_v_formula(const struct ni_leakage_coeffients *coeff,
1897 const u32 fixed_kt, u16 v,
1898 u32 ileakage, u32 *leakage)
1900 s64 kt, kv, leakage_w, i_leakage, vddc;
1902 i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
1903 vddc = div64_s64(drm_int2fixp(v), 1000);
1905 kt = div64_s64(drm_int2fixp(fixed_kt), 100000000);
1906 kv = drm_fixp_mul(div64_s64(drm_int2fixp(coeff->av), 100000000),
1907 drm_fixp_exp(drm_fixp_mul(div64_s64(drm_int2fixp(coeff->bv), 100000000), vddc)));
1909 leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
1911 *leakage = drm_fixp2int(leakage_w * 1000);
1914 static void si_calculate_leakage_for_v(struct amdgpu_device *adev,
1915 const struct ni_leakage_coeffients *coeff,
1921 si_calculate_leakage_for_v_formula(coeff, fixed_kt, v, i_leakage, leakage);
1925 static void si_update_dte_from_pl2(struct amdgpu_device *adev,
1926 struct si_dte_data *dte_data)
1928 u32 p_limit1 = adev->pm.dpm.tdp_limit;
1929 u32 p_limit2 = adev->pm.dpm.near_tdp_limit;
1930 u32 k = dte_data->k;
1931 u32 t_max = dte_data->max_t;
1932 u32 t_split[5] = { 10, 15, 20, 25, 30 };
1933 u32 t_0 = dte_data->t0;
1936 if (p_limit2 != 0 && p_limit2 <= p_limit1) {
1937 dte_data->tdep_count = 3;
1939 for (i = 0; i < k; i++) {
1941 (t_split[i] * (t_max - t_0/(u32)1000) * (1 << 14)) /
1942 (p_limit2 * (u32)100);
1945 dte_data->tdep_r[1] = dte_data->r[4] * 2;
1947 for (i = 2; i < SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE; i++) {
1948 dte_data->tdep_r[i] = dte_data->r[4];
1951 DRM_ERROR("Invalid PL2! DTE will not be updated.\n");
1955 static struct rv7xx_power_info *rv770_get_pi(struct amdgpu_device *adev)
1957 struct rv7xx_power_info *pi = adev->pm.dpm.priv;
1962 static struct ni_power_info *ni_get_pi(struct amdgpu_device *adev)
1964 struct ni_power_info *pi = adev->pm.dpm.priv;
1969 static struct si_ps *si_get_ps(struct amdgpu_ps *aps)
1971 struct si_ps *ps = aps->ps_priv;
1976 static void si_initialize_powertune_defaults(struct amdgpu_device *adev)
1978 struct ni_power_info *ni_pi = ni_get_pi(adev);
1979 struct si_power_info *si_pi = si_get_pi(adev);
1980 bool update_dte_from_pl2 = false;
1982 if (adev->asic_type == CHIP_TAHITI) {
1983 si_pi->cac_weights = cac_weights_tahiti;
1984 si_pi->lcac_config = lcac_tahiti;
1985 si_pi->cac_override = cac_override_tahiti;
1986 si_pi->powertune_data = &powertune_data_tahiti;
1987 si_pi->dte_data = dte_data_tahiti;
1989 switch (adev->pdev->device) {
1991 si_pi->dte_data.enable_dte_by_default = true;
1994 si_pi->dte_data = dte_data_new_zealand;
2000 si_pi->dte_data = dte_data_aruba_pro;
2001 update_dte_from_pl2 = true;
2004 si_pi->dte_data = dte_data_malta;
2005 update_dte_from_pl2 = true;
2008 si_pi->dte_data = dte_data_tahiti_pro;
2009 update_dte_from_pl2 = true;
2012 if (si_pi->dte_data.enable_dte_by_default == true)
2013 DRM_ERROR("DTE is not enabled!\n");
2016 } else if (adev->asic_type == CHIP_PITCAIRN) {
2017 si_pi->cac_weights = cac_weights_pitcairn;
2018 si_pi->lcac_config = lcac_pitcairn;
2019 si_pi->cac_override = cac_override_pitcairn;
2020 si_pi->powertune_data = &powertune_data_pitcairn;
2022 switch (adev->pdev->device) {
2025 si_pi->dte_data = dte_data_curacao_xt;
2026 update_dte_from_pl2 = true;
2030 si_pi->dte_data = dte_data_curacao_pro;
2031 update_dte_from_pl2 = true;
2035 si_pi->dte_data = dte_data_neptune_xt;
2036 update_dte_from_pl2 = true;
2039 si_pi->dte_data = dte_data_pitcairn;
2042 } else if (adev->asic_type == CHIP_VERDE) {
2043 si_pi->lcac_config = lcac_cape_verde;
2044 si_pi->cac_override = cac_override_cape_verde;
2045 si_pi->powertune_data = &powertune_data_cape_verde;
2047 switch (adev->pdev->device) {
2052 si_pi->cac_weights = cac_weights_cape_verde_pro;
2053 si_pi->dte_data = dte_data_cape_verde;
2056 si_pi->cac_weights = cac_weights_cape_verde_pro;
2057 si_pi->dte_data = dte_data_sun_xt;
2061 si_pi->cac_weights = cac_weights_heathrow;
2062 si_pi->dte_data = dte_data_cape_verde;
2066 si_pi->cac_weights = cac_weights_chelsea_xt;
2067 si_pi->dte_data = dte_data_cape_verde;
2070 si_pi->cac_weights = cac_weights_chelsea_pro;
2071 si_pi->dte_data = dte_data_cape_verde;
2074 si_pi->cac_weights = cac_weights_heathrow;
2075 si_pi->dte_data = dte_data_venus_xtx;
2078 si_pi->cac_weights = cac_weights_heathrow;
2079 si_pi->dte_data = dte_data_venus_xt;
2085 si_pi->cac_weights = cac_weights_chelsea_pro;
2086 si_pi->dte_data = dte_data_venus_pro;
2089 si_pi->cac_weights = cac_weights_cape_verde;
2090 si_pi->dte_data = dte_data_cape_verde;
2093 } else if (adev->asic_type == CHIP_OLAND) {
2094 si_pi->lcac_config = lcac_mars_pro;
2095 si_pi->cac_override = cac_override_oland;
2096 si_pi->powertune_data = &powertune_data_mars_pro;
2097 si_pi->dte_data = dte_data_mars_pro;
2099 switch (adev->pdev->device) {
2104 si_pi->cac_weights = cac_weights_mars_pro;
2105 update_dte_from_pl2 = true;
2111 si_pi->cac_weights = cac_weights_mars_xt;
2112 update_dte_from_pl2 = true;
2117 si_pi->cac_weights = cac_weights_oland_pro;
2118 update_dte_from_pl2 = true;
2121 si_pi->cac_weights = cac_weights_oland_xt;
2122 update_dte_from_pl2 = true;
2125 si_pi->cac_weights = cac_weights_oland;
2126 si_pi->lcac_config = lcac_oland;
2127 si_pi->cac_override = cac_override_oland;
2128 si_pi->powertune_data = &powertune_data_oland;
2129 si_pi->dte_data = dte_data_oland;
2132 } else if (adev->asic_type == CHIP_HAINAN) {
2133 si_pi->cac_weights = cac_weights_hainan;
2134 si_pi->lcac_config = lcac_oland;
2135 si_pi->cac_override = cac_override_oland;
2136 si_pi->powertune_data = &powertune_data_hainan;
2137 si_pi->dte_data = dte_data_sun_xt;
2138 update_dte_from_pl2 = true;
2140 DRM_ERROR("Unknown SI asic revision, failed to initialize PowerTune!\n");
2144 ni_pi->enable_power_containment = false;
2145 ni_pi->enable_cac = false;
2146 ni_pi->enable_sq_ramping = false;
2147 si_pi->enable_dte = false;
2149 if (si_pi->powertune_data->enable_powertune_by_default) {
2150 ni_pi->enable_power_containment = true;
2151 ni_pi->enable_cac = true;
2152 if (si_pi->dte_data.enable_dte_by_default) {
2153 si_pi->enable_dte = true;
2154 if (update_dte_from_pl2)
2155 si_update_dte_from_pl2(adev, &si_pi->dte_data);
2158 ni_pi->enable_sq_ramping = true;
2161 ni_pi->driver_calculate_cac_leakage = true;
2162 ni_pi->cac_configuration_required = true;
2164 if (ni_pi->cac_configuration_required) {
2165 ni_pi->support_cac_long_term_average = true;
2166 si_pi->dyn_powertune_data.l2_lta_window_size =
2167 si_pi->powertune_data->l2_lta_window_size_default;
2168 si_pi->dyn_powertune_data.lts_truncate =
2169 si_pi->powertune_data->lts_truncate_default;
2171 ni_pi->support_cac_long_term_average = false;
2172 si_pi->dyn_powertune_data.l2_lta_window_size = 0;
2173 si_pi->dyn_powertune_data.lts_truncate = 0;
2176 si_pi->dyn_powertune_data.disable_uvd_powertune = false;
2179 static u32 si_get_smc_power_scaling_factor(struct amdgpu_device *adev)
2184 static u32 si_calculate_cac_wintime(struct amdgpu_device *adev)
2189 u32 cac_window_size;
2191 xclk = amdgpu_asic_get_xclk(adev);
2196 cac_window = RREG32(CG_CAC_CTRL) & CAC_WINDOW_MASK;
2197 cac_window_size = ((cac_window & 0xFFFF0000) >> 16) * (cac_window & 0x0000FFFF);
2199 wintime = (cac_window_size * 100) / xclk;
2204 static u32 si_scale_power_for_smc(u32 power_in_watts, u32 scaling_factor)
2206 return power_in_watts;
2209 static int si_calculate_adjusted_tdp_limits(struct amdgpu_device *adev,
2210 bool adjust_polarity,
2213 u32 *near_tdp_limit)
2215 u32 adjustment_delta, max_tdp_limit;
2217 if (tdp_adjustment > (u32)adev->pm.dpm.tdp_od_limit)
2220 max_tdp_limit = ((100 + 100) * adev->pm.dpm.tdp_limit) / 100;
2222 if (adjust_polarity) {
2223 *tdp_limit = ((100 + tdp_adjustment) * adev->pm.dpm.tdp_limit) / 100;
2224 *near_tdp_limit = adev->pm.dpm.near_tdp_limit_adjusted + (*tdp_limit - adev->pm.dpm.tdp_limit);
2226 *tdp_limit = ((100 - tdp_adjustment) * adev->pm.dpm.tdp_limit) / 100;
2227 adjustment_delta = adev->pm.dpm.tdp_limit - *tdp_limit;
2228 if (adjustment_delta < adev->pm.dpm.near_tdp_limit_adjusted)
2229 *near_tdp_limit = adev->pm.dpm.near_tdp_limit_adjusted - adjustment_delta;
2231 *near_tdp_limit = 0;
2234 if ((*tdp_limit <= 0) || (*tdp_limit > max_tdp_limit))
2236 if ((*near_tdp_limit <= 0) || (*near_tdp_limit > *tdp_limit))
2242 static int si_populate_smc_tdp_limits(struct amdgpu_device *adev,
2243 struct amdgpu_ps *amdgpu_state)
2245 struct ni_power_info *ni_pi = ni_get_pi(adev);
2246 struct si_power_info *si_pi = si_get_pi(adev);
2248 if (ni_pi->enable_power_containment) {
2249 SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable;
2250 PP_SIslands_PAPMParameters *papm_parm;
2251 struct amdgpu_ppm_table *ppm = adev->pm.dpm.dyn_state.ppm_table;
2252 u32 scaling_factor = si_get_smc_power_scaling_factor(adev);
2257 if (scaling_factor == 0)
2260 memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE));
2262 ret = si_calculate_adjusted_tdp_limits(adev,
2264 adev->pm.dpm.tdp_adjustment,
2270 smc_table->dpm2Params.TDPLimit =
2271 cpu_to_be32(si_scale_power_for_smc(tdp_limit, scaling_factor) * 1000);
2272 smc_table->dpm2Params.NearTDPLimit =
2273 cpu_to_be32(si_scale_power_for_smc(near_tdp_limit, scaling_factor) * 1000);
2274 smc_table->dpm2Params.SafePowerLimit =
2275 cpu_to_be32(si_scale_power_for_smc((near_tdp_limit * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000);
2277 ret = amdgpu_si_copy_bytes_to_smc(adev,
2278 (si_pi->state_table_start + offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) +
2279 offsetof(PP_SIslands_DPM2Parameters, TDPLimit)),
2280 (u8 *)(&(smc_table->dpm2Params.TDPLimit)),
2286 if (si_pi->enable_ppm) {
2287 papm_parm = &si_pi->papm_parm;
2288 memset(papm_parm, 0, sizeof(PP_SIslands_PAPMParameters));
2289 papm_parm->NearTDPLimitTherm = cpu_to_be32(ppm->dgpu_tdp);
2290 papm_parm->dGPU_T_Limit = cpu_to_be32(ppm->tj_max);
2291 papm_parm->dGPU_T_Warning = cpu_to_be32(95);
2292 papm_parm->dGPU_T_Hysteresis = cpu_to_be32(5);
2293 papm_parm->PlatformPowerLimit = 0xffffffff;
2294 papm_parm->NearTDPLimitPAPM = 0xffffffff;
2296 ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->papm_cfg_table_start,
2298 sizeof(PP_SIslands_PAPMParameters),
2307 static int si_populate_smc_tdp_limits_2(struct amdgpu_device *adev,
2308 struct amdgpu_ps *amdgpu_state)
2310 struct ni_power_info *ni_pi = ni_get_pi(adev);
2311 struct si_power_info *si_pi = si_get_pi(adev);
2313 if (ni_pi->enable_power_containment) {
2314 SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable;
2315 u32 scaling_factor = si_get_smc_power_scaling_factor(adev);
2318 memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE));
2320 smc_table->dpm2Params.NearTDPLimit =
2321 cpu_to_be32(si_scale_power_for_smc(adev->pm.dpm.near_tdp_limit_adjusted, scaling_factor) * 1000);
2322 smc_table->dpm2Params.SafePowerLimit =
2323 cpu_to_be32(si_scale_power_for_smc((adev->pm.dpm.near_tdp_limit_adjusted * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000);
2325 ret = amdgpu_si_copy_bytes_to_smc(adev,
2326 (si_pi->state_table_start +
2327 offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) +
2328 offsetof(PP_SIslands_DPM2Parameters, NearTDPLimit)),
2329 (u8 *)(&(smc_table->dpm2Params.NearTDPLimit)),
2339 static u16 si_calculate_power_efficiency_ratio(struct amdgpu_device *adev,
2340 const u16 prev_std_vddc,
2341 const u16 curr_std_vddc)
2343 u64 margin = (u64)SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN;
2344 u64 prev_vddc = (u64)prev_std_vddc;
2345 u64 curr_vddc = (u64)curr_std_vddc;
2346 u64 pwr_efficiency_ratio, n, d;
2348 if ((prev_vddc == 0) || (curr_vddc == 0))
2351 n = div64_u64((u64)1024 * curr_vddc * curr_vddc * ((u64)1000 + margin), (u64)1000);
2352 d = prev_vddc * prev_vddc;
2353 pwr_efficiency_ratio = div64_u64(n, d);
2355 if (pwr_efficiency_ratio > (u64)0xFFFF)
2358 return (u16)pwr_efficiency_ratio;
2361 static bool si_should_disable_uvd_powertune(struct amdgpu_device *adev,
2362 struct amdgpu_ps *amdgpu_state)
2364 struct si_power_info *si_pi = si_get_pi(adev);
2366 if (si_pi->dyn_powertune_data.disable_uvd_powertune &&
2367 amdgpu_state->vclk && amdgpu_state->dclk)
2373 struct evergreen_power_info *evergreen_get_pi(struct amdgpu_device *adev)
2375 struct evergreen_power_info *pi = adev->pm.dpm.priv;
2380 static int si_populate_power_containment_values(struct amdgpu_device *adev,
2381 struct amdgpu_ps *amdgpu_state,
2382 SISLANDS_SMC_SWSTATE *smc_state)
2384 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
2385 struct ni_power_info *ni_pi = ni_get_pi(adev);
2386 struct si_ps *state = si_get_ps(amdgpu_state);
2387 SISLANDS_SMC_VOLTAGE_VALUE vddc;
2394 u16 pwr_efficiency_ratio;
2396 bool disable_uvd_power_tune;
2399 if (ni_pi->enable_power_containment == false)
2402 if (state->performance_level_count == 0)
2405 if (smc_state->levelCount != state->performance_level_count)
2408 disable_uvd_power_tune = si_should_disable_uvd_powertune(adev, amdgpu_state);
2410 smc_state->levels[0].dpm2.MaxPS = 0;
2411 smc_state->levels[0].dpm2.NearTDPDec = 0;
2412 smc_state->levels[0].dpm2.AboveSafeInc = 0;
2413 smc_state->levels[0].dpm2.BelowSafeInc = 0;
2414 smc_state->levels[0].dpm2.PwrEfficiencyRatio = 0;
2416 for (i = 1; i < state->performance_level_count; i++) {
2417 prev_sclk = state->performance_levels[i-1].sclk;
2418 max_sclk = state->performance_levels[i].sclk;
2420 max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_M;
2422 max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_H;
2424 if (prev_sclk > max_sclk)
2427 if ((max_ps_percent == 0) ||
2428 (prev_sclk == max_sclk) ||
2429 disable_uvd_power_tune)
2430 min_sclk = max_sclk;
2432 min_sclk = prev_sclk;
2434 min_sclk = (prev_sclk * (u32)max_ps_percent) / 100;
2436 if (min_sclk < state->performance_levels[0].sclk)
2437 min_sclk = state->performance_levels[0].sclk;
2442 ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
2443 state->performance_levels[i-1].vddc, &vddc);
2447 ret = si_get_std_voltage_value(adev, &vddc, &prev_std_vddc);
2451 ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
2452 state->performance_levels[i].vddc, &vddc);
2456 ret = si_get_std_voltage_value(adev, &vddc, &curr_std_vddc);
2460 pwr_efficiency_ratio = si_calculate_power_efficiency_ratio(adev,
2461 prev_std_vddc, curr_std_vddc);
2463 smc_state->levels[i].dpm2.MaxPS = (u8)((SISLANDS_DPM2_MAX_PULSE_SKIP * (max_sclk - min_sclk)) / max_sclk);
2464 smc_state->levels[i].dpm2.NearTDPDec = SISLANDS_DPM2_NEAR_TDP_DEC;
2465 smc_state->levels[i].dpm2.AboveSafeInc = SISLANDS_DPM2_ABOVE_SAFE_INC;
2466 smc_state->levels[i].dpm2.BelowSafeInc = SISLANDS_DPM2_BELOW_SAFE_INC;
2467 smc_state->levels[i].dpm2.PwrEfficiencyRatio = cpu_to_be16(pwr_efficiency_ratio);
2473 static int si_populate_sq_ramping_values(struct amdgpu_device *adev,
2474 struct amdgpu_ps *amdgpu_state,
2475 SISLANDS_SMC_SWSTATE *smc_state)
2477 struct ni_power_info *ni_pi = ni_get_pi(adev);
2478 struct si_ps *state = si_get_ps(amdgpu_state);
2479 u32 sq_power_throttle, sq_power_throttle2;
2480 bool enable_sq_ramping = ni_pi->enable_sq_ramping;
2483 if (state->performance_level_count == 0)
2486 if (smc_state->levelCount != state->performance_level_count)
2489 if (adev->pm.dpm.sq_ramping_threshold == 0)
2492 if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER > (MAX_POWER_MASK >> MAX_POWER_SHIFT))
2493 enable_sq_ramping = false;
2495 if (SISLANDS_DPM2_SQ_RAMP_MIN_POWER > (MIN_POWER_MASK >> MIN_POWER_SHIFT))
2496 enable_sq_ramping = false;
2498 if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA > (MAX_POWER_DELTA_MASK >> MAX_POWER_DELTA_SHIFT))
2499 enable_sq_ramping = false;
2501 if (SISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT))
2502 enable_sq_ramping = false;
2504 if (SISLANDS_DPM2_SQ_RAMP_LTI_RATIO > (LTI_RATIO_MASK >> LTI_RATIO_SHIFT))
2505 enable_sq_ramping = false;
2507 for (i = 0; i < state->performance_level_count; i++) {
2508 sq_power_throttle = 0;
2509 sq_power_throttle2 = 0;
2511 if ((state->performance_levels[i].sclk >= adev->pm.dpm.sq_ramping_threshold) &&
2512 enable_sq_ramping) {
2513 sq_power_throttle |= MAX_POWER(SISLANDS_DPM2_SQ_RAMP_MAX_POWER);
2514 sq_power_throttle |= MIN_POWER(SISLANDS_DPM2_SQ_RAMP_MIN_POWER);
2515 sq_power_throttle2 |= MAX_POWER_DELTA(SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA);
2516 sq_power_throttle2 |= STI_SIZE(SISLANDS_DPM2_SQ_RAMP_STI_SIZE);
2517 sq_power_throttle2 |= LTI_RATIO(SISLANDS_DPM2_SQ_RAMP_LTI_RATIO);
2519 sq_power_throttle |= MAX_POWER_MASK | MIN_POWER_MASK;
2520 sq_power_throttle2 |= MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
2523 smc_state->levels[i].SQPowerThrottle = cpu_to_be32(sq_power_throttle);
2524 smc_state->levels[i].SQPowerThrottle_2 = cpu_to_be32(sq_power_throttle2);
2530 static int si_enable_power_containment(struct amdgpu_device *adev,
2531 struct amdgpu_ps *amdgpu_new_state,
2534 struct ni_power_info *ni_pi = ni_get_pi(adev);
2535 PPSMC_Result smc_result;
2538 if (ni_pi->enable_power_containment) {
2540 if (!si_should_disable_uvd_powertune(adev, amdgpu_new_state)) {
2541 smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_TDPClampingActive);
2542 if (smc_result != PPSMC_Result_OK) {
2544 ni_pi->pc_enabled = false;
2546 ni_pi->pc_enabled = true;
2550 smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_TDPClampingInactive);
2551 if (smc_result != PPSMC_Result_OK)
2553 ni_pi->pc_enabled = false;
2560 static int si_initialize_smc_dte_tables(struct amdgpu_device *adev)
2562 struct si_power_info *si_pi = si_get_pi(adev);
2564 struct si_dte_data *dte_data = &si_pi->dte_data;
2565 Smc_SIslands_DTE_Configuration *dte_tables = NULL;
2570 if (dte_data == NULL)
2571 si_pi->enable_dte = false;
2573 if (si_pi->enable_dte == false)
2576 if (dte_data->k <= 0)
2579 dte_tables = kzalloc(sizeof(Smc_SIslands_DTE_Configuration), GFP_KERNEL);
2580 if (dte_tables == NULL) {
2581 si_pi->enable_dte = false;
2585 table_size = dte_data->k;
2587 if (table_size > SMC_SISLANDS_DTE_MAX_FILTER_STAGES)
2588 table_size = SMC_SISLANDS_DTE_MAX_FILTER_STAGES;
2590 tdep_count = dte_data->tdep_count;
2591 if (tdep_count > SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE)
2592 tdep_count = SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE;
2594 dte_tables->K = cpu_to_be32(table_size);
2595 dte_tables->T0 = cpu_to_be32(dte_data->t0);
2596 dte_tables->MaxT = cpu_to_be32(dte_data->max_t);
2597 dte_tables->WindowSize = dte_data->window_size;
2598 dte_tables->temp_select = dte_data->temp_select;
2599 dte_tables->DTE_mode = dte_data->dte_mode;
2600 dte_tables->Tthreshold = cpu_to_be32(dte_data->t_threshold);
2605 for (i = 0; i < table_size; i++) {
2606 dte_tables->tau[i] = cpu_to_be32(dte_data->tau[i]);
2607 dte_tables->R[i] = cpu_to_be32(dte_data->r[i]);
2610 dte_tables->Tdep_count = tdep_count;
2612 for (i = 0; i < (u32)tdep_count; i++) {
2613 dte_tables->T_limits[i] = dte_data->t_limits[i];
2614 dte_tables->Tdep_tau[i] = cpu_to_be32(dte_data->tdep_tau[i]);
2615 dte_tables->Tdep_R[i] = cpu_to_be32(dte_data->tdep_r[i]);
2618 ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->dte_table_start,
2620 sizeof(Smc_SIslands_DTE_Configuration),
2627 static int si_get_cac_std_voltage_max_min(struct amdgpu_device *adev,
2630 struct si_power_info *si_pi = si_get_pi(adev);
2631 struct amdgpu_cac_leakage_table *table =
2632 &adev->pm.dpm.dyn_state.cac_leakage_table;
2642 for (i = 0; i < table->count; i++) {
2643 if (table->entries[i].vddc > *max)
2644 *max = table->entries[i].vddc;
2645 if (table->entries[i].vddc < *min)
2646 *min = table->entries[i].vddc;
2649 if (si_pi->powertune_data->lkge_lut_v0_percent > 100)
2652 v0_loadline = (*min) * (100 - si_pi->powertune_data->lkge_lut_v0_percent) / 100;
2654 if (v0_loadline > 0xFFFFUL)
2657 *min = (u16)v0_loadline;
2659 if ((*min > *max) || (*max == 0) || (*min == 0))
2665 static u16 si_get_cac_std_voltage_step(u16 max, u16 min)
2667 return ((max - min) + (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1)) /
2668 SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES;
2671 static int si_init_dte_leakage_table(struct amdgpu_device *adev,
2672 PP_SIslands_CacConfig *cac_tables,
2673 u16 vddc_max, u16 vddc_min, u16 vddc_step,
2676 struct si_power_info *si_pi = si_get_pi(adev);
2684 scaling_factor = si_get_smc_power_scaling_factor(adev);
2686 for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++) {
2687 t = (1000 * (i * t_step + t0));
2689 for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) {
2690 voltage = vddc_max - (vddc_step * j);
2692 si_calculate_leakage_for_v_and_t(adev,
2693 &si_pi->powertune_data->leakage_coefficients,
2696 si_pi->dyn_powertune_data.cac_leakage,
2699 smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4;
2701 if (smc_leakage > 0xFFFF)
2702 smc_leakage = 0xFFFF;
2704 cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] =
2705 cpu_to_be16((u16)smc_leakage);
2711 static int si_init_simplified_leakage_table(struct amdgpu_device *adev,
2712 PP_SIslands_CacConfig *cac_tables,
2713 u16 vddc_max, u16 vddc_min, u16 vddc_step)
2715 struct si_power_info *si_pi = si_get_pi(adev);
2722 scaling_factor = si_get_smc_power_scaling_factor(adev);
2724 for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) {
2725 voltage = vddc_max - (vddc_step * j);
2727 si_calculate_leakage_for_v(adev,
2728 &si_pi->powertune_data->leakage_coefficients,
2729 si_pi->powertune_data->fixed_kt,
2731 si_pi->dyn_powertune_data.cac_leakage,
2734 smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4;
2736 if (smc_leakage > 0xFFFF)
2737 smc_leakage = 0xFFFF;
2739 for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++)
2740 cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] =
2741 cpu_to_be16((u16)smc_leakage);
2746 static int si_initialize_smc_cac_tables(struct amdgpu_device *adev)
2748 struct ni_power_info *ni_pi = ni_get_pi(adev);
2749 struct si_power_info *si_pi = si_get_pi(adev);
2750 PP_SIslands_CacConfig *cac_tables = NULL;
2751 u16 vddc_max, vddc_min, vddc_step;
2753 u32 load_line_slope, reg;
2755 u32 ticks_per_us = amdgpu_asic_get_xclk(adev) / 100;
2757 if (ni_pi->enable_cac == false)
2760 cac_tables = kzalloc(sizeof(PP_SIslands_CacConfig), GFP_KERNEL);
2764 reg = RREG32(CG_CAC_CTRL) & ~CAC_WINDOW_MASK;
2765 reg |= CAC_WINDOW(si_pi->powertune_data->cac_window);
2766 WREG32(CG_CAC_CTRL, reg);
2768 si_pi->dyn_powertune_data.cac_leakage = adev->pm.dpm.cac_leakage;
2769 si_pi->dyn_powertune_data.dc_pwr_value =
2770 si_pi->powertune_data->dc_cac[NISLANDS_DCCAC_LEVEL_0];
2771 si_pi->dyn_powertune_data.wintime = si_calculate_cac_wintime(adev);
2772 si_pi->dyn_powertune_data.shift_n = si_pi->powertune_data->shift_n_default;
2774 si_pi->dyn_powertune_data.leakage_minimum_temperature = 80 * 1000;
2776 ret = si_get_cac_std_voltage_max_min(adev, &vddc_max, &vddc_min);
2780 vddc_step = si_get_cac_std_voltage_step(vddc_max, vddc_min);
2781 vddc_min = vddc_max - (vddc_step * (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1));
2785 if (si_pi->enable_dte || ni_pi->driver_calculate_cac_leakage)
2786 ret = si_init_dte_leakage_table(adev, cac_tables,
2787 vddc_max, vddc_min, vddc_step,
2790 ret = si_init_simplified_leakage_table(adev, cac_tables,
2791 vddc_max, vddc_min, vddc_step);
2795 load_line_slope = ((u32)adev->pm.dpm.load_line_slope << SMC_SISLANDS_SCALE_R) / 100;
2797 cac_tables->l2numWin_TDP = cpu_to_be32(si_pi->dyn_powertune_data.l2_lta_window_size);
2798 cac_tables->lts_truncate_n = si_pi->dyn_powertune_data.lts_truncate;
2799 cac_tables->SHIFT_N = si_pi->dyn_powertune_data.shift_n;
2800 cac_tables->lkge_lut_V0 = cpu_to_be32((u32)vddc_min);
2801 cac_tables->lkge_lut_Vstep = cpu_to_be32((u32)vddc_step);
2802 cac_tables->R_LL = cpu_to_be32(load_line_slope);
2803 cac_tables->WinTime = cpu_to_be32(si_pi->dyn_powertune_data.wintime);
2804 cac_tables->calculation_repeats = cpu_to_be32(2);
2805 cac_tables->dc_cac = cpu_to_be32(0);
2806 cac_tables->log2_PG_LKG_SCALE = 12;
2807 cac_tables->cac_temp = si_pi->powertune_data->operating_temp;
2808 cac_tables->lkge_lut_T0 = cpu_to_be32((u32)t0);
2809 cac_tables->lkge_lut_Tstep = cpu_to_be32((u32)t_step);
2811 ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->cac_table_start,
2813 sizeof(PP_SIslands_CacConfig),
2819 ret = si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_ticks_per_us, ticks_per_us);
2823 ni_pi->enable_cac = false;
2824 ni_pi->enable_power_containment = false;
2832 static int si_program_cac_config_registers(struct amdgpu_device *adev,
2833 const struct si_cac_config_reg *cac_config_regs)
2835 const struct si_cac_config_reg *config_regs = cac_config_regs;
2836 u32 data = 0, offset;
2841 while (config_regs->offset != 0xFFFFFFFF) {
2842 switch (config_regs->type) {
2843 case SISLANDS_CACCONFIG_CGIND:
2844 offset = SMC_CG_IND_START + config_regs->offset;
2845 if (offset < SMC_CG_IND_END)
2846 data = RREG32_SMC(offset);
2849 data = RREG32(config_regs->offset);
2853 data &= ~config_regs->mask;
2854 data |= ((config_regs->value << config_regs->shift) & config_regs->mask);
2856 switch (config_regs->type) {
2857 case SISLANDS_CACCONFIG_CGIND:
2858 offset = SMC_CG_IND_START + config_regs->offset;
2859 if (offset < SMC_CG_IND_END)
2860 WREG32_SMC(offset, data);
2863 WREG32(config_regs->offset, data);
2871 static int si_initialize_hardware_cac_manager(struct amdgpu_device *adev)
2873 struct ni_power_info *ni_pi = ni_get_pi(adev);
2874 struct si_power_info *si_pi = si_get_pi(adev);
2877 if ((ni_pi->enable_cac == false) ||
2878 (ni_pi->cac_configuration_required == false))
2881 ret = si_program_cac_config_registers(adev, si_pi->lcac_config);
2884 ret = si_program_cac_config_registers(adev, si_pi->cac_override);
2887 ret = si_program_cac_config_registers(adev, si_pi->cac_weights);
2894 static int si_enable_smc_cac(struct amdgpu_device *adev,
2895 struct amdgpu_ps *amdgpu_new_state,
2898 struct ni_power_info *ni_pi = ni_get_pi(adev);
2899 struct si_power_info *si_pi = si_get_pi(adev);
2900 PPSMC_Result smc_result;
2903 if (ni_pi->enable_cac) {
2905 if (!si_should_disable_uvd_powertune(adev, amdgpu_new_state)) {
2906 if (ni_pi->support_cac_long_term_average) {
2907 smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_CACLongTermAvgEnable);
2908 if (smc_result != PPSMC_Result_OK)
2909 ni_pi->support_cac_long_term_average = false;
2912 smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableCac);
2913 if (smc_result != PPSMC_Result_OK) {
2915 ni_pi->cac_enabled = false;
2917 ni_pi->cac_enabled = true;
2920 if (si_pi->enable_dte) {
2921 smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableDTE);
2922 if (smc_result != PPSMC_Result_OK)
2926 } else if (ni_pi->cac_enabled) {
2927 if (si_pi->enable_dte)
2928 smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableDTE);
2930 smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableCac);
2932 ni_pi->cac_enabled = false;
2934 if (ni_pi->support_cac_long_term_average)
2935 smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_CACLongTermAvgDisable);
2941 static int si_init_smc_spll_table(struct amdgpu_device *adev)
2943 struct ni_power_info *ni_pi = ni_get_pi(adev);
2944 struct si_power_info *si_pi = si_get_pi(adev);
2945 SMC_SISLANDS_SPLL_DIV_TABLE *spll_table;
2946 SISLANDS_SMC_SCLK_VALUE sclk_params;
2954 if (si_pi->spll_table_start == 0)
2957 spll_table = kzalloc(sizeof(SMC_SISLANDS_SPLL_DIV_TABLE), GFP_KERNEL);
2958 if (spll_table == NULL)
2961 for (i = 0; i < 256; i++) {
2962 ret = si_calculate_sclk_params(adev, sclk, &sclk_params);
2965 p_div = (sclk_params.vCG_SPLL_FUNC_CNTL & SPLL_PDIV_A_MASK) >> SPLL_PDIV_A_SHIFT;
2966 fb_div = (sclk_params.vCG_SPLL_FUNC_CNTL_3 & SPLL_FB_DIV_MASK) >> SPLL_FB_DIV_SHIFT;
2967 clk_s = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM & CLK_S_MASK) >> CLK_S_SHIFT;
2968 clk_v = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM_2 & CLK_V_MASK) >> CLK_V_SHIFT;
2970 fb_div &= ~0x00001FFF;
2974 if (p_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT))
2976 if (fb_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT))
2978 if (clk_s & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT))
2980 if (clk_v & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT))
2986 tmp = ((fb_div << SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK) |
2987 ((p_div << SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK);
2988 spll_table->freq[i] = cpu_to_be32(tmp);
2990 tmp = ((clk_v << SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK) |
2991 ((clk_s << SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK);
2992 spll_table->ss[i] = cpu_to_be32(tmp);
2999 ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->spll_table_start,
3001 sizeof(SMC_SISLANDS_SPLL_DIV_TABLE),
3005 ni_pi->enable_power_containment = false;
3012 struct si_dpm_quirk {
3021 /* cards with dpm stability problems */
3022 static struct si_dpm_quirk si_dpm_quirk_list[] = {
3023 /* PITCAIRN - https://bugs.freedesktop.org/show_bug.cgi?id=76490 */
3024 { PCI_VENDOR_ID_ATI, 0x6810, 0x1462, 0x3036, 0, 120000 },
3025 { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0xe271, 0, 120000 },
3026 { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0x2015, 0, 120000 },
3027 { PCI_VENDOR_ID_ATI, 0x6810, 0x174b, 0xe271, 85000, 90000 },
3028 { PCI_VENDOR_ID_ATI, 0x6811, 0x1462, 0x2015, 0, 120000 },
3029 { PCI_VENDOR_ID_ATI, 0x6811, 0x1043, 0x2015, 0, 120000 },
3030 { PCI_VENDOR_ID_ATI, 0x6811, 0x148c, 0x2015, 0, 120000 },
3031 { PCI_VENDOR_ID_ATI, 0x6810, 0x1682, 0x9275, 0, 120000 },
3035 static u16 si_get_lower_of_leakage_and_vce_voltage(struct amdgpu_device *adev,
3038 u16 highest_leakage = 0;
3039 struct si_power_info *si_pi = si_get_pi(adev);
3042 for (i = 0; i < si_pi->leakage_voltage.count; i++){
3043 if (highest_leakage < si_pi->leakage_voltage.entries[i].voltage)
3044 highest_leakage = si_pi->leakage_voltage.entries[i].voltage;
3047 if (si_pi->leakage_voltage.count && (highest_leakage < vce_voltage))
3048 return highest_leakage;
3053 static int si_get_vce_clock_voltage(struct amdgpu_device *adev,
3054 u32 evclk, u32 ecclk, u16 *voltage)
3058 struct amdgpu_vce_clock_voltage_dependency_table *table =
3059 &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;
3061 if (((evclk == 0) && (ecclk == 0)) ||
3062 (table && (table->count == 0))) {
3067 for (i = 0; i < table->count; i++) {
3068 if ((evclk <= table->entries[i].evclk) &&
3069 (ecclk <= table->entries[i].ecclk)) {
3070 *voltage = table->entries[i].v;
3076 /* if no match return the highest voltage */
3078 *voltage = table->entries[table->count - 1].v;
3080 *voltage = si_get_lower_of_leakage_and_vce_voltage(adev, *voltage);
3085 static bool si_dpm_vblank_too_short(struct amdgpu_device *adev)
3088 u32 vblank_time = amdgpu_dpm_get_vblank_time(adev);
3089 /* we never hit the non-gddr5 limit so disable it */
3090 u32 switch_limit = adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5 ? 450 : 0;
3092 if (vblank_time < switch_limit)
3099 static int ni_copy_and_switch_arb_sets(struct amdgpu_device *adev,
3100 u32 arb_freq_src, u32 arb_freq_dest)
3102 u32 mc_arb_dram_timing;
3103 u32 mc_arb_dram_timing2;
3107 switch (arb_freq_src) {
3108 case MC_CG_ARB_FREQ_F0:
3109 mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING);
3110 mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
3111 burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE0_MASK) >> STATE0_SHIFT;
3113 case MC_CG_ARB_FREQ_F1:
3114 mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_1);
3115 mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_1);
3116 burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE1_MASK) >> STATE1_SHIFT;
3118 case MC_CG_ARB_FREQ_F2:
3119 mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_2);
3120 mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_2);
3121 burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE2_MASK) >> STATE2_SHIFT;
3123 case MC_CG_ARB_FREQ_F3:
3124 mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_3);
3125 mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_3);
3126 burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE3_MASK) >> STATE3_SHIFT;
3132 switch (arb_freq_dest) {
3133 case MC_CG_ARB_FREQ_F0:
3134 WREG32(MC_ARB_DRAM_TIMING, mc_arb_dram_timing);
3135 WREG32(MC_ARB_DRAM_TIMING2, mc_arb_dram_timing2);
3136 WREG32_P(MC_ARB_BURST_TIME, STATE0(burst_time), ~STATE0_MASK);
3138 case MC_CG_ARB_FREQ_F1:
3139 WREG32(MC_ARB_DRAM_TIMING_1, mc_arb_dram_timing);
3140 WREG32(MC_ARB_DRAM_TIMING2_1, mc_arb_dram_timing2);
3141 WREG32_P(MC_ARB_BURST_TIME, STATE1(burst_time), ~STATE1_MASK);
3143 case MC_CG_ARB_FREQ_F2:
3144 WREG32(MC_ARB_DRAM_TIMING_2, mc_arb_dram_timing);
3145 WREG32(MC_ARB_DRAM_TIMING2_2, mc_arb_dram_timing2);
3146 WREG32_P(MC_ARB_BURST_TIME, STATE2(burst_time), ~STATE2_MASK);
3148 case MC_CG_ARB_FREQ_F3:
3149 WREG32(MC_ARB_DRAM_TIMING_3, mc_arb_dram_timing);
3150 WREG32(MC_ARB_DRAM_TIMING2_3, mc_arb_dram_timing2);
3151 WREG32_P(MC_ARB_BURST_TIME, STATE3(burst_time), ~STATE3_MASK);
3157 mc_cg_config = RREG32(MC_CG_CONFIG) | 0x0000000F;
3158 WREG32(MC_CG_CONFIG, mc_cg_config);
3159 WREG32_P(MC_ARB_CG, CG_ARB_REQ(arb_freq_dest), ~CG_ARB_REQ_MASK);
3164 static void ni_update_current_ps(struct amdgpu_device *adev,
3165 struct amdgpu_ps *rps)
3167 struct si_ps *new_ps = si_get_ps(rps);
3168 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
3169 struct ni_power_info *ni_pi = ni_get_pi(adev);
3171 eg_pi->current_rps = *rps;
3172 ni_pi->current_ps = *new_ps;
3173 eg_pi->current_rps.ps_priv = &ni_pi->current_ps;
3174 adev->pm.dpm.current_ps = &eg_pi->current_rps;
3177 static void ni_update_requested_ps(struct amdgpu_device *adev,
3178 struct amdgpu_ps *rps)
3180 struct si_ps *new_ps = si_get_ps(rps);
3181 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
3182 struct ni_power_info *ni_pi = ni_get_pi(adev);
3184 eg_pi->requested_rps = *rps;
3185 ni_pi->requested_ps = *new_ps;
3186 eg_pi->requested_rps.ps_priv = &ni_pi->requested_ps;
3187 adev->pm.dpm.requested_ps = &eg_pi->requested_rps;
3190 static void ni_set_uvd_clock_before_set_eng_clock(struct amdgpu_device *adev,
3191 struct amdgpu_ps *new_ps,
3192 struct amdgpu_ps *old_ps)
3194 struct si_ps *new_state = si_get_ps(new_ps);
3195 struct si_ps *current_state = si_get_ps(old_ps);
3197 if ((new_ps->vclk == old_ps->vclk) &&
3198 (new_ps->dclk == old_ps->dclk))
3201 if (new_state->performance_levels[new_state->performance_level_count - 1].sclk >=
3202 current_state->performance_levels[current_state->performance_level_count - 1].sclk)
3205 amdgpu_asic_set_uvd_clocks(adev, new_ps->vclk, new_ps->dclk);
3208 static void ni_set_uvd_clock_after_set_eng_clock(struct amdgpu_device *adev,
3209 struct amdgpu_ps *new_ps,
3210 struct amdgpu_ps *old_ps)
3212 struct si_ps *new_state = si_get_ps(new_ps);
3213 struct si_ps *current_state = si_get_ps(old_ps);
3215 if ((new_ps->vclk == old_ps->vclk) &&
3216 (new_ps->dclk == old_ps->dclk))
3219 if (new_state->performance_levels[new_state->performance_level_count - 1].sclk <
3220 current_state->performance_levels[current_state->performance_level_count - 1].sclk)
3223 amdgpu_asic_set_uvd_clocks(adev, new_ps->vclk, new_ps->dclk);
3226 static u16 btc_find_voltage(struct atom_voltage_table *table, u16 voltage)
3230 for (i = 0; i < table->count; i++)
3231 if (voltage <= table->entries[i].value)
3232 return table->entries[i].value;
3234 return table->entries[table->count - 1].value;
3237 static u32 btc_find_valid_clock(struct amdgpu_clock_array *clocks,
3238 u32 max_clock, u32 requested_clock)
3242 if ((clocks == NULL) || (clocks->count == 0))
3243 return (requested_clock < max_clock) ? requested_clock : max_clock;
3245 for (i = 0; i < clocks->count; i++) {
3246 if (clocks->values[i] >= requested_clock)
3247 return (clocks->values[i] < max_clock) ? clocks->values[i] : max_clock;
3250 return (clocks->values[clocks->count - 1] < max_clock) ?
3251 clocks->values[clocks->count - 1] : max_clock;
3254 static u32 btc_get_valid_mclk(struct amdgpu_device *adev,
3255 u32 max_mclk, u32 requested_mclk)
3257 return btc_find_valid_clock(&adev->pm.dpm.dyn_state.valid_mclk_values,
3258 max_mclk, requested_mclk);
3261 static u32 btc_get_valid_sclk(struct amdgpu_device *adev,
3262 u32 max_sclk, u32 requested_sclk)
3264 return btc_find_valid_clock(&adev->pm.dpm.dyn_state.valid_sclk_values,
3265 max_sclk, requested_sclk);
3268 static void btc_get_max_clock_from_voltage_dependency_table(struct amdgpu_clock_voltage_dependency_table *table,
3273 if ((table == NULL) || (table->count == 0)) {
3278 for (i = 0; i < table->count; i++) {
3279 if (clock < table->entries[i].clk)
3280 clock = table->entries[i].clk;
3285 static void btc_apply_voltage_dependency_rules(struct amdgpu_clock_voltage_dependency_table *table,
3286 u32 clock, u16 max_voltage, u16 *voltage)
3290 if ((table == NULL) || (table->count == 0))
3293 for (i= 0; i < table->count; i++) {
3294 if (clock <= table->entries[i].clk) {
3295 if (*voltage < table->entries[i].v)
3296 *voltage = (u16)((table->entries[i].v < max_voltage) ?
3297 table->entries[i].v : max_voltage);
3302 *voltage = (*voltage > max_voltage) ? *voltage : max_voltage;
3305 static void btc_adjust_clock_combinations(struct amdgpu_device *adev,
3306 const struct amdgpu_clock_and_voltage_limits *max_limits,
3307 struct rv7xx_pl *pl)
3310 if ((pl->mclk == 0) || (pl->sclk == 0))
3313 if (pl->mclk == pl->sclk)
3316 if (pl->mclk > pl->sclk) {
3317 if (((pl->mclk + (pl->sclk - 1)) / pl->sclk) > adev->pm.dpm.dyn_state.mclk_sclk_ratio)
3318 pl->sclk = btc_get_valid_sclk(adev,
3321 (adev->pm.dpm.dyn_state.mclk_sclk_ratio - 1)) /
3322 adev->pm.dpm.dyn_state.mclk_sclk_ratio);
3324 if ((pl->sclk - pl->mclk) > adev->pm.dpm.dyn_state.sclk_mclk_delta)
3325 pl->mclk = btc_get_valid_mclk(adev,
3328 adev->pm.dpm.dyn_state.sclk_mclk_delta);
3332 static void btc_apply_voltage_delta_rules(struct amdgpu_device *adev,
3333 u16 max_vddc, u16 max_vddci,
3334 u16 *vddc, u16 *vddci)
3336 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
3339 if ((0 == *vddc) || (0 == *vddci))
3342 if (*vddc > *vddci) {
3343 if ((*vddc - *vddci) > adev->pm.dpm.dyn_state.vddc_vddci_delta) {
3344 new_voltage = btc_find_voltage(&eg_pi->vddci_voltage_table,
3345 (*vddc - adev->pm.dpm.dyn_state.vddc_vddci_delta));
3346 *vddci = (new_voltage < max_vddci) ? new_voltage : max_vddci;
3349 if ((*vddci - *vddc) > adev->pm.dpm.dyn_state.vddc_vddci_delta) {
3350 new_voltage = btc_find_voltage(&eg_pi->vddc_voltage_table,
3351 (*vddci - adev->pm.dpm.dyn_state.vddc_vddci_delta));
3352 *vddc = (new_voltage < max_vddc) ? new_voltage : max_vddc;
3357 static enum amdgpu_pcie_gen r600_get_pcie_gen_support(struct amdgpu_device *adev,
3359 enum amdgpu_pcie_gen asic_gen,
3360 enum amdgpu_pcie_gen default_gen)
3363 case AMDGPU_PCIE_GEN1:
3364 return AMDGPU_PCIE_GEN1;
3365 case AMDGPU_PCIE_GEN2:
3366 return AMDGPU_PCIE_GEN2;
3367 case AMDGPU_PCIE_GEN3:
3368 return AMDGPU_PCIE_GEN3;
3370 if ((sys_mask & DRM_PCIE_SPEED_80) && (default_gen == AMDGPU_PCIE_GEN3))
3371 return AMDGPU_PCIE_GEN3;
3372 else if ((sys_mask & DRM_PCIE_SPEED_50) && (default_gen == AMDGPU_PCIE_GEN2))
3373 return AMDGPU_PCIE_GEN2;
3375 return AMDGPU_PCIE_GEN1;
3377 return AMDGPU_PCIE_GEN1;
3380 static void r600_calculate_u_and_p(u32 i, u32 r_c, u32 p_b,
3387 i_c = (i * r_c) / 100;
3396 *p = i_c / (1 << (2 * (*u)));
3399 static int r600_calculate_at(u32 t, u32 h, u32 fh, u32 fl, u32 *tl, u32 *th)
3404 if ((fl == 0) || (fh == 0) || (fl > fh))
3407 k = (100 * fh) / fl;
3408 t1 = (t * (k - 100));
3409 a = (1000 * (100 * h + t1)) / (10000 + (t1 / 100));
3411 ah = ((a * t) + 5000) / 10000;
3420 static bool r600_is_uvd_state(u32 class, u32 class2)
3422 if (class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE)
3424 if (class & ATOM_PPLIB_CLASSIFICATION_HD2STATE)
3426 if (class & ATOM_PPLIB_CLASSIFICATION_HDSTATE)
3428 if (class & ATOM_PPLIB_CLASSIFICATION_SDSTATE)
3430 if (class2 & ATOM_PPLIB_CLASSIFICATION2_MVC)
3435 static u8 rv770_get_memory_module_index(struct amdgpu_device *adev)
3437 return (u8) ((RREG32(BIOS_SCRATCH_4) >> 16) & 0xff);
3440 static void rv770_get_max_vddc(struct amdgpu_device *adev)
3442 struct rv7xx_power_info *pi = rv770_get_pi(adev);
3445 if (amdgpu_atombios_get_max_vddc(adev, 0, 0, &vddc))
3448 pi->max_vddc = vddc;
3451 static void rv770_get_engine_memory_ss(struct amdgpu_device *adev)
3453 struct rv7xx_power_info *pi = rv770_get_pi(adev);
3454 struct amdgpu_atom_ss ss;
3456 pi->sclk_ss = amdgpu_atombios_get_asic_ss_info(adev, &ss,
3457 ASIC_INTERNAL_ENGINE_SS, 0);
3458 pi->mclk_ss = amdgpu_atombios_get_asic_ss_info(adev, &ss,
3459 ASIC_INTERNAL_MEMORY_SS, 0);
3461 if (pi->sclk_ss || pi->mclk_ss)
3462 pi->dynamic_ss = true;
3464 pi->dynamic_ss = false;
3468 static void si_apply_state_adjust_rules(struct amdgpu_device *adev,
3469 struct amdgpu_ps *rps)
3471 struct si_ps *ps = si_get_ps(rps);
3472 struct amdgpu_clock_and_voltage_limits *max_limits;
3473 bool disable_mclk_switching = false;
3474 bool disable_sclk_switching = false;
3476 u16 vddc, vddci, min_vce_voltage = 0;
3477 u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;
3478 u32 max_sclk = 0, max_mclk = 0;
3480 struct si_dpm_quirk *p = si_dpm_quirk_list;
3482 /* limit all SI kickers */
3483 if (adev->asic_type == CHIP_PITCAIRN) {
3484 if ((adev->pdev->revision == 0x81) ||
3485 (adev->pdev->device == 0x6810) ||
3486 (adev->pdev->device == 0x6811) ||
3487 (adev->pdev->device == 0x6816) ||
3488 (adev->pdev->device == 0x6817) ||
3489 (adev->pdev->device == 0x6806))
3491 } else if (adev->asic_type == CHIP_VERDE) {
3492 if ((adev->pdev->revision == 0x81) ||
3493 (adev->pdev->revision == 0x83) ||
3494 (adev->pdev->revision == 0x87) ||
3495 (adev->pdev->device == 0x6820) ||
3496 (adev->pdev->device == 0x6821) ||
3497 (adev->pdev->device == 0x6822) ||
3498 (adev->pdev->device == 0x6823) ||
3499 (adev->pdev->device == 0x682A) ||
3500 (adev->pdev->device == 0x682B)) {
3504 } else if (adev->asic_type == CHIP_OLAND) {
3505 if ((adev->pdev->revision == 0xC7) ||
3506 (adev->pdev->revision == 0x80) ||
3507 (adev->pdev->revision == 0x81) ||
3508 (adev->pdev->revision == 0x83) ||
3509 (adev->pdev->revision == 0x87) ||
3510 (adev->pdev->device == 0x6604) ||
3511 (adev->pdev->device == 0x6605)) {
3515 } else if (adev->asic_type == CHIP_HAINAN) {
3516 if ((adev->pdev->revision == 0x81) ||
3517 (adev->pdev->revision == 0x83) ||
3518 (adev->pdev->revision == 0xC3) ||
3519 (adev->pdev->device == 0x6664) ||
3520 (adev->pdev->device == 0x6665) ||
3521 (adev->pdev->device == 0x6667)) {
3526 /* Apply dpm quirks */
3527 while (p && p->chip_device != 0) {
3528 if (adev->pdev->vendor == p->chip_vendor &&
3529 adev->pdev->device == p->chip_device &&
3530 adev->pdev->subsystem_vendor == p->subsys_vendor &&
3531 adev->pdev->subsystem_device == p->subsys_device) {
3532 max_sclk = p->max_sclk;
3533 max_mclk = p->max_mclk;
3539 if (rps->vce_active) {
3540 rps->evclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].evclk;
3541 rps->ecclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].ecclk;
3542 si_get_vce_clock_voltage(adev, rps->evclk, rps->ecclk,
3549 if ((adev->pm.dpm.new_active_crtc_count > 1) ||
3550 si_dpm_vblank_too_short(adev))
3551 disable_mclk_switching = true;
3553 if (rps->vclk || rps->dclk) {
3554 disable_mclk_switching = true;
3555 disable_sclk_switching = true;
3558 if (adev->pm.dpm.ac_power)
3559 max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
3561 max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc;
3563 for (i = ps->performance_level_count - 2; i >= 0; i--) {
3564 if (ps->performance_levels[i].vddc > ps->performance_levels[i+1].vddc)
3565 ps->performance_levels[i].vddc = ps->performance_levels[i+1].vddc;
3567 if (adev->pm.dpm.ac_power == false) {
3568 for (i = 0; i < ps->performance_level_count; i++) {
3569 if (ps->performance_levels[i].mclk > max_limits->mclk)
3570 ps->performance_levels[i].mclk = max_limits->mclk;
3571 if (ps->performance_levels[i].sclk > max_limits->sclk)
3572 ps->performance_levels[i].sclk = max_limits->sclk;
3573 if (ps->performance_levels[i].vddc > max_limits->vddc)
3574 ps->performance_levels[i].vddc = max_limits->vddc;
3575 if (ps->performance_levels[i].vddci > max_limits->vddci)
3576 ps->performance_levels[i].vddci = max_limits->vddci;
3580 /* limit clocks to max supported clocks based on voltage dependency tables */
3581 btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
3583 btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
3585 btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
3588 for (i = 0; i < ps->performance_level_count; i++) {
3589 if (max_sclk_vddc) {
3590 if (ps->performance_levels[i].sclk > max_sclk_vddc)
3591 ps->performance_levels[i].sclk = max_sclk_vddc;
3593 if (max_mclk_vddci) {
3594 if (ps->performance_levels[i].mclk > max_mclk_vddci)
3595 ps->performance_levels[i].mclk = max_mclk_vddci;
3597 if (max_mclk_vddc) {
3598 if (ps->performance_levels[i].mclk > max_mclk_vddc)
3599 ps->performance_levels[i].mclk = max_mclk_vddc;
3602 if (ps->performance_levels[i].mclk > max_mclk)
3603 ps->performance_levels[i].mclk = max_mclk;
3606 if (ps->performance_levels[i].sclk > max_sclk)
3607 ps->performance_levels[i].sclk = max_sclk;
3611 /* XXX validate the min clocks required for display */
3613 if (disable_mclk_switching) {
3614 mclk = ps->performance_levels[ps->performance_level_count - 1].mclk;
3615 vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
3617 mclk = ps->performance_levels[0].mclk;
3618 vddci = ps->performance_levels[0].vddci;
3621 if (disable_sclk_switching) {
3622 sclk = ps->performance_levels[ps->performance_level_count - 1].sclk;
3623 vddc = ps->performance_levels[ps->performance_level_count - 1].vddc;
3625 sclk = ps->performance_levels[0].sclk;
3626 vddc = ps->performance_levels[0].vddc;
3629 if (rps->vce_active) {
3630 if (sclk < adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].sclk)
3631 sclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].sclk;
3632 if (mclk < adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].mclk)
3633 mclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].mclk;
3636 /* adjusted low state */
3637 ps->performance_levels[0].sclk = sclk;
3638 ps->performance_levels[0].mclk = mclk;
3639 ps->performance_levels[0].vddc = vddc;
3640 ps->performance_levels[0].vddci = vddci;
3642 if (disable_sclk_switching) {
3643 sclk = ps->performance_levels[0].sclk;
3644 for (i = 1; i < ps->performance_level_count; i++) {
3645 if (sclk < ps->performance_levels[i].sclk)
3646 sclk = ps->performance_levels[i].sclk;
3648 for (i = 0; i < ps->performance_level_count; i++) {
3649 ps->performance_levels[i].sclk = sclk;
3650 ps->performance_levels[i].vddc = vddc;
3653 for (i = 1; i < ps->performance_level_count; i++) {
3654 if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk)
3655 ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk;
3656 if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc)
3657 ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
3661 if (disable_mclk_switching) {
3662 mclk = ps->performance_levels[0].mclk;
3663 for (i = 1; i < ps->performance_level_count; i++) {
3664 if (mclk < ps->performance_levels[i].mclk)
3665 mclk = ps->performance_levels[i].mclk;
3667 for (i = 0; i < ps->performance_level_count; i++) {
3668 ps->performance_levels[i].mclk = mclk;
3669 ps->performance_levels[i].vddci = vddci;
3672 for (i = 1; i < ps->performance_level_count; i++) {
3673 if (ps->performance_levels[i].mclk < ps->performance_levels[i - 1].mclk)
3674 ps->performance_levels[i].mclk = ps->performance_levels[i - 1].mclk;
3675 if (ps->performance_levels[i].vddci < ps->performance_levels[i - 1].vddci)
3676 ps->performance_levels[i].vddci = ps->performance_levels[i - 1].vddci;
3680 for (i = 0; i < ps->performance_level_count; i++)
3681 btc_adjust_clock_combinations(adev, max_limits,
3682 &ps->performance_levels[i]);
3684 for (i = 0; i < ps->performance_level_count; i++) {
3685 if (ps->performance_levels[i].vddc < min_vce_voltage)
3686 ps->performance_levels[i].vddc = min_vce_voltage;
3687 btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
3688 ps->performance_levels[i].sclk,
3689 max_limits->vddc, &ps->performance_levels[i].vddc);
3690 btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
3691 ps->performance_levels[i].mclk,
3692 max_limits->vddci, &ps->performance_levels[i].vddci);
3693 btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
3694 ps->performance_levels[i].mclk,
3695 max_limits->vddc, &ps->performance_levels[i].vddc);
3696 btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
3697 adev->clock.current_dispclk,
3698 max_limits->vddc, &ps->performance_levels[i].vddc);
3701 for (i = 0; i < ps->performance_level_count; i++) {
3702 btc_apply_voltage_delta_rules(adev,
3703 max_limits->vddc, max_limits->vddci,
3704 &ps->performance_levels[i].vddc,
3705 &ps->performance_levels[i].vddci);
3708 ps->dc_compatible = true;
3709 for (i = 0; i < ps->performance_level_count; i++) {
3710 if (ps->performance_levels[i].vddc > adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc)
3711 ps->dc_compatible = false;
3716 static int si_read_smc_soft_register(struct amdgpu_device *adev,
3717 u16 reg_offset, u32 *value)
3719 struct si_power_info *si_pi = si_get_pi(adev);
3721 return amdgpu_si_read_smc_sram_dword(adev,
3722 si_pi->soft_regs_start + reg_offset, value,
3727 static int si_write_smc_soft_register(struct amdgpu_device *adev,
3728 u16 reg_offset, u32 value)
3730 struct si_power_info *si_pi = si_get_pi(adev);
3732 return amdgpu_si_write_smc_sram_dword(adev,
3733 si_pi->soft_regs_start + reg_offset,
3734 value, si_pi->sram_end);
3737 static bool si_is_special_1gb_platform(struct amdgpu_device *adev)
3740 u32 tmp, width, row, column, bank, density;
3741 bool is_memory_gddr5, is_special;
3743 tmp = RREG32(MC_SEQ_MISC0);
3744 is_memory_gddr5 = (MC_SEQ_MISC0_GDDR5_VALUE == ((tmp & MC_SEQ_MISC0_GDDR5_MASK) >> MC_SEQ_MISC0_GDDR5_SHIFT));
3745 is_special = (MC_SEQ_MISC0_REV_ID_VALUE == ((tmp & MC_SEQ_MISC0_REV_ID_MASK) >> MC_SEQ_MISC0_REV_ID_SHIFT))
3746 & (MC_SEQ_MISC0_VEN_ID_VALUE == ((tmp & MC_SEQ_MISC0_VEN_ID_MASK) >> MC_SEQ_MISC0_VEN_ID_SHIFT));
3748 WREG32(MC_SEQ_IO_DEBUG_INDEX, 0xb);
3749 width = ((RREG32(MC_SEQ_IO_DEBUG_DATA) >> 1) & 1) ? 16 : 32;
3751 tmp = RREG32(MC_ARB_RAMCFG);
3752 row = ((tmp & NOOFROWS_MASK) >> NOOFROWS_SHIFT) + 10;
3753 column = ((tmp & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT) + 8;
3754 bank = ((tmp & NOOFBANK_MASK) >> NOOFBANK_SHIFT) + 2;
3756 density = (1 << (row + column - 20 + bank)) * width;
3758 if ((adev->pdev->device == 0x6819) &&
3759 is_memory_gddr5 && is_special && (density == 0x400))
3765 static void si_get_leakage_vddc(struct amdgpu_device *adev)
3767 struct si_power_info *si_pi = si_get_pi(adev);
3768 u16 vddc, count = 0;
3771 for (i = 0; i < SISLANDS_MAX_LEAKAGE_COUNT; i++) {
3772 ret = amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(adev, &vddc, SISLANDS_LEAKAGE_INDEX0 + i);
3774 if (!ret && (vddc > 0) && (vddc != (SISLANDS_LEAKAGE_INDEX0 + i))) {
3775 si_pi->leakage_voltage.entries[count].voltage = vddc;
3776 si_pi->leakage_voltage.entries[count].leakage_index =
3777 SISLANDS_LEAKAGE_INDEX0 + i;
3781 si_pi->leakage_voltage.count = count;
3784 static int si_get_leakage_voltage_from_leakage_index(struct amdgpu_device *adev,
3785 u32 index, u16 *leakage_voltage)
3787 struct si_power_info *si_pi = si_get_pi(adev);
3790 if (leakage_voltage == NULL)
3793 if ((index & 0xff00) != 0xff00)
3796 if ((index & 0xff) > SISLANDS_MAX_LEAKAGE_COUNT + 1)
3799 if (index < SISLANDS_LEAKAGE_INDEX0)
3802 for (i = 0; i < si_pi->leakage_voltage.count; i++) {
3803 if (si_pi->leakage_voltage.entries[i].leakage_index == index) {
3804 *leakage_voltage = si_pi->leakage_voltage.entries[i].voltage;
3811 static void si_set_dpm_event_sources(struct amdgpu_device *adev, u32 sources)
3813 struct rv7xx_power_info *pi = rv770_get_pi(adev);
3814 bool want_thermal_protection;
3815 enum amdgpu_dpm_event_src dpm_event_src;
3820 want_thermal_protection = false;
3822 case (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL):
3823 want_thermal_protection = true;
3824 dpm_event_src = AMDGPU_DPM_EVENT_SRC_DIGITAL;
3826 case (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL):
3827 want_thermal_protection = true;
3828 dpm_event_src = AMDGPU_DPM_EVENT_SRC_EXTERNAL;
3830 case ((1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL) |
3831 (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL)):
3832 want_thermal_protection = true;
3833 dpm_event_src = AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL;
3837 if (want_thermal_protection) {
3838 WREG32_P(CG_THERMAL_CTRL, DPM_EVENT_SRC(dpm_event_src), ~DPM_EVENT_SRC_MASK);
3839 if (pi->thermal_protection)
3840 WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS);
3842 WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS);
3846 static void si_enable_auto_throttle_source(struct amdgpu_device *adev,
3847 enum amdgpu_dpm_auto_throttle_src source,
3850 struct rv7xx_power_info *pi = rv770_get_pi(adev);
3853 if (!(pi->active_auto_throttle_sources & (1 << source))) {
3854 pi->active_auto_throttle_sources |= 1 << source;
3855 si_set_dpm_event_sources(adev, pi->active_auto_throttle_sources);
3858 if (pi->active_auto_throttle_sources & (1 << source)) {
3859 pi->active_auto_throttle_sources &= ~(1 << source);
3860 si_set_dpm_event_sources(adev, pi->active_auto_throttle_sources);
3865 static void si_start_dpm(struct amdgpu_device *adev)
3867 WREG32_P(GENERAL_PWRMGT, GLOBAL_PWRMGT_EN, ~GLOBAL_PWRMGT_EN);
3870 static void si_stop_dpm(struct amdgpu_device *adev)
3872 WREG32_P(GENERAL_PWRMGT, 0, ~GLOBAL_PWRMGT_EN);
3875 static void si_enable_sclk_control(struct amdgpu_device *adev, bool enable)
3878 WREG32_P(SCLK_PWRMGT_CNTL, 0, ~SCLK_PWRMGT_OFF);
3880 WREG32_P(SCLK_PWRMGT_CNTL, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF);
3885 static int si_notify_hardware_of_thermal_state(struct amdgpu_device *adev,
3890 if (thermal_level == 0) {
3891 ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableThermalInterrupt);
3892 if (ret == PPSMC_Result_OK)
3900 static void si_notify_hardware_vpu_recovery_event(struct amdgpu_device *adev)
3902 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen, true);
3907 static int si_notify_hw_of_powersource(struct amdgpu_device *adev, bool ac_power)
3910 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_RunningOnAC) == PPSMC_Result_OK) ?
3917 static PPSMC_Result si_send_msg_to_smc_with_parameter(struct amdgpu_device *adev,
3918 PPSMC_Msg msg, u32 parameter)
3920 WREG32(SMC_SCRATCH0, parameter);
3921 return amdgpu_si_send_msg_to_smc(adev, msg);
3924 static int si_restrict_performance_levels_before_switch(struct amdgpu_device *adev)
3926 if (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_NoForcedLevel) != PPSMC_Result_OK)
3929 return (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, 1) == PPSMC_Result_OK) ?
3933 static int si_dpm_force_performance_level(struct amdgpu_device *adev,
3934 enum amdgpu_dpm_forced_level level)
3936 struct amdgpu_ps *rps = adev->pm.dpm.current_ps;
3937 struct si_ps *ps = si_get_ps(rps);
3938 u32 levels = ps->performance_level_count;
3940 if (level == AMDGPU_DPM_FORCED_LEVEL_HIGH) {
3941 if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
3944 if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 1) != PPSMC_Result_OK)
3946 } else if (level == AMDGPU_DPM_FORCED_LEVEL_LOW) {
3947 if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
3950 if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, 1) != PPSMC_Result_OK)
3952 } else if (level == AMDGPU_DPM_FORCED_LEVEL_AUTO) {
3953 if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
3956 if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
3960 adev->pm.dpm.forced_level = level;
3966 static int si_set_boot_state(struct amdgpu_device *adev)
3968 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_SwitchToInitialState) == PPSMC_Result_OK) ?
3973 static int si_set_sw_state(struct amdgpu_device *adev)
3975 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_SwitchToSwState) == PPSMC_Result_OK) ?
3979 static int si_halt_smc(struct amdgpu_device *adev)
3981 if (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_Halt) != PPSMC_Result_OK)
3984 return (amdgpu_si_wait_for_smc_inactive(adev) == PPSMC_Result_OK) ?
3988 static int si_resume_smc(struct amdgpu_device *adev)
3990 if (amdgpu_si_send_msg_to_smc(adev, PPSMC_FlushDataCache) != PPSMC_Result_OK)
3993 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_Resume) == PPSMC_Result_OK) ?
3997 static void si_dpm_start_smc(struct amdgpu_device *adev)
3999 amdgpu_si_program_jump_on_start(adev);
4000 amdgpu_si_start_smc(adev);
4001 amdgpu_si_smc_clock(adev, true);
4004 static void si_dpm_stop_smc(struct amdgpu_device *adev)
4006 amdgpu_si_reset_smc(adev);
4007 amdgpu_si_smc_clock(adev, false);
4010 static int si_process_firmware_header(struct amdgpu_device *adev)
4012 struct si_power_info *si_pi = si_get_pi(adev);
4016 ret = amdgpu_si_read_smc_sram_dword(adev,
4017 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4018 SISLANDS_SMC_FIRMWARE_HEADER_stateTable,
4019 &tmp, si_pi->sram_end);
4023 si_pi->state_table_start = tmp;
4025 ret = amdgpu_si_read_smc_sram_dword(adev,
4026 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4027 SISLANDS_SMC_FIRMWARE_HEADER_softRegisters,
4028 &tmp, si_pi->sram_end);
4032 si_pi->soft_regs_start = tmp;
4034 ret = amdgpu_si_read_smc_sram_dword(adev,
4035 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4036 SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable,
4037 &tmp, si_pi->sram_end);
4041 si_pi->mc_reg_table_start = tmp;
4043 ret = amdgpu_si_read_smc_sram_dword(adev,
4044 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4045 SISLANDS_SMC_FIRMWARE_HEADER_fanTable,
4046 &tmp, si_pi->sram_end);
4050 si_pi->fan_table_start = tmp;
4052 ret = amdgpu_si_read_smc_sram_dword(adev,
4053 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4054 SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable,
4055 &tmp, si_pi->sram_end);
4059 si_pi->arb_table_start = tmp;
4061 ret = amdgpu_si_read_smc_sram_dword(adev,
4062 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4063 SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable,
4064 &tmp, si_pi->sram_end);
4068 si_pi->cac_table_start = tmp;
4070 ret = amdgpu_si_read_smc_sram_dword(adev,
4071 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4072 SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration,
4073 &tmp, si_pi->sram_end);
4077 si_pi->dte_table_start = tmp;
4079 ret = amdgpu_si_read_smc_sram_dword(adev,
4080 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4081 SISLANDS_SMC_FIRMWARE_HEADER_spllTable,
4082 &tmp, si_pi->sram_end);
4086 si_pi->spll_table_start = tmp;
4088 ret = amdgpu_si_read_smc_sram_dword(adev,
4089 SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4090 SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters,
4091 &tmp, si_pi->sram_end);
4095 si_pi->papm_cfg_table_start = tmp;
4100 static void si_read_clock_registers(struct amdgpu_device *adev)
4102 struct si_power_info *si_pi = si_get_pi(adev);
4104 si_pi->clock_registers.cg_spll_func_cntl = RREG32(CG_SPLL_FUNC_CNTL);
4105 si_pi->clock_registers.cg_spll_func_cntl_2 = RREG32(CG_SPLL_FUNC_CNTL_2);
4106 si_pi->clock_registers.cg_spll_func_cntl_3 = RREG32(CG_SPLL_FUNC_CNTL_3);
4107 si_pi->clock_registers.cg_spll_func_cntl_4 = RREG32(CG_SPLL_FUNC_CNTL_4);
4108 si_pi->clock_registers.cg_spll_spread_spectrum = RREG32(CG_SPLL_SPREAD_SPECTRUM);
4109 si_pi->clock_registers.cg_spll_spread_spectrum_2 = RREG32(CG_SPLL_SPREAD_SPECTRUM_2);
4110 si_pi->clock_registers.dll_cntl = RREG32(DLL_CNTL);
4111 si_pi->clock_registers.mclk_pwrmgt_cntl = RREG32(MCLK_PWRMGT_CNTL);
4112 si_pi->clock_registers.mpll_ad_func_cntl = RREG32(MPLL_AD_FUNC_CNTL);
4113 si_pi->clock_registers.mpll_dq_func_cntl = RREG32(MPLL_DQ_FUNC_CNTL);
4114 si_pi->clock_registers.mpll_func_cntl = RREG32(MPLL_FUNC_CNTL);
4115 si_pi->clock_registers.mpll_func_cntl_1 = RREG32(MPLL_FUNC_CNTL_1);
4116 si_pi->clock_registers.mpll_func_cntl_2 = RREG32(MPLL_FUNC_CNTL_2);
4117 si_pi->clock_registers.mpll_ss1 = RREG32(MPLL_SS1);
4118 si_pi->clock_registers.mpll_ss2 = RREG32(MPLL_SS2);
4121 static void si_enable_thermal_protection(struct amdgpu_device *adev,
4125 WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS);
4127 WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS);
4130 static void si_enable_acpi_power_management(struct amdgpu_device *adev)
4132 WREG32_P(GENERAL_PWRMGT, STATIC_PM_EN, ~STATIC_PM_EN);
4136 static int si_enter_ulp_state(struct amdgpu_device *adev)
4138 WREG32(SMC_MESSAGE_0, PPSMC_MSG_SwitchToMinimumPower);
4145 static int si_exit_ulp_state(struct amdgpu_device *adev)
4149 WREG32(SMC_MESSAGE_0, PPSMC_MSG_ResumeFromMinimumPower);
4153 for (i = 0; i < adev->usec_timeout; i++) {
4154 if (RREG32(SMC_RESP_0) == 1)
4163 static int si_notify_smc_display_change(struct amdgpu_device *adev,
4166 PPSMC_Msg msg = has_display ?
4167 PPSMC_MSG_HasDisplay : PPSMC_MSG_NoDisplay;
4169 return (amdgpu_si_send_msg_to_smc(adev, msg) == PPSMC_Result_OK) ?
4173 static void si_program_response_times(struct amdgpu_device *adev)
4175 u32 voltage_response_time, backbias_response_time, acpi_delay_time, vbi_time_out;
4176 u32 vddc_dly, acpi_dly, vbi_dly;
4177 u32 reference_clock;
4179 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mvdd_chg_time, 1);
4181 voltage_response_time = (u32)adev->pm.dpm.voltage_response_time;
4182 backbias_response_time = (u32)adev->pm.dpm.backbias_response_time;
4184 if (voltage_response_time == 0)
4185 voltage_response_time = 1000;
4187 acpi_delay_time = 15000;
4188 vbi_time_out = 100000;
4190 reference_clock = amdgpu_asic_get_xclk(adev);
4192 vddc_dly = (voltage_response_time * reference_clock) / 100;
4193 acpi_dly = (acpi_delay_time * reference_clock) / 100;
4194 vbi_dly = (vbi_time_out * reference_clock) / 100;
4196 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_delay_vreg, vddc_dly);
4197 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_delay_acpi, acpi_dly);
4198 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mclk_chg_timeout, vbi_dly);
4199 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mc_block_delay, 0xAA);
4202 static void si_program_ds_registers(struct amdgpu_device *adev)
4204 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4207 /* DEEP_SLEEP_CLK_SEL field should be 0x10 on tahiti A0 */
4208 if (adev->asic_type == CHIP_TAHITI && adev->rev_id == 0x0)
4213 if (eg_pi->sclk_deep_sleep) {
4214 WREG32_P(MISC_CLK_CNTL, DEEP_SLEEP_CLK_SEL(tmp), ~DEEP_SLEEP_CLK_SEL_MASK);
4215 WREG32_P(CG_SPLL_AUTOSCALE_CNTL, AUTOSCALE_ON_SS_CLEAR,
4216 ~AUTOSCALE_ON_SS_CLEAR);
4220 static void si_program_display_gap(struct amdgpu_device *adev)
4225 tmp = RREG32(CG_DISPLAY_GAP_CNTL) & ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
4226 if (adev->pm.dpm.new_active_crtc_count > 0)
4227 tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM);
4229 tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE);
4231 if (adev->pm.dpm.new_active_crtc_count > 1)
4232 tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM);
4234 tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE);
4236 WREG32(CG_DISPLAY_GAP_CNTL, tmp);
4238 tmp = RREG32(DCCG_DISP_SLOW_SELECT_REG);
4239 pipe = (tmp & DCCG_DISP1_SLOW_SELECT_MASK) >> DCCG_DISP1_SLOW_SELECT_SHIFT;
4241 if ((adev->pm.dpm.new_active_crtc_count > 0) &&
4242 (!(adev->pm.dpm.new_active_crtcs & (1 << pipe)))) {
4243 /* find the first active crtc */
4244 for (i = 0; i < adev->mode_info.num_crtc; i++) {
4245 if (adev->pm.dpm.new_active_crtcs & (1 << i))
4248 if (i == adev->mode_info.num_crtc)
4253 tmp &= ~DCCG_DISP1_SLOW_SELECT_MASK;
4254 tmp |= DCCG_DISP1_SLOW_SELECT(pipe);
4255 WREG32(DCCG_DISP_SLOW_SELECT_REG, tmp);
4258 /* Setting this to false forces the performance state to low if the crtcs are disabled.
4259 * This can be a problem on PowerXpress systems or if you want to use the card
4260 * for offscreen rendering or compute if there are no crtcs enabled.
4262 si_notify_smc_display_change(adev, adev->pm.dpm.new_active_crtc_count > 0);
4265 static void si_enable_spread_spectrum(struct amdgpu_device *adev, bool enable)
4267 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4271 WREG32_P(GENERAL_PWRMGT, DYN_SPREAD_SPECTRUM_EN, ~DYN_SPREAD_SPECTRUM_EN);
4273 WREG32_P(CG_SPLL_SPREAD_SPECTRUM, 0, ~SSEN);
4274 WREG32_P(GENERAL_PWRMGT, 0, ~DYN_SPREAD_SPECTRUM_EN);
4278 static void si_setup_bsp(struct amdgpu_device *adev)
4280 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4281 u32 xclk = amdgpu_asic_get_xclk(adev);
4283 r600_calculate_u_and_p(pi->asi,
4289 r600_calculate_u_and_p(pi->pasi,
4296 pi->dsp = BSP(pi->bsp) | BSU(pi->bsu);
4297 pi->psp = BSP(pi->pbsp) | BSU(pi->pbsu);
4299 WREG32(CG_BSP, pi->dsp);
4302 static void si_program_git(struct amdgpu_device *adev)
4304 WREG32_P(CG_GIT, CG_GICST(R600_GICST_DFLT), ~CG_GICST_MASK);
4307 static void si_program_tp(struct amdgpu_device *adev)
4310 enum r600_td td = R600_TD_DFLT;
4312 for (i = 0; i < R600_PM_NUMBER_OF_TC; i++)
4313 WREG32(CG_FFCT_0 + i, (UTC_0(r600_utc[i]) | DTC_0(r600_dtc[i])));
4315 if (td == R600_TD_AUTO)
4316 WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_FORCE_TREND_SEL);
4318 WREG32_P(SCLK_PWRMGT_CNTL, FIR_FORCE_TREND_SEL, ~FIR_FORCE_TREND_SEL);
4320 if (td == R600_TD_UP)
4321 WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_TREND_MODE);
4323 if (td == R600_TD_DOWN)
4324 WREG32_P(SCLK_PWRMGT_CNTL, FIR_TREND_MODE, ~FIR_TREND_MODE);
4327 static void si_program_tpp(struct amdgpu_device *adev)
4329 WREG32(CG_TPC, R600_TPC_DFLT);
4332 static void si_program_sstp(struct amdgpu_device *adev)
4334 WREG32(CG_SSP, (SSTU(R600_SSTU_DFLT) | SST(R600_SST_DFLT)));
4337 static void si_enable_display_gap(struct amdgpu_device *adev)
4339 u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL);
4341 tmp &= ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
4342 tmp |= (DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE) |
4343 DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE));
4345 tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK);
4346 tmp |= (DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK) |
4347 DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE));
4348 WREG32(CG_DISPLAY_GAP_CNTL, tmp);
4351 static void si_program_vc(struct amdgpu_device *adev)
4353 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4355 WREG32(CG_FTV, pi->vrc);
4358 static void si_clear_vc(struct amdgpu_device *adev)
4363 static u8 si_get_ddr3_mclk_frequency_ratio(u32 memory_clock)
4367 if (memory_clock < 10000)
4369 else if (memory_clock >= 80000)
4370 mc_para_index = 0x0f;
4372 mc_para_index = (u8)((memory_clock - 10000) / 5000 + 1);
4373 return mc_para_index;
4376 static u8 si_get_mclk_frequency_ratio(u32 memory_clock, bool strobe_mode)
4381 if (memory_clock < 12500)
4382 mc_para_index = 0x00;
4383 else if (memory_clock > 47500)
4384 mc_para_index = 0x0f;
4386 mc_para_index = (u8)((memory_clock - 10000) / 2500);
4388 if (memory_clock < 65000)
4389 mc_para_index = 0x00;
4390 else if (memory_clock > 135000)
4391 mc_para_index = 0x0f;
4393 mc_para_index = (u8)((memory_clock - 60000) / 5000);
4395 return mc_para_index;
4398 static u8 si_get_strobe_mode_settings(struct amdgpu_device *adev, u32 mclk)
4400 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4401 bool strobe_mode = false;
4404 if (mclk <= pi->mclk_strobe_mode_threshold)
4407 if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5)
4408 result = si_get_mclk_frequency_ratio(mclk, strobe_mode);
4410 result = si_get_ddr3_mclk_frequency_ratio(mclk);
4413 result |= SISLANDS_SMC_STROBE_ENABLE;
4418 static int si_upload_firmware(struct amdgpu_device *adev)
4420 struct si_power_info *si_pi = si_get_pi(adev);
4422 amdgpu_si_reset_smc(adev);
4423 amdgpu_si_smc_clock(adev, false);
4425 return amdgpu_si_load_smc_ucode(adev, si_pi->sram_end);
4428 static bool si_validate_phase_shedding_tables(struct amdgpu_device *adev,
4429 const struct atom_voltage_table *table,
4430 const struct amdgpu_phase_shedding_limits_table *limits)
4432 u32 data, num_bits, num_levels;
4434 if ((table == NULL) || (limits == NULL))
4437 data = table->mask_low;
4439 num_bits = hweight32(data);
4444 num_levels = (1 << num_bits);
4446 if (table->count != num_levels)
4449 if (limits->count != (num_levels - 1))
4455 static void si_trim_voltage_table_to_fit_state_table(struct amdgpu_device *adev,
4456 u32 max_voltage_steps,
4457 struct atom_voltage_table *voltage_table)
4459 unsigned int i, diff;
4461 if (voltage_table->count <= max_voltage_steps)
4464 diff = voltage_table->count - max_voltage_steps;
4466 for (i= 0; i < max_voltage_steps; i++)
4467 voltage_table->entries[i] = voltage_table->entries[i + diff];
4469 voltage_table->count = max_voltage_steps;
4472 static int si_get_svi2_voltage_table(struct amdgpu_device *adev,
4473 struct amdgpu_clock_voltage_dependency_table *voltage_dependency_table,
4474 struct atom_voltage_table *voltage_table)
4478 if (voltage_dependency_table == NULL)
4481 voltage_table->mask_low = 0;
4482 voltage_table->phase_delay = 0;
4484 voltage_table->count = voltage_dependency_table->count;
4485 for (i = 0; i < voltage_table->count; i++) {
4486 voltage_table->entries[i].value = voltage_dependency_table->entries[i].v;
4487 voltage_table->entries[i].smio_low = 0;
4493 static int si_construct_voltage_tables(struct amdgpu_device *adev)
4495 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4496 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4497 struct si_power_info *si_pi = si_get_pi(adev);
4500 if (pi->voltage_control) {
4501 ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDC,
4502 VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddc_voltage_table);
4506 if (eg_pi->vddc_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
4507 si_trim_voltage_table_to_fit_state_table(adev,
4508 SISLANDS_MAX_NO_VREG_STEPS,
4509 &eg_pi->vddc_voltage_table);
4510 } else if (si_pi->voltage_control_svi2) {
4511 ret = si_get_svi2_voltage_table(adev,
4512 &adev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
4513 &eg_pi->vddc_voltage_table);
4520 if (eg_pi->vddci_control) {
4521 ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDCI,
4522 VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddci_voltage_table);
4526 if (eg_pi->vddci_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
4527 si_trim_voltage_table_to_fit_state_table(adev,
4528 SISLANDS_MAX_NO_VREG_STEPS,
4529 &eg_pi->vddci_voltage_table);
4531 if (si_pi->vddci_control_svi2) {
4532 ret = si_get_svi2_voltage_table(adev,
4533 &adev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
4534 &eg_pi->vddci_voltage_table);
4539 if (pi->mvdd_control) {
4540 ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_MVDDC,
4541 VOLTAGE_OBJ_GPIO_LUT, &si_pi->mvdd_voltage_table);
4544 pi->mvdd_control = false;
4548 if (si_pi->mvdd_voltage_table.count == 0) {
4549 pi->mvdd_control = false;
4553 if (si_pi->mvdd_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
4554 si_trim_voltage_table_to_fit_state_table(adev,
4555 SISLANDS_MAX_NO_VREG_STEPS,
4556 &si_pi->mvdd_voltage_table);
4559 if (si_pi->vddc_phase_shed_control) {
4560 ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDC,
4561 VOLTAGE_OBJ_PHASE_LUT, &si_pi->vddc_phase_shed_table);
4563 si_pi->vddc_phase_shed_control = false;
4565 if ((si_pi->vddc_phase_shed_table.count == 0) ||
4566 (si_pi->vddc_phase_shed_table.count > SISLANDS_MAX_NO_VREG_STEPS))
4567 si_pi->vddc_phase_shed_control = false;
4573 static void si_populate_smc_voltage_table(struct amdgpu_device *adev,
4574 const struct atom_voltage_table *voltage_table,
4575 SISLANDS_SMC_STATETABLE *table)
4579 for (i = 0; i < voltage_table->count; i++)
4580 table->lowSMIO[i] |= cpu_to_be32(voltage_table->entries[i].smio_low);
4583 static int si_populate_smc_voltage_tables(struct amdgpu_device *adev,
4584 SISLANDS_SMC_STATETABLE *table)
4586 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4587 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4588 struct si_power_info *si_pi = si_get_pi(adev);
4591 if (si_pi->voltage_control_svi2) {
4592 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc,
4593 si_pi->svc_gpio_id);
4594 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd,
4595 si_pi->svd_gpio_id);
4596 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_plat_type,
4599 if (eg_pi->vddc_voltage_table.count) {
4600 si_populate_smc_voltage_table(adev, &eg_pi->vddc_voltage_table, table);
4601 table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC] =
4602 cpu_to_be32(eg_pi->vddc_voltage_table.mask_low);
4604 for (i = 0; i < eg_pi->vddc_voltage_table.count; i++) {
4605 if (pi->max_vddc_in_table <= eg_pi->vddc_voltage_table.entries[i].value) {
4606 table->maxVDDCIndexInPPTable = i;
4612 if (eg_pi->vddci_voltage_table.count) {
4613 si_populate_smc_voltage_table(adev, &eg_pi->vddci_voltage_table, table);
4615 table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDCI] =
4616 cpu_to_be32(eg_pi->vddci_voltage_table.mask_low);
4620 if (si_pi->mvdd_voltage_table.count) {
4621 si_populate_smc_voltage_table(adev, &si_pi->mvdd_voltage_table, table);
4623 table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_MVDD] =
4624 cpu_to_be32(si_pi->mvdd_voltage_table.mask_low);
4627 if (si_pi->vddc_phase_shed_control) {
4628 if (si_validate_phase_shedding_tables(adev, &si_pi->vddc_phase_shed_table,
4629 &adev->pm.dpm.dyn_state.phase_shedding_limits_table)) {
4630 si_populate_smc_voltage_table(adev, &si_pi->vddc_phase_shed_table, table);
4632 table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING] =
4633 cpu_to_be32(si_pi->vddc_phase_shed_table.mask_low);
4635 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_phase_shedding_delay,
4636 (u32)si_pi->vddc_phase_shed_table.phase_delay);
4638 si_pi->vddc_phase_shed_control = false;
4646 static int si_populate_voltage_value(struct amdgpu_device *adev,
4647 const struct atom_voltage_table *table,
4648 u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage)
4652 for (i = 0; i < table->count; i++) {
4653 if (value <= table->entries[i].value) {
4654 voltage->index = (u8)i;
4655 voltage->value = cpu_to_be16(table->entries[i].value);
4660 if (i >= table->count)
4666 static int si_populate_mvdd_value(struct amdgpu_device *adev, u32 mclk,
4667 SISLANDS_SMC_VOLTAGE_VALUE *voltage)
4669 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4670 struct si_power_info *si_pi = si_get_pi(adev);
4672 if (pi->mvdd_control) {
4673 if (mclk <= pi->mvdd_split_frequency)
4676 voltage->index = (u8)(si_pi->mvdd_voltage_table.count) - 1;
4678 voltage->value = cpu_to_be16(si_pi->mvdd_voltage_table.entries[voltage->index].value);
4683 static int si_get_std_voltage_value(struct amdgpu_device *adev,
4684 SISLANDS_SMC_VOLTAGE_VALUE *voltage,
4688 bool voltage_found = false;
4689 *std_voltage = be16_to_cpu(voltage->value);
4691 if (adev->pm.dpm.dyn_state.cac_leakage_table.entries) {
4692 if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_NEW_CAC_VOLTAGE) {
4693 if (adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries == NULL)
4696 for (v_index = 0; (u32)v_index < adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) {
4697 if (be16_to_cpu(voltage->value) ==
4698 (u16)adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) {
4699 voltage_found = true;
4700 if ((u32)v_index < adev->pm.dpm.dyn_state.cac_leakage_table.count)
4702 adev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc;
4705 adev->pm.dpm.dyn_state.cac_leakage_table.entries[adev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc;
4710 if (!voltage_found) {
4711 for (v_index = 0; (u32)v_index < adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) {
4712 if (be16_to_cpu(voltage->value) <=
4713 (u16)adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) {
4714 voltage_found = true;
4715 if ((u32)v_index < adev->pm.dpm.dyn_state.cac_leakage_table.count)
4717 adev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc;
4720 adev->pm.dpm.dyn_state.cac_leakage_table.entries[adev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc;
4726 if ((u32)voltage->index < adev->pm.dpm.dyn_state.cac_leakage_table.count)
4727 *std_voltage = adev->pm.dpm.dyn_state.cac_leakage_table.entries[voltage->index].vddc;
4734 static int si_populate_std_voltage_value(struct amdgpu_device *adev,
4735 u16 value, u8 index,
4736 SISLANDS_SMC_VOLTAGE_VALUE *voltage)
4738 voltage->index = index;
4739 voltage->value = cpu_to_be16(value);
4744 static int si_populate_phase_shedding_value(struct amdgpu_device *adev,
4745 const struct amdgpu_phase_shedding_limits_table *limits,
4746 u16 voltage, u32 sclk, u32 mclk,
4747 SISLANDS_SMC_VOLTAGE_VALUE *smc_voltage)
4751 for (i = 0; i < limits->count; i++) {
4752 if ((voltage <= limits->entries[i].voltage) &&
4753 (sclk <= limits->entries[i].sclk) &&
4754 (mclk <= limits->entries[i].mclk))
4758 smc_voltage->phase_settings = (u8)i;
4763 static int si_init_arb_table_index(struct amdgpu_device *adev)
4765 struct si_power_info *si_pi = si_get_pi(adev);
4769 ret = amdgpu_si_read_smc_sram_dword(adev, si_pi->arb_table_start,
4770 &tmp, si_pi->sram_end);
4775 tmp |= MC_CG_ARB_FREQ_F1 << 24;
4777 return amdgpu_si_write_smc_sram_dword(adev, si_pi->arb_table_start,
4778 tmp, si_pi->sram_end);
4781 static int si_initial_switch_from_arb_f0_to_f1(struct amdgpu_device *adev)
4783 return ni_copy_and_switch_arb_sets(adev, MC_CG_ARB_FREQ_F0, MC_CG_ARB_FREQ_F1);
4786 static int si_reset_to_default(struct amdgpu_device *adev)
4788 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_ResetToDefaults) == PPSMC_Result_OK) ?
4792 static int si_force_switch_to_arb_f0(struct amdgpu_device *adev)
4794 struct si_power_info *si_pi = si_get_pi(adev);
4798 ret = amdgpu_si_read_smc_sram_dword(adev, si_pi->arb_table_start,
4799 &tmp, si_pi->sram_end);
4803 tmp = (tmp >> 24) & 0xff;
4805 if (tmp == MC_CG_ARB_FREQ_F0)
4808 return ni_copy_and_switch_arb_sets(adev, tmp, MC_CG_ARB_FREQ_F0);
4811 static u32 si_calculate_memory_refresh_rate(struct amdgpu_device *adev,
4815 u32 dram_refresh_rate;
4816 u32 mc_arb_rfsh_rate;
4817 u32 tmp = (RREG32(MC_ARB_RAMCFG) & NOOFROWS_MASK) >> NOOFROWS_SHIFT;
4822 dram_rows = 1 << (tmp + 10);
4824 dram_refresh_rate = 1 << ((RREG32(MC_SEQ_MISC0) & 0x3) + 3);
4825 mc_arb_rfsh_rate = ((engine_clock * 10) * dram_refresh_rate / dram_rows - 32) / 64;
4827 return mc_arb_rfsh_rate;
4830 static int si_populate_memory_timing_parameters(struct amdgpu_device *adev,
4831 struct rv7xx_pl *pl,
4832 SMC_SIslands_MCArbDramTimingRegisterSet *arb_regs)
4838 arb_regs->mc_arb_rfsh_rate =
4839 (u8)si_calculate_memory_refresh_rate(adev, pl->sclk);
4841 amdgpu_atombios_set_engine_dram_timings(adev,
4845 dram_timing = RREG32(MC_ARB_DRAM_TIMING);
4846 dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
4847 burst_time = RREG32(MC_ARB_BURST_TIME) & STATE0_MASK;
4849 arb_regs->mc_arb_dram_timing = cpu_to_be32(dram_timing);
4850 arb_regs->mc_arb_dram_timing2 = cpu_to_be32(dram_timing2);
4851 arb_regs->mc_arb_burst_time = (u8)burst_time;
4856 static int si_do_program_memory_timing_parameters(struct amdgpu_device *adev,
4857 struct amdgpu_ps *amdgpu_state,
4858 unsigned int first_arb_set)
4860 struct si_power_info *si_pi = si_get_pi(adev);
4861 struct si_ps *state = si_get_ps(amdgpu_state);
4862 SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 };
4865 for (i = 0; i < state->performance_level_count; i++) {
4866 ret = si_populate_memory_timing_parameters(adev, &state->performance_levels[i], &arb_regs);
4869 ret = amdgpu_si_copy_bytes_to_smc(adev,
4870 si_pi->arb_table_start +
4871 offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) +
4872 sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * (first_arb_set + i),
4874 sizeof(SMC_SIslands_MCArbDramTimingRegisterSet),
4883 static int si_program_memory_timing_parameters(struct amdgpu_device *adev,
4884 struct amdgpu_ps *amdgpu_new_state)
4886 return si_do_program_memory_timing_parameters(adev, amdgpu_new_state,
4887 SISLANDS_DRIVER_STATE_ARB_INDEX);
4890 static int si_populate_initial_mvdd_value(struct amdgpu_device *adev,
4891 struct SISLANDS_SMC_VOLTAGE_VALUE *voltage)
4893 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4894 struct si_power_info *si_pi = si_get_pi(adev);
4896 if (pi->mvdd_control)
4897 return si_populate_voltage_value(adev, &si_pi->mvdd_voltage_table,
4898 si_pi->mvdd_bootup_value, voltage);
4903 static int si_populate_smc_initial_state(struct amdgpu_device *adev,
4904 struct amdgpu_ps *amdgpu_initial_state,
4905 SISLANDS_SMC_STATETABLE *table)
4907 struct si_ps *initial_state = si_get_ps(amdgpu_initial_state);
4908 struct rv7xx_power_info *pi = rv770_get_pi(adev);
4909 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4910 struct si_power_info *si_pi = si_get_pi(adev);
4914 table->initialState.levels[0].mclk.vDLL_CNTL =
4915 cpu_to_be32(si_pi->clock_registers.dll_cntl);
4916 table->initialState.levels[0].mclk.vMCLK_PWRMGT_CNTL =
4917 cpu_to_be32(si_pi->clock_registers.mclk_pwrmgt_cntl);
4918 table->initialState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
4919 cpu_to_be32(si_pi->clock_registers.mpll_ad_func_cntl);
4920 table->initialState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL =
4921 cpu_to_be32(si_pi->clock_registers.mpll_dq_func_cntl);
4922 table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL =
4923 cpu_to_be32(si_pi->clock_registers.mpll_func_cntl);
4924 table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_1 =
4925 cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_1);
4926 table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_2 =
4927 cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_2);
4928 table->initialState.levels[0].mclk.vMPLL_SS =
4929 cpu_to_be32(si_pi->clock_registers.mpll_ss1);
4930 table->initialState.levels[0].mclk.vMPLL_SS2 =
4931 cpu_to_be32(si_pi->clock_registers.mpll_ss2);
4933 table->initialState.levels[0].mclk.mclk_value =
4934 cpu_to_be32(initial_state->performance_levels[0].mclk);
4936 table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL =
4937 cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl);
4938 table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 =
4939 cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_2);
4940 table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 =
4941 cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_3);
4942 table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 =
4943 cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_4);
4944 table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM =
4945 cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum);
4946 table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM_2 =
4947 cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum_2);
4949 table->initialState.levels[0].sclk.sclk_value =
4950 cpu_to_be32(initial_state->performance_levels[0].sclk);
4952 table->initialState.levels[0].arbRefreshState =
4953 SISLANDS_INITIAL_STATE_ARB_INDEX;
4955 table->initialState.levels[0].ACIndex = 0;
4957 ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
4958 initial_state->performance_levels[0].vddc,
4959 &table->initialState.levels[0].vddc);
4964 ret = si_get_std_voltage_value(adev,
4965 &table->initialState.levels[0].vddc,
4968 si_populate_std_voltage_value(adev, std_vddc,
4969 table->initialState.levels[0].vddc.index,
4970 &table->initialState.levels[0].std_vddc);
4973 if (eg_pi->vddci_control)
4974 si_populate_voltage_value(adev,
4975 &eg_pi->vddci_voltage_table,
4976 initial_state->performance_levels[0].vddci,
4977 &table->initialState.levels[0].vddci);
4979 if (si_pi->vddc_phase_shed_control)
4980 si_populate_phase_shedding_value(adev,
4981 &adev->pm.dpm.dyn_state.phase_shedding_limits_table,
4982 initial_state->performance_levels[0].vddc,
4983 initial_state->performance_levels[0].sclk,
4984 initial_state->performance_levels[0].mclk,
4985 &table->initialState.levels[0].vddc);
4987 si_populate_initial_mvdd_value(adev, &table->initialState.levels[0].mvdd);
4989 reg = CG_R(0xffff) | CG_L(0);
4990 table->initialState.levels[0].aT = cpu_to_be32(reg);
4991 table->initialState.levels[0].bSP = cpu_to_be32(pi->dsp);
4992 table->initialState.levels[0].gen2PCIE = (u8)si_pi->boot_pcie_gen;
4994 if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) {
4995 table->initialState.levels[0].strobeMode =
4996 si_get_strobe_mode_settings(adev,
4997 initial_state->performance_levels[0].mclk);
4999 if (initial_state->performance_levels[0].mclk > pi->mclk_edc_enable_threshold)
5000 table->initialState.levels[0].mcFlags = SISLANDS_SMC_MC_EDC_RD_FLAG | SISLANDS_SMC_MC_EDC_WR_FLAG;
5002 table->initialState.levels[0].mcFlags = 0;
5005 table->initialState.levelCount = 1;
5007 table->initialState.flags |= PPSMC_SWSTATE_FLAG_DC;
5009 table->initialState.levels[0].dpm2.MaxPS = 0;
5010 table->initialState.levels[0].dpm2.NearTDPDec = 0;
5011 table->initialState.levels[0].dpm2.AboveSafeInc = 0;
5012 table->initialState.levels[0].dpm2.BelowSafeInc = 0;
5013 table->initialState.levels[0].dpm2.PwrEfficiencyRatio = 0;
5015 reg = MIN_POWER_MASK | MAX_POWER_MASK;
5016 table->initialState.levels[0].SQPowerThrottle = cpu_to_be32(reg);
5018 reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
5019 table->initialState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg);
5024 static int si_populate_smc_acpi_state(struct amdgpu_device *adev,
5025 SISLANDS_SMC_STATETABLE *table)
5027 struct rv7xx_power_info *pi = rv770_get_pi(adev);
5028 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
5029 struct si_power_info *si_pi = si_get_pi(adev);
5030 u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl;
5031 u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2;
5032 u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3;
5033 u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4;
5034 u32 dll_cntl = si_pi->clock_registers.dll_cntl;
5035 u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl;
5036 u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl;
5037 u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl;
5038 u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl;
5039 u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1;
5040 u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2;
5044 table->ACPIState = table->initialState;
5046 table->ACPIState.flags &= ~PPSMC_SWSTATE_FLAG_DC;
5048 if (pi->acpi_vddc) {
5049 ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
5050 pi->acpi_vddc, &table->ACPIState.levels[0].vddc);
5054 ret = si_get_std_voltage_value(adev,
5055 &table->ACPIState.levels[0].vddc, &std_vddc);
5057 si_populate_std_voltage_value(adev, std_vddc,
5058 table->ACPIState.levels[0].vddc.index,
5059 &table->ACPIState.levels[0].std_vddc);
5061 table->ACPIState.levels[0].gen2PCIE = si_pi->acpi_pcie_gen;
5063 if (si_pi->vddc_phase_shed_control) {
5064 si_populate_phase_shedding_value(adev,
5065 &adev->pm.dpm.dyn_state.phase_shedding_limits_table,
5069 &table->ACPIState.levels[0].vddc);
5072 ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
5073 pi->min_vddc_in_table, &table->ACPIState.levels[0].vddc);
5077 ret = si_get_std_voltage_value(adev,
5078 &table->ACPIState.levels[0].vddc, &std_vddc);
5081 si_populate_std_voltage_value(adev, std_vddc,
5082 table->ACPIState.levels[0].vddc.index,
5083 &table->ACPIState.levels[0].std_vddc);
5085 table->ACPIState.levels[0].gen2PCIE = (u8)r600_get_pcie_gen_support(adev,
5086 si_pi->sys_pcie_mask,
5087 si_pi->boot_pcie_gen,
5090 if (si_pi->vddc_phase_shed_control)
5091 si_populate_phase_shedding_value(adev,
5092 &adev->pm.dpm.dyn_state.phase_shedding_limits_table,
5093 pi->min_vddc_in_table,
5096 &table->ACPIState.levels[0].vddc);
5099 if (pi->acpi_vddc) {
5100 if (eg_pi->acpi_vddci)
5101 si_populate_voltage_value(adev, &eg_pi->vddci_voltage_table,
5103 &table->ACPIState.levels[0].vddci);
5106 mclk_pwrmgt_cntl |= MRDCK0_RESET | MRDCK1_RESET;
5107 mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB);
5109 dll_cntl &= ~(MRDCK0_BYPASS | MRDCK1_BYPASS);
5111 spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK;
5112 spll_func_cntl_2 |= SCLK_MUX_SEL(4);
5114 table->ACPIState.levels[0].mclk.vDLL_CNTL =
5115 cpu_to_be32(dll_cntl);
5116 table->ACPIState.levels[0].mclk.vMCLK_PWRMGT_CNTL =
5117 cpu_to_be32(mclk_pwrmgt_cntl);
5118 table->ACPIState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
5119 cpu_to_be32(mpll_ad_func_cntl);
5120 table->ACPIState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL =
5121 cpu_to_be32(mpll_dq_func_cntl);
5122 table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL =
5123 cpu_to_be32(mpll_func_cntl);
5124 table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_1 =
5125 cpu_to_be32(mpll_func_cntl_1);
5126 table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_2 =
5127 cpu_to_be32(mpll_func_cntl_2);
5128 table->ACPIState.levels[0].mclk.vMPLL_SS =
5129 cpu_to_be32(si_pi->clock_registers.mpll_ss1);
5130 table->ACPIState.levels[0].mclk.vMPLL_SS2 =
5131 cpu_to_be32(si_pi->clock_registers.mpll_ss2);
5133 table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL =
5134 cpu_to_be32(spll_func_cntl);
5135 table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 =
5136 cpu_to_be32(spll_func_cntl_2);
5137 table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 =
5138 cpu_to_be32(spll_func_cntl_3);
5139 table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 =
5140 cpu_to_be32(spll_func_cntl_4);
5142 table->ACPIState.levels[0].mclk.mclk_value = 0;
5143 table->ACPIState.levels[0].sclk.sclk_value = 0;
5145 si_populate_mvdd_value(adev, 0, &table->ACPIState.levels[0].mvdd);
5147 if (eg_pi->dynamic_ac_timing)
5148 table->ACPIState.levels[0].ACIndex = 0;
5150 table->ACPIState.levels[0].dpm2.MaxPS = 0;
5151 table->ACPIState.levels[0].dpm2.NearTDPDec = 0;
5152 table->ACPIState.levels[0].dpm2.AboveSafeInc = 0;
5153 table->ACPIState.levels[0].dpm2.BelowSafeInc = 0;
5154 table->ACPIState.levels[0].dpm2.PwrEfficiencyRatio = 0;
5156 reg = MIN_POWER_MASK | MAX_POWER_MASK;
5157 table->ACPIState.levels[0].SQPowerThrottle = cpu_to_be32(reg);
5159 reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
5160 table->ACPIState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg);
5165 static int si_populate_ulv_state(struct amdgpu_device *adev,
5166 SISLANDS_SMC_SWSTATE *state)
5168 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
5169 struct si_power_info *si_pi = si_get_pi(adev);
5170 struct si_ulv_param *ulv = &si_pi->ulv;
5171 u32 sclk_in_sr = 1350; /* ??? */
5174 ret = si_convert_power_level_to_smc(adev, &ulv->pl,
5177 if (eg_pi->sclk_deep_sleep) {
5178 if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ)
5179 state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS;
5181 state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE;
5183 if (ulv->one_pcie_lane_in_ulv)
5184 state->flags |= PPSMC_SWSTATE_FLAG_PCIE_X1;
5185 state->levels[0].arbRefreshState = (u8)(SISLANDS_ULV_STATE_ARB_INDEX);
5186 state->levels[0].ACIndex = 1;
5187 state->levels[0].std_vddc = state->levels[0].vddc;
5188 state->levelCount = 1;
5190 state->flags |= PPSMC_SWSTATE_FLAG_DC;
5196 static int si_program_ulv_memory_timing_parameters(struct amdgpu_device *adev)
5198 struct si_power_info *si_pi = si_get_pi(adev);
5199 struct si_ulv_param *ulv = &si_pi->ulv;
5200 SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 };
5203 ret = si_populate_memory_timing_parameters(adev, &ulv->pl,
5208 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_ulv_volt_change_delay,
5209 ulv->volt_change_delay);
5211 ret = amdgpu_si_copy_bytes_to_smc(adev,
5212 si_pi->arb_table_start +
5213 offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) +
5214 sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * SISLANDS_ULV_STATE_ARB_INDEX,
5216 sizeof(SMC_SIslands_MCArbDramTimingRegisterSet),
5222 static void si_get_mvdd_configuration(struct amdgpu_device *adev)
5224 struct rv7xx_power_info *pi = rv770_get_pi(adev);
5226 pi->mvdd_split_frequency = 30000;
5229 static int si_init_smc_table(struct amdgpu_device *adev)
5231 struct si_power_info *si_pi = si_get_pi(adev);
5232 struct amdgpu_ps *amdgpu_boot_state = adev->pm.dpm.boot_ps;
5233 const struct si_ulv_param *ulv = &si_pi->ulv;
5234 SISLANDS_SMC_STATETABLE *table = &si_pi->smc_statetable;
5239 si_populate_smc_voltage_tables(adev, table);
5241 switch (adev->pm.int_thermal_type) {
5242 case THERMAL_TYPE_SI:
5243 case THERMAL_TYPE_EMC2103_WITH_INTERNAL:
5244 table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_INTERNAL;
5246 case THERMAL_TYPE_NONE:
5247 table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_NONE;
5250 table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL;
5254 if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
5255 table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC;
5257 if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT) {
5258 if ((adev->pdev->device != 0x6818) && (adev->pdev->device != 0x6819))
5259 table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT;
5262 if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_STEPVDDC)
5263 table->systemFlags |= PPSMC_SYSTEMFLAG_STEPVDDC;
5265 if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5)
5266 table->systemFlags |= PPSMC_SYSTEMFLAG_GDDR5;
5268 if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REVERT_GPIO5_POLARITY)
5269 table->extraFlags |= PPSMC_EXTRAFLAGS_AC2DC_GPIO5_POLARITY_HIGH;
5271 if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_VRHOT_GPIO_CONFIGURABLE) {
5272 table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT_PROG_GPIO;
5273 vr_hot_gpio = adev->pm.dpm.backbias_response_time;
5274 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_vr_hot_gpio,
5278 ret = si_populate_smc_initial_state(adev, amdgpu_boot_state, table);
5282 ret = si_populate_smc_acpi_state(adev, table);
5286 table->driverState = table->initialState;
5288 ret = si_do_program_memory_timing_parameters(adev, amdgpu_boot_state,
5289 SISLANDS_INITIAL_STATE_ARB_INDEX);
5293 if (ulv->supported && ulv->pl.vddc) {
5294 ret = si_populate_ulv_state(adev, &table->ULVState);
5298 ret = si_program_ulv_memory_timing_parameters(adev);
5302 WREG32(CG_ULV_CONTROL, ulv->cg_ulv_control);
5303 WREG32(CG_ULV_PARAMETER, ulv->cg_ulv_parameter);
5305 lane_width = amdgpu_get_pcie_lanes(adev);
5306 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width);
5308 table->ULVState = table->initialState;
5311 return amdgpu_si_copy_bytes_to_smc(adev, si_pi->state_table_start,
5312 (u8 *)table, sizeof(SISLANDS_SMC_STATETABLE),
5316 static int si_calculate_sclk_params(struct amdgpu_device *adev,
5318 SISLANDS_SMC_SCLK_VALUE *sclk)
5320 struct rv7xx_power_info *pi = rv770_get_pi(adev);
5321 struct si_power_info *si_pi = si_get_pi(adev);
5322 struct atom_clock_dividers dividers;
5323 u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl;
5324 u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2;
5325 u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3;
5326 u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4;
5327 u32 cg_spll_spread_spectrum = si_pi->clock_registers.cg_spll_spread_spectrum;
5328 u32 cg_spll_spread_spectrum_2 = si_pi->clock_registers.cg_spll_spread_spectrum_2;
5330 u32 reference_clock = adev->clock.spll.reference_freq;
5331 u32 reference_divider;
5335 ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_ENGINE_PLL_PARAM,
5336 engine_clock, false, ÷rs);
5340 reference_divider = 1 + dividers.ref_div;
5342 tmp = (u64) engine_clock * reference_divider * dividers.post_div * 16384;
5343 do_div(tmp, reference_clock);
5346 spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
5347 spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
5348 spll_func_cntl |= SPLL_PDIV_A(dividers.post_div);
5350 spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK;
5351 spll_func_cntl_2 |= SCLK_MUX_SEL(2);
5353 spll_func_cntl_3 &= ~SPLL_FB_DIV_MASK;
5354 spll_func_cntl_3 |= SPLL_FB_DIV(fbdiv);
5355 spll_func_cntl_3 |= SPLL_DITHEN;
5358 struct amdgpu_atom_ss ss;
5359 u32 vco_freq = engine_clock * dividers.post_div;
5361 if (amdgpu_atombios_get_asic_ss_info(adev, &ss,
5362 ASIC_INTERNAL_ENGINE_SS, vco_freq)) {
5363 u32 clk_s = reference_clock * 5 / (reference_divider * ss.rate);
5364 u32 clk_v = 4 * ss.percentage * fbdiv / (clk_s * 10000);
5366 cg_spll_spread_spectrum &= ~CLK_S_MASK;
5367 cg_spll_spread_spectrum |= CLK_S(clk_s);
5368 cg_spll_spread_spectrum |= SSEN;
5370 cg_spll_spread_spectrum_2 &= ~CLK_V_MASK;
5371 cg_spll_spread_spectrum_2 |= CLK_V(clk_v);
5375 sclk->sclk_value = engine_clock;
5376 sclk->vCG_SPLL_FUNC_CNTL = spll_func_cntl;
5377 sclk->vCG_SPLL_FUNC_CNTL_2 = spll_func_cntl_2;
5378 sclk->vCG_SPLL_FUNC_CNTL_3 = spll_func_cntl_3;
5379 sclk->vCG_SPLL_FUNC_CNTL_4 = spll_func_cntl_4;
5380 sclk->vCG_SPLL_SPREAD_SPECTRUM = cg_spll_spread_spectrum;
5381 sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cg_spll_spread_spectrum_2;
5386 static int si_populate_sclk_value(struct amdgpu_device *adev,
5388 SISLANDS_SMC_SCLK_VALUE *sclk)
5390 SISLANDS_SMC_SCLK_VALUE sclk_tmp;
5393 ret = si_calculate_sclk_params(adev, engine_clock, &sclk_tmp);
5395 sclk->sclk_value = cpu_to_be32(sclk_tmp.sclk_value);
5396 sclk->vCG_SPLL_FUNC_CNTL = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL);
5397 sclk->vCG_SPLL_FUNC_CNTL_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_2);
5398 sclk->vCG_SPLL_FUNC_CNTL_3 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_3);
5399 sclk->vCG_SPLL_FUNC_CNTL_4 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_4);
5400 sclk->vCG_SPLL_SPREAD_SPECTRUM = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM);
5401 sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM_2);
5407 static int si_populate_mclk_value(struct amdgpu_device *adev,
5410 SISLANDS_SMC_MCLK_VALUE *mclk,
5414 struct rv7xx_power_info *pi = rv770_get_pi(adev);
5415 struct si_power_info *si_pi = si_get_pi(adev);
5416 u32 dll_cntl = si_pi->clock_registers.dll_cntl;
5417 u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl;
5418 u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl;
5419 u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl;
5420 u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl;
5421 u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1;
5422 u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2;
5423 u32 mpll_ss1 = si_pi->clock_registers.mpll_ss1;
5424 u32 mpll_ss2 = si_pi->clock_registers.mpll_ss2;
5425 struct atom_mpll_param mpll_param;
5428 ret = amdgpu_atombios_get_memory_pll_dividers(adev, memory_clock, strobe_mode, &mpll_param);
5432 mpll_func_cntl &= ~BWCTRL_MASK;
5433 mpll_func_cntl |= BWCTRL(mpll_param.bwcntl);
5435 mpll_func_cntl_1 &= ~(CLKF_MASK | CLKFRAC_MASK | VCO_MODE_MASK);
5436 mpll_func_cntl_1 |= CLKF(mpll_param.clkf) |
5437 CLKFRAC(mpll_param.clkfrac) | VCO_MODE(mpll_param.vco_mode);
5439 mpll_ad_func_cntl &= ~YCLK_POST_DIV_MASK;
5440 mpll_ad_func_cntl |= YCLK_POST_DIV(mpll_param.post_div);
5442 if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) {
5443 mpll_dq_func_cntl &= ~(YCLK_SEL_MASK | YCLK_POST_DIV_MASK);
5444 mpll_dq_func_cntl |= YCLK_SEL(mpll_param.yclk_sel) |
5445 YCLK_POST_DIV(mpll_param.post_div);
5449 struct amdgpu_atom_ss ss;
5452 u32 reference_clock = adev->clock.mpll.reference_freq;
5454 if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5)
5455 freq_nom = memory_clock * 4;
5457 freq_nom = memory_clock * 2;
5459 tmp = freq_nom / reference_clock;
5461 if (amdgpu_atombios_get_asic_ss_info(adev, &ss,
5462 ASIC_INTERNAL_MEMORY_SS, freq_nom)) {
5463 u32 clks = reference_clock * 5 / ss.rate;
5464 u32 clkv = (u32)((((131 * ss.percentage * ss.rate) / 100) * tmp) / freq_nom);
5466 mpll_ss1 &= ~CLKV_MASK;
5467 mpll_ss1 |= CLKV(clkv);
5469 mpll_ss2 &= ~CLKS_MASK;
5470 mpll_ss2 |= CLKS(clks);
5474 mclk_pwrmgt_cntl &= ~DLL_SPEED_MASK;
5475 mclk_pwrmgt_cntl |= DLL_SPEED(mpll_param.dll_speed);
5478 mclk_pwrmgt_cntl |= MRDCK0_PDNB | MRDCK1_PDNB;
5480 mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB);
5482 mclk->mclk_value = cpu_to_be32(memory_clock);
5483 mclk->vMPLL_FUNC_CNTL = cpu_to_be32(mpll_func_cntl);
5484 mclk->vMPLL_FUNC_CNTL_1 = cpu_to_be32(mpll_func_cntl_1);
5485 mclk->vMPLL_FUNC_CNTL_2 = cpu_to_be32(mpll_func_cntl_2);
5486 mclk->vMPLL_AD_FUNC_CNTL = cpu_to_be32(mpll_ad_func_cntl);
5487 mclk->vMPLL_DQ_FUNC_CNTL = cpu_to_be32(mpll_dq_func_cntl);
5488 mclk->vMCLK_PWRMGT_CNTL = cpu_to_be32(mclk_pwrmgt_cntl);
5489 mclk->vDLL_CNTL = cpu_to_be32(dll_cntl);
5490 mclk->vMPLL_SS = cpu_to_be32(mpll_ss1);
5491 mclk->vMPLL_SS2 = cpu_to_be32(mpll_ss2);
5496 static void si_populate_smc_sp(struct amdgpu_device *adev,
5497 struct amdgpu_ps *amdgpu_state,
5498 SISLANDS_SMC_SWSTATE *smc_state)
5500 struct si_ps *ps = si_get_ps(amdgpu_state);
5501 struct rv7xx_power_info *pi = rv770_get_pi(adev);
5504 for (i = 0; i < ps->performance_level_count - 1; i++)
5505 smc_state->levels[i].bSP = cpu_to_be32(pi->dsp);
5507 smc_state->levels[ps->performance_level_count - 1].bSP =
5508 cpu_to_be32(pi->psp);
5511 static int si_convert_power_level_to_smc(struct amdgpu_device *adev,
5512 struct rv7xx_pl *pl,
5513 SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level)
5515 struct rv7xx_power_info *pi = rv770_get_pi(adev);
5516 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
5517 struct si_power_info *si_pi = si_get_pi(adev);
5521 bool gmc_pg = false;
5523 if (eg_pi->pcie_performance_request &&
5524 (si_pi->force_pcie_gen != AMDGPU_PCIE_GEN_INVALID))
5525 level->gen2PCIE = (u8)si_pi->force_pcie_gen;
5527 level->gen2PCIE = (u8)pl->pcie_gen;
5529 ret = si_populate_sclk_value(adev, pl->sclk, &level->sclk);
5535 if (pi->mclk_stutter_mode_threshold &&
5536 (pl->mclk <= pi->mclk_stutter_mode_threshold) &&
5537 !eg_pi->uvd_enabled &&
5538 (RREG32(DPG_PIPE_STUTTER_CONTROL) & STUTTER_ENABLE) &&
5539 (adev->pm.dpm.new_active_crtc_count <= 2)) {
5540 level->mcFlags |= SISLANDS_SMC_MC_STUTTER_EN;
5543 level->mcFlags |= SISLANDS_SMC_MC_PG_EN;
5546 if (adev->mc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) {
5547 if (pl->mclk > pi->mclk_edc_enable_threshold)
5548 level->mcFlags |= SISLANDS_SMC_MC_EDC_RD_FLAG;
5550 if (pl->mclk > eg_pi->mclk_edc_wr_enable_threshold)
5551 level->mcFlags |= SISLANDS_SMC_MC_EDC_WR_FLAG;
5553 level->strobeMode = si_get_strobe_mode_settings(adev, pl->mclk);
5555 if (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) {
5556 if (si_get_mclk_frequency_ratio(pl->mclk, true) >=
5557 ((RREG32(MC_SEQ_MISC7) >> 16) & 0xf))
5558 dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false;
5560 dll_state_on = ((RREG32(MC_SEQ_MISC6) >> 1) & 0x1) ? true : false;
5562 dll_state_on = false;
5565 level->strobeMode = si_get_strobe_mode_settings(adev,
5568 dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false;
5571 ret = si_populate_mclk_value(adev,
5575 (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) != 0, dll_state_on);
5579 ret = si_populate_voltage_value(adev,
5580 &eg_pi->vddc_voltage_table,
5581 pl->vddc, &level->vddc);
5586 ret = si_get_std_voltage_value(adev, &level->vddc, &std_vddc);
5590 ret = si_populate_std_voltage_value(adev, std_vddc,
5591 level->vddc.index, &level->std_vddc);
5595 if (eg_pi->vddci_control) {
5596 ret = si_populate_voltage_value(adev, &eg_pi->vddci_voltage_table,
5597 pl->vddci, &level->vddci);
5602 if (si_pi->vddc_phase_shed_control) {
5603 ret = si_populate_phase_shedding_value(adev,
5604 &adev->pm.dpm.dyn_state.phase_shedding_limits_table,
5613 level->MaxPoweredUpCU = si_pi->max_cu;
5615 ret = si_populate_mvdd_value(adev, pl->mclk, &level->mvdd);
5620 static int si_populate_smc_t(struct amdgpu_device *adev,
5621 struct amdgpu_ps *amdgpu_state,
5622 SISLANDS_SMC_SWSTATE *smc_state)
5624 struct rv7xx_power_info *pi = rv770_get_pi(adev);
5625 struct si_ps *state = si_get_ps(amdgpu_state);
5631 if (state->performance_level_count >= 9)
5634 if (state->performance_level_count < 2) {
5635 a_t = CG_R(0xffff) | CG_L(0);
5636 smc_state->levels[0].aT = cpu_to_be32(a_t);
5640 smc_state->levels[0].aT = cpu_to_be32(0);
5642 for (i = 0; i <= state->performance_level_count - 2; i++) {
5643 ret = r600_calculate_at(
5644 (50 / SISLANDS_MAX_HARDWARE_POWERLEVELS) * 100 * (i + 1),
5646 state->performance_levels[i + 1].sclk,
5647 state->performance_levels[i].sclk,
5652 t_h = (i + 1) * 1000 - 50 * R600_AH_DFLT;
5653 t_l = (i + 1) * 1000 + 50 * R600_AH_DFLT;
5656 a_t = be32_to_cpu(smc_state->levels[i].aT) & ~CG_R_MASK;
5657 a_t |= CG_R(t_l * pi->bsp / 20000);
5658 smc_state->levels[i].aT = cpu_to_be32(a_t);
5660 high_bsp = (i == state->performance_level_count - 2) ?
5662 a_t = CG_R(0xffff) | CG_L(t_h * high_bsp / 20000);
5663 smc_state->levels[i + 1].aT = cpu_to_be32(a_t);
5669 static int si_disable_ulv(struct amdgpu_device *adev)
5671 struct si_power_info *si_pi = si_get_pi(adev);
5672 struct si_ulv_param *ulv = &si_pi->ulv;
5675 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ?
5681 static bool si_is_state_ulv_compatible(struct amdgpu_device *adev,
5682 struct amdgpu_ps *amdgpu_state)
5684 const struct si_power_info *si_pi = si_get_pi(adev);
5685 const struct si_ulv_param *ulv = &si_pi->ulv;
5686 const struct si_ps *state = si_get_ps(amdgpu_state);
5689 if (state->performance_levels[0].mclk != ulv->pl.mclk)
5692 /* XXX validate against display requirements! */
5694 for (i = 0; i < adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count; i++) {
5695 if (adev->clock.current_dispclk <=
5696 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].clk) {
5698 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].v)
5703 if ((amdgpu_state->vclk != 0) || (amdgpu_state->dclk != 0))
5709 static int si_set_power_state_conditionally_enable_ulv(struct amdgpu_device *adev,
5710 struct amdgpu_ps *amdgpu_new_state)
5712 const struct si_power_info *si_pi = si_get_pi(adev);
5713 const struct si_ulv_param *ulv = &si_pi->ulv;
5715 if (ulv->supported) {
5716 if (si_is_state_ulv_compatible(adev, amdgpu_new_state))
5717 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableULV) == PPSMC_Result_OK) ?
5723 static int si_convert_power_state_to_smc(struct amdgpu_device *adev,
5724 struct amdgpu_ps *amdgpu_state,
5725 SISLANDS_SMC_SWSTATE *smc_state)
5727 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
5728 struct ni_power_info *ni_pi = ni_get_pi(adev);
5729 struct si_power_info *si_pi = si_get_pi(adev);
5730 struct si_ps *state = si_get_ps(amdgpu_state);
5733 u32 sclk_in_sr = 1350; /* ??? */
5735 if (state->performance_level_count > SISLANDS_MAX_HARDWARE_POWERLEVELS)
5738 threshold = state->performance_levels[state->performance_level_count-1].sclk * 100 / 100;
5740 if (amdgpu_state->vclk && amdgpu_state->dclk) {
5741 eg_pi->uvd_enabled = true;
5742 if (eg_pi->smu_uvd_hs)
5743 smc_state->flags |= PPSMC_SWSTATE_FLAG_UVD;
5745 eg_pi->uvd_enabled = false;
5748 if (state->dc_compatible)
5749 smc_state->flags |= PPSMC_SWSTATE_FLAG_DC;
5751 smc_state->levelCount = 0;
5752 for (i = 0; i < state->performance_level_count; i++) {
5753 if (eg_pi->sclk_deep_sleep) {
5754 if ((i == 0) || si_pi->sclk_deep_sleep_above_low) {
5755 if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ)
5756 smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS;
5758 smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE;
5762 ret = si_convert_power_level_to_smc(adev, &state->performance_levels[i],
5763 &smc_state->levels[i]);
5764 smc_state->levels[i].arbRefreshState =
5765 (u8)(SISLANDS_DRIVER_STATE_ARB_INDEX + i);
5770 if (ni_pi->enable_power_containment)
5771 smc_state->levels[i].displayWatermark =
5772 (state->performance_levels[i].sclk < threshold) ?
5773 PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH;
5775 smc_state->levels[i].displayWatermark = (i < 2) ?
5776 PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH;
5778 if (eg_pi->dynamic_ac_timing)
5779 smc_state->levels[i].ACIndex = SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i;
5781 smc_state->levels[i].ACIndex = 0;
5783 smc_state->levelCount++;
5786 si_write_smc_soft_register(adev,
5787 SI_SMC_SOFT_REGISTER_watermark_threshold,
5790 si_populate_smc_sp(adev, amdgpu_state, smc_state);
5792 ret = si_populate_power_containment_values(adev, amdgpu_state, smc_state);
5794 ni_pi->enable_power_containment = false;
5796 ret = si_populate_sq_ramping_values(adev, amdgpu_state, smc_state);
5798 ni_pi->enable_sq_ramping = false;
5800 return si_populate_smc_t(adev, amdgpu_state, smc_state);
5803 static int si_upload_sw_state(struct amdgpu_device *adev,
5804 struct amdgpu_ps *amdgpu_new_state)
5806 struct si_power_info *si_pi = si_get_pi(adev);
5807 struct si_ps *new_state = si_get_ps(amdgpu_new_state);
5809 u32 address = si_pi->state_table_start +
5810 offsetof(SISLANDS_SMC_STATETABLE, driverState);
5811 u32 state_size = sizeof(SISLANDS_SMC_SWSTATE) +
5812 ((new_state->performance_level_count - 1) *
5813 sizeof(SISLANDS_SMC_HW_PERFORMANCE_LEVEL));
5814 SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.driverState;
5816 memset(smc_state, 0, state_size);
5818 ret = si_convert_power_state_to_smc(adev, amdgpu_new_state, smc_state);
5822 return amdgpu_si_copy_bytes_to_smc(adev, address, (u8 *)smc_state,
5823 state_size, si_pi->sram_end);
5826 static int si_upload_ulv_state(struct amdgpu_device *adev)
5828 struct si_power_info *si_pi = si_get_pi(adev);
5829 struct si_ulv_param *ulv = &si_pi->ulv;
5832 if (ulv->supported && ulv->pl.vddc) {
5833 u32 address = si_pi->state_table_start +
5834 offsetof(SISLANDS_SMC_STATETABLE, ULVState);
5835 SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.ULVState;
5836 u32 state_size = sizeof(SISLANDS_SMC_SWSTATE);
5838 memset(smc_state, 0, state_size);
5840 ret = si_populate_ulv_state(adev, smc_state);
5842 ret = amdgpu_si_copy_bytes_to_smc(adev, address, (u8 *)smc_state,
5843 state_size, si_pi->sram_end);
5849 static int si_upload_smc_data(struct amdgpu_device *adev)
5851 struct amdgpu_crtc *amdgpu_crtc = NULL;
5854 if (adev->pm.dpm.new_active_crtc_count == 0)
5857 for (i = 0; i < adev->mode_info.num_crtc; i++) {
5858 if (adev->pm.dpm.new_active_crtcs & (1 << i)) {
5859 amdgpu_crtc = adev->mode_info.crtcs[i];
5864 if (amdgpu_crtc == NULL)
5867 if (amdgpu_crtc->line_time <= 0)
5870 if (si_write_smc_soft_register(adev,
5871 SI_SMC_SOFT_REGISTER_crtc_index,
5872 amdgpu_crtc->crtc_id) != PPSMC_Result_OK)
5875 if (si_write_smc_soft_register(adev,
5876 SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
5877 amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK)
5880 if (si_write_smc_soft_register(adev,
5881 SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
5882 amdgpu_crtc->wm_low / amdgpu_crtc->line_time) != PPSMC_Result_OK)
5888 static int si_set_mc_special_registers(struct amdgpu_device *adev,
5889 struct si_mc_reg_table *table)
5894 for (i = 0, j = table->last; i < table->last; i++) {
5895 if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5897 switch (table->mc_reg_address[i].s1) {
5899 temp_reg = RREG32(MC_PMG_CMD_EMRS);
5900 table->mc_reg_address[j].s1 = MC_PMG_CMD_EMRS;
5901 table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_EMRS_LP;
5902 for (k = 0; k < table->num_entries; k++)
5903 table->mc_reg_table_entry[k].mc_data[j] =
5904 ((temp_reg & 0xffff0000)) |
5905 ((table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16);
5907 if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5910 temp_reg = RREG32(MC_PMG_CMD_MRS);
5911 table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS;
5912 table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS_LP;
5913 for (k = 0; k < table->num_entries; k++) {
5914 table->mc_reg_table_entry[k].mc_data[j] =
5915 (temp_reg & 0xffff0000) |
5916 (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
5917 if (adev->mc.vram_type != AMDGPU_VRAM_TYPE_GDDR5)
5918 table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
5921 if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5924 if (adev->mc.vram_type != AMDGPU_VRAM_TYPE_GDDR5) {
5925 table->mc_reg_address[j].s1 = MC_PMG_AUTO_CMD;
5926 table->mc_reg_address[j].s0 = MC_PMG_AUTO_CMD;
5927 for (k = 0; k < table->num_entries; k++)
5928 table->mc_reg_table_entry[k].mc_data[j] =
5929 (table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16;
5931 if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5935 case MC_SEQ_RESERVE_M:
5936 temp_reg = RREG32(MC_PMG_CMD_MRS1);
5937 table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1;
5938 table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP;
5939 for(k = 0; k < table->num_entries; k++)
5940 table->mc_reg_table_entry[k].mc_data[j] =
5941 (temp_reg & 0xffff0000) |
5942 (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
5944 if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5957 static bool si_check_s0_mc_reg_index(u16 in_reg, u16 *out_reg)
5961 case MC_SEQ_RAS_TIMING:
5962 *out_reg = MC_SEQ_RAS_TIMING_LP;
5964 case MC_SEQ_CAS_TIMING:
5965 *out_reg = MC_SEQ_CAS_TIMING_LP;
5967 case MC_SEQ_MISC_TIMING:
5968 *out_reg = MC_SEQ_MISC_TIMING_LP;
5970 case MC_SEQ_MISC_TIMING2:
5971 *out_reg = MC_SEQ_MISC_TIMING2_LP;
5973 case MC_SEQ_RD_CTL_D0:
5974 *out_reg = MC_SEQ_RD_CTL_D0_LP;
5976 case MC_SEQ_RD_CTL_D1:
5977 *out_reg = MC_SEQ_RD_CTL_D1_LP;
5979 case MC_SEQ_WR_CTL_D0:
5980 *out_reg = MC_SEQ_WR_CTL_D0_LP;
5982 case MC_SEQ_WR_CTL_D1:
5983 *out_reg = MC_SEQ_WR_CTL_D1_LP;
5985 case MC_PMG_CMD_EMRS:
5986 *out_reg = MC_SEQ_PMG_CMD_EMRS_LP;
5988 case MC_PMG_CMD_MRS:
5989 *out_reg = MC_SEQ_PMG_CMD_MRS_LP;
5991 case MC_PMG_CMD_MRS1:
5992 *out_reg = MC_SEQ_PMG_CMD_MRS1_LP;
5994 case MC_SEQ_PMG_TIMING:
5995 *out_reg = MC_SEQ_PMG_TIMING_LP;
5997 case MC_PMG_CMD_MRS2:
5998 *out_reg = MC_SEQ_PMG_CMD_MRS2_LP;
6000 case MC_SEQ_WR_CTL_2:
6001 *out_reg = MC_SEQ_WR_CTL_2_LP;
6011 static void si_set_valid_flag(struct si_mc_reg_table *table)
6015 for (i = 0; i < table->last; i++) {
6016 for (j = 1; j < table->num_entries; j++) {
6017 if (table->mc_reg_table_entry[j-1].mc_data[i] != table->mc_reg_table_entry[j].mc_data[i]) {
6018 table->valid_flag |= 1 << i;
6025 static void si_set_s0_mc_reg_index(struct si_mc_reg_table *table)
6030 for (i = 0; i < table->last; i++)
6031 table->mc_reg_address[i].s0 = si_check_s0_mc_reg_index(table->mc_reg_address[i].s1, &address) ?
6032 address : table->mc_reg_address[i].s1;
6036 static int si_copy_vbios_mc_reg_table(struct atom_mc_reg_table *table,
6037 struct si_mc_reg_table *si_table)
6041 if (table->last > SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
6043 if (table->num_entries > MAX_AC_TIMING_ENTRIES)
6046 for (i = 0; i < table->last; i++)
6047 si_table->mc_reg_address[i].s1 = table->mc_reg_address[i].s1;
6048 si_table->last = table->last;
6050 for (i = 0; i < table->num_entries; i++) {
6051 si_table->mc_reg_table_entry[i].mclk_max =
6052 table->mc_reg_table_entry[i].mclk_max;
6053 for (j = 0; j < table->last; j++) {
6054 si_table->mc_reg_table_entry[i].mc_data[j] =
6055 table->mc_reg_table_entry[i].mc_data[j];
6058 si_table->num_entries = table->num_entries;
6063 static int si_initialize_mc_reg_table(struct amdgpu_device *adev)
6065 struct si_power_info *si_pi = si_get_pi(adev);
6066 struct atom_mc_reg_table *table;
6067 struct si_mc_reg_table *si_table = &si_pi->mc_reg_table;
6068 u8 module_index = rv770_get_memory_module_index(adev);
6071 table = kzalloc(sizeof(struct atom_mc_reg_table), GFP_KERNEL);
6075 WREG32(MC_SEQ_RAS_TIMING_LP, RREG32(MC_SEQ_RAS_TIMING));
6076 WREG32(MC_SEQ_CAS_TIMING_LP, RREG32(MC_SEQ_CAS_TIMING));
6077 WREG32(MC_SEQ_MISC_TIMING_LP, RREG32(MC_SEQ_MISC_TIMING));
6078 WREG32(MC_SEQ_MISC_TIMING2_LP, RREG32(MC_SEQ_MISC_TIMING2));
6079 WREG32(MC_SEQ_PMG_CMD_EMRS_LP, RREG32(MC_PMG_CMD_EMRS));
6080 WREG32(MC_SEQ_PMG_CMD_MRS_LP, RREG32(MC_PMG_CMD_MRS));
6081 WREG32(MC_SEQ_PMG_CMD_MRS1_LP, RREG32(MC_PMG_CMD_MRS1));
6082 WREG32(MC_SEQ_WR_CTL_D0_LP, RREG32(MC_SEQ_WR_CTL_D0));
6083 WREG32(MC_SEQ_WR_CTL_D1_LP, RREG32(MC_SEQ_WR_CTL_D1));
6084 WREG32(MC_SEQ_RD_CTL_D0_LP, RREG32(MC_SEQ_RD_CTL_D0));
6085 WREG32(MC_SEQ_RD_CTL_D1_LP, RREG32(MC_SEQ_RD_CTL_D1));
6086 WREG32(MC_SEQ_PMG_TIMING_LP, RREG32(MC_SEQ_PMG_TIMING));
6087 WREG32(MC_SEQ_PMG_CMD_MRS2_LP, RREG32(MC_PMG_CMD_MRS2));
6088 WREG32(MC_SEQ_WR_CTL_2_LP, RREG32(MC_SEQ_WR_CTL_2));
6090 ret = amdgpu_atombios_init_mc_reg_table(adev, module_index, table);
6094 ret = si_copy_vbios_mc_reg_table(table, si_table);
6098 si_set_s0_mc_reg_index(si_table);
6100 ret = si_set_mc_special_registers(adev, si_table);
6104 si_set_valid_flag(si_table);
6113 static void si_populate_mc_reg_addresses(struct amdgpu_device *adev,
6114 SMC_SIslands_MCRegisters *mc_reg_table)
6116 struct si_power_info *si_pi = si_get_pi(adev);
6119 for (i = 0, j = 0; j < si_pi->mc_reg_table.last; j++) {
6120 if (si_pi->mc_reg_table.valid_flag & (1 << j)) {
6121 if (i >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
6123 mc_reg_table->address[i].s0 =
6124 cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s0);
6125 mc_reg_table->address[i].s1 =
6126 cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s1);
6130 mc_reg_table->last = (u8)i;
6133 static void si_convert_mc_registers(const struct si_mc_reg_entry *entry,
6134 SMC_SIslands_MCRegisterSet *data,
6135 u32 num_entries, u32 valid_flag)
6139 for(i = 0, j = 0; j < num_entries; j++) {
6140 if (valid_flag & (1 << j)) {
6141 data->value[i] = cpu_to_be32(entry->mc_data[j]);
6147 static void si_convert_mc_reg_table_entry_to_smc(struct amdgpu_device *adev,
6148 struct rv7xx_pl *pl,
6149 SMC_SIslands_MCRegisterSet *mc_reg_table_data)
6151 struct si_power_info *si_pi = si_get_pi(adev);
6154 for (i = 0; i < si_pi->mc_reg_table.num_entries; i++) {
6155 if (pl->mclk <= si_pi->mc_reg_table.mc_reg_table_entry[i].mclk_max)
6159 if ((i == si_pi->mc_reg_table.num_entries) && (i > 0))
6162 si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[i],
6163 mc_reg_table_data, si_pi->mc_reg_table.last,
6164 si_pi->mc_reg_table.valid_flag);
6167 static void si_convert_mc_reg_table_to_smc(struct amdgpu_device *adev,
6168 struct amdgpu_ps *amdgpu_state,
6169 SMC_SIslands_MCRegisters *mc_reg_table)
6171 struct si_ps *state = si_get_ps(amdgpu_state);
6174 for (i = 0; i < state->performance_level_count; i++) {
6175 si_convert_mc_reg_table_entry_to_smc(adev,
6176 &state->performance_levels[i],
6177 &mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i]);
6181 static int si_populate_mc_reg_table(struct amdgpu_device *adev,
6182 struct amdgpu_ps *amdgpu_boot_state)
6184 struct si_ps *boot_state = si_get_ps(amdgpu_boot_state);
6185 struct si_power_info *si_pi = si_get_pi(adev);
6186 struct si_ulv_param *ulv = &si_pi->ulv;
6187 SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table;
6189 memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters));
6191 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_seq_index, 1);
6193 si_populate_mc_reg_addresses(adev, smc_mc_reg_table);
6195 si_convert_mc_reg_table_entry_to_smc(adev, &boot_state->performance_levels[0],
6196 &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_INITIAL_SLOT]);
6198 si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0],
6199 &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ACPI_SLOT],
6200 si_pi->mc_reg_table.last,
6201 si_pi->mc_reg_table.valid_flag);
6203 if (ulv->supported && ulv->pl.vddc != 0)
6204 si_convert_mc_reg_table_entry_to_smc(adev, &ulv->pl,
6205 &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT]);
6207 si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0],
6208 &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT],
6209 si_pi->mc_reg_table.last,
6210 si_pi->mc_reg_table.valid_flag);
6212 si_convert_mc_reg_table_to_smc(adev, amdgpu_boot_state, smc_mc_reg_table);
6214 return amdgpu_si_copy_bytes_to_smc(adev, si_pi->mc_reg_table_start,
6215 (u8 *)smc_mc_reg_table,
6216 sizeof(SMC_SIslands_MCRegisters), si_pi->sram_end);
6219 static int si_upload_mc_reg_table(struct amdgpu_device *adev,
6220 struct amdgpu_ps *amdgpu_new_state)
6222 struct si_ps *new_state = si_get_ps(amdgpu_new_state);
6223 struct si_power_info *si_pi = si_get_pi(adev);
6224 u32 address = si_pi->mc_reg_table_start +
6225 offsetof(SMC_SIslands_MCRegisters,
6226 data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT]);
6227 SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table;
6229 memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters));
6231 si_convert_mc_reg_table_to_smc(adev, amdgpu_new_state, smc_mc_reg_table);
6233 return amdgpu_si_copy_bytes_to_smc(adev, address,
6234 (u8 *)&smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT],
6235 sizeof(SMC_SIslands_MCRegisterSet) * new_state->performance_level_count,
6239 static void si_enable_voltage_control(struct amdgpu_device *adev, bool enable)
6242 WREG32_P(GENERAL_PWRMGT, VOLT_PWRMGT_EN, ~VOLT_PWRMGT_EN);
6244 WREG32_P(GENERAL_PWRMGT, 0, ~VOLT_PWRMGT_EN);
6247 static enum amdgpu_pcie_gen si_get_maximum_link_speed(struct amdgpu_device *adev,
6248 struct amdgpu_ps *amdgpu_state)
6250 struct si_ps *state = si_get_ps(amdgpu_state);
6252 u16 pcie_speed, max_speed = 0;
6254 for (i = 0; i < state->performance_level_count; i++) {
6255 pcie_speed = state->performance_levels[i].pcie_gen;
6256 if (max_speed < pcie_speed)
6257 max_speed = pcie_speed;
6262 static u16 si_get_current_pcie_speed(struct amdgpu_device *adev)
6266 speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL) & LC_CURRENT_DATA_RATE_MASK;
6267 speed_cntl >>= LC_CURRENT_DATA_RATE_SHIFT;
6269 return (u16)speed_cntl;
6272 static void si_request_link_speed_change_before_state_change(struct amdgpu_device *adev,
6273 struct amdgpu_ps *amdgpu_new_state,
6274 struct amdgpu_ps *amdgpu_current_state)
6276 struct si_power_info *si_pi = si_get_pi(adev);
6277 enum amdgpu_pcie_gen target_link_speed = si_get_maximum_link_speed(adev, amdgpu_new_state);
6278 enum amdgpu_pcie_gen current_link_speed;
6280 if (si_pi->force_pcie_gen == AMDGPU_PCIE_GEN_INVALID)
6281 current_link_speed = si_get_maximum_link_speed(adev, amdgpu_current_state);
6283 current_link_speed = si_pi->force_pcie_gen;
6285 si_pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID;
6286 si_pi->pspp_notify_required = false;
6287 if (target_link_speed > current_link_speed) {
6288 switch (target_link_speed) {
6289 #if defined(CONFIG_ACPI)
6290 case AMDGPU_PCIE_GEN3:
6291 if (amdgpu_acpi_pcie_performance_request(adev, PCIE_PERF_REQ_PECI_GEN3, false) == 0)
6293 si_pi->force_pcie_gen = AMDGPU_PCIE_GEN2;
6294 if (current_link_speed == AMDGPU_PCIE_GEN2)
6296 case AMDGPU_PCIE_GEN2:
6297 if (amdgpu_acpi_pcie_performance_request(adev, PCIE_PERF_REQ_PECI_GEN2, false) == 0)
6301 si_pi->force_pcie_gen = si_get_current_pcie_speed(adev);
6305 if (target_link_speed < current_link_speed)
6306 si_pi->pspp_notify_required = true;
6310 static void si_notify_link_speed_change_after_state_change(struct amdgpu_device *adev,
6311 struct amdgpu_ps *amdgpu_new_state,
6312 struct amdgpu_ps *amdgpu_current_state)
6314 struct si_power_info *si_pi = si_get_pi(adev);
6315 enum amdgpu_pcie_gen target_link_speed = si_get_maximum_link_speed(adev, amdgpu_new_state);
6318 if (si_pi->pspp_notify_required) {
6319 if (target_link_speed == AMDGPU_PCIE_GEN3)
6320 request = PCIE_PERF_REQ_PECI_GEN3;
6321 else if (target_link_speed == AMDGPU_PCIE_GEN2)
6322 request = PCIE_PERF_REQ_PECI_GEN2;
6324 request = PCIE_PERF_REQ_PECI_GEN1;
6326 if ((request == PCIE_PERF_REQ_PECI_GEN1) &&
6327 (si_get_current_pcie_speed(adev) > 0))
6330 #if defined(CONFIG_ACPI)
6331 amdgpu_acpi_pcie_performance_request(adev, request, false);
6337 static int si_ds_request(struct amdgpu_device *adev,
6338 bool ds_status_on, u32 count_write)
6340 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
6342 if (eg_pi->sclk_deep_sleep) {
6344 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_CancelThrottleOVRDSCLKDS) ==
6348 return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_ThrottleOVRDSCLKDS) ==
6349 PPSMC_Result_OK) ? 0 : -EINVAL;
6355 static void si_set_max_cu_value(struct amdgpu_device *adev)
6357 struct si_power_info *si_pi = si_get_pi(adev);
6359 if (adev->asic_type == CHIP_VERDE) {
6360 switch (adev->pdev->device) {
6396 static int si_patch_single_dependency_table_based_on_leakage(struct amdgpu_device *adev,
6397 struct amdgpu_clock_voltage_dependency_table *table)
6401 u16 leakage_voltage;
6404 for (i = 0; i < table->count; i++) {
6405 switch (si_get_leakage_voltage_from_leakage_index(adev,
6406 table->entries[i].v,
6407 &leakage_voltage)) {
6409 table->entries[i].v = leakage_voltage;
6419 for (j = (table->count - 2); j >= 0; j--) {
6420 table->entries[j].v = (table->entries[j].v <= table->entries[j + 1].v) ?
6421 table->entries[j].v : table->entries[j + 1].v;
6427 static int si_patch_dependency_tables_based_on_leakage(struct amdgpu_device *adev)
6431 ret = si_patch_single_dependency_table_based_on_leakage(adev,
6432 &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk);
6434 DRM_ERROR("Could not patch vddc_on_sclk leakage table\n");
6435 ret = si_patch_single_dependency_table_based_on_leakage(adev,
6436 &adev->pm.dpm.dyn_state.vddc_dependency_on_mclk);
6438 DRM_ERROR("Could not patch vddc_on_mclk leakage table\n");
6439 ret = si_patch_single_dependency_table_based_on_leakage(adev,
6440 &adev->pm.dpm.dyn_state.vddci_dependency_on_mclk);
6442 DRM_ERROR("Could not patch vddci_on_mclk leakage table\n");
6446 static void si_set_pcie_lane_width_in_smc(struct amdgpu_device *adev,
6447 struct amdgpu_ps *amdgpu_new_state,
6448 struct amdgpu_ps *amdgpu_current_state)
6451 u32 new_lane_width =
6452 (amdgpu_new_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT;
6453 u32 current_lane_width =
6454 (amdgpu_current_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT;
6456 if (new_lane_width != current_lane_width) {
6457 amdgpu_set_pcie_lanes(adev, new_lane_width);
6458 lane_width = amdgpu_get_pcie_lanes(adev);
6459 si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width);
6463 static void si_dpm_setup_asic(struct amdgpu_device *adev)
6465 si_read_clock_registers(adev);
6466 si_enable_acpi_power_management(adev);
6469 static int si_thermal_enable_alert(struct amdgpu_device *adev,
6472 u32 thermal_int = RREG32(CG_THERMAL_INT);
6475 PPSMC_Result result;
6477 thermal_int &= ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW);
6478 WREG32(CG_THERMAL_INT, thermal_int);
6479 result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableThermalInterrupt);
6480 if (result != PPSMC_Result_OK) {
6481 DRM_DEBUG_KMS("Could not enable thermal interrupts.\n");
6485 thermal_int |= THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW;
6486 WREG32(CG_THERMAL_INT, thermal_int);
6492 static int si_thermal_set_temperature_range(struct amdgpu_device *adev,
6493 int min_temp, int max_temp)
6495 int low_temp = 0 * 1000;
6496 int high_temp = 255 * 1000;
6498 if (low_temp < min_temp)
6499 low_temp = min_temp;
6500 if (high_temp > max_temp)
6501 high_temp = max_temp;
6502 if (high_temp < low_temp) {
6503 DRM_ERROR("invalid thermal range: %d - %d\n", low_temp, high_temp);
6507 WREG32_P(CG_THERMAL_INT, DIG_THERM_INTH(high_temp / 1000), ~DIG_THERM_INTH_MASK);
6508 WREG32_P(CG_THERMAL_INT, DIG_THERM_INTL(low_temp / 1000), ~DIG_THERM_INTL_MASK);
6509 WREG32_P(CG_THERMAL_CTRL, DIG_THERM_DPM(high_temp / 1000), ~DIG_THERM_DPM_MASK);
6511 adev->pm.dpm.thermal.min_temp = low_temp;
6512 adev->pm.dpm.thermal.max_temp = high_temp;
6517 static void si_fan_ctrl_set_static_mode(struct amdgpu_device *adev, u32 mode)
6519 struct si_power_info *si_pi = si_get_pi(adev);
6522 if (si_pi->fan_ctrl_is_in_default_mode) {
6523 tmp = (RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK) >> FDO_PWM_MODE_SHIFT;
6524 si_pi->fan_ctrl_default_mode = tmp;
6525 tmp = (RREG32(CG_FDO_CTRL2) & TMIN_MASK) >> TMIN_SHIFT;
6527 si_pi->fan_ctrl_is_in_default_mode = false;
6530 tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK;
6532 WREG32(CG_FDO_CTRL2, tmp);
6534 tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK;
6535 tmp |= FDO_PWM_MODE(mode);
6536 WREG32(CG_FDO_CTRL2, tmp);
6539 static int si_thermal_setup_fan_table(struct amdgpu_device *adev)
6541 struct si_power_info *si_pi = si_get_pi(adev);
6542 PP_SIslands_FanTable fan_table = { FDO_MODE_HARDWARE };
6544 u32 t_diff1, t_diff2, pwm_diff1, pwm_diff2;
6545 u16 fdo_min, slope1, slope2;
6546 u32 reference_clock, tmp;
6550 if (!si_pi->fan_table_start) {
6551 adev->pm.dpm.fan.ucode_fan_control = false;
6555 duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
6558 adev->pm.dpm.fan.ucode_fan_control = false;
6562 tmp64 = (u64)adev->pm.dpm.fan.pwm_min * duty100;
6563 do_div(tmp64, 10000);
6564 fdo_min = (u16)tmp64;
6566 t_diff1 = adev->pm.dpm.fan.t_med - adev->pm.dpm.fan.t_min;
6567 t_diff2 = adev->pm.dpm.fan.t_high - adev->pm.dpm.fan.t_med;
6569 pwm_diff1 = adev->pm.dpm.fan.pwm_med - adev->pm.dpm.fan.pwm_min;
6570 pwm_diff2 = adev->pm.dpm.fan.pwm_high - adev->pm.dpm.fan.pwm_med;
6572 slope1 = (u16)((50 + ((16 * duty100 * pwm_diff1) / t_diff1)) / 100);
6573 slope2 = (u16)((50 + ((16 * duty100 * pwm_diff2) / t_diff2)) / 100);
6575 fan_table.temp_min = cpu_to_be16((50 + adev->pm.dpm.fan.t_min) / 100);
6576 fan_table.temp_med = cpu_to_be16((50 + adev->pm.dpm.fan.t_med) / 100);
6577 fan_table.temp_max = cpu_to_be16((50 + adev->pm.dpm.fan.t_max) / 100);
6578 fan_table.slope1 = cpu_to_be16(slope1);
6579 fan_table.slope2 = cpu_to_be16(slope2);
6580 fan_table.fdo_min = cpu_to_be16(fdo_min);
6581 fan_table.hys_down = cpu_to_be16(adev->pm.dpm.fan.t_hyst);
6582 fan_table.hys_up = cpu_to_be16(1);
6583 fan_table.hys_slope = cpu_to_be16(1);
6584 fan_table.temp_resp_lim = cpu_to_be16(5);
6585 reference_clock = amdgpu_asic_get_xclk(adev);
6587 fan_table.refresh_period = cpu_to_be32((adev->pm.dpm.fan.cycle_delay *
6588 reference_clock) / 1600);
6589 fan_table.fdo_max = cpu_to_be16((u16)duty100);
6591 tmp = (RREG32(CG_MULT_THERMAL_CTRL) & TEMP_SEL_MASK) >> TEMP_SEL_SHIFT;
6592 fan_table.temp_src = (uint8_t)tmp;
6594 ret = amdgpu_si_copy_bytes_to_smc(adev,
6595 si_pi->fan_table_start,
6601 DRM_ERROR("Failed to load fan table to the SMC.");
6602 adev->pm.dpm.fan.ucode_fan_control = false;
6608 static int si_fan_ctrl_start_smc_fan_control(struct amdgpu_device *adev)
6610 struct si_power_info *si_pi = si_get_pi(adev);
6613 ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_StartFanControl);
6614 if (ret == PPSMC_Result_OK) {
6615 si_pi->fan_is_controlled_by_smc = true;
6622 static int si_fan_ctrl_stop_smc_fan_control(struct amdgpu_device *adev)
6624 struct si_power_info *si_pi = si_get_pi(adev);
6627 ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_StopFanControl);
6629 if (ret == PPSMC_Result_OK) {
6630 si_pi->fan_is_controlled_by_smc = false;
6637 static int si_dpm_get_fan_speed_percent(struct amdgpu_device *adev,
6643 if (adev->pm.no_fan)
6646 duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
6647 duty = (RREG32(CG_THERMAL_STATUS) & FDO_PWM_DUTY_MASK) >> FDO_PWM_DUTY_SHIFT;
6652 tmp64 = (u64)duty * 100;
6653 do_div(tmp64, duty100);
6654 *speed = (u32)tmp64;
6662 static int si_dpm_set_fan_speed_percent(struct amdgpu_device *adev,
6665 struct si_power_info *si_pi = si_get_pi(adev);
6670 if (adev->pm.no_fan)
6673 if (si_pi->fan_is_controlled_by_smc)
6679 duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
6684 tmp64 = (u64)speed * duty100;
6688 tmp = RREG32(CG_FDO_CTRL0) & ~FDO_STATIC_DUTY_MASK;
6689 tmp |= FDO_STATIC_DUTY(duty);
6690 WREG32(CG_FDO_CTRL0, tmp);
6695 static void si_dpm_set_fan_control_mode(struct amdgpu_device *adev, u32 mode)
6698 /* stop auto-manage */
6699 if (adev->pm.dpm.fan.ucode_fan_control)
6700 si_fan_ctrl_stop_smc_fan_control(adev);
6701 si_fan_ctrl_set_static_mode(adev, mode);
6703 /* restart auto-manage */
6704 if (adev->pm.dpm.fan.ucode_fan_control)
6705 si_thermal_start_smc_fan_control(adev);
6707 si_fan_ctrl_set_default_mode(adev);
6711 static u32 si_dpm_get_fan_control_mode(struct amdgpu_device *adev)
6713 struct si_power_info *si_pi = si_get_pi(adev);
6716 if (si_pi->fan_is_controlled_by_smc)
6719 tmp = RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK;
6720 return (tmp >> FDO_PWM_MODE_SHIFT);
6724 static int si_fan_ctrl_get_fan_speed_rpm(struct amdgpu_device *adev,
6728 u32 xclk = amdgpu_asic_get_xclk(adev);
6730 if (adev->pm.no_fan)
6733 if (adev->pm.fan_pulses_per_revolution == 0)
6736 tach_period = (RREG32(CG_TACH_STATUS) & TACH_PERIOD_MASK) >> TACH_PERIOD_SHIFT;
6737 if (tach_period == 0)
6740 *speed = 60 * xclk * 10000 / tach_period;
6745 static int si_fan_ctrl_set_fan_speed_rpm(struct amdgpu_device *adev,
6748 u32 tach_period, tmp;
6749 u32 xclk = amdgpu_asic_get_xclk(adev);
6751 if (adev->pm.no_fan)
6754 if (adev->pm.fan_pulses_per_revolution == 0)
6757 if ((speed < adev->pm.fan_min_rpm) ||
6758 (speed > adev->pm.fan_max_rpm))
6761 if (adev->pm.dpm.fan.ucode_fan_control)
6762 si_fan_ctrl_stop_smc_fan_control(adev);
6764 tach_period = 60 * xclk * 10000 / (8 * speed);
6765 tmp = RREG32(CG_TACH_CTRL) & ~TARGET_PERIOD_MASK;
6766 tmp |= TARGET_PERIOD(tach_period);
6767 WREG32(CG_TACH_CTRL, tmp);
6769 si_fan_ctrl_set_static_mode(adev, FDO_PWM_MODE_STATIC_RPM);
6775 static void si_fan_ctrl_set_default_mode(struct amdgpu_device *adev)
6777 struct si_power_info *si_pi = si_get_pi(adev);
6780 if (!si_pi->fan_ctrl_is_in_default_mode) {
6781 tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK;
6782 tmp |= FDO_PWM_MODE(si_pi->fan_ctrl_default_mode);
6783 WREG32(CG_FDO_CTRL2, tmp);
6785 tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK;
6786 tmp |= TMIN(si_pi->t_min);
6787 WREG32(CG_FDO_CTRL2, tmp);
6788 si_pi->fan_ctrl_is_in_default_mode = true;
6792 static void si_thermal_start_smc_fan_control(struct amdgpu_device *adev)
6794 if (adev->pm.dpm.fan.ucode_fan_control) {
6795 si_fan_ctrl_start_smc_fan_control(adev);
6796 si_fan_ctrl_set_static_mode(adev, FDO_PWM_MODE_STATIC);
6800 static void si_thermal_initialize(struct amdgpu_device *adev)
6804 if (adev->pm.fan_pulses_per_revolution) {
6805 tmp = RREG32(CG_TACH_CTRL) & ~EDGE_PER_REV_MASK;
6806 tmp |= EDGE_PER_REV(adev->pm.fan_pulses_per_revolution -1);
6807 WREG32(CG_TACH_CTRL, tmp);
6810 tmp = RREG32(CG_FDO_CTRL2) & ~TACH_PWM_RESP_RATE_MASK;
6811 tmp |= TACH_PWM_RESP_RATE(0x28);
6812 WREG32(CG_FDO_CTRL2, tmp);
6815 static int si_thermal_start_thermal_controller(struct amdgpu_device *adev)
6819 si_thermal_initialize(adev);
6820 ret = si_thermal_set_temperature_range(adev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
6823 ret = si_thermal_enable_alert(adev, true);
6826 if (adev->pm.dpm.fan.ucode_fan_control) {
6827 ret = si_halt_smc(adev);
6830 ret = si_thermal_setup_fan_table(adev);
6833 ret = si_resume_smc(adev);
6836 si_thermal_start_smc_fan_control(adev);
6842 static void si_thermal_stop_thermal_controller(struct amdgpu_device *adev)
6844 if (!adev->pm.no_fan) {
6845 si_fan_ctrl_set_default_mode(adev);
6846 si_fan_ctrl_stop_smc_fan_control(adev);
6850 static int si_dpm_enable(struct amdgpu_device *adev)
6852 struct rv7xx_power_info *pi = rv770_get_pi(adev);
6853 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
6854 struct si_power_info *si_pi = si_get_pi(adev);
6855 struct amdgpu_ps *boot_ps = adev->pm.dpm.boot_ps;
6858 if (amdgpu_si_is_smc_running(adev))
6860 if (pi->voltage_control || si_pi->voltage_control_svi2)
6861 si_enable_voltage_control(adev, true);
6862 if (pi->mvdd_control)
6863 si_get_mvdd_configuration(adev);
6864 if (pi->voltage_control || si_pi->voltage_control_svi2) {
6865 ret = si_construct_voltage_tables(adev);
6867 DRM_ERROR("si_construct_voltage_tables failed\n");
6871 if (eg_pi->dynamic_ac_timing) {
6872 ret = si_initialize_mc_reg_table(adev);
6874 eg_pi->dynamic_ac_timing = false;
6877 si_enable_spread_spectrum(adev, true);
6878 if (pi->thermal_protection)
6879 si_enable_thermal_protection(adev, true);
6881 si_program_git(adev);
6882 si_program_tp(adev);
6883 si_program_tpp(adev);
6884 si_program_sstp(adev);
6885 si_enable_display_gap(adev);
6886 si_program_vc(adev);
6887 ret = si_upload_firmware(adev);
6889 DRM_ERROR("si_upload_firmware failed\n");
6892 ret = si_process_firmware_header(adev);
6894 DRM_ERROR("si_process_firmware_header failed\n");
6897 ret = si_initial_switch_from_arb_f0_to_f1(adev);
6899 DRM_ERROR("si_initial_switch_from_arb_f0_to_f1 failed\n");
6902 ret = si_init_smc_table(adev);
6904 DRM_ERROR("si_init_smc_table failed\n");
6907 ret = si_init_smc_spll_table(adev);
6909 DRM_ERROR("si_init_smc_spll_table failed\n");
6912 ret = si_init_arb_table_index(adev);
6914 DRM_ERROR("si_init_arb_table_index failed\n");
6917 if (eg_pi->dynamic_ac_timing) {
6918 ret = si_populate_mc_reg_table(adev, boot_ps);
6920 DRM_ERROR("si_populate_mc_reg_table failed\n");
6924 ret = si_initialize_smc_cac_tables(adev);
6926 DRM_ERROR("si_initialize_smc_cac_tables failed\n");
6929 ret = si_initialize_hardware_cac_manager(adev);
6931 DRM_ERROR("si_initialize_hardware_cac_manager failed\n");
6934 ret = si_initialize_smc_dte_tables(adev);
6936 DRM_ERROR("si_initialize_smc_dte_tables failed\n");
6939 ret = si_populate_smc_tdp_limits(adev, boot_ps);
6941 DRM_ERROR("si_populate_smc_tdp_limits failed\n");
6944 ret = si_populate_smc_tdp_limits_2(adev, boot_ps);
6946 DRM_ERROR("si_populate_smc_tdp_limits_2 failed\n");
6949 si_program_response_times(adev);
6950 si_program_ds_registers(adev);
6951 si_dpm_start_smc(adev);
6952 ret = si_notify_smc_display_change(adev, false);
6954 DRM_ERROR("si_notify_smc_display_change failed\n");
6957 si_enable_sclk_control(adev, true);
6960 si_enable_auto_throttle_source(adev, AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
6961 si_thermal_start_thermal_controller(adev);
6962 ni_update_current_ps(adev, boot_ps);
6967 static int si_set_temperature_range(struct amdgpu_device *adev)
6971 ret = si_thermal_enable_alert(adev, false);
6974 ret = si_thermal_set_temperature_range(adev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
6977 ret = si_thermal_enable_alert(adev, true);
6984 static void si_dpm_disable(struct amdgpu_device *adev)
6986 struct rv7xx_power_info *pi = rv770_get_pi(adev);
6987 struct amdgpu_ps *boot_ps = adev->pm.dpm.boot_ps;
6989 if (!amdgpu_si_is_smc_running(adev))
6991 si_thermal_stop_thermal_controller(adev);
6992 si_disable_ulv(adev);
6994 if (pi->thermal_protection)
6995 si_enable_thermal_protection(adev, false);
6996 si_enable_power_containment(adev, boot_ps, false);
6997 si_enable_smc_cac(adev, boot_ps, false);
6998 si_enable_spread_spectrum(adev, false);
6999 si_enable_auto_throttle_source(adev, AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, false);
7001 si_reset_to_default(adev);
7002 si_dpm_stop_smc(adev);
7003 si_force_switch_to_arb_f0(adev);
7005 ni_update_current_ps(adev, boot_ps);
7008 static int si_dpm_pre_set_power_state(struct amdgpu_device *adev)
7010 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7011 struct amdgpu_ps requested_ps = *adev->pm.dpm.requested_ps;
7012 struct amdgpu_ps *new_ps = &requested_ps;
7014 ni_update_requested_ps(adev, new_ps);
7015 si_apply_state_adjust_rules(adev, &eg_pi->requested_rps);
7020 static int si_power_control_set_level(struct amdgpu_device *adev)
7022 struct amdgpu_ps *new_ps = adev->pm.dpm.requested_ps;
7025 ret = si_restrict_performance_levels_before_switch(adev);
7028 ret = si_halt_smc(adev);
7031 ret = si_populate_smc_tdp_limits(adev, new_ps);
7034 ret = si_populate_smc_tdp_limits_2(adev, new_ps);
7037 ret = si_resume_smc(adev);
7040 ret = si_set_sw_state(adev);
7046 static int si_dpm_set_power_state(struct amdgpu_device *adev)
7048 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7049 struct amdgpu_ps *new_ps = &eg_pi->requested_rps;
7050 struct amdgpu_ps *old_ps = &eg_pi->current_rps;
7053 ret = si_disable_ulv(adev);
7055 DRM_ERROR("si_disable_ulv failed\n");
7058 ret = si_restrict_performance_levels_before_switch(adev);
7060 DRM_ERROR("si_restrict_performance_levels_before_switch failed\n");
7063 if (eg_pi->pcie_performance_request)
7064 si_request_link_speed_change_before_state_change(adev, new_ps, old_ps);
7065 ni_set_uvd_clock_before_set_eng_clock(adev, new_ps, old_ps);
7066 ret = si_enable_power_containment(adev, new_ps, false);
7068 DRM_ERROR("si_enable_power_containment failed\n");
7071 ret = si_enable_smc_cac(adev, new_ps, false);
7073 DRM_ERROR("si_enable_smc_cac failed\n");
7076 ret = si_halt_smc(adev);
7078 DRM_ERROR("si_halt_smc failed\n");
7081 ret = si_upload_sw_state(adev, new_ps);
7083 DRM_ERROR("si_upload_sw_state failed\n");
7086 ret = si_upload_smc_data(adev);
7088 DRM_ERROR("si_upload_smc_data failed\n");
7091 ret = si_upload_ulv_state(adev);
7093 DRM_ERROR("si_upload_ulv_state failed\n");
7096 if (eg_pi->dynamic_ac_timing) {
7097 ret = si_upload_mc_reg_table(adev, new_ps);
7099 DRM_ERROR("si_upload_mc_reg_table failed\n");
7103 ret = si_program_memory_timing_parameters(adev, new_ps);
7105 DRM_ERROR("si_program_memory_timing_parameters failed\n");
7108 si_set_pcie_lane_width_in_smc(adev, new_ps, old_ps);
7110 ret = si_resume_smc(adev);
7112 DRM_ERROR("si_resume_smc failed\n");
7115 ret = si_set_sw_state(adev);
7117 DRM_ERROR("si_set_sw_state failed\n");
7120 ni_set_uvd_clock_after_set_eng_clock(adev, new_ps, old_ps);
7121 if (eg_pi->pcie_performance_request)
7122 si_notify_link_speed_change_after_state_change(adev, new_ps, old_ps);
7123 ret = si_set_power_state_conditionally_enable_ulv(adev, new_ps);
7125 DRM_ERROR("si_set_power_state_conditionally_enable_ulv failed\n");
7128 ret = si_enable_smc_cac(adev, new_ps, true);
7130 DRM_ERROR("si_enable_smc_cac failed\n");
7133 ret = si_enable_power_containment(adev, new_ps, true);
7135 DRM_ERROR("si_enable_power_containment failed\n");
7139 ret = si_power_control_set_level(adev);
7141 DRM_ERROR("si_power_control_set_level failed\n");
7148 static void si_dpm_post_set_power_state(struct amdgpu_device *adev)
7150 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7151 struct amdgpu_ps *new_ps = &eg_pi->requested_rps;
7153 ni_update_current_ps(adev, new_ps);
7157 void si_dpm_reset_asic(struct amdgpu_device *adev)
7159 si_restrict_performance_levels_before_switch(adev);
7160 si_disable_ulv(adev);
7161 si_set_boot_state(adev);
7165 static void si_dpm_display_configuration_changed(struct amdgpu_device *adev)
7167 si_program_display_gap(adev);
7171 static void si_parse_pplib_non_clock_info(struct amdgpu_device *adev,
7172 struct amdgpu_ps *rps,
7173 struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info,
7176 rps->caps = le32_to_cpu(non_clock_info->ulCapsAndSettings);
7177 rps->class = le16_to_cpu(non_clock_info->usClassification);
7178 rps->class2 = le16_to_cpu(non_clock_info->usClassification2);
7180 if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) {
7181 rps->vclk = le32_to_cpu(non_clock_info->ulVCLK);
7182 rps->dclk = le32_to_cpu(non_clock_info->ulDCLK);
7183 } else if (r600_is_uvd_state(rps->class, rps->class2)) {
7184 rps->vclk = RV770_DEFAULT_VCLK_FREQ;
7185 rps->dclk = RV770_DEFAULT_DCLK_FREQ;
7191 if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT)
7192 adev->pm.dpm.boot_ps = rps;
7193 if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE)
7194 adev->pm.dpm.uvd_ps = rps;
7197 static void si_parse_pplib_clock_info(struct amdgpu_device *adev,
7198 struct amdgpu_ps *rps, int index,
7199 union pplib_clock_info *clock_info)
7201 struct rv7xx_power_info *pi = rv770_get_pi(adev);
7202 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7203 struct si_power_info *si_pi = si_get_pi(adev);
7204 struct si_ps *ps = si_get_ps(rps);
7205 u16 leakage_voltage;
7206 struct rv7xx_pl *pl = &ps->performance_levels[index];
7209 ps->performance_level_count = index + 1;
7211 pl->sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
7212 pl->sclk |= clock_info->si.ucEngineClockHigh << 16;
7213 pl->mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
7214 pl->mclk |= clock_info->si.ucMemoryClockHigh << 16;
7216 pl->vddc = le16_to_cpu(clock_info->si.usVDDC);
7217 pl->vddci = le16_to_cpu(clock_info->si.usVDDCI);
7218 pl->flags = le32_to_cpu(clock_info->si.ulFlags);
7219 pl->pcie_gen = r600_get_pcie_gen_support(adev,
7220 si_pi->sys_pcie_mask,
7221 si_pi->boot_pcie_gen,
7222 clock_info->si.ucPCIEGen);
7224 /* patch up vddc if necessary */
7225 ret = si_get_leakage_voltage_from_leakage_index(adev, pl->vddc,
7228 pl->vddc = leakage_voltage;
7230 if (rps->class & ATOM_PPLIB_CLASSIFICATION_ACPI) {
7231 pi->acpi_vddc = pl->vddc;
7232 eg_pi->acpi_vddci = pl->vddci;
7233 si_pi->acpi_pcie_gen = pl->pcie_gen;
7236 if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) &&
7238 /* XXX disable for A0 tahiti */
7239 si_pi->ulv.supported = false;
7240 si_pi->ulv.pl = *pl;
7241 si_pi->ulv.one_pcie_lane_in_ulv = false;
7242 si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT;
7243 si_pi->ulv.cg_ulv_parameter = SISLANDS_CGULVPARAMETER_DFLT;
7244 si_pi->ulv.cg_ulv_control = SISLANDS_CGULVCONTROL_DFLT;
7247 if (pi->min_vddc_in_table > pl->vddc)
7248 pi->min_vddc_in_table = pl->vddc;
7250 if (pi->max_vddc_in_table < pl->vddc)
7251 pi->max_vddc_in_table = pl->vddc;
7253 /* patch up boot state */
7254 if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) {
7255 u16 vddc, vddci, mvdd;
7256 amdgpu_atombios_get_default_voltages(adev, &vddc, &vddci, &mvdd);
7257 pl->mclk = adev->clock.default_mclk;
7258 pl->sclk = adev->clock.default_sclk;
7261 si_pi->mvdd_bootup_value = mvdd;
7264 if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) ==
7265 ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE) {
7266 adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.sclk = pl->sclk;
7267 adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.mclk = pl->mclk;
7268 adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddc = pl->vddc;
7269 adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddci = pl->vddci;
7273 union pplib_power_state {
7274 struct _ATOM_PPLIB_STATE v1;
7275 struct _ATOM_PPLIB_STATE_V2 v2;
7278 static int si_parse_power_table(struct amdgpu_device *adev)
7280 struct amdgpu_mode_info *mode_info = &adev->mode_info;
7281 struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info;
7282 union pplib_power_state *power_state;
7283 int i, j, k, non_clock_array_index, clock_array_index;
7284 union pplib_clock_info *clock_info;
7285 struct _StateArray *state_array;
7286 struct _ClockInfoArray *clock_info_array;
7287 struct _NonClockInfoArray *non_clock_info_array;
7288 union power_info *power_info;
7289 int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
7292 u8 *power_state_offset;
7295 if (!amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL,
7296 &frev, &crev, &data_offset))
7298 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
7300 amdgpu_add_thermal_controller(adev);
7302 state_array = (struct _StateArray *)
7303 (mode_info->atom_context->bios + data_offset +
7304 le16_to_cpu(power_info->pplib.usStateArrayOffset));
7305 clock_info_array = (struct _ClockInfoArray *)
7306 (mode_info->atom_context->bios + data_offset +
7307 le16_to_cpu(power_info->pplib.usClockInfoArrayOffset));
7308 non_clock_info_array = (struct _NonClockInfoArray *)
7309 (mode_info->atom_context->bios + data_offset +
7310 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
7312 adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
7313 state_array->ucNumEntries, GFP_KERNEL);
7314 if (!adev->pm.dpm.ps)
7316 power_state_offset = (u8 *)state_array->states;
7317 for (i = 0; i < state_array->ucNumEntries; i++) {
7319 power_state = (union pplib_power_state *)power_state_offset;
7320 non_clock_array_index = power_state->v2.nonClockInfoIndex;
7321 non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
7322 &non_clock_info_array->nonClockInfo[non_clock_array_index];
7323 ps = kzalloc(sizeof(struct si_ps), GFP_KERNEL);
7325 kfree(adev->pm.dpm.ps);
7328 adev->pm.dpm.ps[i].ps_priv = ps;
7329 si_parse_pplib_non_clock_info(adev, &adev->pm.dpm.ps[i],
7331 non_clock_info_array->ucEntrySize);
7333 idx = (u8 *)&power_state->v2.clockInfoIndex[0];
7334 for (j = 0; j < power_state->v2.ucNumDPMLevels; j++) {
7335 clock_array_index = idx[j];
7336 if (clock_array_index >= clock_info_array->ucNumEntries)
7338 if (k >= SISLANDS_MAX_HARDWARE_POWERLEVELS)
7340 clock_info = (union pplib_clock_info *)
7341 ((u8 *)&clock_info_array->clockInfo[0] +
7342 (clock_array_index * clock_info_array->ucEntrySize));
7343 si_parse_pplib_clock_info(adev,
7344 &adev->pm.dpm.ps[i], k,
7348 power_state_offset += 2 + power_state->v2.ucNumDPMLevels;
7350 adev->pm.dpm.num_ps = state_array->ucNumEntries;
7352 /* fill in the vce power states */
7353 for (i = 0; i < adev->pm.dpm.num_of_vce_states; i++) {
7355 clock_array_index = adev->pm.dpm.vce_states[i].clk_idx;
7356 clock_info = (union pplib_clock_info *)
7357 &clock_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize];
7358 sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
7359 sclk |= clock_info->si.ucEngineClockHigh << 16;
7360 mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
7361 mclk |= clock_info->si.ucMemoryClockHigh << 16;
7362 adev->pm.dpm.vce_states[i].sclk = sclk;
7363 adev->pm.dpm.vce_states[i].mclk = mclk;
7369 static int si_dpm_init(struct amdgpu_device *adev)
7371 struct rv7xx_power_info *pi;
7372 struct evergreen_power_info *eg_pi;
7373 struct ni_power_info *ni_pi;
7374 struct si_power_info *si_pi;
7375 struct atom_clock_dividers dividers;
7379 si_pi = kzalloc(sizeof(struct si_power_info), GFP_KERNEL);
7382 adev->pm.dpm.priv = si_pi;
7387 ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask);
7389 si_pi->sys_pcie_mask = 0;
7391 si_pi->sys_pcie_mask = mask;
7392 si_pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID;
7393 si_pi->boot_pcie_gen = si_get_current_pcie_speed(adev);
7395 si_set_max_cu_value(adev);
7397 rv770_get_max_vddc(adev);
7398 si_get_leakage_vddc(adev);
7399 si_patch_dependency_tables_based_on_leakage(adev);
7402 eg_pi->acpi_vddci = 0;
7403 pi->min_vddc_in_table = 0;
7404 pi->max_vddc_in_table = 0;
7406 ret = amdgpu_get_platform_caps(adev);
7410 ret = amdgpu_parse_extended_power_table(adev);
7414 ret = si_parse_power_table(adev);
7418 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
7419 kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL);
7420 if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
7421 amdgpu_free_extended_power_table(adev);
7424 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
7425 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
7426 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;
7427 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].clk = 36000;
7428 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].v = 720;
7429 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].clk = 54000;
7430 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].v = 810;
7431 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000;
7432 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 900;
7434 if (adev->pm.dpm.voltage_response_time == 0)
7435 adev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT;
7436 if (adev->pm.dpm.backbias_response_time == 0)
7437 adev->pm.dpm.backbias_response_time = R600_BACKBIASRESPONSETIME_DFLT;
7439 ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_ENGINE_PLL_PARAM,
7440 0, false, ÷rs);
7442 pi->ref_div = dividers.ref_div + 1;
7444 pi->ref_div = R600_REFERENCEDIVIDER_DFLT;
7446 eg_pi->smu_uvd_hs = false;
7448 pi->mclk_strobe_mode_threshold = 40000;
7449 if (si_is_special_1gb_platform(adev))
7450 pi->mclk_stutter_mode_threshold = 0;
7452 pi->mclk_stutter_mode_threshold = pi->mclk_strobe_mode_threshold;
7453 pi->mclk_edc_enable_threshold = 40000;
7454 eg_pi->mclk_edc_wr_enable_threshold = 40000;
7456 ni_pi->mclk_rtt_mode_threshold = eg_pi->mclk_edc_wr_enable_threshold;
7458 pi->voltage_control =
7459 amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC,
7460 VOLTAGE_OBJ_GPIO_LUT);
7461 if (!pi->voltage_control) {
7462 si_pi->voltage_control_svi2 =
7463 amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC,
7465 if (si_pi->voltage_control_svi2)
7466 amdgpu_atombios_get_svi2_info(adev, SET_VOLTAGE_TYPE_ASIC_VDDC,
7467 &si_pi->svd_gpio_id, &si_pi->svc_gpio_id);
7471 amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_MVDDC,
7472 VOLTAGE_OBJ_GPIO_LUT);
7474 eg_pi->vddci_control =
7475 amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDCI,
7476 VOLTAGE_OBJ_GPIO_LUT);
7477 if (!eg_pi->vddci_control)
7478 si_pi->vddci_control_svi2 =
7479 amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDCI,
7482 si_pi->vddc_phase_shed_control =
7483 amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC,
7484 VOLTAGE_OBJ_PHASE_LUT);
7486 rv770_get_engine_memory_ss(adev);
7488 pi->asi = RV770_ASI_DFLT;
7489 pi->pasi = CYPRESS_HASI_DFLT;
7490 pi->vrc = SISLANDS_VRC_DFLT;
7492 pi->gfx_clock_gating = true;
7494 eg_pi->sclk_deep_sleep = true;
7495 si_pi->sclk_deep_sleep_above_low = false;
7497 if (adev->pm.int_thermal_type != THERMAL_TYPE_NONE)
7498 pi->thermal_protection = true;
7500 pi->thermal_protection = false;
7502 eg_pi->dynamic_ac_timing = true;
7504 eg_pi->light_sleep = true;
7505 #if defined(CONFIG_ACPI)
7506 eg_pi->pcie_performance_request =
7507 amdgpu_acpi_is_pcie_performance_request_supported(adev);
7509 eg_pi->pcie_performance_request = false;
7512 si_pi->sram_end = SMC_RAM_END;
7514 adev->pm.dpm.dyn_state.mclk_sclk_ratio = 4;
7515 adev->pm.dpm.dyn_state.sclk_mclk_delta = 15000;
7516 adev->pm.dpm.dyn_state.vddc_vddci_delta = 200;
7517 adev->pm.dpm.dyn_state.valid_sclk_values.count = 0;
7518 adev->pm.dpm.dyn_state.valid_sclk_values.values = NULL;
7519 adev->pm.dpm.dyn_state.valid_mclk_values.count = 0;
7520 adev->pm.dpm.dyn_state.valid_mclk_values.values = NULL;
7522 si_initialize_powertune_defaults(adev);
7524 /* make sure dc limits are valid */
7525 if ((adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) ||
7526 (adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0))
7527 adev->pm.dpm.dyn_state.max_clock_voltage_on_dc =
7528 adev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
7530 si_pi->fan_ctrl_is_in_default_mode = true;
7535 static void si_dpm_fini(struct amdgpu_device *adev)
7539 if (adev->pm.dpm.ps)
7540 for (i = 0; i < adev->pm.dpm.num_ps; i++)
7541 kfree(adev->pm.dpm.ps[i].ps_priv);
7542 kfree(adev->pm.dpm.ps);
7543 kfree(adev->pm.dpm.priv);
7544 kfree(adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries);
7545 amdgpu_free_extended_power_table(adev);
7548 static void si_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev,
7551 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7552 struct amdgpu_ps *rps = &eg_pi->current_rps;
7553 struct si_ps *ps = si_get_ps(rps);
7554 struct rv7xx_pl *pl;
7556 (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
7557 CURRENT_STATE_INDEX_SHIFT;
7559 if (current_index >= ps->performance_level_count) {
7560 seq_printf(m, "invalid dpm profile %d\n", current_index);
7562 pl = &ps->performance_levels[current_index];
7563 seq_printf(m, "uvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
7564 seq_printf(m, "power level %d sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n",
7565 current_index, pl->sclk, pl->mclk, pl->vddc, pl->vddci, pl->pcie_gen + 1);
7569 static int si_dpm_set_interrupt_state(struct amdgpu_device *adev,
7570 struct amdgpu_irq_src *source,
7572 enum amdgpu_interrupt_state state)
7577 case AMDGPU_THERMAL_IRQ_LOW_TO_HIGH:
7579 case AMDGPU_IRQ_STATE_DISABLE:
7580 cg_thermal_int = RREG32_SMC(CG_THERMAL_INT);
7581 cg_thermal_int |= THERM_INT_MASK_HIGH;
7582 WREG32_SMC(CG_THERMAL_INT, cg_thermal_int);
7584 case AMDGPU_IRQ_STATE_ENABLE:
7585 cg_thermal_int = RREG32_SMC(CG_THERMAL_INT);
7586 cg_thermal_int &= ~THERM_INT_MASK_HIGH;
7587 WREG32_SMC(CG_THERMAL_INT, cg_thermal_int);
7594 case AMDGPU_THERMAL_IRQ_HIGH_TO_LOW:
7596 case AMDGPU_IRQ_STATE_DISABLE:
7597 cg_thermal_int = RREG32_SMC(CG_THERMAL_INT);
7598 cg_thermal_int |= THERM_INT_MASK_LOW;
7599 WREG32_SMC(CG_THERMAL_INT, cg_thermal_int);
7601 case AMDGPU_IRQ_STATE_ENABLE:
7602 cg_thermal_int = RREG32_SMC(CG_THERMAL_INT);
7603 cg_thermal_int &= ~THERM_INT_MASK_LOW;
7604 WREG32_SMC(CG_THERMAL_INT, cg_thermal_int);
7617 static int si_dpm_process_interrupt(struct amdgpu_device *adev,
7618 struct amdgpu_irq_src *source,
7619 struct amdgpu_iv_entry *entry)
7621 bool queue_thermal = false;
7626 switch (entry->src_id) {
7627 case 230: /* thermal low to high */
7628 DRM_DEBUG("IH: thermal low to high\n");
7629 adev->pm.dpm.thermal.high_to_low = false;
7630 queue_thermal = true;
7632 case 231: /* thermal high to low */
7633 DRM_DEBUG("IH: thermal high to low\n");
7634 adev->pm.dpm.thermal.high_to_low = true;
7635 queue_thermal = true;
7642 schedule_work(&adev->pm.dpm.thermal.work);
7647 static int si_dpm_late_init(void *handle)
7650 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7655 /* init the sysfs and debugfs files late */
7656 ret = amdgpu_pm_sysfs_init(adev);
7660 ret = si_set_temperature_range(adev);
7664 si_dpm_powergate_uvd(adev, true);
7670 * si_dpm_init_microcode - load ucode images from disk
7672 * @adev: amdgpu_device pointer
7674 * Use the firmware interface to load the ucode images into
7675 * the driver (not loaded into hw).
7676 * Returns 0 on success, error on failure.
7678 static int si_dpm_init_microcode(struct amdgpu_device *adev)
7680 const char *chip_name;
7685 switch (adev->asic_type) {
7687 chip_name = "tahiti";
7690 if ((adev->pdev->revision == 0x81) ||
7691 (adev->pdev->device == 0x6810) ||
7692 (adev->pdev->device == 0x6811) ||
7693 (adev->pdev->device == 0x6816) ||
7694 (adev->pdev->device == 0x6817) ||
7695 (adev->pdev->device == 0x6806))
7696 chip_name = "pitcairn_k";
7698 chip_name = "pitcairn";
7701 if ((adev->pdev->revision == 0x81) ||
7702 (adev->pdev->revision == 0x83) ||
7703 (adev->pdev->revision == 0x87) ||
7704 (adev->pdev->device == 0x6820) ||
7705 (adev->pdev->device == 0x6821) ||
7706 (adev->pdev->device == 0x6822) ||
7707 (adev->pdev->device == 0x6823) ||
7708 (adev->pdev->device == 0x682A) ||
7709 (adev->pdev->device == 0x682B))
7710 chip_name = "verde_k";
7712 chip_name = "verde";
7715 if ((adev->pdev->revision == 0xC7) ||
7716 (adev->pdev->revision == 0x80) ||
7717 (adev->pdev->revision == 0x81) ||
7718 (adev->pdev->revision == 0x83) ||
7719 (adev->pdev->revision == 0x87) ||
7720 (adev->pdev->device == 0x6604) ||
7721 (adev->pdev->device == 0x6605))
7722 chip_name = "oland_k";
7724 chip_name = "oland";
7727 if ((adev->pdev->revision == 0x81) ||
7728 (adev->pdev->revision == 0x83) ||
7729 (adev->pdev->revision == 0xC3) ||
7730 (adev->pdev->device == 0x6664) ||
7731 (adev->pdev->device == 0x6665) ||
7732 (adev->pdev->device == 0x6667))
7733 chip_name = "hainan_k";
7735 chip_name = "hainan";
7740 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
7741 err = request_firmware(&adev->pm.fw, fw_name, adev->dev);
7744 err = amdgpu_ucode_validate(adev->pm.fw);
7748 DRM_ERROR("si_smc: Failed to load firmware. err = %d\"%s\"\n",
7750 release_firmware(adev->pm.fw);
7757 static int si_dpm_sw_init(void *handle)
7760 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7762 ret = amdgpu_irq_add_id(adev, 230, &adev->pm.dpm.thermal.irq);
7766 ret = amdgpu_irq_add_id(adev, 231, &adev->pm.dpm.thermal.irq);
7770 /* default to balanced state */
7771 adev->pm.dpm.state = POWER_STATE_TYPE_BALANCED;
7772 adev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED;
7773 adev->pm.dpm.forced_level = AMDGPU_DPM_FORCED_LEVEL_AUTO;
7774 adev->pm.default_sclk = adev->clock.default_sclk;
7775 adev->pm.default_mclk = adev->clock.default_mclk;
7776 adev->pm.current_sclk = adev->clock.default_sclk;
7777 adev->pm.current_mclk = adev->clock.default_mclk;
7778 adev->pm.int_thermal_type = THERMAL_TYPE_NONE;
7780 if (amdgpu_dpm == 0)
7783 ret = si_dpm_init_microcode(adev);
7787 INIT_WORK(&adev->pm.dpm.thermal.work, amdgpu_dpm_thermal_work_handler);
7788 mutex_lock(&adev->pm.mutex);
7789 ret = si_dpm_init(adev);
7792 adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps;
7793 if (amdgpu_dpm == 1)
7794 amdgpu_pm_print_power_states(adev);
7795 mutex_unlock(&adev->pm.mutex);
7796 DRM_INFO("amdgpu: dpm initialized\n");
7802 mutex_unlock(&adev->pm.mutex);
7803 DRM_ERROR("amdgpu: dpm initialization failed\n");
7807 static int si_dpm_sw_fini(void *handle)
7809 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7811 flush_work(&adev->pm.dpm.thermal.work);
7813 mutex_lock(&adev->pm.mutex);
7814 amdgpu_pm_sysfs_fini(adev);
7816 mutex_unlock(&adev->pm.mutex);
7821 static int si_dpm_hw_init(void *handle)
7825 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7830 mutex_lock(&adev->pm.mutex);
7831 si_dpm_setup_asic(adev);
7832 ret = si_dpm_enable(adev);
7834 adev->pm.dpm_enabled = false;
7836 adev->pm.dpm_enabled = true;
7837 mutex_unlock(&adev->pm.mutex);
7842 static int si_dpm_hw_fini(void *handle)
7844 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7846 if (adev->pm.dpm_enabled) {
7847 mutex_lock(&adev->pm.mutex);
7848 si_dpm_disable(adev);
7849 mutex_unlock(&adev->pm.mutex);
7855 static int si_dpm_suspend(void *handle)
7857 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7859 if (adev->pm.dpm_enabled) {
7860 mutex_lock(&adev->pm.mutex);
7862 si_dpm_disable(adev);
7863 /* reset the power state */
7864 adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps;
7865 mutex_unlock(&adev->pm.mutex);
7870 static int si_dpm_resume(void *handle)
7873 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7875 if (adev->pm.dpm_enabled) {
7876 /* asic init will reset to the boot state */
7877 mutex_lock(&adev->pm.mutex);
7878 si_dpm_setup_asic(adev);
7879 ret = si_dpm_enable(adev);
7881 adev->pm.dpm_enabled = false;
7883 adev->pm.dpm_enabled = true;
7884 mutex_unlock(&adev->pm.mutex);
7885 if (adev->pm.dpm_enabled)
7886 amdgpu_pm_compute_clocks(adev);
7891 static bool si_dpm_is_idle(void *handle)
7897 static int si_dpm_wait_for_idle(void *handle)
7903 static int si_dpm_soft_reset(void *handle)
7908 static int si_dpm_set_clockgating_state(void *handle,
7909 enum amd_clockgating_state state)
7914 static int si_dpm_set_powergating_state(void *handle,
7915 enum amd_powergating_state state)
7920 /* get temperature in millidegrees */
7921 static int si_dpm_get_temp(struct amdgpu_device *adev)
7924 int actual_temp = 0;
7926 temp = (RREG32(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >>
7932 actual_temp = temp & 0x1ff;
7934 actual_temp = (actual_temp * 1000);
7939 static u32 si_dpm_get_sclk(struct amdgpu_device *adev, bool low)
7941 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7942 struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps);
7945 return requested_state->performance_levels[0].sclk;
7947 return requested_state->performance_levels[requested_state->performance_level_count - 1].sclk;
7950 static u32 si_dpm_get_mclk(struct amdgpu_device *adev, bool low)
7952 struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7953 struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps);
7956 return requested_state->performance_levels[0].mclk;
7958 return requested_state->performance_levels[requested_state->performance_level_count - 1].mclk;
7961 static void si_dpm_print_power_state(struct amdgpu_device *adev,
7962 struct amdgpu_ps *rps)
7964 struct si_ps *ps = si_get_ps(rps);
7965 struct rv7xx_pl *pl;
7968 amdgpu_dpm_print_class_info(rps->class, rps->class2);
7969 amdgpu_dpm_print_cap_info(rps->caps);
7970 DRM_INFO("\tuvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
7971 for (i = 0; i < ps->performance_level_count; i++) {
7972 pl = &ps->performance_levels[i];
7973 if (adev->asic_type >= CHIP_TAHITI)
7974 DRM_INFO("\t\tpower level %d sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n",
7975 i, pl->sclk, pl->mclk, pl->vddc, pl->vddci, pl->pcie_gen + 1);
7977 DRM_INFO("\t\tpower level %d sclk: %u mclk: %u vddc: %u vddci: %u\n",
7978 i, pl->sclk, pl->mclk, pl->vddc, pl->vddci);
7980 amdgpu_dpm_print_ps_status(adev, rps);
7983 static int si_dpm_early_init(void *handle)
7986 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7988 si_dpm_set_dpm_funcs(adev);
7989 si_dpm_set_irq_funcs(adev);
7993 static inline bool si_are_power_levels_equal(const struct rv7xx_pl *si_cpl1,
7994 const struct rv7xx_pl *si_cpl2)
7996 return ((si_cpl1->mclk == si_cpl2->mclk) &&
7997 (si_cpl1->sclk == si_cpl2->sclk) &&
7998 (si_cpl1->pcie_gen == si_cpl2->pcie_gen) &&
7999 (si_cpl1->vddc == si_cpl2->vddc) &&
8000 (si_cpl1->vddci == si_cpl2->vddci));
8003 static int si_check_state_equal(struct amdgpu_device *adev,
8004 struct amdgpu_ps *cps,
8005 struct amdgpu_ps *rps,
8008 struct si_ps *si_cps;
8009 struct si_ps *si_rps;
8012 if (adev == NULL || cps == NULL || rps == NULL || equal == NULL)
8015 si_cps = si_get_ps(cps);
8016 si_rps = si_get_ps(rps);
8018 if (si_cps == NULL) {
8019 printk("si_cps is NULL\n");
8024 if (si_cps->performance_level_count != si_rps->performance_level_count) {
8029 for (i = 0; i < si_cps->performance_level_count; i++) {
8030 if (!si_are_power_levels_equal(&(si_cps->performance_levels[i]),
8031 &(si_rps->performance_levels[i]))) {
8037 /* If all performance levels are the same try to use the UVD clocks to break the tie.*/
8038 *equal = ((cps->vclk == rps->vclk) && (cps->dclk == rps->dclk));
8039 *equal &= ((cps->evclk == rps->evclk) && (cps->ecclk == rps->ecclk));
8045 const struct amd_ip_funcs si_dpm_ip_funcs = {
8047 .early_init = si_dpm_early_init,
8048 .late_init = si_dpm_late_init,
8049 .sw_init = si_dpm_sw_init,
8050 .sw_fini = si_dpm_sw_fini,
8051 .hw_init = si_dpm_hw_init,
8052 .hw_fini = si_dpm_hw_fini,
8053 .suspend = si_dpm_suspend,
8054 .resume = si_dpm_resume,
8055 .is_idle = si_dpm_is_idle,
8056 .wait_for_idle = si_dpm_wait_for_idle,
8057 .soft_reset = si_dpm_soft_reset,
8058 .set_clockgating_state = si_dpm_set_clockgating_state,
8059 .set_powergating_state = si_dpm_set_powergating_state,
8062 static const struct amdgpu_dpm_funcs si_dpm_funcs = {
8063 .get_temperature = &si_dpm_get_temp,
8064 .pre_set_power_state = &si_dpm_pre_set_power_state,
8065 .set_power_state = &si_dpm_set_power_state,
8066 .post_set_power_state = &si_dpm_post_set_power_state,
8067 .display_configuration_changed = &si_dpm_display_configuration_changed,
8068 .get_sclk = &si_dpm_get_sclk,
8069 .get_mclk = &si_dpm_get_mclk,
8070 .print_power_state = &si_dpm_print_power_state,
8071 .debugfs_print_current_performance_level = &si_dpm_debugfs_print_current_performance_level,
8072 .force_performance_level = &si_dpm_force_performance_level,
8073 .vblank_too_short = &si_dpm_vblank_too_short,
8074 .set_fan_control_mode = &si_dpm_set_fan_control_mode,
8075 .get_fan_control_mode = &si_dpm_get_fan_control_mode,
8076 .set_fan_speed_percent = &si_dpm_set_fan_speed_percent,
8077 .get_fan_speed_percent = &si_dpm_get_fan_speed_percent,
8078 .check_state_equal = &si_check_state_equal,
8079 .get_vce_clock_state = amdgpu_get_vce_clock_state,
8082 static void si_dpm_set_dpm_funcs(struct amdgpu_device *adev)
8084 if (adev->pm.funcs == NULL)
8085 adev->pm.funcs = &si_dpm_funcs;
8088 static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = {
8089 .set = si_dpm_set_interrupt_state,
8090 .process = si_dpm_process_interrupt,
8093 static void si_dpm_set_irq_funcs(struct amdgpu_device *adev)
8095 adev->pm.dpm.thermal.irq.num_types = AMDGPU_THERMAL_IRQ_LAST;
8096 adev->pm.dpm.thermal.irq.funcs = &si_dpm_irq_funcs;
8099 const struct amdgpu_ip_block_version si_dpm_ip_block =
8101 .type = AMD_IP_BLOCK_TYPE_SMC,
8105 .funcs = &si_dpm_ip_funcs,