ARM: tegra11: power: Add AP40 core edp tables
[linux-3.10.git] / arch / arm / mach-tegra / tegra11_edp.c
1 /*
2  * arch/arm/mach-tegra/tegra11_edp.c
3  *
4  * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/string.h>
22 #include <linux/module.h>
23 #include <linux/clk.h>
24 #include <linux/kobject.h>
25 #include <linux/err.h>
26
27 #include <mach/edp.h>
28
29 #include "clock.h"
30 #include "fuse.h"
31
32 #define CORE_MODULES_STATES 1
33 #define TEMPERATURE_RANGES 4
34 #define CAP_CLKS_NUM 2
35 #define TOTAL_CAPS (CORE_EDP_PROFILES_NUM * CORE_MODULES_STATES *\
36                         TEMPERATURE_RANGES * CAP_CLKS_NUM)
37
38 struct core_edp_entry {
39         int sku;
40         int process_id;
41         unsigned int cap_mA;
42         int mult;
43         unsigned long cap_scpu_on[CORE_EDP_PROFILES_NUM][
44                 CORE_MODULES_STATES][TEMPERATURE_RANGES][CAP_CLKS_NUM];
45         unsigned long cap_scpu_off[CORE_EDP_PROFILES_NUM][
46                 CORE_MODULES_STATES][TEMPERATURE_RANGES][CAP_CLKS_NUM];
47 };
48
49 static int temperatures[] = { 50, 70, 90, 105 };
50
51 #ifdef CONFIG_TEGRA_DUAL_CBUS
52 static char *cap_clks_names[] = { "edp.emc", "edp.c2bus" };
53 #else
54 static char *cap_clks_names[] = { "edp.emc", "edp.cbus" };
55 #endif
56 static struct clk *cap_clks[CAP_CLKS_NUM];
57
58 static struct core_edp_entry core_edp_table[] = {
59         /* SKU 3 */
60         {
61                 .sku            = 0x3,          /* SKU = 3 */
62                 .process_id     = -1,           /* any process id */
63                 .cap_mA         = 6000,         /* 6A cap */
64                 .mult           = 1000000,      /* MHZ */
65                 .cap_scpu_on    = {
66                         /* favor emc */
67                         {       /* core modules power state 0 (all ON) */
68                                 {{ 924, 636 },
69                                  { 924, 612 },
70                                  { 924, 564 },
71                                  { 924, 384 },
72                                 },
73                         },
74                         /* balanced profile */
75                         {       /* core modules power state 0 (all ON) */
76                                 {{ 792, 636 },
77                                  { 792, 636 },
78                                  { 792, 636 },
79                                  { 792, 384 },
80                                 },
81                         },
82                         /* favor gpu */
83                         {       /* core modules power state 0 (all ON) */
84                                 {{ 624, 672 },
85                                  { 624, 672 },
86                                  { 528, 672 },
87                                  { 528, 384 },
88                                 }
89                         },
90                 },
91                 .cap_scpu_off   = {
92                         /* favor emc */
93                         {       /* core modules power state 0 (all ON) */
94                                 {{ 924, 672 },
95                                  { 924, 648 },
96                                  { 924, 636 },
97                                  { 924, 516 },
98                                 },
99                         },
100                         /* balanced profile */
101                         {       /* core modules power state 0 (all ON) */
102                                 {{ 924, 672 },
103                                  { 792, 672 },
104                                  { 792, 672 },
105                                  { 792, 516 },
106                                 },
107                         },
108                         /* favor gpu */
109                         {       /* core modules power state 0 (all ON) */
110                                 {{ 924, 672 },
111                                  { 792, 672 },
112                                  { 792, 672 },
113                                  { 792, 516 },
114                                 }
115                         },
116                 },
117         },
118         {
119                 .sku            = 0x3,          /* SKU = 3 */
120                 .process_id     = -1,           /* any process id */
121                 .cap_mA         = 8000,         /* 8A cap */
122                 .mult           = 1000000,      /* MHZ */
123                 .cap_scpu_on    = {
124                         /* favor emc */
125                         {       /* core modules power state 0 (all ON) */
126                                 {{ 924, 672 },
127                                  { 924, 672 },
128                                  { 924, 672 },
129                                  { 924, 588 },
130                                 },
131                         },
132                         /* balanced profile */
133                         {       /* core modules power state 0 (all ON) */
134                                 {{ 924, 672 },
135                                  { 924, 672 },
136                                  { 924, 672 },
137                                  { 924, 588 },
138                                 },
139                         },
140                         /* favor gpu */
141                         {       /* core modules power state 0 (all ON) */
142                                 {{ 924, 672 },
143                                  { 924, 672 },
144                                  { 924, 672 },
145                                  { 924, 588 },
146                                 }
147                         },
148                 },
149                 .cap_scpu_off   = {
150                         /* favor emc */
151                         {       /* core modules power state 0 (all ON) */
152                                 {{ 924, 672 },
153                                  { 924, 672 },
154                                  { 924, 672 },
155                                  { 924, 588 },
156                                 },
157                         },
158                         /* balanced profile */
159                         {       /* core modules power state 0 (all ON) */
160                                 {{ 924, 672 },
161                                  { 924, 672 },
162                                  { 924, 672 },
163                                  { 924, 588 },
164                                 },
165                         },
166                         /* favor gpu */
167                         {       /* core modules power state 0 (all ON) */
168                                 {{ 924, 672 },
169                                  { 924, 672 },
170                                  { 924, 672 },
171                                  { 924, 588 },
172                                 }
173                         },
174                 },
175         },
176         /* SKU 5 */
177         {
178                 .sku            = 0x5,          /* SKU = 5 */
179                 .process_id     = 0,            /* bin 0 */
180                 .cap_mA         = 4000,         /* 4A cap */
181                 .mult           = 1000000,      /* MHZ */
182                 .cap_scpu_on    = {
183                         /* favor emc */
184                         {       /* core modules power state 0 (all ON) */
185                                 {{ 792, 336 },
186                                  { 792, 336 },
187                                  { 792, 300 },
188                                  { 792, 240 },
189                                 },
190                         },
191                         /* balanced profile */
192                         {       /* core modules power state 0 (all ON) */
193                                 {{ 624, 396 },
194                                  { 660, 372 },
195                                  { 660, 324 },
196                                  { 660, 288 },
197                                 },
198                         },
199                         /* favor gpu */
200                         {       /* core modules power state 0 (all ON) */
201                                 {{ 408, 492 },
202                                  { 408, 396 },
203                                  { 408, 396 },
204                                  { 408, 396 },
205                                 }
206                         },
207                 },
208                 .cap_scpu_off   = {
209                         /* favor emc */
210                         {       /* core modules power state 0 (all ON) */
211                                 {{ 792, 432 },
212                                  { 792, 432 },
213                                  { 792, 396 },
214                                  { 792, 348 },
215                                 },
216                         },
217                         /* balanced profile */
218                         {       /* core modules power state 0 (all ON) */
219                                 {{ 624, 492 },
220                                  { 660, 492 },
221                                  { 660, 444 },
222                                  { 660, 384 },
223                                 },
224                         },
225                         /* favor gpu */
226                         {       /* core modules power state 0 (all ON) */
227                                 {{ 408, 516 },
228                                  { 408, 516 },
229                                  { 408, 516 },
230                                  { 408, 492 },
231                                 }
232                         },
233                 },
234         },
235         {
236                 .sku            = 0x5,          /* SKU = 5 */
237                 .process_id     = 1,            /* bin 1 */
238                 .cap_mA         = 4000,         /* 4A cap */
239                 .mult           = 1000000,      /* MHZ */
240                 .cap_scpu_on    = {
241                         /* favor emc */
242                         {       /* core modules power state 0 (all ON) */
243                                 {{ 792, 348 },
244                                  { 792, 336 },
245                                  { 792, 300 },
246                                  { 792, 240 },
247                                 },
248                         },
249                         /* balanced profile */
250                         {       /* core modules power state 0 (all ON) */
251                                 {{ 624, 420 },
252                                  { 660, 372 },
253                                  { 660, 324 },
254                                  { 660, 288 },
255                                 },
256                         },
257                         /* favor gpu */
258                         {       /* core modules power state 0 (all ON) */
259                                 {{ 408, 528 },
260                                  { 408, 492 },
261                                  { 408, 420 },
262                                  { 408, 420 },
263                                 }
264                         },
265                 },
266                 .cap_scpu_off   = {
267                         /* favor emc */
268                         {       /* core modules power state 0 (all ON) */
269                                 {{ 792, 432 },
270                                  { 792, 432 },
271                                  { 792, 396 },
272                                  { 792, 348 },
273                                 },
274                         },
275                         /* balanced profile */
276                         {       /* core modules power state 0 (all ON) */
277                                 {{ 624, 528 },
278                                  { 660, 492 },
279                                  { 660, 444 },
280                                  { 660, 384 },
281                                 },
282                         },
283                         /* favor gpu */
284                         {       /* core modules power state 0 (all ON) */
285                                 {{ 408, 564 },
286                                  { 408, 564 },
287                                  { 408, 528 },
288                                  { 408, 528 },
289                                 }
290                         },
291                 },
292         },
293         {
294                 .sku            = 0x5,          /* SKU = 5 */
295                 .process_id     = -1,           /* any process id */
296                 .cap_mA         = 6000,         /* 6A cap */
297                 .mult           = 1000000,      /* MHZ */
298                 .cap_scpu_on    = {
299                         /* favor emc */
300                         {       /* core modules power state 0 (all ON) */
301                                 {{ 792, 600 },
302                                  { 792, 600 },
303                                  { 792, 600 },
304                                  { 792, 516 },
305                                 },
306                         },
307                         /* balanced profile */
308                         {       /* core modules power state 0 (all ON) */
309                                 {{ 792, 600 },
310                                  { 792, 600 },
311                                  { 660, 600 },
312                                  { 660, 564 },
313                                 },
314                         },
315                         /* favor gpu */
316                         {       /* core modules power state 0 (all ON) */
317                                 {{ 792, 600 },
318                                  { 792, 600 },
319                                  { 660, 600 },
320                                  { 528, 600 },
321                                 }
322                         },
323                 },
324                 .cap_scpu_off   = {
325                         /* favor emc */
326                         {       /* core modules power state 0 (all ON) */
327                                 {{ 792, 600 },
328                                  { 792, 600 },
329                                  { 792, 600 },
330                                  { 792, 600 },
331                                 },
332                         },
333                         /* balanced profile */
334                         {       /* core modules power state 0 (all ON) */
335                                 {{ 792, 600 },
336                                  { 792, 600 },
337                                  { 792, 600 },
338                                  { 624, 600 },
339                                 },
340                         },
341                         /* favor gpu */
342                         {       /* core modules power state 0 (all ON) */
343                                 {{ 792, 600 },
344                                  { 792, 600 },
345                                  { 792, 600 },
346                                  { 624, 600 },
347                                 }
348                         },
349                 },
350         },
351         /* SKU 6 */
352         {
353                 .sku            = 0x6,          /* SKU = 6 */
354                 .process_id     = 0,            /* bin 0 */
355                 .cap_mA         = 4000,         /* 4A cap */
356                 .mult           = 1000000,      /* MHZ */
357                 .cap_scpu_on    = {
358                         /* favor emc */
359                         {       /* core modules power state 0 (all ON) */
360                                 {{ 792, 348 },
361                                  { 792, 348 },
362                                  { 792, 312 },
363                                  { 792, 264 },
364                                 },
365                         },
366                         /* balanced profile */
367                         {       /* core modules power state 0 (all ON) */
368                                 {{ 660, 372 },
369                                  { 660, 372 },
370                                  { 660, 336 },
371                                  { 660, 300 },
372                                 },
373                         },
374                         /* favor gpu */
375                         {       /* core modules power state 0 (all ON) */
376                                 {{ 408, 492 },
377                                  { 408, 396 },
378                                  { 408, 396 },
379                                  { 408, 396 },
380                                 }
381                         },
382                 },
383                 .cap_scpu_off   = {
384                         /* favor emc */
385                         {       /* core modules power state 0 (all ON) */
386                                 {{ 792, 444 },
387                                  { 792, 444 },
388                                  { 792, 408 },
389                                  { 792, 372 },
390                                 },
391                         },
392                         /* balanced profile */
393                         {       /* core modules power state 0 (all ON) */
394                                 {{ 660, 492 },
395                                  { 660, 492 },
396                                  { 660, 456 },
397                                  { 660, 408 },
398                                 },
399                         },
400                         /* favor gpu */
401                         {       /* core modules power state 0 (all ON) */
402                                 {{ 408, 552 },
403                                  { 408, 516 },
404                                  { 408, 516 },
405                                  { 408, 516 },
406                                 }
407                         },
408                 },
409         },
410         {
411                 .sku            = 0x6,          /* SKU = 6 */
412                 .process_id     = 1,            /* bin 1 */
413                 .cap_mA         = 4000,         /* 4A cap */
414                 .mult           = 1000000,      /* MHZ */
415                 .cap_scpu_on    = {
416                         /* favor emc */
417                         {       /* core modules power state 0 (all ON) */
418                                 {{ 792, 348 },
419                                  { 792, 348 },
420                                  { 792, 312 },
421                                  { 792, 264 },
422                                 },
423                         },
424                         /* balanced profile */
425                         {       /* core modules power state 0 (all ON) */
426                                 {{ 660, 420 },
427                                  { 660, 372 },
428                                  { 660, 336 },
429                                  { 660, 300 },
430                                 },
431                         },
432                         /* favor gpu */
433                         {       /* core modules power state 0 (all ON) */
434                                 {{ 408, 528 },
435                                  { 408, 492 },
436                                  { 408, 420 },
437                                  { 408, 420 },
438                                 }
439                         },
440                 },
441                 .cap_scpu_off   = {
442                         /* favor emc */
443                         {       /* core modules power state 0 (all ON) */
444                                 {{ 792, 444 },
445                                  { 792, 444 },
446                                  { 792, 408 },
447                                  { 792, 372 },
448                                 },
449                         },
450                         /* balanced profile */
451                         {       /* core modules power state 0 (all ON) */
452                                 {{ 660, 492 },
453                                  { 660, 492 },
454                                  { 660, 456 },
455                                  { 660, 408 },
456                                 },
457                         },
458                         /* favor gpu */
459                         {       /* core modules power state 0 (all ON) */
460                                 {{ 408, 564 },
461                                  { 408, 564 },
462                                  { 408, 564 },
463                                  { 408, 528 },
464                                 }
465                         },
466                 },
467         },
468         {
469                 .sku            = 0x6,          /* SKU = 6 */
470                 .process_id     = -1,           /* any process id */
471                 .cap_mA         = 6000,         /* 6A cap */
472                 .mult           = 1000000,      /* MHZ */
473                 .cap_scpu_on    = {
474                         /* favor emc */
475                         {       /* core modules power state 0 (all ON) */
476                                 {{ 792, 600 },
477                                  { 792, 600 },
478                                  { 792, 600 },
479                                  { 792, 516 },
480                                 },
481                         },
482                         /* balanced profile */
483                         {       /* core modules power state 0 (all ON) */
484                                 {{ 792, 600 },
485                                  { 792, 600 },
486                                  { 792, 600 },
487                                  { 660, 600 },
488                                 },
489                         },
490                         /* favor gpu */
491                         {       /* core modules power state 0 (all ON) */
492                                 {{ 792, 600 },
493                                  { 792, 600 },
494                                  { 792, 600 },
495                                  { 660, 600 },
496                                 }
497                         },
498                 },
499                 .cap_scpu_off   = {
500                         /* favor emc */
501                         {       /* core modules power state 0 (all ON) */
502                                 {{ 792, 600 },
503                                  { 792, 600 },
504                                  { 792, 600 },
505                                  { 792, 600 },
506                                 },
507                         },
508                         /* balanced profile */
509                         {       /* core modules power state 0 (all ON) */
510                                 {{ 792, 600 },
511                                  { 792, 600 },
512                                  { 792, 600 },
513                                  { 792, 600 },
514                                 },
515                         },
516                         /* favor gpu */
517                         {       /* core modules power state 0 (all ON) */
518                                 {{ 792, 600 },
519                                  { 792, 600 },
520                                  { 792, 600 },
521                                  { 792, 600 },
522                                 }
523                         },
524                 },
525         },
526 };
527
528 #ifdef CONFIG_TEGRA_EDP_LIMITS
529 #define LEAKAGE_CONSTS_IJK_COMMON                                       \
530         {                                                               \
531                 /* i = 0 */                                             \
532                 { {   13919916,  -28721837,   7560552,  -570495, },     \
533                   {  -39991855,   87294629, -22972570,  1734058, },     \
534                   {   36869935,  -86826110,  22833611, -1723750, },     \
535                   {  -10611796,   28192235,  -7407903,   559012, },     \
536                 },                                                      \
537                 /* i = 1 */                                             \
538                 { {  -37335213,   53397584, -16025243,  1341064, },     \
539                   {  111121782, -160756323,  48421377, -4049609, },     \
540                   { -107149149,  157911131, -47786861,  3994796, },     \
541                   {   32802647,  -49872380,  15236453, -1268662, },     \
542                 },                                                      \
543                 /* i = 2 */                                             \
544                 { {    3315214,  -21010655,   7718286,  -789185, },     \
545                   {   -4336249,   59786076, -22312653,  2313754, },     \
546                   {   -3346058,  -54529998,  20777469, -2198700, },     \
547                   {    4810027,   15417133,  -6086955,   665766, },     \
548                 },                                                      \
549                 /* i = 3 */                                             \
550                 { {    4681958,   -1470999,   -232691,    73384, },     \
551                   {  -15445149,    5487248,    422447,  -201475, },     \
552                   {   16983482,   -6716242,    -65917,   174128, },     \
553                   {   -6293336,    2756799,   -140100,   -44673, },     \
554                 },                                                      \
555         }
556
557 #define LEAKAGE_PARAMS_COMMON_PART                                      \
558         .temp_scaled        = 10,                                       \
559         .dyn_scaled         = 1000000,                                  \
560         .dyn_consts_n       = { 1410000, 2440000, 3450000, 4440000 },   \
561         .consts_scaled      = 1000000,                                  \
562         .leakage_consts_n   = {  400000,  650000,  850000, 1050000 },   \
563         .ijk_scaled         = 10000,                                    \
564         .leakage_min        = 30,                                       \
565         .volt_temp_cap      = { 70, 1300 },                             \
566         .leakage_consts_ijk = LEAKAGE_CONSTS_IJK_COMMON
567
568 static struct tegra_edp_cpu_leakage_params t11x_leakage_params[] = {
569         {
570                 .cpu_speedo_id      = 0, /* A01 CPU */
571                 .max_current_cap = { /* values are from tegra4 datasheet */
572                         { .max_cur = 9000, .max_temp = 60,
573                                 { 1900000, 1900000, 1600000, 1600000 }
574                         },
575                         { .max_cur = 9000, .max_temp = 75,
576                                 { 1900000, 1900000, 1530000, 1530000 }
577                         },
578                         { .max_cur = 9000, .max_temp = 90,
579                                 { 1900000, 1900000, 1500000, 1500000 }
580                         },
581                         { .max_cur = 12000, .max_temp = 90,
582                                 { 1900000, 1900000, 1700000, 1700000 }
583                         },
584                         { .max_cur = 15000, .max_temp = 90,
585                                 { 1900000, 1900000, 1900000, 1900000 }
586                         },
587                 },
588                 LEAKAGE_PARAMS_COMMON_PART,
589         },
590         {
591                 .cpu_speedo_id      = 1, /* A01P+ CPU */
592                 .safety_cap         = { 1810500, 1810500, 1606500, 1606500 },
593                 .max_current_cap = { /* values are from tegra4 datasheet */
594                         { .max_cur = 7500, .max_temp = 90,
595                                 { 1800000, 1700000, 1320000, 1320000 }
596                         },
597                         { .max_cur = 7500, .max_temp = 75,
598                                 { 1800000, 1700000, 1420000, 1420000 }
599                         },
600                         { .max_cur = 7500, .max_temp = 60,
601                                 { 1800000, 1800000, 1420000, 1420000 }
602                         },
603                         { .max_cur = 7500, .max_temp = 45,
604                                 { 1800000, 1800000, 1530000, 1530000 }
605                         },
606                         { .max_cur = 9000, .max_temp = 90,
607                                 { 1800000, 1800000, 1500000, 1500000 }
608                         },
609                         { .max_cur = 9000, .max_temp = 75,
610                                 { 1800000, 1800000, 1530000, 1530000 }
611                         },
612                         { .max_cur = 9000, .max_temp = 60,
613                                 { 1800000, 1800000, 1600000, 1600000 }
614                         },
615                         { .max_cur = 12000, .max_temp = 45,
616                                 { 1800000, 1800000, 1600000, 1600000 }
617                         },
618                 },
619                 LEAKAGE_PARAMS_COMMON_PART,
620         },
621         {
622                 .cpu_speedo_id      = 2, /* A01P+ fast CPU */
623                 .safety_cap         = { 1912500, 1912500, 1912500, 1912500 },
624                 .max_current_cap = { /* values are from tegra4 datasheet */
625                         { .max_cur = 9000, .max_temp = 90,
626                                 { 1900000, 1900000, 1500000, 1500000 }
627                         },
628                         { .max_cur = 9000, .max_temp = 75,
629                                 { 1900000, 1900000, 1530000, 1530000 }
630                         },
631                         { .max_cur = 9000, .max_temp = 60,
632                                 { 1900000, 1900000, 1600000, 1600000 }
633                         },
634                         { .max_cur = 12000, .max_temp = 90,
635                                 { 1900000, 1900000, 1700000, 1700000 }
636                         },
637                         { .max_cur = 15000, .max_temp = 90,
638                                 { 1900000, 1900000, 1900000, 1900000 }
639                         },
640                 },
641                 LEAKAGE_PARAMS_COMMON_PART,
642         },
643 };
644
645 struct tegra_edp_cpu_leakage_params *tegra11x_get_leakage_params(int index,
646                                                         unsigned int *sz)
647 {
648         BUG_ON(index >= ARRAY_SIZE(t11x_leakage_params));
649         if (sz)
650                 *sz = ARRAY_SIZE(t11x_leakage_params);
651         return &t11x_leakage_params[index];
652 }
653 #endif
654
655 static struct core_edp_entry *find_edp_entry(int sku, unsigned int regulator_mA)
656 {
657         int i;
658         int pid = tegra_core_process_id();
659
660         for (i = 0; i < ARRAY_SIZE(core_edp_table); i++) {
661                 struct core_edp_entry *entry = &core_edp_table[i];
662                 if ((entry->sku == sku) && (entry->cap_mA == regulator_mA) &&
663                     ((entry->process_id == -1) || (entry->process_id == pid)))
664                         return entry;
665         }
666         return NULL;
667 }
668
669 static unsigned long clip_cap_rate(struct clk *cap_clk, unsigned long rate)
670 {
671         unsigned long floor, ceiling;
672         struct clk *p = clk_get_parent(cap_clk);
673
674         if (!p || !p->ops || !p->ops->shared_bus_update) {
675                 WARN(1, "%s: edp cap clk %s is not a shared bus user\n",
676                         __func__, cap_clk->name);
677                 return rate;
678         }
679
680         /*
681          * Clip cap rate to shared bus possible rates (going up via shared
682          * bus * ladder since bus clocks always rounds up with resolution of
683          * at least 2kHz)
684          */
685         ceiling = clk_round_rate(p, clk_get_min_rate(p));
686         do {
687                 floor = ceiling;
688                 ceiling = clk_round_rate(p, floor + 2000);
689                 if (IS_ERR_VALUE(ceiling)) {
690                         pr_err("%s: failed to clip %lu to %s possible rates\n",
691                                __func__, rate, p->name);
692                         return rate;
693                 }
694         } while ((floor < ceiling) && (ceiling <= rate));
695
696         if (floor > rate)
697                 WARN(1, "%s: %s cap rate %lu is below %s floor %lu\n",
698                         __func__, cap_clk->name, rate, p->name, floor);
699         return floor;
700 }
701
702 int __init tegra11x_select_core_edp_table(unsigned int regulator_mA,
703                                           struct tegra_core_edp_limits *limits)
704 {
705         int i;
706         int sku = tegra_sku_id;
707         unsigned long *cap_rates;
708         struct core_edp_entry *edp_entry;
709
710         BUG_ON(ARRAY_SIZE(temperatures) != TEMPERATURE_RANGES);
711         BUG_ON(ARRAY_SIZE(cap_clks_names) != CAP_CLKS_NUM);
712         for (i = 0; i < CAP_CLKS_NUM; i++) {
713                 struct clk *c = tegra_get_clock_by_name(cap_clks_names[i]);
714                 if (!c) {
715                         pr_err("%s: failed to find edp cap clock %s\n",
716                                __func__, cap_clks_names[i]);
717                         return -ENODEV;
718                 }
719                 cap_clks[i] = c;
720         }
721
722         edp_entry = find_edp_entry(sku, regulator_mA);
723         if (!edp_entry) {
724                 pr_info("%s: no core edp table for sku %d, %d mA\n",
725                        __func__, sku, regulator_mA);
726                 return -ENODATA;
727         }
728
729         limits->sku = sku;
730         limits->cap_clocks = cap_clks;
731         limits->cap_clocks_num = CAP_CLKS_NUM;
732         limits->temperatures = temperatures;
733         limits->temperature_ranges = TEMPERATURE_RANGES;
734         limits->core_modules_states = CORE_MODULES_STATES;
735
736         cap_rates = &edp_entry->cap_scpu_on[0][0][0][0];
737         limits->cap_rates_scpu_on = cap_rates;
738         for (i = 0; i < TOTAL_CAPS; i++, cap_rates++) {
739                 unsigned long rate = *cap_rates * edp_entry->mult;
740                 *cap_rates = clip_cap_rate(cap_clks[i % CAP_CLKS_NUM], rate);
741         }
742
743         cap_rates = &edp_entry->cap_scpu_off[0][0][0][0];
744         limits->cap_rates_scpu_off = cap_rates;
745         for (i = 0; i < TOTAL_CAPS; i++, cap_rates++) {
746                 unsigned long rate = *cap_rates * edp_entry->mult;
747                 *cap_rates = clip_cap_rate(cap_clks[i % CAP_CLKS_NUM], rate);
748         }
749
750         return 0;
751 }