1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
6 * Samsung Exynos 5422 SoC Adaptive Supply Voltage support
9 #include <linux/bitrev.h>
10 #include <linux/errno.h>
11 #include <linux/regmap.h>
12 #include <linux/soc/samsung/exynos-chipid.h>
13 #include <linux/slab.h>
15 #include "exynos-asv.h"
16 #include "exynos5422-asv.h"
18 #define ASV_GROUPS_NUM 14
19 #define ASV_ARM_DVFS_NUM 20
20 #define ASV_ARM_BIN2_DVFS_NUM 17
21 #define ASV_KFC_DVFS_NUM 14
22 #define ASV_KFC_BIN2_DVFS_NUM 12
25 * This array is a set of 4 ASV data tables, first column of each ASV table
26 * contains frequency value in MHz and subsequent columns contain the CPU
27 * cluster's supply voltage values in uV.
28 * In order to create a set of OPPs for specific SoC revision one of the voltage
29 * columns (1...14) from one of the tables (0...3) is selected during
30 * initialization. There are separate ASV tables for the big (ARM) and little
31 * (KFC) CPU cluster. Only OPPs which are already defined in devicetree
35 static const u32 asv_arm_table
[][ASV_ARM_DVFS_NUM
][ASV_GROUPS_NUM
+ 1] = {
38 { 2100, 1362500, 1362500, 1350000, 1337500, 1325000, 1312500, 1300000,
39 1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000 },
40 { 2000, 1312500, 1312500, 1300000, 1287500, 1275000, 1262500, 1250000,
41 1237500, 1225000, 1237500, 1225000, 1212500, 1200000, 1187500 },
42 { 1900, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500, 1175000,
43 1162500, 1150000, 1162500, 1150000, 1137500, 1125000, 1112500 },
44 { 1800, 1200000, 1187500, 1175000, 1162500, 1150000, 1137500, 1125000,
45 1112500, 1100000, 1112500, 1100000, 1087500, 1075000, 1062500 },
46 { 1700, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000, 1087500,
47 1075000, 1062500, 1075000, 1062500, 1050000, 1037500, 1025000 },
48 { 1600, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500, 1050000,
49 1037500, 1025000, 1037500, 1025000, 1012500, 1000000, 987500 },
50 { 1500, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500,
51 1000000, 987500, 1000000, 987500, 975000, 962500, 950000 },
52 { 1400, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
53 975000, 962500, 975000, 962500, 950000, 937500, 925000 },
54 { 1300, 1050000, 1037500, 1025000, 1012500, 1000000, 987500, 975000,
55 962500, 950000, 962500, 950000, 937500, 925000, 912500 },
56 { 1200, 1025000, 1012500, 1000000, 987500, 975000, 962500, 950000,
57 937500, 925000, 937500, 925000, 912500, 900000, 900000 },
58 { 1100, 1000000, 987500, 975000, 962500, 950000, 937500, 925000,
59 912500, 900000, 900000, 900000, 900000, 900000, 900000 },
60 { 1000, 975000, 962500, 950000, 937500, 925000, 912500, 900000,
61 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
62 { 900, 950000, 937500, 925000, 912500, 900000, 900000, 900000,
63 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
64 { 800, 925000, 912500, 900000, 900000, 900000, 900000, 900000,
65 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
66 { 700, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
67 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
68 { 600, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
69 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
70 { 500, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
71 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
72 { 400, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
73 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
74 { 300, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
75 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
76 { 200, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
77 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
80 { 2100, 1362500, 1362500, 1350000, 1337500, 1325000, 1312500, 1300000,
81 1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000 },
82 { 2000, 1312500, 1312500, 1312500, 1300000, 1275000, 1262500, 1250000,
83 1237500, 1225000, 1237500, 1225000, 1212500, 1200000, 1187500 },
84 { 1900, 1262500, 1250000, 1250000, 1237500, 1212500, 1200000, 1187500,
85 1175000, 1162500, 1175000, 1162500, 1150000, 1137500, 1125000 },
86 { 1800, 1212500, 1200000, 1187500, 1175000, 1162500, 1150000, 1137500,
87 1125000, 1112500, 1125000, 1112500, 1100000, 1087500, 1075000 },
88 { 1700, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
89 1087500, 1075000, 1087500, 1075000, 1062500, 1050000, 1037500 },
90 { 1600, 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
91 1050000, 1037500, 1050000, 1037500, 1025000, 1012500, 1000000 },
92 { 1500, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
93 1012500, 1000000, 1012500, 1000000, 987500, 975000, 962500 },
94 { 1400, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000,
95 987500, 975000, 987500, 975000, 962500, 950000, 937500 },
96 { 1300, 1050000, 1037500, 1025000, 1012500, 1000000, 987500, 975000,
97 962500, 950000, 962500, 950000, 937500, 925000, 912500 },
98 { 1200, 1025000, 1012500, 1000000, 987500, 975000, 962500, 950000,
99 937500, 925000, 937500, 925000, 912500, 900000, 900000 },
100 { 1100, 1000000, 987500, 975000, 962500, 950000, 937500, 925000,
101 912500, 900000, 900000, 900000, 900000, 900000, 900000 },
102 { 1000, 975000, 962500, 950000, 937500, 925000, 912500, 900000,
103 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
104 { 900, 950000, 937500, 925000, 912500, 900000, 900000, 900000,
105 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
106 { 800, 925000, 912500, 900000, 900000, 900000, 900000, 900000,
107 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
108 { 700, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
109 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
110 { 600, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
111 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
112 { 500, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
113 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
114 { 400, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
115 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
116 { 300, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
117 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
118 { 200, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
119 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
122 { 2100, 1362500, 1362500, 1350000, 1337500, 1325000, 1312500, 1300000,
123 1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000 },
124 { 2000, 1312500, 1312500, 1300000, 1287500, 1275000, 1262500, 1250000,
125 1237500, 1225000, 1237500, 1225000, 1212500, 1200000, 1187500 },
126 { 1900, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500,
127 1175000, 1162500, 1175000, 1162500, 1150000, 1137500, 1125000 },
128 { 1800, 1212500, 1200000, 1187500, 1175000, 1162500, 1150000, 1137500,
129 1125000, 1112500, 1125000, 1112500, 1100000, 1087500, 1075000 },
130 { 1700, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
131 1087500, 1075000, 1087500, 1075000, 1062500, 1050000, 1037500 },
132 { 1600, 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
133 1050000, 1037500, 1050000, 1037500, 1025000, 1012500, 1000000 },
134 { 1500, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
135 1012500, 1000000, 1012500, 1000000, 987500, 975000, 962500 },
136 { 1400, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000,
137 987500, 975000, 987500, 975000, 962500, 950000, 937500 },
138 { 1300, 1050000, 1037500, 1025000, 1012500, 1000000, 987500, 975000,
139 962500, 950000, 962500, 950000, 937500, 925000, 912500 },
140 { 1200, 1025000, 1012500, 1000000, 987500, 975000, 962500, 950000,
141 937500, 925000, 937500, 925000, 912500, 900000, 900000 },
142 { 1100, 1000000, 987500, 975000, 962500, 950000, 937500, 925000,
143 912500, 900000, 900000, 900000, 900000, 900000, 900000 },
144 { 1000, 975000, 962500, 950000, 937500, 925000, 912500, 900000,
145 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
146 { 900, 950000, 937500, 925000, 912500, 900000, 900000, 900000,
147 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
148 { 800, 925000, 912500, 900000, 900000, 900000, 900000, 900000,
149 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
150 { 700, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
151 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
152 { 600, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
153 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
154 { 500, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
155 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
156 { 400, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
157 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
158 { 300, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
159 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
160 { 200, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
161 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
164 { 1800, 1237500, 1225000, 1212500, 1200000, 1187500, 1175000, 1162500,
165 1150000, 1137500, 1150000, 1137500, 1125000, 1112500, 1100000 },
166 { 1700, 1200000, 1187500, 1175000, 1162500, 1150000, 1137500, 1125000,
167 1112500, 1100000, 1112500, 1100000, 1087500, 1075000, 1062500 },
168 { 1600, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000, 1087500,
169 1075000, 1062500, 1075000, 1062500, 1050000, 1037500, 1025000 },
170 { 1500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500, 1050000,
171 1037500, 1025000, 1037500, 1025000, 1012500, 1000000, 987500 },
172 { 1400, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
173 1012500, 1000000, 1012500, 1000000, 987500, 975000, 962500 },
174 { 1300, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500,
175 1000000, 987500, 1000000, 987500, 975000, 962500, 950000 },
176 { 1200, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
177 975000, 962500, 975000, 962500, 950000, 937500, 925000 },
178 { 1100, 1037500, 1025000, 1012500, 1000000, 987500, 975000, 962500,
179 950000, 937500, 950000, 937500, 925000, 912500, 900000 },
180 { 1000, 1012500, 1000000, 987500, 975000, 962500, 950000, 937500,
181 925000, 912500, 925000, 912500, 900000, 900000, 900000 },
182 { 900, 987500, 975000, 962500, 950000, 937500, 925000, 912500,
183 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
184 { 800, 962500, 950000, 937500, 925000, 912500, 900000, 900000,
185 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
186 { 700, 937500, 925000, 912500, 900000, 900000, 900000, 900000,
187 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
188 { 600, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
189 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
190 { 500, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
191 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
192 { 400, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
193 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
194 { 300, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
195 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
196 { 200, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
197 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
201 static const u32 asv_kfc_table
[][ASV_KFC_DVFS_NUM
][ASV_GROUPS_NUM
+ 1] = {
204 { 1500000, 1300000, 1300000, 1300000, 1287500, 1287500, 1287500, 1275000,
205 1262500, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500 },
206 { 1400000, 1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000,
207 1187500, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500 },
208 { 1300000, 1225000, 1212500, 1200000, 1187500, 1175000, 1162500, 1150000,
209 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500 },
210 { 1200000, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
211 1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500 },
212 { 1100000, 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
213 1050000, 1037500, 1025000, 1012500, 1000000, 987500, 975000 },
214 { 1000000, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
215 1012500, 1000000, 987500, 975000, 962500, 950000, 937500 },
216 { 900000, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
217 975000, 962500, 950000, 937500, 925000, 912500, 900000 },
218 { 800000, 1025000, 1012500, 1000000, 987500, 975000, 962500, 950000,
219 937500, 925000, 912500, 900000, 900000, 900000, 900000 },
220 { 700000, 987500, 975000, 962500, 950000, 937500, 925000, 912500,
221 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
222 { 600000, 950000, 937500, 925000, 912500, 900000, 900000, 900000,
223 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
224 { 500000, 912500, 900000, 900000, 900000, 900000, 900000, 900000,
225 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
226 { 400000, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
227 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
228 { 300000, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
229 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
230 { 200000, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
231 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
234 { 1500, 1300000, 1300000, 1300000, 1287500, 1287500, 1287500, 1275000,
235 1262500, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500 },
236 { 1400, 1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000,
237 1187500, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500 },
238 { 1300, 1225000, 1212500, 1200000, 1187500, 1175000, 1162500, 1150000,
239 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500 },
240 { 1200, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
241 1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500 },
242 { 1100, 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
243 1050000, 1037500, 1025000, 1012500, 1000000, 987500, 975000 },
244 { 1000, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
245 1012500, 1000000, 987500, 975000, 962500, 950000, 937500 },
246 { 900, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
247 975000, 962500, 950000, 937500, 925000, 912500, 900000 },
248 { 800, 1025000, 1012500, 1000000, 987500, 975000, 962500, 950000,
249 937500, 925000, 912500, 900000, 900000, 900000, 900000 },
250 { 700, 987500, 975000, 962500, 950000, 937500, 925000, 912500,
251 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
252 { 600, 950000, 937500, 925000, 912500, 900000, 900000, 900000,
253 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
254 { 500, 912500, 900000, 900000, 900000, 900000, 900000, 900000,
255 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
256 { 400, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
257 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
258 { 300, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
259 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
260 { 200, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
261 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
264 { 1500, 1300000, 1300000, 1300000, 1287500, 1287500, 1287500, 1275000,
265 1262500, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500 },
266 { 1400, 1275000, 1262500, 1250000, 1237500, 1225000, 1212500, 1200000,
267 1187500, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500 },
268 { 1300, 1225000, 1212500, 1200000, 1187500, 1175000, 1162500, 1150000,
269 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500 },
270 { 1200, 1175000, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000,
271 1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500 },
272 { 1100, 1137500, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500,
273 1050000, 1037500, 1025000, 1012500, 1000000, 987500, 975000 },
274 { 1000, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000,
275 1012500, 1000000, 987500, 975000, 962500, 950000, 937500 },
276 { 900, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000, 987500,
277 975000, 962500, 950000, 937500, 925000, 912500, 900000 },
278 { 800, 1025000, 1012500, 1000000, 987500, 975000, 962500, 950000,
279 937500, 925000, 912500, 900000, 900000, 900000, 900000 },
280 { 700, 987500, 975000, 962500, 950000, 937500, 925000, 912500,
281 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
282 { 600, 950000, 937500, 925000, 912500, 900000, 900000, 900000,
283 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
284 { 500, 912500, 900000, 900000, 900000, 900000, 900000, 900000,
285 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
286 { 400, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
287 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
288 { 300, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
289 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
290 { 200, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
291 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
294 { 1300, 1250000, 1237500, 1225000, 1212500, 1200000, 1187500, 1175000,
295 1162500, 1150000, 1137500, 1125000, 1112500, 1100000, 1087500 },
296 { 1200, 1200000, 1187500, 1175000, 1162500, 1150000, 1137500, 1125000,
297 1112500, 1100000, 1087500, 1075000, 1062500, 1050000, 1037500 },
298 { 1100, 1162500, 1150000, 1137500, 1125000, 1112500, 1100000, 1087500,
299 1075000, 1062500, 1050000, 1037500, 1025000, 1012500, 1000000 },
300 { 1000, 1125000, 1112500, 1100000, 1087500, 1075000, 1062500, 1050000,
301 1037500, 1025000, 1012500, 1000000, 987500, 975000, 962500 },
302 { 900, 1087500, 1075000, 1062500, 1050000, 1037500, 1025000, 1012500,
303 1000000, 987500, 975000, 962500, 950000, 937500, 925000 },
304 { 800, 1050000, 1037500, 1025000, 1012500, 1000000, 987500, 975000,
305 962500, 950000, 937500, 925000, 912500, 900000, 900000 },
306 { 700, 1012500, 1000000, 987500, 975000, 962500, 950000, 937500,
307 925000, 912500, 900000, 900000, 900000, 900000, 900000 },
308 { 600, 975000, 962500, 950000, 937500, 925000, 912500, 900000,
309 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
310 { 500, 937500, 925000, 912500, 900000, 900000, 900000, 900000,
311 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
312 { 400, 925000, 912500, 900000, 900000, 900000, 900000, 900000,
313 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
314 { 300, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
315 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
316 { 200, 900000, 900000, 900000, 900000, 900000, 900000, 900000,
317 900000, 900000, 900000, 900000, 900000, 900000, 900000 },
321 static const struct asv_limit_entry __asv_limits
[ASV_GROUPS_NUM
] = {
338 static int exynos5422_asv_get_group(struct exynos_asv
*asv
)
340 unsigned int pkgid_reg
, auxi_reg
;
343 regmap_read(asv
->chipid_regmap
, EXYNOS_CHIPID_REG_PKG_ID
, &pkgid_reg
);
344 regmap_read(asv
->chipid_regmap
, EXYNOS_CHIPID_REG_AUX_INFO
, &auxi_reg
);
347 u32 sga
= (pkgid_reg
>> EXYNOS5422_SG_A_OFFSET
) &
348 EXYNOS5422_SG_A_MASK
;
350 u32 sgb
= (pkgid_reg
>> EXYNOS5422_SG_B_OFFSET
) &
351 EXYNOS5422_SG_B_MASK
;
353 if ((pkgid_reg
>> EXYNOS5422_SG_BSIGN_OFFSET
) &
354 EXYNOS5422_SG_BSIGN_MASK
)
360 hpm
= (auxi_reg
>> EXYNOS5422_TMCB_OFFSET
) & EXYNOS5422_TMCB_MASK
;
361 ids
= (pkgid_reg
>> EXYNOS5422_IDS_OFFSET
) & EXYNOS5422_IDS_MASK
;
363 for (i
= 0; i
< ASV_GROUPS_NUM
; i
++) {
364 if (ids
<= __asv_limits
[i
].ids
)
366 if (hpm
<= __asv_limits
[i
].hpm
)
369 if (i
< ASV_GROUPS_NUM
)
375 static int __asv_offset_voltage(unsigned int index
)
389 static void exynos5422_asv_offset_voltage_setup(struct exynos_asv
*asv
)
391 struct exynos_asv_subsys
*subsys
;
392 unsigned int reg
, value
;
394 regmap_read(asv
->chipid_regmap
, EXYNOS_CHIPID_REG_AUX_INFO
, ®
);
396 /* ARM offset voltage setup */
397 subsys
= &asv
->subsys
[EXYNOS_ASV_SUBSYS_ID_ARM
];
399 subsys
->base_volt
= 1000000;
401 value
= (reg
>> EXYNOS5422_ARM_UP_OFFSET
) & EXYNOS5422_ARM_UP_MASK
;
402 subsys
->offset_volt_h
= __asv_offset_voltage(value
);
404 value
= (reg
>> EXYNOS5422_ARM_DN_OFFSET
) & EXYNOS5422_ARM_DN_MASK
;
405 subsys
->offset_volt_l
= __asv_offset_voltage(value
);
407 /* KFC offset voltage setup */
408 subsys
= &asv
->subsys
[EXYNOS_ASV_SUBSYS_ID_KFC
];
410 subsys
->base_volt
= 1000000;
412 value
= (reg
>> EXYNOS5422_KFC_UP_OFFSET
) & EXYNOS5422_KFC_UP_MASK
;
413 subsys
->offset_volt_h
= __asv_offset_voltage(value
);
415 value
= (reg
>> EXYNOS5422_KFC_DN_OFFSET
) & EXYNOS5422_KFC_DN_MASK
;
416 subsys
->offset_volt_l
= __asv_offset_voltage(value
);
419 static int exynos5422_asv_opp_get_voltage(const struct exynos_asv_subsys
*subsys
,
420 int level
, unsigned int volt
)
422 unsigned int asv_volt
;
424 if (level
>= subsys
->table
.num_rows
)
427 asv_volt
= exynos_asv_opp_get_voltage(subsys
, level
,
430 if (volt
> subsys
->base_volt
)
431 asv_volt
+= subsys
->offset_volt_h
;
433 asv_volt
+= subsys
->offset_volt_l
;
438 static unsigned int exynos5422_asv_parse_table(unsigned int pkg_id
)
440 return (pkg_id
>> EXYNOS5422_TABLE_OFFSET
) & EXYNOS5422_TABLE_MASK
;
443 static bool exynos5422_asv_parse_bin2(unsigned int pkg_id
)
445 return (pkg_id
>> EXYNOS5422_BIN2_OFFSET
) & EXYNOS5422_BIN2_MASK
;
448 static bool exynos5422_asv_parse_sg(unsigned int pkg_id
)
450 return (pkg_id
>> EXYNOS5422_USESG_OFFSET
) & EXYNOS5422_USESG_MASK
;
453 int exynos5422_asv_init(struct exynos_asv
*asv
)
455 struct exynos_asv_subsys
*subsys
;
456 unsigned int table_index
;
460 regmap_read(asv
->chipid_regmap
, EXYNOS_CHIPID_REG_PKG_ID
, &pkg_id
);
462 if (asv
->of_bin
== 2) {
466 asv
->use_sg
= exynos5422_asv_parse_sg(pkg_id
);
467 bin2
= exynos5422_asv_parse_bin2(pkg_id
);
470 asv
->group
= exynos5422_asv_get_group(asv
);
471 asv
->table
= exynos5422_asv_parse_table(pkg_id
);
473 exynos5422_asv_offset_voltage_setup(asv
);
478 if (asv
->table
== 2 || asv
->table
== 3)
479 table_index
= asv
->table
- 1;
484 subsys
= &asv
->subsys
[EXYNOS_ASV_SUBSYS_ID_ARM
];
485 subsys
->cpu_dt_compat
= "arm,cortex-a15";
487 subsys
->table
.num_rows
= ASV_ARM_BIN2_DVFS_NUM
;
489 subsys
->table
.num_rows
= ASV_ARM_DVFS_NUM
;
490 subsys
->table
.num_cols
= ASV_GROUPS_NUM
+ 1;
491 subsys
->table
.buf
= (u32
*)asv_arm_table
[table_index
];
493 subsys
= &asv
->subsys
[EXYNOS_ASV_SUBSYS_ID_KFC
];
494 subsys
->cpu_dt_compat
= "arm,cortex-a7";
496 subsys
->table
.num_rows
= ASV_KFC_BIN2_DVFS_NUM
;
498 subsys
->table
.num_rows
= ASV_KFC_DVFS_NUM
;
499 subsys
->table
.num_cols
= ASV_GROUPS_NUM
+ 1;
500 subsys
->table
.buf
= (u32
*)asv_kfc_table
[table_index
];
502 asv
->opp_get_voltage
= exynos5422_asv_opp_get_voltage
;