1b843c749SSergey Zigachev /*
2b843c749SSergey Zigachev * Copyright 2013 Advanced Micro Devices, Inc.
3b843c749SSergey Zigachev *
4b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a
5b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"),
6b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation
7b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the
9b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions:
10b843c749SSergey Zigachev *
11b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in
12b843c749SSergey Zigachev * all copies or substantial portions of the Software.
13b843c749SSergey Zigachev *
14b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE.
21b843c749SSergey Zigachev *
22b843c749SSergey Zigachev */
23b843c749SSergey Zigachev
24b843c749SSergey Zigachev #include <drm/drmP.h>
25b843c749SSergey Zigachev #include "amdgpu.h"
26b843c749SSergey Zigachev #include "amdgpu_pm.h"
27b843c749SSergey Zigachev #include "amdgpu_dpm.h"
28b843c749SSergey Zigachev #include "amdgpu_atombios.h"
29b843c749SSergey Zigachev #include "amd_pcie.h"
30b843c749SSergey Zigachev #include "sid.h"
31b843c749SSergey Zigachev #include "r600_dpm.h"
32b843c749SSergey Zigachev #include "si_dpm.h"
33b843c749SSergey Zigachev #include "atom.h"
34b843c749SSergey Zigachev #include "../include/pptable.h"
35b843c749SSergey Zigachev #include <linux/math64.h>
36b843c749SSergey Zigachev #include <linux/seq_file.h>
37b843c749SSergey Zigachev #include <linux/firmware.h>
38b843c749SSergey Zigachev
39b843c749SSergey Zigachev #define MC_CG_ARB_FREQ_F0 0x0a
40b843c749SSergey Zigachev #define MC_CG_ARB_FREQ_F1 0x0b
41b843c749SSergey Zigachev #define MC_CG_ARB_FREQ_F2 0x0c
42b843c749SSergey Zigachev #define MC_CG_ARB_FREQ_F3 0x0d
43b843c749SSergey Zigachev
44b843c749SSergey Zigachev #define SMC_RAM_END 0x20000
45b843c749SSergey Zigachev
46b843c749SSergey Zigachev #define SCLK_MIN_DEEPSLEEP_FREQ 1350
47b843c749SSergey Zigachev
48b843c749SSergey Zigachev
49b843c749SSergey Zigachev /* sizeof(ATOM_PPLIB_EXTENDEDHEADER) */
50b843c749SSergey Zigachev #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 12
51b843c749SSergey Zigachev #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 14
52b843c749SSergey Zigachev #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V4 16
53b843c749SSergey Zigachev #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V5 18
54b843c749SSergey Zigachev #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V6 20
55b843c749SSergey Zigachev #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V7 22
56b843c749SSergey Zigachev
57b843c749SSergey Zigachev #define BIOS_SCRATCH_4 0x5cd
58b843c749SSergey Zigachev
59*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_tahiti_smc");
60*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_pitcairn_smc");
61*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_pitcairn_k_smc");
62*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_verde_smc");
63*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_verde_k_smc");
64*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_oland_smc");
65*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_oland_k_smc");
66*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_hainan_smc");
67*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_hainan_k_smc");
68*809f3802SSergey Zigachev MODULE_FIRMWARE("amdgpufw_banks_k_2_smc");
69b843c749SSergey Zigachev
70b843c749SSergey Zigachev static const struct amd_pm_funcs si_dpm_funcs;
71b843c749SSergey Zigachev
72b843c749SSergey Zigachev union power_info {
73b843c749SSergey Zigachev struct _ATOM_POWERPLAY_INFO info;
74b843c749SSergey Zigachev struct _ATOM_POWERPLAY_INFO_V2 info_2;
75b843c749SSergey Zigachev struct _ATOM_POWERPLAY_INFO_V3 info_3;
76b843c749SSergey Zigachev struct _ATOM_PPLIB_POWERPLAYTABLE pplib;
77b843c749SSergey Zigachev struct _ATOM_PPLIB_POWERPLAYTABLE2 pplib2;
78b843c749SSergey Zigachev struct _ATOM_PPLIB_POWERPLAYTABLE3 pplib3;
79b843c749SSergey Zigachev struct _ATOM_PPLIB_POWERPLAYTABLE4 pplib4;
80b843c749SSergey Zigachev struct _ATOM_PPLIB_POWERPLAYTABLE5 pplib5;
81b843c749SSergey Zigachev };
82b843c749SSergey Zigachev
83b843c749SSergey Zigachev union fan_info {
84b843c749SSergey Zigachev struct _ATOM_PPLIB_FANTABLE fan;
85b843c749SSergey Zigachev struct _ATOM_PPLIB_FANTABLE2 fan2;
86b843c749SSergey Zigachev struct _ATOM_PPLIB_FANTABLE3 fan3;
87b843c749SSergey Zigachev };
88b843c749SSergey Zigachev
89b843c749SSergey Zigachev union pplib_clock_info {
90b843c749SSergey Zigachev struct _ATOM_PPLIB_R600_CLOCK_INFO r600;
91b843c749SSergey Zigachev struct _ATOM_PPLIB_RS780_CLOCK_INFO rs780;
92b843c749SSergey Zigachev struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen;
93b843c749SSergey Zigachev struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo;
94b843c749SSergey Zigachev struct _ATOM_PPLIB_SI_CLOCK_INFO si;
95b843c749SSergey Zigachev };
96b843c749SSergey Zigachev
97b843c749SSergey Zigachev static const u32 r600_utc[R600_PM_NUMBER_OF_TC] =
98b843c749SSergey Zigachev {
99b843c749SSergey Zigachev R600_UTC_DFLT_00,
100b843c749SSergey Zigachev R600_UTC_DFLT_01,
101b843c749SSergey Zigachev R600_UTC_DFLT_02,
102b843c749SSergey Zigachev R600_UTC_DFLT_03,
103b843c749SSergey Zigachev R600_UTC_DFLT_04,
104b843c749SSergey Zigachev R600_UTC_DFLT_05,
105b843c749SSergey Zigachev R600_UTC_DFLT_06,
106b843c749SSergey Zigachev R600_UTC_DFLT_07,
107b843c749SSergey Zigachev R600_UTC_DFLT_08,
108b843c749SSergey Zigachev R600_UTC_DFLT_09,
109b843c749SSergey Zigachev R600_UTC_DFLT_10,
110b843c749SSergey Zigachev R600_UTC_DFLT_11,
111b843c749SSergey Zigachev R600_UTC_DFLT_12,
112b843c749SSergey Zigachev R600_UTC_DFLT_13,
113b843c749SSergey Zigachev R600_UTC_DFLT_14,
114b843c749SSergey Zigachev };
115b843c749SSergey Zigachev
116b843c749SSergey Zigachev static const u32 r600_dtc[R600_PM_NUMBER_OF_TC] =
117b843c749SSergey Zigachev {
118b843c749SSergey Zigachev R600_DTC_DFLT_00,
119b843c749SSergey Zigachev R600_DTC_DFLT_01,
120b843c749SSergey Zigachev R600_DTC_DFLT_02,
121b843c749SSergey Zigachev R600_DTC_DFLT_03,
122b843c749SSergey Zigachev R600_DTC_DFLT_04,
123b843c749SSergey Zigachev R600_DTC_DFLT_05,
124b843c749SSergey Zigachev R600_DTC_DFLT_06,
125b843c749SSergey Zigachev R600_DTC_DFLT_07,
126b843c749SSergey Zigachev R600_DTC_DFLT_08,
127b843c749SSergey Zigachev R600_DTC_DFLT_09,
128b843c749SSergey Zigachev R600_DTC_DFLT_10,
129b843c749SSergey Zigachev R600_DTC_DFLT_11,
130b843c749SSergey Zigachev R600_DTC_DFLT_12,
131b843c749SSergey Zigachev R600_DTC_DFLT_13,
132b843c749SSergey Zigachev R600_DTC_DFLT_14,
133b843c749SSergey Zigachev };
134b843c749SSergey Zigachev
135b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_tahiti[] =
136b843c749SSergey Zigachev {
137b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0xc, SISLANDS_CACCONFIG_CGIND },
138b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
139b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x101, SISLANDS_CACCONFIG_CGIND },
140b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0xc, SISLANDS_CACCONFIG_CGIND },
141b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
142b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
143b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
144b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
145b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
146b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x8fc, SISLANDS_CACCONFIG_CGIND },
147b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
148b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x95, SISLANDS_CACCONFIG_CGIND },
149b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x34e, SISLANDS_CACCONFIG_CGIND },
150b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x1a1, SISLANDS_CACCONFIG_CGIND },
151b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0xda, SISLANDS_CACCONFIG_CGIND },
152b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
153b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
154b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x46, SISLANDS_CACCONFIG_CGIND },
155b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
156b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x208, SISLANDS_CACCONFIG_CGIND },
157b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0xe7, SISLANDS_CACCONFIG_CGIND },
158b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x948, SISLANDS_CACCONFIG_CGIND },
159b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
160b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
161b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
162b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
163b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
164b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
165b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
166b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
167b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x167, SISLANDS_CACCONFIG_CGIND },
168b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
169b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
170b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
171b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
172b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
173b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
174b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
175b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
176b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x31, SISLANDS_CACCONFIG_CGIND },
177b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
178b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
179b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
180b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
181b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
182b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
183b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
184b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
185b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
186b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
187b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
188b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
189b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
190b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
191b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
192b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
193b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
194b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
195b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
196b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x18e, SISLANDS_CACCONFIG_CGIND },
197b843c749SSergey Zigachev { 0xFFFFFFFF }
198b843c749SSergey Zigachev };
199b843c749SSergey Zigachev
200b843c749SSergey Zigachev static const struct si_cac_config_reg lcac_tahiti[] =
201b843c749SSergey Zigachev {
202b843c749SSergey Zigachev { 0x143, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
203b843c749SSergey Zigachev { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
204b843c749SSergey Zigachev { 0x146, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
205b843c749SSergey Zigachev { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
206b843c749SSergey Zigachev { 0x149, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
207b843c749SSergey Zigachev { 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
208b843c749SSergey Zigachev { 0x14c, 0x0001fffe, 1, 0x3, SISLANDS_CACCONFIG_CGIND },
209b843c749SSergey Zigachev { 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
210b843c749SSergey Zigachev { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
211b843c749SSergey Zigachev { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
212b843c749SSergey Zigachev { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
213b843c749SSergey Zigachev { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
214b843c749SSergey Zigachev { 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
215b843c749SSergey Zigachev { 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
216b843c749SSergey Zigachev { 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
217b843c749SSergey Zigachev { 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
218b843c749SSergey Zigachev { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
219b843c749SSergey Zigachev { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
220b843c749SSergey Zigachev { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
221b843c749SSergey Zigachev { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
222b843c749SSergey Zigachev { 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
223b843c749SSergey Zigachev { 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
224b843c749SSergey Zigachev { 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
225b843c749SSergey Zigachev { 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
226b843c749SSergey Zigachev { 0x8c, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
227b843c749SSergey Zigachev { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
228b843c749SSergey Zigachev { 0x8f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
229b843c749SSergey Zigachev { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
230b843c749SSergey Zigachev { 0x92, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
231b843c749SSergey Zigachev { 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
232b843c749SSergey Zigachev { 0x95, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
233b843c749SSergey Zigachev { 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
234b843c749SSergey Zigachev { 0x14f, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
235b843c749SSergey Zigachev { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
236b843c749SSergey Zigachev { 0x152, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
237b843c749SSergey Zigachev { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
238b843c749SSergey Zigachev { 0x155, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
239b843c749SSergey Zigachev { 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
240b843c749SSergey Zigachev { 0x158, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
241b843c749SSergey Zigachev { 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
242b843c749SSergey Zigachev { 0x110, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
243b843c749SSergey Zigachev { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
244b843c749SSergey Zigachev { 0x113, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
245b843c749SSergey Zigachev { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
246b843c749SSergey Zigachev { 0x116, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
247b843c749SSergey Zigachev { 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
248b843c749SSergey Zigachev { 0x119, 0x0001fffe, 1, 0x8, SISLANDS_CACCONFIG_CGIND },
249b843c749SSergey Zigachev { 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
250b843c749SSergey Zigachev { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
251b843c749SSergey Zigachev { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
252b843c749SSergey Zigachev { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
253b843c749SSergey Zigachev { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
254b843c749SSergey Zigachev { 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
255b843c749SSergey Zigachev { 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
256b843c749SSergey Zigachev { 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
257b843c749SSergey Zigachev { 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
258b843c749SSergey Zigachev { 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
259b843c749SSergey Zigachev { 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
260b843c749SSergey Zigachev { 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
261b843c749SSergey Zigachev { 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
262b843c749SSergey Zigachev { 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
263b843c749SSergey Zigachev { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
264b843c749SSergey Zigachev { 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
265b843c749SSergey Zigachev { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
266b843c749SSergey Zigachev { 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
267b843c749SSergey Zigachev { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
268b843c749SSergey Zigachev { 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
269b843c749SSergey Zigachev { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
270b843c749SSergey Zigachev { 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
271b843c749SSergey Zigachev { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
272b843c749SSergey Zigachev { 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
273b843c749SSergey Zigachev { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
274b843c749SSergey Zigachev { 0x16d, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
275b843c749SSergey Zigachev { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
276b843c749SSergey Zigachev { 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
277b843c749SSergey Zigachev { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
278b843c749SSergey Zigachev { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
279b843c749SSergey Zigachev { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
280b843c749SSergey Zigachev { 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
281b843c749SSergey Zigachev { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
282b843c749SSergey Zigachev { 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
283b843c749SSergey Zigachev { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
284b843c749SSergey Zigachev { 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
285b843c749SSergey Zigachev { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
286b843c749SSergey Zigachev { 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
287b843c749SSergey Zigachev { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
288b843c749SSergey Zigachev { 0xFFFFFFFF }
289b843c749SSergey Zigachev
290b843c749SSergey Zigachev };
291b843c749SSergey Zigachev
292b843c749SSergey Zigachev static const struct si_cac_config_reg cac_override_tahiti[] =
293b843c749SSergey Zigachev {
294b843c749SSergey Zigachev { 0xFFFFFFFF }
295b843c749SSergey Zigachev };
296b843c749SSergey Zigachev
297b843c749SSergey Zigachev static const struct si_powertune_data powertune_data_tahiti =
298b843c749SSergey Zigachev {
299b843c749SSergey Zigachev ((1 << 16) | 27027),
300b843c749SSergey Zigachev 6,
301b843c749SSergey Zigachev 0,
302b843c749SSergey Zigachev 4,
303b843c749SSergey Zigachev 95,
304b843c749SSergey Zigachev {
305b843c749SSergey Zigachev 0UL,
306b843c749SSergey Zigachev 0UL,
307b843c749SSergey Zigachev 4521550UL,
308b843c749SSergey Zigachev 309631529UL,
309b843c749SSergey Zigachev -1270850L,
310b843c749SSergey Zigachev 4513710L,
311b843c749SSergey Zigachev 40
312b843c749SSergey Zigachev },
313b843c749SSergey Zigachev 595000000UL,
314b843c749SSergey Zigachev 12,
315b843c749SSergey Zigachev {
316b843c749SSergey Zigachev 0,
317b843c749SSergey Zigachev 0,
318b843c749SSergey Zigachev 0,
319b843c749SSergey Zigachev 0,
320b843c749SSergey Zigachev 0,
321b843c749SSergey Zigachev 0,
322b843c749SSergey Zigachev 0,
323b843c749SSergey Zigachev 0
324b843c749SSergey Zigachev },
325b843c749SSergey Zigachev true
326b843c749SSergey Zigachev };
327b843c749SSergey Zigachev
328b843c749SSergey Zigachev static const struct si_dte_data dte_data_tahiti =
329b843c749SSergey Zigachev {
330b843c749SSergey Zigachev { 1159409, 0, 0, 0, 0 },
331b843c749SSergey Zigachev { 777, 0, 0, 0, 0 },
332b843c749SSergey Zigachev 2,
333b843c749SSergey Zigachev 54000,
334b843c749SSergey Zigachev 127000,
335b843c749SSergey Zigachev 25,
336b843c749SSergey Zigachev 2,
337b843c749SSergey Zigachev 10,
338b843c749SSergey Zigachev 13,
339b843c749SSergey Zigachev { 27, 31, 35, 39, 43, 47, 54, 61, 67, 74, 81, 88, 95, 0, 0, 0 },
340b843c749SSergey Zigachev { 240888759, 221057860, 235370597, 162287531, 158510299, 131423027, 116673180, 103067515, 87941937, 76209048, 68209175, 64090048, 58301890, 0, 0, 0 },
341b843c749SSergey Zigachev { 12024, 11189, 11451, 8411, 7939, 6666, 5681, 4905, 4241, 3720, 3354, 3122, 2890, 0, 0, 0 },
342b843c749SSergey Zigachev 85,
343b843c749SSergey Zigachev false
344b843c749SSergey Zigachev };
345b843c749SSergey Zigachev
346b843c749SSergey Zigachev #if 0
347b843c749SSergey Zigachev static const struct si_dte_data dte_data_tahiti_le =
348b843c749SSergey Zigachev {
349b843c749SSergey Zigachev { 0x1E8480, 0x7A1200, 0x2160EC0, 0x3938700, 0 },
350b843c749SSergey Zigachev { 0x7D, 0x7D, 0x4E4, 0xB00, 0 },
351b843c749SSergey Zigachev 0x5,
352b843c749SSergey Zigachev 0xAFC8,
353b843c749SSergey Zigachev 0x64,
354b843c749SSergey Zigachev 0x32,
355b843c749SSergey Zigachev 1,
356b843c749SSergey Zigachev 0,
357b843c749SSergey Zigachev 0x10,
358b843c749SSergey Zigachev { 0x78, 0x7C, 0x82, 0x88, 0x8E, 0x94, 0x9A, 0xA0, 0xA6, 0xAC, 0xB0, 0xB4, 0xB8, 0xBC, 0xC0, 0xC4 },
359b843c749SSergey Zigachev { 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700, 0x3938700 },
360b843c749SSergey Zigachev { 0x2AF8, 0x2AF8, 0x29BB, 0x27F9, 0x2637, 0x2475, 0x22B3, 0x20F1, 0x1F2F, 0x1D6D, 0x1734, 0x1414, 0x10F4, 0xDD4, 0xAB4, 0x794 },
361b843c749SSergey Zigachev 85,
362b843c749SSergey Zigachev true
363b843c749SSergey Zigachev };
364b843c749SSergey Zigachev #endif
365b843c749SSergey Zigachev
366b843c749SSergey Zigachev static const struct si_dte_data dte_data_tahiti_pro =
367b843c749SSergey Zigachev {
368b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
369b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0 },
370b843c749SSergey Zigachev 5,
371b843c749SSergey Zigachev 45000,
372b843c749SSergey Zigachev 100,
373b843c749SSergey Zigachev 0xA,
374b843c749SSergey Zigachev 1,
375b843c749SSergey Zigachev 0,
376b843c749SSergey Zigachev 0x10,
377b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
378b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
379b843c749SSergey Zigachev { 0x7D0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
380b843c749SSergey Zigachev 90,
381b843c749SSergey Zigachev true
382b843c749SSergey Zigachev };
383b843c749SSergey Zigachev
384b843c749SSergey Zigachev static const struct si_dte_data dte_data_new_zealand =
385b843c749SSergey Zigachev {
386b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0 },
387b843c749SSergey Zigachev { 0x29B, 0x3E9, 0x537, 0x7D2, 0 },
388b843c749SSergey Zigachev 0x5,
389b843c749SSergey Zigachev 0xAFC8,
390b843c749SSergey Zigachev 0x69,
391b843c749SSergey Zigachev 0x32,
392b843c749SSergey Zigachev 1,
393b843c749SSergey Zigachev 0,
394b843c749SSergey Zigachev 0x10,
395b843c749SSergey Zigachev { 0x82, 0xA0, 0xB4, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE },
396b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
397b843c749SSergey Zigachev { 0xDAC, 0x1388, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685, 0x685 },
398b843c749SSergey Zigachev 85,
399b843c749SSergey Zigachev true
400b843c749SSergey Zigachev };
401b843c749SSergey Zigachev
402b843c749SSergey Zigachev static const struct si_dte_data dte_data_aruba_pro =
403b843c749SSergey Zigachev {
404b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
405b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0 },
406b843c749SSergey Zigachev 5,
407b843c749SSergey Zigachev 45000,
408b843c749SSergey Zigachev 100,
409b843c749SSergey Zigachev 0xA,
410b843c749SSergey Zigachev 1,
411b843c749SSergey Zigachev 0,
412b843c749SSergey Zigachev 0x10,
413b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
414b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
415b843c749SSergey Zigachev { 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
416b843c749SSergey Zigachev 90,
417b843c749SSergey Zigachev true
418b843c749SSergey Zigachev };
419b843c749SSergey Zigachev
420b843c749SSergey Zigachev static const struct si_dte_data dte_data_malta =
421b843c749SSergey Zigachev {
422b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
423b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0 },
424b843c749SSergey Zigachev 5,
425b843c749SSergey Zigachev 45000,
426b843c749SSergey Zigachev 100,
427b843c749SSergey Zigachev 0xA,
428b843c749SSergey Zigachev 1,
429b843c749SSergey Zigachev 0,
430b843c749SSergey Zigachev 0x10,
431b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
432b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
433b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
434b843c749SSergey Zigachev 90,
435b843c749SSergey Zigachev true
436b843c749SSergey Zigachev };
437b843c749SSergey Zigachev
438b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_pitcairn[] =
439b843c749SSergey Zigachev {
440b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x8a, SISLANDS_CACCONFIG_CGIND },
441b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
442b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
443b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x24d, SISLANDS_CACCONFIG_CGIND },
444b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x19, SISLANDS_CACCONFIG_CGIND },
445b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
446b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
447b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
448b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
449b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0xc11, SISLANDS_CACCONFIG_CGIND },
450b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0x7f3, SISLANDS_CACCONFIG_CGIND },
451b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x403, SISLANDS_CACCONFIG_CGIND },
452b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x367, SISLANDS_CACCONFIG_CGIND },
453b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x4c9, SISLANDS_CACCONFIG_CGIND },
454b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
455b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
456b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
457b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x45d, SISLANDS_CACCONFIG_CGIND },
458b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0x36d, SISLANDS_CACCONFIG_CGIND },
459b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x534, SISLANDS_CACCONFIG_CGIND },
460b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x5da, SISLANDS_CACCONFIG_CGIND },
461b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x880, SISLANDS_CACCONFIG_CGIND },
462b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0x201, SISLANDS_CACCONFIG_CGIND },
463b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
464b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
465b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND },
466b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x1f, SISLANDS_CACCONFIG_CGIND },
467b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
468b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
469b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
470b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x5de, SISLANDS_CACCONFIG_CGIND },
471b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
472b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x7b, SISLANDS_CACCONFIG_CGIND },
473b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
474b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x13, SISLANDS_CACCONFIG_CGIND },
475b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0xf9, SISLANDS_CACCONFIG_CGIND },
476b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x66, SISLANDS_CACCONFIG_CGIND },
477b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
478b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x13, SISLANDS_CACCONFIG_CGIND },
479b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
480b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
481b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
482b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
483b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
484b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
485b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
486b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
487b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
488b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
489b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
490b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
491b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
492b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
493b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
494b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
495b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
496b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
497b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
498b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
499b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x186, SISLANDS_CACCONFIG_CGIND },
500b843c749SSergey Zigachev { 0xFFFFFFFF }
501b843c749SSergey Zigachev };
502b843c749SSergey Zigachev
503b843c749SSergey Zigachev static const struct si_cac_config_reg lcac_pitcairn[] =
504b843c749SSergey Zigachev {
505b843c749SSergey Zigachev { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
506b843c749SSergey Zigachev { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
507b843c749SSergey Zigachev { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
508b843c749SSergey Zigachev { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
509b843c749SSergey Zigachev { 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
510b843c749SSergey Zigachev { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
511b843c749SSergey Zigachev { 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
512b843c749SSergey Zigachev { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
513b843c749SSergey Zigachev { 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
514b843c749SSergey Zigachev { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
515b843c749SSergey Zigachev { 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
516b843c749SSergey Zigachev { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
517b843c749SSergey Zigachev { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
518b843c749SSergey Zigachev { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
519b843c749SSergey Zigachev { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
520b843c749SSergey Zigachev { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
521b843c749SSergey Zigachev { 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
522b843c749SSergey Zigachev { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
523b843c749SSergey Zigachev { 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
524b843c749SSergey Zigachev { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
525b843c749SSergey Zigachev { 0x8f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
526b843c749SSergey Zigachev { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
527b843c749SSergey Zigachev { 0x146, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
528b843c749SSergey Zigachev { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
529b843c749SSergey Zigachev { 0x9e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
530b843c749SSergey Zigachev { 0x9e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
531b843c749SSergey Zigachev { 0x10a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
532b843c749SSergey Zigachev { 0x10a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
533b843c749SSergey Zigachev { 0x116, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
534b843c749SSergey Zigachev { 0x116, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
535b843c749SSergey Zigachev { 0x155, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
536b843c749SSergey Zigachev { 0x155, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
537b843c749SSergey Zigachev { 0x92, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
538b843c749SSergey Zigachev { 0x92, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
539b843c749SSergey Zigachev { 0x149, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
540b843c749SSergey Zigachev { 0x149, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
541b843c749SSergey Zigachev { 0x101, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
542b843c749SSergey Zigachev { 0x101, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
543b843c749SSergey Zigachev { 0x10d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
544b843c749SSergey Zigachev { 0x10d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
545b843c749SSergey Zigachev { 0x119, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
546b843c749SSergey Zigachev { 0x119, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
547b843c749SSergey Zigachev { 0x158, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
548b843c749SSergey Zigachev { 0x158, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
549b843c749SSergey Zigachev { 0x95, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
550b843c749SSergey Zigachev { 0x95, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
551b843c749SSergey Zigachev { 0x14c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
552b843c749SSergey Zigachev { 0x14c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
553b843c749SSergey Zigachev { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
554b843c749SSergey Zigachev { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
555b843c749SSergey Zigachev { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
556b843c749SSergey Zigachev { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
557b843c749SSergey Zigachev { 0x122, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
558b843c749SSergey Zigachev { 0x122, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
559b843c749SSergey Zigachev { 0x125, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
560b843c749SSergey Zigachev { 0x125, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
561b843c749SSergey Zigachev { 0x128, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
562b843c749SSergey Zigachev { 0x128, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
563b843c749SSergey Zigachev { 0x12b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
564b843c749SSergey Zigachev { 0x12b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
565b843c749SSergey Zigachev { 0x164, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
566b843c749SSergey Zigachev { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
567b843c749SSergey Zigachev { 0x167, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
568b843c749SSergey Zigachev { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
569b843c749SSergey Zigachev { 0x16a, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
570b843c749SSergey Zigachev { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
571b843c749SSergey Zigachev { 0x15e, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
572b843c749SSergey Zigachev { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
573b843c749SSergey Zigachev { 0x161, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
574b843c749SSergey Zigachev { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
575b843c749SSergey Zigachev { 0x15b, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
576b843c749SSergey Zigachev { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
577b843c749SSergey Zigachev { 0x16d, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
578b843c749SSergey Zigachev { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
579b843c749SSergey Zigachev { 0x170, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
580b843c749SSergey Zigachev { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
581b843c749SSergey Zigachev { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
582b843c749SSergey Zigachev { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
583b843c749SSergey Zigachev { 0x176, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
584b843c749SSergey Zigachev { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
585b843c749SSergey Zigachev { 0x179, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
586b843c749SSergey Zigachev { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
587b843c749SSergey Zigachev { 0x17c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
588b843c749SSergey Zigachev { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
589b843c749SSergey Zigachev { 0x17f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
590b843c749SSergey Zigachev { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
591b843c749SSergey Zigachev { 0xFFFFFFFF }
592b843c749SSergey Zigachev };
593b843c749SSergey Zigachev
594b843c749SSergey Zigachev static const struct si_cac_config_reg cac_override_pitcairn[] =
595b843c749SSergey Zigachev {
596b843c749SSergey Zigachev { 0xFFFFFFFF }
597b843c749SSergey Zigachev };
598b843c749SSergey Zigachev
599b843c749SSergey Zigachev static const struct si_powertune_data powertune_data_pitcairn =
600b843c749SSergey Zigachev {
601b843c749SSergey Zigachev ((1 << 16) | 27027),
602b843c749SSergey Zigachev 5,
603b843c749SSergey Zigachev 0,
604b843c749SSergey Zigachev 6,
605b843c749SSergey Zigachev 100,
606b843c749SSergey Zigachev {
607b843c749SSergey Zigachev 51600000UL,
608b843c749SSergey Zigachev 1800000UL,
609b843c749SSergey Zigachev 7194395UL,
610b843c749SSergey Zigachev 309631529UL,
611b843c749SSergey Zigachev -1270850L,
612b843c749SSergey Zigachev 4513710L,
613b843c749SSergey Zigachev 100
614b843c749SSergey Zigachev },
615b843c749SSergey Zigachev 117830498UL,
616b843c749SSergey Zigachev 12,
617b843c749SSergey Zigachev {
618b843c749SSergey Zigachev 0,
619b843c749SSergey Zigachev 0,
620b843c749SSergey Zigachev 0,
621b843c749SSergey Zigachev 0,
622b843c749SSergey Zigachev 0,
623b843c749SSergey Zigachev 0,
624b843c749SSergey Zigachev 0,
625b843c749SSergey Zigachev 0
626b843c749SSergey Zigachev },
627b843c749SSergey Zigachev true
628b843c749SSergey Zigachev };
629b843c749SSergey Zigachev
630b843c749SSergey Zigachev static const struct si_dte_data dte_data_pitcairn =
631b843c749SSergey Zigachev {
632b843c749SSergey Zigachev { 0, 0, 0, 0, 0 },
633b843c749SSergey Zigachev { 0, 0, 0, 0, 0 },
634b843c749SSergey Zigachev 0,
635b843c749SSergey Zigachev 0,
636b843c749SSergey Zigachev 0,
637b843c749SSergey Zigachev 0,
638b843c749SSergey Zigachev 0,
639b843c749SSergey Zigachev 0,
640b843c749SSergey Zigachev 0,
641b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
642b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
643b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
644b843c749SSergey Zigachev 0,
645b843c749SSergey Zigachev false
646b843c749SSergey Zigachev };
647b843c749SSergey Zigachev
648b843c749SSergey Zigachev static const struct si_dte_data dte_data_curacao_xt =
649b843c749SSergey Zigachev {
650b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
651b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0 },
652b843c749SSergey Zigachev 5,
653b843c749SSergey Zigachev 45000,
654b843c749SSergey Zigachev 100,
655b843c749SSergey Zigachev 0xA,
656b843c749SSergey Zigachev 1,
657b843c749SSergey Zigachev 0,
658b843c749SSergey Zigachev 0x10,
659b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
660b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
661b843c749SSergey Zigachev { 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
662b843c749SSergey Zigachev 90,
663b843c749SSergey Zigachev true
664b843c749SSergey Zigachev };
665b843c749SSergey Zigachev
666b843c749SSergey Zigachev static const struct si_dte_data dte_data_curacao_pro =
667b843c749SSergey Zigachev {
668b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
669b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0 },
670b843c749SSergey Zigachev 5,
671b843c749SSergey Zigachev 45000,
672b843c749SSergey Zigachev 100,
673b843c749SSergey Zigachev 0xA,
674b843c749SSergey Zigachev 1,
675b843c749SSergey Zigachev 0,
676b843c749SSergey Zigachev 0x10,
677b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
678b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
679b843c749SSergey Zigachev { 0x1D17, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
680b843c749SSergey Zigachev 90,
681b843c749SSergey Zigachev true
682b843c749SSergey Zigachev };
683b843c749SSergey Zigachev
684b843c749SSergey Zigachev static const struct si_dte_data dte_data_neptune_xt =
685b843c749SSergey Zigachev {
686b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
687b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0 },
688b843c749SSergey Zigachev 5,
689b843c749SSergey Zigachev 45000,
690b843c749SSergey Zigachev 100,
691b843c749SSergey Zigachev 0xA,
692b843c749SSergey Zigachev 1,
693b843c749SSergey Zigachev 0,
694b843c749SSergey Zigachev 0x10,
695b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
696b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
697b843c749SSergey Zigachev { 0x3A2F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
698b843c749SSergey Zigachev 90,
699b843c749SSergey Zigachev true
700b843c749SSergey Zigachev };
701b843c749SSergey Zigachev
702b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_chelsea_pro[] =
703b843c749SSergey Zigachev {
704b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
705b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
706b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
707b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
708b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
709b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
710b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
711b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
712b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
713b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
714b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
715b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
716b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
717b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
718b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
719b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
720b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
721b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
722b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
723b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
724b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
725b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
726b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
727b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
728b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
729b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
730b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
731b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
732b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
733b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
734b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
735b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
736b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
737b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
738b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
739b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x2BD, SISLANDS_CACCONFIG_CGIND },
740b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
741b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
742b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
743b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
744b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
745b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
746b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
747b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
748b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
749b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
750b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
751b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
752b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
753b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
754b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
755b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
756b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
757b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
758b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
759b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
760b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
761b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
762b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
763b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
764b843c749SSergey Zigachev { 0xFFFFFFFF }
765b843c749SSergey Zigachev };
766b843c749SSergey Zigachev
767b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_chelsea_xt[] =
768b843c749SSergey Zigachev {
769b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
770b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
771b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
772b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
773b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
774b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
775b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
776b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
777b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
778b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
779b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
780b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
781b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
782b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
783b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
784b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
785b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
786b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
787b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
788b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
789b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
790b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
791b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
792b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
793b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
794b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
795b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
796b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
797b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
798b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
799b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
800b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
801b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
802b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
803b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
804b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x30A, SISLANDS_CACCONFIG_CGIND },
805b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
806b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
807b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
808b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
809b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
810b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
811b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
812b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
813b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
814b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
815b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
816b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
817b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
818b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
819b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
820b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
821b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
822b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
823b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
824b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
825b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
826b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
827b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
828b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
829b843c749SSergey Zigachev { 0xFFFFFFFF }
830b843c749SSergey Zigachev };
831b843c749SSergey Zigachev
832b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_heathrow[] =
833b843c749SSergey Zigachev {
834b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
835b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
836b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
837b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
838b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
839b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
840b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
841b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
842b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
843b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
844b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
845b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
846b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
847b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
848b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
849b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
850b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
851b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
852b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
853b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
854b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
855b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
856b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
857b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
858b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
859b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
860b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
861b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
862b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
863b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
864b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
865b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
866b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
867b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
868b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
869b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x362, SISLANDS_CACCONFIG_CGIND },
870b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
871b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
872b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
873b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
874b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
875b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
876b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
877b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
878b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
879b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
880b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
881b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
882b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
883b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
884b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
885b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
886b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
887b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
888b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
889b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
890b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
891b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
892b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
893b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
894b843c749SSergey Zigachev { 0xFFFFFFFF }
895b843c749SSergey Zigachev };
896b843c749SSergey Zigachev
897b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_cape_verde_pro[] =
898b843c749SSergey Zigachev {
899b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
900b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
901b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
902b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
903b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
904b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
905b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
906b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
907b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
908b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
909b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
910b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
911b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
912b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
913b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
914b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
915b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
916b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
917b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
918b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
919b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
920b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
921b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
922b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
923b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
924b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
925b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
926b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
927b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
928b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
929b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
930b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
931b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
932b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
933b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
934b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x315, SISLANDS_CACCONFIG_CGIND },
935b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
936b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
937b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
938b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
939b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
940b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
941b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
942b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
943b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
944b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
945b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
946b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
947b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
948b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
949b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
950b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
951b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
952b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
953b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
954b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
955b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
956b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
957b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
958b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
959b843c749SSergey Zigachev { 0xFFFFFFFF }
960b843c749SSergey Zigachev };
961b843c749SSergey Zigachev
962b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_cape_verde[] =
963b843c749SSergey Zigachev {
964b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
965b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
966b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
967b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
968b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
969b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
970b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
971b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
972b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
973b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
974b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
975b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
976b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
977b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
978b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
979b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
980b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
981b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
982b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
983b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
984b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
985b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
986b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
987b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
988b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
989b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
990b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
991b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
992b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
993b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
994b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
995b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
996b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
997b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
998b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
999b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND },
1000b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1001b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1002b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1003b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
1004b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
1005b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1006b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1007b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1008b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1009b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1010b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1011b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1012b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1013b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1014b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1015b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1016b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1017b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1018b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1019b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1020b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1021b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1022b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1023b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
1024b843c749SSergey Zigachev { 0xFFFFFFFF }
1025b843c749SSergey Zigachev };
1026b843c749SSergey Zigachev
1027b843c749SSergey Zigachev static const struct si_cac_config_reg lcac_cape_verde[] =
1028b843c749SSergey Zigachev {
1029b843c749SSergey Zigachev { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1030b843c749SSergey Zigachev { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1031b843c749SSergey Zigachev { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1032b843c749SSergey Zigachev { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1033b843c749SSergey Zigachev { 0x110, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1034b843c749SSergey Zigachev { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1035b843c749SSergey Zigachev { 0x14f, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1036b843c749SSergey Zigachev { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1037b843c749SSergey Zigachev { 0x8c, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1038b843c749SSergey Zigachev { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1039b843c749SSergey Zigachev { 0x143, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1040b843c749SSergey Zigachev { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1041b843c749SSergey Zigachev { 0x9b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1042b843c749SSergey Zigachev { 0x9b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1043b843c749SSergey Zigachev { 0x107, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1044b843c749SSergey Zigachev { 0x107, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1045b843c749SSergey Zigachev { 0x113, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1046b843c749SSergey Zigachev { 0x113, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1047b843c749SSergey Zigachev { 0x152, 0x0001fffe, 1, 0x5, SISLANDS_CACCONFIG_CGIND },
1048b843c749SSergey Zigachev { 0x152, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1049b843c749SSergey Zigachev { 0x8f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1050b843c749SSergey Zigachev { 0x8f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1051b843c749SSergey Zigachev { 0x146, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1052b843c749SSergey Zigachev { 0x146, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1053b843c749SSergey Zigachev { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1054b843c749SSergey Zigachev { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1055b843c749SSergey Zigachev { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1056b843c749SSergey Zigachev { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1057b843c749SSergey Zigachev { 0x164, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1058b843c749SSergey Zigachev { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1059b843c749SSergey Zigachev { 0x167, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1060b843c749SSergey Zigachev { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1061b843c749SSergey Zigachev { 0x16a, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1062b843c749SSergey Zigachev { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1063b843c749SSergey Zigachev { 0x15e, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1064b843c749SSergey Zigachev { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1065b843c749SSergey Zigachev { 0x161, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1066b843c749SSergey Zigachev { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1067b843c749SSergey Zigachev { 0x15b, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1068b843c749SSergey Zigachev { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1069b843c749SSergey Zigachev { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1070b843c749SSergey Zigachev { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1071b843c749SSergey Zigachev { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1072b843c749SSergey Zigachev { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1073b843c749SSergey Zigachev { 0x173, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1074b843c749SSergey Zigachev { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1075b843c749SSergey Zigachev { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1076b843c749SSergey Zigachev { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1077b843c749SSergey Zigachev { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1078b843c749SSergey Zigachev { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1079b843c749SSergey Zigachev { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1080b843c749SSergey Zigachev { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1081b843c749SSergey Zigachev { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1082b843c749SSergey Zigachev { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1083b843c749SSergey Zigachev { 0xFFFFFFFF }
1084b843c749SSergey Zigachev };
1085b843c749SSergey Zigachev
1086b843c749SSergey Zigachev static const struct si_cac_config_reg cac_override_cape_verde[] =
1087b843c749SSergey Zigachev {
1088b843c749SSergey Zigachev { 0xFFFFFFFF }
1089b843c749SSergey Zigachev };
1090b843c749SSergey Zigachev
1091b843c749SSergey Zigachev static const struct si_powertune_data powertune_data_cape_verde =
1092b843c749SSergey Zigachev {
1093b843c749SSergey Zigachev ((1 << 16) | 0x6993),
1094b843c749SSergey Zigachev 5,
1095b843c749SSergey Zigachev 0,
1096b843c749SSergey Zigachev 7,
1097b843c749SSergey Zigachev 105,
1098b843c749SSergey Zigachev {
1099b843c749SSergey Zigachev 0UL,
1100b843c749SSergey Zigachev 0UL,
1101b843c749SSergey Zigachev 7194395UL,
1102b843c749SSergey Zigachev 309631529UL,
1103b843c749SSergey Zigachev -1270850L,
1104b843c749SSergey Zigachev 4513710L,
1105b843c749SSergey Zigachev 100
1106b843c749SSergey Zigachev },
1107b843c749SSergey Zigachev 117830498UL,
1108b843c749SSergey Zigachev 12,
1109b843c749SSergey Zigachev {
1110b843c749SSergey Zigachev 0,
1111b843c749SSergey Zigachev 0,
1112b843c749SSergey Zigachev 0,
1113b843c749SSergey Zigachev 0,
1114b843c749SSergey Zigachev 0,
1115b843c749SSergey Zigachev 0,
1116b843c749SSergey Zigachev 0,
1117b843c749SSergey Zigachev 0
1118b843c749SSergey Zigachev },
1119b843c749SSergey Zigachev true
1120b843c749SSergey Zigachev };
1121b843c749SSergey Zigachev
1122b843c749SSergey Zigachev static const struct si_dte_data dte_data_cape_verde =
1123b843c749SSergey Zigachev {
1124b843c749SSergey Zigachev { 0, 0, 0, 0, 0 },
1125b843c749SSergey Zigachev { 0, 0, 0, 0, 0 },
1126b843c749SSergey Zigachev 0,
1127b843c749SSergey Zigachev 0,
1128b843c749SSergey Zigachev 0,
1129b843c749SSergey Zigachev 0,
1130b843c749SSergey Zigachev 0,
1131b843c749SSergey Zigachev 0,
1132b843c749SSergey Zigachev 0,
1133b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1134b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1135b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1136b843c749SSergey Zigachev 0,
1137b843c749SSergey Zigachev false
1138b843c749SSergey Zigachev };
1139b843c749SSergey Zigachev
1140b843c749SSergey Zigachev static const struct si_dte_data dte_data_venus_xtx =
1141b843c749SSergey Zigachev {
1142b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1143b843c749SSergey Zigachev { 0x71C, 0xAAB, 0xE39, 0x11C7, 0x0 },
1144b843c749SSergey Zigachev 5,
1145b843c749SSergey Zigachev 55000,
1146b843c749SSergey Zigachev 0x69,
1147b843c749SSergey Zigachev 0xA,
1148b843c749SSergey Zigachev 1,
1149b843c749SSergey Zigachev 0,
1150b843c749SSergey Zigachev 0x3,
1151b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1152b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1153b843c749SSergey Zigachev { 0xD6D8, 0x88B8, 0x1555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1154b843c749SSergey Zigachev 90,
1155b843c749SSergey Zigachev true
1156b843c749SSergey Zigachev };
1157b843c749SSergey Zigachev
1158b843c749SSergey Zigachev static const struct si_dte_data dte_data_venus_xt =
1159b843c749SSergey Zigachev {
1160b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1161b843c749SSergey Zigachev { 0xBDA, 0x11C7, 0x17B4, 0x1DA1, 0x0 },
1162b843c749SSergey Zigachev 5,
1163b843c749SSergey Zigachev 55000,
1164b843c749SSergey Zigachev 0x69,
1165b843c749SSergey Zigachev 0xA,
1166b843c749SSergey Zigachev 1,
1167b843c749SSergey Zigachev 0,
1168b843c749SSergey Zigachev 0x3,
1169b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1170b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1171b843c749SSergey Zigachev { 0xAFC8, 0x88B8, 0x238E, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1172b843c749SSergey Zigachev 90,
1173b843c749SSergey Zigachev true
1174b843c749SSergey Zigachev };
1175b843c749SSergey Zigachev
1176b843c749SSergey Zigachev static const struct si_dte_data dte_data_venus_pro =
1177b843c749SSergey Zigachev {
1178b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1179b843c749SSergey Zigachev { 0x11C7, 0x1AAB, 0x238E, 0x2C72, 0x0 },
1180b843c749SSergey Zigachev 5,
1181b843c749SSergey Zigachev 55000,
1182b843c749SSergey Zigachev 0x69,
1183b843c749SSergey Zigachev 0xA,
1184b843c749SSergey Zigachev 1,
1185b843c749SSergey Zigachev 0,
1186b843c749SSergey Zigachev 0x3,
1187b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1188b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1189b843c749SSergey Zigachev { 0x88B8, 0x88B8, 0x3555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1190b843c749SSergey Zigachev 90,
1191b843c749SSergey Zigachev true
1192b843c749SSergey Zigachev };
1193b843c749SSergey Zigachev
1194b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_oland[] =
1195b843c749SSergey Zigachev {
1196b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x82, SISLANDS_CACCONFIG_CGIND },
1197b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
1198b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x153, SISLANDS_CACCONFIG_CGIND },
1199b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x52, SISLANDS_CACCONFIG_CGIND },
1200b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1201b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
1202b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x4F, SISLANDS_CACCONFIG_CGIND },
1203b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x135, SISLANDS_CACCONFIG_CGIND },
1204b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0xAC, SISLANDS_CACCONFIG_CGIND },
1205b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x118, SISLANDS_CACCONFIG_CGIND },
1206b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0xBE, SISLANDS_CACCONFIG_CGIND },
1207b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x110, SISLANDS_CACCONFIG_CGIND },
1208b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x4CD, SISLANDS_CACCONFIG_CGIND },
1209b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
1210b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x37, SISLANDS_CACCONFIG_CGIND },
1211b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x27, SISLANDS_CACCONFIG_CGIND },
1212b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0xC3, SISLANDS_CACCONFIG_CGIND },
1213b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x35, SISLANDS_CACCONFIG_CGIND },
1214b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0x28, SISLANDS_CACCONFIG_CGIND },
1215b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x26C, SISLANDS_CACCONFIG_CGIND },
1216b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3B2, SISLANDS_CACCONFIG_CGIND },
1217b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x99D, SISLANDS_CACCONFIG_CGIND },
1218b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA3F, SISLANDS_CACCONFIG_CGIND },
1219b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0xA, SISLANDS_CACCONFIG_CGIND },
1220b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0xA, SISLANDS_CACCONFIG_CGIND },
1221b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1222b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1223b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1224b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1225b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x1, SISLANDS_CACCONFIG_CGIND },
1226b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1227b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x15, SISLANDS_CACCONFIG_CGIND },
1228b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x34, SISLANDS_CACCONFIG_CGIND },
1229b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x4, SISLANDS_CACCONFIG_CGIND },
1230b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1231b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x3BA, SISLANDS_CACCONFIG_CGIND },
1232b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1233b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1234b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1235b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x30, SISLANDS_CACCONFIG_CGIND },
1236b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7A, SISLANDS_CACCONFIG_CGIND },
1237b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1238b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1239b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1240b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1241b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1242b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1243b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1244b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1245b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1246b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1247b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1248b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1249b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1250b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1251b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1252b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1253b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1254b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1255b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x100, SISLANDS_CACCONFIG_CGIND },
1256b843c749SSergey Zigachev { 0xFFFFFFFF }
1257b843c749SSergey Zigachev };
1258b843c749SSergey Zigachev
1259b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_mars_pro[] =
1260b843c749SSergey Zigachev {
1261b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
1262b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1263b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
1264b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
1265b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1266b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1267b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1268b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1269b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
1270b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
1271b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
1272b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
1273b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
1274b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
1275b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
1276b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
1277b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
1278b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
1279b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
1280b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
1281b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
1282b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
1283b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
1284b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1285b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
1286b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
1287b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1288b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
1289b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1290b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1291b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
1292b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1293b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
1294b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
1295b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
1296b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x2, SISLANDS_CACCONFIG_CGIND },
1297b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1298b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1299b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1300b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
1301b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
1302b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1303b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1304b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1305b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1306b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1307b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
1308b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1309b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1310b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1311b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
1312b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
1313b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1314b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1315b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1316b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1317b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1318b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1319b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1320b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
1321b843c749SSergey Zigachev { 0xFFFFFFFF }
1322b843c749SSergey Zigachev };
1323b843c749SSergey Zigachev
1324b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_mars_xt[] =
1325b843c749SSergey Zigachev {
1326b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
1327b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1328b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
1329b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
1330b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1331b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1332b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1333b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1334b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
1335b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
1336b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
1337b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
1338b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
1339b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
1340b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
1341b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
1342b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
1343b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
1344b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
1345b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
1346b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
1347b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
1348b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
1349b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1350b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
1351b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
1352b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1353b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
1354b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1355b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1356b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
1357b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1358b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
1359b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
1360b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
1361b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x60, SISLANDS_CACCONFIG_CGIND },
1362b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1363b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1364b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1365b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
1366b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
1367b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1368b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1369b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1370b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1371b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1372b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
1373b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1374b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1375b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1376b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
1377b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
1378b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1379b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1380b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1381b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1382b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1383b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1384b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1385b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
1386b843c749SSergey Zigachev { 0xFFFFFFFF }
1387b843c749SSergey Zigachev };
1388b843c749SSergey Zigachev
1389b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_oland_pro[] =
1390b843c749SSergey Zigachev {
1391b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
1392b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1393b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
1394b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
1395b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1396b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1397b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1398b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1399b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
1400b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
1401b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
1402b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
1403b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
1404b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
1405b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
1406b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
1407b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
1408b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
1409b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
1410b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
1411b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
1412b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
1413b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
1414b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1415b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
1416b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
1417b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1418b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
1419b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1420b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1421b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
1422b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1423b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
1424b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
1425b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
1426b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x90, SISLANDS_CACCONFIG_CGIND },
1427b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1428b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1429b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1430b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
1431b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
1432b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1433b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1434b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1435b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1436b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1437b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
1438b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1439b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1440b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1441b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
1442b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
1443b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1444b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1445b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1446b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1447b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1448b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1449b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1450b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
1451b843c749SSergey Zigachev { 0xFFFFFFFF }
1452b843c749SSergey Zigachev };
1453b843c749SSergey Zigachev
1454b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_oland_xt[] =
1455b843c749SSergey Zigachev {
1456b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x43, SISLANDS_CACCONFIG_CGIND },
1457b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1458b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0xAF, SISLANDS_CACCONFIG_CGIND },
1459b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x2A, SISLANDS_CACCONFIG_CGIND },
1460b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1461b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1462b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x29, SISLANDS_CACCONFIG_CGIND },
1463b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0xA0, SISLANDS_CACCONFIG_CGIND },
1464b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0x59, SISLANDS_CACCONFIG_CGIND },
1465b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x1A5, SISLANDS_CACCONFIG_CGIND },
1466b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0x1D6, SISLANDS_CACCONFIG_CGIND },
1467b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0x2A3, SISLANDS_CACCONFIG_CGIND },
1468b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x8FD, SISLANDS_CACCONFIG_CGIND },
1469b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x76, SISLANDS_CACCONFIG_CGIND },
1470b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x8A, SISLANDS_CACCONFIG_CGIND },
1471b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0xA3, SISLANDS_CACCONFIG_CGIND },
1472b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0x71, SISLANDS_CACCONFIG_CGIND },
1473b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0x36, SISLANDS_CACCONFIG_CGIND },
1474b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0xA6, SISLANDS_CACCONFIG_CGIND },
1475b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x81, SISLANDS_CACCONFIG_CGIND },
1476b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0x3D2, SISLANDS_CACCONFIG_CGIND },
1477b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0x27C, SISLANDS_CACCONFIG_CGIND },
1478b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xA96, SISLANDS_CACCONFIG_CGIND },
1479b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0x5, SISLANDS_CACCONFIG_CGIND },
1480b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0x5, SISLANDS_CACCONFIG_CGIND },
1481b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0xB, SISLANDS_CACCONFIG_CGIND },
1482b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x3, SISLANDS_CACCONFIG_CGIND },
1483b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x2, SISLANDS_CACCONFIG_CGIND },
1484b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1485b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x4, SISLANDS_CACCONFIG_CGIND },
1486b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x15, SISLANDS_CACCONFIG_CGIND },
1487b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1488b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x36, SISLANDS_CACCONFIG_CGIND },
1489b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x10, SISLANDS_CACCONFIG_CGIND },
1490b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x10, SISLANDS_CACCONFIG_CGIND },
1491b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x120, SISLANDS_CACCONFIG_CGIND },
1492b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1493b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x6, SISLANDS_CACCONFIG_CGIND },
1494b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1495b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x32, SISLANDS_CACCONFIG_CGIND },
1496b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x7E, SISLANDS_CACCONFIG_CGIND },
1497b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1498b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1499b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1500b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1501b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1502b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0x280, SISLANDS_CACCONFIG_CGIND },
1503b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0x7, SISLANDS_CACCONFIG_CGIND },
1504b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1505b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1506b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0x3C, SISLANDS_CACCONFIG_CGIND },
1507b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0x203, SISLANDS_CACCONFIG_CGIND },
1508b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1509b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1510b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1511b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1512b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1513b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1514b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1515b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0xB4, SISLANDS_CACCONFIG_CGIND },
1516b843c749SSergey Zigachev { 0xFFFFFFFF }
1517b843c749SSergey Zigachev };
1518b843c749SSergey Zigachev
1519b843c749SSergey Zigachev static const struct si_cac_config_reg lcac_oland[] =
1520b843c749SSergey Zigachev {
1521b843c749SSergey Zigachev { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1522b843c749SSergey Zigachev { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1523b843c749SSergey Zigachev { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1524b843c749SSergey Zigachev { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1525b843c749SSergey Zigachev { 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1526b843c749SSergey Zigachev { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1527b843c749SSergey Zigachev { 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1528b843c749SSergey Zigachev { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1529b843c749SSergey Zigachev { 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1530b843c749SSergey Zigachev { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1531b843c749SSergey Zigachev { 0x143, 0x0001fffe, 1, 0x4, SISLANDS_CACCONFIG_CGIND },
1532b843c749SSergey Zigachev { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1533b843c749SSergey Zigachev { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1534b843c749SSergey Zigachev { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1535b843c749SSergey Zigachev { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1536b843c749SSergey Zigachev { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1537b843c749SSergey Zigachev { 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1538b843c749SSergey Zigachev { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1539b843c749SSergey Zigachev { 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1540b843c749SSergey Zigachev { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1541b843c749SSergey Zigachev { 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1542b843c749SSergey Zigachev { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1543b843c749SSergey Zigachev { 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1544b843c749SSergey Zigachev { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1545b843c749SSergey Zigachev { 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1546b843c749SSergey Zigachev { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1547b843c749SSergey Zigachev { 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1548b843c749SSergey Zigachev { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1549b843c749SSergey Zigachev { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1550b843c749SSergey Zigachev { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1551b843c749SSergey Zigachev { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1552b843c749SSergey Zigachev { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1553b843c749SSergey Zigachev { 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1554b843c749SSergey Zigachev { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1555b843c749SSergey Zigachev { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1556b843c749SSergey Zigachev { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1557b843c749SSergey Zigachev { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1558b843c749SSergey Zigachev { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1559b843c749SSergey Zigachev { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1560b843c749SSergey Zigachev { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1561b843c749SSergey Zigachev { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1562b843c749SSergey Zigachev { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1563b843c749SSergey Zigachev { 0xFFFFFFFF }
1564b843c749SSergey Zigachev };
1565b843c749SSergey Zigachev
1566b843c749SSergey Zigachev static const struct si_cac_config_reg lcac_mars_pro[] =
1567b843c749SSergey Zigachev {
1568b843c749SSergey Zigachev { 0x98, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1569b843c749SSergey Zigachev { 0x98, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1570b843c749SSergey Zigachev { 0x104, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1571b843c749SSergey Zigachev { 0x104, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1572b843c749SSergey Zigachev { 0x110, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1573b843c749SSergey Zigachev { 0x110, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1574b843c749SSergey Zigachev { 0x14f, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1575b843c749SSergey Zigachev { 0x14f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1576b843c749SSergey Zigachev { 0x8c, 0x0001fffe, 1, 0x6, SISLANDS_CACCONFIG_CGIND },
1577b843c749SSergey Zigachev { 0x8c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1578b843c749SSergey Zigachev { 0x143, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1579b843c749SSergey Zigachev { 0x143, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1580b843c749SSergey Zigachev { 0x11c, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1581b843c749SSergey Zigachev { 0x11c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1582b843c749SSergey Zigachev { 0x11f, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1583b843c749SSergey Zigachev { 0x11f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1584b843c749SSergey Zigachev { 0x164, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1585b843c749SSergey Zigachev { 0x164, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1586b843c749SSergey Zigachev { 0x167, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1587b843c749SSergey Zigachev { 0x167, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1588b843c749SSergey Zigachev { 0x16a, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1589b843c749SSergey Zigachev { 0x16a, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1590b843c749SSergey Zigachev { 0x15e, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1591b843c749SSergey Zigachev { 0x15e, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1592b843c749SSergey Zigachev { 0x161, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1593b843c749SSergey Zigachev { 0x161, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1594b843c749SSergey Zigachev { 0x15b, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1595b843c749SSergey Zigachev { 0x15b, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1596b843c749SSergey Zigachev { 0x16d, 0x0001fffe, 1, 0x2, SISLANDS_CACCONFIG_CGIND },
1597b843c749SSergey Zigachev { 0x16d, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1598b843c749SSergey Zigachev { 0x170, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1599b843c749SSergey Zigachev { 0x170, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1600b843c749SSergey Zigachev { 0x173, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1601b843c749SSergey Zigachev { 0x173, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1602b843c749SSergey Zigachev { 0x176, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1603b843c749SSergey Zigachev { 0x176, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1604b843c749SSergey Zigachev { 0x179, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1605b843c749SSergey Zigachev { 0x179, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1606b843c749SSergey Zigachev { 0x17c, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1607b843c749SSergey Zigachev { 0x17c, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1608b843c749SSergey Zigachev { 0x17f, 0x0001fffe, 1, 0x1, SISLANDS_CACCONFIG_CGIND },
1609b843c749SSergey Zigachev { 0x17f, 0x00000001, 0, 0x1, SISLANDS_CACCONFIG_CGIND },
1610b843c749SSergey Zigachev { 0xFFFFFFFF }
1611b843c749SSergey Zigachev };
1612b843c749SSergey Zigachev
1613b843c749SSergey Zigachev static const struct si_cac_config_reg cac_override_oland[] =
1614b843c749SSergey Zigachev {
1615b843c749SSergey Zigachev { 0xFFFFFFFF }
1616b843c749SSergey Zigachev };
1617b843c749SSergey Zigachev
1618b843c749SSergey Zigachev static const struct si_powertune_data powertune_data_oland =
1619b843c749SSergey Zigachev {
1620b843c749SSergey Zigachev ((1 << 16) | 0x6993),
1621b843c749SSergey Zigachev 5,
1622b843c749SSergey Zigachev 0,
1623b843c749SSergey Zigachev 7,
1624b843c749SSergey Zigachev 105,
1625b843c749SSergey Zigachev {
1626b843c749SSergey Zigachev 0UL,
1627b843c749SSergey Zigachev 0UL,
1628b843c749SSergey Zigachev 7194395UL,
1629b843c749SSergey Zigachev 309631529UL,
1630b843c749SSergey Zigachev -1270850L,
1631b843c749SSergey Zigachev 4513710L,
1632b843c749SSergey Zigachev 100
1633b843c749SSergey Zigachev },
1634b843c749SSergey Zigachev 117830498UL,
1635b843c749SSergey Zigachev 12,
1636b843c749SSergey Zigachev {
1637b843c749SSergey Zigachev 0,
1638b843c749SSergey Zigachev 0,
1639b843c749SSergey Zigachev 0,
1640b843c749SSergey Zigachev 0,
1641b843c749SSergey Zigachev 0,
1642b843c749SSergey Zigachev 0,
1643b843c749SSergey Zigachev 0,
1644b843c749SSergey Zigachev 0
1645b843c749SSergey Zigachev },
1646b843c749SSergey Zigachev true
1647b843c749SSergey Zigachev };
1648b843c749SSergey Zigachev
1649b843c749SSergey Zigachev static const struct si_powertune_data powertune_data_mars_pro =
1650b843c749SSergey Zigachev {
1651b843c749SSergey Zigachev ((1 << 16) | 0x6993),
1652b843c749SSergey Zigachev 5,
1653b843c749SSergey Zigachev 0,
1654b843c749SSergey Zigachev 7,
1655b843c749SSergey Zigachev 105,
1656b843c749SSergey Zigachev {
1657b843c749SSergey Zigachev 0UL,
1658b843c749SSergey Zigachev 0UL,
1659b843c749SSergey Zigachev 7194395UL,
1660b843c749SSergey Zigachev 309631529UL,
1661b843c749SSergey Zigachev -1270850L,
1662b843c749SSergey Zigachev 4513710L,
1663b843c749SSergey Zigachev 100
1664b843c749SSergey Zigachev },
1665b843c749SSergey Zigachev 117830498UL,
1666b843c749SSergey Zigachev 12,
1667b843c749SSergey Zigachev {
1668b843c749SSergey Zigachev 0,
1669b843c749SSergey Zigachev 0,
1670b843c749SSergey Zigachev 0,
1671b843c749SSergey Zigachev 0,
1672b843c749SSergey Zigachev 0,
1673b843c749SSergey Zigachev 0,
1674b843c749SSergey Zigachev 0,
1675b843c749SSergey Zigachev 0
1676b843c749SSergey Zigachev },
1677b843c749SSergey Zigachev true
1678b843c749SSergey Zigachev };
1679b843c749SSergey Zigachev
1680b843c749SSergey Zigachev static const struct si_dte_data dte_data_oland =
1681b843c749SSergey Zigachev {
1682b843c749SSergey Zigachev { 0, 0, 0, 0, 0 },
1683b843c749SSergey Zigachev { 0, 0, 0, 0, 0 },
1684b843c749SSergey Zigachev 0,
1685b843c749SSergey Zigachev 0,
1686b843c749SSergey Zigachev 0,
1687b843c749SSergey Zigachev 0,
1688b843c749SSergey Zigachev 0,
1689b843c749SSergey Zigachev 0,
1690b843c749SSergey Zigachev 0,
1691b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1692b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1693b843c749SSergey Zigachev { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1694b843c749SSergey Zigachev 0,
1695b843c749SSergey Zigachev false
1696b843c749SSergey Zigachev };
1697b843c749SSergey Zigachev
1698b843c749SSergey Zigachev static const struct si_dte_data dte_data_mars_pro =
1699b843c749SSergey Zigachev {
1700b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1701b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0 },
1702b843c749SSergey Zigachev 5,
1703b843c749SSergey Zigachev 55000,
1704b843c749SSergey Zigachev 105,
1705b843c749SSergey Zigachev 0xA,
1706b843c749SSergey Zigachev 1,
1707b843c749SSergey Zigachev 0,
1708b843c749SSergey Zigachev 0x10,
1709b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
1710b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
1711b843c749SSergey Zigachev { 0xF627, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1712b843c749SSergey Zigachev 90,
1713b843c749SSergey Zigachev true
1714b843c749SSergey Zigachev };
1715b843c749SSergey Zigachev
1716b843c749SSergey Zigachev static const struct si_dte_data dte_data_sun_xt =
1717b843c749SSergey Zigachev {
1718b843c749SSergey Zigachev { 0x1E8480, 0x3D0900, 0x989680, 0x2625A00, 0x0 },
1719b843c749SSergey Zigachev { 0x0, 0x0, 0x0, 0x0, 0x0 },
1720b843c749SSergey Zigachev 5,
1721b843c749SSergey Zigachev 55000,
1722b843c749SSergey Zigachev 105,
1723b843c749SSergey Zigachev 0xA,
1724b843c749SSergey Zigachev 1,
1725b843c749SSergey Zigachev 0,
1726b843c749SSergey Zigachev 0x10,
1727b843c749SSergey Zigachev { 0x96, 0xB4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
1728b843c749SSergey Zigachev { 0x895440, 0x3D0900, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680, 0x989680 },
1729b843c749SSergey Zigachev { 0xD555, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
1730b843c749SSergey Zigachev 90,
1731b843c749SSergey Zigachev true
1732b843c749SSergey Zigachev };
1733b843c749SSergey Zigachev
1734b843c749SSergey Zigachev
1735b843c749SSergey Zigachev static const struct si_cac_config_reg cac_weights_hainan[] =
1736b843c749SSergey Zigachev {
1737b843c749SSergey Zigachev { 0x0, 0x0000ffff, 0, 0x2d9, SISLANDS_CACCONFIG_CGIND },
1738b843c749SSergey Zigachev { 0x0, 0xffff0000, 16, 0x22b, SISLANDS_CACCONFIG_CGIND },
1739b843c749SSergey Zigachev { 0x1, 0x0000ffff, 0, 0x21c, SISLANDS_CACCONFIG_CGIND },
1740b843c749SSergey Zigachev { 0x1, 0xffff0000, 16, 0x1dc, SISLANDS_CACCONFIG_CGIND },
1741b843c749SSergey Zigachev { 0x2, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1742b843c749SSergey Zigachev { 0x3, 0x0000ffff, 0, 0x24e, SISLANDS_CACCONFIG_CGIND },
1743b843c749SSergey Zigachev { 0x3, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1744b843c749SSergey Zigachev { 0x4, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1745b843c749SSergey Zigachev { 0x4, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1746b843c749SSergey Zigachev { 0x5, 0x0000ffff, 0, 0x35e, SISLANDS_CACCONFIG_CGIND },
1747b843c749SSergey Zigachev { 0x5, 0xffff0000, 16, 0x1143, SISLANDS_CACCONFIG_CGIND },
1748b843c749SSergey Zigachev { 0x6, 0x0000ffff, 0, 0xe17, SISLANDS_CACCONFIG_CGIND },
1749b843c749SSergey Zigachev { 0x6, 0xffff0000, 16, 0x441, SISLANDS_CACCONFIG_CGIND },
1750b843c749SSergey Zigachev { 0x18f, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1751b843c749SSergey Zigachev { 0x7, 0x0000ffff, 0, 0x28b, SISLANDS_CACCONFIG_CGIND },
1752b843c749SSergey Zigachev { 0x7, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1753b843c749SSergey Zigachev { 0x8, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1754b843c749SSergey Zigachev { 0x8, 0xffff0000, 16, 0xabe, SISLANDS_CACCONFIG_CGIND },
1755b843c749SSergey Zigachev { 0x9, 0x0000ffff, 0, 0xf11, SISLANDS_CACCONFIG_CGIND },
1756b843c749SSergey Zigachev { 0xa, 0x0000ffff, 0, 0x907, SISLANDS_CACCONFIG_CGIND },
1757b843c749SSergey Zigachev { 0xb, 0x0000ffff, 0, 0xb45, SISLANDS_CACCONFIG_CGIND },
1758b843c749SSergey Zigachev { 0xb, 0xffff0000, 16, 0xd1e, SISLANDS_CACCONFIG_CGIND },
1759b843c749SSergey Zigachev { 0xc, 0x0000ffff, 0, 0xa2c, SISLANDS_CACCONFIG_CGIND },
1760b843c749SSergey Zigachev { 0xd, 0x0000ffff, 0, 0x62, SISLANDS_CACCONFIG_CGIND },
1761b843c749SSergey Zigachev { 0xd, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1762b843c749SSergey Zigachev { 0xe, 0x0000ffff, 0, 0x1f3, SISLANDS_CACCONFIG_CGIND },
1763b843c749SSergey Zigachev { 0xf, 0x0000ffff, 0, 0x42, SISLANDS_CACCONFIG_CGIND },
1764b843c749SSergey Zigachev { 0xf, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1765b843c749SSergey Zigachev { 0x10, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1766b843c749SSergey Zigachev { 0x10, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1767b843c749SSergey Zigachev { 0x11, 0x0000ffff, 0, 0x709, SISLANDS_CACCONFIG_CGIND },
1768b843c749SSergey Zigachev { 0x11, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1769b843c749SSergey Zigachev { 0x12, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1770b843c749SSergey Zigachev { 0x13, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1771b843c749SSergey Zigachev { 0x13, 0xffff0000, 16, 0x3a, SISLANDS_CACCONFIG_CGIND },
1772b843c749SSergey Zigachev { 0x14, 0x0000ffff, 0, 0x357, SISLANDS_CACCONFIG_CGIND },
1773b843c749SSergey Zigachev { 0x15, 0x0000ffff, 0, 0x9f, SISLANDS_CACCONFIG_CGIND },
1774b843c749SSergey Zigachev { 0x15, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1775b843c749SSergey Zigachev { 0x4e, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1776b843c749SSergey Zigachev { 0x16, 0x0000ffff, 0, 0x314, SISLANDS_CACCONFIG_CGIND },
1777b843c749SSergey Zigachev { 0x16, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1778b843c749SSergey Zigachev { 0x17, 0x0000ffff, 0, 0x6d, SISLANDS_CACCONFIG_CGIND },
1779b843c749SSergey Zigachev { 0x18, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1780b843c749SSergey Zigachev { 0x18, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1781b843c749SSergey Zigachev { 0x19, 0x0000ffff, 0, 0x0, SISLANDS_CACCONFIG_CGIND },
1782b843c749SSergey Zigachev { 0x19, 0xffff0000, 16, 0x0, SISLANDS_CACCONFIG_CGIND },
1783b843c749SSergey Zigachev { 0x1a, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1784b843c749SSergey Zigachev { 0x1a, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1785b843c749SSergey Zigachev { 0x1b, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1786b843c749SSergey Zigachev { 0x1b, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1787b843c749SSergey Zigachev { 0x1c, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1788b843c749SSergey Zigachev { 0x1c, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1789b843c749SSergey Zigachev { 0x1d, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1790b843c749SSergey Zigachev { 0x1d, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1791b843c749SSergey Zigachev { 0x1e, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1792b843c749SSergey Zigachev { 0x1e, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1793b843c749SSergey Zigachev { 0x1f, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1794b843c749SSergey Zigachev { 0x1f, 0xffff0000, 16, 0, SISLANDS_CACCONFIG_CGIND },
1795b843c749SSergey Zigachev { 0x20, 0x0000ffff, 0, 0, SISLANDS_CACCONFIG_CGIND },
1796b843c749SSergey Zigachev { 0x6d, 0x0000ffff, 0, 0x1b9, SISLANDS_CACCONFIG_CGIND },
1797b843c749SSergey Zigachev { 0xFFFFFFFF }
1798b843c749SSergey Zigachev };
1799b843c749SSergey Zigachev
1800b843c749SSergey Zigachev static const struct si_powertune_data powertune_data_hainan =
1801b843c749SSergey Zigachev {
1802b843c749SSergey Zigachev ((1 << 16) | 0x6993),
1803b843c749SSergey Zigachev 5,
1804b843c749SSergey Zigachev 0,
1805b843c749SSergey Zigachev 9,
1806b843c749SSergey Zigachev 105,
1807b843c749SSergey Zigachev {
1808b843c749SSergey Zigachev 0UL,
1809b843c749SSergey Zigachev 0UL,
1810b843c749SSergey Zigachev 7194395UL,
1811b843c749SSergey Zigachev 309631529UL,
1812b843c749SSergey Zigachev -1270850L,
1813b843c749SSergey Zigachev 4513710L,
1814b843c749SSergey Zigachev 100
1815b843c749SSergey Zigachev },
1816b843c749SSergey Zigachev 117830498UL,
1817b843c749SSergey Zigachev 12,
1818b843c749SSergey Zigachev {
1819b843c749SSergey Zigachev 0,
1820b843c749SSergey Zigachev 0,
1821b843c749SSergey Zigachev 0,
1822b843c749SSergey Zigachev 0,
1823b843c749SSergey Zigachev 0,
1824b843c749SSergey Zigachev 0,
1825b843c749SSergey Zigachev 0,
1826b843c749SSergey Zigachev 0
1827b843c749SSergey Zigachev },
1828b843c749SSergey Zigachev true
1829b843c749SSergey Zigachev };
1830b843c749SSergey Zigachev
1831b843c749SSergey Zigachev static struct rv7xx_power_info *rv770_get_pi(struct amdgpu_device *adev);
1832b843c749SSergey Zigachev static struct evergreen_power_info *evergreen_get_pi(struct amdgpu_device *adev);
1833b843c749SSergey Zigachev static struct ni_power_info *ni_get_pi(struct amdgpu_device *adev);
1834b843c749SSergey Zigachev static struct si_ps *si_get_ps(struct amdgpu_ps *rps);
1835b843c749SSergey Zigachev
1836b843c749SSergey Zigachev static int si_populate_voltage_value(struct amdgpu_device *adev,
1837b843c749SSergey Zigachev const struct atom_voltage_table *table,
1838b843c749SSergey Zigachev u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage);
1839b843c749SSergey Zigachev static int si_get_std_voltage_value(struct amdgpu_device *adev,
1840b843c749SSergey Zigachev SISLANDS_SMC_VOLTAGE_VALUE *voltage,
1841b843c749SSergey Zigachev u16 *std_voltage);
1842b843c749SSergey Zigachev static int si_write_smc_soft_register(struct amdgpu_device *adev,
1843b843c749SSergey Zigachev u16 reg_offset, u32 value);
1844b843c749SSergey Zigachev static int si_convert_power_level_to_smc(struct amdgpu_device *adev,
1845b843c749SSergey Zigachev struct rv7xx_pl *pl,
1846b843c749SSergey Zigachev SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level);
1847b843c749SSergey Zigachev static int si_calculate_sclk_params(struct amdgpu_device *adev,
1848b843c749SSergey Zigachev u32 engine_clock,
1849b843c749SSergey Zigachev SISLANDS_SMC_SCLK_VALUE *sclk);
1850b843c749SSergey Zigachev
1851b843c749SSergey Zigachev static void si_thermal_start_smc_fan_control(struct amdgpu_device *adev);
1852b843c749SSergey Zigachev static void si_fan_ctrl_set_default_mode(struct amdgpu_device *adev);
1853b843c749SSergey Zigachev static void si_dpm_set_irq_funcs(struct amdgpu_device *adev);
1854b843c749SSergey Zigachev
si_get_pi(struct amdgpu_device * adev)1855b843c749SSergey Zigachev static struct si_power_info *si_get_pi(struct amdgpu_device *adev)
1856b843c749SSergey Zigachev {
1857b843c749SSergey Zigachev struct si_power_info *pi = adev->pm.dpm.priv;
1858b843c749SSergey Zigachev return pi;
1859b843c749SSergey Zigachev }
1860b843c749SSergey Zigachev
si_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coeffients * coeff,u16 v,s32 t,u32 ileakage,u32 * leakage)1861b843c749SSergey Zigachev static void si_calculate_leakage_for_v_and_t_formula(const struct ni_leakage_coeffients *coeff,
1862b843c749SSergey Zigachev u16 v, s32 t, u32 ileakage, u32 *leakage)
1863b843c749SSergey Zigachev {
1864b843c749SSergey Zigachev s64 kt, kv, leakage_w, i_leakage, vddc;
1865b843c749SSergey Zigachev s64 temperature, t_slope, t_intercept, av, bv, t_ref;
1866b843c749SSergey Zigachev s64 tmp;
1867b843c749SSergey Zigachev
1868b843c749SSergey Zigachev i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
1869b843c749SSergey Zigachev vddc = div64_s64(drm_int2fixp(v), 1000);
1870b843c749SSergey Zigachev temperature = div64_s64(drm_int2fixp(t), 1000);
1871b843c749SSergey Zigachev
1872b843c749SSergey Zigachev t_slope = div64_s64(drm_int2fixp(coeff->t_slope), 100000000);
1873b843c749SSergey Zigachev t_intercept = div64_s64(drm_int2fixp(coeff->t_intercept), 100000000);
1874b843c749SSergey Zigachev av = div64_s64(drm_int2fixp(coeff->av), 100000000);
1875b843c749SSergey Zigachev bv = div64_s64(drm_int2fixp(coeff->bv), 100000000);
1876b843c749SSergey Zigachev t_ref = drm_int2fixp(coeff->t_ref);
1877b843c749SSergey Zigachev
1878b843c749SSergey Zigachev tmp = drm_fixp_mul(t_slope, vddc) + t_intercept;
1879b843c749SSergey Zigachev kt = drm_fixp_exp(drm_fixp_mul(tmp, temperature));
1880b843c749SSergey Zigachev kt = drm_fixp_div(kt, drm_fixp_exp(drm_fixp_mul(tmp, t_ref)));
1881b843c749SSergey Zigachev kv = drm_fixp_mul(av, drm_fixp_exp(drm_fixp_mul(bv, vddc)));
1882b843c749SSergey Zigachev
1883b843c749SSergey Zigachev leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
1884b843c749SSergey Zigachev
1885b843c749SSergey Zigachev *leakage = drm_fixp2int(leakage_w * 1000);
1886b843c749SSergey Zigachev }
1887b843c749SSergey Zigachev
si_calculate_leakage_for_v_and_t(struct amdgpu_device * adev,const struct ni_leakage_coeffients * coeff,u16 v,s32 t,u32 i_leakage,u32 * leakage)1888b843c749SSergey Zigachev static void si_calculate_leakage_for_v_and_t(struct amdgpu_device *adev,
1889b843c749SSergey Zigachev const struct ni_leakage_coeffients *coeff,
1890b843c749SSergey Zigachev u16 v,
1891b843c749SSergey Zigachev s32 t,
1892b843c749SSergey Zigachev u32 i_leakage,
1893b843c749SSergey Zigachev u32 *leakage)
1894b843c749SSergey Zigachev {
1895b843c749SSergey Zigachev si_calculate_leakage_for_v_and_t_formula(coeff, v, t, i_leakage, leakage);
1896b843c749SSergey Zigachev }
1897b843c749SSergey Zigachev
si_calculate_leakage_for_v_formula(const struct ni_leakage_coeffients * coeff,const u32 fixed_kt,u16 v,u32 ileakage,u32 * leakage)1898b843c749SSergey Zigachev static void si_calculate_leakage_for_v_formula(const struct ni_leakage_coeffients *coeff,
1899b843c749SSergey Zigachev const u32 fixed_kt, u16 v,
1900b843c749SSergey Zigachev u32 ileakage, u32 *leakage)
1901b843c749SSergey Zigachev {
1902b843c749SSergey Zigachev s64 kt, kv, leakage_w, i_leakage, vddc;
1903b843c749SSergey Zigachev
1904b843c749SSergey Zigachev i_leakage = div64_s64(drm_int2fixp(ileakage), 100);
1905b843c749SSergey Zigachev vddc = div64_s64(drm_int2fixp(v), 1000);
1906b843c749SSergey Zigachev
1907b843c749SSergey Zigachev kt = div64_s64(drm_int2fixp(fixed_kt), 100000000);
1908b843c749SSergey Zigachev kv = drm_fixp_mul(div64_s64(drm_int2fixp(coeff->av), 100000000),
1909b843c749SSergey Zigachev drm_fixp_exp(drm_fixp_mul(div64_s64(drm_int2fixp(coeff->bv), 100000000), vddc)));
1910b843c749SSergey Zigachev
1911b843c749SSergey Zigachev leakage_w = drm_fixp_mul(drm_fixp_mul(drm_fixp_mul(i_leakage, kt), kv), vddc);
1912b843c749SSergey Zigachev
1913b843c749SSergey Zigachev *leakage = drm_fixp2int(leakage_w * 1000);
1914b843c749SSergey Zigachev }
1915b843c749SSergey Zigachev
si_calculate_leakage_for_v(struct amdgpu_device * adev,const struct ni_leakage_coeffients * coeff,const u32 fixed_kt,u16 v,u32 i_leakage,u32 * leakage)1916b843c749SSergey Zigachev static void si_calculate_leakage_for_v(struct amdgpu_device *adev,
1917b843c749SSergey Zigachev const struct ni_leakage_coeffients *coeff,
1918b843c749SSergey Zigachev const u32 fixed_kt,
1919b843c749SSergey Zigachev u16 v,
1920b843c749SSergey Zigachev u32 i_leakage,
1921b843c749SSergey Zigachev u32 *leakage)
1922b843c749SSergey Zigachev {
1923b843c749SSergey Zigachev si_calculate_leakage_for_v_formula(coeff, fixed_kt, v, i_leakage, leakage);
1924b843c749SSergey Zigachev }
1925b843c749SSergey Zigachev
1926b843c749SSergey Zigachev
si_update_dte_from_pl2(struct amdgpu_device * adev,struct si_dte_data * dte_data)1927b843c749SSergey Zigachev static void si_update_dte_from_pl2(struct amdgpu_device *adev,
1928b843c749SSergey Zigachev struct si_dte_data *dte_data)
1929b843c749SSergey Zigachev {
1930b843c749SSergey Zigachev u32 p_limit1 = adev->pm.dpm.tdp_limit;
1931b843c749SSergey Zigachev u32 p_limit2 = adev->pm.dpm.near_tdp_limit;
1932b843c749SSergey Zigachev u32 k = dte_data->k;
1933b843c749SSergey Zigachev u32 t_max = dte_data->max_t;
1934b843c749SSergey Zigachev u32 t_split[5] = { 10, 15, 20, 25, 30 };
1935b843c749SSergey Zigachev u32 t_0 = dte_data->t0;
1936b843c749SSergey Zigachev u32 i;
1937b843c749SSergey Zigachev
1938b843c749SSergey Zigachev if (p_limit2 != 0 && p_limit2 <= p_limit1) {
1939b843c749SSergey Zigachev dte_data->tdep_count = 3;
1940b843c749SSergey Zigachev
1941b843c749SSergey Zigachev for (i = 0; i < k; i++) {
1942b843c749SSergey Zigachev dte_data->r[i] =
1943b843c749SSergey Zigachev (t_split[i] * (t_max - t_0/(u32)1000) * (1 << 14)) /
1944b843c749SSergey Zigachev (p_limit2 * (u32)100);
1945b843c749SSergey Zigachev }
1946b843c749SSergey Zigachev
1947b843c749SSergey Zigachev dte_data->tdep_r[1] = dte_data->r[4] * 2;
1948b843c749SSergey Zigachev
1949b843c749SSergey Zigachev for (i = 2; i < SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE; i++) {
1950b843c749SSergey Zigachev dte_data->tdep_r[i] = dte_data->r[4];
1951b843c749SSergey Zigachev }
1952b843c749SSergey Zigachev } else {
1953b843c749SSergey Zigachev DRM_ERROR("Invalid PL2! DTE will not be updated.\n");
1954b843c749SSergey Zigachev }
1955b843c749SSergey Zigachev }
1956b843c749SSergey Zigachev
rv770_get_pi(struct amdgpu_device * adev)1957b843c749SSergey Zigachev static struct rv7xx_power_info *rv770_get_pi(struct amdgpu_device *adev)
1958b843c749SSergey Zigachev {
1959b843c749SSergey Zigachev struct rv7xx_power_info *pi = adev->pm.dpm.priv;
1960b843c749SSergey Zigachev
1961b843c749SSergey Zigachev return pi;
1962b843c749SSergey Zigachev }
1963b843c749SSergey Zigachev
ni_get_pi(struct amdgpu_device * adev)1964b843c749SSergey Zigachev static struct ni_power_info *ni_get_pi(struct amdgpu_device *adev)
1965b843c749SSergey Zigachev {
1966b843c749SSergey Zigachev struct ni_power_info *pi = adev->pm.dpm.priv;
1967b843c749SSergey Zigachev
1968b843c749SSergey Zigachev return pi;
1969b843c749SSergey Zigachev }
1970b843c749SSergey Zigachev
si_get_ps(struct amdgpu_ps * aps)1971b843c749SSergey Zigachev static struct si_ps *si_get_ps(struct amdgpu_ps *aps)
1972b843c749SSergey Zigachev {
1973b843c749SSergey Zigachev struct si_ps *ps = aps->ps_priv;
1974b843c749SSergey Zigachev
1975b843c749SSergey Zigachev return ps;
1976b843c749SSergey Zigachev }
1977b843c749SSergey Zigachev
si_initialize_powertune_defaults(struct amdgpu_device * adev)1978b843c749SSergey Zigachev static void si_initialize_powertune_defaults(struct amdgpu_device *adev)
1979b843c749SSergey Zigachev {
1980b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
1981b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
1982b843c749SSergey Zigachev bool update_dte_from_pl2 = false;
1983b843c749SSergey Zigachev
1984b843c749SSergey Zigachev if (adev->asic_type == CHIP_TAHITI) {
1985b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_tahiti;
1986b843c749SSergey Zigachev si_pi->lcac_config = lcac_tahiti;
1987b843c749SSergey Zigachev si_pi->cac_override = cac_override_tahiti;
1988b843c749SSergey Zigachev si_pi->powertune_data = &powertune_data_tahiti;
1989b843c749SSergey Zigachev si_pi->dte_data = dte_data_tahiti;
1990b843c749SSergey Zigachev
1991b843c749SSergey Zigachev switch (adev->pdev->device) {
1992b843c749SSergey Zigachev case 0x6798:
1993b843c749SSergey Zigachev si_pi->dte_data.enable_dte_by_default = true;
1994b843c749SSergey Zigachev break;
1995b843c749SSergey Zigachev case 0x6799:
1996b843c749SSergey Zigachev si_pi->dte_data = dte_data_new_zealand;
1997b843c749SSergey Zigachev break;
1998b843c749SSergey Zigachev case 0x6790:
1999b843c749SSergey Zigachev case 0x6791:
2000b843c749SSergey Zigachev case 0x6792:
2001b843c749SSergey Zigachev case 0x679E:
2002b843c749SSergey Zigachev si_pi->dte_data = dte_data_aruba_pro;
2003b843c749SSergey Zigachev update_dte_from_pl2 = true;
2004b843c749SSergey Zigachev break;
2005b843c749SSergey Zigachev case 0x679B:
2006b843c749SSergey Zigachev si_pi->dte_data = dte_data_malta;
2007b843c749SSergey Zigachev update_dte_from_pl2 = true;
2008b843c749SSergey Zigachev break;
2009b843c749SSergey Zigachev case 0x679A:
2010b843c749SSergey Zigachev si_pi->dte_data = dte_data_tahiti_pro;
2011b843c749SSergey Zigachev update_dte_from_pl2 = true;
2012b843c749SSergey Zigachev break;
2013b843c749SSergey Zigachev default:
2014b843c749SSergey Zigachev if (si_pi->dte_data.enable_dte_by_default == true)
2015b843c749SSergey Zigachev DRM_ERROR("DTE is not enabled!\n");
2016b843c749SSergey Zigachev break;
2017b843c749SSergey Zigachev }
2018b843c749SSergey Zigachev } else if (adev->asic_type == CHIP_PITCAIRN) {
2019b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_pitcairn;
2020b843c749SSergey Zigachev si_pi->lcac_config = lcac_pitcairn;
2021b843c749SSergey Zigachev si_pi->cac_override = cac_override_pitcairn;
2022b843c749SSergey Zigachev si_pi->powertune_data = &powertune_data_pitcairn;
2023b843c749SSergey Zigachev
2024b843c749SSergey Zigachev switch (adev->pdev->device) {
2025b843c749SSergey Zigachev case 0x6810:
2026b843c749SSergey Zigachev case 0x6818:
2027b843c749SSergey Zigachev si_pi->dte_data = dte_data_curacao_xt;
2028b843c749SSergey Zigachev update_dte_from_pl2 = true;
2029b843c749SSergey Zigachev break;
2030b843c749SSergey Zigachev case 0x6819:
2031b843c749SSergey Zigachev case 0x6811:
2032b843c749SSergey Zigachev si_pi->dte_data = dte_data_curacao_pro;
2033b843c749SSergey Zigachev update_dte_from_pl2 = true;
2034b843c749SSergey Zigachev break;
2035b843c749SSergey Zigachev case 0x6800:
2036b843c749SSergey Zigachev case 0x6806:
2037b843c749SSergey Zigachev si_pi->dte_data = dte_data_neptune_xt;
2038b843c749SSergey Zigachev update_dte_from_pl2 = true;
2039b843c749SSergey Zigachev break;
2040b843c749SSergey Zigachev default:
2041b843c749SSergey Zigachev si_pi->dte_data = dte_data_pitcairn;
2042b843c749SSergey Zigachev break;
2043b843c749SSergey Zigachev }
2044b843c749SSergey Zigachev } else if (adev->asic_type == CHIP_VERDE) {
2045b843c749SSergey Zigachev si_pi->lcac_config = lcac_cape_verde;
2046b843c749SSergey Zigachev si_pi->cac_override = cac_override_cape_verde;
2047b843c749SSergey Zigachev si_pi->powertune_data = &powertune_data_cape_verde;
2048b843c749SSergey Zigachev
2049b843c749SSergey Zigachev switch (adev->pdev->device) {
2050b843c749SSergey Zigachev case 0x683B:
2051b843c749SSergey Zigachev case 0x683F:
2052b843c749SSergey Zigachev case 0x6829:
2053b843c749SSergey Zigachev case 0x6835:
2054b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_cape_verde_pro;
2055b843c749SSergey Zigachev si_pi->dte_data = dte_data_cape_verde;
2056b843c749SSergey Zigachev break;
2057b843c749SSergey Zigachev case 0x682C:
2058b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_cape_verde_pro;
2059b843c749SSergey Zigachev si_pi->dte_data = dte_data_sun_xt;
2060b843c749SSergey Zigachev update_dte_from_pl2 = true;
2061b843c749SSergey Zigachev break;
2062b843c749SSergey Zigachev case 0x6825:
2063b843c749SSergey Zigachev case 0x6827:
2064b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_heathrow;
2065b843c749SSergey Zigachev si_pi->dte_data = dte_data_cape_verde;
2066b843c749SSergey Zigachev break;
2067b843c749SSergey Zigachev case 0x6824:
2068b843c749SSergey Zigachev case 0x682D:
2069b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_chelsea_xt;
2070b843c749SSergey Zigachev si_pi->dte_data = dte_data_cape_verde;
2071b843c749SSergey Zigachev break;
2072b843c749SSergey Zigachev case 0x682F:
2073b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_chelsea_pro;
2074b843c749SSergey Zigachev si_pi->dte_data = dte_data_cape_verde;
2075b843c749SSergey Zigachev break;
2076b843c749SSergey Zigachev case 0x6820:
2077b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_heathrow;
2078b843c749SSergey Zigachev si_pi->dte_data = dte_data_venus_xtx;
2079b843c749SSergey Zigachev break;
2080b843c749SSergey Zigachev case 0x6821:
2081b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_heathrow;
2082b843c749SSergey Zigachev si_pi->dte_data = dte_data_venus_xt;
2083b843c749SSergey Zigachev break;
2084b843c749SSergey Zigachev case 0x6823:
2085b843c749SSergey Zigachev case 0x682B:
2086b843c749SSergey Zigachev case 0x6822:
2087b843c749SSergey Zigachev case 0x682A:
2088b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_chelsea_pro;
2089b843c749SSergey Zigachev si_pi->dte_data = dte_data_venus_pro;
2090b843c749SSergey Zigachev break;
2091b843c749SSergey Zigachev default:
2092b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_cape_verde;
2093b843c749SSergey Zigachev si_pi->dte_data = dte_data_cape_verde;
2094b843c749SSergey Zigachev break;
2095b843c749SSergey Zigachev }
2096b843c749SSergey Zigachev } else if (adev->asic_type == CHIP_OLAND) {
2097b843c749SSergey Zigachev si_pi->lcac_config = lcac_mars_pro;
2098b843c749SSergey Zigachev si_pi->cac_override = cac_override_oland;
2099b843c749SSergey Zigachev si_pi->powertune_data = &powertune_data_mars_pro;
2100b843c749SSergey Zigachev si_pi->dte_data = dte_data_mars_pro;
2101b843c749SSergey Zigachev
2102b843c749SSergey Zigachev switch (adev->pdev->device) {
2103b843c749SSergey Zigachev case 0x6601:
2104b843c749SSergey Zigachev case 0x6621:
2105b843c749SSergey Zigachev case 0x6603:
2106b843c749SSergey Zigachev case 0x6605:
2107b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_mars_pro;
2108b843c749SSergey Zigachev update_dte_from_pl2 = true;
2109b843c749SSergey Zigachev break;
2110b843c749SSergey Zigachev case 0x6600:
2111b843c749SSergey Zigachev case 0x6606:
2112b843c749SSergey Zigachev case 0x6620:
2113b843c749SSergey Zigachev case 0x6604:
2114b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_mars_xt;
2115b843c749SSergey Zigachev update_dte_from_pl2 = true;
2116b843c749SSergey Zigachev break;
2117b843c749SSergey Zigachev case 0x6611:
2118b843c749SSergey Zigachev case 0x6613:
2119b843c749SSergey Zigachev case 0x6608:
2120b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_oland_pro;
2121b843c749SSergey Zigachev update_dte_from_pl2 = true;
2122b843c749SSergey Zigachev break;
2123b843c749SSergey Zigachev case 0x6610:
2124b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_oland_xt;
2125b843c749SSergey Zigachev update_dte_from_pl2 = true;
2126b843c749SSergey Zigachev break;
2127b843c749SSergey Zigachev default:
2128b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_oland;
2129b843c749SSergey Zigachev si_pi->lcac_config = lcac_oland;
2130b843c749SSergey Zigachev si_pi->cac_override = cac_override_oland;
2131b843c749SSergey Zigachev si_pi->powertune_data = &powertune_data_oland;
2132b843c749SSergey Zigachev si_pi->dte_data = dte_data_oland;
2133b843c749SSergey Zigachev break;
2134b843c749SSergey Zigachev }
2135b843c749SSergey Zigachev } else if (adev->asic_type == CHIP_HAINAN) {
2136b843c749SSergey Zigachev si_pi->cac_weights = cac_weights_hainan;
2137b843c749SSergey Zigachev si_pi->lcac_config = lcac_oland;
2138b843c749SSergey Zigachev si_pi->cac_override = cac_override_oland;
2139b843c749SSergey Zigachev si_pi->powertune_data = &powertune_data_hainan;
2140b843c749SSergey Zigachev si_pi->dte_data = dte_data_sun_xt;
2141b843c749SSergey Zigachev update_dte_from_pl2 = true;
2142b843c749SSergey Zigachev } else {
2143b843c749SSergey Zigachev DRM_ERROR("Unknown SI asic revision, failed to initialize PowerTune!\n");
2144b843c749SSergey Zigachev return;
2145b843c749SSergey Zigachev }
2146b843c749SSergey Zigachev
2147b843c749SSergey Zigachev ni_pi->enable_power_containment = false;
2148b843c749SSergey Zigachev ni_pi->enable_cac = false;
2149b843c749SSergey Zigachev ni_pi->enable_sq_ramping = false;
2150b843c749SSergey Zigachev si_pi->enable_dte = false;
2151b843c749SSergey Zigachev
2152b843c749SSergey Zigachev if (si_pi->powertune_data->enable_powertune_by_default) {
2153b843c749SSergey Zigachev ni_pi->enable_power_containment = true;
2154b843c749SSergey Zigachev ni_pi->enable_cac = true;
2155b843c749SSergey Zigachev if (si_pi->dte_data.enable_dte_by_default) {
2156b843c749SSergey Zigachev si_pi->enable_dte = true;
2157b843c749SSergey Zigachev if (update_dte_from_pl2)
2158b843c749SSergey Zigachev si_update_dte_from_pl2(adev, &si_pi->dte_data);
2159b843c749SSergey Zigachev
2160b843c749SSergey Zigachev }
2161b843c749SSergey Zigachev ni_pi->enable_sq_ramping = true;
2162b843c749SSergey Zigachev }
2163b843c749SSergey Zigachev
2164b843c749SSergey Zigachev ni_pi->driver_calculate_cac_leakage = true;
2165b843c749SSergey Zigachev ni_pi->cac_configuration_required = true;
2166b843c749SSergey Zigachev
2167b843c749SSergey Zigachev if (ni_pi->cac_configuration_required) {
2168b843c749SSergey Zigachev ni_pi->support_cac_long_term_average = true;
2169b843c749SSergey Zigachev si_pi->dyn_powertune_data.l2_lta_window_size =
2170b843c749SSergey Zigachev si_pi->powertune_data->l2_lta_window_size_default;
2171b843c749SSergey Zigachev si_pi->dyn_powertune_data.lts_truncate =
2172b843c749SSergey Zigachev si_pi->powertune_data->lts_truncate_default;
2173b843c749SSergey Zigachev } else {
2174b843c749SSergey Zigachev ni_pi->support_cac_long_term_average = false;
2175b843c749SSergey Zigachev si_pi->dyn_powertune_data.l2_lta_window_size = 0;
2176b843c749SSergey Zigachev si_pi->dyn_powertune_data.lts_truncate = 0;
2177b843c749SSergey Zigachev }
2178b843c749SSergey Zigachev
2179b843c749SSergey Zigachev si_pi->dyn_powertune_data.disable_uvd_powertune = false;
2180b843c749SSergey Zigachev }
2181b843c749SSergey Zigachev
si_get_smc_power_scaling_factor(struct amdgpu_device * adev)2182b843c749SSergey Zigachev static u32 si_get_smc_power_scaling_factor(struct amdgpu_device *adev)
2183b843c749SSergey Zigachev {
2184b843c749SSergey Zigachev return 1;
2185b843c749SSergey Zigachev }
2186b843c749SSergey Zigachev
si_calculate_cac_wintime(struct amdgpu_device * adev)2187b843c749SSergey Zigachev static u32 si_calculate_cac_wintime(struct amdgpu_device *adev)
2188b843c749SSergey Zigachev {
2189b843c749SSergey Zigachev u32 xclk;
2190b843c749SSergey Zigachev u32 wintime;
2191b843c749SSergey Zigachev u32 cac_window;
2192b843c749SSergey Zigachev u32 cac_window_size;
2193b843c749SSergey Zigachev
2194b843c749SSergey Zigachev xclk = amdgpu_asic_get_xclk(adev);
2195b843c749SSergey Zigachev
2196b843c749SSergey Zigachev if (xclk == 0)
2197b843c749SSergey Zigachev return 0;
2198b843c749SSergey Zigachev
2199b843c749SSergey Zigachev cac_window = RREG32(CG_CAC_CTRL) & CAC_WINDOW_MASK;
2200b843c749SSergey Zigachev cac_window_size = ((cac_window & 0xFFFF0000) >> 16) * (cac_window & 0x0000FFFF);
2201b843c749SSergey Zigachev
2202b843c749SSergey Zigachev wintime = (cac_window_size * 100) / xclk;
2203b843c749SSergey Zigachev
2204b843c749SSergey Zigachev return wintime;
2205b843c749SSergey Zigachev }
2206b843c749SSergey Zigachev
si_scale_power_for_smc(u32 power_in_watts,u32 scaling_factor)2207b843c749SSergey Zigachev static u32 si_scale_power_for_smc(u32 power_in_watts, u32 scaling_factor)
2208b843c749SSergey Zigachev {
2209b843c749SSergey Zigachev return power_in_watts;
2210b843c749SSergey Zigachev }
2211b843c749SSergey Zigachev
si_calculate_adjusted_tdp_limits(struct amdgpu_device * adev,bool adjust_polarity,u32 tdp_adjustment,u32 * tdp_limit,u32 * near_tdp_limit)2212b843c749SSergey Zigachev static int si_calculate_adjusted_tdp_limits(struct amdgpu_device *adev,
2213b843c749SSergey Zigachev bool adjust_polarity,
2214b843c749SSergey Zigachev u32 tdp_adjustment,
2215b843c749SSergey Zigachev u32 *tdp_limit,
2216b843c749SSergey Zigachev u32 *near_tdp_limit)
2217b843c749SSergey Zigachev {
2218b843c749SSergey Zigachev u32 adjustment_delta, max_tdp_limit;
2219b843c749SSergey Zigachev
2220b843c749SSergey Zigachev if (tdp_adjustment > (u32)adev->pm.dpm.tdp_od_limit)
2221b843c749SSergey Zigachev return -EINVAL;
2222b843c749SSergey Zigachev
2223b843c749SSergey Zigachev max_tdp_limit = ((100 + 100) * adev->pm.dpm.tdp_limit) / 100;
2224b843c749SSergey Zigachev
2225b843c749SSergey Zigachev if (adjust_polarity) {
2226b843c749SSergey Zigachev *tdp_limit = ((100 + tdp_adjustment) * adev->pm.dpm.tdp_limit) / 100;
2227b843c749SSergey Zigachev *near_tdp_limit = adev->pm.dpm.near_tdp_limit_adjusted + (*tdp_limit - adev->pm.dpm.tdp_limit);
2228b843c749SSergey Zigachev } else {
2229b843c749SSergey Zigachev *tdp_limit = ((100 - tdp_adjustment) * adev->pm.dpm.tdp_limit) / 100;
2230b843c749SSergey Zigachev adjustment_delta = adev->pm.dpm.tdp_limit - *tdp_limit;
2231b843c749SSergey Zigachev if (adjustment_delta < adev->pm.dpm.near_tdp_limit_adjusted)
2232b843c749SSergey Zigachev *near_tdp_limit = adev->pm.dpm.near_tdp_limit_adjusted - adjustment_delta;
2233b843c749SSergey Zigachev else
2234b843c749SSergey Zigachev *near_tdp_limit = 0;
2235b843c749SSergey Zigachev }
2236b843c749SSergey Zigachev
2237b843c749SSergey Zigachev if ((*tdp_limit <= 0) || (*tdp_limit > max_tdp_limit))
2238b843c749SSergey Zigachev return -EINVAL;
2239b843c749SSergey Zigachev if ((*near_tdp_limit <= 0) || (*near_tdp_limit > *tdp_limit))
2240b843c749SSergey Zigachev return -EINVAL;
2241b843c749SSergey Zigachev
2242b843c749SSergey Zigachev return 0;
2243b843c749SSergey Zigachev }
2244b843c749SSergey Zigachev
si_populate_smc_tdp_limits(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state)2245b843c749SSergey Zigachev static int si_populate_smc_tdp_limits(struct amdgpu_device *adev,
2246b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state)
2247b843c749SSergey Zigachev {
2248b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2249b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2250b843c749SSergey Zigachev
2251b843c749SSergey Zigachev if (ni_pi->enable_power_containment) {
2252b843c749SSergey Zigachev SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable;
2253b843c749SSergey Zigachev PP_SIslands_PAPMParameters *papm_parm;
2254b843c749SSergey Zigachev struct amdgpu_ppm_table *ppm = adev->pm.dpm.dyn_state.ppm_table;
2255b843c749SSergey Zigachev u32 scaling_factor = si_get_smc_power_scaling_factor(adev);
2256b843c749SSergey Zigachev u32 tdp_limit;
2257b843c749SSergey Zigachev u32 near_tdp_limit;
2258b843c749SSergey Zigachev int ret;
2259b843c749SSergey Zigachev
2260b843c749SSergey Zigachev if (scaling_factor == 0)
2261b843c749SSergey Zigachev return -EINVAL;
2262b843c749SSergey Zigachev
2263b843c749SSergey Zigachev memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE));
2264b843c749SSergey Zigachev
2265b843c749SSergey Zigachev ret = si_calculate_adjusted_tdp_limits(adev,
2266b843c749SSergey Zigachev false, /* ??? */
2267b843c749SSergey Zigachev adev->pm.dpm.tdp_adjustment,
2268b843c749SSergey Zigachev &tdp_limit,
2269b843c749SSergey Zigachev &near_tdp_limit);
2270b843c749SSergey Zigachev if (ret)
2271b843c749SSergey Zigachev return ret;
2272b843c749SSergey Zigachev
2273b843c749SSergey Zigachev smc_table->dpm2Params.TDPLimit =
2274b843c749SSergey Zigachev cpu_to_be32(si_scale_power_for_smc(tdp_limit, scaling_factor) * 1000);
2275b843c749SSergey Zigachev smc_table->dpm2Params.NearTDPLimit =
2276b843c749SSergey Zigachev cpu_to_be32(si_scale_power_for_smc(near_tdp_limit, scaling_factor) * 1000);
2277b843c749SSergey Zigachev smc_table->dpm2Params.SafePowerLimit =
2278b843c749SSergey Zigachev cpu_to_be32(si_scale_power_for_smc((near_tdp_limit * SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT) / 100, scaling_factor) * 1000);
2279b843c749SSergey Zigachev
2280b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev,
2281b843c749SSergey Zigachev (si_pi->state_table_start + offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) +
2282b843c749SSergey Zigachev offsetof(PP_SIslands_DPM2Parameters, TDPLimit)),
2283b843c749SSergey Zigachev (u8 *)(&(smc_table->dpm2Params.TDPLimit)),
2284b843c749SSergey Zigachev sizeof(u32) * 3,
2285b843c749SSergey Zigachev si_pi->sram_end);
2286b843c749SSergey Zigachev if (ret)
2287b843c749SSergey Zigachev return ret;
2288b843c749SSergey Zigachev
2289b843c749SSergey Zigachev if (si_pi->enable_ppm) {
2290b843c749SSergey Zigachev papm_parm = &si_pi->papm_parm;
2291b843c749SSergey Zigachev memset(papm_parm, 0, sizeof(PP_SIslands_PAPMParameters));
2292b843c749SSergey Zigachev papm_parm->NearTDPLimitTherm = cpu_to_be32(ppm->dgpu_tdp);
2293b843c749SSergey Zigachev papm_parm->dGPU_T_Limit = cpu_to_be32(ppm->tj_max);
2294b843c749SSergey Zigachev papm_parm->dGPU_T_Warning = cpu_to_be32(95);
2295b843c749SSergey Zigachev papm_parm->dGPU_T_Hysteresis = cpu_to_be32(5);
2296b843c749SSergey Zigachev papm_parm->PlatformPowerLimit = 0xffffffff;
2297b843c749SSergey Zigachev papm_parm->NearTDPLimitPAPM = 0xffffffff;
2298b843c749SSergey Zigachev
2299b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->papm_cfg_table_start,
2300b843c749SSergey Zigachev (u8 *)papm_parm,
2301b843c749SSergey Zigachev sizeof(PP_SIslands_PAPMParameters),
2302b843c749SSergey Zigachev si_pi->sram_end);
2303b843c749SSergey Zigachev if (ret)
2304b843c749SSergey Zigachev return ret;
2305b843c749SSergey Zigachev }
2306b843c749SSergey Zigachev }
2307b843c749SSergey Zigachev return 0;
2308b843c749SSergey Zigachev }
2309b843c749SSergey Zigachev
si_populate_smc_tdp_limits_2(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state)2310b843c749SSergey Zigachev static int si_populate_smc_tdp_limits_2(struct amdgpu_device *adev,
2311b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state)
2312b843c749SSergey Zigachev {
2313b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2314b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2315b843c749SSergey Zigachev
2316b843c749SSergey Zigachev if (ni_pi->enable_power_containment) {
2317b843c749SSergey Zigachev SISLANDS_SMC_STATETABLE *smc_table = &si_pi->smc_statetable;
2318b843c749SSergey Zigachev u32 scaling_factor = si_get_smc_power_scaling_factor(adev);
2319b843c749SSergey Zigachev int ret;
2320b843c749SSergey Zigachev
2321b843c749SSergey Zigachev memset(smc_table, 0, sizeof(SISLANDS_SMC_STATETABLE));
2322b843c749SSergey Zigachev
2323b843c749SSergey Zigachev smc_table->dpm2Params.NearTDPLimit =
2324b843c749SSergey Zigachev cpu_to_be32(si_scale_power_for_smc(adev->pm.dpm.near_tdp_limit_adjusted, scaling_factor) * 1000);
2325b843c749SSergey Zigachev smc_table->dpm2Params.SafePowerLimit =
2326b843c749SSergey Zigachev 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);
2327b843c749SSergey Zigachev
2328b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev,
2329b843c749SSergey Zigachev (si_pi->state_table_start +
2330b843c749SSergey Zigachev offsetof(SISLANDS_SMC_STATETABLE, dpm2Params) +
2331b843c749SSergey Zigachev offsetof(PP_SIslands_DPM2Parameters, NearTDPLimit)),
2332b843c749SSergey Zigachev (u8 *)(&(smc_table->dpm2Params.NearTDPLimit)),
2333b843c749SSergey Zigachev sizeof(u32) * 2,
2334b843c749SSergey Zigachev si_pi->sram_end);
2335b843c749SSergey Zigachev if (ret)
2336b843c749SSergey Zigachev return ret;
2337b843c749SSergey Zigachev }
2338b843c749SSergey Zigachev
2339b843c749SSergey Zigachev return 0;
2340b843c749SSergey Zigachev }
2341b843c749SSergey Zigachev
si_calculate_power_efficiency_ratio(struct amdgpu_device * adev,const u16 prev_std_vddc,const u16 curr_std_vddc)2342b843c749SSergey Zigachev static u16 si_calculate_power_efficiency_ratio(struct amdgpu_device *adev,
2343b843c749SSergey Zigachev const u16 prev_std_vddc,
2344b843c749SSergey Zigachev const u16 curr_std_vddc)
2345b843c749SSergey Zigachev {
2346b843c749SSergey Zigachev u64 margin = (u64)SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN;
2347b843c749SSergey Zigachev u64 prev_vddc = (u64)prev_std_vddc;
2348b843c749SSergey Zigachev u64 curr_vddc = (u64)curr_std_vddc;
2349b843c749SSergey Zigachev u64 pwr_efficiency_ratio, n, d;
2350b843c749SSergey Zigachev
2351b843c749SSergey Zigachev if ((prev_vddc == 0) || (curr_vddc == 0))
2352b843c749SSergey Zigachev return 0;
2353b843c749SSergey Zigachev
2354b843c749SSergey Zigachev n = div64_u64((u64)1024 * curr_vddc * curr_vddc * ((u64)1000 + margin), (u64)1000);
2355b843c749SSergey Zigachev d = prev_vddc * prev_vddc;
2356b843c749SSergey Zigachev pwr_efficiency_ratio = div64_u64(n, d);
2357b843c749SSergey Zigachev
2358b843c749SSergey Zigachev if (pwr_efficiency_ratio > (u64)0xFFFF)
2359b843c749SSergey Zigachev return 0;
2360b843c749SSergey Zigachev
2361b843c749SSergey Zigachev return (u16)pwr_efficiency_ratio;
2362b843c749SSergey Zigachev }
2363b843c749SSergey Zigachev
si_should_disable_uvd_powertune(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state)2364b843c749SSergey Zigachev static bool si_should_disable_uvd_powertune(struct amdgpu_device *adev,
2365b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state)
2366b843c749SSergey Zigachev {
2367b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2368b843c749SSergey Zigachev
2369b843c749SSergey Zigachev if (si_pi->dyn_powertune_data.disable_uvd_powertune &&
2370b843c749SSergey Zigachev amdgpu_state->vclk && amdgpu_state->dclk)
2371b843c749SSergey Zigachev return true;
2372b843c749SSergey Zigachev
2373b843c749SSergey Zigachev return false;
2374b843c749SSergey Zigachev }
2375b843c749SSergey Zigachev
evergreen_get_pi(struct amdgpu_device * adev)2376b843c749SSergey Zigachev struct evergreen_power_info *evergreen_get_pi(struct amdgpu_device *adev)
2377b843c749SSergey Zigachev {
2378b843c749SSergey Zigachev struct evergreen_power_info *pi = adev->pm.dpm.priv;
2379b843c749SSergey Zigachev
2380b843c749SSergey Zigachev return pi;
2381b843c749SSergey Zigachev }
2382b843c749SSergey Zigachev
si_populate_power_containment_values(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state,SISLANDS_SMC_SWSTATE * smc_state)2383b843c749SSergey Zigachev static int si_populate_power_containment_values(struct amdgpu_device *adev,
2384b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state,
2385b843c749SSergey Zigachev SISLANDS_SMC_SWSTATE *smc_state)
2386b843c749SSergey Zigachev {
2387b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
2388b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2389b843c749SSergey Zigachev struct si_ps *state = si_get_ps(amdgpu_state);
2390b843c749SSergey Zigachev SISLANDS_SMC_VOLTAGE_VALUE vddc;
2391b843c749SSergey Zigachev u32 prev_sclk;
2392b843c749SSergey Zigachev u32 max_sclk;
2393b843c749SSergey Zigachev u32 min_sclk;
2394b843c749SSergey Zigachev u16 prev_std_vddc;
2395b843c749SSergey Zigachev u16 curr_std_vddc;
2396b843c749SSergey Zigachev int i;
2397b843c749SSergey Zigachev u16 pwr_efficiency_ratio;
2398b843c749SSergey Zigachev u8 max_ps_percent;
2399b843c749SSergey Zigachev bool disable_uvd_power_tune;
2400b843c749SSergey Zigachev int ret;
2401b843c749SSergey Zigachev
2402b843c749SSergey Zigachev if (ni_pi->enable_power_containment == false)
2403b843c749SSergey Zigachev return 0;
2404b843c749SSergey Zigachev
2405b843c749SSergey Zigachev if (state->performance_level_count == 0)
2406b843c749SSergey Zigachev return -EINVAL;
2407b843c749SSergey Zigachev
2408b843c749SSergey Zigachev if (smc_state->levelCount != state->performance_level_count)
2409b843c749SSergey Zigachev return -EINVAL;
2410b843c749SSergey Zigachev
2411b843c749SSergey Zigachev disable_uvd_power_tune = si_should_disable_uvd_powertune(adev, amdgpu_state);
2412b843c749SSergey Zigachev
2413b843c749SSergey Zigachev smc_state->levels[0].dpm2.MaxPS = 0;
2414b843c749SSergey Zigachev smc_state->levels[0].dpm2.NearTDPDec = 0;
2415b843c749SSergey Zigachev smc_state->levels[0].dpm2.AboveSafeInc = 0;
2416b843c749SSergey Zigachev smc_state->levels[0].dpm2.BelowSafeInc = 0;
2417b843c749SSergey Zigachev smc_state->levels[0].dpm2.PwrEfficiencyRatio = 0;
2418b843c749SSergey Zigachev
2419b843c749SSergey Zigachev for (i = 1; i < state->performance_level_count; i++) {
2420b843c749SSergey Zigachev prev_sclk = state->performance_levels[i-1].sclk;
2421b843c749SSergey Zigachev max_sclk = state->performance_levels[i].sclk;
2422b843c749SSergey Zigachev if (i == 1)
2423b843c749SSergey Zigachev max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_M;
2424b843c749SSergey Zigachev else
2425b843c749SSergey Zigachev max_ps_percent = SISLANDS_DPM2_MAXPS_PERCENT_H;
2426b843c749SSergey Zigachev
2427b843c749SSergey Zigachev if (prev_sclk > max_sclk)
2428b843c749SSergey Zigachev return -EINVAL;
2429b843c749SSergey Zigachev
2430b843c749SSergey Zigachev if ((max_ps_percent == 0) ||
2431b843c749SSergey Zigachev (prev_sclk == max_sclk) ||
2432b843c749SSergey Zigachev disable_uvd_power_tune)
2433b843c749SSergey Zigachev min_sclk = max_sclk;
2434b843c749SSergey Zigachev else if (i == 1)
2435b843c749SSergey Zigachev min_sclk = prev_sclk;
2436b843c749SSergey Zigachev else
2437b843c749SSergey Zigachev min_sclk = (prev_sclk * (u32)max_ps_percent) / 100;
2438b843c749SSergey Zigachev
2439b843c749SSergey Zigachev if (min_sclk < state->performance_levels[0].sclk)
2440b843c749SSergey Zigachev min_sclk = state->performance_levels[0].sclk;
2441b843c749SSergey Zigachev
2442b843c749SSergey Zigachev if (min_sclk == 0)
2443b843c749SSergey Zigachev return -EINVAL;
2444b843c749SSergey Zigachev
2445b843c749SSergey Zigachev ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
2446b843c749SSergey Zigachev state->performance_levels[i-1].vddc, &vddc);
2447b843c749SSergey Zigachev if (ret)
2448b843c749SSergey Zigachev return ret;
2449b843c749SSergey Zigachev
2450b843c749SSergey Zigachev ret = si_get_std_voltage_value(adev, &vddc, &prev_std_vddc);
2451b843c749SSergey Zigachev if (ret)
2452b843c749SSergey Zigachev return ret;
2453b843c749SSergey Zigachev
2454b843c749SSergey Zigachev ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
2455b843c749SSergey Zigachev state->performance_levels[i].vddc, &vddc);
2456b843c749SSergey Zigachev if (ret)
2457b843c749SSergey Zigachev return ret;
2458b843c749SSergey Zigachev
2459b843c749SSergey Zigachev ret = si_get_std_voltage_value(adev, &vddc, &curr_std_vddc);
2460b843c749SSergey Zigachev if (ret)
2461b843c749SSergey Zigachev return ret;
2462b843c749SSergey Zigachev
2463b843c749SSergey Zigachev pwr_efficiency_ratio = si_calculate_power_efficiency_ratio(adev,
2464b843c749SSergey Zigachev prev_std_vddc, curr_std_vddc);
2465b843c749SSergey Zigachev
2466b843c749SSergey Zigachev smc_state->levels[i].dpm2.MaxPS = (u8)((SISLANDS_DPM2_MAX_PULSE_SKIP * (max_sclk - min_sclk)) / max_sclk);
2467b843c749SSergey Zigachev smc_state->levels[i].dpm2.NearTDPDec = SISLANDS_DPM2_NEAR_TDP_DEC;
2468b843c749SSergey Zigachev smc_state->levels[i].dpm2.AboveSafeInc = SISLANDS_DPM2_ABOVE_SAFE_INC;
2469b843c749SSergey Zigachev smc_state->levels[i].dpm2.BelowSafeInc = SISLANDS_DPM2_BELOW_SAFE_INC;
2470b843c749SSergey Zigachev smc_state->levels[i].dpm2.PwrEfficiencyRatio = cpu_to_be16(pwr_efficiency_ratio);
2471b843c749SSergey Zigachev }
2472b843c749SSergey Zigachev
2473b843c749SSergey Zigachev return 0;
2474b843c749SSergey Zigachev }
2475b843c749SSergey Zigachev
si_populate_sq_ramping_values(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state,SISLANDS_SMC_SWSTATE * smc_state)2476b843c749SSergey Zigachev static int si_populate_sq_ramping_values(struct amdgpu_device *adev,
2477b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state,
2478b843c749SSergey Zigachev SISLANDS_SMC_SWSTATE *smc_state)
2479b843c749SSergey Zigachev {
2480b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2481b843c749SSergey Zigachev struct si_ps *state = si_get_ps(amdgpu_state);
2482b843c749SSergey Zigachev u32 sq_power_throttle, sq_power_throttle2;
2483b843c749SSergey Zigachev bool enable_sq_ramping = ni_pi->enable_sq_ramping;
2484b843c749SSergey Zigachev int i;
2485b843c749SSergey Zigachev
2486b843c749SSergey Zigachev if (state->performance_level_count == 0)
2487b843c749SSergey Zigachev return -EINVAL;
2488b843c749SSergey Zigachev
2489b843c749SSergey Zigachev if (smc_state->levelCount != state->performance_level_count)
2490b843c749SSergey Zigachev return -EINVAL;
2491b843c749SSergey Zigachev
2492b843c749SSergey Zigachev if (adev->pm.dpm.sq_ramping_threshold == 0)
2493b843c749SSergey Zigachev return -EINVAL;
2494b843c749SSergey Zigachev
2495b843c749SSergey Zigachev if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER > (MAX_POWER_MASK >> MAX_POWER_SHIFT))
2496b843c749SSergey Zigachev enable_sq_ramping = false;
2497b843c749SSergey Zigachev
2498b843c749SSergey Zigachev if (SISLANDS_DPM2_SQ_RAMP_MIN_POWER > (MIN_POWER_MASK >> MIN_POWER_SHIFT))
2499b843c749SSergey Zigachev enable_sq_ramping = false;
2500b843c749SSergey Zigachev
2501b843c749SSergey Zigachev if (SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA > (MAX_POWER_DELTA_MASK >> MAX_POWER_DELTA_SHIFT))
2502b843c749SSergey Zigachev enable_sq_ramping = false;
2503b843c749SSergey Zigachev
2504b843c749SSergey Zigachev if (SISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT))
2505b843c749SSergey Zigachev enable_sq_ramping = false;
2506b843c749SSergey Zigachev
2507b843c749SSergey Zigachev if (SISLANDS_DPM2_SQ_RAMP_LTI_RATIO > (LTI_RATIO_MASK >> LTI_RATIO_SHIFT))
2508b843c749SSergey Zigachev enable_sq_ramping = false;
2509b843c749SSergey Zigachev
2510b843c749SSergey Zigachev for (i = 0; i < state->performance_level_count; i++) {
2511b843c749SSergey Zigachev sq_power_throttle = 0;
2512b843c749SSergey Zigachev sq_power_throttle2 = 0;
2513b843c749SSergey Zigachev
2514b843c749SSergey Zigachev if ((state->performance_levels[i].sclk >= adev->pm.dpm.sq_ramping_threshold) &&
2515b843c749SSergey Zigachev enable_sq_ramping) {
2516b843c749SSergey Zigachev sq_power_throttle |= MAX_POWER(SISLANDS_DPM2_SQ_RAMP_MAX_POWER);
2517b843c749SSergey Zigachev sq_power_throttle |= MIN_POWER(SISLANDS_DPM2_SQ_RAMP_MIN_POWER);
2518b843c749SSergey Zigachev sq_power_throttle2 |= MAX_POWER_DELTA(SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA);
2519b843c749SSergey Zigachev sq_power_throttle2 |= STI_SIZE(SISLANDS_DPM2_SQ_RAMP_STI_SIZE);
2520b843c749SSergey Zigachev sq_power_throttle2 |= LTI_RATIO(SISLANDS_DPM2_SQ_RAMP_LTI_RATIO);
2521b843c749SSergey Zigachev } else {
2522b843c749SSergey Zigachev sq_power_throttle |= MAX_POWER_MASK | MIN_POWER_MASK;
2523b843c749SSergey Zigachev sq_power_throttle2 |= MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
2524b843c749SSergey Zigachev }
2525b843c749SSergey Zigachev
2526b843c749SSergey Zigachev smc_state->levels[i].SQPowerThrottle = cpu_to_be32(sq_power_throttle);
2527b843c749SSergey Zigachev smc_state->levels[i].SQPowerThrottle_2 = cpu_to_be32(sq_power_throttle2);
2528b843c749SSergey Zigachev }
2529b843c749SSergey Zigachev
2530b843c749SSergey Zigachev return 0;
2531b843c749SSergey Zigachev }
2532b843c749SSergey Zigachev
si_enable_power_containment(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state,bool enable)2533b843c749SSergey Zigachev static int si_enable_power_containment(struct amdgpu_device *adev,
2534b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state,
2535b843c749SSergey Zigachev bool enable)
2536b843c749SSergey Zigachev {
2537b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2538b843c749SSergey Zigachev PPSMC_Result smc_result;
2539b843c749SSergey Zigachev int ret = 0;
2540b843c749SSergey Zigachev
2541b843c749SSergey Zigachev if (ni_pi->enable_power_containment) {
2542b843c749SSergey Zigachev if (enable) {
2543b843c749SSergey Zigachev if (!si_should_disable_uvd_powertune(adev, amdgpu_new_state)) {
2544b843c749SSergey Zigachev smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_TDPClampingActive);
2545b843c749SSergey Zigachev if (smc_result != PPSMC_Result_OK) {
2546b843c749SSergey Zigachev ret = -EINVAL;
2547b843c749SSergey Zigachev ni_pi->pc_enabled = false;
2548b843c749SSergey Zigachev } else {
2549b843c749SSergey Zigachev ni_pi->pc_enabled = true;
2550b843c749SSergey Zigachev }
2551b843c749SSergey Zigachev }
2552b843c749SSergey Zigachev } else {
2553b843c749SSergey Zigachev smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_TDPClampingInactive);
2554b843c749SSergey Zigachev if (smc_result != PPSMC_Result_OK)
2555b843c749SSergey Zigachev ret = -EINVAL;
2556b843c749SSergey Zigachev ni_pi->pc_enabled = false;
2557b843c749SSergey Zigachev }
2558b843c749SSergey Zigachev }
2559b843c749SSergey Zigachev
2560b843c749SSergey Zigachev return ret;
2561b843c749SSergey Zigachev }
2562b843c749SSergey Zigachev
si_initialize_smc_dte_tables(struct amdgpu_device * adev)2563b843c749SSergey Zigachev static int si_initialize_smc_dte_tables(struct amdgpu_device *adev)
2564b843c749SSergey Zigachev {
2565b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2566b843c749SSergey Zigachev int ret = 0;
2567b843c749SSergey Zigachev struct si_dte_data *dte_data = &si_pi->dte_data;
2568b843c749SSergey Zigachev Smc_SIslands_DTE_Configuration *dte_tables = NULL;
2569b843c749SSergey Zigachev u32 table_size;
2570b843c749SSergey Zigachev u8 tdep_count;
2571b843c749SSergey Zigachev u32 i;
2572b843c749SSergey Zigachev
2573b843c749SSergey Zigachev if (dte_data == NULL)
2574b843c749SSergey Zigachev si_pi->enable_dte = false;
2575b843c749SSergey Zigachev
2576b843c749SSergey Zigachev if (si_pi->enable_dte == false)
2577b843c749SSergey Zigachev return 0;
2578b843c749SSergey Zigachev
2579b843c749SSergey Zigachev if (dte_data->k <= 0)
2580b843c749SSergey Zigachev return -EINVAL;
2581b843c749SSergey Zigachev
2582b843c749SSergey Zigachev dte_tables = kzalloc(sizeof(Smc_SIslands_DTE_Configuration), GFP_KERNEL);
2583b843c749SSergey Zigachev if (dte_tables == NULL) {
2584b843c749SSergey Zigachev si_pi->enable_dte = false;
2585b843c749SSergey Zigachev return -ENOMEM;
2586b843c749SSergey Zigachev }
2587b843c749SSergey Zigachev
2588b843c749SSergey Zigachev table_size = dte_data->k;
2589b843c749SSergey Zigachev
2590b843c749SSergey Zigachev if (table_size > SMC_SISLANDS_DTE_MAX_FILTER_STAGES)
2591b843c749SSergey Zigachev table_size = SMC_SISLANDS_DTE_MAX_FILTER_STAGES;
2592b843c749SSergey Zigachev
2593b843c749SSergey Zigachev tdep_count = dte_data->tdep_count;
2594b843c749SSergey Zigachev if (tdep_count > SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE)
2595b843c749SSergey Zigachev tdep_count = SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE;
2596b843c749SSergey Zigachev
2597b843c749SSergey Zigachev dte_tables->K = cpu_to_be32(table_size);
2598b843c749SSergey Zigachev dte_tables->T0 = cpu_to_be32(dte_data->t0);
2599b843c749SSergey Zigachev dte_tables->MaxT = cpu_to_be32(dte_data->max_t);
2600b843c749SSergey Zigachev dte_tables->WindowSize = dte_data->window_size;
2601b843c749SSergey Zigachev dte_tables->temp_select = dte_data->temp_select;
2602b843c749SSergey Zigachev dte_tables->DTE_mode = dte_data->dte_mode;
2603b843c749SSergey Zigachev dte_tables->Tthreshold = cpu_to_be32(dte_data->t_threshold);
2604b843c749SSergey Zigachev
2605b843c749SSergey Zigachev if (tdep_count > 0)
2606b843c749SSergey Zigachev table_size--;
2607b843c749SSergey Zigachev
2608b843c749SSergey Zigachev for (i = 0; i < table_size; i++) {
2609b843c749SSergey Zigachev dte_tables->tau[i] = cpu_to_be32(dte_data->tau[i]);
2610b843c749SSergey Zigachev dte_tables->R[i] = cpu_to_be32(dte_data->r[i]);
2611b843c749SSergey Zigachev }
2612b843c749SSergey Zigachev
2613b843c749SSergey Zigachev dte_tables->Tdep_count = tdep_count;
2614b843c749SSergey Zigachev
2615b843c749SSergey Zigachev for (i = 0; i < (u32)tdep_count; i++) {
2616b843c749SSergey Zigachev dte_tables->T_limits[i] = dte_data->t_limits[i];
2617b843c749SSergey Zigachev dte_tables->Tdep_tau[i] = cpu_to_be32(dte_data->tdep_tau[i]);
2618b843c749SSergey Zigachev dte_tables->Tdep_R[i] = cpu_to_be32(dte_data->tdep_r[i]);
2619b843c749SSergey Zigachev }
2620b843c749SSergey Zigachev
2621b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->dte_table_start,
2622b843c749SSergey Zigachev (u8 *)dte_tables,
2623b843c749SSergey Zigachev sizeof(Smc_SIslands_DTE_Configuration),
2624b843c749SSergey Zigachev si_pi->sram_end);
2625b843c749SSergey Zigachev kfree(dte_tables);
2626b843c749SSergey Zigachev
2627b843c749SSergey Zigachev return ret;
2628b843c749SSergey Zigachev }
2629b843c749SSergey Zigachev
si_get_cac_std_voltage_max_min(struct amdgpu_device * adev,u16 * max,u16 * min)2630b843c749SSergey Zigachev static int si_get_cac_std_voltage_max_min(struct amdgpu_device *adev,
2631b843c749SSergey Zigachev u16 *max, u16 *min)
2632b843c749SSergey Zigachev {
2633b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2634b843c749SSergey Zigachev struct amdgpu_cac_leakage_table *table =
2635b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.cac_leakage_table;
2636b843c749SSergey Zigachev u32 i;
2637b843c749SSergey Zigachev u32 v0_loadline;
2638b843c749SSergey Zigachev
2639b843c749SSergey Zigachev if (table == NULL)
2640b843c749SSergey Zigachev return -EINVAL;
2641b843c749SSergey Zigachev
2642b843c749SSergey Zigachev *max = 0;
2643b843c749SSergey Zigachev *min = 0xFFFF;
2644b843c749SSergey Zigachev
2645b843c749SSergey Zigachev for (i = 0; i < table->count; i++) {
2646b843c749SSergey Zigachev if (table->entries[i].vddc > *max)
2647b843c749SSergey Zigachev *max = table->entries[i].vddc;
2648b843c749SSergey Zigachev if (table->entries[i].vddc < *min)
2649b843c749SSergey Zigachev *min = table->entries[i].vddc;
2650b843c749SSergey Zigachev }
2651b843c749SSergey Zigachev
2652b843c749SSergey Zigachev if (si_pi->powertune_data->lkge_lut_v0_percent > 100)
2653b843c749SSergey Zigachev return -EINVAL;
2654b843c749SSergey Zigachev
2655b843c749SSergey Zigachev v0_loadline = (*min) * (100 - si_pi->powertune_data->lkge_lut_v0_percent) / 100;
2656b843c749SSergey Zigachev
2657b843c749SSergey Zigachev if (v0_loadline > 0xFFFFUL)
2658b843c749SSergey Zigachev return -EINVAL;
2659b843c749SSergey Zigachev
2660b843c749SSergey Zigachev *min = (u16)v0_loadline;
2661b843c749SSergey Zigachev
2662b843c749SSergey Zigachev if ((*min > *max) || (*max == 0) || (*min == 0))
2663b843c749SSergey Zigachev return -EINVAL;
2664b843c749SSergey Zigachev
2665b843c749SSergey Zigachev return 0;
2666b843c749SSergey Zigachev }
2667b843c749SSergey Zigachev
si_get_cac_std_voltage_step(u16 max,u16 min)2668b843c749SSergey Zigachev static u16 si_get_cac_std_voltage_step(u16 max, u16 min)
2669b843c749SSergey Zigachev {
2670b843c749SSergey Zigachev return ((max - min) + (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1)) /
2671b843c749SSergey Zigachev SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES;
2672b843c749SSergey Zigachev }
2673b843c749SSergey Zigachev
si_init_dte_leakage_table(struct amdgpu_device * adev,PP_SIslands_CacConfig * cac_tables,u16 vddc_max,u16 vddc_min,u16 vddc_step,u16 t0,u16 t_step)2674b843c749SSergey Zigachev static int si_init_dte_leakage_table(struct amdgpu_device *adev,
2675b843c749SSergey Zigachev PP_SIslands_CacConfig *cac_tables,
2676b843c749SSergey Zigachev u16 vddc_max, u16 vddc_min, u16 vddc_step,
2677b843c749SSergey Zigachev u16 t0, u16 t_step)
2678b843c749SSergey Zigachev {
2679b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2680b843c749SSergey Zigachev u32 leakage;
2681b843c749SSergey Zigachev unsigned int i, j;
2682b843c749SSergey Zigachev s32 t;
2683b843c749SSergey Zigachev u32 smc_leakage;
2684b843c749SSergey Zigachev u32 scaling_factor;
2685b843c749SSergey Zigachev u16 voltage;
2686b843c749SSergey Zigachev
2687b843c749SSergey Zigachev scaling_factor = si_get_smc_power_scaling_factor(adev);
2688b843c749SSergey Zigachev
2689b843c749SSergey Zigachev for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++) {
2690b843c749SSergey Zigachev t = (1000 * (i * t_step + t0));
2691b843c749SSergey Zigachev
2692b843c749SSergey Zigachev for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) {
2693b843c749SSergey Zigachev voltage = vddc_max - (vddc_step * j);
2694b843c749SSergey Zigachev
2695b843c749SSergey Zigachev si_calculate_leakage_for_v_and_t(adev,
2696b843c749SSergey Zigachev &si_pi->powertune_data->leakage_coefficients,
2697b843c749SSergey Zigachev voltage,
2698b843c749SSergey Zigachev t,
2699b843c749SSergey Zigachev si_pi->dyn_powertune_data.cac_leakage,
2700b843c749SSergey Zigachev &leakage);
2701b843c749SSergey Zigachev
2702b843c749SSergey Zigachev smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4;
2703b843c749SSergey Zigachev
2704b843c749SSergey Zigachev if (smc_leakage > 0xFFFF)
2705b843c749SSergey Zigachev smc_leakage = 0xFFFF;
2706b843c749SSergey Zigachev
2707b843c749SSergey Zigachev cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] =
2708b843c749SSergey Zigachev cpu_to_be16((u16)smc_leakage);
2709b843c749SSergey Zigachev }
2710b843c749SSergey Zigachev }
2711b843c749SSergey Zigachev return 0;
2712b843c749SSergey Zigachev }
2713b843c749SSergey Zigachev
si_init_simplified_leakage_table(struct amdgpu_device * adev,PP_SIslands_CacConfig * cac_tables,u16 vddc_max,u16 vddc_min,u16 vddc_step)2714b843c749SSergey Zigachev static int si_init_simplified_leakage_table(struct amdgpu_device *adev,
2715b843c749SSergey Zigachev PP_SIslands_CacConfig *cac_tables,
2716b843c749SSergey Zigachev u16 vddc_max, u16 vddc_min, u16 vddc_step)
2717b843c749SSergey Zigachev {
2718b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2719b843c749SSergey Zigachev u32 leakage;
2720b843c749SSergey Zigachev unsigned int i, j;
2721b843c749SSergey Zigachev u32 smc_leakage;
2722b843c749SSergey Zigachev u32 scaling_factor;
2723b843c749SSergey Zigachev u16 voltage;
2724b843c749SSergey Zigachev
2725b843c749SSergey Zigachev scaling_factor = si_get_smc_power_scaling_factor(adev);
2726b843c749SSergey Zigachev
2727b843c749SSergey Zigachev for (j = 0; j < SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES; j++) {
2728b843c749SSergey Zigachev voltage = vddc_max - (vddc_step * j);
2729b843c749SSergey Zigachev
2730b843c749SSergey Zigachev si_calculate_leakage_for_v(adev,
2731b843c749SSergey Zigachev &si_pi->powertune_data->leakage_coefficients,
2732b843c749SSergey Zigachev si_pi->powertune_data->fixed_kt,
2733b843c749SSergey Zigachev voltage,
2734b843c749SSergey Zigachev si_pi->dyn_powertune_data.cac_leakage,
2735b843c749SSergey Zigachev &leakage);
2736b843c749SSergey Zigachev
2737b843c749SSergey Zigachev smc_leakage = si_scale_power_for_smc(leakage, scaling_factor) / 4;
2738b843c749SSergey Zigachev
2739b843c749SSergey Zigachev if (smc_leakage > 0xFFFF)
2740b843c749SSergey Zigachev smc_leakage = 0xFFFF;
2741b843c749SSergey Zigachev
2742b843c749SSergey Zigachev for (i = 0; i < SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES ; i++)
2743b843c749SSergey Zigachev cac_tables->cac_lkge_lut[i][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES-1-j] =
2744b843c749SSergey Zigachev cpu_to_be16((u16)smc_leakage);
2745b843c749SSergey Zigachev }
2746b843c749SSergey Zigachev return 0;
2747b843c749SSergey Zigachev }
2748b843c749SSergey Zigachev
si_initialize_smc_cac_tables(struct amdgpu_device * adev)2749b843c749SSergey Zigachev static int si_initialize_smc_cac_tables(struct amdgpu_device *adev)
2750b843c749SSergey Zigachev {
2751b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2752b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2753b843c749SSergey Zigachev PP_SIslands_CacConfig *cac_tables = NULL;
2754b843c749SSergey Zigachev u16 vddc_max, vddc_min, vddc_step;
2755b843c749SSergey Zigachev u16 t0, t_step;
2756b843c749SSergey Zigachev u32 load_line_slope, reg;
2757b843c749SSergey Zigachev int ret = 0;
2758b843c749SSergey Zigachev u32 ticks_per_us = amdgpu_asic_get_xclk(adev) / 100;
2759b843c749SSergey Zigachev
2760b843c749SSergey Zigachev if (ni_pi->enable_cac == false)
2761b843c749SSergey Zigachev return 0;
2762b843c749SSergey Zigachev
2763b843c749SSergey Zigachev cac_tables = kzalloc(sizeof(PP_SIslands_CacConfig), GFP_KERNEL);
2764b843c749SSergey Zigachev if (!cac_tables)
2765b843c749SSergey Zigachev return -ENOMEM;
2766b843c749SSergey Zigachev
2767b843c749SSergey Zigachev reg = RREG32(CG_CAC_CTRL) & ~CAC_WINDOW_MASK;
2768b843c749SSergey Zigachev reg |= CAC_WINDOW(si_pi->powertune_data->cac_window);
2769b843c749SSergey Zigachev WREG32(CG_CAC_CTRL, reg);
2770b843c749SSergey Zigachev
2771b843c749SSergey Zigachev si_pi->dyn_powertune_data.cac_leakage = adev->pm.dpm.cac_leakage;
2772b843c749SSergey Zigachev si_pi->dyn_powertune_data.dc_pwr_value =
2773b843c749SSergey Zigachev si_pi->powertune_data->dc_cac[NISLANDS_DCCAC_LEVEL_0];
2774b843c749SSergey Zigachev si_pi->dyn_powertune_data.wintime = si_calculate_cac_wintime(adev);
2775b843c749SSergey Zigachev si_pi->dyn_powertune_data.shift_n = si_pi->powertune_data->shift_n_default;
2776b843c749SSergey Zigachev
2777b843c749SSergey Zigachev si_pi->dyn_powertune_data.leakage_minimum_temperature = 80 * 1000;
2778b843c749SSergey Zigachev
2779b843c749SSergey Zigachev ret = si_get_cac_std_voltage_max_min(adev, &vddc_max, &vddc_min);
2780b843c749SSergey Zigachev if (ret)
2781b843c749SSergey Zigachev goto done_free;
2782b843c749SSergey Zigachev
2783b843c749SSergey Zigachev vddc_step = si_get_cac_std_voltage_step(vddc_max, vddc_min);
2784b843c749SSergey Zigachev vddc_min = vddc_max - (vddc_step * (SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES - 1));
2785b843c749SSergey Zigachev t_step = 4;
2786b843c749SSergey Zigachev t0 = 60;
2787b843c749SSergey Zigachev
2788b843c749SSergey Zigachev if (si_pi->enable_dte || ni_pi->driver_calculate_cac_leakage)
2789b843c749SSergey Zigachev ret = si_init_dte_leakage_table(adev, cac_tables,
2790b843c749SSergey Zigachev vddc_max, vddc_min, vddc_step,
2791b843c749SSergey Zigachev t0, t_step);
2792b843c749SSergey Zigachev else
2793b843c749SSergey Zigachev ret = si_init_simplified_leakage_table(adev, cac_tables,
2794b843c749SSergey Zigachev vddc_max, vddc_min, vddc_step);
2795b843c749SSergey Zigachev if (ret)
2796b843c749SSergey Zigachev goto done_free;
2797b843c749SSergey Zigachev
2798b843c749SSergey Zigachev load_line_slope = ((u32)adev->pm.dpm.load_line_slope << SMC_SISLANDS_SCALE_R) / 100;
2799b843c749SSergey Zigachev
2800b843c749SSergey Zigachev cac_tables->l2numWin_TDP = cpu_to_be32(si_pi->dyn_powertune_data.l2_lta_window_size);
2801b843c749SSergey Zigachev cac_tables->lts_truncate_n = si_pi->dyn_powertune_data.lts_truncate;
2802b843c749SSergey Zigachev cac_tables->SHIFT_N = si_pi->dyn_powertune_data.shift_n;
2803b843c749SSergey Zigachev cac_tables->lkge_lut_V0 = cpu_to_be32((u32)vddc_min);
2804b843c749SSergey Zigachev cac_tables->lkge_lut_Vstep = cpu_to_be32((u32)vddc_step);
2805b843c749SSergey Zigachev cac_tables->R_LL = cpu_to_be32(load_line_slope);
2806b843c749SSergey Zigachev cac_tables->WinTime = cpu_to_be32(si_pi->dyn_powertune_data.wintime);
2807b843c749SSergey Zigachev cac_tables->calculation_repeats = cpu_to_be32(2);
2808b843c749SSergey Zigachev cac_tables->dc_cac = cpu_to_be32(0);
2809b843c749SSergey Zigachev cac_tables->log2_PG_LKG_SCALE = 12;
2810b843c749SSergey Zigachev cac_tables->cac_temp = si_pi->powertune_data->operating_temp;
2811b843c749SSergey Zigachev cac_tables->lkge_lut_T0 = cpu_to_be32((u32)t0);
2812b843c749SSergey Zigachev cac_tables->lkge_lut_Tstep = cpu_to_be32((u32)t_step);
2813b843c749SSergey Zigachev
2814b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->cac_table_start,
2815b843c749SSergey Zigachev (u8 *)cac_tables,
2816b843c749SSergey Zigachev sizeof(PP_SIslands_CacConfig),
2817b843c749SSergey Zigachev si_pi->sram_end);
2818b843c749SSergey Zigachev
2819b843c749SSergey Zigachev if (ret)
2820b843c749SSergey Zigachev goto done_free;
2821b843c749SSergey Zigachev
2822b843c749SSergey Zigachev ret = si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_ticks_per_us, ticks_per_us);
2823b843c749SSergey Zigachev
2824b843c749SSergey Zigachev done_free:
2825b843c749SSergey Zigachev if (ret) {
2826b843c749SSergey Zigachev ni_pi->enable_cac = false;
2827b843c749SSergey Zigachev ni_pi->enable_power_containment = false;
2828b843c749SSergey Zigachev }
2829b843c749SSergey Zigachev
2830b843c749SSergey Zigachev kfree(cac_tables);
2831b843c749SSergey Zigachev
2832b843c749SSergey Zigachev return ret;
2833b843c749SSergey Zigachev }
2834b843c749SSergey Zigachev
si_program_cac_config_registers(struct amdgpu_device * adev,const struct si_cac_config_reg * cac_config_regs)2835b843c749SSergey Zigachev static int si_program_cac_config_registers(struct amdgpu_device *adev,
2836b843c749SSergey Zigachev const struct si_cac_config_reg *cac_config_regs)
2837b843c749SSergey Zigachev {
2838b843c749SSergey Zigachev const struct si_cac_config_reg *config_regs = cac_config_regs;
2839b843c749SSergey Zigachev u32 data = 0, offset;
2840b843c749SSergey Zigachev
2841b843c749SSergey Zigachev if (!config_regs)
2842b843c749SSergey Zigachev return -EINVAL;
2843b843c749SSergey Zigachev
2844b843c749SSergey Zigachev while (config_regs->offset != 0xFFFFFFFF) {
2845b843c749SSergey Zigachev switch (config_regs->type) {
2846b843c749SSergey Zigachev case SISLANDS_CACCONFIG_CGIND:
2847b843c749SSergey Zigachev offset = SMC_CG_IND_START + config_regs->offset;
2848b843c749SSergey Zigachev if (offset < SMC_CG_IND_END)
2849b843c749SSergey Zigachev data = RREG32_SMC(offset);
2850b843c749SSergey Zigachev break;
2851b843c749SSergey Zigachev default:
2852b843c749SSergey Zigachev data = RREG32(config_regs->offset);
2853b843c749SSergey Zigachev break;
2854b843c749SSergey Zigachev }
2855b843c749SSergey Zigachev
2856b843c749SSergey Zigachev data &= ~config_regs->mask;
2857b843c749SSergey Zigachev data |= ((config_regs->value << config_regs->shift) & config_regs->mask);
2858b843c749SSergey Zigachev
2859b843c749SSergey Zigachev switch (config_regs->type) {
2860b843c749SSergey Zigachev case SISLANDS_CACCONFIG_CGIND:
2861b843c749SSergey Zigachev offset = SMC_CG_IND_START + config_regs->offset;
2862b843c749SSergey Zigachev if (offset < SMC_CG_IND_END)
2863b843c749SSergey Zigachev WREG32_SMC(offset, data);
2864b843c749SSergey Zigachev break;
2865b843c749SSergey Zigachev default:
2866b843c749SSergey Zigachev WREG32(config_regs->offset, data);
2867b843c749SSergey Zigachev break;
2868b843c749SSergey Zigachev }
2869b843c749SSergey Zigachev config_regs++;
2870b843c749SSergey Zigachev }
2871b843c749SSergey Zigachev return 0;
2872b843c749SSergey Zigachev }
2873b843c749SSergey Zigachev
si_initialize_hardware_cac_manager(struct amdgpu_device * adev)2874b843c749SSergey Zigachev static int si_initialize_hardware_cac_manager(struct amdgpu_device *adev)
2875b843c749SSergey Zigachev {
2876b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2877b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2878b843c749SSergey Zigachev int ret;
2879b843c749SSergey Zigachev
2880b843c749SSergey Zigachev if ((ni_pi->enable_cac == false) ||
2881b843c749SSergey Zigachev (ni_pi->cac_configuration_required == false))
2882b843c749SSergey Zigachev return 0;
2883b843c749SSergey Zigachev
2884b843c749SSergey Zigachev ret = si_program_cac_config_registers(adev, si_pi->lcac_config);
2885b843c749SSergey Zigachev if (ret)
2886b843c749SSergey Zigachev return ret;
2887b843c749SSergey Zigachev ret = si_program_cac_config_registers(adev, si_pi->cac_override);
2888b843c749SSergey Zigachev if (ret)
2889b843c749SSergey Zigachev return ret;
2890b843c749SSergey Zigachev ret = si_program_cac_config_registers(adev, si_pi->cac_weights);
2891b843c749SSergey Zigachev if (ret)
2892b843c749SSergey Zigachev return ret;
2893b843c749SSergey Zigachev
2894b843c749SSergey Zigachev return 0;
2895b843c749SSergey Zigachev }
2896b843c749SSergey Zigachev
si_enable_smc_cac(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state,bool enable)2897b843c749SSergey Zigachev static int si_enable_smc_cac(struct amdgpu_device *adev,
2898b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state,
2899b843c749SSergey Zigachev bool enable)
2900b843c749SSergey Zigachev {
2901b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2902b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2903b843c749SSergey Zigachev PPSMC_Result smc_result;
2904b843c749SSergey Zigachev int ret = 0;
2905b843c749SSergey Zigachev
2906b843c749SSergey Zigachev if (ni_pi->enable_cac) {
2907b843c749SSergey Zigachev if (enable) {
2908b843c749SSergey Zigachev if (!si_should_disable_uvd_powertune(adev, amdgpu_new_state)) {
2909b843c749SSergey Zigachev if (ni_pi->support_cac_long_term_average) {
2910b843c749SSergey Zigachev smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_CACLongTermAvgEnable);
2911b843c749SSergey Zigachev if (smc_result != PPSMC_Result_OK)
2912b843c749SSergey Zigachev ni_pi->support_cac_long_term_average = false;
2913b843c749SSergey Zigachev }
2914b843c749SSergey Zigachev
2915b843c749SSergey Zigachev smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableCac);
2916b843c749SSergey Zigachev if (smc_result != PPSMC_Result_OK) {
2917b843c749SSergey Zigachev ret = -EINVAL;
2918b843c749SSergey Zigachev ni_pi->cac_enabled = false;
2919b843c749SSergey Zigachev } else {
2920b843c749SSergey Zigachev ni_pi->cac_enabled = true;
2921b843c749SSergey Zigachev }
2922b843c749SSergey Zigachev
2923b843c749SSergey Zigachev if (si_pi->enable_dte) {
2924b843c749SSergey Zigachev smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableDTE);
2925b843c749SSergey Zigachev if (smc_result != PPSMC_Result_OK)
2926b843c749SSergey Zigachev ret = -EINVAL;
2927b843c749SSergey Zigachev }
2928b843c749SSergey Zigachev }
2929b843c749SSergey Zigachev } else if (ni_pi->cac_enabled) {
2930b843c749SSergey Zigachev if (si_pi->enable_dte)
2931b843c749SSergey Zigachev smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableDTE);
2932b843c749SSergey Zigachev
2933b843c749SSergey Zigachev smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableCac);
2934b843c749SSergey Zigachev
2935b843c749SSergey Zigachev ni_pi->cac_enabled = false;
2936b843c749SSergey Zigachev
2937b843c749SSergey Zigachev if (ni_pi->support_cac_long_term_average)
2938b843c749SSergey Zigachev smc_result = amdgpu_si_send_msg_to_smc(adev, PPSMC_CACLongTermAvgDisable);
2939b843c749SSergey Zigachev }
2940b843c749SSergey Zigachev }
2941b843c749SSergey Zigachev return ret;
2942b843c749SSergey Zigachev }
2943b843c749SSergey Zigachev
si_init_smc_spll_table(struct amdgpu_device * adev)2944b843c749SSergey Zigachev static int si_init_smc_spll_table(struct amdgpu_device *adev)
2945b843c749SSergey Zigachev {
2946b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
2947b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
2948b843c749SSergey Zigachev SMC_SISLANDS_SPLL_DIV_TABLE *spll_table;
2949b843c749SSergey Zigachev SISLANDS_SMC_SCLK_VALUE sclk_params;
2950b843c749SSergey Zigachev u32 fb_div, p_div;
2951b843c749SSergey Zigachev u32 clk_s, clk_v;
2952b843c749SSergey Zigachev u32 sclk = 0;
2953b843c749SSergey Zigachev int ret = 0;
2954b843c749SSergey Zigachev u32 tmp;
2955b843c749SSergey Zigachev int i;
2956b843c749SSergey Zigachev
2957b843c749SSergey Zigachev if (si_pi->spll_table_start == 0)
2958b843c749SSergey Zigachev return -EINVAL;
2959b843c749SSergey Zigachev
2960b843c749SSergey Zigachev spll_table = kzalloc(sizeof(SMC_SISLANDS_SPLL_DIV_TABLE), GFP_KERNEL);
2961b843c749SSergey Zigachev if (spll_table == NULL)
2962b843c749SSergey Zigachev return -ENOMEM;
2963b843c749SSergey Zigachev
2964b843c749SSergey Zigachev for (i = 0; i < 256; i++) {
2965b843c749SSergey Zigachev ret = si_calculate_sclk_params(adev, sclk, &sclk_params);
2966b843c749SSergey Zigachev if (ret)
2967b843c749SSergey Zigachev break;
2968b843c749SSergey Zigachev p_div = (sclk_params.vCG_SPLL_FUNC_CNTL & SPLL_PDIV_A_MASK) >> SPLL_PDIV_A_SHIFT;
2969b843c749SSergey Zigachev fb_div = (sclk_params.vCG_SPLL_FUNC_CNTL_3 & SPLL_FB_DIV_MASK) >> SPLL_FB_DIV_SHIFT;
2970b843c749SSergey Zigachev clk_s = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM & CLK_S_MASK) >> CLK_S_SHIFT;
2971b843c749SSergey Zigachev clk_v = (sclk_params.vCG_SPLL_SPREAD_SPECTRUM_2 & CLK_V_MASK) >> CLK_V_SHIFT;
2972b843c749SSergey Zigachev
2973b843c749SSergey Zigachev fb_div &= ~0x00001FFF;
2974b843c749SSergey Zigachev fb_div >>= 1;
2975b843c749SSergey Zigachev clk_v >>= 6;
2976b843c749SSergey Zigachev
2977b843c749SSergey Zigachev if (p_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT))
2978b843c749SSergey Zigachev ret = -EINVAL;
2979b843c749SSergey Zigachev if (fb_div & ~(SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT))
2980b843c749SSergey Zigachev ret = -EINVAL;
2981b843c749SSergey Zigachev if (clk_s & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT))
2982b843c749SSergey Zigachev ret = -EINVAL;
2983b843c749SSergey Zigachev if (clk_v & ~(SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK >> SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT))
2984b843c749SSergey Zigachev ret = -EINVAL;
2985b843c749SSergey Zigachev
2986b843c749SSergey Zigachev if (ret)
2987b843c749SSergey Zigachev break;
2988b843c749SSergey Zigachev
2989b843c749SSergey Zigachev tmp = ((fb_div << SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK) |
2990b843c749SSergey Zigachev ((p_div << SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK);
2991b843c749SSergey Zigachev spll_table->freq[i] = cpu_to_be32(tmp);
2992b843c749SSergey Zigachev
2993b843c749SSergey Zigachev tmp = ((clk_v << SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK) |
2994b843c749SSergey Zigachev ((clk_s << SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT) & SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK);
2995b843c749SSergey Zigachev spll_table->ss[i] = cpu_to_be32(tmp);
2996b843c749SSergey Zigachev
2997b843c749SSergey Zigachev sclk += 512;
2998b843c749SSergey Zigachev }
2999b843c749SSergey Zigachev
3000b843c749SSergey Zigachev
3001b843c749SSergey Zigachev if (!ret)
3002b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev, si_pi->spll_table_start,
3003b843c749SSergey Zigachev (u8 *)spll_table,
3004b843c749SSergey Zigachev sizeof(SMC_SISLANDS_SPLL_DIV_TABLE),
3005b843c749SSergey Zigachev si_pi->sram_end);
3006b843c749SSergey Zigachev
3007b843c749SSergey Zigachev if (ret)
3008b843c749SSergey Zigachev ni_pi->enable_power_containment = false;
3009b843c749SSergey Zigachev
3010b843c749SSergey Zigachev kfree(spll_table);
3011b843c749SSergey Zigachev
3012b843c749SSergey Zigachev return ret;
3013b843c749SSergey Zigachev }
3014b843c749SSergey Zigachev
si_get_lower_of_leakage_and_vce_voltage(struct amdgpu_device * adev,u16 vce_voltage)3015b843c749SSergey Zigachev static u16 si_get_lower_of_leakage_and_vce_voltage(struct amdgpu_device *adev,
3016b843c749SSergey Zigachev u16 vce_voltage)
3017b843c749SSergey Zigachev {
3018b843c749SSergey Zigachev u16 highest_leakage = 0;
3019b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
3020b843c749SSergey Zigachev int i;
3021b843c749SSergey Zigachev
3022b843c749SSergey Zigachev for (i = 0; i < si_pi->leakage_voltage.count; i++){
3023b843c749SSergey Zigachev if (highest_leakage < si_pi->leakage_voltage.entries[i].voltage)
3024b843c749SSergey Zigachev highest_leakage = si_pi->leakage_voltage.entries[i].voltage;
3025b843c749SSergey Zigachev }
3026b843c749SSergey Zigachev
3027b843c749SSergey Zigachev if (si_pi->leakage_voltage.count && (highest_leakage < vce_voltage))
3028b843c749SSergey Zigachev return highest_leakage;
3029b843c749SSergey Zigachev
3030b843c749SSergey Zigachev return vce_voltage;
3031b843c749SSergey Zigachev }
3032b843c749SSergey Zigachev
si_get_vce_clock_voltage(struct amdgpu_device * adev,u32 evclk,u32 ecclk,u16 * voltage)3033b843c749SSergey Zigachev static int si_get_vce_clock_voltage(struct amdgpu_device *adev,
3034b843c749SSergey Zigachev u32 evclk, u32 ecclk, u16 *voltage)
3035b843c749SSergey Zigachev {
3036b843c749SSergey Zigachev u32 i;
3037b843c749SSergey Zigachev int ret = -EINVAL;
3038b843c749SSergey Zigachev struct amdgpu_vce_clock_voltage_dependency_table *table =
3039b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.vce_clock_voltage_dependency_table;
3040b843c749SSergey Zigachev
3041b843c749SSergey Zigachev if (((evclk == 0) && (ecclk == 0)) ||
3042b843c749SSergey Zigachev (table && (table->count == 0))) {
3043b843c749SSergey Zigachev *voltage = 0;
3044b843c749SSergey Zigachev return 0;
3045b843c749SSergey Zigachev }
3046b843c749SSergey Zigachev
3047b843c749SSergey Zigachev for (i = 0; i < table->count; i++) {
3048b843c749SSergey Zigachev if ((evclk <= table->entries[i].evclk) &&
3049b843c749SSergey Zigachev (ecclk <= table->entries[i].ecclk)) {
3050b843c749SSergey Zigachev *voltage = table->entries[i].v;
3051b843c749SSergey Zigachev ret = 0;
3052b843c749SSergey Zigachev break;
3053b843c749SSergey Zigachev }
3054b843c749SSergey Zigachev }
3055b843c749SSergey Zigachev
3056b843c749SSergey Zigachev /* if no match return the highest voltage */
3057b843c749SSergey Zigachev if (ret)
3058b843c749SSergey Zigachev *voltage = table->entries[table->count - 1].v;
3059b843c749SSergey Zigachev
3060b843c749SSergey Zigachev *voltage = si_get_lower_of_leakage_and_vce_voltage(adev, *voltage);
3061b843c749SSergey Zigachev
3062b843c749SSergey Zigachev return ret;
3063b843c749SSergey Zigachev }
3064b843c749SSergey Zigachev
si_dpm_vblank_too_short(void * handle)3065b843c749SSergey Zigachev static bool si_dpm_vblank_too_short(void *handle)
3066b843c749SSergey Zigachev {
3067b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
3068b843c749SSergey Zigachev u32 vblank_time = amdgpu_dpm_get_vblank_time(adev);
3069b843c749SSergey Zigachev /* we never hit the non-gddr5 limit so disable it */
3070b843c749SSergey Zigachev u32 switch_limit = adev->gmc.vram_type == AMDGPU_VRAM_TYPE_GDDR5 ? 450 : 0;
3071b843c749SSergey Zigachev
3072b843c749SSergey Zigachev if (vblank_time < switch_limit)
3073b843c749SSergey Zigachev return true;
3074b843c749SSergey Zigachev else
3075b843c749SSergey Zigachev return false;
3076b843c749SSergey Zigachev
3077b843c749SSergey Zigachev }
3078b843c749SSergey Zigachev
ni_copy_and_switch_arb_sets(struct amdgpu_device * adev,u32 arb_freq_src,u32 arb_freq_dest)3079b843c749SSergey Zigachev static int ni_copy_and_switch_arb_sets(struct amdgpu_device *adev,
3080b843c749SSergey Zigachev u32 arb_freq_src, u32 arb_freq_dest)
3081b843c749SSergey Zigachev {
3082b843c749SSergey Zigachev u32 mc_arb_dram_timing;
3083b843c749SSergey Zigachev u32 mc_arb_dram_timing2;
3084b843c749SSergey Zigachev u32 burst_time;
3085b843c749SSergey Zigachev u32 mc_cg_config;
3086b843c749SSergey Zigachev
3087b843c749SSergey Zigachev switch (arb_freq_src) {
3088b843c749SSergey Zigachev case MC_CG_ARB_FREQ_F0:
3089b843c749SSergey Zigachev mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING);
3090b843c749SSergey Zigachev mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
3091b843c749SSergey Zigachev burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE0_MASK) >> STATE0_SHIFT;
3092b843c749SSergey Zigachev break;
3093b843c749SSergey Zigachev case MC_CG_ARB_FREQ_F1:
3094b843c749SSergey Zigachev mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_1);
3095b843c749SSergey Zigachev mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_1);
3096b843c749SSergey Zigachev burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE1_MASK) >> STATE1_SHIFT;
3097b843c749SSergey Zigachev break;
3098b843c749SSergey Zigachev case MC_CG_ARB_FREQ_F2:
3099b843c749SSergey Zigachev mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_2);
3100b843c749SSergey Zigachev mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_2);
3101b843c749SSergey Zigachev burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE2_MASK) >> STATE2_SHIFT;
3102b843c749SSergey Zigachev break;
3103b843c749SSergey Zigachev case MC_CG_ARB_FREQ_F3:
3104b843c749SSergey Zigachev mc_arb_dram_timing = RREG32(MC_ARB_DRAM_TIMING_3);
3105b843c749SSergey Zigachev mc_arb_dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2_3);
3106b843c749SSergey Zigachev burst_time = (RREG32(MC_ARB_BURST_TIME) & STATE3_MASK) >> STATE3_SHIFT;
3107b843c749SSergey Zigachev break;
3108b843c749SSergey Zigachev default:
3109b843c749SSergey Zigachev return -EINVAL;
3110b843c749SSergey Zigachev }
3111b843c749SSergey Zigachev
3112b843c749SSergey Zigachev switch (arb_freq_dest) {
3113b843c749SSergey Zigachev case MC_CG_ARB_FREQ_F0:
3114b843c749SSergey Zigachev WREG32(MC_ARB_DRAM_TIMING, mc_arb_dram_timing);
3115b843c749SSergey Zigachev WREG32(MC_ARB_DRAM_TIMING2, mc_arb_dram_timing2);
3116b843c749SSergey Zigachev WREG32_P(MC_ARB_BURST_TIME, STATE0(burst_time), ~STATE0_MASK);
3117b843c749SSergey Zigachev break;
3118b843c749SSergey Zigachev case MC_CG_ARB_FREQ_F1:
3119b843c749SSergey Zigachev WREG32(MC_ARB_DRAM_TIMING_1, mc_arb_dram_timing);
3120b843c749SSergey Zigachev WREG32(MC_ARB_DRAM_TIMING2_1, mc_arb_dram_timing2);
3121b843c749SSergey Zigachev WREG32_P(MC_ARB_BURST_TIME, STATE1(burst_time), ~STATE1_MASK);
3122b843c749SSergey Zigachev break;
3123b843c749SSergey Zigachev case MC_CG_ARB_FREQ_F2:
3124b843c749SSergey Zigachev WREG32(MC_ARB_DRAM_TIMING_2, mc_arb_dram_timing);
3125b843c749SSergey Zigachev WREG32(MC_ARB_DRAM_TIMING2_2, mc_arb_dram_timing2);
3126b843c749SSergey Zigachev WREG32_P(MC_ARB_BURST_TIME, STATE2(burst_time), ~STATE2_MASK);
3127b843c749SSergey Zigachev break;
3128b843c749SSergey Zigachev case MC_CG_ARB_FREQ_F3:
3129b843c749SSergey Zigachev WREG32(MC_ARB_DRAM_TIMING_3, mc_arb_dram_timing);
3130b843c749SSergey Zigachev WREG32(MC_ARB_DRAM_TIMING2_3, mc_arb_dram_timing2);
3131b843c749SSergey Zigachev WREG32_P(MC_ARB_BURST_TIME, STATE3(burst_time), ~STATE3_MASK);
3132b843c749SSergey Zigachev break;
3133b843c749SSergey Zigachev default:
3134b843c749SSergey Zigachev return -EINVAL;
3135b843c749SSergey Zigachev }
3136b843c749SSergey Zigachev
3137b843c749SSergey Zigachev mc_cg_config = RREG32(MC_CG_CONFIG) | 0x0000000F;
3138b843c749SSergey Zigachev WREG32(MC_CG_CONFIG, mc_cg_config);
3139b843c749SSergey Zigachev WREG32_P(MC_ARB_CG, CG_ARB_REQ(arb_freq_dest), ~CG_ARB_REQ_MASK);
3140b843c749SSergey Zigachev
3141b843c749SSergey Zigachev return 0;
3142b843c749SSergey Zigachev }
3143b843c749SSergey Zigachev
ni_update_current_ps(struct amdgpu_device * adev,struct amdgpu_ps * rps)3144b843c749SSergey Zigachev static void ni_update_current_ps(struct amdgpu_device *adev,
3145b843c749SSergey Zigachev struct amdgpu_ps *rps)
3146b843c749SSergey Zigachev {
3147b843c749SSergey Zigachev struct si_ps *new_ps = si_get_ps(rps);
3148b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
3149b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
3150b843c749SSergey Zigachev
3151b843c749SSergey Zigachev eg_pi->current_rps = *rps;
3152b843c749SSergey Zigachev ni_pi->current_ps = *new_ps;
3153b843c749SSergey Zigachev eg_pi->current_rps.ps_priv = &ni_pi->current_ps;
3154b843c749SSergey Zigachev adev->pm.dpm.current_ps = &eg_pi->current_rps;
3155b843c749SSergey Zigachev }
3156b843c749SSergey Zigachev
ni_update_requested_ps(struct amdgpu_device * adev,struct amdgpu_ps * rps)3157b843c749SSergey Zigachev static void ni_update_requested_ps(struct amdgpu_device *adev,
3158b843c749SSergey Zigachev struct amdgpu_ps *rps)
3159b843c749SSergey Zigachev {
3160b843c749SSergey Zigachev struct si_ps *new_ps = si_get_ps(rps);
3161b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
3162b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
3163b843c749SSergey Zigachev
3164b843c749SSergey Zigachev eg_pi->requested_rps = *rps;
3165b843c749SSergey Zigachev ni_pi->requested_ps = *new_ps;
3166b843c749SSergey Zigachev eg_pi->requested_rps.ps_priv = &ni_pi->requested_ps;
3167b843c749SSergey Zigachev adev->pm.dpm.requested_ps = &eg_pi->requested_rps;
3168b843c749SSergey Zigachev }
3169b843c749SSergey Zigachev
ni_set_uvd_clock_before_set_eng_clock(struct amdgpu_device * adev,struct amdgpu_ps * new_ps,struct amdgpu_ps * old_ps)3170b843c749SSergey Zigachev static void ni_set_uvd_clock_before_set_eng_clock(struct amdgpu_device *adev,
3171b843c749SSergey Zigachev struct amdgpu_ps *new_ps,
3172b843c749SSergey Zigachev struct amdgpu_ps *old_ps)
3173b843c749SSergey Zigachev {
3174b843c749SSergey Zigachev struct si_ps *new_state = si_get_ps(new_ps);
3175b843c749SSergey Zigachev struct si_ps *current_state = si_get_ps(old_ps);
3176b843c749SSergey Zigachev
3177b843c749SSergey Zigachev if ((new_ps->vclk == old_ps->vclk) &&
3178b843c749SSergey Zigachev (new_ps->dclk == old_ps->dclk))
3179b843c749SSergey Zigachev return;
3180b843c749SSergey Zigachev
3181b843c749SSergey Zigachev if (new_state->performance_levels[new_state->performance_level_count - 1].sclk >=
3182b843c749SSergey Zigachev current_state->performance_levels[current_state->performance_level_count - 1].sclk)
3183b843c749SSergey Zigachev return;
3184b843c749SSergey Zigachev
3185b843c749SSergey Zigachev amdgpu_asic_set_uvd_clocks(adev, new_ps->vclk, new_ps->dclk);
3186b843c749SSergey Zigachev }
3187b843c749SSergey Zigachev
ni_set_uvd_clock_after_set_eng_clock(struct amdgpu_device * adev,struct amdgpu_ps * new_ps,struct amdgpu_ps * old_ps)3188b843c749SSergey Zigachev static void ni_set_uvd_clock_after_set_eng_clock(struct amdgpu_device *adev,
3189b843c749SSergey Zigachev struct amdgpu_ps *new_ps,
3190b843c749SSergey Zigachev struct amdgpu_ps *old_ps)
3191b843c749SSergey Zigachev {
3192b843c749SSergey Zigachev struct si_ps *new_state = si_get_ps(new_ps);
3193b843c749SSergey Zigachev struct si_ps *current_state = si_get_ps(old_ps);
3194b843c749SSergey Zigachev
3195b843c749SSergey Zigachev if ((new_ps->vclk == old_ps->vclk) &&
3196b843c749SSergey Zigachev (new_ps->dclk == old_ps->dclk))
3197b843c749SSergey Zigachev return;
3198b843c749SSergey Zigachev
3199b843c749SSergey Zigachev if (new_state->performance_levels[new_state->performance_level_count - 1].sclk <
3200b843c749SSergey Zigachev current_state->performance_levels[current_state->performance_level_count - 1].sclk)
3201b843c749SSergey Zigachev return;
3202b843c749SSergey Zigachev
3203b843c749SSergey Zigachev amdgpu_asic_set_uvd_clocks(adev, new_ps->vclk, new_ps->dclk);
3204b843c749SSergey Zigachev }
3205b843c749SSergey Zigachev
btc_find_voltage(struct atom_voltage_table * table,u16 voltage)3206b843c749SSergey Zigachev static u16 btc_find_voltage(struct atom_voltage_table *table, u16 voltage)
3207b843c749SSergey Zigachev {
3208b843c749SSergey Zigachev unsigned int i;
3209b843c749SSergey Zigachev
3210b843c749SSergey Zigachev for (i = 0; i < table->count; i++)
3211b843c749SSergey Zigachev if (voltage <= table->entries[i].value)
3212b843c749SSergey Zigachev return table->entries[i].value;
3213b843c749SSergey Zigachev
3214b843c749SSergey Zigachev return table->entries[table->count - 1].value;
3215b843c749SSergey Zigachev }
3216b843c749SSergey Zigachev
btc_find_valid_clock(struct amdgpu_clock_array * clocks,u32 max_clock,u32 requested_clock)3217b843c749SSergey Zigachev static u32 btc_find_valid_clock(struct amdgpu_clock_array *clocks,
3218b843c749SSergey Zigachev u32 max_clock, u32 requested_clock)
3219b843c749SSergey Zigachev {
3220b843c749SSergey Zigachev unsigned int i;
3221b843c749SSergey Zigachev
3222b843c749SSergey Zigachev if ((clocks == NULL) || (clocks->count == 0))
3223b843c749SSergey Zigachev return (requested_clock < max_clock) ? requested_clock : max_clock;
3224b843c749SSergey Zigachev
3225b843c749SSergey Zigachev for (i = 0; i < clocks->count; i++) {
3226b843c749SSergey Zigachev if (clocks->values[i] >= requested_clock)
3227b843c749SSergey Zigachev return (clocks->values[i] < max_clock) ? clocks->values[i] : max_clock;
3228b843c749SSergey Zigachev }
3229b843c749SSergey Zigachev
3230b843c749SSergey Zigachev return (clocks->values[clocks->count - 1] < max_clock) ?
3231b843c749SSergey Zigachev clocks->values[clocks->count - 1] : max_clock;
3232b843c749SSergey Zigachev }
3233b843c749SSergey Zigachev
btc_get_valid_mclk(struct amdgpu_device * adev,u32 max_mclk,u32 requested_mclk)3234b843c749SSergey Zigachev static u32 btc_get_valid_mclk(struct amdgpu_device *adev,
3235b843c749SSergey Zigachev u32 max_mclk, u32 requested_mclk)
3236b843c749SSergey Zigachev {
3237b843c749SSergey Zigachev return btc_find_valid_clock(&adev->pm.dpm.dyn_state.valid_mclk_values,
3238b843c749SSergey Zigachev max_mclk, requested_mclk);
3239b843c749SSergey Zigachev }
3240b843c749SSergey Zigachev
btc_get_valid_sclk(struct amdgpu_device * adev,u32 max_sclk,u32 requested_sclk)3241b843c749SSergey Zigachev static u32 btc_get_valid_sclk(struct amdgpu_device *adev,
3242b843c749SSergey Zigachev u32 max_sclk, u32 requested_sclk)
3243b843c749SSergey Zigachev {
3244b843c749SSergey Zigachev return btc_find_valid_clock(&adev->pm.dpm.dyn_state.valid_sclk_values,
3245b843c749SSergey Zigachev max_sclk, requested_sclk);
3246b843c749SSergey Zigachev }
3247b843c749SSergey Zigachev
btc_get_max_clock_from_voltage_dependency_table(struct amdgpu_clock_voltage_dependency_table * table,u32 * max_clock)3248b843c749SSergey Zigachev static void btc_get_max_clock_from_voltage_dependency_table(struct amdgpu_clock_voltage_dependency_table *table,
3249b843c749SSergey Zigachev u32 *max_clock)
3250b843c749SSergey Zigachev {
3251b843c749SSergey Zigachev u32 i, clock = 0;
3252b843c749SSergey Zigachev
3253b843c749SSergey Zigachev if ((table == NULL) || (table->count == 0)) {
3254b843c749SSergey Zigachev *max_clock = clock;
3255b843c749SSergey Zigachev return;
3256b843c749SSergey Zigachev }
3257b843c749SSergey Zigachev
3258b843c749SSergey Zigachev for (i = 0; i < table->count; i++) {
3259b843c749SSergey Zigachev if (clock < table->entries[i].clk)
3260b843c749SSergey Zigachev clock = table->entries[i].clk;
3261b843c749SSergey Zigachev }
3262b843c749SSergey Zigachev *max_clock = clock;
3263b843c749SSergey Zigachev }
3264b843c749SSergey Zigachev
btc_apply_voltage_dependency_rules(struct amdgpu_clock_voltage_dependency_table * table,u32 clock,u16 max_voltage,u16 * voltage)3265b843c749SSergey Zigachev static void btc_apply_voltage_dependency_rules(struct amdgpu_clock_voltage_dependency_table *table,
3266b843c749SSergey Zigachev u32 clock, u16 max_voltage, u16 *voltage)
3267b843c749SSergey Zigachev {
3268b843c749SSergey Zigachev u32 i;
3269b843c749SSergey Zigachev
3270b843c749SSergey Zigachev if ((table == NULL) || (table->count == 0))
3271b843c749SSergey Zigachev return;
3272b843c749SSergey Zigachev
3273b843c749SSergey Zigachev for (i= 0; i < table->count; i++) {
3274b843c749SSergey Zigachev if (clock <= table->entries[i].clk) {
3275b843c749SSergey Zigachev if (*voltage < table->entries[i].v)
3276b843c749SSergey Zigachev *voltage = (u16)((table->entries[i].v < max_voltage) ?
3277b843c749SSergey Zigachev table->entries[i].v : max_voltage);
3278b843c749SSergey Zigachev return;
3279b843c749SSergey Zigachev }
3280b843c749SSergey Zigachev }
3281b843c749SSergey Zigachev
3282b843c749SSergey Zigachev *voltage = (*voltage > max_voltage) ? *voltage : max_voltage;
3283b843c749SSergey Zigachev }
3284b843c749SSergey Zigachev
btc_adjust_clock_combinations(struct amdgpu_device * adev,const struct amdgpu_clock_and_voltage_limits * max_limits,struct rv7xx_pl * pl)3285b843c749SSergey Zigachev static void btc_adjust_clock_combinations(struct amdgpu_device *adev,
3286b843c749SSergey Zigachev const struct amdgpu_clock_and_voltage_limits *max_limits,
3287b843c749SSergey Zigachev struct rv7xx_pl *pl)
3288b843c749SSergey Zigachev {
3289b843c749SSergey Zigachev
3290b843c749SSergey Zigachev if ((pl->mclk == 0) || (pl->sclk == 0))
3291b843c749SSergey Zigachev return;
3292b843c749SSergey Zigachev
3293b843c749SSergey Zigachev if (pl->mclk == pl->sclk)
3294b843c749SSergey Zigachev return;
3295b843c749SSergey Zigachev
3296b843c749SSergey Zigachev if (pl->mclk > pl->sclk) {
3297b843c749SSergey Zigachev if (((pl->mclk + (pl->sclk - 1)) / pl->sclk) > adev->pm.dpm.dyn_state.mclk_sclk_ratio)
3298b843c749SSergey Zigachev pl->sclk = btc_get_valid_sclk(adev,
3299b843c749SSergey Zigachev max_limits->sclk,
3300b843c749SSergey Zigachev (pl->mclk +
3301b843c749SSergey Zigachev (adev->pm.dpm.dyn_state.mclk_sclk_ratio - 1)) /
3302b843c749SSergey Zigachev adev->pm.dpm.dyn_state.mclk_sclk_ratio);
3303b843c749SSergey Zigachev } else {
3304b843c749SSergey Zigachev if ((pl->sclk - pl->mclk) > adev->pm.dpm.dyn_state.sclk_mclk_delta)
3305b843c749SSergey Zigachev pl->mclk = btc_get_valid_mclk(adev,
3306b843c749SSergey Zigachev max_limits->mclk,
3307b843c749SSergey Zigachev pl->sclk -
3308b843c749SSergey Zigachev adev->pm.dpm.dyn_state.sclk_mclk_delta);
3309b843c749SSergey Zigachev }
3310b843c749SSergey Zigachev }
3311b843c749SSergey Zigachev
btc_apply_voltage_delta_rules(struct amdgpu_device * adev,u16 max_vddc,u16 max_vddci,u16 * vddc,u16 * vddci)3312b843c749SSergey Zigachev static void btc_apply_voltage_delta_rules(struct amdgpu_device *adev,
3313b843c749SSergey Zigachev u16 max_vddc, u16 max_vddci,
3314b843c749SSergey Zigachev u16 *vddc, u16 *vddci)
3315b843c749SSergey Zigachev {
3316b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
3317b843c749SSergey Zigachev u16 new_voltage;
3318b843c749SSergey Zigachev
3319b843c749SSergey Zigachev if ((0 == *vddc) || (0 == *vddci))
3320b843c749SSergey Zigachev return;
3321b843c749SSergey Zigachev
3322b843c749SSergey Zigachev if (*vddc > *vddci) {
3323b843c749SSergey Zigachev if ((*vddc - *vddci) > adev->pm.dpm.dyn_state.vddc_vddci_delta) {
3324b843c749SSergey Zigachev new_voltage = btc_find_voltage(&eg_pi->vddci_voltage_table,
3325b843c749SSergey Zigachev (*vddc - adev->pm.dpm.dyn_state.vddc_vddci_delta));
3326b843c749SSergey Zigachev *vddci = (new_voltage < max_vddci) ? new_voltage : max_vddci;
3327b843c749SSergey Zigachev }
3328b843c749SSergey Zigachev } else {
3329b843c749SSergey Zigachev if ((*vddci - *vddc) > adev->pm.dpm.dyn_state.vddc_vddci_delta) {
3330b843c749SSergey Zigachev new_voltage = btc_find_voltage(&eg_pi->vddc_voltage_table,
3331b843c749SSergey Zigachev (*vddci - adev->pm.dpm.dyn_state.vddc_vddci_delta));
3332b843c749SSergey Zigachev *vddc = (new_voltage < max_vddc) ? new_voltage : max_vddc;
3333b843c749SSergey Zigachev }
3334b843c749SSergey Zigachev }
3335b843c749SSergey Zigachev }
3336b843c749SSergey Zigachev
r600_calculate_u_and_p(u32 i,u32 r_c,u32 p_b,u32 * p,u32 * u)3337b843c749SSergey Zigachev static void r600_calculate_u_and_p(u32 i, u32 r_c, u32 p_b,
3338b843c749SSergey Zigachev u32 *p, u32 *u)
3339b843c749SSergey Zigachev {
3340b843c749SSergey Zigachev u32 b_c = 0;
3341b843c749SSergey Zigachev u32 i_c;
3342b843c749SSergey Zigachev u32 tmp;
3343b843c749SSergey Zigachev
3344b843c749SSergey Zigachev i_c = (i * r_c) / 100;
3345b843c749SSergey Zigachev tmp = i_c >> p_b;
3346b843c749SSergey Zigachev
3347b843c749SSergey Zigachev while (tmp) {
3348b843c749SSergey Zigachev b_c++;
3349b843c749SSergey Zigachev tmp >>= 1;
3350b843c749SSergey Zigachev }
3351b843c749SSergey Zigachev
3352b843c749SSergey Zigachev *u = (b_c + 1) / 2;
3353b843c749SSergey Zigachev *p = i_c / (1 << (2 * (*u)));
3354b843c749SSergey Zigachev }
3355b843c749SSergey Zigachev
r600_calculate_at(u32 t,u32 h,u32 fh,u32 fl,u32 * tl,u32 * th)3356b843c749SSergey Zigachev static int r600_calculate_at(u32 t, u32 h, u32 fh, u32 fl, u32 *tl, u32 *th)
3357b843c749SSergey Zigachev {
3358b843c749SSergey Zigachev u32 k, a, ah, al;
3359b843c749SSergey Zigachev u32 t1;
3360b843c749SSergey Zigachev
3361b843c749SSergey Zigachev if ((fl == 0) || (fh == 0) || (fl > fh))
3362b843c749SSergey Zigachev return -EINVAL;
3363b843c749SSergey Zigachev
3364b843c749SSergey Zigachev k = (100 * fh) / fl;
3365b843c749SSergey Zigachev t1 = (t * (k - 100));
3366b843c749SSergey Zigachev a = (1000 * (100 * h + t1)) / (10000 + (t1 / 100));
3367b843c749SSergey Zigachev a = (a + 5) / 10;
3368b843c749SSergey Zigachev ah = ((a * t) + 5000) / 10000;
3369b843c749SSergey Zigachev al = a - ah;
3370b843c749SSergey Zigachev
3371b843c749SSergey Zigachev *th = t - ah;
3372b843c749SSergey Zigachev *tl = t + al;
3373b843c749SSergey Zigachev
3374b843c749SSergey Zigachev return 0;
3375b843c749SSergey Zigachev }
3376b843c749SSergey Zigachev
r600_is_uvd_state(u32 class,u32 class2)3377b843c749SSergey Zigachev static bool r600_is_uvd_state(u32 class, u32 class2)
3378b843c749SSergey Zigachev {
3379b843c749SSergey Zigachev if (class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE)
3380b843c749SSergey Zigachev return true;
3381b843c749SSergey Zigachev if (class & ATOM_PPLIB_CLASSIFICATION_HD2STATE)
3382b843c749SSergey Zigachev return true;
3383b843c749SSergey Zigachev if (class & ATOM_PPLIB_CLASSIFICATION_HDSTATE)
3384b843c749SSergey Zigachev return true;
3385b843c749SSergey Zigachev if (class & ATOM_PPLIB_CLASSIFICATION_SDSTATE)
3386b843c749SSergey Zigachev return true;
3387b843c749SSergey Zigachev if (class2 & ATOM_PPLIB_CLASSIFICATION2_MVC)
3388b843c749SSergey Zigachev return true;
3389b843c749SSergey Zigachev return false;
3390b843c749SSergey Zigachev }
3391b843c749SSergey Zigachev
rv770_get_memory_module_index(struct amdgpu_device * adev)3392b843c749SSergey Zigachev static u8 rv770_get_memory_module_index(struct amdgpu_device *adev)
3393b843c749SSergey Zigachev {
3394b843c749SSergey Zigachev return (u8) ((RREG32(BIOS_SCRATCH_4) >> 16) & 0xff);
3395b843c749SSergey Zigachev }
3396b843c749SSergey Zigachev
rv770_get_max_vddc(struct amdgpu_device * adev)3397b843c749SSergey Zigachev static void rv770_get_max_vddc(struct amdgpu_device *adev)
3398b843c749SSergey Zigachev {
3399b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
3400b843c749SSergey Zigachev u16 vddc;
3401b843c749SSergey Zigachev
3402b843c749SSergey Zigachev if (amdgpu_atombios_get_max_vddc(adev, 0, 0, &vddc))
3403b843c749SSergey Zigachev pi->max_vddc = 0;
3404b843c749SSergey Zigachev else
3405b843c749SSergey Zigachev pi->max_vddc = vddc;
3406b843c749SSergey Zigachev }
3407b843c749SSergey Zigachev
rv770_get_engine_memory_ss(struct amdgpu_device * adev)3408b843c749SSergey Zigachev static void rv770_get_engine_memory_ss(struct amdgpu_device *adev)
3409b843c749SSergey Zigachev {
3410b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
3411b843c749SSergey Zigachev struct amdgpu_atom_ss ss;
3412b843c749SSergey Zigachev
3413b843c749SSergey Zigachev pi->sclk_ss = amdgpu_atombios_get_asic_ss_info(adev, &ss,
3414b843c749SSergey Zigachev ASIC_INTERNAL_ENGINE_SS, 0);
3415b843c749SSergey Zigachev pi->mclk_ss = amdgpu_atombios_get_asic_ss_info(adev, &ss,
3416b843c749SSergey Zigachev ASIC_INTERNAL_MEMORY_SS, 0);
3417b843c749SSergey Zigachev
3418b843c749SSergey Zigachev if (pi->sclk_ss || pi->mclk_ss)
3419b843c749SSergey Zigachev pi->dynamic_ss = true;
3420b843c749SSergey Zigachev else
3421b843c749SSergey Zigachev pi->dynamic_ss = false;
3422b843c749SSergey Zigachev }
3423b843c749SSergey Zigachev
3424b843c749SSergey Zigachev
si_apply_state_adjust_rules(struct amdgpu_device * adev,struct amdgpu_ps * rps)3425b843c749SSergey Zigachev static void si_apply_state_adjust_rules(struct amdgpu_device *adev,
3426b843c749SSergey Zigachev struct amdgpu_ps *rps)
3427b843c749SSergey Zigachev {
3428b843c749SSergey Zigachev struct si_ps *ps = si_get_ps(rps);
3429b843c749SSergey Zigachev struct amdgpu_clock_and_voltage_limits *max_limits;
3430b843c749SSergey Zigachev bool disable_mclk_switching = false;
3431b843c749SSergey Zigachev bool disable_sclk_switching = false;
3432b843c749SSergey Zigachev u32 mclk, sclk;
3433b843c749SSergey Zigachev u16 vddc, vddci, min_vce_voltage = 0;
3434b843c749SSergey Zigachev u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;
3435b843c749SSergey Zigachev u32 max_sclk = 0, max_mclk = 0;
3436b843c749SSergey Zigachev int i;
3437b843c749SSergey Zigachev
3438b843c749SSergey Zigachev if (adev->asic_type == CHIP_HAINAN) {
3439b843c749SSergey Zigachev if ((adev->pdev->revision == 0x81) ||
3440b843c749SSergey Zigachev (adev->pdev->revision == 0x83) ||
3441b843c749SSergey Zigachev (adev->pdev->revision == 0xC3) ||
3442b843c749SSergey Zigachev (adev->pdev->device == 0x6664) ||
3443b843c749SSergey Zigachev (adev->pdev->device == 0x6665) ||
3444b843c749SSergey Zigachev (adev->pdev->device == 0x6667)) {
3445b843c749SSergey Zigachev max_sclk = 75000;
3446b843c749SSergey Zigachev }
3447b843c749SSergey Zigachev if ((adev->pdev->revision == 0xC3) ||
3448b843c749SSergey Zigachev (adev->pdev->device == 0x6665)) {
3449b843c749SSergey Zigachev max_sclk = 60000;
3450b843c749SSergey Zigachev max_mclk = 80000;
3451b843c749SSergey Zigachev }
3452b843c749SSergey Zigachev } else if (adev->asic_type == CHIP_OLAND) {
3453b843c749SSergey Zigachev if ((adev->pdev->revision == 0xC7) ||
3454b843c749SSergey Zigachev (adev->pdev->revision == 0x80) ||
3455b843c749SSergey Zigachev (adev->pdev->revision == 0x81) ||
3456b843c749SSergey Zigachev (adev->pdev->revision == 0x83) ||
3457b843c749SSergey Zigachev (adev->pdev->revision == 0x87) ||
3458b843c749SSergey Zigachev (adev->pdev->device == 0x6604) ||
3459b843c749SSergey Zigachev (adev->pdev->device == 0x6605)) {
3460b843c749SSergey Zigachev max_sclk = 75000;
3461b843c749SSergey Zigachev }
3462b843c749SSergey Zigachev }
3463b843c749SSergey Zigachev
3464b843c749SSergey Zigachev if (rps->vce_active) {
3465b843c749SSergey Zigachev rps->evclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].evclk;
3466b843c749SSergey Zigachev rps->ecclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].ecclk;
3467b843c749SSergey Zigachev si_get_vce_clock_voltage(adev, rps->evclk, rps->ecclk,
3468b843c749SSergey Zigachev &min_vce_voltage);
3469b843c749SSergey Zigachev } else {
3470b843c749SSergey Zigachev rps->evclk = 0;
3471b843c749SSergey Zigachev rps->ecclk = 0;
3472b843c749SSergey Zigachev }
3473b843c749SSergey Zigachev
3474b843c749SSergey Zigachev if ((adev->pm.dpm.new_active_crtc_count > 1) ||
3475b843c749SSergey Zigachev si_dpm_vblank_too_short(adev))
3476b843c749SSergey Zigachev disable_mclk_switching = true;
3477b843c749SSergey Zigachev
3478b843c749SSergey Zigachev if (rps->vclk || rps->dclk) {
3479b843c749SSergey Zigachev disable_mclk_switching = true;
3480b843c749SSergey Zigachev disable_sclk_switching = true;
3481b843c749SSergey Zigachev }
3482b843c749SSergey Zigachev
3483b843c749SSergey Zigachev if (adev->pm.ac_power)
3484b843c749SSergey Zigachev max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
3485b843c749SSergey Zigachev else
3486b843c749SSergey Zigachev max_limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc;
3487b843c749SSergey Zigachev
3488b843c749SSergey Zigachev for (i = ps->performance_level_count - 2; i >= 0; i--) {
3489b843c749SSergey Zigachev if (ps->performance_levels[i].vddc > ps->performance_levels[i+1].vddc)
3490b843c749SSergey Zigachev ps->performance_levels[i].vddc = ps->performance_levels[i+1].vddc;
3491b843c749SSergey Zigachev }
3492b843c749SSergey Zigachev if (adev->pm.ac_power == false) {
3493b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++) {
3494b843c749SSergey Zigachev if (ps->performance_levels[i].mclk > max_limits->mclk)
3495b843c749SSergey Zigachev ps->performance_levels[i].mclk = max_limits->mclk;
3496b843c749SSergey Zigachev if (ps->performance_levels[i].sclk > max_limits->sclk)
3497b843c749SSergey Zigachev ps->performance_levels[i].sclk = max_limits->sclk;
3498b843c749SSergey Zigachev if (ps->performance_levels[i].vddc > max_limits->vddc)
3499b843c749SSergey Zigachev ps->performance_levels[i].vddc = max_limits->vddc;
3500b843c749SSergey Zigachev if (ps->performance_levels[i].vddci > max_limits->vddci)
3501b843c749SSergey Zigachev ps->performance_levels[i].vddci = max_limits->vddci;
3502b843c749SSergey Zigachev }
3503b843c749SSergey Zigachev }
3504b843c749SSergey Zigachev
3505b843c749SSergey Zigachev /* limit clocks to max supported clocks based on voltage dependency tables */
3506b843c749SSergey Zigachev btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
3507b843c749SSergey Zigachev &max_sclk_vddc);
3508b843c749SSergey Zigachev btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
3509b843c749SSergey Zigachev &max_mclk_vddci);
3510b843c749SSergey Zigachev btc_get_max_clock_from_voltage_dependency_table(&adev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
3511b843c749SSergey Zigachev &max_mclk_vddc);
3512b843c749SSergey Zigachev
3513b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++) {
3514b843c749SSergey Zigachev if (max_sclk_vddc) {
3515b843c749SSergey Zigachev if (ps->performance_levels[i].sclk > max_sclk_vddc)
3516b843c749SSergey Zigachev ps->performance_levels[i].sclk = max_sclk_vddc;
3517b843c749SSergey Zigachev }
3518b843c749SSergey Zigachev if (max_mclk_vddci) {
3519b843c749SSergey Zigachev if (ps->performance_levels[i].mclk > max_mclk_vddci)
3520b843c749SSergey Zigachev ps->performance_levels[i].mclk = max_mclk_vddci;
3521b843c749SSergey Zigachev }
3522b843c749SSergey Zigachev if (max_mclk_vddc) {
3523b843c749SSergey Zigachev if (ps->performance_levels[i].mclk > max_mclk_vddc)
3524b843c749SSergey Zigachev ps->performance_levels[i].mclk = max_mclk_vddc;
3525b843c749SSergey Zigachev }
3526b843c749SSergey Zigachev if (max_mclk) {
3527b843c749SSergey Zigachev if (ps->performance_levels[i].mclk > max_mclk)
3528b843c749SSergey Zigachev ps->performance_levels[i].mclk = max_mclk;
3529b843c749SSergey Zigachev }
3530b843c749SSergey Zigachev if (max_sclk) {
3531b843c749SSergey Zigachev if (ps->performance_levels[i].sclk > max_sclk)
3532b843c749SSergey Zigachev ps->performance_levels[i].sclk = max_sclk;
3533b843c749SSergey Zigachev }
3534b843c749SSergey Zigachev }
3535b843c749SSergey Zigachev
3536b843c749SSergey Zigachev /* XXX validate the min clocks required for display */
3537b843c749SSergey Zigachev
3538b843c749SSergey Zigachev if (disable_mclk_switching) {
3539b843c749SSergey Zigachev mclk = ps->performance_levels[ps->performance_level_count - 1].mclk;
3540b843c749SSergey Zigachev vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
3541b843c749SSergey Zigachev } else {
3542b843c749SSergey Zigachev mclk = ps->performance_levels[0].mclk;
3543b843c749SSergey Zigachev vddci = ps->performance_levels[0].vddci;
3544b843c749SSergey Zigachev }
3545b843c749SSergey Zigachev
3546b843c749SSergey Zigachev if (disable_sclk_switching) {
3547b843c749SSergey Zigachev sclk = ps->performance_levels[ps->performance_level_count - 1].sclk;
3548b843c749SSergey Zigachev vddc = ps->performance_levels[ps->performance_level_count - 1].vddc;
3549b843c749SSergey Zigachev } else {
3550b843c749SSergey Zigachev sclk = ps->performance_levels[0].sclk;
3551b843c749SSergey Zigachev vddc = ps->performance_levels[0].vddc;
3552b843c749SSergey Zigachev }
3553b843c749SSergey Zigachev
3554b843c749SSergey Zigachev if (rps->vce_active) {
3555b843c749SSergey Zigachev if (sclk < adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].sclk)
3556b843c749SSergey Zigachev sclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].sclk;
3557b843c749SSergey Zigachev if (mclk < adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].mclk)
3558b843c749SSergey Zigachev mclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].mclk;
3559b843c749SSergey Zigachev }
3560b843c749SSergey Zigachev
3561b843c749SSergey Zigachev /* adjusted low state */
3562b843c749SSergey Zigachev ps->performance_levels[0].sclk = sclk;
3563b843c749SSergey Zigachev ps->performance_levels[0].mclk = mclk;
3564b843c749SSergey Zigachev ps->performance_levels[0].vddc = vddc;
3565b843c749SSergey Zigachev ps->performance_levels[0].vddci = vddci;
3566b843c749SSergey Zigachev
3567b843c749SSergey Zigachev if (disable_sclk_switching) {
3568b843c749SSergey Zigachev sclk = ps->performance_levels[0].sclk;
3569b843c749SSergey Zigachev for (i = 1; i < ps->performance_level_count; i++) {
3570b843c749SSergey Zigachev if (sclk < ps->performance_levels[i].sclk)
3571b843c749SSergey Zigachev sclk = ps->performance_levels[i].sclk;
3572b843c749SSergey Zigachev }
3573b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++) {
3574b843c749SSergey Zigachev ps->performance_levels[i].sclk = sclk;
3575b843c749SSergey Zigachev ps->performance_levels[i].vddc = vddc;
3576b843c749SSergey Zigachev }
3577b843c749SSergey Zigachev } else {
3578b843c749SSergey Zigachev for (i = 1; i < ps->performance_level_count; i++) {
3579b843c749SSergey Zigachev if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk)
3580b843c749SSergey Zigachev ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk;
3581b843c749SSergey Zigachev if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc)
3582b843c749SSergey Zigachev ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
3583b843c749SSergey Zigachev }
3584b843c749SSergey Zigachev }
3585b843c749SSergey Zigachev
3586b843c749SSergey Zigachev if (disable_mclk_switching) {
3587b843c749SSergey Zigachev mclk = ps->performance_levels[0].mclk;
3588b843c749SSergey Zigachev for (i = 1; i < ps->performance_level_count; i++) {
3589b843c749SSergey Zigachev if (mclk < ps->performance_levels[i].mclk)
3590b843c749SSergey Zigachev mclk = ps->performance_levels[i].mclk;
3591b843c749SSergey Zigachev }
3592b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++) {
3593b843c749SSergey Zigachev ps->performance_levels[i].mclk = mclk;
3594b843c749SSergey Zigachev ps->performance_levels[i].vddci = vddci;
3595b843c749SSergey Zigachev }
3596b843c749SSergey Zigachev } else {
3597b843c749SSergey Zigachev for (i = 1; i < ps->performance_level_count; i++) {
3598b843c749SSergey Zigachev if (ps->performance_levels[i].mclk < ps->performance_levels[i - 1].mclk)
3599b843c749SSergey Zigachev ps->performance_levels[i].mclk = ps->performance_levels[i - 1].mclk;
3600b843c749SSergey Zigachev if (ps->performance_levels[i].vddci < ps->performance_levels[i - 1].vddci)
3601b843c749SSergey Zigachev ps->performance_levels[i].vddci = ps->performance_levels[i - 1].vddci;
3602b843c749SSergey Zigachev }
3603b843c749SSergey Zigachev }
3604b843c749SSergey Zigachev
3605b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++)
3606b843c749SSergey Zigachev btc_adjust_clock_combinations(adev, max_limits,
3607b843c749SSergey Zigachev &ps->performance_levels[i]);
3608b843c749SSergey Zigachev
3609b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++) {
3610b843c749SSergey Zigachev if (ps->performance_levels[i].vddc < min_vce_voltage)
3611b843c749SSergey Zigachev ps->performance_levels[i].vddc = min_vce_voltage;
3612b843c749SSergey Zigachev btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_sclk,
3613b843c749SSergey Zigachev ps->performance_levels[i].sclk,
3614b843c749SSergey Zigachev max_limits->vddc, &ps->performance_levels[i].vddc);
3615b843c749SSergey Zigachev btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
3616b843c749SSergey Zigachev ps->performance_levels[i].mclk,
3617b843c749SSergey Zigachev max_limits->vddci, &ps->performance_levels[i].vddci);
3618b843c749SSergey Zigachev btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
3619b843c749SSergey Zigachev ps->performance_levels[i].mclk,
3620b843c749SSergey Zigachev max_limits->vddc, &ps->performance_levels[i].vddc);
3621b843c749SSergey Zigachev btc_apply_voltage_dependency_rules(&adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk,
3622b843c749SSergey Zigachev adev->clock.current_dispclk,
3623b843c749SSergey Zigachev max_limits->vddc, &ps->performance_levels[i].vddc);
3624b843c749SSergey Zigachev }
3625b843c749SSergey Zigachev
3626b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++) {
3627b843c749SSergey Zigachev btc_apply_voltage_delta_rules(adev,
3628b843c749SSergey Zigachev max_limits->vddc, max_limits->vddci,
3629b843c749SSergey Zigachev &ps->performance_levels[i].vddc,
3630b843c749SSergey Zigachev &ps->performance_levels[i].vddci);
3631b843c749SSergey Zigachev }
3632b843c749SSergey Zigachev
3633b843c749SSergey Zigachev ps->dc_compatible = true;
3634b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++) {
3635b843c749SSergey Zigachev if (ps->performance_levels[i].vddc > adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.vddc)
3636b843c749SSergey Zigachev ps->dc_compatible = false;
3637b843c749SSergey Zigachev }
3638b843c749SSergey Zigachev }
3639b843c749SSergey Zigachev
3640b843c749SSergey Zigachev #if 0
3641b843c749SSergey Zigachev static int si_read_smc_soft_register(struct amdgpu_device *adev,
3642b843c749SSergey Zigachev u16 reg_offset, u32 *value)
3643b843c749SSergey Zigachev {
3644b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
3645b843c749SSergey Zigachev
3646b843c749SSergey Zigachev return amdgpu_si_read_smc_sram_dword(adev,
3647b843c749SSergey Zigachev si_pi->soft_regs_start + reg_offset, value,
3648b843c749SSergey Zigachev si_pi->sram_end);
3649b843c749SSergey Zigachev }
3650b843c749SSergey Zigachev #endif
3651b843c749SSergey Zigachev
si_write_smc_soft_register(struct amdgpu_device * adev,u16 reg_offset,u32 value)3652b843c749SSergey Zigachev static int si_write_smc_soft_register(struct amdgpu_device *adev,
3653b843c749SSergey Zigachev u16 reg_offset, u32 value)
3654b843c749SSergey Zigachev {
3655b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
3656b843c749SSergey Zigachev
3657b843c749SSergey Zigachev return amdgpu_si_write_smc_sram_dword(adev,
3658b843c749SSergey Zigachev si_pi->soft_regs_start + reg_offset,
3659b843c749SSergey Zigachev value, si_pi->sram_end);
3660b843c749SSergey Zigachev }
3661b843c749SSergey Zigachev
si_is_special_1gb_platform(struct amdgpu_device * adev)3662b843c749SSergey Zigachev static bool si_is_special_1gb_platform(struct amdgpu_device *adev)
3663b843c749SSergey Zigachev {
3664b843c749SSergey Zigachev bool ret = false;
3665b843c749SSergey Zigachev u32 tmp, width, row, column, bank, density;
3666b843c749SSergey Zigachev bool is_memory_gddr5, is_special;
3667b843c749SSergey Zigachev
3668b843c749SSergey Zigachev tmp = RREG32(MC_SEQ_MISC0);
3669b843c749SSergey Zigachev is_memory_gddr5 = (MC_SEQ_MISC0_GDDR5_VALUE == ((tmp & MC_SEQ_MISC0_GDDR5_MASK) >> MC_SEQ_MISC0_GDDR5_SHIFT));
3670b843c749SSergey Zigachev is_special = (MC_SEQ_MISC0_REV_ID_VALUE == ((tmp & MC_SEQ_MISC0_REV_ID_MASK) >> MC_SEQ_MISC0_REV_ID_SHIFT))
3671b843c749SSergey Zigachev & (MC_SEQ_MISC0_VEN_ID_VALUE == ((tmp & MC_SEQ_MISC0_VEN_ID_MASK) >> MC_SEQ_MISC0_VEN_ID_SHIFT));
3672b843c749SSergey Zigachev
3673b843c749SSergey Zigachev WREG32(MC_SEQ_IO_DEBUG_INDEX, 0xb);
3674b843c749SSergey Zigachev width = ((RREG32(MC_SEQ_IO_DEBUG_DATA) >> 1) & 1) ? 16 : 32;
3675b843c749SSergey Zigachev
3676b843c749SSergey Zigachev tmp = RREG32(MC_ARB_RAMCFG);
3677b843c749SSergey Zigachev row = ((tmp & NOOFROWS_MASK) >> NOOFROWS_SHIFT) + 10;
3678b843c749SSergey Zigachev column = ((tmp & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT) + 8;
3679b843c749SSergey Zigachev bank = ((tmp & NOOFBANK_MASK) >> NOOFBANK_SHIFT) + 2;
3680b843c749SSergey Zigachev
3681b843c749SSergey Zigachev density = (1 << (row + column - 20 + bank)) * width;
3682b843c749SSergey Zigachev
3683b843c749SSergey Zigachev if ((adev->pdev->device == 0x6819) &&
3684b843c749SSergey Zigachev is_memory_gddr5 && is_special && (density == 0x400))
3685b843c749SSergey Zigachev ret = true;
3686b843c749SSergey Zigachev
3687b843c749SSergey Zigachev return ret;
3688b843c749SSergey Zigachev }
3689b843c749SSergey Zigachev
si_get_leakage_vddc(struct amdgpu_device * adev)3690b843c749SSergey Zigachev static void si_get_leakage_vddc(struct amdgpu_device *adev)
3691b843c749SSergey Zigachev {
3692b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
3693b843c749SSergey Zigachev u16 vddc, count = 0;
3694b843c749SSergey Zigachev int i, ret;
3695b843c749SSergey Zigachev
3696b843c749SSergey Zigachev for (i = 0; i < SISLANDS_MAX_LEAKAGE_COUNT; i++) {
3697b843c749SSergey Zigachev ret = amdgpu_atombios_get_leakage_vddc_based_on_leakage_idx(adev, &vddc, SISLANDS_LEAKAGE_INDEX0 + i);
3698b843c749SSergey Zigachev
3699b843c749SSergey Zigachev if (!ret && (vddc > 0) && (vddc != (SISLANDS_LEAKAGE_INDEX0 + i))) {
3700b843c749SSergey Zigachev si_pi->leakage_voltage.entries[count].voltage = vddc;
3701b843c749SSergey Zigachev si_pi->leakage_voltage.entries[count].leakage_index =
3702b843c749SSergey Zigachev SISLANDS_LEAKAGE_INDEX0 + i;
3703b843c749SSergey Zigachev count++;
3704b843c749SSergey Zigachev }
3705b843c749SSergey Zigachev }
3706b843c749SSergey Zigachev si_pi->leakage_voltage.count = count;
3707b843c749SSergey Zigachev }
3708b843c749SSergey Zigachev
si_get_leakage_voltage_from_leakage_index(struct amdgpu_device * adev,u32 index,u16 * leakage_voltage)3709b843c749SSergey Zigachev static int si_get_leakage_voltage_from_leakage_index(struct amdgpu_device *adev,
3710b843c749SSergey Zigachev u32 index, u16 *leakage_voltage)
3711b843c749SSergey Zigachev {
3712b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
3713b843c749SSergey Zigachev int i;
3714b843c749SSergey Zigachev
3715b843c749SSergey Zigachev if (leakage_voltage == NULL)
3716b843c749SSergey Zigachev return -EINVAL;
3717b843c749SSergey Zigachev
3718b843c749SSergey Zigachev if ((index & 0xff00) != 0xff00)
3719b843c749SSergey Zigachev return -EINVAL;
3720b843c749SSergey Zigachev
3721b843c749SSergey Zigachev if ((index & 0xff) > SISLANDS_MAX_LEAKAGE_COUNT + 1)
3722b843c749SSergey Zigachev return -EINVAL;
3723b843c749SSergey Zigachev
3724b843c749SSergey Zigachev if (index < SISLANDS_LEAKAGE_INDEX0)
3725b843c749SSergey Zigachev return -EINVAL;
3726b843c749SSergey Zigachev
3727b843c749SSergey Zigachev for (i = 0; i < si_pi->leakage_voltage.count; i++) {
3728b843c749SSergey Zigachev if (si_pi->leakage_voltage.entries[i].leakage_index == index) {
3729b843c749SSergey Zigachev *leakage_voltage = si_pi->leakage_voltage.entries[i].voltage;
3730b843c749SSergey Zigachev return 0;
3731b843c749SSergey Zigachev }
3732b843c749SSergey Zigachev }
3733b843c749SSergey Zigachev return -EAGAIN;
3734b843c749SSergey Zigachev }
3735b843c749SSergey Zigachev
si_set_dpm_event_sources(struct amdgpu_device * adev,u32 sources)3736b843c749SSergey Zigachev static void si_set_dpm_event_sources(struct amdgpu_device *adev, u32 sources)
3737b843c749SSergey Zigachev {
3738b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
3739b843c749SSergey Zigachev bool want_thermal_protection;
3740b843c749SSergey Zigachev enum amdgpu_dpm_event_src dpm_event_src;
3741b843c749SSergey Zigachev
3742b843c749SSergey Zigachev switch (sources) {
3743b843c749SSergey Zigachev case 0:
3744b843c749SSergey Zigachev default:
3745b843c749SSergey Zigachev want_thermal_protection = false;
3746b843c749SSergey Zigachev break;
3747b843c749SSergey Zigachev case (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL):
3748b843c749SSergey Zigachev want_thermal_protection = true;
3749b843c749SSergey Zigachev dpm_event_src = AMDGPU_DPM_EVENT_SRC_DIGITAL;
3750b843c749SSergey Zigachev break;
3751b843c749SSergey Zigachev case (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL):
3752b843c749SSergey Zigachev want_thermal_protection = true;
3753b843c749SSergey Zigachev dpm_event_src = AMDGPU_DPM_EVENT_SRC_EXTERNAL;
3754b843c749SSergey Zigachev break;
3755b843c749SSergey Zigachev case ((1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL) |
3756b843c749SSergey Zigachev (1 << AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL)):
3757b843c749SSergey Zigachev want_thermal_protection = true;
3758b843c749SSergey Zigachev dpm_event_src = AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL;
3759b843c749SSergey Zigachev break;
3760b843c749SSergey Zigachev }
3761b843c749SSergey Zigachev
3762b843c749SSergey Zigachev if (want_thermal_protection) {
3763b843c749SSergey Zigachev WREG32_P(CG_THERMAL_CTRL, DPM_EVENT_SRC(dpm_event_src), ~DPM_EVENT_SRC_MASK);
3764b843c749SSergey Zigachev if (pi->thermal_protection)
3765b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS);
3766b843c749SSergey Zigachev } else {
3767b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS);
3768b843c749SSergey Zigachev }
3769b843c749SSergey Zigachev }
3770b843c749SSergey Zigachev
si_enable_auto_throttle_source(struct amdgpu_device * adev,enum amdgpu_dpm_auto_throttle_src source,bool enable)3771b843c749SSergey Zigachev static void si_enable_auto_throttle_source(struct amdgpu_device *adev,
3772b843c749SSergey Zigachev enum amdgpu_dpm_auto_throttle_src source,
3773b843c749SSergey Zigachev bool enable)
3774b843c749SSergey Zigachev {
3775b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
3776b843c749SSergey Zigachev
3777b843c749SSergey Zigachev if (enable) {
3778b843c749SSergey Zigachev if (!(pi->active_auto_throttle_sources & (1 << source))) {
3779b843c749SSergey Zigachev pi->active_auto_throttle_sources |= 1 << source;
3780b843c749SSergey Zigachev si_set_dpm_event_sources(adev, pi->active_auto_throttle_sources);
3781b843c749SSergey Zigachev }
3782b843c749SSergey Zigachev } else {
3783b843c749SSergey Zigachev if (pi->active_auto_throttle_sources & (1 << source)) {
3784b843c749SSergey Zigachev pi->active_auto_throttle_sources &= ~(1 << source);
3785b843c749SSergey Zigachev si_set_dpm_event_sources(adev, pi->active_auto_throttle_sources);
3786b843c749SSergey Zigachev }
3787b843c749SSergey Zigachev }
3788b843c749SSergey Zigachev }
3789b843c749SSergey Zigachev
si_start_dpm(struct amdgpu_device * adev)3790b843c749SSergey Zigachev static void si_start_dpm(struct amdgpu_device *adev)
3791b843c749SSergey Zigachev {
3792b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, GLOBAL_PWRMGT_EN, ~GLOBAL_PWRMGT_EN);
3793b843c749SSergey Zigachev }
3794b843c749SSergey Zigachev
si_stop_dpm(struct amdgpu_device * adev)3795b843c749SSergey Zigachev static void si_stop_dpm(struct amdgpu_device *adev)
3796b843c749SSergey Zigachev {
3797b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, 0, ~GLOBAL_PWRMGT_EN);
3798b843c749SSergey Zigachev }
3799b843c749SSergey Zigachev
si_enable_sclk_control(struct amdgpu_device * adev,bool enable)3800b843c749SSergey Zigachev static void si_enable_sclk_control(struct amdgpu_device *adev, bool enable)
3801b843c749SSergey Zigachev {
3802b843c749SSergey Zigachev if (enable)
3803b843c749SSergey Zigachev WREG32_P(SCLK_PWRMGT_CNTL, 0, ~SCLK_PWRMGT_OFF);
3804b843c749SSergey Zigachev else
3805b843c749SSergey Zigachev WREG32_P(SCLK_PWRMGT_CNTL, SCLK_PWRMGT_OFF, ~SCLK_PWRMGT_OFF);
3806b843c749SSergey Zigachev
3807b843c749SSergey Zigachev }
3808b843c749SSergey Zigachev
3809b843c749SSergey Zigachev #if 0
3810b843c749SSergey Zigachev static int si_notify_hardware_of_thermal_state(struct amdgpu_device *adev,
3811b843c749SSergey Zigachev u32 thermal_level)
3812b843c749SSergey Zigachev {
3813b843c749SSergey Zigachev PPSMC_Result ret;
3814b843c749SSergey Zigachev
3815b843c749SSergey Zigachev if (thermal_level == 0) {
3816b843c749SSergey Zigachev ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableThermalInterrupt);
3817b843c749SSergey Zigachev if (ret == PPSMC_Result_OK)
3818b843c749SSergey Zigachev return 0;
3819b843c749SSergey Zigachev else
3820b843c749SSergey Zigachev return -EINVAL;
3821b843c749SSergey Zigachev }
3822b843c749SSergey Zigachev return 0;
3823b843c749SSergey Zigachev }
3824b843c749SSergey Zigachev
3825b843c749SSergey Zigachev static void si_notify_hardware_vpu_recovery_event(struct amdgpu_device *adev)
3826b843c749SSergey Zigachev {
3827b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen, true);
3828b843c749SSergey Zigachev }
3829b843c749SSergey Zigachev #endif
3830b843c749SSergey Zigachev
3831b843c749SSergey Zigachev #if 0
3832b843c749SSergey Zigachev static int si_notify_hw_of_powersource(struct amdgpu_device *adev, bool ac_power)
3833b843c749SSergey Zigachev {
3834b843c749SSergey Zigachev if (ac_power)
3835b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_RunningOnAC) == PPSMC_Result_OK) ?
3836b843c749SSergey Zigachev 0 : -EINVAL;
3837b843c749SSergey Zigachev
3838b843c749SSergey Zigachev return 0;
3839b843c749SSergey Zigachev }
3840b843c749SSergey Zigachev #endif
3841b843c749SSergey Zigachev
si_send_msg_to_smc_with_parameter(struct amdgpu_device * adev,PPSMC_Msg msg,u32 parameter)3842b843c749SSergey Zigachev static PPSMC_Result si_send_msg_to_smc_with_parameter(struct amdgpu_device *adev,
3843b843c749SSergey Zigachev PPSMC_Msg msg, u32 parameter)
3844b843c749SSergey Zigachev {
3845b843c749SSergey Zigachev WREG32(SMC_SCRATCH0, parameter);
3846b843c749SSergey Zigachev return amdgpu_si_send_msg_to_smc(adev, msg);
3847b843c749SSergey Zigachev }
3848b843c749SSergey Zigachev
si_restrict_performance_levels_before_switch(struct amdgpu_device * adev)3849b843c749SSergey Zigachev static int si_restrict_performance_levels_before_switch(struct amdgpu_device *adev)
3850b843c749SSergey Zigachev {
3851b843c749SSergey Zigachev if (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_NoForcedLevel) != PPSMC_Result_OK)
3852b843c749SSergey Zigachev return -EINVAL;
3853b843c749SSergey Zigachev
3854b843c749SSergey Zigachev return (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, 1) == PPSMC_Result_OK) ?
3855b843c749SSergey Zigachev 0 : -EINVAL;
3856b843c749SSergey Zigachev }
3857b843c749SSergey Zigachev
si_dpm_force_performance_level(void * handle,enum amd_dpm_forced_level level)3858b843c749SSergey Zigachev static int si_dpm_force_performance_level(void *handle,
3859b843c749SSergey Zigachev enum amd_dpm_forced_level level)
3860b843c749SSergey Zigachev {
3861b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
3862b843c749SSergey Zigachev struct amdgpu_ps *rps = adev->pm.dpm.current_ps;
3863b843c749SSergey Zigachev struct si_ps *ps = si_get_ps(rps);
3864b843c749SSergey Zigachev u32 levels = ps->performance_level_count;
3865b843c749SSergey Zigachev
3866b843c749SSergey Zigachev if (level == AMD_DPM_FORCED_LEVEL_HIGH) {
3867b843c749SSergey Zigachev if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
3868b843c749SSergey Zigachev return -EINVAL;
3869b843c749SSergey Zigachev
3870b843c749SSergey Zigachev if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 1) != PPSMC_Result_OK)
3871b843c749SSergey Zigachev return -EINVAL;
3872b843c749SSergey Zigachev } else if (level == AMD_DPM_FORCED_LEVEL_LOW) {
3873b843c749SSergey Zigachev if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
3874b843c749SSergey Zigachev return -EINVAL;
3875b843c749SSergey Zigachev
3876b843c749SSergey Zigachev if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, 1) != PPSMC_Result_OK)
3877b843c749SSergey Zigachev return -EINVAL;
3878b843c749SSergey Zigachev } else if (level == AMD_DPM_FORCED_LEVEL_AUTO) {
3879b843c749SSergey Zigachev if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetForcedLevels, 0) != PPSMC_Result_OK)
3880b843c749SSergey Zigachev return -EINVAL;
3881b843c749SSergey Zigachev
3882b843c749SSergey Zigachev if (si_send_msg_to_smc_with_parameter(adev, PPSMC_MSG_SetEnabledLevels, levels) != PPSMC_Result_OK)
3883b843c749SSergey Zigachev return -EINVAL;
3884b843c749SSergey Zigachev }
3885b843c749SSergey Zigachev
3886b843c749SSergey Zigachev adev->pm.dpm.forced_level = level;
3887b843c749SSergey Zigachev
3888b843c749SSergey Zigachev return 0;
3889b843c749SSergey Zigachev }
3890b843c749SSergey Zigachev
3891b843c749SSergey Zigachev #if 0
3892b843c749SSergey Zigachev static int si_set_boot_state(struct amdgpu_device *adev)
3893b843c749SSergey Zigachev {
3894b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_SwitchToInitialState) == PPSMC_Result_OK) ?
3895b843c749SSergey Zigachev 0 : -EINVAL;
3896b843c749SSergey Zigachev }
3897b843c749SSergey Zigachev #endif
3898b843c749SSergey Zigachev
si_set_sw_state(struct amdgpu_device * adev)3899b843c749SSergey Zigachev static int si_set_sw_state(struct amdgpu_device *adev)
3900b843c749SSergey Zigachev {
3901b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_SwitchToSwState) == PPSMC_Result_OK) ?
3902b843c749SSergey Zigachev 0 : -EINVAL;
3903b843c749SSergey Zigachev }
3904b843c749SSergey Zigachev
si_halt_smc(struct amdgpu_device * adev)3905b843c749SSergey Zigachev static int si_halt_smc(struct amdgpu_device *adev)
3906b843c749SSergey Zigachev {
3907b843c749SSergey Zigachev if (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_Halt) != PPSMC_Result_OK)
3908b843c749SSergey Zigachev return -EINVAL;
3909b843c749SSergey Zigachev
3910b843c749SSergey Zigachev return (amdgpu_si_wait_for_smc_inactive(adev) == PPSMC_Result_OK) ?
3911b843c749SSergey Zigachev 0 : -EINVAL;
3912b843c749SSergey Zigachev }
3913b843c749SSergey Zigachev
si_resume_smc(struct amdgpu_device * adev)3914b843c749SSergey Zigachev static int si_resume_smc(struct amdgpu_device *adev)
3915b843c749SSergey Zigachev {
3916b843c749SSergey Zigachev if (amdgpu_si_send_msg_to_smc(adev, PPSMC_FlushDataCache) != PPSMC_Result_OK)
3917b843c749SSergey Zigachev return -EINVAL;
3918b843c749SSergey Zigachev
3919b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_Resume) == PPSMC_Result_OK) ?
3920b843c749SSergey Zigachev 0 : -EINVAL;
3921b843c749SSergey Zigachev }
3922b843c749SSergey Zigachev
si_dpm_start_smc(struct amdgpu_device * adev)3923b843c749SSergey Zigachev static void si_dpm_start_smc(struct amdgpu_device *adev)
3924b843c749SSergey Zigachev {
3925b843c749SSergey Zigachev amdgpu_si_program_jump_on_start(adev);
3926b843c749SSergey Zigachev amdgpu_si_start_smc(adev);
3927b843c749SSergey Zigachev amdgpu_si_smc_clock(adev, true);
3928b843c749SSergey Zigachev }
3929b843c749SSergey Zigachev
si_dpm_stop_smc(struct amdgpu_device * adev)3930b843c749SSergey Zigachev static void si_dpm_stop_smc(struct amdgpu_device *adev)
3931b843c749SSergey Zigachev {
3932b843c749SSergey Zigachev amdgpu_si_reset_smc(adev);
3933b843c749SSergey Zigachev amdgpu_si_smc_clock(adev, false);
3934b843c749SSergey Zigachev }
3935b843c749SSergey Zigachev
si_process_firmware_header(struct amdgpu_device * adev)3936b843c749SSergey Zigachev static int si_process_firmware_header(struct amdgpu_device *adev)
3937b843c749SSergey Zigachev {
3938b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
3939b843c749SSergey Zigachev u32 tmp;
3940b843c749SSergey Zigachev int ret;
3941b843c749SSergey Zigachev
3942b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
3943b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
3944b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_stateTable,
3945b843c749SSergey Zigachev &tmp, si_pi->sram_end);
3946b843c749SSergey Zigachev if (ret)
3947b843c749SSergey Zigachev return ret;
3948b843c749SSergey Zigachev
3949b843c749SSergey Zigachev si_pi->state_table_start = tmp;
3950b843c749SSergey Zigachev
3951b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
3952b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
3953b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_softRegisters,
3954b843c749SSergey Zigachev &tmp, si_pi->sram_end);
3955b843c749SSergey Zigachev if (ret)
3956b843c749SSergey Zigachev return ret;
3957b843c749SSergey Zigachev
3958b843c749SSergey Zigachev si_pi->soft_regs_start = tmp;
3959b843c749SSergey Zigachev
3960b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
3961b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
3962b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable,
3963b843c749SSergey Zigachev &tmp, si_pi->sram_end);
3964b843c749SSergey Zigachev if (ret)
3965b843c749SSergey Zigachev return ret;
3966b843c749SSergey Zigachev
3967b843c749SSergey Zigachev si_pi->mc_reg_table_start = tmp;
3968b843c749SSergey Zigachev
3969b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
3970b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
3971b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_fanTable,
3972b843c749SSergey Zigachev &tmp, si_pi->sram_end);
3973b843c749SSergey Zigachev if (ret)
3974b843c749SSergey Zigachev return ret;
3975b843c749SSergey Zigachev
3976b843c749SSergey Zigachev si_pi->fan_table_start = tmp;
3977b843c749SSergey Zigachev
3978b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
3979b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
3980b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable,
3981b843c749SSergey Zigachev &tmp, si_pi->sram_end);
3982b843c749SSergey Zigachev if (ret)
3983b843c749SSergey Zigachev return ret;
3984b843c749SSergey Zigachev
3985b843c749SSergey Zigachev si_pi->arb_table_start = tmp;
3986b843c749SSergey Zigachev
3987b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
3988b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
3989b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable,
3990b843c749SSergey Zigachev &tmp, si_pi->sram_end);
3991b843c749SSergey Zigachev if (ret)
3992b843c749SSergey Zigachev return ret;
3993b843c749SSergey Zigachev
3994b843c749SSergey Zigachev si_pi->cac_table_start = tmp;
3995b843c749SSergey Zigachev
3996b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
3997b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
3998b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration,
3999b843c749SSergey Zigachev &tmp, si_pi->sram_end);
4000b843c749SSergey Zigachev if (ret)
4001b843c749SSergey Zigachev return ret;
4002b843c749SSergey Zigachev
4003b843c749SSergey Zigachev si_pi->dte_table_start = tmp;
4004b843c749SSergey Zigachev
4005b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
4006b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4007b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_spllTable,
4008b843c749SSergey Zigachev &tmp, si_pi->sram_end);
4009b843c749SSergey Zigachev if (ret)
4010b843c749SSergey Zigachev return ret;
4011b843c749SSergey Zigachev
4012b843c749SSergey Zigachev si_pi->spll_table_start = tmp;
4013b843c749SSergey Zigachev
4014b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev,
4015b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_LOCATION +
4016b843c749SSergey Zigachev SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters,
4017b843c749SSergey Zigachev &tmp, si_pi->sram_end);
4018b843c749SSergey Zigachev if (ret)
4019b843c749SSergey Zigachev return ret;
4020b843c749SSergey Zigachev
4021b843c749SSergey Zigachev si_pi->papm_cfg_table_start = tmp;
4022b843c749SSergey Zigachev
4023b843c749SSergey Zigachev return ret;
4024b843c749SSergey Zigachev }
4025b843c749SSergey Zigachev
si_read_clock_registers(struct amdgpu_device * adev)4026b843c749SSergey Zigachev static void si_read_clock_registers(struct amdgpu_device *adev)
4027b843c749SSergey Zigachev {
4028b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4029b843c749SSergey Zigachev
4030b843c749SSergey Zigachev si_pi->clock_registers.cg_spll_func_cntl = RREG32(CG_SPLL_FUNC_CNTL);
4031b843c749SSergey Zigachev si_pi->clock_registers.cg_spll_func_cntl_2 = RREG32(CG_SPLL_FUNC_CNTL_2);
4032b843c749SSergey Zigachev si_pi->clock_registers.cg_spll_func_cntl_3 = RREG32(CG_SPLL_FUNC_CNTL_3);
4033b843c749SSergey Zigachev si_pi->clock_registers.cg_spll_func_cntl_4 = RREG32(CG_SPLL_FUNC_CNTL_4);
4034b843c749SSergey Zigachev si_pi->clock_registers.cg_spll_spread_spectrum = RREG32(CG_SPLL_SPREAD_SPECTRUM);
4035b843c749SSergey Zigachev si_pi->clock_registers.cg_spll_spread_spectrum_2 = RREG32(CG_SPLL_SPREAD_SPECTRUM_2);
4036b843c749SSergey Zigachev si_pi->clock_registers.dll_cntl = RREG32(DLL_CNTL);
4037b843c749SSergey Zigachev si_pi->clock_registers.mclk_pwrmgt_cntl = RREG32(MCLK_PWRMGT_CNTL);
4038b843c749SSergey Zigachev si_pi->clock_registers.mpll_ad_func_cntl = RREG32(MPLL_AD_FUNC_CNTL);
4039b843c749SSergey Zigachev si_pi->clock_registers.mpll_dq_func_cntl = RREG32(MPLL_DQ_FUNC_CNTL);
4040b843c749SSergey Zigachev si_pi->clock_registers.mpll_func_cntl = RREG32(MPLL_FUNC_CNTL);
4041b843c749SSergey Zigachev si_pi->clock_registers.mpll_func_cntl_1 = RREG32(MPLL_FUNC_CNTL_1);
4042b843c749SSergey Zigachev si_pi->clock_registers.mpll_func_cntl_2 = RREG32(MPLL_FUNC_CNTL_2);
4043b843c749SSergey Zigachev si_pi->clock_registers.mpll_ss1 = RREG32(MPLL_SS1);
4044b843c749SSergey Zigachev si_pi->clock_registers.mpll_ss2 = RREG32(MPLL_SS2);
4045b843c749SSergey Zigachev }
4046b843c749SSergey Zigachev
si_enable_thermal_protection(struct amdgpu_device * adev,bool enable)4047b843c749SSergey Zigachev static void si_enable_thermal_protection(struct amdgpu_device *adev,
4048b843c749SSergey Zigachev bool enable)
4049b843c749SSergey Zigachev {
4050b843c749SSergey Zigachev if (enable)
4051b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, 0, ~THERMAL_PROTECTION_DIS);
4052b843c749SSergey Zigachev else
4053b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, THERMAL_PROTECTION_DIS, ~THERMAL_PROTECTION_DIS);
4054b843c749SSergey Zigachev }
4055b843c749SSergey Zigachev
si_enable_acpi_power_management(struct amdgpu_device * adev)4056b843c749SSergey Zigachev static void si_enable_acpi_power_management(struct amdgpu_device *adev)
4057b843c749SSergey Zigachev {
4058b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, STATIC_PM_EN, ~STATIC_PM_EN);
4059b843c749SSergey Zigachev }
4060b843c749SSergey Zigachev
4061b843c749SSergey Zigachev #if 0
4062b843c749SSergey Zigachev static int si_enter_ulp_state(struct amdgpu_device *adev)
4063b843c749SSergey Zigachev {
4064b843c749SSergey Zigachev WREG32(SMC_MESSAGE_0, PPSMC_MSG_SwitchToMinimumPower);
4065b843c749SSergey Zigachev
4066b843c749SSergey Zigachev udelay(25000);
4067b843c749SSergey Zigachev
4068b843c749SSergey Zigachev return 0;
4069b843c749SSergey Zigachev }
4070b843c749SSergey Zigachev
4071b843c749SSergey Zigachev static int si_exit_ulp_state(struct amdgpu_device *adev)
4072b843c749SSergey Zigachev {
4073b843c749SSergey Zigachev int i;
4074b843c749SSergey Zigachev
4075b843c749SSergey Zigachev WREG32(SMC_MESSAGE_0, PPSMC_MSG_ResumeFromMinimumPower);
4076b843c749SSergey Zigachev
4077b843c749SSergey Zigachev udelay(7000);
4078b843c749SSergey Zigachev
4079b843c749SSergey Zigachev for (i = 0; i < adev->usec_timeout; i++) {
4080b843c749SSergey Zigachev if (RREG32(SMC_RESP_0) == 1)
4081b843c749SSergey Zigachev break;
4082b843c749SSergey Zigachev udelay(1000);
4083b843c749SSergey Zigachev }
4084b843c749SSergey Zigachev
4085b843c749SSergey Zigachev return 0;
4086b843c749SSergey Zigachev }
4087b843c749SSergey Zigachev #endif
4088b843c749SSergey Zigachev
si_notify_smc_display_change(struct amdgpu_device * adev,bool has_display)4089b843c749SSergey Zigachev static int si_notify_smc_display_change(struct amdgpu_device *adev,
4090b843c749SSergey Zigachev bool has_display)
4091b843c749SSergey Zigachev {
4092b843c749SSergey Zigachev PPSMC_Msg msg = has_display ?
4093b843c749SSergey Zigachev PPSMC_MSG_HasDisplay : PPSMC_MSG_NoDisplay;
4094b843c749SSergey Zigachev
4095b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, msg) == PPSMC_Result_OK) ?
4096b843c749SSergey Zigachev 0 : -EINVAL;
4097b843c749SSergey Zigachev }
4098b843c749SSergey Zigachev
si_program_response_times(struct amdgpu_device * adev)4099b843c749SSergey Zigachev static void si_program_response_times(struct amdgpu_device *adev)
4100b843c749SSergey Zigachev {
4101b843c749SSergey Zigachev u32 voltage_response_time, backbias_response_time, acpi_delay_time, vbi_time_out;
4102b843c749SSergey Zigachev u32 vddc_dly, acpi_dly, vbi_dly;
4103b843c749SSergey Zigachev u32 reference_clock;
4104b843c749SSergey Zigachev
4105b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mvdd_chg_time, 1);
4106b843c749SSergey Zigachev
4107b843c749SSergey Zigachev voltage_response_time = (u32)adev->pm.dpm.voltage_response_time;
4108b843c749SSergey Zigachev backbias_response_time = (u32)adev->pm.dpm.backbias_response_time;
4109b843c749SSergey Zigachev
4110b843c749SSergey Zigachev if (voltage_response_time == 0)
4111b843c749SSergey Zigachev voltage_response_time = 1000;
4112b843c749SSergey Zigachev
4113b843c749SSergey Zigachev acpi_delay_time = 15000;
4114b843c749SSergey Zigachev vbi_time_out = 100000;
4115b843c749SSergey Zigachev
4116b843c749SSergey Zigachev reference_clock = amdgpu_asic_get_xclk(adev);
4117b843c749SSergey Zigachev
4118b843c749SSergey Zigachev vddc_dly = (voltage_response_time * reference_clock) / 100;
4119b843c749SSergey Zigachev acpi_dly = (acpi_delay_time * reference_clock) / 100;
4120b843c749SSergey Zigachev vbi_dly = (vbi_time_out * reference_clock) / 100;
4121b843c749SSergey Zigachev
4122b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_delay_vreg, vddc_dly);
4123b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_delay_acpi, acpi_dly);
4124b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mclk_chg_timeout, vbi_dly);
4125b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mc_block_delay, 0xAA);
4126b843c749SSergey Zigachev }
4127b843c749SSergey Zigachev
si_program_ds_registers(struct amdgpu_device * adev)4128b843c749SSergey Zigachev static void si_program_ds_registers(struct amdgpu_device *adev)
4129b843c749SSergey Zigachev {
4130b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4131b843c749SSergey Zigachev u32 tmp;
4132b843c749SSergey Zigachev
4133b843c749SSergey Zigachev /* DEEP_SLEEP_CLK_SEL field should be 0x10 on tahiti A0 */
4134b843c749SSergey Zigachev if (adev->asic_type == CHIP_TAHITI && adev->rev_id == 0x0)
4135b843c749SSergey Zigachev tmp = 0x10;
4136b843c749SSergey Zigachev else
4137b843c749SSergey Zigachev tmp = 0x1;
4138b843c749SSergey Zigachev
4139b843c749SSergey Zigachev if (eg_pi->sclk_deep_sleep) {
4140b843c749SSergey Zigachev WREG32_P(MISC_CLK_CNTL, DEEP_SLEEP_CLK_SEL(tmp), ~DEEP_SLEEP_CLK_SEL_MASK);
4141b843c749SSergey Zigachev WREG32_P(CG_SPLL_AUTOSCALE_CNTL, AUTOSCALE_ON_SS_CLEAR,
4142b843c749SSergey Zigachev ~AUTOSCALE_ON_SS_CLEAR);
4143b843c749SSergey Zigachev }
4144b843c749SSergey Zigachev }
4145b843c749SSergey Zigachev
si_program_display_gap(struct amdgpu_device * adev)4146b843c749SSergey Zigachev static void si_program_display_gap(struct amdgpu_device *adev)
4147b843c749SSergey Zigachev {
4148b843c749SSergey Zigachev u32 tmp, pipe;
4149b843c749SSergey Zigachev int i;
4150b843c749SSergey Zigachev
4151b843c749SSergey Zigachev tmp = RREG32(CG_DISPLAY_GAP_CNTL) & ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
4152b843c749SSergey Zigachev if (adev->pm.dpm.new_active_crtc_count > 0)
4153b843c749SSergey Zigachev tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM);
4154b843c749SSergey Zigachev else
4155b843c749SSergey Zigachev tmp |= DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE);
4156b843c749SSergey Zigachev
4157b843c749SSergey Zigachev if (adev->pm.dpm.new_active_crtc_count > 1)
4158b843c749SSergey Zigachev tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_VBLANK_OR_WM);
4159b843c749SSergey Zigachev else
4160b843c749SSergey Zigachev tmp |= DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE);
4161b843c749SSergey Zigachev
4162b843c749SSergey Zigachev WREG32(CG_DISPLAY_GAP_CNTL, tmp);
4163b843c749SSergey Zigachev
4164b843c749SSergey Zigachev tmp = RREG32(DCCG_DISP_SLOW_SELECT_REG);
4165b843c749SSergey Zigachev pipe = (tmp & DCCG_DISP1_SLOW_SELECT_MASK) >> DCCG_DISP1_SLOW_SELECT_SHIFT;
4166b843c749SSergey Zigachev
4167b843c749SSergey Zigachev if ((adev->pm.dpm.new_active_crtc_count > 0) &&
4168b843c749SSergey Zigachev (!(adev->pm.dpm.new_active_crtcs & (1 << pipe)))) {
4169b843c749SSergey Zigachev /* find the first active crtc */
4170b843c749SSergey Zigachev for (i = 0; i < adev->mode_info.num_crtc; i++) {
4171b843c749SSergey Zigachev if (adev->pm.dpm.new_active_crtcs & (1 << i))
4172b843c749SSergey Zigachev break;
4173b843c749SSergey Zigachev }
4174b843c749SSergey Zigachev if (i == adev->mode_info.num_crtc)
4175b843c749SSergey Zigachev pipe = 0;
4176b843c749SSergey Zigachev else
4177b843c749SSergey Zigachev pipe = i;
4178b843c749SSergey Zigachev
4179b843c749SSergey Zigachev tmp &= ~DCCG_DISP1_SLOW_SELECT_MASK;
4180b843c749SSergey Zigachev tmp |= DCCG_DISP1_SLOW_SELECT(pipe);
4181b843c749SSergey Zigachev WREG32(DCCG_DISP_SLOW_SELECT_REG, tmp);
4182b843c749SSergey Zigachev }
4183b843c749SSergey Zigachev
4184b843c749SSergey Zigachev /* Setting this to false forces the performance state to low if the crtcs are disabled.
4185b843c749SSergey Zigachev * This can be a problem on PowerXpress systems or if you want to use the card
4186b843c749SSergey Zigachev * for offscreen rendering or compute if there are no crtcs enabled.
4187b843c749SSergey Zigachev */
4188b843c749SSergey Zigachev si_notify_smc_display_change(adev, adev->pm.dpm.new_active_crtc_count > 0);
4189b843c749SSergey Zigachev }
4190b843c749SSergey Zigachev
si_enable_spread_spectrum(struct amdgpu_device * adev,bool enable)4191b843c749SSergey Zigachev static void si_enable_spread_spectrum(struct amdgpu_device *adev, bool enable)
4192b843c749SSergey Zigachev {
4193b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4194b843c749SSergey Zigachev
4195b843c749SSergey Zigachev if (enable) {
4196b843c749SSergey Zigachev if (pi->sclk_ss)
4197b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, DYN_SPREAD_SPECTRUM_EN, ~DYN_SPREAD_SPECTRUM_EN);
4198b843c749SSergey Zigachev } else {
4199b843c749SSergey Zigachev WREG32_P(CG_SPLL_SPREAD_SPECTRUM, 0, ~SSEN);
4200b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, 0, ~DYN_SPREAD_SPECTRUM_EN);
4201b843c749SSergey Zigachev }
4202b843c749SSergey Zigachev }
4203b843c749SSergey Zigachev
si_setup_bsp(struct amdgpu_device * adev)4204b843c749SSergey Zigachev static void si_setup_bsp(struct amdgpu_device *adev)
4205b843c749SSergey Zigachev {
4206b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4207b843c749SSergey Zigachev u32 xclk = amdgpu_asic_get_xclk(adev);
4208b843c749SSergey Zigachev
4209b843c749SSergey Zigachev r600_calculate_u_and_p(pi->asi,
4210b843c749SSergey Zigachev xclk,
4211b843c749SSergey Zigachev 16,
4212b843c749SSergey Zigachev &pi->bsp,
4213b843c749SSergey Zigachev &pi->bsu);
4214b843c749SSergey Zigachev
4215b843c749SSergey Zigachev r600_calculate_u_and_p(pi->pasi,
4216b843c749SSergey Zigachev xclk,
4217b843c749SSergey Zigachev 16,
4218b843c749SSergey Zigachev &pi->pbsp,
4219b843c749SSergey Zigachev &pi->pbsu);
4220b843c749SSergey Zigachev
4221b843c749SSergey Zigachev
4222b843c749SSergey Zigachev pi->dsp = BSP(pi->bsp) | BSU(pi->bsu);
4223b843c749SSergey Zigachev pi->psp = BSP(pi->pbsp) | BSU(pi->pbsu);
4224b843c749SSergey Zigachev
4225b843c749SSergey Zigachev WREG32(CG_BSP, pi->dsp);
4226b843c749SSergey Zigachev }
4227b843c749SSergey Zigachev
si_program_git(struct amdgpu_device * adev)4228b843c749SSergey Zigachev static void si_program_git(struct amdgpu_device *adev)
4229b843c749SSergey Zigachev {
4230b843c749SSergey Zigachev WREG32_P(CG_GIT, CG_GICST(R600_GICST_DFLT), ~CG_GICST_MASK);
4231b843c749SSergey Zigachev }
4232b843c749SSergey Zigachev
si_program_tp(struct amdgpu_device * adev)4233b843c749SSergey Zigachev static void si_program_tp(struct amdgpu_device *adev)
4234b843c749SSergey Zigachev {
4235b843c749SSergey Zigachev int i;
4236b843c749SSergey Zigachev enum r600_td td = R600_TD_DFLT;
4237b843c749SSergey Zigachev
4238b843c749SSergey Zigachev for (i = 0; i < R600_PM_NUMBER_OF_TC; i++)
4239b843c749SSergey Zigachev WREG32(CG_FFCT_0 + i, (UTC_0(r600_utc[i]) | DTC_0(r600_dtc[i])));
4240b843c749SSergey Zigachev
4241b843c749SSergey Zigachev if (td == R600_TD_AUTO)
4242b843c749SSergey Zigachev WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_FORCE_TREND_SEL);
4243b843c749SSergey Zigachev else
4244b843c749SSergey Zigachev WREG32_P(SCLK_PWRMGT_CNTL, FIR_FORCE_TREND_SEL, ~FIR_FORCE_TREND_SEL);
4245b843c749SSergey Zigachev
4246b843c749SSergey Zigachev if (td == R600_TD_UP)
4247b843c749SSergey Zigachev WREG32_P(SCLK_PWRMGT_CNTL, 0, ~FIR_TREND_MODE);
4248b843c749SSergey Zigachev
4249b843c749SSergey Zigachev if (td == R600_TD_DOWN)
4250b843c749SSergey Zigachev WREG32_P(SCLK_PWRMGT_CNTL, FIR_TREND_MODE, ~FIR_TREND_MODE);
4251b843c749SSergey Zigachev }
4252b843c749SSergey Zigachev
si_program_tpp(struct amdgpu_device * adev)4253b843c749SSergey Zigachev static void si_program_tpp(struct amdgpu_device *adev)
4254b843c749SSergey Zigachev {
4255b843c749SSergey Zigachev WREG32(CG_TPC, R600_TPC_DFLT);
4256b843c749SSergey Zigachev }
4257b843c749SSergey Zigachev
si_program_sstp(struct amdgpu_device * adev)4258b843c749SSergey Zigachev static void si_program_sstp(struct amdgpu_device *adev)
4259b843c749SSergey Zigachev {
4260b843c749SSergey Zigachev WREG32(CG_SSP, (SSTU(R600_SSTU_DFLT) | SST(R600_SST_DFLT)));
4261b843c749SSergey Zigachev }
4262b843c749SSergey Zigachev
si_enable_display_gap(struct amdgpu_device * adev)4263b843c749SSergey Zigachev static void si_enable_display_gap(struct amdgpu_device *adev)
4264b843c749SSergey Zigachev {
4265b843c749SSergey Zigachev u32 tmp = RREG32(CG_DISPLAY_GAP_CNTL);
4266b843c749SSergey Zigachev
4267b843c749SSergey Zigachev tmp &= ~(DISP1_GAP_MASK | DISP2_GAP_MASK);
4268b843c749SSergey Zigachev tmp |= (DISP1_GAP(R600_PM_DISPLAY_GAP_IGNORE) |
4269b843c749SSergey Zigachev DISP2_GAP(R600_PM_DISPLAY_GAP_IGNORE));
4270b843c749SSergey Zigachev
4271b843c749SSergey Zigachev tmp &= ~(DISP1_GAP_MCHG_MASK | DISP2_GAP_MCHG_MASK);
4272b843c749SSergey Zigachev tmp |= (DISP1_GAP_MCHG(R600_PM_DISPLAY_GAP_VBLANK) |
4273b843c749SSergey Zigachev DISP2_GAP_MCHG(R600_PM_DISPLAY_GAP_IGNORE));
4274b843c749SSergey Zigachev WREG32(CG_DISPLAY_GAP_CNTL, tmp);
4275b843c749SSergey Zigachev }
4276b843c749SSergey Zigachev
si_program_vc(struct amdgpu_device * adev)4277b843c749SSergey Zigachev static void si_program_vc(struct amdgpu_device *adev)
4278b843c749SSergey Zigachev {
4279b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4280b843c749SSergey Zigachev
4281b843c749SSergey Zigachev WREG32(CG_FTV, pi->vrc);
4282b843c749SSergey Zigachev }
4283b843c749SSergey Zigachev
si_clear_vc(struct amdgpu_device * adev)4284b843c749SSergey Zigachev static void si_clear_vc(struct amdgpu_device *adev)
4285b843c749SSergey Zigachev {
4286b843c749SSergey Zigachev WREG32(CG_FTV, 0);
4287b843c749SSergey Zigachev }
4288b843c749SSergey Zigachev
si_get_ddr3_mclk_frequency_ratio(u32 memory_clock)4289b843c749SSergey Zigachev static u8 si_get_ddr3_mclk_frequency_ratio(u32 memory_clock)
4290b843c749SSergey Zigachev {
4291b843c749SSergey Zigachev u8 mc_para_index;
4292b843c749SSergey Zigachev
4293b843c749SSergey Zigachev if (memory_clock < 10000)
4294b843c749SSergey Zigachev mc_para_index = 0;
4295b843c749SSergey Zigachev else if (memory_clock >= 80000)
4296b843c749SSergey Zigachev mc_para_index = 0x0f;
4297b843c749SSergey Zigachev else
4298b843c749SSergey Zigachev mc_para_index = (u8)((memory_clock - 10000) / 5000 + 1);
4299b843c749SSergey Zigachev return mc_para_index;
4300b843c749SSergey Zigachev }
4301b843c749SSergey Zigachev
si_get_mclk_frequency_ratio(u32 memory_clock,bool strobe_mode)4302b843c749SSergey Zigachev static u8 si_get_mclk_frequency_ratio(u32 memory_clock, bool strobe_mode)
4303b843c749SSergey Zigachev {
4304b843c749SSergey Zigachev u8 mc_para_index;
4305b843c749SSergey Zigachev
4306b843c749SSergey Zigachev if (strobe_mode) {
4307b843c749SSergey Zigachev if (memory_clock < 12500)
4308b843c749SSergey Zigachev mc_para_index = 0x00;
4309b843c749SSergey Zigachev else if (memory_clock > 47500)
4310b843c749SSergey Zigachev mc_para_index = 0x0f;
4311b843c749SSergey Zigachev else
4312b843c749SSergey Zigachev mc_para_index = (u8)((memory_clock - 10000) / 2500);
4313b843c749SSergey Zigachev } else {
4314b843c749SSergey Zigachev if (memory_clock < 65000)
4315b843c749SSergey Zigachev mc_para_index = 0x00;
4316b843c749SSergey Zigachev else if (memory_clock > 135000)
4317b843c749SSergey Zigachev mc_para_index = 0x0f;
4318b843c749SSergey Zigachev else
4319b843c749SSergey Zigachev mc_para_index = (u8)((memory_clock - 60000) / 5000);
4320b843c749SSergey Zigachev }
4321b843c749SSergey Zigachev return mc_para_index;
4322b843c749SSergey Zigachev }
4323b843c749SSergey Zigachev
si_get_strobe_mode_settings(struct amdgpu_device * adev,u32 mclk)4324b843c749SSergey Zigachev static u8 si_get_strobe_mode_settings(struct amdgpu_device *adev, u32 mclk)
4325b843c749SSergey Zigachev {
4326b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4327b843c749SSergey Zigachev bool strobe_mode = false;
4328b843c749SSergey Zigachev u8 result = 0;
4329b843c749SSergey Zigachev
4330b843c749SSergey Zigachev if (mclk <= pi->mclk_strobe_mode_threshold)
4331b843c749SSergey Zigachev strobe_mode = true;
4332b843c749SSergey Zigachev
4333b843c749SSergey Zigachev if (adev->gmc.vram_type == AMDGPU_VRAM_TYPE_GDDR5)
4334b843c749SSergey Zigachev result = si_get_mclk_frequency_ratio(mclk, strobe_mode);
4335b843c749SSergey Zigachev else
4336b843c749SSergey Zigachev result = si_get_ddr3_mclk_frequency_ratio(mclk);
4337b843c749SSergey Zigachev
4338b843c749SSergey Zigachev if (strobe_mode)
4339b843c749SSergey Zigachev result |= SISLANDS_SMC_STROBE_ENABLE;
4340b843c749SSergey Zigachev
4341b843c749SSergey Zigachev return result;
4342b843c749SSergey Zigachev }
4343b843c749SSergey Zigachev
si_upload_firmware(struct amdgpu_device * adev)4344b843c749SSergey Zigachev static int si_upload_firmware(struct amdgpu_device *adev)
4345b843c749SSergey Zigachev {
4346b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4347b843c749SSergey Zigachev
4348b843c749SSergey Zigachev amdgpu_si_reset_smc(adev);
4349b843c749SSergey Zigachev amdgpu_si_smc_clock(adev, false);
4350b843c749SSergey Zigachev
4351b843c749SSergey Zigachev return amdgpu_si_load_smc_ucode(adev, si_pi->sram_end);
4352b843c749SSergey Zigachev }
4353b843c749SSergey Zigachev
si_validate_phase_shedding_tables(struct amdgpu_device * adev,const struct atom_voltage_table * table,const struct amdgpu_phase_shedding_limits_table * limits)4354b843c749SSergey Zigachev static bool si_validate_phase_shedding_tables(struct amdgpu_device *adev,
4355b843c749SSergey Zigachev const struct atom_voltage_table *table,
4356b843c749SSergey Zigachev const struct amdgpu_phase_shedding_limits_table *limits)
4357b843c749SSergey Zigachev {
4358b843c749SSergey Zigachev u32 data, num_bits, num_levels;
4359b843c749SSergey Zigachev
4360b843c749SSergey Zigachev if ((table == NULL) || (limits == NULL))
4361b843c749SSergey Zigachev return false;
4362b843c749SSergey Zigachev
4363b843c749SSergey Zigachev data = table->mask_low;
4364b843c749SSergey Zigachev
4365b843c749SSergey Zigachev num_bits = hweight32(data);
4366b843c749SSergey Zigachev
4367b843c749SSergey Zigachev if (num_bits == 0)
4368b843c749SSergey Zigachev return false;
4369b843c749SSergey Zigachev
4370b843c749SSergey Zigachev num_levels = (1 << num_bits);
4371b843c749SSergey Zigachev
4372b843c749SSergey Zigachev if (table->count != num_levels)
4373b843c749SSergey Zigachev return false;
4374b843c749SSergey Zigachev
4375b843c749SSergey Zigachev if (limits->count != (num_levels - 1))
4376b843c749SSergey Zigachev return false;
4377b843c749SSergey Zigachev
4378b843c749SSergey Zigachev return true;
4379b843c749SSergey Zigachev }
4380b843c749SSergey Zigachev
si_trim_voltage_table_to_fit_state_table(struct amdgpu_device * adev,u32 max_voltage_steps,struct atom_voltage_table * voltage_table)4381b843c749SSergey Zigachev static void si_trim_voltage_table_to_fit_state_table(struct amdgpu_device *adev,
4382b843c749SSergey Zigachev u32 max_voltage_steps,
4383b843c749SSergey Zigachev struct atom_voltage_table *voltage_table)
4384b843c749SSergey Zigachev {
4385b843c749SSergey Zigachev unsigned int i, diff;
4386b843c749SSergey Zigachev
4387b843c749SSergey Zigachev if (voltage_table->count <= max_voltage_steps)
4388b843c749SSergey Zigachev return;
4389b843c749SSergey Zigachev
4390b843c749SSergey Zigachev diff = voltage_table->count - max_voltage_steps;
4391b843c749SSergey Zigachev
4392b843c749SSergey Zigachev for (i= 0; i < max_voltage_steps; i++)
4393b843c749SSergey Zigachev voltage_table->entries[i] = voltage_table->entries[i + diff];
4394b843c749SSergey Zigachev
4395b843c749SSergey Zigachev voltage_table->count = max_voltage_steps;
4396b843c749SSergey Zigachev }
4397b843c749SSergey Zigachev
si_get_svi2_voltage_table(struct amdgpu_device * adev,struct amdgpu_clock_voltage_dependency_table * voltage_dependency_table,struct atom_voltage_table * voltage_table)4398b843c749SSergey Zigachev static int si_get_svi2_voltage_table(struct amdgpu_device *adev,
4399b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table *voltage_dependency_table,
4400b843c749SSergey Zigachev struct atom_voltage_table *voltage_table)
4401b843c749SSergey Zigachev {
4402b843c749SSergey Zigachev u32 i;
4403b843c749SSergey Zigachev
4404b843c749SSergey Zigachev if (voltage_dependency_table == NULL)
4405b843c749SSergey Zigachev return -EINVAL;
4406b843c749SSergey Zigachev
4407b843c749SSergey Zigachev voltage_table->mask_low = 0;
4408b843c749SSergey Zigachev voltage_table->phase_delay = 0;
4409b843c749SSergey Zigachev
4410b843c749SSergey Zigachev voltage_table->count = voltage_dependency_table->count;
4411b843c749SSergey Zigachev for (i = 0; i < voltage_table->count; i++) {
4412b843c749SSergey Zigachev voltage_table->entries[i].value = voltage_dependency_table->entries[i].v;
4413b843c749SSergey Zigachev voltage_table->entries[i].smio_low = 0;
4414b843c749SSergey Zigachev }
4415b843c749SSergey Zigachev
4416b843c749SSergey Zigachev return 0;
4417b843c749SSergey Zigachev }
4418b843c749SSergey Zigachev
si_construct_voltage_tables(struct amdgpu_device * adev)4419b843c749SSergey Zigachev static int si_construct_voltage_tables(struct amdgpu_device *adev)
4420b843c749SSergey Zigachev {
4421b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4422b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4423b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4424b843c749SSergey Zigachev int ret;
4425b843c749SSergey Zigachev
4426b843c749SSergey Zigachev if (pi->voltage_control) {
4427b843c749SSergey Zigachev ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDC,
4428b843c749SSergey Zigachev VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddc_voltage_table);
4429b843c749SSergey Zigachev if (ret)
4430b843c749SSergey Zigachev return ret;
4431b843c749SSergey Zigachev
4432b843c749SSergey Zigachev if (eg_pi->vddc_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
4433b843c749SSergey Zigachev si_trim_voltage_table_to_fit_state_table(adev,
4434b843c749SSergey Zigachev SISLANDS_MAX_NO_VREG_STEPS,
4435b843c749SSergey Zigachev &eg_pi->vddc_voltage_table);
4436b843c749SSergey Zigachev } else if (si_pi->voltage_control_svi2) {
4437b843c749SSergey Zigachev ret = si_get_svi2_voltage_table(adev,
4438b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.vddc_dependency_on_mclk,
4439b843c749SSergey Zigachev &eg_pi->vddc_voltage_table);
4440b843c749SSergey Zigachev if (ret)
4441b843c749SSergey Zigachev return ret;
4442b843c749SSergey Zigachev } else {
4443b843c749SSergey Zigachev return -EINVAL;
4444b843c749SSergey Zigachev }
4445b843c749SSergey Zigachev
4446b843c749SSergey Zigachev if (eg_pi->vddci_control) {
4447b843c749SSergey Zigachev ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDCI,
4448b843c749SSergey Zigachev VOLTAGE_OBJ_GPIO_LUT, &eg_pi->vddci_voltage_table);
4449b843c749SSergey Zigachev if (ret)
4450b843c749SSergey Zigachev return ret;
4451b843c749SSergey Zigachev
4452b843c749SSergey Zigachev if (eg_pi->vddci_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
4453b843c749SSergey Zigachev si_trim_voltage_table_to_fit_state_table(adev,
4454b843c749SSergey Zigachev SISLANDS_MAX_NO_VREG_STEPS,
4455b843c749SSergey Zigachev &eg_pi->vddci_voltage_table);
4456b843c749SSergey Zigachev }
4457b843c749SSergey Zigachev if (si_pi->vddci_control_svi2) {
4458b843c749SSergey Zigachev ret = si_get_svi2_voltage_table(adev,
4459b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.vddci_dependency_on_mclk,
4460b843c749SSergey Zigachev &eg_pi->vddci_voltage_table);
4461b843c749SSergey Zigachev if (ret)
4462b843c749SSergey Zigachev return ret;
4463b843c749SSergey Zigachev }
4464b843c749SSergey Zigachev
4465b843c749SSergey Zigachev if (pi->mvdd_control) {
4466b843c749SSergey Zigachev ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_MVDDC,
4467b843c749SSergey Zigachev VOLTAGE_OBJ_GPIO_LUT, &si_pi->mvdd_voltage_table);
4468b843c749SSergey Zigachev
4469b843c749SSergey Zigachev if (ret) {
4470b843c749SSergey Zigachev pi->mvdd_control = false;
4471b843c749SSergey Zigachev return ret;
4472b843c749SSergey Zigachev }
4473b843c749SSergey Zigachev
4474b843c749SSergey Zigachev if (si_pi->mvdd_voltage_table.count == 0) {
4475b843c749SSergey Zigachev pi->mvdd_control = false;
4476b843c749SSergey Zigachev return -EINVAL;
4477b843c749SSergey Zigachev }
4478b843c749SSergey Zigachev
4479b843c749SSergey Zigachev if (si_pi->mvdd_voltage_table.count > SISLANDS_MAX_NO_VREG_STEPS)
4480b843c749SSergey Zigachev si_trim_voltage_table_to_fit_state_table(adev,
4481b843c749SSergey Zigachev SISLANDS_MAX_NO_VREG_STEPS,
4482b843c749SSergey Zigachev &si_pi->mvdd_voltage_table);
4483b843c749SSergey Zigachev }
4484b843c749SSergey Zigachev
4485b843c749SSergey Zigachev if (si_pi->vddc_phase_shed_control) {
4486b843c749SSergey Zigachev ret = amdgpu_atombios_get_voltage_table(adev, VOLTAGE_TYPE_VDDC,
4487b843c749SSergey Zigachev VOLTAGE_OBJ_PHASE_LUT, &si_pi->vddc_phase_shed_table);
4488b843c749SSergey Zigachev if (ret)
4489b843c749SSergey Zigachev si_pi->vddc_phase_shed_control = false;
4490b843c749SSergey Zigachev
4491b843c749SSergey Zigachev if ((si_pi->vddc_phase_shed_table.count == 0) ||
4492b843c749SSergey Zigachev (si_pi->vddc_phase_shed_table.count > SISLANDS_MAX_NO_VREG_STEPS))
4493b843c749SSergey Zigachev si_pi->vddc_phase_shed_control = false;
4494b843c749SSergey Zigachev }
4495b843c749SSergey Zigachev
4496b843c749SSergey Zigachev return 0;
4497b843c749SSergey Zigachev }
4498b843c749SSergey Zigachev
si_populate_smc_voltage_table(struct amdgpu_device * adev,const struct atom_voltage_table * voltage_table,SISLANDS_SMC_STATETABLE * table)4499b843c749SSergey Zigachev static void si_populate_smc_voltage_table(struct amdgpu_device *adev,
4500b843c749SSergey Zigachev const struct atom_voltage_table *voltage_table,
4501b843c749SSergey Zigachev SISLANDS_SMC_STATETABLE *table)
4502b843c749SSergey Zigachev {
4503b843c749SSergey Zigachev unsigned int i;
4504b843c749SSergey Zigachev
4505b843c749SSergey Zigachev for (i = 0; i < voltage_table->count; i++)
4506b843c749SSergey Zigachev table->lowSMIO[i] |= cpu_to_be32(voltage_table->entries[i].smio_low);
4507b843c749SSergey Zigachev }
4508b843c749SSergey Zigachev
si_populate_smc_voltage_tables(struct amdgpu_device * adev,SISLANDS_SMC_STATETABLE * table)4509b843c749SSergey Zigachev static int si_populate_smc_voltage_tables(struct amdgpu_device *adev,
4510b843c749SSergey Zigachev SISLANDS_SMC_STATETABLE *table)
4511b843c749SSergey Zigachev {
4512b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4513b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4514b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4515b843c749SSergey Zigachev u8 i;
4516b843c749SSergey Zigachev
4517b843c749SSergey Zigachev if (si_pi->voltage_control_svi2) {
4518b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc,
4519b843c749SSergey Zigachev si_pi->svc_gpio_id);
4520b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd,
4521b843c749SSergey Zigachev si_pi->svd_gpio_id);
4522b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_svi_rework_plat_type,
4523b843c749SSergey Zigachev 2);
4524b843c749SSergey Zigachev } else {
4525b843c749SSergey Zigachev if (eg_pi->vddc_voltage_table.count) {
4526b843c749SSergey Zigachev si_populate_smc_voltage_table(adev, &eg_pi->vddc_voltage_table, table);
4527b843c749SSergey Zigachev table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC] =
4528b843c749SSergey Zigachev cpu_to_be32(eg_pi->vddc_voltage_table.mask_low);
4529b843c749SSergey Zigachev
4530b843c749SSergey Zigachev for (i = 0; i < eg_pi->vddc_voltage_table.count; i++) {
4531b843c749SSergey Zigachev if (pi->max_vddc_in_table <= eg_pi->vddc_voltage_table.entries[i].value) {
4532b843c749SSergey Zigachev table->maxVDDCIndexInPPTable = i;
4533b843c749SSergey Zigachev break;
4534b843c749SSergey Zigachev }
4535b843c749SSergey Zigachev }
4536b843c749SSergey Zigachev }
4537b843c749SSergey Zigachev
4538b843c749SSergey Zigachev if (eg_pi->vddci_voltage_table.count) {
4539b843c749SSergey Zigachev si_populate_smc_voltage_table(adev, &eg_pi->vddci_voltage_table, table);
4540b843c749SSergey Zigachev
4541b843c749SSergey Zigachev table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDCI] =
4542b843c749SSergey Zigachev cpu_to_be32(eg_pi->vddci_voltage_table.mask_low);
4543b843c749SSergey Zigachev }
4544b843c749SSergey Zigachev
4545b843c749SSergey Zigachev
4546b843c749SSergey Zigachev if (si_pi->mvdd_voltage_table.count) {
4547b843c749SSergey Zigachev si_populate_smc_voltage_table(adev, &si_pi->mvdd_voltage_table, table);
4548b843c749SSergey Zigachev
4549b843c749SSergey Zigachev table->voltageMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_MVDD] =
4550b843c749SSergey Zigachev cpu_to_be32(si_pi->mvdd_voltage_table.mask_low);
4551b843c749SSergey Zigachev }
4552b843c749SSergey Zigachev
4553b843c749SSergey Zigachev if (si_pi->vddc_phase_shed_control) {
4554b843c749SSergey Zigachev if (si_validate_phase_shedding_tables(adev, &si_pi->vddc_phase_shed_table,
4555b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.phase_shedding_limits_table)) {
4556b843c749SSergey Zigachev si_populate_smc_voltage_table(adev, &si_pi->vddc_phase_shed_table, table);
4557b843c749SSergey Zigachev
4558b843c749SSergey Zigachev table->phaseMaskTable.lowMask[SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING] =
4559b843c749SSergey Zigachev cpu_to_be32(si_pi->vddc_phase_shed_table.mask_low);
4560b843c749SSergey Zigachev
4561b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_phase_shedding_delay,
4562b843c749SSergey Zigachev (u32)si_pi->vddc_phase_shed_table.phase_delay);
4563b843c749SSergey Zigachev } else {
4564b843c749SSergey Zigachev si_pi->vddc_phase_shed_control = false;
4565b843c749SSergey Zigachev }
4566b843c749SSergey Zigachev }
4567b843c749SSergey Zigachev }
4568b843c749SSergey Zigachev
4569b843c749SSergey Zigachev return 0;
4570b843c749SSergey Zigachev }
4571b843c749SSergey Zigachev
si_populate_voltage_value(struct amdgpu_device * adev,const struct atom_voltage_table * table,u16 value,SISLANDS_SMC_VOLTAGE_VALUE * voltage)4572b843c749SSergey Zigachev static int si_populate_voltage_value(struct amdgpu_device *adev,
4573b843c749SSergey Zigachev const struct atom_voltage_table *table,
4574b843c749SSergey Zigachev u16 value, SISLANDS_SMC_VOLTAGE_VALUE *voltage)
4575b843c749SSergey Zigachev {
4576b843c749SSergey Zigachev unsigned int i;
4577b843c749SSergey Zigachev
4578b843c749SSergey Zigachev for (i = 0; i < table->count; i++) {
4579b843c749SSergey Zigachev if (value <= table->entries[i].value) {
4580b843c749SSergey Zigachev voltage->index = (u8)i;
4581b843c749SSergey Zigachev voltage->value = cpu_to_be16(table->entries[i].value);
4582b843c749SSergey Zigachev break;
4583b843c749SSergey Zigachev }
4584b843c749SSergey Zigachev }
4585b843c749SSergey Zigachev
4586b843c749SSergey Zigachev if (i >= table->count)
4587b843c749SSergey Zigachev return -EINVAL;
4588b843c749SSergey Zigachev
4589b843c749SSergey Zigachev return 0;
4590b843c749SSergey Zigachev }
4591b843c749SSergey Zigachev
si_populate_mvdd_value(struct amdgpu_device * adev,u32 mclk,SISLANDS_SMC_VOLTAGE_VALUE * voltage)4592b843c749SSergey Zigachev static int si_populate_mvdd_value(struct amdgpu_device *adev, u32 mclk,
4593b843c749SSergey Zigachev SISLANDS_SMC_VOLTAGE_VALUE *voltage)
4594b843c749SSergey Zigachev {
4595b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4596b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4597b843c749SSergey Zigachev
4598b843c749SSergey Zigachev if (pi->mvdd_control) {
4599b843c749SSergey Zigachev if (mclk <= pi->mvdd_split_frequency)
4600b843c749SSergey Zigachev voltage->index = 0;
4601b843c749SSergey Zigachev else
4602b843c749SSergey Zigachev voltage->index = (u8)(si_pi->mvdd_voltage_table.count) - 1;
4603b843c749SSergey Zigachev
4604b843c749SSergey Zigachev voltage->value = cpu_to_be16(si_pi->mvdd_voltage_table.entries[voltage->index].value);
4605b843c749SSergey Zigachev }
4606b843c749SSergey Zigachev return 0;
4607b843c749SSergey Zigachev }
4608b843c749SSergey Zigachev
si_get_std_voltage_value(struct amdgpu_device * adev,SISLANDS_SMC_VOLTAGE_VALUE * voltage,u16 * std_voltage)4609b843c749SSergey Zigachev static int si_get_std_voltage_value(struct amdgpu_device *adev,
4610b843c749SSergey Zigachev SISLANDS_SMC_VOLTAGE_VALUE *voltage,
4611b843c749SSergey Zigachev u16 *std_voltage)
4612b843c749SSergey Zigachev {
4613b843c749SSergey Zigachev u16 v_index;
4614b843c749SSergey Zigachev bool voltage_found = false;
4615b843c749SSergey Zigachev *std_voltage = be16_to_cpu(voltage->value);
4616b843c749SSergey Zigachev
4617b843c749SSergey Zigachev if (adev->pm.dpm.dyn_state.cac_leakage_table.entries) {
4618b843c749SSergey Zigachev if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_NEW_CAC_VOLTAGE) {
4619b843c749SSergey Zigachev if (adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries == NULL)
4620b843c749SSergey Zigachev return -EINVAL;
4621b843c749SSergey Zigachev
4622b843c749SSergey Zigachev for (v_index = 0; (u32)v_index < adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) {
4623b843c749SSergey Zigachev if (be16_to_cpu(voltage->value) ==
4624b843c749SSergey Zigachev (u16)adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) {
4625b843c749SSergey Zigachev voltage_found = true;
4626b843c749SSergey Zigachev if ((u32)v_index < adev->pm.dpm.dyn_state.cac_leakage_table.count)
4627b843c749SSergey Zigachev *std_voltage =
4628b843c749SSergey Zigachev adev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc;
4629b843c749SSergey Zigachev else
4630b843c749SSergey Zigachev *std_voltage =
4631b843c749SSergey Zigachev adev->pm.dpm.dyn_state.cac_leakage_table.entries[adev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc;
4632b843c749SSergey Zigachev break;
4633b843c749SSergey Zigachev }
4634b843c749SSergey Zigachev }
4635b843c749SSergey Zigachev
4636b843c749SSergey Zigachev if (!voltage_found) {
4637b843c749SSergey Zigachev for (v_index = 0; (u32)v_index < adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.count; v_index++) {
4638b843c749SSergey Zigachev if (be16_to_cpu(voltage->value) <=
4639b843c749SSergey Zigachev (u16)adev->pm.dpm.dyn_state.vddc_dependency_on_sclk.entries[v_index].v) {
4640b843c749SSergey Zigachev voltage_found = true;
4641b843c749SSergey Zigachev if ((u32)v_index < adev->pm.dpm.dyn_state.cac_leakage_table.count)
4642b843c749SSergey Zigachev *std_voltage =
4643b843c749SSergey Zigachev adev->pm.dpm.dyn_state.cac_leakage_table.entries[v_index].vddc;
4644b843c749SSergey Zigachev else
4645b843c749SSergey Zigachev *std_voltage =
4646b843c749SSergey Zigachev adev->pm.dpm.dyn_state.cac_leakage_table.entries[adev->pm.dpm.dyn_state.cac_leakage_table.count-1].vddc;
4647b843c749SSergey Zigachev break;
4648b843c749SSergey Zigachev }
4649b843c749SSergey Zigachev }
4650b843c749SSergey Zigachev }
4651b843c749SSergey Zigachev } else {
4652b843c749SSergey Zigachev if ((u32)voltage->index < adev->pm.dpm.dyn_state.cac_leakage_table.count)
4653b843c749SSergey Zigachev *std_voltage = adev->pm.dpm.dyn_state.cac_leakage_table.entries[voltage->index].vddc;
4654b843c749SSergey Zigachev }
4655b843c749SSergey Zigachev }
4656b843c749SSergey Zigachev
4657b843c749SSergey Zigachev return 0;
4658b843c749SSergey Zigachev }
4659b843c749SSergey Zigachev
si_populate_std_voltage_value(struct amdgpu_device * adev,u16 value,u8 index,SISLANDS_SMC_VOLTAGE_VALUE * voltage)4660b843c749SSergey Zigachev static int si_populate_std_voltage_value(struct amdgpu_device *adev,
4661b843c749SSergey Zigachev u16 value, u8 index,
4662b843c749SSergey Zigachev SISLANDS_SMC_VOLTAGE_VALUE *voltage)
4663b843c749SSergey Zigachev {
4664b843c749SSergey Zigachev voltage->index = index;
4665b843c749SSergey Zigachev voltage->value = cpu_to_be16(value);
4666b843c749SSergey Zigachev
4667b843c749SSergey Zigachev return 0;
4668b843c749SSergey Zigachev }
4669b843c749SSergey Zigachev
si_populate_phase_shedding_value(struct amdgpu_device * adev,const struct amdgpu_phase_shedding_limits_table * limits,u16 voltage,u32 sclk,u32 mclk,SISLANDS_SMC_VOLTAGE_VALUE * smc_voltage)4670b843c749SSergey Zigachev static int si_populate_phase_shedding_value(struct amdgpu_device *adev,
4671b843c749SSergey Zigachev const struct amdgpu_phase_shedding_limits_table *limits,
4672b843c749SSergey Zigachev u16 voltage, u32 sclk, u32 mclk,
4673b843c749SSergey Zigachev SISLANDS_SMC_VOLTAGE_VALUE *smc_voltage)
4674b843c749SSergey Zigachev {
4675b843c749SSergey Zigachev unsigned int i;
4676b843c749SSergey Zigachev
4677b843c749SSergey Zigachev for (i = 0; i < limits->count; i++) {
4678b843c749SSergey Zigachev if ((voltage <= limits->entries[i].voltage) &&
4679b843c749SSergey Zigachev (sclk <= limits->entries[i].sclk) &&
4680b843c749SSergey Zigachev (mclk <= limits->entries[i].mclk))
4681b843c749SSergey Zigachev break;
4682b843c749SSergey Zigachev }
4683b843c749SSergey Zigachev
4684b843c749SSergey Zigachev smc_voltage->phase_settings = (u8)i;
4685b843c749SSergey Zigachev
4686b843c749SSergey Zigachev return 0;
4687b843c749SSergey Zigachev }
4688b843c749SSergey Zigachev
si_init_arb_table_index(struct amdgpu_device * adev)4689b843c749SSergey Zigachev static int si_init_arb_table_index(struct amdgpu_device *adev)
4690b843c749SSergey Zigachev {
4691b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4692b843c749SSergey Zigachev u32 tmp;
4693b843c749SSergey Zigachev int ret;
4694b843c749SSergey Zigachev
4695b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev, si_pi->arb_table_start,
4696b843c749SSergey Zigachev &tmp, si_pi->sram_end);
4697b843c749SSergey Zigachev if (ret)
4698b843c749SSergey Zigachev return ret;
4699b843c749SSergey Zigachev
4700b843c749SSergey Zigachev tmp &= 0x00FFFFFF;
4701b843c749SSergey Zigachev tmp |= MC_CG_ARB_FREQ_F1 << 24;
4702b843c749SSergey Zigachev
4703b843c749SSergey Zigachev return amdgpu_si_write_smc_sram_dword(adev, si_pi->arb_table_start,
4704b843c749SSergey Zigachev tmp, si_pi->sram_end);
4705b843c749SSergey Zigachev }
4706b843c749SSergey Zigachev
si_initial_switch_from_arb_f0_to_f1(struct amdgpu_device * adev)4707b843c749SSergey Zigachev static int si_initial_switch_from_arb_f0_to_f1(struct amdgpu_device *adev)
4708b843c749SSergey Zigachev {
4709b843c749SSergey Zigachev return ni_copy_and_switch_arb_sets(adev, MC_CG_ARB_FREQ_F0, MC_CG_ARB_FREQ_F1);
4710b843c749SSergey Zigachev }
4711b843c749SSergey Zigachev
si_reset_to_default(struct amdgpu_device * adev)4712b843c749SSergey Zigachev static int si_reset_to_default(struct amdgpu_device *adev)
4713b843c749SSergey Zigachev {
4714b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_ResetToDefaults) == PPSMC_Result_OK) ?
4715b843c749SSergey Zigachev 0 : -EINVAL;
4716b843c749SSergey Zigachev }
4717b843c749SSergey Zigachev
si_force_switch_to_arb_f0(struct amdgpu_device * adev)4718b843c749SSergey Zigachev static int si_force_switch_to_arb_f0(struct amdgpu_device *adev)
4719b843c749SSergey Zigachev {
4720b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4721b843c749SSergey Zigachev u32 tmp;
4722b843c749SSergey Zigachev int ret;
4723b843c749SSergey Zigachev
4724b843c749SSergey Zigachev ret = amdgpu_si_read_smc_sram_dword(adev, si_pi->arb_table_start,
4725b843c749SSergey Zigachev &tmp, si_pi->sram_end);
4726b843c749SSergey Zigachev if (ret)
4727b843c749SSergey Zigachev return ret;
4728b843c749SSergey Zigachev
4729b843c749SSergey Zigachev tmp = (tmp >> 24) & 0xff;
4730b843c749SSergey Zigachev
4731b843c749SSergey Zigachev if (tmp == MC_CG_ARB_FREQ_F0)
4732b843c749SSergey Zigachev return 0;
4733b843c749SSergey Zigachev
4734b843c749SSergey Zigachev return ni_copy_and_switch_arb_sets(adev, tmp, MC_CG_ARB_FREQ_F0);
4735b843c749SSergey Zigachev }
4736b843c749SSergey Zigachev
si_calculate_memory_refresh_rate(struct amdgpu_device * adev,u32 engine_clock)4737b843c749SSergey Zigachev static u32 si_calculate_memory_refresh_rate(struct amdgpu_device *adev,
4738b843c749SSergey Zigachev u32 engine_clock)
4739b843c749SSergey Zigachev {
4740b843c749SSergey Zigachev u32 dram_rows;
4741b843c749SSergey Zigachev u32 dram_refresh_rate;
4742b843c749SSergey Zigachev u32 mc_arb_rfsh_rate;
4743b843c749SSergey Zigachev u32 tmp = (RREG32(MC_ARB_RAMCFG) & NOOFROWS_MASK) >> NOOFROWS_SHIFT;
4744b843c749SSergey Zigachev
4745b843c749SSergey Zigachev if (tmp >= 4)
4746b843c749SSergey Zigachev dram_rows = 16384;
4747b843c749SSergey Zigachev else
4748b843c749SSergey Zigachev dram_rows = 1 << (tmp + 10);
4749b843c749SSergey Zigachev
4750b843c749SSergey Zigachev dram_refresh_rate = 1 << ((RREG32(MC_SEQ_MISC0) & 0x3) + 3);
4751b843c749SSergey Zigachev mc_arb_rfsh_rate = ((engine_clock * 10) * dram_refresh_rate / dram_rows - 32) / 64;
4752b843c749SSergey Zigachev
4753b843c749SSergey Zigachev return mc_arb_rfsh_rate;
4754b843c749SSergey Zigachev }
4755b843c749SSergey Zigachev
si_populate_memory_timing_parameters(struct amdgpu_device * adev,struct rv7xx_pl * pl,SMC_SIslands_MCArbDramTimingRegisterSet * arb_regs)4756b843c749SSergey Zigachev static int si_populate_memory_timing_parameters(struct amdgpu_device *adev,
4757b843c749SSergey Zigachev struct rv7xx_pl *pl,
4758b843c749SSergey Zigachev SMC_SIslands_MCArbDramTimingRegisterSet *arb_regs)
4759b843c749SSergey Zigachev {
4760b843c749SSergey Zigachev u32 dram_timing;
4761b843c749SSergey Zigachev u32 dram_timing2;
4762b843c749SSergey Zigachev u32 burst_time;
4763b843c749SSergey Zigachev
4764b843c749SSergey Zigachev arb_regs->mc_arb_rfsh_rate =
4765b843c749SSergey Zigachev (u8)si_calculate_memory_refresh_rate(adev, pl->sclk);
4766b843c749SSergey Zigachev
4767b843c749SSergey Zigachev amdgpu_atombios_set_engine_dram_timings(adev,
4768b843c749SSergey Zigachev pl->sclk,
4769b843c749SSergey Zigachev pl->mclk);
4770b843c749SSergey Zigachev
4771b843c749SSergey Zigachev dram_timing = RREG32(MC_ARB_DRAM_TIMING);
4772b843c749SSergey Zigachev dram_timing2 = RREG32(MC_ARB_DRAM_TIMING2);
4773b843c749SSergey Zigachev burst_time = RREG32(MC_ARB_BURST_TIME) & STATE0_MASK;
4774b843c749SSergey Zigachev
4775b843c749SSergey Zigachev arb_regs->mc_arb_dram_timing = cpu_to_be32(dram_timing);
4776b843c749SSergey Zigachev arb_regs->mc_arb_dram_timing2 = cpu_to_be32(dram_timing2);
4777b843c749SSergey Zigachev arb_regs->mc_arb_burst_time = (u8)burst_time;
4778b843c749SSergey Zigachev
4779b843c749SSergey Zigachev return 0;
4780b843c749SSergey Zigachev }
4781b843c749SSergey Zigachev
si_do_program_memory_timing_parameters(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state,unsigned int first_arb_set)4782b843c749SSergey Zigachev static int si_do_program_memory_timing_parameters(struct amdgpu_device *adev,
4783b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state,
4784b843c749SSergey Zigachev unsigned int first_arb_set)
4785b843c749SSergey Zigachev {
4786b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4787b843c749SSergey Zigachev struct si_ps *state = si_get_ps(amdgpu_state);
4788b843c749SSergey Zigachev SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 };
4789b843c749SSergey Zigachev int i, ret = 0;
4790b843c749SSergey Zigachev
4791b843c749SSergey Zigachev for (i = 0; i < state->performance_level_count; i++) {
4792b843c749SSergey Zigachev ret = si_populate_memory_timing_parameters(adev, &state->performance_levels[i], &arb_regs);
4793b843c749SSergey Zigachev if (ret)
4794b843c749SSergey Zigachev break;
4795b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev,
4796b843c749SSergey Zigachev si_pi->arb_table_start +
4797b843c749SSergey Zigachev offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) +
4798b843c749SSergey Zigachev sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * (first_arb_set + i),
4799b843c749SSergey Zigachev (u8 *)&arb_regs,
4800b843c749SSergey Zigachev sizeof(SMC_SIslands_MCArbDramTimingRegisterSet),
4801b843c749SSergey Zigachev si_pi->sram_end);
4802b843c749SSergey Zigachev if (ret)
4803b843c749SSergey Zigachev break;
4804b843c749SSergey Zigachev }
4805b843c749SSergey Zigachev
4806b843c749SSergey Zigachev return ret;
4807b843c749SSergey Zigachev }
4808b843c749SSergey Zigachev
si_program_memory_timing_parameters(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state)4809b843c749SSergey Zigachev static int si_program_memory_timing_parameters(struct amdgpu_device *adev,
4810b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state)
4811b843c749SSergey Zigachev {
4812b843c749SSergey Zigachev return si_do_program_memory_timing_parameters(adev, amdgpu_new_state,
4813b843c749SSergey Zigachev SISLANDS_DRIVER_STATE_ARB_INDEX);
4814b843c749SSergey Zigachev }
4815b843c749SSergey Zigachev
si_populate_initial_mvdd_value(struct amdgpu_device * adev,struct SISLANDS_SMC_VOLTAGE_VALUE * voltage)4816b843c749SSergey Zigachev static int si_populate_initial_mvdd_value(struct amdgpu_device *adev,
4817b843c749SSergey Zigachev struct SISLANDS_SMC_VOLTAGE_VALUE *voltage)
4818b843c749SSergey Zigachev {
4819b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4820b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4821b843c749SSergey Zigachev
4822b843c749SSergey Zigachev if (pi->mvdd_control)
4823b843c749SSergey Zigachev return si_populate_voltage_value(adev, &si_pi->mvdd_voltage_table,
4824b843c749SSergey Zigachev si_pi->mvdd_bootup_value, voltage);
4825b843c749SSergey Zigachev
4826b843c749SSergey Zigachev return 0;
4827b843c749SSergey Zigachev }
4828b843c749SSergey Zigachev
si_populate_smc_initial_state(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_initial_state,SISLANDS_SMC_STATETABLE * table)4829b843c749SSergey Zigachev static int si_populate_smc_initial_state(struct amdgpu_device *adev,
4830b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_initial_state,
4831b843c749SSergey Zigachev SISLANDS_SMC_STATETABLE *table)
4832b843c749SSergey Zigachev {
4833b843c749SSergey Zigachev struct si_ps *initial_state = si_get_ps(amdgpu_initial_state);
4834b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4835b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4836b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4837b843c749SSergey Zigachev u32 reg;
4838b843c749SSergey Zigachev int ret;
4839b843c749SSergey Zigachev
4840b843c749SSergey Zigachev table->initialState.levels[0].mclk.vDLL_CNTL =
4841b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.dll_cntl);
4842b843c749SSergey Zigachev table->initialState.levels[0].mclk.vMCLK_PWRMGT_CNTL =
4843b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mclk_pwrmgt_cntl);
4844b843c749SSergey Zigachev table->initialState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
4845b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_ad_func_cntl);
4846b843c749SSergey Zigachev table->initialState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL =
4847b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_dq_func_cntl);
4848b843c749SSergey Zigachev table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL =
4849b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_func_cntl);
4850b843c749SSergey Zigachev table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_1 =
4851b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_1);
4852b843c749SSergey Zigachev table->initialState.levels[0].mclk.vMPLL_FUNC_CNTL_2 =
4853b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_func_cntl_2);
4854b843c749SSergey Zigachev table->initialState.levels[0].mclk.vMPLL_SS =
4855b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_ss1);
4856b843c749SSergey Zigachev table->initialState.levels[0].mclk.vMPLL_SS2 =
4857b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_ss2);
4858b843c749SSergey Zigachev
4859b843c749SSergey Zigachev table->initialState.levels[0].mclk.mclk_value =
4860b843c749SSergey Zigachev cpu_to_be32(initial_state->performance_levels[0].mclk);
4861b843c749SSergey Zigachev
4862b843c749SSergey Zigachev table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL =
4863b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl);
4864b843c749SSergey Zigachev table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 =
4865b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_2);
4866b843c749SSergey Zigachev table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 =
4867b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_3);
4868b843c749SSergey Zigachev table->initialState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 =
4869b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.cg_spll_func_cntl_4);
4870b843c749SSergey Zigachev table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM =
4871b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum);
4872b843c749SSergey Zigachev table->initialState.levels[0].sclk.vCG_SPLL_SPREAD_SPECTRUM_2 =
4873b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.cg_spll_spread_spectrum_2);
4874b843c749SSergey Zigachev
4875b843c749SSergey Zigachev table->initialState.levels[0].sclk.sclk_value =
4876b843c749SSergey Zigachev cpu_to_be32(initial_state->performance_levels[0].sclk);
4877b843c749SSergey Zigachev
4878b843c749SSergey Zigachev table->initialState.levels[0].arbRefreshState =
4879b843c749SSergey Zigachev SISLANDS_INITIAL_STATE_ARB_INDEX;
4880b843c749SSergey Zigachev
4881b843c749SSergey Zigachev table->initialState.levels[0].ACIndex = 0;
4882b843c749SSergey Zigachev
4883b843c749SSergey Zigachev ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
4884b843c749SSergey Zigachev initial_state->performance_levels[0].vddc,
4885b843c749SSergey Zigachev &table->initialState.levels[0].vddc);
4886b843c749SSergey Zigachev
4887b843c749SSergey Zigachev if (!ret) {
4888b843c749SSergey Zigachev u16 std_vddc;
4889b843c749SSergey Zigachev
4890b843c749SSergey Zigachev ret = si_get_std_voltage_value(adev,
4891b843c749SSergey Zigachev &table->initialState.levels[0].vddc,
4892b843c749SSergey Zigachev &std_vddc);
4893b843c749SSergey Zigachev if (!ret)
4894b843c749SSergey Zigachev si_populate_std_voltage_value(adev, std_vddc,
4895b843c749SSergey Zigachev table->initialState.levels[0].vddc.index,
4896b843c749SSergey Zigachev &table->initialState.levels[0].std_vddc);
4897b843c749SSergey Zigachev }
4898b843c749SSergey Zigachev
4899b843c749SSergey Zigachev if (eg_pi->vddci_control)
4900b843c749SSergey Zigachev si_populate_voltage_value(adev,
4901b843c749SSergey Zigachev &eg_pi->vddci_voltage_table,
4902b843c749SSergey Zigachev initial_state->performance_levels[0].vddci,
4903b843c749SSergey Zigachev &table->initialState.levels[0].vddci);
4904b843c749SSergey Zigachev
4905b843c749SSergey Zigachev if (si_pi->vddc_phase_shed_control)
4906b843c749SSergey Zigachev si_populate_phase_shedding_value(adev,
4907b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.phase_shedding_limits_table,
4908b843c749SSergey Zigachev initial_state->performance_levels[0].vddc,
4909b843c749SSergey Zigachev initial_state->performance_levels[0].sclk,
4910b843c749SSergey Zigachev initial_state->performance_levels[0].mclk,
4911b843c749SSergey Zigachev &table->initialState.levels[0].vddc);
4912b843c749SSergey Zigachev
4913b843c749SSergey Zigachev si_populate_initial_mvdd_value(adev, &table->initialState.levels[0].mvdd);
4914b843c749SSergey Zigachev
4915b843c749SSergey Zigachev reg = CG_R(0xffff) | CG_L(0);
4916b843c749SSergey Zigachev table->initialState.levels[0].aT = cpu_to_be32(reg);
4917b843c749SSergey Zigachev table->initialState.levels[0].bSP = cpu_to_be32(pi->dsp);
4918b843c749SSergey Zigachev table->initialState.levels[0].gen2PCIE = (u8)si_pi->boot_pcie_gen;
4919b843c749SSergey Zigachev
4920b843c749SSergey Zigachev if (adev->gmc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) {
4921b843c749SSergey Zigachev table->initialState.levels[0].strobeMode =
4922b843c749SSergey Zigachev si_get_strobe_mode_settings(adev,
4923b843c749SSergey Zigachev initial_state->performance_levels[0].mclk);
4924b843c749SSergey Zigachev
4925b843c749SSergey Zigachev if (initial_state->performance_levels[0].mclk > pi->mclk_edc_enable_threshold)
4926b843c749SSergey Zigachev table->initialState.levels[0].mcFlags = SISLANDS_SMC_MC_EDC_RD_FLAG | SISLANDS_SMC_MC_EDC_WR_FLAG;
4927b843c749SSergey Zigachev else
4928b843c749SSergey Zigachev table->initialState.levels[0].mcFlags = 0;
4929b843c749SSergey Zigachev }
4930b843c749SSergey Zigachev
4931b843c749SSergey Zigachev table->initialState.levelCount = 1;
4932b843c749SSergey Zigachev
4933b843c749SSergey Zigachev table->initialState.flags |= PPSMC_SWSTATE_FLAG_DC;
4934b843c749SSergey Zigachev
4935b843c749SSergey Zigachev table->initialState.levels[0].dpm2.MaxPS = 0;
4936b843c749SSergey Zigachev table->initialState.levels[0].dpm2.NearTDPDec = 0;
4937b843c749SSergey Zigachev table->initialState.levels[0].dpm2.AboveSafeInc = 0;
4938b843c749SSergey Zigachev table->initialState.levels[0].dpm2.BelowSafeInc = 0;
4939b843c749SSergey Zigachev table->initialState.levels[0].dpm2.PwrEfficiencyRatio = 0;
4940b843c749SSergey Zigachev
4941b843c749SSergey Zigachev reg = MIN_POWER_MASK | MAX_POWER_MASK;
4942b843c749SSergey Zigachev table->initialState.levels[0].SQPowerThrottle = cpu_to_be32(reg);
4943b843c749SSergey Zigachev
4944b843c749SSergey Zigachev reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
4945b843c749SSergey Zigachev table->initialState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg);
4946b843c749SSergey Zigachev
4947b843c749SSergey Zigachev return 0;
4948b843c749SSergey Zigachev }
4949b843c749SSergey Zigachev
si_populate_smc_acpi_state(struct amdgpu_device * adev,SISLANDS_SMC_STATETABLE * table)4950b843c749SSergey Zigachev static int si_populate_smc_acpi_state(struct amdgpu_device *adev,
4951b843c749SSergey Zigachev SISLANDS_SMC_STATETABLE *table)
4952b843c749SSergey Zigachev {
4953b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
4954b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
4955b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
4956b843c749SSergey Zigachev u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl;
4957b843c749SSergey Zigachev u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2;
4958b843c749SSergey Zigachev u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3;
4959b843c749SSergey Zigachev u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4;
4960b843c749SSergey Zigachev u32 dll_cntl = si_pi->clock_registers.dll_cntl;
4961b843c749SSergey Zigachev u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl;
4962b843c749SSergey Zigachev u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl;
4963b843c749SSergey Zigachev u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl;
4964b843c749SSergey Zigachev u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl;
4965b843c749SSergey Zigachev u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1;
4966b843c749SSergey Zigachev u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2;
4967b843c749SSergey Zigachev u32 reg;
4968b843c749SSergey Zigachev int ret;
4969b843c749SSergey Zigachev
4970b843c749SSergey Zigachev table->ACPIState = table->initialState;
4971b843c749SSergey Zigachev
4972b843c749SSergey Zigachev table->ACPIState.flags &= ~PPSMC_SWSTATE_FLAG_DC;
4973b843c749SSergey Zigachev
4974b843c749SSergey Zigachev if (pi->acpi_vddc) {
4975b843c749SSergey Zigachev ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
4976b843c749SSergey Zigachev pi->acpi_vddc, &table->ACPIState.levels[0].vddc);
4977b843c749SSergey Zigachev if (!ret) {
4978b843c749SSergey Zigachev u16 std_vddc;
4979b843c749SSergey Zigachev
4980b843c749SSergey Zigachev ret = si_get_std_voltage_value(adev,
4981b843c749SSergey Zigachev &table->ACPIState.levels[0].vddc, &std_vddc);
4982b843c749SSergey Zigachev if (!ret)
4983b843c749SSergey Zigachev si_populate_std_voltage_value(adev, std_vddc,
4984b843c749SSergey Zigachev table->ACPIState.levels[0].vddc.index,
4985b843c749SSergey Zigachev &table->ACPIState.levels[0].std_vddc);
4986b843c749SSergey Zigachev }
4987b843c749SSergey Zigachev table->ACPIState.levels[0].gen2PCIE = si_pi->acpi_pcie_gen;
4988b843c749SSergey Zigachev
4989b843c749SSergey Zigachev if (si_pi->vddc_phase_shed_control) {
4990b843c749SSergey Zigachev si_populate_phase_shedding_value(adev,
4991b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.phase_shedding_limits_table,
4992b843c749SSergey Zigachev pi->acpi_vddc,
4993b843c749SSergey Zigachev 0,
4994b843c749SSergey Zigachev 0,
4995b843c749SSergey Zigachev &table->ACPIState.levels[0].vddc);
4996b843c749SSergey Zigachev }
4997b843c749SSergey Zigachev } else {
4998b843c749SSergey Zigachev ret = si_populate_voltage_value(adev, &eg_pi->vddc_voltage_table,
4999b843c749SSergey Zigachev pi->min_vddc_in_table, &table->ACPIState.levels[0].vddc);
5000b843c749SSergey Zigachev if (!ret) {
5001b843c749SSergey Zigachev u16 std_vddc;
5002b843c749SSergey Zigachev
5003b843c749SSergey Zigachev ret = si_get_std_voltage_value(adev,
5004b843c749SSergey Zigachev &table->ACPIState.levels[0].vddc, &std_vddc);
5005b843c749SSergey Zigachev
5006b843c749SSergey Zigachev if (!ret)
5007b843c749SSergey Zigachev si_populate_std_voltage_value(adev, std_vddc,
5008b843c749SSergey Zigachev table->ACPIState.levels[0].vddc.index,
5009b843c749SSergey Zigachev &table->ACPIState.levels[0].std_vddc);
5010b843c749SSergey Zigachev }
5011b843c749SSergey Zigachev table->ACPIState.levels[0].gen2PCIE =
5012b843c749SSergey Zigachev (u8)amdgpu_get_pcie_gen_support(adev,
5013b843c749SSergey Zigachev si_pi->sys_pcie_mask,
5014b843c749SSergey Zigachev si_pi->boot_pcie_gen,
5015b843c749SSergey Zigachev AMDGPU_PCIE_GEN1);
5016b843c749SSergey Zigachev
5017b843c749SSergey Zigachev if (si_pi->vddc_phase_shed_control)
5018b843c749SSergey Zigachev si_populate_phase_shedding_value(adev,
5019b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.phase_shedding_limits_table,
5020b843c749SSergey Zigachev pi->min_vddc_in_table,
5021b843c749SSergey Zigachev 0,
5022b843c749SSergey Zigachev 0,
5023b843c749SSergey Zigachev &table->ACPIState.levels[0].vddc);
5024b843c749SSergey Zigachev }
5025b843c749SSergey Zigachev
5026b843c749SSergey Zigachev if (pi->acpi_vddc) {
5027b843c749SSergey Zigachev if (eg_pi->acpi_vddci)
5028b843c749SSergey Zigachev si_populate_voltage_value(adev, &eg_pi->vddci_voltage_table,
5029b843c749SSergey Zigachev eg_pi->acpi_vddci,
5030b843c749SSergey Zigachev &table->ACPIState.levels[0].vddci);
5031b843c749SSergey Zigachev }
5032b843c749SSergey Zigachev
5033b843c749SSergey Zigachev mclk_pwrmgt_cntl |= MRDCK0_RESET | MRDCK1_RESET;
5034b843c749SSergey Zigachev mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB);
5035b843c749SSergey Zigachev
5036b843c749SSergey Zigachev dll_cntl &= ~(MRDCK0_BYPASS | MRDCK1_BYPASS);
5037b843c749SSergey Zigachev
5038b843c749SSergey Zigachev spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK;
5039b843c749SSergey Zigachev spll_func_cntl_2 |= SCLK_MUX_SEL(4);
5040b843c749SSergey Zigachev
5041b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vDLL_CNTL =
5042b843c749SSergey Zigachev cpu_to_be32(dll_cntl);
5043b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vMCLK_PWRMGT_CNTL =
5044b843c749SSergey Zigachev cpu_to_be32(mclk_pwrmgt_cntl);
5045b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vMPLL_AD_FUNC_CNTL =
5046b843c749SSergey Zigachev cpu_to_be32(mpll_ad_func_cntl);
5047b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vMPLL_DQ_FUNC_CNTL =
5048b843c749SSergey Zigachev cpu_to_be32(mpll_dq_func_cntl);
5049b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL =
5050b843c749SSergey Zigachev cpu_to_be32(mpll_func_cntl);
5051b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_1 =
5052b843c749SSergey Zigachev cpu_to_be32(mpll_func_cntl_1);
5053b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vMPLL_FUNC_CNTL_2 =
5054b843c749SSergey Zigachev cpu_to_be32(mpll_func_cntl_2);
5055b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vMPLL_SS =
5056b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_ss1);
5057b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.vMPLL_SS2 =
5058b843c749SSergey Zigachev cpu_to_be32(si_pi->clock_registers.mpll_ss2);
5059b843c749SSergey Zigachev
5060b843c749SSergey Zigachev table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL =
5061b843c749SSergey Zigachev cpu_to_be32(spll_func_cntl);
5062b843c749SSergey Zigachev table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_2 =
5063b843c749SSergey Zigachev cpu_to_be32(spll_func_cntl_2);
5064b843c749SSergey Zigachev table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_3 =
5065b843c749SSergey Zigachev cpu_to_be32(spll_func_cntl_3);
5066b843c749SSergey Zigachev table->ACPIState.levels[0].sclk.vCG_SPLL_FUNC_CNTL_4 =
5067b843c749SSergey Zigachev cpu_to_be32(spll_func_cntl_4);
5068b843c749SSergey Zigachev
5069b843c749SSergey Zigachev table->ACPIState.levels[0].mclk.mclk_value = 0;
5070b843c749SSergey Zigachev table->ACPIState.levels[0].sclk.sclk_value = 0;
5071b843c749SSergey Zigachev
5072b843c749SSergey Zigachev si_populate_mvdd_value(adev, 0, &table->ACPIState.levels[0].mvdd);
5073b843c749SSergey Zigachev
5074b843c749SSergey Zigachev if (eg_pi->dynamic_ac_timing)
5075b843c749SSergey Zigachev table->ACPIState.levels[0].ACIndex = 0;
5076b843c749SSergey Zigachev
5077b843c749SSergey Zigachev table->ACPIState.levels[0].dpm2.MaxPS = 0;
5078b843c749SSergey Zigachev table->ACPIState.levels[0].dpm2.NearTDPDec = 0;
5079b843c749SSergey Zigachev table->ACPIState.levels[0].dpm2.AboveSafeInc = 0;
5080b843c749SSergey Zigachev table->ACPIState.levels[0].dpm2.BelowSafeInc = 0;
5081b843c749SSergey Zigachev table->ACPIState.levels[0].dpm2.PwrEfficiencyRatio = 0;
5082b843c749SSergey Zigachev
5083b843c749SSergey Zigachev reg = MIN_POWER_MASK | MAX_POWER_MASK;
5084b843c749SSergey Zigachev table->ACPIState.levels[0].SQPowerThrottle = cpu_to_be32(reg);
5085b843c749SSergey Zigachev
5086b843c749SSergey Zigachev reg = MAX_POWER_DELTA_MASK | STI_SIZE_MASK | LTI_RATIO_MASK;
5087b843c749SSergey Zigachev table->ACPIState.levels[0].SQPowerThrottle_2 = cpu_to_be32(reg);
5088b843c749SSergey Zigachev
5089b843c749SSergey Zigachev return 0;
5090b843c749SSergey Zigachev }
5091b843c749SSergey Zigachev
si_populate_ulv_state(struct amdgpu_device * adev,SISLANDS_SMC_SWSTATE * state)5092b843c749SSergey Zigachev static int si_populate_ulv_state(struct amdgpu_device *adev,
5093b843c749SSergey Zigachev SISLANDS_SMC_SWSTATE *state)
5094b843c749SSergey Zigachev {
5095b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
5096b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5097b843c749SSergey Zigachev struct si_ulv_param *ulv = &si_pi->ulv;
5098b843c749SSergey Zigachev u32 sclk_in_sr = 1350; /* ??? */
5099b843c749SSergey Zigachev int ret;
5100b843c749SSergey Zigachev
5101b843c749SSergey Zigachev ret = si_convert_power_level_to_smc(adev, &ulv->pl,
5102b843c749SSergey Zigachev &state->levels[0]);
5103b843c749SSergey Zigachev if (!ret) {
5104b843c749SSergey Zigachev if (eg_pi->sclk_deep_sleep) {
5105b843c749SSergey Zigachev if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ)
5106b843c749SSergey Zigachev state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS;
5107b843c749SSergey Zigachev else
5108b843c749SSergey Zigachev state->levels[0].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE;
5109b843c749SSergey Zigachev }
5110b843c749SSergey Zigachev if (ulv->one_pcie_lane_in_ulv)
5111b843c749SSergey Zigachev state->flags |= PPSMC_SWSTATE_FLAG_PCIE_X1;
5112b843c749SSergey Zigachev state->levels[0].arbRefreshState = (u8)(SISLANDS_ULV_STATE_ARB_INDEX);
5113b843c749SSergey Zigachev state->levels[0].ACIndex = 1;
5114b843c749SSergey Zigachev state->levels[0].std_vddc = state->levels[0].vddc;
5115b843c749SSergey Zigachev state->levelCount = 1;
5116b843c749SSergey Zigachev
5117b843c749SSergey Zigachev state->flags |= PPSMC_SWSTATE_FLAG_DC;
5118b843c749SSergey Zigachev }
5119b843c749SSergey Zigachev
5120b843c749SSergey Zigachev return ret;
5121b843c749SSergey Zigachev }
5122b843c749SSergey Zigachev
si_program_ulv_memory_timing_parameters(struct amdgpu_device * adev)5123b843c749SSergey Zigachev static int si_program_ulv_memory_timing_parameters(struct amdgpu_device *adev)
5124b843c749SSergey Zigachev {
5125b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5126b843c749SSergey Zigachev struct si_ulv_param *ulv = &si_pi->ulv;
5127b843c749SSergey Zigachev SMC_SIslands_MCArbDramTimingRegisterSet arb_regs = { 0 };
5128b843c749SSergey Zigachev int ret;
5129b843c749SSergey Zigachev
5130b843c749SSergey Zigachev ret = si_populate_memory_timing_parameters(adev, &ulv->pl,
5131b843c749SSergey Zigachev &arb_regs);
5132b843c749SSergey Zigachev if (ret)
5133b843c749SSergey Zigachev return ret;
5134b843c749SSergey Zigachev
5135b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_ulv_volt_change_delay,
5136b843c749SSergey Zigachev ulv->volt_change_delay);
5137b843c749SSergey Zigachev
5138b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev,
5139b843c749SSergey Zigachev si_pi->arb_table_start +
5140b843c749SSergey Zigachev offsetof(SMC_SIslands_MCArbDramTimingRegisters, data) +
5141b843c749SSergey Zigachev sizeof(SMC_SIslands_MCArbDramTimingRegisterSet) * SISLANDS_ULV_STATE_ARB_INDEX,
5142b843c749SSergey Zigachev (u8 *)&arb_regs,
5143b843c749SSergey Zigachev sizeof(SMC_SIslands_MCArbDramTimingRegisterSet),
5144b843c749SSergey Zigachev si_pi->sram_end);
5145b843c749SSergey Zigachev
5146b843c749SSergey Zigachev return ret;
5147b843c749SSergey Zigachev }
5148b843c749SSergey Zigachev
si_get_mvdd_configuration(struct amdgpu_device * adev)5149b843c749SSergey Zigachev static void si_get_mvdd_configuration(struct amdgpu_device *adev)
5150b843c749SSergey Zigachev {
5151b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
5152b843c749SSergey Zigachev
5153b843c749SSergey Zigachev pi->mvdd_split_frequency = 30000;
5154b843c749SSergey Zigachev }
5155b843c749SSergey Zigachev
si_init_smc_table(struct amdgpu_device * adev)5156b843c749SSergey Zigachev static int si_init_smc_table(struct amdgpu_device *adev)
5157b843c749SSergey Zigachev {
5158b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5159b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_boot_state = adev->pm.dpm.boot_ps;
5160b843c749SSergey Zigachev const struct si_ulv_param *ulv = &si_pi->ulv;
5161b843c749SSergey Zigachev SISLANDS_SMC_STATETABLE *table = &si_pi->smc_statetable;
5162b843c749SSergey Zigachev int ret;
5163b843c749SSergey Zigachev u32 lane_width;
5164b843c749SSergey Zigachev u32 vr_hot_gpio;
5165b843c749SSergey Zigachev
5166b843c749SSergey Zigachev si_populate_smc_voltage_tables(adev, table);
5167b843c749SSergey Zigachev
5168b843c749SSergey Zigachev switch (adev->pm.int_thermal_type) {
5169b843c749SSergey Zigachev case THERMAL_TYPE_SI:
5170b843c749SSergey Zigachev case THERMAL_TYPE_EMC2103_WITH_INTERNAL:
5171b843c749SSergey Zigachev table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_INTERNAL;
5172b843c749SSergey Zigachev break;
5173b843c749SSergey Zigachev case THERMAL_TYPE_NONE:
5174b843c749SSergey Zigachev table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_NONE;
5175b843c749SSergey Zigachev break;
5176b843c749SSergey Zigachev default:
5177b843c749SSergey Zigachev table->thermalProtectType = PPSMC_THERMAL_PROTECT_TYPE_EXTERNAL;
5178b843c749SSergey Zigachev break;
5179b843c749SSergey Zigachev }
5180b843c749SSergey Zigachev
5181b843c749SSergey Zigachev if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)
5182b843c749SSergey Zigachev table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC;
5183b843c749SSergey Zigachev
5184b843c749SSergey Zigachev if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT) {
5185b843c749SSergey Zigachev if ((adev->pdev->device != 0x6818) && (adev->pdev->device != 0x6819))
5186b843c749SSergey Zigachev table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT;
5187b843c749SSergey Zigachev }
5188b843c749SSergey Zigachev
5189b843c749SSergey Zigachev if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_STEPVDDC)
5190b843c749SSergey Zigachev table->systemFlags |= PPSMC_SYSTEMFLAG_STEPVDDC;
5191b843c749SSergey Zigachev
5192b843c749SSergey Zigachev if (adev->gmc.vram_type == AMDGPU_VRAM_TYPE_GDDR5)
5193b843c749SSergey Zigachev table->systemFlags |= PPSMC_SYSTEMFLAG_GDDR5;
5194b843c749SSergey Zigachev
5195b843c749SSergey Zigachev if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REVERT_GPIO5_POLARITY)
5196b843c749SSergey Zigachev table->extraFlags |= PPSMC_EXTRAFLAGS_AC2DC_GPIO5_POLARITY_HIGH;
5197b843c749SSergey Zigachev
5198b843c749SSergey Zigachev if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_VRHOT_GPIO_CONFIGURABLE) {
5199b843c749SSergey Zigachev table->systemFlags |= PPSMC_SYSTEMFLAG_REGULATOR_HOT_PROG_GPIO;
5200b843c749SSergey Zigachev vr_hot_gpio = adev->pm.dpm.backbias_response_time;
5201b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_vr_hot_gpio,
5202b843c749SSergey Zigachev vr_hot_gpio);
5203b843c749SSergey Zigachev }
5204b843c749SSergey Zigachev
5205b843c749SSergey Zigachev ret = si_populate_smc_initial_state(adev, amdgpu_boot_state, table);
5206b843c749SSergey Zigachev if (ret)
5207b843c749SSergey Zigachev return ret;
5208b843c749SSergey Zigachev
5209b843c749SSergey Zigachev ret = si_populate_smc_acpi_state(adev, table);
5210b843c749SSergey Zigachev if (ret)
5211b843c749SSergey Zigachev return ret;
5212b843c749SSergey Zigachev
5213b843c749SSergey Zigachev table->driverState = table->initialState;
5214b843c749SSergey Zigachev
5215b843c749SSergey Zigachev ret = si_do_program_memory_timing_parameters(adev, amdgpu_boot_state,
5216b843c749SSergey Zigachev SISLANDS_INITIAL_STATE_ARB_INDEX);
5217b843c749SSergey Zigachev if (ret)
5218b843c749SSergey Zigachev return ret;
5219b843c749SSergey Zigachev
5220b843c749SSergey Zigachev if (ulv->supported && ulv->pl.vddc) {
5221b843c749SSergey Zigachev ret = si_populate_ulv_state(adev, &table->ULVState);
5222b843c749SSergey Zigachev if (ret)
5223b843c749SSergey Zigachev return ret;
5224b843c749SSergey Zigachev
5225b843c749SSergey Zigachev ret = si_program_ulv_memory_timing_parameters(adev);
5226b843c749SSergey Zigachev if (ret)
5227b843c749SSergey Zigachev return ret;
5228b843c749SSergey Zigachev
5229b843c749SSergey Zigachev WREG32(CG_ULV_CONTROL, ulv->cg_ulv_control);
5230b843c749SSergey Zigachev WREG32(CG_ULV_PARAMETER, ulv->cg_ulv_parameter);
5231b843c749SSergey Zigachev
5232b843c749SSergey Zigachev lane_width = amdgpu_get_pcie_lanes(adev);
5233b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width);
5234b843c749SSergey Zigachev } else {
5235b843c749SSergey Zigachev table->ULVState = table->initialState;
5236b843c749SSergey Zigachev }
5237b843c749SSergey Zigachev
5238b843c749SSergey Zigachev return amdgpu_si_copy_bytes_to_smc(adev, si_pi->state_table_start,
5239b843c749SSergey Zigachev (u8 *)table, sizeof(SISLANDS_SMC_STATETABLE),
5240b843c749SSergey Zigachev si_pi->sram_end);
5241b843c749SSergey Zigachev }
5242b843c749SSergey Zigachev
si_calculate_sclk_params(struct amdgpu_device * adev,u32 engine_clock,SISLANDS_SMC_SCLK_VALUE * sclk)5243b843c749SSergey Zigachev static int si_calculate_sclk_params(struct amdgpu_device *adev,
5244b843c749SSergey Zigachev u32 engine_clock,
5245b843c749SSergey Zigachev SISLANDS_SMC_SCLK_VALUE *sclk)
5246b843c749SSergey Zigachev {
5247b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
5248b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5249b843c749SSergey Zigachev struct atom_clock_dividers dividers;
5250b843c749SSergey Zigachev u32 spll_func_cntl = si_pi->clock_registers.cg_spll_func_cntl;
5251b843c749SSergey Zigachev u32 spll_func_cntl_2 = si_pi->clock_registers.cg_spll_func_cntl_2;
5252b843c749SSergey Zigachev u32 spll_func_cntl_3 = si_pi->clock_registers.cg_spll_func_cntl_3;
5253b843c749SSergey Zigachev u32 spll_func_cntl_4 = si_pi->clock_registers.cg_spll_func_cntl_4;
5254b843c749SSergey Zigachev u32 cg_spll_spread_spectrum = si_pi->clock_registers.cg_spll_spread_spectrum;
5255b843c749SSergey Zigachev u32 cg_spll_spread_spectrum_2 = si_pi->clock_registers.cg_spll_spread_spectrum_2;
5256b843c749SSergey Zigachev u64 tmp;
5257b843c749SSergey Zigachev u32 reference_clock = adev->clock.spll.reference_freq;
5258b843c749SSergey Zigachev u32 reference_divider;
5259b843c749SSergey Zigachev u32 fbdiv;
5260b843c749SSergey Zigachev int ret;
5261b843c749SSergey Zigachev
5262b843c749SSergey Zigachev ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_ENGINE_PLL_PARAM,
5263b843c749SSergey Zigachev engine_clock, false, ÷rs);
5264b843c749SSergey Zigachev if (ret)
5265b843c749SSergey Zigachev return ret;
5266b843c749SSergey Zigachev
5267b843c749SSergey Zigachev reference_divider = 1 + dividers.ref_div;
5268b843c749SSergey Zigachev
5269b843c749SSergey Zigachev tmp = (u64) engine_clock * reference_divider * dividers.post_div * 16384;
5270b843c749SSergey Zigachev do_div(tmp, reference_clock);
5271b843c749SSergey Zigachev fbdiv = (u32) tmp;
5272b843c749SSergey Zigachev
5273b843c749SSergey Zigachev spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
5274b843c749SSergey Zigachev spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
5275b843c749SSergey Zigachev spll_func_cntl |= SPLL_PDIV_A(dividers.post_div);
5276b843c749SSergey Zigachev
5277b843c749SSergey Zigachev spll_func_cntl_2 &= ~SCLK_MUX_SEL_MASK;
5278b843c749SSergey Zigachev spll_func_cntl_2 |= SCLK_MUX_SEL(2);
5279b843c749SSergey Zigachev
5280b843c749SSergey Zigachev spll_func_cntl_3 &= ~SPLL_FB_DIV_MASK;
5281b843c749SSergey Zigachev spll_func_cntl_3 |= SPLL_FB_DIV(fbdiv);
5282b843c749SSergey Zigachev spll_func_cntl_3 |= SPLL_DITHEN;
5283b843c749SSergey Zigachev
5284b843c749SSergey Zigachev if (pi->sclk_ss) {
5285b843c749SSergey Zigachev struct amdgpu_atom_ss ss;
5286b843c749SSergey Zigachev u32 vco_freq = engine_clock * dividers.post_div;
5287b843c749SSergey Zigachev
5288b843c749SSergey Zigachev if (amdgpu_atombios_get_asic_ss_info(adev, &ss,
5289b843c749SSergey Zigachev ASIC_INTERNAL_ENGINE_SS, vco_freq)) {
5290b843c749SSergey Zigachev u32 clk_s = reference_clock * 5 / (reference_divider * ss.rate);
5291b843c749SSergey Zigachev u32 clk_v = 4 * ss.percentage * fbdiv / (clk_s * 10000);
5292b843c749SSergey Zigachev
5293b843c749SSergey Zigachev cg_spll_spread_spectrum &= ~CLK_S_MASK;
5294b843c749SSergey Zigachev cg_spll_spread_spectrum |= CLK_S(clk_s);
5295b843c749SSergey Zigachev cg_spll_spread_spectrum |= SSEN;
5296b843c749SSergey Zigachev
5297b843c749SSergey Zigachev cg_spll_spread_spectrum_2 &= ~CLK_V_MASK;
5298b843c749SSergey Zigachev cg_spll_spread_spectrum_2 |= CLK_V(clk_v);
5299b843c749SSergey Zigachev }
5300b843c749SSergey Zigachev }
5301b843c749SSergey Zigachev
5302b843c749SSergey Zigachev sclk->sclk_value = engine_clock;
5303b843c749SSergey Zigachev sclk->vCG_SPLL_FUNC_CNTL = spll_func_cntl;
5304b843c749SSergey Zigachev sclk->vCG_SPLL_FUNC_CNTL_2 = spll_func_cntl_2;
5305b843c749SSergey Zigachev sclk->vCG_SPLL_FUNC_CNTL_3 = spll_func_cntl_3;
5306b843c749SSergey Zigachev sclk->vCG_SPLL_FUNC_CNTL_4 = spll_func_cntl_4;
5307b843c749SSergey Zigachev sclk->vCG_SPLL_SPREAD_SPECTRUM = cg_spll_spread_spectrum;
5308b843c749SSergey Zigachev sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cg_spll_spread_spectrum_2;
5309b843c749SSergey Zigachev
5310b843c749SSergey Zigachev return 0;
5311b843c749SSergey Zigachev }
5312b843c749SSergey Zigachev
si_populate_sclk_value(struct amdgpu_device * adev,u32 engine_clock,SISLANDS_SMC_SCLK_VALUE * sclk)5313b843c749SSergey Zigachev static int si_populate_sclk_value(struct amdgpu_device *adev,
5314b843c749SSergey Zigachev u32 engine_clock,
5315b843c749SSergey Zigachev SISLANDS_SMC_SCLK_VALUE *sclk)
5316b843c749SSergey Zigachev {
5317b843c749SSergey Zigachev SISLANDS_SMC_SCLK_VALUE sclk_tmp;
5318b843c749SSergey Zigachev int ret;
5319b843c749SSergey Zigachev
5320b843c749SSergey Zigachev ret = si_calculate_sclk_params(adev, engine_clock, &sclk_tmp);
5321b843c749SSergey Zigachev if (!ret) {
5322b843c749SSergey Zigachev sclk->sclk_value = cpu_to_be32(sclk_tmp.sclk_value);
5323b843c749SSergey Zigachev sclk->vCG_SPLL_FUNC_CNTL = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL);
5324b843c749SSergey Zigachev sclk->vCG_SPLL_FUNC_CNTL_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_2);
5325b843c749SSergey Zigachev sclk->vCG_SPLL_FUNC_CNTL_3 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_3);
5326b843c749SSergey Zigachev sclk->vCG_SPLL_FUNC_CNTL_4 = cpu_to_be32(sclk_tmp.vCG_SPLL_FUNC_CNTL_4);
5327b843c749SSergey Zigachev sclk->vCG_SPLL_SPREAD_SPECTRUM = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM);
5328b843c749SSergey Zigachev sclk->vCG_SPLL_SPREAD_SPECTRUM_2 = cpu_to_be32(sclk_tmp.vCG_SPLL_SPREAD_SPECTRUM_2);
5329b843c749SSergey Zigachev }
5330b843c749SSergey Zigachev
5331b843c749SSergey Zigachev return ret;
5332b843c749SSergey Zigachev }
5333b843c749SSergey Zigachev
si_populate_mclk_value(struct amdgpu_device * adev,u32 engine_clock,u32 memory_clock,SISLANDS_SMC_MCLK_VALUE * mclk,bool strobe_mode,bool dll_state_on)5334b843c749SSergey Zigachev static int si_populate_mclk_value(struct amdgpu_device *adev,
5335b843c749SSergey Zigachev u32 engine_clock,
5336b843c749SSergey Zigachev u32 memory_clock,
5337b843c749SSergey Zigachev SISLANDS_SMC_MCLK_VALUE *mclk,
5338b843c749SSergey Zigachev bool strobe_mode,
5339b843c749SSergey Zigachev bool dll_state_on)
5340b843c749SSergey Zigachev {
5341b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
5342b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5343b843c749SSergey Zigachev u32 dll_cntl = si_pi->clock_registers.dll_cntl;
5344b843c749SSergey Zigachev u32 mclk_pwrmgt_cntl = si_pi->clock_registers.mclk_pwrmgt_cntl;
5345b843c749SSergey Zigachev u32 mpll_ad_func_cntl = si_pi->clock_registers.mpll_ad_func_cntl;
5346b843c749SSergey Zigachev u32 mpll_dq_func_cntl = si_pi->clock_registers.mpll_dq_func_cntl;
5347b843c749SSergey Zigachev u32 mpll_func_cntl = si_pi->clock_registers.mpll_func_cntl;
5348b843c749SSergey Zigachev u32 mpll_func_cntl_1 = si_pi->clock_registers.mpll_func_cntl_1;
5349b843c749SSergey Zigachev u32 mpll_func_cntl_2 = si_pi->clock_registers.mpll_func_cntl_2;
5350b843c749SSergey Zigachev u32 mpll_ss1 = si_pi->clock_registers.mpll_ss1;
5351b843c749SSergey Zigachev u32 mpll_ss2 = si_pi->clock_registers.mpll_ss2;
5352b843c749SSergey Zigachev struct atom_mpll_param mpll_param;
5353b843c749SSergey Zigachev int ret;
5354b843c749SSergey Zigachev
5355b843c749SSergey Zigachev ret = amdgpu_atombios_get_memory_pll_dividers(adev, memory_clock, strobe_mode, &mpll_param);
5356b843c749SSergey Zigachev if (ret)
5357b843c749SSergey Zigachev return ret;
5358b843c749SSergey Zigachev
5359b843c749SSergey Zigachev mpll_func_cntl &= ~BWCTRL_MASK;
5360b843c749SSergey Zigachev mpll_func_cntl |= BWCTRL(mpll_param.bwcntl);
5361b843c749SSergey Zigachev
5362b843c749SSergey Zigachev mpll_func_cntl_1 &= ~(CLKF_MASK | CLKFRAC_MASK | VCO_MODE_MASK);
5363b843c749SSergey Zigachev mpll_func_cntl_1 |= CLKF(mpll_param.clkf) |
5364b843c749SSergey Zigachev CLKFRAC(mpll_param.clkfrac) | VCO_MODE(mpll_param.vco_mode);
5365b843c749SSergey Zigachev
5366b843c749SSergey Zigachev mpll_ad_func_cntl &= ~YCLK_POST_DIV_MASK;
5367b843c749SSergey Zigachev mpll_ad_func_cntl |= YCLK_POST_DIV(mpll_param.post_div);
5368b843c749SSergey Zigachev
5369b843c749SSergey Zigachev if (adev->gmc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) {
5370b843c749SSergey Zigachev mpll_dq_func_cntl &= ~(YCLK_SEL_MASK | YCLK_POST_DIV_MASK);
5371b843c749SSergey Zigachev mpll_dq_func_cntl |= YCLK_SEL(mpll_param.yclk_sel) |
5372b843c749SSergey Zigachev YCLK_POST_DIV(mpll_param.post_div);
5373b843c749SSergey Zigachev }
5374b843c749SSergey Zigachev
5375b843c749SSergey Zigachev if (pi->mclk_ss) {
5376b843c749SSergey Zigachev struct amdgpu_atom_ss ss;
5377b843c749SSergey Zigachev u32 freq_nom;
5378b843c749SSergey Zigachev u32 tmp;
5379b843c749SSergey Zigachev u32 reference_clock = adev->clock.mpll.reference_freq;
5380b843c749SSergey Zigachev
5381b843c749SSergey Zigachev if (adev->gmc.vram_type == AMDGPU_VRAM_TYPE_GDDR5)
5382b843c749SSergey Zigachev freq_nom = memory_clock * 4;
5383b843c749SSergey Zigachev else
5384b843c749SSergey Zigachev freq_nom = memory_clock * 2;
5385b843c749SSergey Zigachev
5386b843c749SSergey Zigachev tmp = freq_nom / reference_clock;
5387b843c749SSergey Zigachev tmp = tmp * tmp;
5388b843c749SSergey Zigachev if (amdgpu_atombios_get_asic_ss_info(adev, &ss,
5389b843c749SSergey Zigachev ASIC_INTERNAL_MEMORY_SS, freq_nom)) {
5390b843c749SSergey Zigachev u32 clks = reference_clock * 5 / ss.rate;
5391b843c749SSergey Zigachev u32 clkv = (u32)((((131 * ss.percentage * ss.rate) / 100) * tmp) / freq_nom);
5392b843c749SSergey Zigachev
5393b843c749SSergey Zigachev mpll_ss1 &= ~CLKV_MASK;
5394b843c749SSergey Zigachev mpll_ss1 |= CLKV(clkv);
5395b843c749SSergey Zigachev
5396b843c749SSergey Zigachev mpll_ss2 &= ~CLKS_MASK;
5397b843c749SSergey Zigachev mpll_ss2 |= CLKS(clks);
5398b843c749SSergey Zigachev }
5399b843c749SSergey Zigachev }
5400b843c749SSergey Zigachev
5401b843c749SSergey Zigachev mclk_pwrmgt_cntl &= ~DLL_SPEED_MASK;
5402b843c749SSergey Zigachev mclk_pwrmgt_cntl |= DLL_SPEED(mpll_param.dll_speed);
5403b843c749SSergey Zigachev
5404b843c749SSergey Zigachev if (dll_state_on)
5405b843c749SSergey Zigachev mclk_pwrmgt_cntl |= MRDCK0_PDNB | MRDCK1_PDNB;
5406b843c749SSergey Zigachev else
5407b843c749SSergey Zigachev mclk_pwrmgt_cntl &= ~(MRDCK0_PDNB | MRDCK1_PDNB);
5408b843c749SSergey Zigachev
5409b843c749SSergey Zigachev mclk->mclk_value = cpu_to_be32(memory_clock);
5410b843c749SSergey Zigachev mclk->vMPLL_FUNC_CNTL = cpu_to_be32(mpll_func_cntl);
5411b843c749SSergey Zigachev mclk->vMPLL_FUNC_CNTL_1 = cpu_to_be32(mpll_func_cntl_1);
5412b843c749SSergey Zigachev mclk->vMPLL_FUNC_CNTL_2 = cpu_to_be32(mpll_func_cntl_2);
5413b843c749SSergey Zigachev mclk->vMPLL_AD_FUNC_CNTL = cpu_to_be32(mpll_ad_func_cntl);
5414b843c749SSergey Zigachev mclk->vMPLL_DQ_FUNC_CNTL = cpu_to_be32(mpll_dq_func_cntl);
5415b843c749SSergey Zigachev mclk->vMCLK_PWRMGT_CNTL = cpu_to_be32(mclk_pwrmgt_cntl);
5416b843c749SSergey Zigachev mclk->vDLL_CNTL = cpu_to_be32(dll_cntl);
5417b843c749SSergey Zigachev mclk->vMPLL_SS = cpu_to_be32(mpll_ss1);
5418b843c749SSergey Zigachev mclk->vMPLL_SS2 = cpu_to_be32(mpll_ss2);
5419b843c749SSergey Zigachev
5420b843c749SSergey Zigachev return 0;
5421b843c749SSergey Zigachev }
5422b843c749SSergey Zigachev
si_populate_smc_sp(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state,SISLANDS_SMC_SWSTATE * smc_state)5423b843c749SSergey Zigachev static void si_populate_smc_sp(struct amdgpu_device *adev,
5424b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state,
5425b843c749SSergey Zigachev SISLANDS_SMC_SWSTATE *smc_state)
5426b843c749SSergey Zigachev {
5427b843c749SSergey Zigachev struct si_ps *ps = si_get_ps(amdgpu_state);
5428b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
5429b843c749SSergey Zigachev int i;
5430b843c749SSergey Zigachev
5431b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count - 1; i++)
5432b843c749SSergey Zigachev smc_state->levels[i].bSP = cpu_to_be32(pi->dsp);
5433b843c749SSergey Zigachev
5434b843c749SSergey Zigachev smc_state->levels[ps->performance_level_count - 1].bSP =
5435b843c749SSergey Zigachev cpu_to_be32(pi->psp);
5436b843c749SSergey Zigachev }
5437b843c749SSergey Zigachev
si_convert_power_level_to_smc(struct amdgpu_device * adev,struct rv7xx_pl * pl,SISLANDS_SMC_HW_PERFORMANCE_LEVEL * level)5438b843c749SSergey Zigachev static int si_convert_power_level_to_smc(struct amdgpu_device *adev,
5439b843c749SSergey Zigachev struct rv7xx_pl *pl,
5440b843c749SSergey Zigachev SISLANDS_SMC_HW_PERFORMANCE_LEVEL *level)
5441b843c749SSergey Zigachev {
5442b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
5443b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
5444b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5445b843c749SSergey Zigachev int ret;
5446b843c749SSergey Zigachev bool dll_state_on;
5447b843c749SSergey Zigachev u16 std_vddc;
5448b843c749SSergey Zigachev bool gmc_pg = false;
5449b843c749SSergey Zigachev
5450b843c749SSergey Zigachev if (eg_pi->pcie_performance_request &&
5451b843c749SSergey Zigachev (si_pi->force_pcie_gen != AMDGPU_PCIE_GEN_INVALID))
5452b843c749SSergey Zigachev level->gen2PCIE = (u8)si_pi->force_pcie_gen;
5453b843c749SSergey Zigachev else
5454b843c749SSergey Zigachev level->gen2PCIE = (u8)pl->pcie_gen;
5455b843c749SSergey Zigachev
5456b843c749SSergey Zigachev ret = si_populate_sclk_value(adev, pl->sclk, &level->sclk);
5457b843c749SSergey Zigachev if (ret)
5458b843c749SSergey Zigachev return ret;
5459b843c749SSergey Zigachev
5460b843c749SSergey Zigachev level->mcFlags = 0;
5461b843c749SSergey Zigachev
5462b843c749SSergey Zigachev if (pi->mclk_stutter_mode_threshold &&
5463b843c749SSergey Zigachev (pl->mclk <= pi->mclk_stutter_mode_threshold) &&
5464b843c749SSergey Zigachev !eg_pi->uvd_enabled &&
5465b843c749SSergey Zigachev (RREG32(DPG_PIPE_STUTTER_CONTROL) & STUTTER_ENABLE) &&
5466b843c749SSergey Zigachev (adev->pm.dpm.new_active_crtc_count <= 2)) {
5467b843c749SSergey Zigachev level->mcFlags |= SISLANDS_SMC_MC_STUTTER_EN;
5468b843c749SSergey Zigachev
5469b843c749SSergey Zigachev if (gmc_pg)
5470b843c749SSergey Zigachev level->mcFlags |= SISLANDS_SMC_MC_PG_EN;
5471b843c749SSergey Zigachev }
5472b843c749SSergey Zigachev
5473b843c749SSergey Zigachev if (adev->gmc.vram_type == AMDGPU_VRAM_TYPE_GDDR5) {
5474b843c749SSergey Zigachev if (pl->mclk > pi->mclk_edc_enable_threshold)
5475b843c749SSergey Zigachev level->mcFlags |= SISLANDS_SMC_MC_EDC_RD_FLAG;
5476b843c749SSergey Zigachev
5477b843c749SSergey Zigachev if (pl->mclk > eg_pi->mclk_edc_wr_enable_threshold)
5478b843c749SSergey Zigachev level->mcFlags |= SISLANDS_SMC_MC_EDC_WR_FLAG;
5479b843c749SSergey Zigachev
5480b843c749SSergey Zigachev level->strobeMode = si_get_strobe_mode_settings(adev, pl->mclk);
5481b843c749SSergey Zigachev
5482b843c749SSergey Zigachev if (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) {
5483b843c749SSergey Zigachev if (si_get_mclk_frequency_ratio(pl->mclk, true) >=
5484b843c749SSergey Zigachev ((RREG32(MC_SEQ_MISC7) >> 16) & 0xf))
5485b843c749SSergey Zigachev dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false;
5486b843c749SSergey Zigachev else
5487b843c749SSergey Zigachev dll_state_on = ((RREG32(MC_SEQ_MISC6) >> 1) & 0x1) ? true : false;
5488b843c749SSergey Zigachev } else {
5489b843c749SSergey Zigachev dll_state_on = false;
5490b843c749SSergey Zigachev }
5491b843c749SSergey Zigachev } else {
5492b843c749SSergey Zigachev level->strobeMode = si_get_strobe_mode_settings(adev,
5493b843c749SSergey Zigachev pl->mclk);
5494b843c749SSergey Zigachev
5495b843c749SSergey Zigachev dll_state_on = ((RREG32(MC_SEQ_MISC5) >> 1) & 0x1) ? true : false;
5496b843c749SSergey Zigachev }
5497b843c749SSergey Zigachev
5498b843c749SSergey Zigachev ret = si_populate_mclk_value(adev,
5499b843c749SSergey Zigachev pl->sclk,
5500b843c749SSergey Zigachev pl->mclk,
5501b843c749SSergey Zigachev &level->mclk,
5502b843c749SSergey Zigachev (level->strobeMode & SISLANDS_SMC_STROBE_ENABLE) != 0, dll_state_on);
5503b843c749SSergey Zigachev if (ret)
5504b843c749SSergey Zigachev return ret;
5505b843c749SSergey Zigachev
5506b843c749SSergey Zigachev ret = si_populate_voltage_value(adev,
5507b843c749SSergey Zigachev &eg_pi->vddc_voltage_table,
5508b843c749SSergey Zigachev pl->vddc, &level->vddc);
5509b843c749SSergey Zigachev if (ret)
5510b843c749SSergey Zigachev return ret;
5511b843c749SSergey Zigachev
5512b843c749SSergey Zigachev
5513b843c749SSergey Zigachev ret = si_get_std_voltage_value(adev, &level->vddc, &std_vddc);
5514b843c749SSergey Zigachev if (ret)
5515b843c749SSergey Zigachev return ret;
5516b843c749SSergey Zigachev
5517b843c749SSergey Zigachev ret = si_populate_std_voltage_value(adev, std_vddc,
5518b843c749SSergey Zigachev level->vddc.index, &level->std_vddc);
5519b843c749SSergey Zigachev if (ret)
5520b843c749SSergey Zigachev return ret;
5521b843c749SSergey Zigachev
5522b843c749SSergey Zigachev if (eg_pi->vddci_control) {
5523b843c749SSergey Zigachev ret = si_populate_voltage_value(adev, &eg_pi->vddci_voltage_table,
5524b843c749SSergey Zigachev pl->vddci, &level->vddci);
5525b843c749SSergey Zigachev if (ret)
5526b843c749SSergey Zigachev return ret;
5527b843c749SSergey Zigachev }
5528b843c749SSergey Zigachev
5529b843c749SSergey Zigachev if (si_pi->vddc_phase_shed_control) {
5530b843c749SSergey Zigachev ret = si_populate_phase_shedding_value(adev,
5531b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.phase_shedding_limits_table,
5532b843c749SSergey Zigachev pl->vddc,
5533b843c749SSergey Zigachev pl->sclk,
5534b843c749SSergey Zigachev pl->mclk,
5535b843c749SSergey Zigachev &level->vddc);
5536b843c749SSergey Zigachev if (ret)
5537b843c749SSergey Zigachev return ret;
5538b843c749SSergey Zigachev }
5539b843c749SSergey Zigachev
5540b843c749SSergey Zigachev level->MaxPoweredUpCU = si_pi->max_cu;
5541b843c749SSergey Zigachev
5542b843c749SSergey Zigachev ret = si_populate_mvdd_value(adev, pl->mclk, &level->mvdd);
5543b843c749SSergey Zigachev
5544b843c749SSergey Zigachev return ret;
5545b843c749SSergey Zigachev }
5546b843c749SSergey Zigachev
si_populate_smc_t(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state,SISLANDS_SMC_SWSTATE * smc_state)5547b843c749SSergey Zigachev static int si_populate_smc_t(struct amdgpu_device *adev,
5548b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state,
5549b843c749SSergey Zigachev SISLANDS_SMC_SWSTATE *smc_state)
5550b843c749SSergey Zigachev {
5551b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
5552b843c749SSergey Zigachev struct si_ps *state = si_get_ps(amdgpu_state);
5553b843c749SSergey Zigachev u32 a_t;
5554b843c749SSergey Zigachev u32 t_l, t_h;
5555b843c749SSergey Zigachev u32 high_bsp;
5556b843c749SSergey Zigachev int i, ret;
5557b843c749SSergey Zigachev
5558b843c749SSergey Zigachev if (state->performance_level_count >= 9)
5559b843c749SSergey Zigachev return -EINVAL;
5560b843c749SSergey Zigachev
5561b843c749SSergey Zigachev if (state->performance_level_count < 2) {
5562b843c749SSergey Zigachev a_t = CG_R(0xffff) | CG_L(0);
5563b843c749SSergey Zigachev smc_state->levels[0].aT = cpu_to_be32(a_t);
5564b843c749SSergey Zigachev return 0;
5565b843c749SSergey Zigachev }
5566b843c749SSergey Zigachev
5567b843c749SSergey Zigachev smc_state->levels[0].aT = cpu_to_be32(0);
5568b843c749SSergey Zigachev
5569b843c749SSergey Zigachev for (i = 0; i <= state->performance_level_count - 2; i++) {
5570b843c749SSergey Zigachev ret = r600_calculate_at(
5571b843c749SSergey Zigachev (50 / SISLANDS_MAX_HARDWARE_POWERLEVELS) * 100 * (i + 1),
5572b843c749SSergey Zigachev 100 * R600_AH_DFLT,
5573b843c749SSergey Zigachev state->performance_levels[i + 1].sclk,
5574b843c749SSergey Zigachev state->performance_levels[i].sclk,
5575b843c749SSergey Zigachev &t_l,
5576b843c749SSergey Zigachev &t_h);
5577b843c749SSergey Zigachev
5578b843c749SSergey Zigachev if (ret) {
5579b843c749SSergey Zigachev t_h = (i + 1) * 1000 - 50 * R600_AH_DFLT;
5580b843c749SSergey Zigachev t_l = (i + 1) * 1000 + 50 * R600_AH_DFLT;
5581b843c749SSergey Zigachev }
5582b843c749SSergey Zigachev
5583b843c749SSergey Zigachev a_t = be32_to_cpu(smc_state->levels[i].aT) & ~CG_R_MASK;
5584b843c749SSergey Zigachev a_t |= CG_R(t_l * pi->bsp / 20000);
5585b843c749SSergey Zigachev smc_state->levels[i].aT = cpu_to_be32(a_t);
5586b843c749SSergey Zigachev
5587b843c749SSergey Zigachev high_bsp = (i == state->performance_level_count - 2) ?
5588b843c749SSergey Zigachev pi->pbsp : pi->bsp;
5589b843c749SSergey Zigachev a_t = CG_R(0xffff) | CG_L(t_h * high_bsp / 20000);
5590b843c749SSergey Zigachev smc_state->levels[i + 1].aT = cpu_to_be32(a_t);
5591b843c749SSergey Zigachev }
5592b843c749SSergey Zigachev
5593b843c749SSergey Zigachev return 0;
5594b843c749SSergey Zigachev }
5595b843c749SSergey Zigachev
si_disable_ulv(struct amdgpu_device * adev)5596b843c749SSergey Zigachev static int si_disable_ulv(struct amdgpu_device *adev)
5597b843c749SSergey Zigachev {
5598b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5599b843c749SSergey Zigachev struct si_ulv_param *ulv = &si_pi->ulv;
5600b843c749SSergey Zigachev
5601b843c749SSergey Zigachev if (ulv->supported)
5602b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ?
5603b843c749SSergey Zigachev 0 : -EINVAL;
5604b843c749SSergey Zigachev
5605b843c749SSergey Zigachev return 0;
5606b843c749SSergey Zigachev }
5607b843c749SSergey Zigachev
si_is_state_ulv_compatible(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state)5608b843c749SSergey Zigachev static bool si_is_state_ulv_compatible(struct amdgpu_device *adev,
5609b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state)
5610b843c749SSergey Zigachev {
5611b843c749SSergey Zigachev const struct si_power_info *si_pi = si_get_pi(adev);
5612b843c749SSergey Zigachev const struct si_ulv_param *ulv = &si_pi->ulv;
5613b843c749SSergey Zigachev const struct si_ps *state = si_get_ps(amdgpu_state);
5614b843c749SSergey Zigachev int i;
5615b843c749SSergey Zigachev
5616b843c749SSergey Zigachev if (state->performance_levels[0].mclk != ulv->pl.mclk)
5617b843c749SSergey Zigachev return false;
5618b843c749SSergey Zigachev
5619b843c749SSergey Zigachev /* XXX validate against display requirements! */
5620b843c749SSergey Zigachev
5621b843c749SSergey Zigachev for (i = 0; i < adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count; i++) {
5622b843c749SSergey Zigachev if (adev->clock.current_dispclk <=
5623b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].clk) {
5624b843c749SSergey Zigachev if (ulv->pl.vddc <
5625b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[i].v)
5626b843c749SSergey Zigachev return false;
5627b843c749SSergey Zigachev }
5628b843c749SSergey Zigachev }
5629b843c749SSergey Zigachev
5630b843c749SSergey Zigachev if ((amdgpu_state->vclk != 0) || (amdgpu_state->dclk != 0))
5631b843c749SSergey Zigachev return false;
5632b843c749SSergey Zigachev
5633b843c749SSergey Zigachev return true;
5634b843c749SSergey Zigachev }
5635b843c749SSergey Zigachev
si_set_power_state_conditionally_enable_ulv(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state)5636b843c749SSergey Zigachev static int si_set_power_state_conditionally_enable_ulv(struct amdgpu_device *adev,
5637b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state)
5638b843c749SSergey Zigachev {
5639b843c749SSergey Zigachev const struct si_power_info *si_pi = si_get_pi(adev);
5640b843c749SSergey Zigachev const struct si_ulv_param *ulv = &si_pi->ulv;
5641b843c749SSergey Zigachev
5642b843c749SSergey Zigachev if (ulv->supported) {
5643b843c749SSergey Zigachev if (si_is_state_ulv_compatible(adev, amdgpu_new_state))
5644b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableULV) == PPSMC_Result_OK) ?
5645b843c749SSergey Zigachev 0 : -EINVAL;
5646b843c749SSergey Zigachev }
5647b843c749SSergey Zigachev return 0;
5648b843c749SSergey Zigachev }
5649b843c749SSergey Zigachev
si_convert_power_state_to_smc(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state,SISLANDS_SMC_SWSTATE * smc_state)5650b843c749SSergey Zigachev static int si_convert_power_state_to_smc(struct amdgpu_device *adev,
5651b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state,
5652b843c749SSergey Zigachev SISLANDS_SMC_SWSTATE *smc_state)
5653b843c749SSergey Zigachev {
5654b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
5655b843c749SSergey Zigachev struct ni_power_info *ni_pi = ni_get_pi(adev);
5656b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5657b843c749SSergey Zigachev struct si_ps *state = si_get_ps(amdgpu_state);
5658b843c749SSergey Zigachev int i, ret;
5659b843c749SSergey Zigachev u32 threshold;
5660b843c749SSergey Zigachev u32 sclk_in_sr = 1350; /* ??? */
5661b843c749SSergey Zigachev
5662b843c749SSergey Zigachev if (state->performance_level_count > SISLANDS_MAX_HARDWARE_POWERLEVELS)
5663b843c749SSergey Zigachev return -EINVAL;
5664b843c749SSergey Zigachev
5665b843c749SSergey Zigachev threshold = state->performance_levels[state->performance_level_count-1].sclk * 100 / 100;
5666b843c749SSergey Zigachev
5667b843c749SSergey Zigachev if (amdgpu_state->vclk && amdgpu_state->dclk) {
5668b843c749SSergey Zigachev eg_pi->uvd_enabled = true;
5669b843c749SSergey Zigachev if (eg_pi->smu_uvd_hs)
5670b843c749SSergey Zigachev smc_state->flags |= PPSMC_SWSTATE_FLAG_UVD;
5671b843c749SSergey Zigachev } else {
5672b843c749SSergey Zigachev eg_pi->uvd_enabled = false;
5673b843c749SSergey Zigachev }
5674b843c749SSergey Zigachev
5675b843c749SSergey Zigachev if (state->dc_compatible)
5676b843c749SSergey Zigachev smc_state->flags |= PPSMC_SWSTATE_FLAG_DC;
5677b843c749SSergey Zigachev
5678b843c749SSergey Zigachev smc_state->levelCount = 0;
5679b843c749SSergey Zigachev for (i = 0; i < state->performance_level_count; i++) {
5680b843c749SSergey Zigachev if (eg_pi->sclk_deep_sleep) {
5681b843c749SSergey Zigachev if ((i == 0) || si_pi->sclk_deep_sleep_above_low) {
5682b843c749SSergey Zigachev if (sclk_in_sr <= SCLK_MIN_DEEPSLEEP_FREQ)
5683b843c749SSergey Zigachev smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_BYPASS;
5684b843c749SSergey Zigachev else
5685b843c749SSergey Zigachev smc_state->levels[i].stateFlags |= PPSMC_STATEFLAG_DEEPSLEEP_THROTTLE;
5686b843c749SSergey Zigachev }
5687b843c749SSergey Zigachev }
5688b843c749SSergey Zigachev
5689b843c749SSergey Zigachev ret = si_convert_power_level_to_smc(adev, &state->performance_levels[i],
5690b843c749SSergey Zigachev &smc_state->levels[i]);
5691b843c749SSergey Zigachev smc_state->levels[i].arbRefreshState =
5692b843c749SSergey Zigachev (u8)(SISLANDS_DRIVER_STATE_ARB_INDEX + i);
5693b843c749SSergey Zigachev
5694b843c749SSergey Zigachev if (ret)
5695b843c749SSergey Zigachev return ret;
5696b843c749SSergey Zigachev
5697b843c749SSergey Zigachev if (ni_pi->enable_power_containment)
5698b843c749SSergey Zigachev smc_state->levels[i].displayWatermark =
5699b843c749SSergey Zigachev (state->performance_levels[i].sclk < threshold) ?
5700b843c749SSergey Zigachev PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH;
5701b843c749SSergey Zigachev else
5702b843c749SSergey Zigachev smc_state->levels[i].displayWatermark = (i < 2) ?
5703b843c749SSergey Zigachev PPSMC_DISPLAY_WATERMARK_LOW : PPSMC_DISPLAY_WATERMARK_HIGH;
5704b843c749SSergey Zigachev
5705b843c749SSergey Zigachev if (eg_pi->dynamic_ac_timing)
5706b843c749SSergey Zigachev smc_state->levels[i].ACIndex = SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i;
5707b843c749SSergey Zigachev else
5708b843c749SSergey Zigachev smc_state->levels[i].ACIndex = 0;
5709b843c749SSergey Zigachev
5710b843c749SSergey Zigachev smc_state->levelCount++;
5711b843c749SSergey Zigachev }
5712b843c749SSergey Zigachev
5713b843c749SSergey Zigachev si_write_smc_soft_register(adev,
5714b843c749SSergey Zigachev SI_SMC_SOFT_REGISTER_watermark_threshold,
5715b843c749SSergey Zigachev threshold / 512);
5716b843c749SSergey Zigachev
5717b843c749SSergey Zigachev si_populate_smc_sp(adev, amdgpu_state, smc_state);
5718b843c749SSergey Zigachev
5719b843c749SSergey Zigachev ret = si_populate_power_containment_values(adev, amdgpu_state, smc_state);
5720b843c749SSergey Zigachev if (ret)
5721b843c749SSergey Zigachev ni_pi->enable_power_containment = false;
5722b843c749SSergey Zigachev
5723b843c749SSergey Zigachev ret = si_populate_sq_ramping_values(adev, amdgpu_state, smc_state);
5724b843c749SSergey Zigachev if (ret)
5725b843c749SSergey Zigachev ni_pi->enable_sq_ramping = false;
5726b843c749SSergey Zigachev
5727b843c749SSergey Zigachev return si_populate_smc_t(adev, amdgpu_state, smc_state);
5728b843c749SSergey Zigachev }
5729b843c749SSergey Zigachev
si_upload_sw_state(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state)5730b843c749SSergey Zigachev static int si_upload_sw_state(struct amdgpu_device *adev,
5731b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state)
5732b843c749SSergey Zigachev {
5733b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5734b843c749SSergey Zigachev struct si_ps *new_state = si_get_ps(amdgpu_new_state);
5735b843c749SSergey Zigachev int ret;
5736b843c749SSergey Zigachev u32 address = si_pi->state_table_start +
5737b843c749SSergey Zigachev offsetof(SISLANDS_SMC_STATETABLE, driverState);
5738b843c749SSergey Zigachev u32 state_size = sizeof(SISLANDS_SMC_SWSTATE) +
5739b843c749SSergey Zigachev ((new_state->performance_level_count - 1) *
5740b843c749SSergey Zigachev sizeof(SISLANDS_SMC_HW_PERFORMANCE_LEVEL));
5741b843c749SSergey Zigachev SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.driverState;
5742b843c749SSergey Zigachev
5743b843c749SSergey Zigachev memset(smc_state, 0, state_size);
5744b843c749SSergey Zigachev
5745b843c749SSergey Zigachev ret = si_convert_power_state_to_smc(adev, amdgpu_new_state, smc_state);
5746b843c749SSergey Zigachev if (ret)
5747b843c749SSergey Zigachev return ret;
5748b843c749SSergey Zigachev
5749b843c749SSergey Zigachev return amdgpu_si_copy_bytes_to_smc(adev, address, (u8 *)smc_state,
5750b843c749SSergey Zigachev state_size, si_pi->sram_end);
5751b843c749SSergey Zigachev }
5752b843c749SSergey Zigachev
si_upload_ulv_state(struct amdgpu_device * adev)5753b843c749SSergey Zigachev static int si_upload_ulv_state(struct amdgpu_device *adev)
5754b843c749SSergey Zigachev {
5755b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5756b843c749SSergey Zigachev struct si_ulv_param *ulv = &si_pi->ulv;
5757b843c749SSergey Zigachev int ret = 0;
5758b843c749SSergey Zigachev
5759b843c749SSergey Zigachev if (ulv->supported && ulv->pl.vddc) {
5760b843c749SSergey Zigachev u32 address = si_pi->state_table_start +
5761b843c749SSergey Zigachev offsetof(SISLANDS_SMC_STATETABLE, ULVState);
5762b843c749SSergey Zigachev SISLANDS_SMC_SWSTATE *smc_state = &si_pi->smc_statetable.ULVState;
5763b843c749SSergey Zigachev u32 state_size = sizeof(SISLANDS_SMC_SWSTATE);
5764b843c749SSergey Zigachev
5765b843c749SSergey Zigachev memset(smc_state, 0, state_size);
5766b843c749SSergey Zigachev
5767b843c749SSergey Zigachev ret = si_populate_ulv_state(adev, smc_state);
5768b843c749SSergey Zigachev if (!ret)
5769b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev, address, (u8 *)smc_state,
5770b843c749SSergey Zigachev state_size, si_pi->sram_end);
5771b843c749SSergey Zigachev }
5772b843c749SSergey Zigachev
5773b843c749SSergey Zigachev return ret;
5774b843c749SSergey Zigachev }
5775b843c749SSergey Zigachev
si_upload_smc_data(struct amdgpu_device * adev)5776b843c749SSergey Zigachev static int si_upload_smc_data(struct amdgpu_device *adev)
5777b843c749SSergey Zigachev {
5778b843c749SSergey Zigachev struct amdgpu_crtc *amdgpu_crtc = NULL;
5779b843c749SSergey Zigachev int i;
5780b843c749SSergey Zigachev
5781b843c749SSergey Zigachev if (adev->pm.dpm.new_active_crtc_count == 0)
5782b843c749SSergey Zigachev return 0;
5783b843c749SSergey Zigachev
5784b843c749SSergey Zigachev for (i = 0; i < adev->mode_info.num_crtc; i++) {
5785b843c749SSergey Zigachev if (adev->pm.dpm.new_active_crtcs & (1 << i)) {
5786b843c749SSergey Zigachev amdgpu_crtc = adev->mode_info.crtcs[i];
5787b843c749SSergey Zigachev break;
5788b843c749SSergey Zigachev }
5789b843c749SSergey Zigachev }
5790b843c749SSergey Zigachev
5791b843c749SSergey Zigachev if (amdgpu_crtc == NULL)
5792b843c749SSergey Zigachev return 0;
5793b843c749SSergey Zigachev
5794b843c749SSergey Zigachev if (amdgpu_crtc->line_time <= 0)
5795b843c749SSergey Zigachev return 0;
5796b843c749SSergey Zigachev
5797b843c749SSergey Zigachev if (si_write_smc_soft_register(adev,
5798b843c749SSergey Zigachev SI_SMC_SOFT_REGISTER_crtc_index,
5799b843c749SSergey Zigachev amdgpu_crtc->crtc_id) != PPSMC_Result_OK)
5800b843c749SSergey Zigachev return 0;
5801b843c749SSergey Zigachev
5802b843c749SSergey Zigachev if (si_write_smc_soft_register(adev,
5803b843c749SSergey Zigachev SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
5804b843c749SSergey Zigachev amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK)
5805b843c749SSergey Zigachev return 0;
5806b843c749SSergey Zigachev
5807b843c749SSergey Zigachev if (si_write_smc_soft_register(adev,
5808b843c749SSergey Zigachev SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
5809b843c749SSergey Zigachev amdgpu_crtc->wm_low / amdgpu_crtc->line_time) != PPSMC_Result_OK)
5810b843c749SSergey Zigachev return 0;
5811b843c749SSergey Zigachev
5812b843c749SSergey Zigachev return 0;
5813b843c749SSergey Zigachev }
5814b843c749SSergey Zigachev
si_set_mc_special_registers(struct amdgpu_device * adev,struct si_mc_reg_table * table)5815b843c749SSergey Zigachev static int si_set_mc_special_registers(struct amdgpu_device *adev,
5816b843c749SSergey Zigachev struct si_mc_reg_table *table)
5817b843c749SSergey Zigachev {
5818b843c749SSergey Zigachev u8 i, j, k;
5819b843c749SSergey Zigachev u32 temp_reg;
5820b843c749SSergey Zigachev
5821b843c749SSergey Zigachev for (i = 0, j = table->last; i < table->last; i++) {
5822b843c749SSergey Zigachev if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5823b843c749SSergey Zigachev return -EINVAL;
5824b843c749SSergey Zigachev switch (table->mc_reg_address[i].s1) {
5825b843c749SSergey Zigachev case MC_SEQ_MISC1:
5826b843c749SSergey Zigachev temp_reg = RREG32(MC_PMG_CMD_EMRS);
5827b843c749SSergey Zigachev table->mc_reg_address[j].s1 = MC_PMG_CMD_EMRS;
5828b843c749SSergey Zigachev table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_EMRS_LP;
5829b843c749SSergey Zigachev for (k = 0; k < table->num_entries; k++)
5830b843c749SSergey Zigachev table->mc_reg_table_entry[k].mc_data[j] =
5831b843c749SSergey Zigachev ((temp_reg & 0xffff0000)) |
5832b843c749SSergey Zigachev ((table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16);
5833b843c749SSergey Zigachev j++;
5834b843c749SSergey Zigachev
5835b843c749SSergey Zigachev if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5836b843c749SSergey Zigachev return -EINVAL;
5837b843c749SSergey Zigachev temp_reg = RREG32(MC_PMG_CMD_MRS);
5838b843c749SSergey Zigachev table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS;
5839b843c749SSergey Zigachev table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS_LP;
5840b843c749SSergey Zigachev for (k = 0; k < table->num_entries; k++) {
5841b843c749SSergey Zigachev table->mc_reg_table_entry[k].mc_data[j] =
5842b843c749SSergey Zigachev (temp_reg & 0xffff0000) |
5843b843c749SSergey Zigachev (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
5844b843c749SSergey Zigachev if (adev->gmc.vram_type != AMDGPU_VRAM_TYPE_GDDR5)
5845b843c749SSergey Zigachev table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
5846b843c749SSergey Zigachev }
5847b843c749SSergey Zigachev j++;
5848b843c749SSergey Zigachev
5849b843c749SSergey Zigachev if (adev->gmc.vram_type != AMDGPU_VRAM_TYPE_GDDR5) {
5850b843c749SSergey Zigachev if (j >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5851b843c749SSergey Zigachev return -EINVAL;
5852b843c749SSergey Zigachev table->mc_reg_address[j].s1 = MC_PMG_AUTO_CMD;
5853b843c749SSergey Zigachev table->mc_reg_address[j].s0 = MC_PMG_AUTO_CMD;
5854b843c749SSergey Zigachev for (k = 0; k < table->num_entries; k++)
5855b843c749SSergey Zigachev table->mc_reg_table_entry[k].mc_data[j] =
5856b843c749SSergey Zigachev (table->mc_reg_table_entry[k].mc_data[i] & 0xffff0000) >> 16;
5857b843c749SSergey Zigachev j++;
5858b843c749SSergey Zigachev }
5859b843c749SSergey Zigachev break;
5860b843c749SSergey Zigachev case MC_SEQ_RESERVE_M:
5861b843c749SSergey Zigachev temp_reg = RREG32(MC_PMG_CMD_MRS1);
5862b843c749SSergey Zigachev table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1;
5863b843c749SSergey Zigachev table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP;
5864b843c749SSergey Zigachev for(k = 0; k < table->num_entries; k++)
5865b843c749SSergey Zigachev table->mc_reg_table_entry[k].mc_data[j] =
5866b843c749SSergey Zigachev (temp_reg & 0xffff0000) |
5867b843c749SSergey Zigachev (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
5868b843c749SSergey Zigachev j++;
5869b843c749SSergey Zigachev break;
5870b843c749SSergey Zigachev default:
5871b843c749SSergey Zigachev break;
5872b843c749SSergey Zigachev }
5873b843c749SSergey Zigachev }
5874b843c749SSergey Zigachev
5875b843c749SSergey Zigachev table->last = j;
5876b843c749SSergey Zigachev
5877b843c749SSergey Zigachev return 0;
5878b843c749SSergey Zigachev }
5879b843c749SSergey Zigachev
si_check_s0_mc_reg_index(u16 in_reg,u16 * out_reg)5880b843c749SSergey Zigachev static bool si_check_s0_mc_reg_index(u16 in_reg, u16 *out_reg)
5881b843c749SSergey Zigachev {
5882b843c749SSergey Zigachev bool result = true;
5883b843c749SSergey Zigachev switch (in_reg) {
5884b843c749SSergey Zigachev case MC_SEQ_RAS_TIMING:
5885b843c749SSergey Zigachev *out_reg = MC_SEQ_RAS_TIMING_LP;
5886b843c749SSergey Zigachev break;
5887b843c749SSergey Zigachev case MC_SEQ_CAS_TIMING:
5888b843c749SSergey Zigachev *out_reg = MC_SEQ_CAS_TIMING_LP;
5889b843c749SSergey Zigachev break;
5890b843c749SSergey Zigachev case MC_SEQ_MISC_TIMING:
5891b843c749SSergey Zigachev *out_reg = MC_SEQ_MISC_TIMING_LP;
5892b843c749SSergey Zigachev break;
5893b843c749SSergey Zigachev case MC_SEQ_MISC_TIMING2:
5894b843c749SSergey Zigachev *out_reg = MC_SEQ_MISC_TIMING2_LP;
5895b843c749SSergey Zigachev break;
5896b843c749SSergey Zigachev case MC_SEQ_RD_CTL_D0:
5897b843c749SSergey Zigachev *out_reg = MC_SEQ_RD_CTL_D0_LP;
5898b843c749SSergey Zigachev break;
5899b843c749SSergey Zigachev case MC_SEQ_RD_CTL_D1:
5900b843c749SSergey Zigachev *out_reg = MC_SEQ_RD_CTL_D1_LP;
5901b843c749SSergey Zigachev break;
5902b843c749SSergey Zigachev case MC_SEQ_WR_CTL_D0:
5903b843c749SSergey Zigachev *out_reg = MC_SEQ_WR_CTL_D0_LP;
5904b843c749SSergey Zigachev break;
5905b843c749SSergey Zigachev case MC_SEQ_WR_CTL_D1:
5906b843c749SSergey Zigachev *out_reg = MC_SEQ_WR_CTL_D1_LP;
5907b843c749SSergey Zigachev break;
5908b843c749SSergey Zigachev case MC_PMG_CMD_EMRS:
5909b843c749SSergey Zigachev *out_reg = MC_SEQ_PMG_CMD_EMRS_LP;
5910b843c749SSergey Zigachev break;
5911b843c749SSergey Zigachev case MC_PMG_CMD_MRS:
5912b843c749SSergey Zigachev *out_reg = MC_SEQ_PMG_CMD_MRS_LP;
5913b843c749SSergey Zigachev break;
5914b843c749SSergey Zigachev case MC_PMG_CMD_MRS1:
5915b843c749SSergey Zigachev *out_reg = MC_SEQ_PMG_CMD_MRS1_LP;
5916b843c749SSergey Zigachev break;
5917b843c749SSergey Zigachev case MC_SEQ_PMG_TIMING:
5918b843c749SSergey Zigachev *out_reg = MC_SEQ_PMG_TIMING_LP;
5919b843c749SSergey Zigachev break;
5920b843c749SSergey Zigachev case MC_PMG_CMD_MRS2:
5921b843c749SSergey Zigachev *out_reg = MC_SEQ_PMG_CMD_MRS2_LP;
5922b843c749SSergey Zigachev break;
5923b843c749SSergey Zigachev case MC_SEQ_WR_CTL_2:
5924b843c749SSergey Zigachev *out_reg = MC_SEQ_WR_CTL_2_LP;
5925b843c749SSergey Zigachev break;
5926b843c749SSergey Zigachev default:
5927b843c749SSergey Zigachev result = false;
5928b843c749SSergey Zigachev break;
5929b843c749SSergey Zigachev }
5930b843c749SSergey Zigachev
5931b843c749SSergey Zigachev return result;
5932b843c749SSergey Zigachev }
5933b843c749SSergey Zigachev
si_set_valid_flag(struct si_mc_reg_table * table)5934b843c749SSergey Zigachev static void si_set_valid_flag(struct si_mc_reg_table *table)
5935b843c749SSergey Zigachev {
5936b843c749SSergey Zigachev u8 i, j;
5937b843c749SSergey Zigachev
5938b843c749SSergey Zigachev for (i = 0; i < table->last; i++) {
5939b843c749SSergey Zigachev for (j = 1; j < table->num_entries; j++) {
5940b843c749SSergey Zigachev if (table->mc_reg_table_entry[j-1].mc_data[i] != table->mc_reg_table_entry[j].mc_data[i]) {
5941b843c749SSergey Zigachev table->valid_flag |= 1 << i;
5942b843c749SSergey Zigachev break;
5943b843c749SSergey Zigachev }
5944b843c749SSergey Zigachev }
5945b843c749SSergey Zigachev }
5946b843c749SSergey Zigachev }
5947b843c749SSergey Zigachev
si_set_s0_mc_reg_index(struct si_mc_reg_table * table)5948b843c749SSergey Zigachev static void si_set_s0_mc_reg_index(struct si_mc_reg_table *table)
5949b843c749SSergey Zigachev {
5950b843c749SSergey Zigachev u32 i;
5951b843c749SSergey Zigachev u16 address;
5952b843c749SSergey Zigachev
5953b843c749SSergey Zigachev for (i = 0; i < table->last; i++)
5954b843c749SSergey Zigachev table->mc_reg_address[i].s0 = si_check_s0_mc_reg_index(table->mc_reg_address[i].s1, &address) ?
5955b843c749SSergey Zigachev address : table->mc_reg_address[i].s1;
5956b843c749SSergey Zigachev
5957b843c749SSergey Zigachev }
5958b843c749SSergey Zigachev
si_copy_vbios_mc_reg_table(struct atom_mc_reg_table * table,struct si_mc_reg_table * si_table)5959b843c749SSergey Zigachev static int si_copy_vbios_mc_reg_table(struct atom_mc_reg_table *table,
5960b843c749SSergey Zigachev struct si_mc_reg_table *si_table)
5961b843c749SSergey Zigachev {
5962b843c749SSergey Zigachev u8 i, j;
5963b843c749SSergey Zigachev
5964b843c749SSergey Zigachev if (table->last > SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
5965b843c749SSergey Zigachev return -EINVAL;
5966b843c749SSergey Zigachev if (table->num_entries > MAX_AC_TIMING_ENTRIES)
5967b843c749SSergey Zigachev return -EINVAL;
5968b843c749SSergey Zigachev
5969b843c749SSergey Zigachev for (i = 0; i < table->last; i++)
5970b843c749SSergey Zigachev si_table->mc_reg_address[i].s1 = table->mc_reg_address[i].s1;
5971b843c749SSergey Zigachev si_table->last = table->last;
5972b843c749SSergey Zigachev
5973b843c749SSergey Zigachev for (i = 0; i < table->num_entries; i++) {
5974b843c749SSergey Zigachev si_table->mc_reg_table_entry[i].mclk_max =
5975b843c749SSergey Zigachev table->mc_reg_table_entry[i].mclk_max;
5976b843c749SSergey Zigachev for (j = 0; j < table->last; j++) {
5977b843c749SSergey Zigachev si_table->mc_reg_table_entry[i].mc_data[j] =
5978b843c749SSergey Zigachev table->mc_reg_table_entry[i].mc_data[j];
5979b843c749SSergey Zigachev }
5980b843c749SSergey Zigachev }
5981b843c749SSergey Zigachev si_table->num_entries = table->num_entries;
5982b843c749SSergey Zigachev
5983b843c749SSergey Zigachev return 0;
5984b843c749SSergey Zigachev }
5985b843c749SSergey Zigachev
si_initialize_mc_reg_table(struct amdgpu_device * adev)5986b843c749SSergey Zigachev static int si_initialize_mc_reg_table(struct amdgpu_device *adev)
5987b843c749SSergey Zigachev {
5988b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
5989b843c749SSergey Zigachev struct atom_mc_reg_table *table;
5990b843c749SSergey Zigachev struct si_mc_reg_table *si_table = &si_pi->mc_reg_table;
5991b843c749SSergey Zigachev u8 module_index = rv770_get_memory_module_index(adev);
5992b843c749SSergey Zigachev int ret;
5993b843c749SSergey Zigachev
5994b843c749SSergey Zigachev table = kzalloc(sizeof(struct atom_mc_reg_table), GFP_KERNEL);
5995b843c749SSergey Zigachev if (!table)
5996b843c749SSergey Zigachev return -ENOMEM;
5997b843c749SSergey Zigachev
5998b843c749SSergey Zigachev WREG32(MC_SEQ_RAS_TIMING_LP, RREG32(MC_SEQ_RAS_TIMING));
5999b843c749SSergey Zigachev WREG32(MC_SEQ_CAS_TIMING_LP, RREG32(MC_SEQ_CAS_TIMING));
6000b843c749SSergey Zigachev WREG32(MC_SEQ_MISC_TIMING_LP, RREG32(MC_SEQ_MISC_TIMING));
6001b843c749SSergey Zigachev WREG32(MC_SEQ_MISC_TIMING2_LP, RREG32(MC_SEQ_MISC_TIMING2));
6002b843c749SSergey Zigachev WREG32(MC_SEQ_PMG_CMD_EMRS_LP, RREG32(MC_PMG_CMD_EMRS));
6003b843c749SSergey Zigachev WREG32(MC_SEQ_PMG_CMD_MRS_LP, RREG32(MC_PMG_CMD_MRS));
6004b843c749SSergey Zigachev WREG32(MC_SEQ_PMG_CMD_MRS1_LP, RREG32(MC_PMG_CMD_MRS1));
6005b843c749SSergey Zigachev WREG32(MC_SEQ_WR_CTL_D0_LP, RREG32(MC_SEQ_WR_CTL_D0));
6006b843c749SSergey Zigachev WREG32(MC_SEQ_WR_CTL_D1_LP, RREG32(MC_SEQ_WR_CTL_D1));
6007b843c749SSergey Zigachev WREG32(MC_SEQ_RD_CTL_D0_LP, RREG32(MC_SEQ_RD_CTL_D0));
6008b843c749SSergey Zigachev WREG32(MC_SEQ_RD_CTL_D1_LP, RREG32(MC_SEQ_RD_CTL_D1));
6009b843c749SSergey Zigachev WREG32(MC_SEQ_PMG_TIMING_LP, RREG32(MC_SEQ_PMG_TIMING));
6010b843c749SSergey Zigachev WREG32(MC_SEQ_PMG_CMD_MRS2_LP, RREG32(MC_PMG_CMD_MRS2));
6011b843c749SSergey Zigachev WREG32(MC_SEQ_WR_CTL_2_LP, RREG32(MC_SEQ_WR_CTL_2));
6012b843c749SSergey Zigachev
6013b843c749SSergey Zigachev ret = amdgpu_atombios_init_mc_reg_table(adev, module_index, table);
6014b843c749SSergey Zigachev if (ret)
6015b843c749SSergey Zigachev goto init_mc_done;
6016b843c749SSergey Zigachev
6017b843c749SSergey Zigachev ret = si_copy_vbios_mc_reg_table(table, si_table);
6018b843c749SSergey Zigachev if (ret)
6019b843c749SSergey Zigachev goto init_mc_done;
6020b843c749SSergey Zigachev
6021b843c749SSergey Zigachev si_set_s0_mc_reg_index(si_table);
6022b843c749SSergey Zigachev
6023b843c749SSergey Zigachev ret = si_set_mc_special_registers(adev, si_table);
6024b843c749SSergey Zigachev if (ret)
6025b843c749SSergey Zigachev goto init_mc_done;
6026b843c749SSergey Zigachev
6027b843c749SSergey Zigachev si_set_valid_flag(si_table);
6028b843c749SSergey Zigachev
6029b843c749SSergey Zigachev init_mc_done:
6030b843c749SSergey Zigachev kfree(table);
6031b843c749SSergey Zigachev
6032b843c749SSergey Zigachev return ret;
6033b843c749SSergey Zigachev
6034b843c749SSergey Zigachev }
6035b843c749SSergey Zigachev
si_populate_mc_reg_addresses(struct amdgpu_device * adev,SMC_SIslands_MCRegisters * mc_reg_table)6036b843c749SSergey Zigachev static void si_populate_mc_reg_addresses(struct amdgpu_device *adev,
6037b843c749SSergey Zigachev SMC_SIslands_MCRegisters *mc_reg_table)
6038b843c749SSergey Zigachev {
6039b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6040b843c749SSergey Zigachev u32 i, j;
6041b843c749SSergey Zigachev
6042b843c749SSergey Zigachev for (i = 0, j = 0; j < si_pi->mc_reg_table.last; j++) {
6043b843c749SSergey Zigachev if (si_pi->mc_reg_table.valid_flag & (1 << j)) {
6044b843c749SSergey Zigachev if (i >= SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE)
6045b843c749SSergey Zigachev break;
6046b843c749SSergey Zigachev mc_reg_table->address[i].s0 =
6047b843c749SSergey Zigachev cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s0);
6048b843c749SSergey Zigachev mc_reg_table->address[i].s1 =
6049b843c749SSergey Zigachev cpu_to_be16(si_pi->mc_reg_table.mc_reg_address[j].s1);
6050b843c749SSergey Zigachev i++;
6051b843c749SSergey Zigachev }
6052b843c749SSergey Zigachev }
6053b843c749SSergey Zigachev mc_reg_table->last = (u8)i;
6054b843c749SSergey Zigachev }
6055b843c749SSergey Zigachev
si_convert_mc_registers(const struct si_mc_reg_entry * entry,SMC_SIslands_MCRegisterSet * data,u32 num_entries,u32 valid_flag)6056b843c749SSergey Zigachev static void si_convert_mc_registers(const struct si_mc_reg_entry *entry,
6057b843c749SSergey Zigachev SMC_SIslands_MCRegisterSet *data,
6058b843c749SSergey Zigachev u32 num_entries, u32 valid_flag)
6059b843c749SSergey Zigachev {
6060b843c749SSergey Zigachev u32 i, j;
6061b843c749SSergey Zigachev
6062b843c749SSergey Zigachev for(i = 0, j = 0; j < num_entries; j++) {
6063b843c749SSergey Zigachev if (valid_flag & (1 << j)) {
6064b843c749SSergey Zigachev data->value[i] = cpu_to_be32(entry->mc_data[j]);
6065b843c749SSergey Zigachev i++;
6066b843c749SSergey Zigachev }
6067b843c749SSergey Zigachev }
6068b843c749SSergey Zigachev }
6069b843c749SSergey Zigachev
si_convert_mc_reg_table_entry_to_smc(struct amdgpu_device * adev,struct rv7xx_pl * pl,SMC_SIslands_MCRegisterSet * mc_reg_table_data)6070b843c749SSergey Zigachev static void si_convert_mc_reg_table_entry_to_smc(struct amdgpu_device *adev,
6071b843c749SSergey Zigachev struct rv7xx_pl *pl,
6072b843c749SSergey Zigachev SMC_SIslands_MCRegisterSet *mc_reg_table_data)
6073b843c749SSergey Zigachev {
6074b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6075b843c749SSergey Zigachev u32 i = 0;
6076b843c749SSergey Zigachev
6077b843c749SSergey Zigachev for (i = 0; i < si_pi->mc_reg_table.num_entries; i++) {
6078b843c749SSergey Zigachev if (pl->mclk <= si_pi->mc_reg_table.mc_reg_table_entry[i].mclk_max)
6079b843c749SSergey Zigachev break;
6080b843c749SSergey Zigachev }
6081b843c749SSergey Zigachev
6082b843c749SSergey Zigachev if ((i == si_pi->mc_reg_table.num_entries) && (i > 0))
6083b843c749SSergey Zigachev --i;
6084b843c749SSergey Zigachev
6085b843c749SSergey Zigachev si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[i],
6086b843c749SSergey Zigachev mc_reg_table_data, si_pi->mc_reg_table.last,
6087b843c749SSergey Zigachev si_pi->mc_reg_table.valid_flag);
6088b843c749SSergey Zigachev }
6089b843c749SSergey Zigachev
si_convert_mc_reg_table_to_smc(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state,SMC_SIslands_MCRegisters * mc_reg_table)6090b843c749SSergey Zigachev static void si_convert_mc_reg_table_to_smc(struct amdgpu_device *adev,
6091b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state,
6092b843c749SSergey Zigachev SMC_SIslands_MCRegisters *mc_reg_table)
6093b843c749SSergey Zigachev {
6094b843c749SSergey Zigachev struct si_ps *state = si_get_ps(amdgpu_state);
6095b843c749SSergey Zigachev int i;
6096b843c749SSergey Zigachev
6097b843c749SSergey Zigachev for (i = 0; i < state->performance_level_count; i++) {
6098b843c749SSergey Zigachev si_convert_mc_reg_table_entry_to_smc(adev,
6099b843c749SSergey Zigachev &state->performance_levels[i],
6100b843c749SSergey Zigachev &mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT + i]);
6101b843c749SSergey Zigachev }
6102b843c749SSergey Zigachev }
6103b843c749SSergey Zigachev
si_populate_mc_reg_table(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_boot_state)6104b843c749SSergey Zigachev static int si_populate_mc_reg_table(struct amdgpu_device *adev,
6105b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_boot_state)
6106b843c749SSergey Zigachev {
6107b843c749SSergey Zigachev struct si_ps *boot_state = si_get_ps(amdgpu_boot_state);
6108b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6109b843c749SSergey Zigachev struct si_ulv_param *ulv = &si_pi->ulv;
6110b843c749SSergey Zigachev SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table;
6111b843c749SSergey Zigachev
6112b843c749SSergey Zigachev memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters));
6113b843c749SSergey Zigachev
6114b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_seq_index, 1);
6115b843c749SSergey Zigachev
6116b843c749SSergey Zigachev si_populate_mc_reg_addresses(adev, smc_mc_reg_table);
6117b843c749SSergey Zigachev
6118b843c749SSergey Zigachev si_convert_mc_reg_table_entry_to_smc(adev, &boot_state->performance_levels[0],
6119b843c749SSergey Zigachev &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_INITIAL_SLOT]);
6120b843c749SSergey Zigachev
6121b843c749SSergey Zigachev si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0],
6122b843c749SSergey Zigachev &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ACPI_SLOT],
6123b843c749SSergey Zigachev si_pi->mc_reg_table.last,
6124b843c749SSergey Zigachev si_pi->mc_reg_table.valid_flag);
6125b843c749SSergey Zigachev
6126b843c749SSergey Zigachev if (ulv->supported && ulv->pl.vddc != 0)
6127b843c749SSergey Zigachev si_convert_mc_reg_table_entry_to_smc(adev, &ulv->pl,
6128b843c749SSergey Zigachev &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT]);
6129b843c749SSergey Zigachev else
6130b843c749SSergey Zigachev si_convert_mc_registers(&si_pi->mc_reg_table.mc_reg_table_entry[0],
6131b843c749SSergey Zigachev &smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_ULV_SLOT],
6132b843c749SSergey Zigachev si_pi->mc_reg_table.last,
6133b843c749SSergey Zigachev si_pi->mc_reg_table.valid_flag);
6134b843c749SSergey Zigachev
6135b843c749SSergey Zigachev si_convert_mc_reg_table_to_smc(adev, amdgpu_boot_state, smc_mc_reg_table);
6136b843c749SSergey Zigachev
6137b843c749SSergey Zigachev return amdgpu_si_copy_bytes_to_smc(adev, si_pi->mc_reg_table_start,
6138b843c749SSergey Zigachev (u8 *)smc_mc_reg_table,
6139b843c749SSergey Zigachev sizeof(SMC_SIslands_MCRegisters), si_pi->sram_end);
6140b843c749SSergey Zigachev }
6141b843c749SSergey Zigachev
si_upload_mc_reg_table(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state)6142b843c749SSergey Zigachev static int si_upload_mc_reg_table(struct amdgpu_device *adev,
6143b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state)
6144b843c749SSergey Zigachev {
6145b843c749SSergey Zigachev struct si_ps *new_state = si_get_ps(amdgpu_new_state);
6146b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6147b843c749SSergey Zigachev u32 address = si_pi->mc_reg_table_start +
6148b843c749SSergey Zigachev offsetof(SMC_SIslands_MCRegisters,
6149b843c749SSergey Zigachev data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT]);
6150b843c749SSergey Zigachev SMC_SIslands_MCRegisters *smc_mc_reg_table = &si_pi->smc_mc_reg_table;
6151b843c749SSergey Zigachev
6152b843c749SSergey Zigachev memset(smc_mc_reg_table, 0, sizeof(SMC_SIslands_MCRegisters));
6153b843c749SSergey Zigachev
6154b843c749SSergey Zigachev si_convert_mc_reg_table_to_smc(adev, amdgpu_new_state, smc_mc_reg_table);
6155b843c749SSergey Zigachev
6156b843c749SSergey Zigachev return amdgpu_si_copy_bytes_to_smc(adev, address,
6157b843c749SSergey Zigachev (u8 *)&smc_mc_reg_table->data[SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT],
6158b843c749SSergey Zigachev sizeof(SMC_SIslands_MCRegisterSet) * new_state->performance_level_count,
6159b843c749SSergey Zigachev si_pi->sram_end);
6160b843c749SSergey Zigachev }
6161b843c749SSergey Zigachev
si_enable_voltage_control(struct amdgpu_device * adev,bool enable)6162b843c749SSergey Zigachev static void si_enable_voltage_control(struct amdgpu_device *adev, bool enable)
6163b843c749SSergey Zigachev {
6164b843c749SSergey Zigachev if (enable)
6165b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, VOLT_PWRMGT_EN, ~VOLT_PWRMGT_EN);
6166b843c749SSergey Zigachev else
6167b843c749SSergey Zigachev WREG32_P(GENERAL_PWRMGT, 0, ~VOLT_PWRMGT_EN);
6168b843c749SSergey Zigachev }
6169b843c749SSergey Zigachev
si_get_maximum_link_speed(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_state)6170b843c749SSergey Zigachev static enum amdgpu_pcie_gen si_get_maximum_link_speed(struct amdgpu_device *adev,
6171b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_state)
6172b843c749SSergey Zigachev {
6173b843c749SSergey Zigachev struct si_ps *state = si_get_ps(amdgpu_state);
6174b843c749SSergey Zigachev int i;
6175b843c749SSergey Zigachev u16 pcie_speed, max_speed = 0;
6176b843c749SSergey Zigachev
6177b843c749SSergey Zigachev for (i = 0; i < state->performance_level_count; i++) {
6178b843c749SSergey Zigachev pcie_speed = state->performance_levels[i].pcie_gen;
6179b843c749SSergey Zigachev if (max_speed < pcie_speed)
6180b843c749SSergey Zigachev max_speed = pcie_speed;
6181b843c749SSergey Zigachev }
6182b843c749SSergey Zigachev return max_speed;
6183b843c749SSergey Zigachev }
6184b843c749SSergey Zigachev
si_get_current_pcie_speed(struct amdgpu_device * adev)6185b843c749SSergey Zigachev static u16 si_get_current_pcie_speed(struct amdgpu_device *adev)
6186b843c749SSergey Zigachev {
6187b843c749SSergey Zigachev u32 speed_cntl;
6188b843c749SSergey Zigachev
6189b843c749SSergey Zigachev speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL) & LC_CURRENT_DATA_RATE_MASK;
6190b843c749SSergey Zigachev speed_cntl >>= LC_CURRENT_DATA_RATE_SHIFT;
6191b843c749SSergey Zigachev
6192b843c749SSergey Zigachev return (u16)speed_cntl;
6193b843c749SSergey Zigachev }
6194b843c749SSergey Zigachev
si_request_link_speed_change_before_state_change(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state,struct amdgpu_ps * amdgpu_current_state)6195b843c749SSergey Zigachev static void si_request_link_speed_change_before_state_change(struct amdgpu_device *adev,
6196b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state,
6197b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_current_state)
6198b843c749SSergey Zigachev {
6199b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6200b843c749SSergey Zigachev enum amdgpu_pcie_gen target_link_speed = si_get_maximum_link_speed(adev, amdgpu_new_state);
6201b843c749SSergey Zigachev enum amdgpu_pcie_gen current_link_speed;
6202b843c749SSergey Zigachev
6203b843c749SSergey Zigachev if (si_pi->force_pcie_gen == AMDGPU_PCIE_GEN_INVALID)
6204b843c749SSergey Zigachev current_link_speed = si_get_maximum_link_speed(adev, amdgpu_current_state);
6205b843c749SSergey Zigachev else
6206b843c749SSergey Zigachev current_link_speed = si_pi->force_pcie_gen;
6207b843c749SSergey Zigachev
6208b843c749SSergey Zigachev si_pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID;
6209b843c749SSergey Zigachev si_pi->pspp_notify_required = false;
6210b843c749SSergey Zigachev if (target_link_speed > current_link_speed) {
6211b843c749SSergey Zigachev switch (target_link_speed) {
6212b843c749SSergey Zigachev #if defined(CONFIG_ACPI)
6213b843c749SSergey Zigachev case AMDGPU_PCIE_GEN3:
6214b843c749SSergey Zigachev if (amdgpu_acpi_pcie_performance_request(adev, PCIE_PERF_REQ_PECI_GEN3, false) == 0)
6215b843c749SSergey Zigachev break;
6216b843c749SSergey Zigachev si_pi->force_pcie_gen = AMDGPU_PCIE_GEN2;
6217b843c749SSergey Zigachev if (current_link_speed == AMDGPU_PCIE_GEN2)
6218b843c749SSergey Zigachev break;
6219b843c749SSergey Zigachev case AMDGPU_PCIE_GEN2:
6220b843c749SSergey Zigachev if (amdgpu_acpi_pcie_performance_request(adev, PCIE_PERF_REQ_PECI_GEN2, false) == 0)
6221b843c749SSergey Zigachev break;
6222b843c749SSergey Zigachev #endif
6223b843c749SSergey Zigachev default:
6224b843c749SSergey Zigachev si_pi->force_pcie_gen = si_get_current_pcie_speed(adev);
6225b843c749SSergey Zigachev break;
6226b843c749SSergey Zigachev }
6227b843c749SSergey Zigachev } else {
6228b843c749SSergey Zigachev if (target_link_speed < current_link_speed)
6229b843c749SSergey Zigachev si_pi->pspp_notify_required = true;
6230b843c749SSergey Zigachev }
6231b843c749SSergey Zigachev }
6232b843c749SSergey Zigachev
si_notify_link_speed_change_after_state_change(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state,struct amdgpu_ps * amdgpu_current_state)6233b843c749SSergey Zigachev static void si_notify_link_speed_change_after_state_change(struct amdgpu_device *adev,
6234b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state,
6235b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_current_state)
6236b843c749SSergey Zigachev {
6237b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6238b843c749SSergey Zigachev enum amdgpu_pcie_gen target_link_speed = si_get_maximum_link_speed(adev, amdgpu_new_state);
6239b843c749SSergey Zigachev u8 request;
6240b843c749SSergey Zigachev
6241b843c749SSergey Zigachev if (si_pi->pspp_notify_required) {
6242b843c749SSergey Zigachev if (target_link_speed == AMDGPU_PCIE_GEN3)
6243b843c749SSergey Zigachev request = PCIE_PERF_REQ_PECI_GEN3;
6244b843c749SSergey Zigachev else if (target_link_speed == AMDGPU_PCIE_GEN2)
6245b843c749SSergey Zigachev request = PCIE_PERF_REQ_PECI_GEN2;
6246b843c749SSergey Zigachev else
6247b843c749SSergey Zigachev request = PCIE_PERF_REQ_PECI_GEN1;
6248b843c749SSergey Zigachev
6249b843c749SSergey Zigachev if ((request == PCIE_PERF_REQ_PECI_GEN1) &&
6250b843c749SSergey Zigachev (si_get_current_pcie_speed(adev) > 0))
6251b843c749SSergey Zigachev return;
6252b843c749SSergey Zigachev
6253b843c749SSergey Zigachev #if defined(CONFIG_ACPI)
6254b843c749SSergey Zigachev amdgpu_acpi_pcie_performance_request(adev, request, false);
6255b843c749SSergey Zigachev #endif
6256b843c749SSergey Zigachev }
6257b843c749SSergey Zigachev }
6258b843c749SSergey Zigachev
6259b843c749SSergey Zigachev #if 0
6260b843c749SSergey Zigachev static int si_ds_request(struct amdgpu_device *adev,
6261b843c749SSergey Zigachev bool ds_status_on, u32 count_write)
6262b843c749SSergey Zigachev {
6263b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
6264b843c749SSergey Zigachev
6265b843c749SSergey Zigachev if (eg_pi->sclk_deep_sleep) {
6266b843c749SSergey Zigachev if (ds_status_on)
6267b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_CancelThrottleOVRDSCLKDS) ==
6268b843c749SSergey Zigachev PPSMC_Result_OK) ?
6269b843c749SSergey Zigachev 0 : -EINVAL;
6270b843c749SSergey Zigachev else
6271b843c749SSergey Zigachev return (amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_ThrottleOVRDSCLKDS) ==
6272b843c749SSergey Zigachev PPSMC_Result_OK) ? 0 : -EINVAL;
6273b843c749SSergey Zigachev }
6274b843c749SSergey Zigachev return 0;
6275b843c749SSergey Zigachev }
6276b843c749SSergey Zigachev #endif
6277b843c749SSergey Zigachev
si_set_max_cu_value(struct amdgpu_device * adev)6278b843c749SSergey Zigachev static void si_set_max_cu_value(struct amdgpu_device *adev)
6279b843c749SSergey Zigachev {
6280b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6281b843c749SSergey Zigachev
6282b843c749SSergey Zigachev if (adev->asic_type == CHIP_VERDE) {
6283b843c749SSergey Zigachev switch (adev->pdev->device) {
6284b843c749SSergey Zigachev case 0x6820:
6285b843c749SSergey Zigachev case 0x6825:
6286b843c749SSergey Zigachev case 0x6821:
6287b843c749SSergey Zigachev case 0x6823:
6288b843c749SSergey Zigachev case 0x6827:
6289b843c749SSergey Zigachev si_pi->max_cu = 10;
6290b843c749SSergey Zigachev break;
6291b843c749SSergey Zigachev case 0x682D:
6292b843c749SSergey Zigachev case 0x6824:
6293b843c749SSergey Zigachev case 0x682F:
6294b843c749SSergey Zigachev case 0x6826:
6295b843c749SSergey Zigachev si_pi->max_cu = 8;
6296b843c749SSergey Zigachev break;
6297b843c749SSergey Zigachev case 0x6828:
6298b843c749SSergey Zigachev case 0x6830:
6299b843c749SSergey Zigachev case 0x6831:
6300b843c749SSergey Zigachev case 0x6838:
6301b843c749SSergey Zigachev case 0x6839:
6302b843c749SSergey Zigachev case 0x683D:
6303b843c749SSergey Zigachev si_pi->max_cu = 10;
6304b843c749SSergey Zigachev break;
6305b843c749SSergey Zigachev case 0x683B:
6306b843c749SSergey Zigachev case 0x683F:
6307b843c749SSergey Zigachev case 0x6829:
6308b843c749SSergey Zigachev si_pi->max_cu = 8;
6309b843c749SSergey Zigachev break;
6310b843c749SSergey Zigachev default:
6311b843c749SSergey Zigachev si_pi->max_cu = 0;
6312b843c749SSergey Zigachev break;
6313b843c749SSergey Zigachev }
6314b843c749SSergey Zigachev } else {
6315b843c749SSergey Zigachev si_pi->max_cu = 0;
6316b843c749SSergey Zigachev }
6317b843c749SSergey Zigachev }
6318b843c749SSergey Zigachev
si_patch_single_dependency_table_based_on_leakage(struct amdgpu_device * adev,struct amdgpu_clock_voltage_dependency_table * table)6319b843c749SSergey Zigachev static int si_patch_single_dependency_table_based_on_leakage(struct amdgpu_device *adev,
6320b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table *table)
6321b843c749SSergey Zigachev {
6322b843c749SSergey Zigachev u32 i;
6323b843c749SSergey Zigachev int j;
6324b843c749SSergey Zigachev u16 leakage_voltage;
6325b843c749SSergey Zigachev
6326b843c749SSergey Zigachev if (table) {
6327b843c749SSergey Zigachev for (i = 0; i < table->count; i++) {
6328b843c749SSergey Zigachev switch (si_get_leakage_voltage_from_leakage_index(adev,
6329b843c749SSergey Zigachev table->entries[i].v,
6330b843c749SSergey Zigachev &leakage_voltage)) {
6331b843c749SSergey Zigachev case 0:
6332b843c749SSergey Zigachev table->entries[i].v = leakage_voltage;
6333b843c749SSergey Zigachev break;
6334b843c749SSergey Zigachev case -EAGAIN:
6335b843c749SSergey Zigachev return -EINVAL;
6336b843c749SSergey Zigachev case -EINVAL:
6337b843c749SSergey Zigachev default:
6338b843c749SSergey Zigachev break;
6339b843c749SSergey Zigachev }
6340b843c749SSergey Zigachev }
6341b843c749SSergey Zigachev
6342b843c749SSergey Zigachev for (j = (table->count - 2); j >= 0; j--) {
6343b843c749SSergey Zigachev table->entries[j].v = (table->entries[j].v <= table->entries[j + 1].v) ?
6344b843c749SSergey Zigachev table->entries[j].v : table->entries[j + 1].v;
6345b843c749SSergey Zigachev }
6346b843c749SSergey Zigachev }
6347b843c749SSergey Zigachev return 0;
6348b843c749SSergey Zigachev }
6349b843c749SSergey Zigachev
si_patch_dependency_tables_based_on_leakage(struct amdgpu_device * adev)6350b843c749SSergey Zigachev static int si_patch_dependency_tables_based_on_leakage(struct amdgpu_device *adev)
6351b843c749SSergey Zigachev {
6352b843c749SSergey Zigachev int ret = 0;
6353b843c749SSergey Zigachev
6354b843c749SSergey Zigachev ret = si_patch_single_dependency_table_based_on_leakage(adev,
6355b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.vddc_dependency_on_sclk);
6356b843c749SSergey Zigachev if (ret)
6357b843c749SSergey Zigachev DRM_ERROR("Could not patch vddc_on_sclk leakage table\n");
6358b843c749SSergey Zigachev ret = si_patch_single_dependency_table_based_on_leakage(adev,
6359b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.vddc_dependency_on_mclk);
6360b843c749SSergey Zigachev if (ret)
6361b843c749SSergey Zigachev DRM_ERROR("Could not patch vddc_on_mclk leakage table\n");
6362b843c749SSergey Zigachev ret = si_patch_single_dependency_table_based_on_leakage(adev,
6363b843c749SSergey Zigachev &adev->pm.dpm.dyn_state.vddci_dependency_on_mclk);
6364b843c749SSergey Zigachev if (ret)
6365b843c749SSergey Zigachev DRM_ERROR("Could not patch vddci_on_mclk leakage table\n");
6366b843c749SSergey Zigachev return ret;
6367b843c749SSergey Zigachev }
6368b843c749SSergey Zigachev
si_set_pcie_lane_width_in_smc(struct amdgpu_device * adev,struct amdgpu_ps * amdgpu_new_state,struct amdgpu_ps * amdgpu_current_state)6369b843c749SSergey Zigachev static void si_set_pcie_lane_width_in_smc(struct amdgpu_device *adev,
6370b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_new_state,
6371b843c749SSergey Zigachev struct amdgpu_ps *amdgpu_current_state)
6372b843c749SSergey Zigachev {
6373b843c749SSergey Zigachev u32 lane_width;
6374b843c749SSergey Zigachev u32 new_lane_width =
6375b843c749SSergey Zigachev ((amdgpu_new_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1;
6376b843c749SSergey Zigachev u32 current_lane_width =
6377b843c749SSergey Zigachev ((amdgpu_current_state->caps & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1;
6378b843c749SSergey Zigachev
6379b843c749SSergey Zigachev if (new_lane_width != current_lane_width) {
6380b843c749SSergey Zigachev amdgpu_set_pcie_lanes(adev, new_lane_width);
6381b843c749SSergey Zigachev lane_width = amdgpu_get_pcie_lanes(adev);
6382b843c749SSergey Zigachev si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width, lane_width);
6383b843c749SSergey Zigachev }
6384b843c749SSergey Zigachev }
6385b843c749SSergey Zigachev
si_dpm_setup_asic(struct amdgpu_device * adev)6386b843c749SSergey Zigachev static void si_dpm_setup_asic(struct amdgpu_device *adev)
6387b843c749SSergey Zigachev {
6388b843c749SSergey Zigachev si_read_clock_registers(adev);
6389b843c749SSergey Zigachev si_enable_acpi_power_management(adev);
6390b843c749SSergey Zigachev }
6391b843c749SSergey Zigachev
si_thermal_enable_alert(struct amdgpu_device * adev,bool enable)6392b843c749SSergey Zigachev static int si_thermal_enable_alert(struct amdgpu_device *adev,
6393b843c749SSergey Zigachev bool enable)
6394b843c749SSergey Zigachev {
6395b843c749SSergey Zigachev u32 thermal_int = RREG32(CG_THERMAL_INT);
6396b843c749SSergey Zigachev
6397b843c749SSergey Zigachev if (enable) {
6398b843c749SSergey Zigachev PPSMC_Result result;
6399b843c749SSergey Zigachev
6400b843c749SSergey Zigachev thermal_int &= ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW);
6401b843c749SSergey Zigachev WREG32(CG_THERMAL_INT, thermal_int);
6402b843c749SSergey Zigachev result = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_EnableThermalInterrupt);
6403b843c749SSergey Zigachev if (result != PPSMC_Result_OK) {
6404b843c749SSergey Zigachev DRM_DEBUG_KMS("Could not enable thermal interrupts.\n");
6405b843c749SSergey Zigachev return -EINVAL;
6406b843c749SSergey Zigachev }
6407b843c749SSergey Zigachev } else {
6408b843c749SSergey Zigachev thermal_int |= THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW;
6409b843c749SSergey Zigachev WREG32(CG_THERMAL_INT, thermal_int);
6410b843c749SSergey Zigachev }
6411b843c749SSergey Zigachev
6412b843c749SSergey Zigachev return 0;
6413b843c749SSergey Zigachev }
6414b843c749SSergey Zigachev
si_thermal_set_temperature_range(struct amdgpu_device * adev,int min_temp,int max_temp)6415b843c749SSergey Zigachev static int si_thermal_set_temperature_range(struct amdgpu_device *adev,
6416b843c749SSergey Zigachev int min_temp, int max_temp)
6417b843c749SSergey Zigachev {
6418b843c749SSergey Zigachev int low_temp = 0 * 1000;
6419b843c749SSergey Zigachev int high_temp = 255 * 1000;
6420b843c749SSergey Zigachev
6421b843c749SSergey Zigachev if (low_temp < min_temp)
6422b843c749SSergey Zigachev low_temp = min_temp;
6423b843c749SSergey Zigachev if (high_temp > max_temp)
6424b843c749SSergey Zigachev high_temp = max_temp;
6425b843c749SSergey Zigachev if (high_temp < low_temp) {
6426b843c749SSergey Zigachev DRM_ERROR("invalid thermal range: %d - %d\n", low_temp, high_temp);
6427b843c749SSergey Zigachev return -EINVAL;
6428b843c749SSergey Zigachev }
6429b843c749SSergey Zigachev
6430b843c749SSergey Zigachev WREG32_P(CG_THERMAL_INT, DIG_THERM_INTH(high_temp / 1000), ~DIG_THERM_INTH_MASK);
6431b843c749SSergey Zigachev WREG32_P(CG_THERMAL_INT, DIG_THERM_INTL(low_temp / 1000), ~DIG_THERM_INTL_MASK);
6432b843c749SSergey Zigachev WREG32_P(CG_THERMAL_CTRL, DIG_THERM_DPM(high_temp / 1000), ~DIG_THERM_DPM_MASK);
6433b843c749SSergey Zigachev
6434b843c749SSergey Zigachev adev->pm.dpm.thermal.min_temp = low_temp;
6435b843c749SSergey Zigachev adev->pm.dpm.thermal.max_temp = high_temp;
6436b843c749SSergey Zigachev
6437b843c749SSergey Zigachev return 0;
6438b843c749SSergey Zigachev }
6439b843c749SSergey Zigachev
si_fan_ctrl_set_static_mode(struct amdgpu_device * adev,u32 mode)6440b843c749SSergey Zigachev static void si_fan_ctrl_set_static_mode(struct amdgpu_device *adev, u32 mode)
6441b843c749SSergey Zigachev {
6442b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6443b843c749SSergey Zigachev u32 tmp;
6444b843c749SSergey Zigachev
6445b843c749SSergey Zigachev if (si_pi->fan_ctrl_is_in_default_mode) {
6446b843c749SSergey Zigachev tmp = (RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK) >> FDO_PWM_MODE_SHIFT;
6447b843c749SSergey Zigachev si_pi->fan_ctrl_default_mode = tmp;
6448b843c749SSergey Zigachev tmp = (RREG32(CG_FDO_CTRL2) & TMIN_MASK) >> TMIN_SHIFT;
6449b843c749SSergey Zigachev si_pi->t_min = tmp;
6450b843c749SSergey Zigachev si_pi->fan_ctrl_is_in_default_mode = false;
6451b843c749SSergey Zigachev }
6452b843c749SSergey Zigachev
6453b843c749SSergey Zigachev tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK;
6454b843c749SSergey Zigachev tmp |= TMIN(0);
6455b843c749SSergey Zigachev WREG32(CG_FDO_CTRL2, tmp);
6456b843c749SSergey Zigachev
6457b843c749SSergey Zigachev tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK;
6458b843c749SSergey Zigachev tmp |= FDO_PWM_MODE(mode);
6459b843c749SSergey Zigachev WREG32(CG_FDO_CTRL2, tmp);
6460b843c749SSergey Zigachev }
6461b843c749SSergey Zigachev
si_thermal_setup_fan_table(struct amdgpu_device * adev)6462b843c749SSergey Zigachev static int si_thermal_setup_fan_table(struct amdgpu_device *adev)
6463b843c749SSergey Zigachev {
6464b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6465b843c749SSergey Zigachev PP_SIslands_FanTable fan_table = { FDO_MODE_HARDWARE };
6466b843c749SSergey Zigachev u32 duty100;
6467b843c749SSergey Zigachev u32 t_diff1, t_diff2, pwm_diff1, pwm_diff2;
6468b843c749SSergey Zigachev u16 fdo_min, slope1, slope2;
6469b843c749SSergey Zigachev u32 reference_clock, tmp;
6470b843c749SSergey Zigachev int ret;
6471b843c749SSergey Zigachev u64 tmp64;
6472b843c749SSergey Zigachev
6473b843c749SSergey Zigachev if (!si_pi->fan_table_start) {
6474b843c749SSergey Zigachev adev->pm.dpm.fan.ucode_fan_control = false;
6475b843c749SSergey Zigachev return 0;
6476b843c749SSergey Zigachev }
6477b843c749SSergey Zigachev
6478b843c749SSergey Zigachev duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
6479b843c749SSergey Zigachev
6480b843c749SSergey Zigachev if (duty100 == 0) {
6481b843c749SSergey Zigachev adev->pm.dpm.fan.ucode_fan_control = false;
6482b843c749SSergey Zigachev return 0;
6483b843c749SSergey Zigachev }
6484b843c749SSergey Zigachev
6485b843c749SSergey Zigachev tmp64 = (u64)adev->pm.dpm.fan.pwm_min * duty100;
6486b843c749SSergey Zigachev do_div(tmp64, 10000);
6487b843c749SSergey Zigachev fdo_min = (u16)tmp64;
6488b843c749SSergey Zigachev
6489b843c749SSergey Zigachev t_diff1 = adev->pm.dpm.fan.t_med - adev->pm.dpm.fan.t_min;
6490b843c749SSergey Zigachev t_diff2 = adev->pm.dpm.fan.t_high - adev->pm.dpm.fan.t_med;
6491b843c749SSergey Zigachev
6492b843c749SSergey Zigachev pwm_diff1 = adev->pm.dpm.fan.pwm_med - adev->pm.dpm.fan.pwm_min;
6493b843c749SSergey Zigachev pwm_diff2 = adev->pm.dpm.fan.pwm_high - adev->pm.dpm.fan.pwm_med;
6494b843c749SSergey Zigachev
6495b843c749SSergey Zigachev slope1 = (u16)((50 + ((16 * duty100 * pwm_diff1) / t_diff1)) / 100);
6496b843c749SSergey Zigachev slope2 = (u16)((50 + ((16 * duty100 * pwm_diff2) / t_diff2)) / 100);
6497b843c749SSergey Zigachev
6498b843c749SSergey Zigachev fan_table.temp_min = cpu_to_be16((50 + adev->pm.dpm.fan.t_min) / 100);
6499b843c749SSergey Zigachev fan_table.temp_med = cpu_to_be16((50 + adev->pm.dpm.fan.t_med) / 100);
6500b843c749SSergey Zigachev fan_table.temp_max = cpu_to_be16((50 + adev->pm.dpm.fan.t_max) / 100);
6501b843c749SSergey Zigachev fan_table.slope1 = cpu_to_be16(slope1);
6502b843c749SSergey Zigachev fan_table.slope2 = cpu_to_be16(slope2);
6503b843c749SSergey Zigachev fan_table.fdo_min = cpu_to_be16(fdo_min);
6504b843c749SSergey Zigachev fan_table.hys_down = cpu_to_be16(adev->pm.dpm.fan.t_hyst);
6505b843c749SSergey Zigachev fan_table.hys_up = cpu_to_be16(1);
6506b843c749SSergey Zigachev fan_table.hys_slope = cpu_to_be16(1);
6507b843c749SSergey Zigachev fan_table.temp_resp_lim = cpu_to_be16(5);
6508b843c749SSergey Zigachev reference_clock = amdgpu_asic_get_xclk(adev);
6509b843c749SSergey Zigachev
6510b843c749SSergey Zigachev fan_table.refresh_period = cpu_to_be32((adev->pm.dpm.fan.cycle_delay *
6511b843c749SSergey Zigachev reference_clock) / 1600);
6512b843c749SSergey Zigachev fan_table.fdo_max = cpu_to_be16((u16)duty100);
6513b843c749SSergey Zigachev
6514b843c749SSergey Zigachev tmp = (RREG32(CG_MULT_THERMAL_CTRL) & TEMP_SEL_MASK) >> TEMP_SEL_SHIFT;
6515b843c749SSergey Zigachev fan_table.temp_src = (uint8_t)tmp;
6516b843c749SSergey Zigachev
6517b843c749SSergey Zigachev ret = amdgpu_si_copy_bytes_to_smc(adev,
6518b843c749SSergey Zigachev si_pi->fan_table_start,
6519b843c749SSergey Zigachev (u8 *)(&fan_table),
6520b843c749SSergey Zigachev sizeof(fan_table),
6521b843c749SSergey Zigachev si_pi->sram_end);
6522b843c749SSergey Zigachev
6523b843c749SSergey Zigachev if (ret) {
6524b843c749SSergey Zigachev DRM_ERROR("Failed to load fan table to the SMC.");
6525b843c749SSergey Zigachev adev->pm.dpm.fan.ucode_fan_control = false;
6526b843c749SSergey Zigachev }
6527b843c749SSergey Zigachev
6528b843c749SSergey Zigachev return ret;
6529b843c749SSergey Zigachev }
6530b843c749SSergey Zigachev
si_fan_ctrl_start_smc_fan_control(struct amdgpu_device * adev)6531b843c749SSergey Zigachev static int si_fan_ctrl_start_smc_fan_control(struct amdgpu_device *adev)
6532b843c749SSergey Zigachev {
6533b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6534b843c749SSergey Zigachev PPSMC_Result ret;
6535b843c749SSergey Zigachev
6536b843c749SSergey Zigachev ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_StartFanControl);
6537b843c749SSergey Zigachev if (ret == PPSMC_Result_OK) {
6538b843c749SSergey Zigachev si_pi->fan_is_controlled_by_smc = true;
6539b843c749SSergey Zigachev return 0;
6540b843c749SSergey Zigachev } else {
6541b843c749SSergey Zigachev return -EINVAL;
6542b843c749SSergey Zigachev }
6543b843c749SSergey Zigachev }
6544b843c749SSergey Zigachev
si_fan_ctrl_stop_smc_fan_control(struct amdgpu_device * adev)6545b843c749SSergey Zigachev static int si_fan_ctrl_stop_smc_fan_control(struct amdgpu_device *adev)
6546b843c749SSergey Zigachev {
6547b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6548b843c749SSergey Zigachev PPSMC_Result ret;
6549b843c749SSergey Zigachev
6550b843c749SSergey Zigachev ret = amdgpu_si_send_msg_to_smc(adev, PPSMC_StopFanControl);
6551b843c749SSergey Zigachev
6552b843c749SSergey Zigachev if (ret == PPSMC_Result_OK) {
6553b843c749SSergey Zigachev si_pi->fan_is_controlled_by_smc = false;
6554b843c749SSergey Zigachev return 0;
6555b843c749SSergey Zigachev } else {
6556b843c749SSergey Zigachev return -EINVAL;
6557b843c749SSergey Zigachev }
6558b843c749SSergey Zigachev }
6559b843c749SSergey Zigachev
si_dpm_get_fan_speed_percent(void * handle,u32 * speed)6560b843c749SSergey Zigachev static int si_dpm_get_fan_speed_percent(void *handle,
6561b843c749SSergey Zigachev u32 *speed)
6562b843c749SSergey Zigachev {
6563b843c749SSergey Zigachev u32 duty, duty100;
6564b843c749SSergey Zigachev u64 tmp64;
6565b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6566b843c749SSergey Zigachev
6567b843c749SSergey Zigachev if (adev->pm.no_fan)
6568b843c749SSergey Zigachev return -ENOENT;
6569b843c749SSergey Zigachev
6570b843c749SSergey Zigachev duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
6571b843c749SSergey Zigachev duty = (RREG32(CG_THERMAL_STATUS) & FDO_PWM_DUTY_MASK) >> FDO_PWM_DUTY_SHIFT;
6572b843c749SSergey Zigachev
6573b843c749SSergey Zigachev if (duty100 == 0)
6574b843c749SSergey Zigachev return -EINVAL;
6575b843c749SSergey Zigachev
6576b843c749SSergey Zigachev tmp64 = (u64)duty * 100;
6577b843c749SSergey Zigachev do_div(tmp64, duty100);
6578b843c749SSergey Zigachev *speed = (u32)tmp64;
6579b843c749SSergey Zigachev
6580b843c749SSergey Zigachev if (*speed > 100)
6581b843c749SSergey Zigachev *speed = 100;
6582b843c749SSergey Zigachev
6583b843c749SSergey Zigachev return 0;
6584b843c749SSergey Zigachev }
6585b843c749SSergey Zigachev
si_dpm_set_fan_speed_percent(void * handle,u32 speed)6586b843c749SSergey Zigachev static int si_dpm_set_fan_speed_percent(void *handle,
6587b843c749SSergey Zigachev u32 speed)
6588b843c749SSergey Zigachev {
6589b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6590b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6591b843c749SSergey Zigachev u32 tmp;
6592b843c749SSergey Zigachev u32 duty, duty100;
6593b843c749SSergey Zigachev u64 tmp64;
6594b843c749SSergey Zigachev
6595b843c749SSergey Zigachev if (adev->pm.no_fan)
6596b843c749SSergey Zigachev return -ENOENT;
6597b843c749SSergey Zigachev
6598b843c749SSergey Zigachev if (si_pi->fan_is_controlled_by_smc)
6599b843c749SSergey Zigachev return -EINVAL;
6600b843c749SSergey Zigachev
6601b843c749SSergey Zigachev if (speed > 100)
6602b843c749SSergey Zigachev return -EINVAL;
6603b843c749SSergey Zigachev
6604b843c749SSergey Zigachev duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
6605b843c749SSergey Zigachev
6606b843c749SSergey Zigachev if (duty100 == 0)
6607b843c749SSergey Zigachev return -EINVAL;
6608b843c749SSergey Zigachev
6609b843c749SSergey Zigachev tmp64 = (u64)speed * duty100;
6610b843c749SSergey Zigachev do_div(tmp64, 100);
6611b843c749SSergey Zigachev duty = (u32)tmp64;
6612b843c749SSergey Zigachev
6613b843c749SSergey Zigachev tmp = RREG32(CG_FDO_CTRL0) & ~FDO_STATIC_DUTY_MASK;
6614b843c749SSergey Zigachev tmp |= FDO_STATIC_DUTY(duty);
6615b843c749SSergey Zigachev WREG32(CG_FDO_CTRL0, tmp);
6616b843c749SSergey Zigachev
6617b843c749SSergey Zigachev return 0;
6618b843c749SSergey Zigachev }
6619b843c749SSergey Zigachev
si_dpm_set_fan_control_mode(void * handle,u32 mode)6620b843c749SSergey Zigachev static void si_dpm_set_fan_control_mode(void *handle, u32 mode)
6621b843c749SSergey Zigachev {
6622b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6623b843c749SSergey Zigachev
6624b843c749SSergey Zigachev if (mode) {
6625b843c749SSergey Zigachev /* stop auto-manage */
6626b843c749SSergey Zigachev if (adev->pm.dpm.fan.ucode_fan_control)
6627b843c749SSergey Zigachev si_fan_ctrl_stop_smc_fan_control(adev);
6628b843c749SSergey Zigachev si_fan_ctrl_set_static_mode(adev, mode);
6629b843c749SSergey Zigachev } else {
6630b843c749SSergey Zigachev /* restart auto-manage */
6631b843c749SSergey Zigachev if (adev->pm.dpm.fan.ucode_fan_control)
6632b843c749SSergey Zigachev si_thermal_start_smc_fan_control(adev);
6633b843c749SSergey Zigachev else
6634b843c749SSergey Zigachev si_fan_ctrl_set_default_mode(adev);
6635b843c749SSergey Zigachev }
6636b843c749SSergey Zigachev }
6637b843c749SSergey Zigachev
si_dpm_get_fan_control_mode(void * handle)6638b843c749SSergey Zigachev static u32 si_dpm_get_fan_control_mode(void *handle)
6639b843c749SSergey Zigachev {
6640b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6641b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6642b843c749SSergey Zigachev u32 tmp;
6643b843c749SSergey Zigachev
6644b843c749SSergey Zigachev if (si_pi->fan_is_controlled_by_smc)
6645b843c749SSergey Zigachev return 0;
6646b843c749SSergey Zigachev
6647b843c749SSergey Zigachev tmp = RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK;
6648b843c749SSergey Zigachev return (tmp >> FDO_PWM_MODE_SHIFT);
6649b843c749SSergey Zigachev }
6650b843c749SSergey Zigachev
6651b843c749SSergey Zigachev #if 0
6652b843c749SSergey Zigachev static int si_fan_ctrl_get_fan_speed_rpm(struct amdgpu_device *adev,
6653b843c749SSergey Zigachev u32 *speed)
6654b843c749SSergey Zigachev {
6655b843c749SSergey Zigachev u32 tach_period;
6656b843c749SSergey Zigachev u32 xclk = amdgpu_asic_get_xclk(adev);
6657b843c749SSergey Zigachev
6658b843c749SSergey Zigachev if (adev->pm.no_fan)
6659b843c749SSergey Zigachev return -ENOENT;
6660b843c749SSergey Zigachev
6661b843c749SSergey Zigachev if (adev->pm.fan_pulses_per_revolution == 0)
6662b843c749SSergey Zigachev return -ENOENT;
6663b843c749SSergey Zigachev
6664b843c749SSergey Zigachev tach_period = (RREG32(CG_TACH_STATUS) & TACH_PERIOD_MASK) >> TACH_PERIOD_SHIFT;
6665b843c749SSergey Zigachev if (tach_period == 0)
6666b843c749SSergey Zigachev return -ENOENT;
6667b843c749SSergey Zigachev
6668b843c749SSergey Zigachev *speed = 60 * xclk * 10000 / tach_period;
6669b843c749SSergey Zigachev
6670b843c749SSergey Zigachev return 0;
6671b843c749SSergey Zigachev }
6672b843c749SSergey Zigachev
6673b843c749SSergey Zigachev static int si_fan_ctrl_set_fan_speed_rpm(struct amdgpu_device *adev,
6674b843c749SSergey Zigachev u32 speed)
6675b843c749SSergey Zigachev {
6676b843c749SSergey Zigachev u32 tach_period, tmp;
6677b843c749SSergey Zigachev u32 xclk = amdgpu_asic_get_xclk(adev);
6678b843c749SSergey Zigachev
6679b843c749SSergey Zigachev if (adev->pm.no_fan)
6680b843c749SSergey Zigachev return -ENOENT;
6681b843c749SSergey Zigachev
6682b843c749SSergey Zigachev if (adev->pm.fan_pulses_per_revolution == 0)
6683b843c749SSergey Zigachev return -ENOENT;
6684b843c749SSergey Zigachev
6685b843c749SSergey Zigachev if ((speed < adev->pm.fan_min_rpm) ||
6686b843c749SSergey Zigachev (speed > adev->pm.fan_max_rpm))
6687b843c749SSergey Zigachev return -EINVAL;
6688b843c749SSergey Zigachev
6689b843c749SSergey Zigachev if (adev->pm.dpm.fan.ucode_fan_control)
6690b843c749SSergey Zigachev si_fan_ctrl_stop_smc_fan_control(adev);
6691b843c749SSergey Zigachev
6692b843c749SSergey Zigachev tach_period = 60 * xclk * 10000 / (8 * speed);
6693b843c749SSergey Zigachev tmp = RREG32(CG_TACH_CTRL) & ~TARGET_PERIOD_MASK;
6694b843c749SSergey Zigachev tmp |= TARGET_PERIOD(tach_period);
6695b843c749SSergey Zigachev WREG32(CG_TACH_CTRL, tmp);
6696b843c749SSergey Zigachev
6697b843c749SSergey Zigachev si_fan_ctrl_set_static_mode(adev, FDO_PWM_MODE_STATIC_RPM);
6698b843c749SSergey Zigachev
6699b843c749SSergey Zigachev return 0;
6700b843c749SSergey Zigachev }
6701b843c749SSergey Zigachev #endif
6702b843c749SSergey Zigachev
si_fan_ctrl_set_default_mode(struct amdgpu_device * adev)6703b843c749SSergey Zigachev static void si_fan_ctrl_set_default_mode(struct amdgpu_device *adev)
6704b843c749SSergey Zigachev {
6705b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6706b843c749SSergey Zigachev u32 tmp;
6707b843c749SSergey Zigachev
6708b843c749SSergey Zigachev if (!si_pi->fan_ctrl_is_in_default_mode) {
6709b843c749SSergey Zigachev tmp = RREG32(CG_FDO_CTRL2) & ~FDO_PWM_MODE_MASK;
6710b843c749SSergey Zigachev tmp |= FDO_PWM_MODE(si_pi->fan_ctrl_default_mode);
6711b843c749SSergey Zigachev WREG32(CG_FDO_CTRL2, tmp);
6712b843c749SSergey Zigachev
6713b843c749SSergey Zigachev tmp = RREG32(CG_FDO_CTRL2) & ~TMIN_MASK;
6714b843c749SSergey Zigachev tmp |= TMIN(si_pi->t_min);
6715b843c749SSergey Zigachev WREG32(CG_FDO_CTRL2, tmp);
6716b843c749SSergey Zigachev si_pi->fan_ctrl_is_in_default_mode = true;
6717b843c749SSergey Zigachev }
6718b843c749SSergey Zigachev }
6719b843c749SSergey Zigachev
si_thermal_start_smc_fan_control(struct amdgpu_device * adev)6720b843c749SSergey Zigachev static void si_thermal_start_smc_fan_control(struct amdgpu_device *adev)
6721b843c749SSergey Zigachev {
6722b843c749SSergey Zigachev if (adev->pm.dpm.fan.ucode_fan_control) {
6723b843c749SSergey Zigachev si_fan_ctrl_start_smc_fan_control(adev);
6724b843c749SSergey Zigachev si_fan_ctrl_set_static_mode(adev, FDO_PWM_MODE_STATIC);
6725b843c749SSergey Zigachev }
6726b843c749SSergey Zigachev }
6727b843c749SSergey Zigachev
si_thermal_initialize(struct amdgpu_device * adev)6728b843c749SSergey Zigachev static void si_thermal_initialize(struct amdgpu_device *adev)
6729b843c749SSergey Zigachev {
6730b843c749SSergey Zigachev u32 tmp;
6731b843c749SSergey Zigachev
6732b843c749SSergey Zigachev if (adev->pm.fan_pulses_per_revolution) {
6733b843c749SSergey Zigachev tmp = RREG32(CG_TACH_CTRL) & ~EDGE_PER_REV_MASK;
6734b843c749SSergey Zigachev tmp |= EDGE_PER_REV(adev->pm.fan_pulses_per_revolution -1);
6735b843c749SSergey Zigachev WREG32(CG_TACH_CTRL, tmp);
6736b843c749SSergey Zigachev }
6737b843c749SSergey Zigachev
6738b843c749SSergey Zigachev tmp = RREG32(CG_FDO_CTRL2) & ~TACH_PWM_RESP_RATE_MASK;
6739b843c749SSergey Zigachev tmp |= TACH_PWM_RESP_RATE(0x28);
6740b843c749SSergey Zigachev WREG32(CG_FDO_CTRL2, tmp);
6741b843c749SSergey Zigachev }
6742b843c749SSergey Zigachev
si_thermal_start_thermal_controller(struct amdgpu_device * adev)6743b843c749SSergey Zigachev static int si_thermal_start_thermal_controller(struct amdgpu_device *adev)
6744b843c749SSergey Zigachev {
6745b843c749SSergey Zigachev int ret;
6746b843c749SSergey Zigachev
6747b843c749SSergey Zigachev si_thermal_initialize(adev);
6748b843c749SSergey Zigachev ret = si_thermal_set_temperature_range(adev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
6749b843c749SSergey Zigachev if (ret)
6750b843c749SSergey Zigachev return ret;
6751b843c749SSergey Zigachev ret = si_thermal_enable_alert(adev, true);
6752b843c749SSergey Zigachev if (ret)
6753b843c749SSergey Zigachev return ret;
6754b843c749SSergey Zigachev if (adev->pm.dpm.fan.ucode_fan_control) {
6755b843c749SSergey Zigachev ret = si_halt_smc(adev);
6756b843c749SSergey Zigachev if (ret)
6757b843c749SSergey Zigachev return ret;
6758b843c749SSergey Zigachev ret = si_thermal_setup_fan_table(adev);
6759b843c749SSergey Zigachev if (ret)
6760b843c749SSergey Zigachev return ret;
6761b843c749SSergey Zigachev ret = si_resume_smc(adev);
6762b843c749SSergey Zigachev if (ret)
6763b843c749SSergey Zigachev return ret;
6764b843c749SSergey Zigachev si_thermal_start_smc_fan_control(adev);
6765b843c749SSergey Zigachev }
6766b843c749SSergey Zigachev
6767b843c749SSergey Zigachev return 0;
6768b843c749SSergey Zigachev }
6769b843c749SSergey Zigachev
si_thermal_stop_thermal_controller(struct amdgpu_device * adev)6770b843c749SSergey Zigachev static void si_thermal_stop_thermal_controller(struct amdgpu_device *adev)
6771b843c749SSergey Zigachev {
6772b843c749SSergey Zigachev if (!adev->pm.no_fan) {
6773b843c749SSergey Zigachev si_fan_ctrl_set_default_mode(adev);
6774b843c749SSergey Zigachev si_fan_ctrl_stop_smc_fan_control(adev);
6775b843c749SSergey Zigachev }
6776b843c749SSergey Zigachev }
6777b843c749SSergey Zigachev
si_dpm_enable(struct amdgpu_device * adev)6778b843c749SSergey Zigachev static int si_dpm_enable(struct amdgpu_device *adev)
6779b843c749SSergey Zigachev {
6780b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
6781b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
6782b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
6783b843c749SSergey Zigachev struct amdgpu_ps *boot_ps = adev->pm.dpm.boot_ps;
6784b843c749SSergey Zigachev int ret;
6785b843c749SSergey Zigachev
6786b843c749SSergey Zigachev if (amdgpu_si_is_smc_running(adev))
6787b843c749SSergey Zigachev return -EINVAL;
6788b843c749SSergey Zigachev if (pi->voltage_control || si_pi->voltage_control_svi2)
6789b843c749SSergey Zigachev si_enable_voltage_control(adev, true);
6790b843c749SSergey Zigachev if (pi->mvdd_control)
6791b843c749SSergey Zigachev si_get_mvdd_configuration(adev);
6792b843c749SSergey Zigachev if (pi->voltage_control || si_pi->voltage_control_svi2) {
6793b843c749SSergey Zigachev ret = si_construct_voltage_tables(adev);
6794b843c749SSergey Zigachev if (ret) {
6795b843c749SSergey Zigachev DRM_ERROR("si_construct_voltage_tables failed\n");
6796b843c749SSergey Zigachev return ret;
6797b843c749SSergey Zigachev }
6798b843c749SSergey Zigachev }
6799b843c749SSergey Zigachev if (eg_pi->dynamic_ac_timing) {
6800b843c749SSergey Zigachev ret = si_initialize_mc_reg_table(adev);
6801b843c749SSergey Zigachev if (ret)
6802b843c749SSergey Zigachev eg_pi->dynamic_ac_timing = false;
6803b843c749SSergey Zigachev }
6804b843c749SSergey Zigachev if (pi->dynamic_ss)
6805b843c749SSergey Zigachev si_enable_spread_spectrum(adev, true);
6806b843c749SSergey Zigachev if (pi->thermal_protection)
6807b843c749SSergey Zigachev si_enable_thermal_protection(adev, true);
6808b843c749SSergey Zigachev si_setup_bsp(adev);
6809b843c749SSergey Zigachev si_program_git(adev);
6810b843c749SSergey Zigachev si_program_tp(adev);
6811b843c749SSergey Zigachev si_program_tpp(adev);
6812b843c749SSergey Zigachev si_program_sstp(adev);
6813b843c749SSergey Zigachev si_enable_display_gap(adev);
6814b843c749SSergey Zigachev si_program_vc(adev);
6815b843c749SSergey Zigachev ret = si_upload_firmware(adev);
6816b843c749SSergey Zigachev if (ret) {
6817b843c749SSergey Zigachev DRM_ERROR("si_upload_firmware failed\n");
6818b843c749SSergey Zigachev return ret;
6819b843c749SSergey Zigachev }
6820b843c749SSergey Zigachev ret = si_process_firmware_header(adev);
6821b843c749SSergey Zigachev if (ret) {
6822b843c749SSergey Zigachev DRM_ERROR("si_process_firmware_header failed\n");
6823b843c749SSergey Zigachev return ret;
6824b843c749SSergey Zigachev }
6825b843c749SSergey Zigachev ret = si_initial_switch_from_arb_f0_to_f1(adev);
6826b843c749SSergey Zigachev if (ret) {
6827b843c749SSergey Zigachev DRM_ERROR("si_initial_switch_from_arb_f0_to_f1 failed\n");
6828b843c749SSergey Zigachev return ret;
6829b843c749SSergey Zigachev }
6830b843c749SSergey Zigachev ret = si_init_smc_table(adev);
6831b843c749SSergey Zigachev if (ret) {
6832b843c749SSergey Zigachev DRM_ERROR("si_init_smc_table failed\n");
6833b843c749SSergey Zigachev return ret;
6834b843c749SSergey Zigachev }
6835b843c749SSergey Zigachev ret = si_init_smc_spll_table(adev);
6836b843c749SSergey Zigachev if (ret) {
6837b843c749SSergey Zigachev DRM_ERROR("si_init_smc_spll_table failed\n");
6838b843c749SSergey Zigachev return ret;
6839b843c749SSergey Zigachev }
6840b843c749SSergey Zigachev ret = si_init_arb_table_index(adev);
6841b843c749SSergey Zigachev if (ret) {
6842b843c749SSergey Zigachev DRM_ERROR("si_init_arb_table_index failed\n");
6843b843c749SSergey Zigachev return ret;
6844b843c749SSergey Zigachev }
6845b843c749SSergey Zigachev if (eg_pi->dynamic_ac_timing) {
6846b843c749SSergey Zigachev ret = si_populate_mc_reg_table(adev, boot_ps);
6847b843c749SSergey Zigachev if (ret) {
6848b843c749SSergey Zigachev DRM_ERROR("si_populate_mc_reg_table failed\n");
6849b843c749SSergey Zigachev return ret;
6850b843c749SSergey Zigachev }
6851b843c749SSergey Zigachev }
6852b843c749SSergey Zigachev ret = si_initialize_smc_cac_tables(adev);
6853b843c749SSergey Zigachev if (ret) {
6854b843c749SSergey Zigachev DRM_ERROR("si_initialize_smc_cac_tables failed\n");
6855b843c749SSergey Zigachev return ret;
6856b843c749SSergey Zigachev }
6857b843c749SSergey Zigachev ret = si_initialize_hardware_cac_manager(adev);
6858b843c749SSergey Zigachev if (ret) {
6859b843c749SSergey Zigachev DRM_ERROR("si_initialize_hardware_cac_manager failed\n");
6860b843c749SSergey Zigachev return ret;
6861b843c749SSergey Zigachev }
6862b843c749SSergey Zigachev ret = si_initialize_smc_dte_tables(adev);
6863b843c749SSergey Zigachev if (ret) {
6864b843c749SSergey Zigachev DRM_ERROR("si_initialize_smc_dte_tables failed\n");
6865b843c749SSergey Zigachev return ret;
6866b843c749SSergey Zigachev }
6867b843c749SSergey Zigachev ret = si_populate_smc_tdp_limits(adev, boot_ps);
6868b843c749SSergey Zigachev if (ret) {
6869b843c749SSergey Zigachev DRM_ERROR("si_populate_smc_tdp_limits failed\n");
6870b843c749SSergey Zigachev return ret;
6871b843c749SSergey Zigachev }
6872b843c749SSergey Zigachev ret = si_populate_smc_tdp_limits_2(adev, boot_ps);
6873b843c749SSergey Zigachev if (ret) {
6874b843c749SSergey Zigachev DRM_ERROR("si_populate_smc_tdp_limits_2 failed\n");
6875b843c749SSergey Zigachev return ret;
6876b843c749SSergey Zigachev }
6877b843c749SSergey Zigachev si_program_response_times(adev);
6878b843c749SSergey Zigachev si_program_ds_registers(adev);
6879b843c749SSergey Zigachev si_dpm_start_smc(adev);
6880b843c749SSergey Zigachev ret = si_notify_smc_display_change(adev, false);
6881b843c749SSergey Zigachev if (ret) {
6882b843c749SSergey Zigachev DRM_ERROR("si_notify_smc_display_change failed\n");
6883b843c749SSergey Zigachev return ret;
6884b843c749SSergey Zigachev }
6885b843c749SSergey Zigachev si_enable_sclk_control(adev, true);
6886b843c749SSergey Zigachev si_start_dpm(adev);
6887b843c749SSergey Zigachev
6888b843c749SSergey Zigachev si_enable_auto_throttle_source(adev, AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
6889b843c749SSergey Zigachev si_thermal_start_thermal_controller(adev);
6890b843c749SSergey Zigachev
6891b843c749SSergey Zigachev return 0;
6892b843c749SSergey Zigachev }
6893b843c749SSergey Zigachev
si_set_temperature_range(struct amdgpu_device * adev)6894b843c749SSergey Zigachev static int si_set_temperature_range(struct amdgpu_device *adev)
6895b843c749SSergey Zigachev {
6896b843c749SSergey Zigachev int ret;
6897b843c749SSergey Zigachev
6898b843c749SSergey Zigachev ret = si_thermal_enable_alert(adev, false);
6899b843c749SSergey Zigachev if (ret)
6900b843c749SSergey Zigachev return ret;
6901b843c749SSergey Zigachev ret = si_thermal_set_temperature_range(adev, R600_TEMP_RANGE_MIN, R600_TEMP_RANGE_MAX);
6902b843c749SSergey Zigachev if (ret)
6903b843c749SSergey Zigachev return ret;
6904b843c749SSergey Zigachev ret = si_thermal_enable_alert(adev, true);
6905b843c749SSergey Zigachev if (ret)
6906b843c749SSergey Zigachev return ret;
6907b843c749SSergey Zigachev
6908b843c749SSergey Zigachev return ret;
6909b843c749SSergey Zigachev }
6910b843c749SSergey Zigachev
si_dpm_disable(struct amdgpu_device * adev)6911b843c749SSergey Zigachev static void si_dpm_disable(struct amdgpu_device *adev)
6912b843c749SSergey Zigachev {
6913b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
6914b843c749SSergey Zigachev struct amdgpu_ps *boot_ps = adev->pm.dpm.boot_ps;
6915b843c749SSergey Zigachev
6916b843c749SSergey Zigachev if (!amdgpu_si_is_smc_running(adev))
6917b843c749SSergey Zigachev return;
6918b843c749SSergey Zigachev si_thermal_stop_thermal_controller(adev);
6919b843c749SSergey Zigachev si_disable_ulv(adev);
6920b843c749SSergey Zigachev si_clear_vc(adev);
6921b843c749SSergey Zigachev if (pi->thermal_protection)
6922b843c749SSergey Zigachev si_enable_thermal_protection(adev, false);
6923b843c749SSergey Zigachev si_enable_power_containment(adev, boot_ps, false);
6924b843c749SSergey Zigachev si_enable_smc_cac(adev, boot_ps, false);
6925b843c749SSergey Zigachev si_enable_spread_spectrum(adev, false);
6926b843c749SSergey Zigachev si_enable_auto_throttle_source(adev, AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, false);
6927b843c749SSergey Zigachev si_stop_dpm(adev);
6928b843c749SSergey Zigachev si_reset_to_default(adev);
6929b843c749SSergey Zigachev si_dpm_stop_smc(adev);
6930b843c749SSergey Zigachev si_force_switch_to_arb_f0(adev);
6931b843c749SSergey Zigachev
6932b843c749SSergey Zigachev ni_update_current_ps(adev, boot_ps);
6933b843c749SSergey Zigachev }
6934b843c749SSergey Zigachev
si_dpm_pre_set_power_state(void * handle)6935b843c749SSergey Zigachev static int si_dpm_pre_set_power_state(void *handle)
6936b843c749SSergey Zigachev {
6937b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6938b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
6939b843c749SSergey Zigachev struct amdgpu_ps requested_ps = *adev->pm.dpm.requested_ps;
6940b843c749SSergey Zigachev struct amdgpu_ps *new_ps = &requested_ps;
6941b843c749SSergey Zigachev
6942b843c749SSergey Zigachev ni_update_requested_ps(adev, new_ps);
6943b843c749SSergey Zigachev si_apply_state_adjust_rules(adev, &eg_pi->requested_rps);
6944b843c749SSergey Zigachev
6945b843c749SSergey Zigachev return 0;
6946b843c749SSergey Zigachev }
6947b843c749SSergey Zigachev
si_power_control_set_level(struct amdgpu_device * adev)6948b843c749SSergey Zigachev static int si_power_control_set_level(struct amdgpu_device *adev)
6949b843c749SSergey Zigachev {
6950b843c749SSergey Zigachev struct amdgpu_ps *new_ps = adev->pm.dpm.requested_ps;
6951b843c749SSergey Zigachev int ret;
6952b843c749SSergey Zigachev
6953b843c749SSergey Zigachev ret = si_restrict_performance_levels_before_switch(adev);
6954b843c749SSergey Zigachev if (ret)
6955b843c749SSergey Zigachev return ret;
6956b843c749SSergey Zigachev ret = si_halt_smc(adev);
6957b843c749SSergey Zigachev if (ret)
6958b843c749SSergey Zigachev return ret;
6959b843c749SSergey Zigachev ret = si_populate_smc_tdp_limits(adev, new_ps);
6960b843c749SSergey Zigachev if (ret)
6961b843c749SSergey Zigachev return ret;
6962b843c749SSergey Zigachev ret = si_populate_smc_tdp_limits_2(adev, new_ps);
6963b843c749SSergey Zigachev if (ret)
6964b843c749SSergey Zigachev return ret;
6965b843c749SSergey Zigachev ret = si_resume_smc(adev);
6966b843c749SSergey Zigachev if (ret)
6967b843c749SSergey Zigachev return ret;
6968b843c749SSergey Zigachev ret = si_set_sw_state(adev);
6969b843c749SSergey Zigachev if (ret)
6970b843c749SSergey Zigachev return ret;
6971b843c749SSergey Zigachev return 0;
6972b843c749SSergey Zigachev }
6973b843c749SSergey Zigachev
si_dpm_set_power_state(void * handle)6974b843c749SSergey Zigachev static int si_dpm_set_power_state(void *handle)
6975b843c749SSergey Zigachev {
6976b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
6977b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
6978b843c749SSergey Zigachev struct amdgpu_ps *new_ps = &eg_pi->requested_rps;
6979b843c749SSergey Zigachev struct amdgpu_ps *old_ps = &eg_pi->current_rps;
6980b843c749SSergey Zigachev int ret;
6981b843c749SSergey Zigachev
6982b843c749SSergey Zigachev ret = si_disable_ulv(adev);
6983b843c749SSergey Zigachev if (ret) {
6984b843c749SSergey Zigachev DRM_ERROR("si_disable_ulv failed\n");
6985b843c749SSergey Zigachev return ret;
6986b843c749SSergey Zigachev }
6987b843c749SSergey Zigachev ret = si_restrict_performance_levels_before_switch(adev);
6988b843c749SSergey Zigachev if (ret) {
6989b843c749SSergey Zigachev DRM_ERROR("si_restrict_performance_levels_before_switch failed\n");
6990b843c749SSergey Zigachev return ret;
6991b843c749SSergey Zigachev }
6992b843c749SSergey Zigachev if (eg_pi->pcie_performance_request)
6993b843c749SSergey Zigachev si_request_link_speed_change_before_state_change(adev, new_ps, old_ps);
6994b843c749SSergey Zigachev ni_set_uvd_clock_before_set_eng_clock(adev, new_ps, old_ps);
6995b843c749SSergey Zigachev ret = si_enable_power_containment(adev, new_ps, false);
6996b843c749SSergey Zigachev if (ret) {
6997b843c749SSergey Zigachev DRM_ERROR("si_enable_power_containment failed\n");
6998b843c749SSergey Zigachev return ret;
6999b843c749SSergey Zigachev }
7000b843c749SSergey Zigachev ret = si_enable_smc_cac(adev, new_ps, false);
7001b843c749SSergey Zigachev if (ret) {
7002b843c749SSergey Zigachev DRM_ERROR("si_enable_smc_cac failed\n");
7003b843c749SSergey Zigachev return ret;
7004b843c749SSergey Zigachev }
7005b843c749SSergey Zigachev ret = si_halt_smc(adev);
7006b843c749SSergey Zigachev if (ret) {
7007b843c749SSergey Zigachev DRM_ERROR("si_halt_smc failed\n");
7008b843c749SSergey Zigachev return ret;
7009b843c749SSergey Zigachev }
7010b843c749SSergey Zigachev ret = si_upload_sw_state(adev, new_ps);
7011b843c749SSergey Zigachev if (ret) {
7012b843c749SSergey Zigachev DRM_ERROR("si_upload_sw_state failed\n");
7013b843c749SSergey Zigachev return ret;
7014b843c749SSergey Zigachev }
7015b843c749SSergey Zigachev ret = si_upload_smc_data(adev);
7016b843c749SSergey Zigachev if (ret) {
7017b843c749SSergey Zigachev DRM_ERROR("si_upload_smc_data failed\n");
7018b843c749SSergey Zigachev return ret;
7019b843c749SSergey Zigachev }
7020b843c749SSergey Zigachev ret = si_upload_ulv_state(adev);
7021b843c749SSergey Zigachev if (ret) {
7022b843c749SSergey Zigachev DRM_ERROR("si_upload_ulv_state failed\n");
7023b843c749SSergey Zigachev return ret;
7024b843c749SSergey Zigachev }
7025b843c749SSergey Zigachev if (eg_pi->dynamic_ac_timing) {
7026b843c749SSergey Zigachev ret = si_upload_mc_reg_table(adev, new_ps);
7027b843c749SSergey Zigachev if (ret) {
7028b843c749SSergey Zigachev DRM_ERROR("si_upload_mc_reg_table failed\n");
7029b843c749SSergey Zigachev return ret;
7030b843c749SSergey Zigachev }
7031b843c749SSergey Zigachev }
7032b843c749SSergey Zigachev ret = si_program_memory_timing_parameters(adev, new_ps);
7033b843c749SSergey Zigachev if (ret) {
7034b843c749SSergey Zigachev DRM_ERROR("si_program_memory_timing_parameters failed\n");
7035b843c749SSergey Zigachev return ret;
7036b843c749SSergey Zigachev }
7037b843c749SSergey Zigachev si_set_pcie_lane_width_in_smc(adev, new_ps, old_ps);
7038b843c749SSergey Zigachev
7039b843c749SSergey Zigachev ret = si_resume_smc(adev);
7040b843c749SSergey Zigachev if (ret) {
7041b843c749SSergey Zigachev DRM_ERROR("si_resume_smc failed\n");
7042b843c749SSergey Zigachev return ret;
7043b843c749SSergey Zigachev }
7044b843c749SSergey Zigachev ret = si_set_sw_state(adev);
7045b843c749SSergey Zigachev if (ret) {
7046b843c749SSergey Zigachev DRM_ERROR("si_set_sw_state failed\n");
7047b843c749SSergey Zigachev return ret;
7048b843c749SSergey Zigachev }
7049b843c749SSergey Zigachev ni_set_uvd_clock_after_set_eng_clock(adev, new_ps, old_ps);
7050b843c749SSergey Zigachev if (eg_pi->pcie_performance_request)
7051b843c749SSergey Zigachev si_notify_link_speed_change_after_state_change(adev, new_ps, old_ps);
7052b843c749SSergey Zigachev ret = si_set_power_state_conditionally_enable_ulv(adev, new_ps);
7053b843c749SSergey Zigachev if (ret) {
7054b843c749SSergey Zigachev DRM_ERROR("si_set_power_state_conditionally_enable_ulv failed\n");
7055b843c749SSergey Zigachev return ret;
7056b843c749SSergey Zigachev }
7057b843c749SSergey Zigachev ret = si_enable_smc_cac(adev, new_ps, true);
7058b843c749SSergey Zigachev if (ret) {
7059b843c749SSergey Zigachev DRM_ERROR("si_enable_smc_cac failed\n");
7060b843c749SSergey Zigachev return ret;
7061b843c749SSergey Zigachev }
7062b843c749SSergey Zigachev ret = si_enable_power_containment(adev, new_ps, true);
7063b843c749SSergey Zigachev if (ret) {
7064b843c749SSergey Zigachev DRM_ERROR("si_enable_power_containment failed\n");
7065b843c749SSergey Zigachev return ret;
7066b843c749SSergey Zigachev }
7067b843c749SSergey Zigachev
7068b843c749SSergey Zigachev ret = si_power_control_set_level(adev);
7069b843c749SSergey Zigachev if (ret) {
7070b843c749SSergey Zigachev DRM_ERROR("si_power_control_set_level failed\n");
7071b843c749SSergey Zigachev return ret;
7072b843c749SSergey Zigachev }
7073b843c749SSergey Zigachev
7074b843c749SSergey Zigachev return 0;
7075b843c749SSergey Zigachev }
7076b843c749SSergey Zigachev
si_dpm_post_set_power_state(void * handle)7077b843c749SSergey Zigachev static void si_dpm_post_set_power_state(void *handle)
7078b843c749SSergey Zigachev {
7079b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7080b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7081b843c749SSergey Zigachev struct amdgpu_ps *new_ps = &eg_pi->requested_rps;
7082b843c749SSergey Zigachev
7083b843c749SSergey Zigachev ni_update_current_ps(adev, new_ps);
7084b843c749SSergey Zigachev }
7085b843c749SSergey Zigachev
7086b843c749SSergey Zigachev #if 0
7087b843c749SSergey Zigachev void si_dpm_reset_asic(struct amdgpu_device *adev)
7088b843c749SSergey Zigachev {
7089b843c749SSergey Zigachev si_restrict_performance_levels_before_switch(adev);
7090b843c749SSergey Zigachev si_disable_ulv(adev);
7091b843c749SSergey Zigachev si_set_boot_state(adev);
7092b843c749SSergey Zigachev }
7093b843c749SSergey Zigachev #endif
7094b843c749SSergey Zigachev
si_dpm_display_configuration_changed(void * handle)7095b843c749SSergey Zigachev static void si_dpm_display_configuration_changed(void *handle)
7096b843c749SSergey Zigachev {
7097b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7098b843c749SSergey Zigachev
7099b843c749SSergey Zigachev si_program_display_gap(adev);
7100b843c749SSergey Zigachev }
7101b843c749SSergey Zigachev
7102b843c749SSergey Zigachev
si_parse_pplib_non_clock_info(struct amdgpu_device * adev,struct amdgpu_ps * rps,struct _ATOM_PPLIB_NONCLOCK_INFO * non_clock_info,u8 table_rev)7103b843c749SSergey Zigachev static void si_parse_pplib_non_clock_info(struct amdgpu_device *adev,
7104b843c749SSergey Zigachev struct amdgpu_ps *rps,
7105b843c749SSergey Zigachev struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info,
7106b843c749SSergey Zigachev u8 table_rev)
7107b843c749SSergey Zigachev {
7108b843c749SSergey Zigachev rps->caps = le32_to_cpu(non_clock_info->ulCapsAndSettings);
7109b843c749SSergey Zigachev rps->class = le16_to_cpu(non_clock_info->usClassification);
7110b843c749SSergey Zigachev rps->class2 = le16_to_cpu(non_clock_info->usClassification2);
7111b843c749SSergey Zigachev
7112b843c749SSergey Zigachev if (ATOM_PPLIB_NONCLOCKINFO_VER1 < table_rev) {
7113b843c749SSergey Zigachev rps->vclk = le32_to_cpu(non_clock_info->ulVCLK);
7114b843c749SSergey Zigachev rps->dclk = le32_to_cpu(non_clock_info->ulDCLK);
7115b843c749SSergey Zigachev } else if (r600_is_uvd_state(rps->class, rps->class2)) {
7116b843c749SSergey Zigachev rps->vclk = RV770_DEFAULT_VCLK_FREQ;
7117b843c749SSergey Zigachev rps->dclk = RV770_DEFAULT_DCLK_FREQ;
7118b843c749SSergey Zigachev } else {
7119b843c749SSergey Zigachev rps->vclk = 0;
7120b843c749SSergey Zigachev rps->dclk = 0;
7121b843c749SSergey Zigachev }
7122b843c749SSergey Zigachev
7123b843c749SSergey Zigachev if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT)
7124b843c749SSergey Zigachev adev->pm.dpm.boot_ps = rps;
7125b843c749SSergey Zigachev if (rps->class & ATOM_PPLIB_CLASSIFICATION_UVDSTATE)
7126b843c749SSergey Zigachev adev->pm.dpm.uvd_ps = rps;
7127b843c749SSergey Zigachev }
7128b843c749SSergey Zigachev
si_parse_pplib_clock_info(struct amdgpu_device * adev,struct amdgpu_ps * rps,int index,union pplib_clock_info * clock_info)7129b843c749SSergey Zigachev static void si_parse_pplib_clock_info(struct amdgpu_device *adev,
7130b843c749SSergey Zigachev struct amdgpu_ps *rps, int index,
7131b843c749SSergey Zigachev union pplib_clock_info *clock_info)
7132b843c749SSergey Zigachev {
7133b843c749SSergey Zigachev struct rv7xx_power_info *pi = rv770_get_pi(adev);
7134b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7135b843c749SSergey Zigachev struct si_power_info *si_pi = si_get_pi(adev);
7136b843c749SSergey Zigachev struct si_ps *ps = si_get_ps(rps);
7137b843c749SSergey Zigachev u16 leakage_voltage;
7138b843c749SSergey Zigachev struct rv7xx_pl *pl = &ps->performance_levels[index];
7139b843c749SSergey Zigachev int ret;
7140b843c749SSergey Zigachev
7141b843c749SSergey Zigachev ps->performance_level_count = index + 1;
7142b843c749SSergey Zigachev
7143b843c749SSergey Zigachev pl->sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
7144b843c749SSergey Zigachev pl->sclk |= clock_info->si.ucEngineClockHigh << 16;
7145b843c749SSergey Zigachev pl->mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
7146b843c749SSergey Zigachev pl->mclk |= clock_info->si.ucMemoryClockHigh << 16;
7147b843c749SSergey Zigachev
7148b843c749SSergey Zigachev pl->vddc = le16_to_cpu(clock_info->si.usVDDC);
7149b843c749SSergey Zigachev pl->vddci = le16_to_cpu(clock_info->si.usVDDCI);
7150b843c749SSergey Zigachev pl->flags = le32_to_cpu(clock_info->si.ulFlags);
7151b843c749SSergey Zigachev pl->pcie_gen = amdgpu_get_pcie_gen_support(adev,
7152b843c749SSergey Zigachev si_pi->sys_pcie_mask,
7153b843c749SSergey Zigachev si_pi->boot_pcie_gen,
7154b843c749SSergey Zigachev clock_info->si.ucPCIEGen);
7155b843c749SSergey Zigachev
7156b843c749SSergey Zigachev /* patch up vddc if necessary */
7157b843c749SSergey Zigachev ret = si_get_leakage_voltage_from_leakage_index(adev, pl->vddc,
7158b843c749SSergey Zigachev &leakage_voltage);
7159b843c749SSergey Zigachev if (ret == 0)
7160b843c749SSergey Zigachev pl->vddc = leakage_voltage;
7161b843c749SSergey Zigachev
7162b843c749SSergey Zigachev if (rps->class & ATOM_PPLIB_CLASSIFICATION_ACPI) {
7163b843c749SSergey Zigachev pi->acpi_vddc = pl->vddc;
7164b843c749SSergey Zigachev eg_pi->acpi_vddci = pl->vddci;
7165b843c749SSergey Zigachev si_pi->acpi_pcie_gen = pl->pcie_gen;
7166b843c749SSergey Zigachev }
7167b843c749SSergey Zigachev
7168b843c749SSergey Zigachev if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) &&
7169b843c749SSergey Zigachev index == 0) {
7170b843c749SSergey Zigachev /* XXX disable for A0 tahiti */
7171b843c749SSergey Zigachev si_pi->ulv.supported = false;
7172b843c749SSergey Zigachev si_pi->ulv.pl = *pl;
7173b843c749SSergey Zigachev si_pi->ulv.one_pcie_lane_in_ulv = false;
7174b843c749SSergey Zigachev si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT;
7175b843c749SSergey Zigachev si_pi->ulv.cg_ulv_parameter = SISLANDS_CGULVPARAMETER_DFLT;
7176b843c749SSergey Zigachev si_pi->ulv.cg_ulv_control = SISLANDS_CGULVCONTROL_DFLT;
7177b843c749SSergey Zigachev }
7178b843c749SSergey Zigachev
7179b843c749SSergey Zigachev if (pi->min_vddc_in_table > pl->vddc)
7180b843c749SSergey Zigachev pi->min_vddc_in_table = pl->vddc;
7181b843c749SSergey Zigachev
7182b843c749SSergey Zigachev if (pi->max_vddc_in_table < pl->vddc)
7183b843c749SSergey Zigachev pi->max_vddc_in_table = pl->vddc;
7184b843c749SSergey Zigachev
7185b843c749SSergey Zigachev /* patch up boot state */
7186b843c749SSergey Zigachev if (rps->class & ATOM_PPLIB_CLASSIFICATION_BOOT) {
7187b843c749SSergey Zigachev u16 vddc, vddci, mvdd;
7188b843c749SSergey Zigachev amdgpu_atombios_get_default_voltages(adev, &vddc, &vddci, &mvdd);
7189b843c749SSergey Zigachev pl->mclk = adev->clock.default_mclk;
7190b843c749SSergey Zigachev pl->sclk = adev->clock.default_sclk;
7191b843c749SSergey Zigachev pl->vddc = vddc;
7192b843c749SSergey Zigachev pl->vddci = vddci;
7193b843c749SSergey Zigachev si_pi->mvdd_bootup_value = mvdd;
7194b843c749SSergey Zigachev }
7195b843c749SSergey Zigachev
7196b843c749SSergey Zigachev if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) ==
7197b843c749SSergey Zigachev ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE) {
7198b843c749SSergey Zigachev adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.sclk = pl->sclk;
7199b843c749SSergey Zigachev adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.mclk = pl->mclk;
7200b843c749SSergey Zigachev adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddc = pl->vddc;
7201b843c749SSergey Zigachev adev->pm.dpm.dyn_state.max_clock_voltage_on_ac.vddci = pl->vddci;
7202b843c749SSergey Zigachev }
7203b843c749SSergey Zigachev }
7204b843c749SSergey Zigachev
7205b843c749SSergey Zigachev union pplib_power_state {
7206b843c749SSergey Zigachev struct _ATOM_PPLIB_STATE v1;
7207b843c749SSergey Zigachev struct _ATOM_PPLIB_STATE_V2 v2;
7208b843c749SSergey Zigachev };
7209b843c749SSergey Zigachev
si_parse_power_table(struct amdgpu_device * adev)7210b843c749SSergey Zigachev static int si_parse_power_table(struct amdgpu_device *adev)
7211b843c749SSergey Zigachev {
7212b843c749SSergey Zigachev struct amdgpu_mode_info *mode_info = &adev->mode_info;
7213b843c749SSergey Zigachev struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info;
7214b843c749SSergey Zigachev union pplib_power_state *power_state;
7215b843c749SSergey Zigachev int i, j, k, non_clock_array_index, clock_array_index;
7216b843c749SSergey Zigachev union pplib_clock_info *clock_info;
7217b843c749SSergey Zigachev struct _StateArray *state_array;
7218b843c749SSergey Zigachev struct _ClockInfoArray *clock_info_array;
7219b843c749SSergey Zigachev struct _NonClockInfoArray *non_clock_info_array;
7220b843c749SSergey Zigachev union power_info *power_info;
7221b843c749SSergey Zigachev int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
7222b843c749SSergey Zigachev u16 data_offset;
7223b843c749SSergey Zigachev u8 frev, crev;
7224b843c749SSergey Zigachev u8 *power_state_offset;
7225b843c749SSergey Zigachev struct si_ps *ps;
7226b843c749SSergey Zigachev
7227b843c749SSergey Zigachev if (!amdgpu_atom_parse_data_header(mode_info->atom_context, index, NULL,
7228b843c749SSergey Zigachev &frev, &crev, &data_offset))
7229b843c749SSergey Zigachev return -EINVAL;
7230b843c749SSergey Zigachev power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
7231b843c749SSergey Zigachev
7232b843c749SSergey Zigachev amdgpu_add_thermal_controller(adev);
7233b843c749SSergey Zigachev
7234b843c749SSergey Zigachev state_array = (struct _StateArray *)
7235b843c749SSergey Zigachev (mode_info->atom_context->bios + data_offset +
7236b843c749SSergey Zigachev le16_to_cpu(power_info->pplib.usStateArrayOffset));
7237b843c749SSergey Zigachev clock_info_array = (struct _ClockInfoArray *)
7238b843c749SSergey Zigachev (mode_info->atom_context->bios + data_offset +
7239b843c749SSergey Zigachev le16_to_cpu(power_info->pplib.usClockInfoArrayOffset));
7240b843c749SSergey Zigachev non_clock_info_array = (struct _NonClockInfoArray *)
7241b843c749SSergey Zigachev (mode_info->atom_context->bios + data_offset +
7242b843c749SSergey Zigachev le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
7243b843c749SSergey Zigachev
7244b843c749SSergey Zigachev adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
7245b843c749SSergey Zigachev sizeof(struct amdgpu_ps),
7246b843c749SSergey Zigachev GFP_KERNEL);
7247b843c749SSergey Zigachev if (!adev->pm.dpm.ps)
7248b843c749SSergey Zigachev return -ENOMEM;
7249b843c749SSergey Zigachev power_state_offset = (u8 *)state_array->states;
7250b843c749SSergey Zigachev for (i = 0; i < state_array->ucNumEntries; i++) {
7251b843c749SSergey Zigachev u8 *idx;
7252b843c749SSergey Zigachev power_state = (union pplib_power_state *)power_state_offset;
7253b843c749SSergey Zigachev non_clock_array_index = power_state->v2.nonClockInfoIndex;
7254b843c749SSergey Zigachev non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
7255b843c749SSergey Zigachev &non_clock_info_array->nonClockInfo[non_clock_array_index];
7256b843c749SSergey Zigachev ps = kzalloc(sizeof(struct si_ps), GFP_KERNEL);
7257b843c749SSergey Zigachev if (ps == NULL) {
7258b843c749SSergey Zigachev kfree(adev->pm.dpm.ps);
7259b843c749SSergey Zigachev return -ENOMEM;
7260b843c749SSergey Zigachev }
7261b843c749SSergey Zigachev adev->pm.dpm.ps[i].ps_priv = ps;
7262b843c749SSergey Zigachev si_parse_pplib_non_clock_info(adev, &adev->pm.dpm.ps[i],
7263b843c749SSergey Zigachev non_clock_info,
7264b843c749SSergey Zigachev non_clock_info_array->ucEntrySize);
7265b843c749SSergey Zigachev k = 0;
7266b843c749SSergey Zigachev idx = (u8 *)&power_state->v2.clockInfoIndex[0];
7267b843c749SSergey Zigachev for (j = 0; j < power_state->v2.ucNumDPMLevels; j++) {
7268b843c749SSergey Zigachev clock_array_index = idx[j];
7269b843c749SSergey Zigachev if (clock_array_index >= clock_info_array->ucNumEntries)
7270b843c749SSergey Zigachev continue;
7271b843c749SSergey Zigachev if (k >= SISLANDS_MAX_HARDWARE_POWERLEVELS)
7272b843c749SSergey Zigachev break;
7273b843c749SSergey Zigachev clock_info = (union pplib_clock_info *)
7274b843c749SSergey Zigachev ((u8 *)&clock_info_array->clockInfo[0] +
7275b843c749SSergey Zigachev (clock_array_index * clock_info_array->ucEntrySize));
7276b843c749SSergey Zigachev si_parse_pplib_clock_info(adev,
7277b843c749SSergey Zigachev &adev->pm.dpm.ps[i], k,
7278b843c749SSergey Zigachev clock_info);
7279b843c749SSergey Zigachev k++;
7280b843c749SSergey Zigachev }
7281b843c749SSergey Zigachev power_state_offset += 2 + power_state->v2.ucNumDPMLevels;
7282b843c749SSergey Zigachev }
7283b843c749SSergey Zigachev adev->pm.dpm.num_ps = state_array->ucNumEntries;
7284b843c749SSergey Zigachev
7285b843c749SSergey Zigachev /* fill in the vce power states */
7286b843c749SSergey Zigachev for (i = 0; i < adev->pm.dpm.num_of_vce_states; i++) {
7287b843c749SSergey Zigachev u32 sclk, mclk;
7288b843c749SSergey Zigachev clock_array_index = adev->pm.dpm.vce_states[i].clk_idx;
7289b843c749SSergey Zigachev clock_info = (union pplib_clock_info *)
7290b843c749SSergey Zigachev &clock_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize];
7291b843c749SSergey Zigachev sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
7292b843c749SSergey Zigachev sclk |= clock_info->si.ucEngineClockHigh << 16;
7293b843c749SSergey Zigachev mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
7294b843c749SSergey Zigachev mclk |= clock_info->si.ucMemoryClockHigh << 16;
7295b843c749SSergey Zigachev adev->pm.dpm.vce_states[i].sclk = sclk;
7296b843c749SSergey Zigachev adev->pm.dpm.vce_states[i].mclk = mclk;
7297b843c749SSergey Zigachev }
7298b843c749SSergey Zigachev
7299b843c749SSergey Zigachev return 0;
7300b843c749SSergey Zigachev }
7301b843c749SSergey Zigachev
si_dpm_init(struct amdgpu_device * adev)7302b843c749SSergey Zigachev static int si_dpm_init(struct amdgpu_device *adev)
7303b843c749SSergey Zigachev {
7304b843c749SSergey Zigachev struct rv7xx_power_info *pi;
7305b843c749SSergey Zigachev struct evergreen_power_info *eg_pi;
7306b843c749SSergey Zigachev struct ni_power_info *ni_pi;
7307b843c749SSergey Zigachev struct si_power_info *si_pi;
7308b843c749SSergey Zigachev struct atom_clock_dividers dividers;
7309b843c749SSergey Zigachev int ret;
7310b843c749SSergey Zigachev
7311b843c749SSergey Zigachev si_pi = kzalloc(sizeof(struct si_power_info), GFP_KERNEL);
7312b843c749SSergey Zigachev if (si_pi == NULL)
7313b843c749SSergey Zigachev return -ENOMEM;
7314b843c749SSergey Zigachev adev->pm.dpm.priv = si_pi;
7315b843c749SSergey Zigachev ni_pi = &si_pi->ni;
7316b843c749SSergey Zigachev eg_pi = &ni_pi->eg;
7317b843c749SSergey Zigachev pi = &eg_pi->rv7xx;
7318b843c749SSergey Zigachev
7319b843c749SSergey Zigachev si_pi->sys_pcie_mask =
7320b843c749SSergey Zigachev adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_MASK;
7321b843c749SSergey Zigachev si_pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID;
7322b843c749SSergey Zigachev si_pi->boot_pcie_gen = si_get_current_pcie_speed(adev);
7323b843c749SSergey Zigachev
7324b843c749SSergey Zigachev si_set_max_cu_value(adev);
7325b843c749SSergey Zigachev
7326b843c749SSergey Zigachev rv770_get_max_vddc(adev);
7327b843c749SSergey Zigachev si_get_leakage_vddc(adev);
7328b843c749SSergey Zigachev si_patch_dependency_tables_based_on_leakage(adev);
7329b843c749SSergey Zigachev
7330b843c749SSergey Zigachev pi->acpi_vddc = 0;
7331b843c749SSergey Zigachev eg_pi->acpi_vddci = 0;
7332b843c749SSergey Zigachev pi->min_vddc_in_table = 0;
7333b843c749SSergey Zigachev pi->max_vddc_in_table = 0;
7334b843c749SSergey Zigachev
7335b843c749SSergey Zigachev ret = amdgpu_get_platform_caps(adev);
7336b843c749SSergey Zigachev if (ret)
7337b843c749SSergey Zigachev return ret;
7338b843c749SSergey Zigachev
7339b843c749SSergey Zigachev ret = amdgpu_parse_extended_power_table(adev);
7340b843c749SSergey Zigachev if (ret)
7341b843c749SSergey Zigachev return ret;
7342b843c749SSergey Zigachev
7343b843c749SSergey Zigachev ret = si_parse_power_table(adev);
7344b843c749SSergey Zigachev if (ret)
7345b843c749SSergey Zigachev return ret;
7346b843c749SSergey Zigachev
7347b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
7348b843c749SSergey Zigachev kcalloc(4,
7349b843c749SSergey Zigachev sizeof(struct amdgpu_clock_voltage_dependency_entry),
7350b843c749SSergey Zigachev GFP_KERNEL);
7351b843c749SSergey Zigachev if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
7352b843c749SSergey Zigachev amdgpu_free_extended_power_table(adev);
7353b843c749SSergey Zigachev return -ENOMEM;
7354b843c749SSergey Zigachev }
7355b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4;
7356b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0;
7357b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0;
7358b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].clk = 36000;
7359b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[1].v = 720;
7360b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].clk = 54000;
7361b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[2].v = 810;
7362b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000;
7363b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 900;
7364b843c749SSergey Zigachev
7365b843c749SSergey Zigachev if (adev->pm.dpm.voltage_response_time == 0)
7366b843c749SSergey Zigachev adev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT;
7367b843c749SSergey Zigachev if (adev->pm.dpm.backbias_response_time == 0)
7368b843c749SSergey Zigachev adev->pm.dpm.backbias_response_time = R600_BACKBIASRESPONSETIME_DFLT;
7369b843c749SSergey Zigachev
7370b843c749SSergey Zigachev ret = amdgpu_atombios_get_clock_dividers(adev, COMPUTE_ENGINE_PLL_PARAM,
7371b843c749SSergey Zigachev 0, false, ÷rs);
7372b843c749SSergey Zigachev if (ret)
7373b843c749SSergey Zigachev pi->ref_div = dividers.ref_div + 1;
7374b843c749SSergey Zigachev else
7375b843c749SSergey Zigachev pi->ref_div = R600_REFERENCEDIVIDER_DFLT;
7376b843c749SSergey Zigachev
7377b843c749SSergey Zigachev eg_pi->smu_uvd_hs = false;
7378b843c749SSergey Zigachev
7379b843c749SSergey Zigachev pi->mclk_strobe_mode_threshold = 40000;
7380b843c749SSergey Zigachev if (si_is_special_1gb_platform(adev))
7381b843c749SSergey Zigachev pi->mclk_stutter_mode_threshold = 0;
7382b843c749SSergey Zigachev else
7383b843c749SSergey Zigachev pi->mclk_stutter_mode_threshold = pi->mclk_strobe_mode_threshold;
7384b843c749SSergey Zigachev pi->mclk_edc_enable_threshold = 40000;
7385b843c749SSergey Zigachev eg_pi->mclk_edc_wr_enable_threshold = 40000;
7386b843c749SSergey Zigachev
7387b843c749SSergey Zigachev ni_pi->mclk_rtt_mode_threshold = eg_pi->mclk_edc_wr_enable_threshold;
7388b843c749SSergey Zigachev
7389b843c749SSergey Zigachev pi->voltage_control =
7390b843c749SSergey Zigachev amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC,
7391b843c749SSergey Zigachev VOLTAGE_OBJ_GPIO_LUT);
7392b843c749SSergey Zigachev if (!pi->voltage_control) {
7393b843c749SSergey Zigachev si_pi->voltage_control_svi2 =
7394b843c749SSergey Zigachev amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC,
7395b843c749SSergey Zigachev VOLTAGE_OBJ_SVID2);
7396b843c749SSergey Zigachev if (si_pi->voltage_control_svi2)
7397b843c749SSergey Zigachev amdgpu_atombios_get_svi2_info(adev, SET_VOLTAGE_TYPE_ASIC_VDDC,
7398b843c749SSergey Zigachev &si_pi->svd_gpio_id, &si_pi->svc_gpio_id);
7399b843c749SSergey Zigachev }
7400b843c749SSergey Zigachev
7401b843c749SSergey Zigachev pi->mvdd_control =
7402b843c749SSergey Zigachev amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_MVDDC,
7403b843c749SSergey Zigachev VOLTAGE_OBJ_GPIO_LUT);
7404b843c749SSergey Zigachev
7405b843c749SSergey Zigachev eg_pi->vddci_control =
7406b843c749SSergey Zigachev amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDCI,
7407b843c749SSergey Zigachev VOLTAGE_OBJ_GPIO_LUT);
7408b843c749SSergey Zigachev if (!eg_pi->vddci_control)
7409b843c749SSergey Zigachev si_pi->vddci_control_svi2 =
7410b843c749SSergey Zigachev amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDCI,
7411b843c749SSergey Zigachev VOLTAGE_OBJ_SVID2);
7412b843c749SSergey Zigachev
7413b843c749SSergey Zigachev si_pi->vddc_phase_shed_control =
7414b843c749SSergey Zigachev amdgpu_atombios_is_voltage_gpio(adev, SET_VOLTAGE_TYPE_ASIC_VDDC,
7415b843c749SSergey Zigachev VOLTAGE_OBJ_PHASE_LUT);
7416b843c749SSergey Zigachev
7417b843c749SSergey Zigachev rv770_get_engine_memory_ss(adev);
7418b843c749SSergey Zigachev
7419b843c749SSergey Zigachev pi->asi = RV770_ASI_DFLT;
7420b843c749SSergey Zigachev pi->pasi = CYPRESS_HASI_DFLT;
7421b843c749SSergey Zigachev pi->vrc = SISLANDS_VRC_DFLT;
7422b843c749SSergey Zigachev
7423b843c749SSergey Zigachev pi->gfx_clock_gating = true;
7424b843c749SSergey Zigachev
7425b843c749SSergey Zigachev eg_pi->sclk_deep_sleep = true;
7426b843c749SSergey Zigachev si_pi->sclk_deep_sleep_above_low = false;
7427b843c749SSergey Zigachev
7428b843c749SSergey Zigachev if (adev->pm.int_thermal_type != THERMAL_TYPE_NONE)
7429b843c749SSergey Zigachev pi->thermal_protection = true;
7430b843c749SSergey Zigachev else
7431b843c749SSergey Zigachev pi->thermal_protection = false;
7432b843c749SSergey Zigachev
7433b843c749SSergey Zigachev eg_pi->dynamic_ac_timing = true;
7434b843c749SSergey Zigachev
7435b843c749SSergey Zigachev eg_pi->light_sleep = true;
7436b843c749SSergey Zigachev #if defined(CONFIG_ACPI)
7437b843c749SSergey Zigachev eg_pi->pcie_performance_request =
7438b843c749SSergey Zigachev amdgpu_acpi_is_pcie_performance_request_supported(adev);
7439b843c749SSergey Zigachev #else
7440b843c749SSergey Zigachev eg_pi->pcie_performance_request = false;
7441b843c749SSergey Zigachev #endif
7442b843c749SSergey Zigachev
7443b843c749SSergey Zigachev si_pi->sram_end = SMC_RAM_END;
7444b843c749SSergey Zigachev
7445b843c749SSergey Zigachev adev->pm.dpm.dyn_state.mclk_sclk_ratio = 4;
7446b843c749SSergey Zigachev adev->pm.dpm.dyn_state.sclk_mclk_delta = 15000;
7447b843c749SSergey Zigachev adev->pm.dpm.dyn_state.vddc_vddci_delta = 200;
7448b843c749SSergey Zigachev adev->pm.dpm.dyn_state.valid_sclk_values.count = 0;
7449b843c749SSergey Zigachev adev->pm.dpm.dyn_state.valid_sclk_values.values = NULL;
7450b843c749SSergey Zigachev adev->pm.dpm.dyn_state.valid_mclk_values.count = 0;
7451b843c749SSergey Zigachev adev->pm.dpm.dyn_state.valid_mclk_values.values = NULL;
7452b843c749SSergey Zigachev
7453b843c749SSergey Zigachev si_initialize_powertune_defaults(adev);
7454b843c749SSergey Zigachev
7455b843c749SSergey Zigachev /* make sure dc limits are valid */
7456b843c749SSergey Zigachev if ((adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.sclk == 0) ||
7457b843c749SSergey Zigachev (adev->pm.dpm.dyn_state.max_clock_voltage_on_dc.mclk == 0))
7458b843c749SSergey Zigachev adev->pm.dpm.dyn_state.max_clock_voltage_on_dc =
7459b843c749SSergey Zigachev adev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
7460b843c749SSergey Zigachev
7461b843c749SSergey Zigachev si_pi->fan_ctrl_is_in_default_mode = true;
7462b843c749SSergey Zigachev
7463b843c749SSergey Zigachev return 0;
7464b843c749SSergey Zigachev }
7465b843c749SSergey Zigachev
si_dpm_fini(struct amdgpu_device * adev)7466b843c749SSergey Zigachev static void si_dpm_fini(struct amdgpu_device *adev)
7467b843c749SSergey Zigachev {
7468b843c749SSergey Zigachev int i;
7469b843c749SSergey Zigachev
7470b843c749SSergey Zigachev if (adev->pm.dpm.ps)
7471b843c749SSergey Zigachev for (i = 0; i < adev->pm.dpm.num_ps; i++)
7472b843c749SSergey Zigachev kfree(adev->pm.dpm.ps[i].ps_priv);
7473b843c749SSergey Zigachev kfree(adev->pm.dpm.ps);
7474b843c749SSergey Zigachev kfree(adev->pm.dpm.priv);
7475b843c749SSergey Zigachev kfree(adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries);
7476b843c749SSergey Zigachev amdgpu_free_extended_power_table(adev);
7477b843c749SSergey Zigachev }
7478b843c749SSergey Zigachev
si_dpm_debugfs_print_current_performance_level(void * handle,struct seq_file * m)7479b843c749SSergey Zigachev static void si_dpm_debugfs_print_current_performance_level(void *handle,
7480b843c749SSergey Zigachev struct seq_file *m)
7481b843c749SSergey Zigachev {
7482b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7483b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7484b843c749SSergey Zigachev struct amdgpu_ps *rps = &eg_pi->current_rps;
7485b843c749SSergey Zigachev struct si_ps *ps = si_get_ps(rps);
7486b843c749SSergey Zigachev struct rv7xx_pl *pl;
7487b843c749SSergey Zigachev u32 current_index =
7488b843c749SSergey Zigachev (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
7489b843c749SSergey Zigachev CURRENT_STATE_INDEX_SHIFT;
7490b843c749SSergey Zigachev
7491b843c749SSergey Zigachev if (current_index >= ps->performance_level_count) {
7492b843c749SSergey Zigachev seq_printf(m, "invalid dpm profile %d\n", current_index);
7493b843c749SSergey Zigachev } else {
7494b843c749SSergey Zigachev pl = &ps->performance_levels[current_index];
7495b843c749SSergey Zigachev seq_printf(m, "uvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
7496b843c749SSergey Zigachev seq_printf(m, "power level %d sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n",
7497b843c749SSergey Zigachev current_index, pl->sclk, pl->mclk, pl->vddc, pl->vddci, pl->pcie_gen + 1);
7498b843c749SSergey Zigachev }
7499b843c749SSergey Zigachev }
7500b843c749SSergey Zigachev
si_dpm_set_interrupt_state(struct amdgpu_device * adev,struct amdgpu_irq_src * source,unsigned type,enum amdgpu_interrupt_state state)7501b843c749SSergey Zigachev static int si_dpm_set_interrupt_state(struct amdgpu_device *adev,
7502b843c749SSergey Zigachev struct amdgpu_irq_src *source,
7503b843c749SSergey Zigachev unsigned type,
7504b843c749SSergey Zigachev enum amdgpu_interrupt_state state)
7505b843c749SSergey Zigachev {
7506b843c749SSergey Zigachev u32 cg_thermal_int;
7507b843c749SSergey Zigachev
7508b843c749SSergey Zigachev switch (type) {
7509b843c749SSergey Zigachev case AMDGPU_THERMAL_IRQ_LOW_TO_HIGH:
7510b843c749SSergey Zigachev switch (state) {
7511b843c749SSergey Zigachev case AMDGPU_IRQ_STATE_DISABLE:
7512b843c749SSergey Zigachev cg_thermal_int = RREG32_SMC(CG_THERMAL_INT);
7513b843c749SSergey Zigachev cg_thermal_int |= THERM_INT_MASK_HIGH;
7514b843c749SSergey Zigachev WREG32_SMC(CG_THERMAL_INT, cg_thermal_int);
7515b843c749SSergey Zigachev break;
7516b843c749SSergey Zigachev case AMDGPU_IRQ_STATE_ENABLE:
7517b843c749SSergey Zigachev cg_thermal_int = RREG32_SMC(CG_THERMAL_INT);
7518b843c749SSergey Zigachev cg_thermal_int &= ~THERM_INT_MASK_HIGH;
7519b843c749SSergey Zigachev WREG32_SMC(CG_THERMAL_INT, cg_thermal_int);
7520b843c749SSergey Zigachev break;
7521b843c749SSergey Zigachev default:
7522b843c749SSergey Zigachev break;
7523b843c749SSergey Zigachev }
7524b843c749SSergey Zigachev break;
7525b843c749SSergey Zigachev
7526b843c749SSergey Zigachev case AMDGPU_THERMAL_IRQ_HIGH_TO_LOW:
7527b843c749SSergey Zigachev switch (state) {
7528b843c749SSergey Zigachev case AMDGPU_IRQ_STATE_DISABLE:
7529b843c749SSergey Zigachev cg_thermal_int = RREG32_SMC(CG_THERMAL_INT);
7530b843c749SSergey Zigachev cg_thermal_int |= THERM_INT_MASK_LOW;
7531b843c749SSergey Zigachev WREG32_SMC(CG_THERMAL_INT, cg_thermal_int);
7532b843c749SSergey Zigachev break;
7533b843c749SSergey Zigachev case AMDGPU_IRQ_STATE_ENABLE:
7534b843c749SSergey Zigachev cg_thermal_int = RREG32_SMC(CG_THERMAL_INT);
7535b843c749SSergey Zigachev cg_thermal_int &= ~THERM_INT_MASK_LOW;
7536b843c749SSergey Zigachev WREG32_SMC(CG_THERMAL_INT, cg_thermal_int);
7537b843c749SSergey Zigachev break;
7538b843c749SSergey Zigachev default:
7539b843c749SSergey Zigachev break;
7540b843c749SSergey Zigachev }
7541b843c749SSergey Zigachev break;
7542b843c749SSergey Zigachev
7543b843c749SSergey Zigachev default:
7544b843c749SSergey Zigachev break;
7545b843c749SSergey Zigachev }
7546b843c749SSergey Zigachev return 0;
7547b843c749SSergey Zigachev }
7548b843c749SSergey Zigachev
si_dpm_process_interrupt(struct amdgpu_device * adev,struct amdgpu_irq_src * source,struct amdgpu_iv_entry * entry)7549b843c749SSergey Zigachev static int si_dpm_process_interrupt(struct amdgpu_device *adev,
7550b843c749SSergey Zigachev struct amdgpu_irq_src *source,
7551b843c749SSergey Zigachev struct amdgpu_iv_entry *entry)
7552b843c749SSergey Zigachev {
7553b843c749SSergey Zigachev bool queue_thermal = false;
7554b843c749SSergey Zigachev
7555b843c749SSergey Zigachev if (entry == NULL)
7556b843c749SSergey Zigachev return -EINVAL;
7557b843c749SSergey Zigachev
7558b843c749SSergey Zigachev switch (entry->src_id) {
7559b843c749SSergey Zigachev case 230: /* thermal low to high */
7560b843c749SSergey Zigachev DRM_DEBUG("IH: thermal low to high\n");
7561b843c749SSergey Zigachev adev->pm.dpm.thermal.high_to_low = false;
7562b843c749SSergey Zigachev queue_thermal = true;
7563b843c749SSergey Zigachev break;
7564b843c749SSergey Zigachev case 231: /* thermal high to low */
7565b843c749SSergey Zigachev DRM_DEBUG("IH: thermal high to low\n");
7566b843c749SSergey Zigachev adev->pm.dpm.thermal.high_to_low = true;
7567b843c749SSergey Zigachev queue_thermal = true;
7568b843c749SSergey Zigachev break;
7569b843c749SSergey Zigachev default:
7570b843c749SSergey Zigachev break;
7571b843c749SSergey Zigachev }
7572b843c749SSergey Zigachev
7573b843c749SSergey Zigachev if (queue_thermal)
7574b843c749SSergey Zigachev schedule_work(&adev->pm.dpm.thermal.work);
7575b843c749SSergey Zigachev
7576b843c749SSergey Zigachev return 0;
7577b843c749SSergey Zigachev }
7578b843c749SSergey Zigachev
si_dpm_late_init(void * handle)7579b843c749SSergey Zigachev static int si_dpm_late_init(void *handle)
7580b843c749SSergey Zigachev {
7581b843c749SSergey Zigachev int ret;
7582b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7583b843c749SSergey Zigachev
7584b843c749SSergey Zigachev if (!adev->pm.dpm_enabled)
7585b843c749SSergey Zigachev return 0;
7586b843c749SSergey Zigachev
7587b843c749SSergey Zigachev ret = si_set_temperature_range(adev);
7588b843c749SSergey Zigachev if (ret)
7589b843c749SSergey Zigachev return ret;
7590b843c749SSergey Zigachev #if 0 //TODO ?
7591b843c749SSergey Zigachev si_dpm_powergate_uvd(adev, true);
7592b843c749SSergey Zigachev #endif
7593b843c749SSergey Zigachev return 0;
7594b843c749SSergey Zigachev }
7595b843c749SSergey Zigachev
7596b843c749SSergey Zigachev /**
7597b843c749SSergey Zigachev * si_dpm_init_microcode - load ucode images from disk
7598b843c749SSergey Zigachev *
7599b843c749SSergey Zigachev * @adev: amdgpu_device pointer
7600b843c749SSergey Zigachev *
7601b843c749SSergey Zigachev * Use the firmware interface to load the ucode images into
7602b843c749SSergey Zigachev * the driver (not loaded into hw).
7603b843c749SSergey Zigachev * Returns 0 on success, error on failure.
7604b843c749SSergey Zigachev */
si_dpm_init_microcode(struct amdgpu_device * adev)7605b843c749SSergey Zigachev static int si_dpm_init_microcode(struct amdgpu_device *adev)
7606b843c749SSergey Zigachev {
7607b843c749SSergey Zigachev const char *chip_name;
7608b843c749SSergey Zigachev char fw_name[30];
7609b843c749SSergey Zigachev int err;
7610b843c749SSergey Zigachev
7611b843c749SSergey Zigachev DRM_DEBUG("\n");
7612b843c749SSergey Zigachev switch (adev->asic_type) {
7613b843c749SSergey Zigachev case CHIP_TAHITI:
7614b843c749SSergey Zigachev chip_name = "tahiti";
7615b843c749SSergey Zigachev break;
7616b843c749SSergey Zigachev case CHIP_PITCAIRN:
7617b843c749SSergey Zigachev if ((adev->pdev->revision == 0x81) &&
7618b843c749SSergey Zigachev ((adev->pdev->device == 0x6810) ||
7619b843c749SSergey Zigachev (adev->pdev->device == 0x6811)))
7620b843c749SSergey Zigachev chip_name = "pitcairn_k";
7621b843c749SSergey Zigachev else
7622b843c749SSergey Zigachev chip_name = "pitcairn";
7623b843c749SSergey Zigachev break;
7624b843c749SSergey Zigachev case CHIP_VERDE:
7625b843c749SSergey Zigachev if (((adev->pdev->device == 0x6820) &&
7626b843c749SSergey Zigachev ((adev->pdev->revision == 0x81) ||
7627b843c749SSergey Zigachev (adev->pdev->revision == 0x83))) ||
7628b843c749SSergey Zigachev ((adev->pdev->device == 0x6821) &&
7629b843c749SSergey Zigachev ((adev->pdev->revision == 0x83) ||
7630b843c749SSergey Zigachev (adev->pdev->revision == 0x87))) ||
7631b843c749SSergey Zigachev ((adev->pdev->revision == 0x87) &&
7632b843c749SSergey Zigachev ((adev->pdev->device == 0x6823) ||
7633b843c749SSergey Zigachev (adev->pdev->device == 0x682b))))
7634b843c749SSergey Zigachev chip_name = "verde_k";
7635b843c749SSergey Zigachev else
7636b843c749SSergey Zigachev chip_name = "verde";
7637b843c749SSergey Zigachev break;
7638b843c749SSergey Zigachev case CHIP_OLAND:
7639b843c749SSergey Zigachev if (((adev->pdev->revision == 0x81) &&
7640b843c749SSergey Zigachev ((adev->pdev->device == 0x6600) ||
7641b843c749SSergey Zigachev (adev->pdev->device == 0x6604) ||
7642b843c749SSergey Zigachev (adev->pdev->device == 0x6605) ||
7643b843c749SSergey Zigachev (adev->pdev->device == 0x6610))) ||
7644b843c749SSergey Zigachev ((adev->pdev->revision == 0x83) &&
7645b843c749SSergey Zigachev (adev->pdev->device == 0x6610)))
7646b843c749SSergey Zigachev chip_name = "oland_k";
7647b843c749SSergey Zigachev else
7648b843c749SSergey Zigachev chip_name = "oland";
7649b843c749SSergey Zigachev break;
7650b843c749SSergey Zigachev case CHIP_HAINAN:
7651b843c749SSergey Zigachev if (((adev->pdev->revision == 0x81) &&
7652b843c749SSergey Zigachev (adev->pdev->device == 0x6660)) ||
7653b843c749SSergey Zigachev ((adev->pdev->revision == 0x83) &&
7654b843c749SSergey Zigachev ((adev->pdev->device == 0x6660) ||
7655b843c749SSergey Zigachev (adev->pdev->device == 0x6663) ||
7656b843c749SSergey Zigachev (adev->pdev->device == 0x6665) ||
7657b843c749SSergey Zigachev (adev->pdev->device == 0x6667))))
7658b843c749SSergey Zigachev chip_name = "hainan_k";
7659b843c749SSergey Zigachev else if ((adev->pdev->revision == 0xc3) &&
7660b843c749SSergey Zigachev (adev->pdev->device == 0x6665))
7661b843c749SSergey Zigachev chip_name = "banks_k_2";
7662b843c749SSergey Zigachev else
7663b843c749SSergey Zigachev chip_name = "hainan";
7664b843c749SSergey Zigachev break;
7665b843c749SSergey Zigachev default: BUG();
7666b843c749SSergey Zigachev }
7667b843c749SSergey Zigachev
7668*809f3802SSergey Zigachev snprintf(fw_name, sizeof(fw_name), "amdgpufw_%s_smc", chip_name);
7669b843c749SSergey Zigachev err = request_firmware(&adev->pm.fw, fw_name, adev->dev);
7670b843c749SSergey Zigachev if (err)
7671b843c749SSergey Zigachev goto out;
7672b843c749SSergey Zigachev err = amdgpu_ucode_validate(adev->pm.fw);
7673b843c749SSergey Zigachev
7674b843c749SSergey Zigachev out:
7675b843c749SSergey Zigachev if (err) {
7676b843c749SSergey Zigachev DRM_ERROR("si_smc: Failed to load firmware. err = %d\"%s\"\n",
7677b843c749SSergey Zigachev err, fw_name);
7678b843c749SSergey Zigachev release_firmware(adev->pm.fw);
7679b843c749SSergey Zigachev adev->pm.fw = NULL;
7680b843c749SSergey Zigachev }
7681b843c749SSergey Zigachev return err;
7682b843c749SSergey Zigachev
7683b843c749SSergey Zigachev }
7684b843c749SSergey Zigachev
si_dpm_sw_init(void * handle)7685b843c749SSergey Zigachev static int si_dpm_sw_init(void *handle)
7686b843c749SSergey Zigachev {
7687b843c749SSergey Zigachev int ret;
7688b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7689b843c749SSergey Zigachev
7690b843c749SSergey Zigachev ret = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 230, &adev->pm.dpm.thermal.irq);
7691b843c749SSergey Zigachev if (ret)
7692b843c749SSergey Zigachev return ret;
7693b843c749SSergey Zigachev
7694b843c749SSergey Zigachev ret = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 231, &adev->pm.dpm.thermal.irq);
7695b843c749SSergey Zigachev if (ret)
7696b843c749SSergey Zigachev return ret;
7697b843c749SSergey Zigachev
7698b843c749SSergey Zigachev /* default to balanced state */
7699b843c749SSergey Zigachev adev->pm.dpm.state = POWER_STATE_TYPE_BALANCED;
7700b843c749SSergey Zigachev adev->pm.dpm.user_state = POWER_STATE_TYPE_BALANCED;
7701b843c749SSergey Zigachev adev->pm.dpm.forced_level = AMD_DPM_FORCED_LEVEL_AUTO;
7702b843c749SSergey Zigachev adev->pm.default_sclk = adev->clock.default_sclk;
7703b843c749SSergey Zigachev adev->pm.default_mclk = adev->clock.default_mclk;
7704b843c749SSergey Zigachev adev->pm.current_sclk = adev->clock.default_sclk;
7705b843c749SSergey Zigachev adev->pm.current_mclk = adev->clock.default_mclk;
7706b843c749SSergey Zigachev adev->pm.int_thermal_type = THERMAL_TYPE_NONE;
7707b843c749SSergey Zigachev
7708b843c749SSergey Zigachev if (amdgpu_dpm == 0)
7709b843c749SSergey Zigachev return 0;
7710b843c749SSergey Zigachev
7711b843c749SSergey Zigachev ret = si_dpm_init_microcode(adev);
7712b843c749SSergey Zigachev if (ret)
7713b843c749SSergey Zigachev return ret;
7714b843c749SSergey Zigachev
7715b843c749SSergey Zigachev INIT_WORK(&adev->pm.dpm.thermal.work, amdgpu_dpm_thermal_work_handler);
7716b843c749SSergey Zigachev mutex_lock(&adev->pm.mutex);
7717b843c749SSergey Zigachev ret = si_dpm_init(adev);
7718b843c749SSergey Zigachev if (ret)
7719b843c749SSergey Zigachev goto dpm_failed;
7720b843c749SSergey Zigachev adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps;
7721b843c749SSergey Zigachev if (amdgpu_dpm == 1)
7722b843c749SSergey Zigachev amdgpu_pm_print_power_states(adev);
7723b843c749SSergey Zigachev mutex_unlock(&adev->pm.mutex);
7724b843c749SSergey Zigachev DRM_INFO("amdgpu: dpm initialized\n");
7725b843c749SSergey Zigachev
7726b843c749SSergey Zigachev return 0;
7727b843c749SSergey Zigachev
7728b843c749SSergey Zigachev dpm_failed:
7729b843c749SSergey Zigachev si_dpm_fini(adev);
7730b843c749SSergey Zigachev mutex_unlock(&adev->pm.mutex);
7731b843c749SSergey Zigachev DRM_ERROR("amdgpu: dpm initialization failed\n");
7732b843c749SSergey Zigachev return ret;
7733b843c749SSergey Zigachev }
7734b843c749SSergey Zigachev
si_dpm_sw_fini(void * handle)7735b843c749SSergey Zigachev static int si_dpm_sw_fini(void *handle)
7736b843c749SSergey Zigachev {
7737b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7738b843c749SSergey Zigachev
7739b843c749SSergey Zigachev flush_work(&adev->pm.dpm.thermal.work);
7740b843c749SSergey Zigachev
7741b843c749SSergey Zigachev mutex_lock(&adev->pm.mutex);
7742b843c749SSergey Zigachev si_dpm_fini(adev);
7743b843c749SSergey Zigachev mutex_unlock(&adev->pm.mutex);
7744b843c749SSergey Zigachev
7745b843c749SSergey Zigachev return 0;
7746b843c749SSergey Zigachev }
7747b843c749SSergey Zigachev
si_dpm_hw_init(void * handle)7748b843c749SSergey Zigachev static int si_dpm_hw_init(void *handle)
7749b843c749SSergey Zigachev {
7750b843c749SSergey Zigachev int ret;
7751b843c749SSergey Zigachev
7752b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7753b843c749SSergey Zigachev
7754b843c749SSergey Zigachev if (!amdgpu_dpm)
7755b843c749SSergey Zigachev return 0;
7756b843c749SSergey Zigachev
7757b843c749SSergey Zigachev mutex_lock(&adev->pm.mutex);
7758b843c749SSergey Zigachev si_dpm_setup_asic(adev);
7759b843c749SSergey Zigachev ret = si_dpm_enable(adev);
7760b843c749SSergey Zigachev if (ret)
7761b843c749SSergey Zigachev adev->pm.dpm_enabled = false;
7762b843c749SSergey Zigachev else
7763b843c749SSergey Zigachev adev->pm.dpm_enabled = true;
7764b843c749SSergey Zigachev mutex_unlock(&adev->pm.mutex);
7765b843c749SSergey Zigachev amdgpu_pm_compute_clocks(adev);
7766b843c749SSergey Zigachev return ret;
7767b843c749SSergey Zigachev }
7768b843c749SSergey Zigachev
si_dpm_hw_fini(void * handle)7769b843c749SSergey Zigachev static int si_dpm_hw_fini(void *handle)
7770b843c749SSergey Zigachev {
7771b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7772b843c749SSergey Zigachev
7773b843c749SSergey Zigachev if (adev->pm.dpm_enabled) {
7774b843c749SSergey Zigachev mutex_lock(&adev->pm.mutex);
7775b843c749SSergey Zigachev si_dpm_disable(adev);
7776b843c749SSergey Zigachev mutex_unlock(&adev->pm.mutex);
7777b843c749SSergey Zigachev }
7778b843c749SSergey Zigachev
7779b843c749SSergey Zigachev return 0;
7780b843c749SSergey Zigachev }
7781b843c749SSergey Zigachev
si_dpm_suspend(void * handle)7782b843c749SSergey Zigachev static int si_dpm_suspend(void *handle)
7783b843c749SSergey Zigachev {
7784b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7785b843c749SSergey Zigachev
7786b843c749SSergey Zigachev if (adev->pm.dpm_enabled) {
7787b843c749SSergey Zigachev mutex_lock(&adev->pm.mutex);
7788b843c749SSergey Zigachev /* disable dpm */
7789b843c749SSergey Zigachev si_dpm_disable(adev);
7790b843c749SSergey Zigachev /* reset the power state */
7791b843c749SSergey Zigachev adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps = adev->pm.dpm.boot_ps;
7792b843c749SSergey Zigachev mutex_unlock(&adev->pm.mutex);
7793b843c749SSergey Zigachev }
7794b843c749SSergey Zigachev return 0;
7795b843c749SSergey Zigachev }
7796b843c749SSergey Zigachev
si_dpm_resume(void * handle)7797b843c749SSergey Zigachev static int si_dpm_resume(void *handle)
7798b843c749SSergey Zigachev {
7799b843c749SSergey Zigachev int ret;
7800b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7801b843c749SSergey Zigachev
7802b843c749SSergey Zigachev if (adev->pm.dpm_enabled) {
7803b843c749SSergey Zigachev /* asic init will reset to the boot state */
7804b843c749SSergey Zigachev mutex_lock(&adev->pm.mutex);
7805b843c749SSergey Zigachev si_dpm_setup_asic(adev);
7806b843c749SSergey Zigachev ret = si_dpm_enable(adev);
7807b843c749SSergey Zigachev if (ret)
7808b843c749SSergey Zigachev adev->pm.dpm_enabled = false;
7809b843c749SSergey Zigachev else
7810b843c749SSergey Zigachev adev->pm.dpm_enabled = true;
7811b843c749SSergey Zigachev mutex_unlock(&adev->pm.mutex);
7812b843c749SSergey Zigachev if (adev->pm.dpm_enabled)
7813b843c749SSergey Zigachev amdgpu_pm_compute_clocks(adev);
7814b843c749SSergey Zigachev }
7815b843c749SSergey Zigachev return 0;
7816b843c749SSergey Zigachev }
7817b843c749SSergey Zigachev
si_dpm_is_idle(void * handle)7818b843c749SSergey Zigachev static bool si_dpm_is_idle(void *handle)
7819b843c749SSergey Zigachev {
7820b843c749SSergey Zigachev /* XXX */
7821b843c749SSergey Zigachev return true;
7822b843c749SSergey Zigachev }
7823b843c749SSergey Zigachev
si_dpm_wait_for_idle(void * handle)7824b843c749SSergey Zigachev static int si_dpm_wait_for_idle(void *handle)
7825b843c749SSergey Zigachev {
7826b843c749SSergey Zigachev /* XXX */
7827b843c749SSergey Zigachev return 0;
7828b843c749SSergey Zigachev }
7829b843c749SSergey Zigachev
si_dpm_soft_reset(void * handle)7830b843c749SSergey Zigachev static int si_dpm_soft_reset(void *handle)
7831b843c749SSergey Zigachev {
7832b843c749SSergey Zigachev return 0;
7833b843c749SSergey Zigachev }
7834b843c749SSergey Zigachev
si_dpm_set_clockgating_state(void * handle,enum amd_clockgating_state state)7835b843c749SSergey Zigachev static int si_dpm_set_clockgating_state(void *handle,
7836b843c749SSergey Zigachev enum amd_clockgating_state state)
7837b843c749SSergey Zigachev {
7838b843c749SSergey Zigachev return 0;
7839b843c749SSergey Zigachev }
7840b843c749SSergey Zigachev
si_dpm_set_powergating_state(void * handle,enum amd_powergating_state state)7841b843c749SSergey Zigachev static int si_dpm_set_powergating_state(void *handle,
7842b843c749SSergey Zigachev enum amd_powergating_state state)
7843b843c749SSergey Zigachev {
7844b843c749SSergey Zigachev return 0;
7845b843c749SSergey Zigachev }
7846b843c749SSergey Zigachev
7847b843c749SSergey Zigachev /* get temperature in millidegrees */
si_dpm_get_temp(void * handle)7848b843c749SSergey Zigachev static int si_dpm_get_temp(void *handle)
7849b843c749SSergey Zigachev {
7850b843c749SSergey Zigachev u32 temp;
7851b843c749SSergey Zigachev int actual_temp = 0;
7852b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7853b843c749SSergey Zigachev
7854b843c749SSergey Zigachev temp = (RREG32(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >>
7855b843c749SSergey Zigachev CTF_TEMP_SHIFT;
7856b843c749SSergey Zigachev
7857b843c749SSergey Zigachev if (temp & 0x200)
7858b843c749SSergey Zigachev actual_temp = 255;
7859b843c749SSergey Zigachev else
7860b843c749SSergey Zigachev actual_temp = temp & 0x1ff;
7861b843c749SSergey Zigachev
7862b843c749SSergey Zigachev actual_temp = (actual_temp * 1000);
7863b843c749SSergey Zigachev
7864b843c749SSergey Zigachev return actual_temp;
7865b843c749SSergey Zigachev }
7866b843c749SSergey Zigachev
si_dpm_get_sclk(void * handle,bool low)7867b843c749SSergey Zigachev static u32 si_dpm_get_sclk(void *handle, bool low)
7868b843c749SSergey Zigachev {
7869b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7870b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7871b843c749SSergey Zigachev struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps);
7872b843c749SSergey Zigachev
7873b843c749SSergey Zigachev if (low)
7874b843c749SSergey Zigachev return requested_state->performance_levels[0].sclk;
7875b843c749SSergey Zigachev else
7876b843c749SSergey Zigachev return requested_state->performance_levels[requested_state->performance_level_count - 1].sclk;
7877b843c749SSergey Zigachev }
7878b843c749SSergey Zigachev
si_dpm_get_mclk(void * handle,bool low)7879b843c749SSergey Zigachev static u32 si_dpm_get_mclk(void *handle, bool low)
7880b843c749SSergey Zigachev {
7881b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7882b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7883b843c749SSergey Zigachev struct si_ps *requested_state = si_get_ps(&eg_pi->requested_rps);
7884b843c749SSergey Zigachev
7885b843c749SSergey Zigachev if (low)
7886b843c749SSergey Zigachev return requested_state->performance_levels[0].mclk;
7887b843c749SSergey Zigachev else
7888b843c749SSergey Zigachev return requested_state->performance_levels[requested_state->performance_level_count - 1].mclk;
7889b843c749SSergey Zigachev }
7890b843c749SSergey Zigachev
si_dpm_print_power_state(void * handle,void * current_ps)7891b843c749SSergey Zigachev static void si_dpm_print_power_state(void *handle,
7892b843c749SSergey Zigachev void *current_ps)
7893b843c749SSergey Zigachev {
7894b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7895b843c749SSergey Zigachev struct amdgpu_ps *rps = (struct amdgpu_ps *)current_ps;
7896b843c749SSergey Zigachev struct si_ps *ps = si_get_ps(rps);
7897b843c749SSergey Zigachev struct rv7xx_pl *pl;
7898b843c749SSergey Zigachev int i;
7899b843c749SSergey Zigachev
7900b843c749SSergey Zigachev amdgpu_dpm_print_class_info(rps->class, rps->class2);
7901b843c749SSergey Zigachev amdgpu_dpm_print_cap_info(rps->caps);
7902b843c749SSergey Zigachev DRM_INFO("\tuvd vclk: %d dclk: %d\n", rps->vclk, rps->dclk);
7903b843c749SSergey Zigachev for (i = 0; i < ps->performance_level_count; i++) {
7904b843c749SSergey Zigachev pl = &ps->performance_levels[i];
7905b843c749SSergey Zigachev if (adev->asic_type >= CHIP_TAHITI)
7906b843c749SSergey Zigachev DRM_INFO("\t\tpower level %d sclk: %u mclk: %u vddc: %u vddci: %u pcie gen: %u\n",
7907b843c749SSergey Zigachev i, pl->sclk, pl->mclk, pl->vddc, pl->vddci, pl->pcie_gen + 1);
7908b843c749SSergey Zigachev else
7909b843c749SSergey Zigachev DRM_INFO("\t\tpower level %d sclk: %u mclk: %u vddc: %u vddci: %u\n",
7910b843c749SSergey Zigachev i, pl->sclk, pl->mclk, pl->vddc, pl->vddci);
7911b843c749SSergey Zigachev }
7912b843c749SSergey Zigachev amdgpu_dpm_print_ps_status(adev, rps);
7913b843c749SSergey Zigachev }
7914b843c749SSergey Zigachev
si_dpm_early_init(void * handle)7915b843c749SSergey Zigachev static int si_dpm_early_init(void *handle)
7916b843c749SSergey Zigachev {
7917b843c749SSergey Zigachev
7918b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7919b843c749SSergey Zigachev
7920b843c749SSergey Zigachev adev->powerplay.pp_funcs = &si_dpm_funcs;
7921b843c749SSergey Zigachev adev->powerplay.pp_handle = adev;
7922b843c749SSergey Zigachev si_dpm_set_irq_funcs(adev);
7923b843c749SSergey Zigachev return 0;
7924b843c749SSergey Zigachev }
7925b843c749SSergey Zigachev
si_are_power_levels_equal(const struct rv7xx_pl * si_cpl1,const struct rv7xx_pl * si_cpl2)7926b843c749SSergey Zigachev static inline bool si_are_power_levels_equal(const struct rv7xx_pl *si_cpl1,
7927b843c749SSergey Zigachev const struct rv7xx_pl *si_cpl2)
7928b843c749SSergey Zigachev {
7929b843c749SSergey Zigachev return ((si_cpl1->mclk == si_cpl2->mclk) &&
7930b843c749SSergey Zigachev (si_cpl1->sclk == si_cpl2->sclk) &&
7931b843c749SSergey Zigachev (si_cpl1->pcie_gen == si_cpl2->pcie_gen) &&
7932b843c749SSergey Zigachev (si_cpl1->vddc == si_cpl2->vddc) &&
7933b843c749SSergey Zigachev (si_cpl1->vddci == si_cpl2->vddci));
7934b843c749SSergey Zigachev }
7935b843c749SSergey Zigachev
si_check_state_equal(void * handle,void * current_ps,void * request_ps,bool * equal)7936b843c749SSergey Zigachev static int si_check_state_equal(void *handle,
7937b843c749SSergey Zigachev void *current_ps,
7938b843c749SSergey Zigachev void *request_ps,
7939b843c749SSergey Zigachev bool *equal)
7940b843c749SSergey Zigachev {
7941b843c749SSergey Zigachev struct si_ps *si_cps;
7942b843c749SSergey Zigachev struct si_ps *si_rps;
7943b843c749SSergey Zigachev int i;
7944b843c749SSergey Zigachev struct amdgpu_ps *cps = (struct amdgpu_ps *)current_ps;
7945b843c749SSergey Zigachev struct amdgpu_ps *rps = (struct amdgpu_ps *)request_ps;
7946b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7947b843c749SSergey Zigachev
7948b843c749SSergey Zigachev if (adev == NULL || cps == NULL || rps == NULL || equal == NULL)
7949b843c749SSergey Zigachev return -EINVAL;
7950b843c749SSergey Zigachev
7951b843c749SSergey Zigachev si_cps = si_get_ps((struct amdgpu_ps *)cps);
7952b843c749SSergey Zigachev si_rps = si_get_ps((struct amdgpu_ps *)rps);
7953b843c749SSergey Zigachev
7954b843c749SSergey Zigachev if (si_cps == NULL) {
7955b843c749SSergey Zigachev printk("si_cps is NULL\n");
7956b843c749SSergey Zigachev *equal = false;
7957b843c749SSergey Zigachev return 0;
7958b843c749SSergey Zigachev }
7959b843c749SSergey Zigachev
7960b843c749SSergey Zigachev if (si_cps->performance_level_count != si_rps->performance_level_count) {
7961b843c749SSergey Zigachev *equal = false;
7962b843c749SSergey Zigachev return 0;
7963b843c749SSergey Zigachev }
7964b843c749SSergey Zigachev
7965b843c749SSergey Zigachev for (i = 0; i < si_cps->performance_level_count; i++) {
7966b843c749SSergey Zigachev if (!si_are_power_levels_equal(&(si_cps->performance_levels[i]),
7967b843c749SSergey Zigachev &(si_rps->performance_levels[i]))) {
7968b843c749SSergey Zigachev *equal = false;
7969b843c749SSergey Zigachev return 0;
7970b843c749SSergey Zigachev }
7971b843c749SSergey Zigachev }
7972b843c749SSergey Zigachev
7973b843c749SSergey Zigachev /* If all performance levels are the same try to use the UVD clocks to break the tie.*/
7974b843c749SSergey Zigachev *equal = ((cps->vclk == rps->vclk) && (cps->dclk == rps->dclk));
7975b843c749SSergey Zigachev *equal &= ((cps->evclk == rps->evclk) && (cps->ecclk == rps->ecclk));
7976b843c749SSergey Zigachev
7977b843c749SSergey Zigachev return 0;
7978b843c749SSergey Zigachev }
7979b843c749SSergey Zigachev
si_dpm_read_sensor(void * handle,int idx,void * value,int * size)7980b843c749SSergey Zigachev static int si_dpm_read_sensor(void *handle, int idx,
7981b843c749SSergey Zigachev void *value, int *size)
7982b843c749SSergey Zigachev {
7983b843c749SSergey Zigachev struct amdgpu_device *adev = (struct amdgpu_device *)handle;
7984b843c749SSergey Zigachev struct evergreen_power_info *eg_pi = evergreen_get_pi(adev);
7985b843c749SSergey Zigachev struct amdgpu_ps *rps = &eg_pi->current_rps;
7986b843c749SSergey Zigachev struct si_ps *ps = si_get_ps(rps);
7987b843c749SSergey Zigachev uint32_t sclk, mclk;
7988b843c749SSergey Zigachev u32 pl_index =
7989b843c749SSergey Zigachev (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) & CURRENT_STATE_INDEX_MASK) >>
7990b843c749SSergey Zigachev CURRENT_STATE_INDEX_SHIFT;
7991b843c749SSergey Zigachev
7992b843c749SSergey Zigachev /* size must be at least 4 bytes for all sensors */
7993b843c749SSergey Zigachev if (*size < 4)
7994b843c749SSergey Zigachev return -EINVAL;
7995b843c749SSergey Zigachev
7996b843c749SSergey Zigachev switch (idx) {
7997b843c749SSergey Zigachev case AMDGPU_PP_SENSOR_GFX_SCLK:
7998b843c749SSergey Zigachev if (pl_index < ps->performance_level_count) {
7999b843c749SSergey Zigachev sclk = ps->performance_levels[pl_index].sclk;
8000b843c749SSergey Zigachev *((uint32_t *)value) = sclk;
8001b843c749SSergey Zigachev *size = 4;
8002b843c749SSergey Zigachev return 0;
8003b843c749SSergey Zigachev }
8004b843c749SSergey Zigachev return -EINVAL;
8005b843c749SSergey Zigachev case AMDGPU_PP_SENSOR_GFX_MCLK:
8006b843c749SSergey Zigachev if (pl_index < ps->performance_level_count) {
8007b843c749SSergey Zigachev mclk = ps->performance_levels[pl_index].mclk;
8008b843c749SSergey Zigachev *((uint32_t *)value) = mclk;
8009b843c749SSergey Zigachev *size = 4;
8010b843c749SSergey Zigachev return 0;
8011b843c749SSergey Zigachev }
8012b843c749SSergey Zigachev return -EINVAL;
8013b843c749SSergey Zigachev case AMDGPU_PP_SENSOR_GPU_TEMP:
8014b843c749SSergey Zigachev *((uint32_t *)value) = si_dpm_get_temp(adev);
8015b843c749SSergey Zigachev *size = 4;
8016b843c749SSergey Zigachev return 0;
8017b843c749SSergey Zigachev default:
8018b843c749SSergey Zigachev return -EINVAL;
8019b843c749SSergey Zigachev }
8020b843c749SSergey Zigachev }
8021b843c749SSergey Zigachev
8022b843c749SSergey Zigachev static const struct amd_ip_funcs si_dpm_ip_funcs = {
8023b843c749SSergey Zigachev .name = "si_dpm",
8024b843c749SSergey Zigachev .early_init = si_dpm_early_init,
8025b843c749SSergey Zigachev .late_init = si_dpm_late_init,
8026b843c749SSergey Zigachev .sw_init = si_dpm_sw_init,
8027b843c749SSergey Zigachev .sw_fini = si_dpm_sw_fini,
8028b843c749SSergey Zigachev .hw_init = si_dpm_hw_init,
8029b843c749SSergey Zigachev .hw_fini = si_dpm_hw_fini,
8030b843c749SSergey Zigachev .suspend = si_dpm_suspend,
8031b843c749SSergey Zigachev .resume = si_dpm_resume,
8032b843c749SSergey Zigachev .is_idle = si_dpm_is_idle,
8033b843c749SSergey Zigachev .wait_for_idle = si_dpm_wait_for_idle,
8034b843c749SSergey Zigachev .soft_reset = si_dpm_soft_reset,
8035b843c749SSergey Zigachev .set_clockgating_state = si_dpm_set_clockgating_state,
8036b843c749SSergey Zigachev .set_powergating_state = si_dpm_set_powergating_state,
8037b843c749SSergey Zigachev };
8038b843c749SSergey Zigachev
8039b843c749SSergey Zigachev const struct amdgpu_ip_block_version si_smu_ip_block =
8040b843c749SSergey Zigachev {
8041b843c749SSergey Zigachev .type = AMD_IP_BLOCK_TYPE_SMC,
8042b843c749SSergey Zigachev .major = 6,
8043b843c749SSergey Zigachev .minor = 0,
8044b843c749SSergey Zigachev .rev = 0,
8045b843c749SSergey Zigachev .funcs = &si_dpm_ip_funcs,
8046b843c749SSergey Zigachev };
8047b843c749SSergey Zigachev
8048b843c749SSergey Zigachev static const struct amd_pm_funcs si_dpm_funcs = {
8049b843c749SSergey Zigachev .pre_set_power_state = &si_dpm_pre_set_power_state,
8050b843c749SSergey Zigachev .set_power_state = &si_dpm_set_power_state,
8051b843c749SSergey Zigachev .post_set_power_state = &si_dpm_post_set_power_state,
8052b843c749SSergey Zigachev .display_configuration_changed = &si_dpm_display_configuration_changed,
8053b843c749SSergey Zigachev .get_sclk = &si_dpm_get_sclk,
8054b843c749SSergey Zigachev .get_mclk = &si_dpm_get_mclk,
8055b843c749SSergey Zigachev .print_power_state = &si_dpm_print_power_state,
8056b843c749SSergey Zigachev .debugfs_print_current_performance_level = &si_dpm_debugfs_print_current_performance_level,
8057b843c749SSergey Zigachev .force_performance_level = &si_dpm_force_performance_level,
8058b843c749SSergey Zigachev .vblank_too_short = &si_dpm_vblank_too_short,
8059b843c749SSergey Zigachev .set_fan_control_mode = &si_dpm_set_fan_control_mode,
8060b843c749SSergey Zigachev .get_fan_control_mode = &si_dpm_get_fan_control_mode,
8061b843c749SSergey Zigachev .set_fan_speed_percent = &si_dpm_set_fan_speed_percent,
8062b843c749SSergey Zigachev .get_fan_speed_percent = &si_dpm_get_fan_speed_percent,
8063b843c749SSergey Zigachev .check_state_equal = &si_check_state_equal,
8064b843c749SSergey Zigachev .get_vce_clock_state = amdgpu_get_vce_clock_state,
8065b843c749SSergey Zigachev .read_sensor = &si_dpm_read_sensor,
8066b843c749SSergey Zigachev };
8067b843c749SSergey Zigachev
8068b843c749SSergey Zigachev static const struct amdgpu_irq_src_funcs si_dpm_irq_funcs = {
8069b843c749SSergey Zigachev .set = si_dpm_set_interrupt_state,
8070b843c749SSergey Zigachev .process = si_dpm_process_interrupt,
8071b843c749SSergey Zigachev };
8072b843c749SSergey Zigachev
si_dpm_set_irq_funcs(struct amdgpu_device * adev)8073b843c749SSergey Zigachev static void si_dpm_set_irq_funcs(struct amdgpu_device *adev)
8074b843c749SSergey Zigachev {
8075b843c749SSergey Zigachev adev->pm.dpm.thermal.irq.num_types = AMDGPU_THERMAL_IRQ_LAST;
8076b843c749SSergey Zigachev adev->pm.dpm.thermal.irq.funcs = &si_dpm_irq_funcs;
8077b843c749SSergey Zigachev }
8078b843c749SSergey Zigachev
8079