]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - arch/arm/mach-tegra/tegra3_dvfs.c
arm: tegra: dvfs: add fuse_burn to the dvfs table
[linux-2.6.git] / arch / arm / mach-tegra / tegra3_dvfs.c
1 /*
2  * arch/arm/mach-tegra/tegra3_dvfs.c
3  *
4  * Copyright (C) 2010-2011 NVIDIA Corporation.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/string.h>
20 #include <linux/module.h>
21
22 #include "clock.h"
23 #include "dvfs.h"
24 #include "fuse.h"
25 #include "board.h"
26
27 static bool tegra_dvfs_cpu_disabled;
28 static bool tegra_dvfs_core_disabled;
29
30 static const int cpu_millivolts[MAX_DVFS_FREQS] =
31         {750, 775, 800, 825, 850, 875, 900, 925, 950, 975, 1000, 1025, 1050, 1075, 1100, 1125, 1150};
32
33 static const int core_millivolts[MAX_DVFS_FREQS] =
34         {1000, 1050, 1100, 1150, 1200, 1250, 1300};
35
36 static const int core_speedo_nominal_millivolts[] =
37 /* speedo_id 0,    1,    2 */
38         { 1200, 1200, 1300 };
39
40 static const int cpu_speedo_nominal_millivolts[] =
41 /* speedo_id 0,    1,    2,    3 */
42         { 1125, 1150, 1125, 1150 };
43
44 #define KHZ 1000
45 #define MHZ 1000000
46
47 /* (VDD_CORE - cpu_below_core) <= VDD_CPU <= (VDD_CORE + core_below_cpu)]  */
48 /* (VDD_CPU - core_below_cpu) <= VDD_CORE <= (VDD_CPU + cpu_below_core)]  */
49 #define VDD_CPU_BELOW_VDD_CORE          300
50 static int cpu_below_core = VDD_CPU_BELOW_VDD_CORE;
51 #define VDD_CORE_BELOW_VDD_CPU          0
52 static int core_below_cpu = VDD_CORE_BELOW_VDD_CPU;
53
54 #define VDD_SAFE_STEP                   100
55
56 static struct dvfs_rail tegra3_dvfs_rail_vdd_cpu = {
57         .reg_id = "vdd_cpu",
58         .max_millivolts = 1150,
59         .min_millivolts = 750,
60         .step = VDD_SAFE_STEP,
61 };
62
63 static struct dvfs_rail tegra3_dvfs_rail_vdd_core = {
64         .reg_id = "vdd_core",
65         .max_millivolts = 1300,
66         .min_millivolts = 950,
67         .step = VDD_SAFE_STEP,
68 };
69
70 static struct dvfs_rail *tegra3_dvfs_rails[] = {
71         &tegra3_dvfs_rail_vdd_cpu,
72         &tegra3_dvfs_rail_vdd_core,
73 };
74
75
76 /* vdd_core must be >= (vdd_cpu - core_below_cpu) */
77 static int tegra3_dvfs_rel_vdd_cpu_vdd_core(struct dvfs_rail *vdd_cpu,
78         struct dvfs_rail *vdd_core)
79 {
80         int core_floor = max(vdd_cpu->new_millivolts, vdd_cpu->millivolts) -
81                 core_below_cpu;
82         return max(vdd_core->new_millivolts, core_floor);
83 }
84
85 /* vdd_cpu must be >= (vdd_core - cpu_below_core) */
86 static int tegra3_dvfs_rel_vdd_core_vdd_cpu(struct dvfs_rail *vdd_core,
87         struct dvfs_rail *vdd_cpu)
88 {
89         int cpu_floor = max(vdd_core->new_millivolts, vdd_core->millivolts) -
90                 cpu_below_core;
91         return max(vdd_cpu->new_millivolts, cpu_floor);
92 }
93
94 static struct dvfs_relationship tegra3_dvfs_relationships[] = {
95         {
96                 .from = &tegra3_dvfs_rail_vdd_cpu,
97                 .to = &tegra3_dvfs_rail_vdd_core,
98                 .solve = tegra3_dvfs_rel_vdd_cpu_vdd_core,
99                 .solved_at_nominal = true,
100         },
101         {
102                 .from = &tegra3_dvfs_rail_vdd_core,
103                 .to = &tegra3_dvfs_rail_vdd_cpu,
104                 .solve = tegra3_dvfs_rel_vdd_core_vdd_cpu,
105         },
106 };
107
108 #define CPU_DVFS(_clk_name, _speedo_id, _process_id, _mult, _freqs...)  \
109         {                                                               \
110                 .clk_name       = _clk_name,                            \
111                 .speedo_id      = _speedo_id,                           \
112                 .process_id     = _process_id,                          \
113                 .freqs          = {_freqs},                             \
114                 .freqs_mult     = _mult,                                \
115                 .millivolts     = cpu_millivolts,                       \
116                 .auto_dvfs      = true,                                 \
117                 .dvfs_rail      = &tegra3_dvfs_rail_vdd_cpu,            \
118         }
119
120 static struct dvfs cpu_dvfs_table[] = {
121 #if 0
122         /* Cpu voltages (mV):        750, 775, 800, 825, 850, 875,  900,  925,  950,  975, 1000, 1025, 1050, 1075, 1100, 1125, 1150*/
123         CPU_DVFS("cpu_g", 0, 0, MHZ, 399, 399, 541, 541, 684, 684,  817,  817,  817, 1026, 1102, 1149, 1187, 1225, 1282, 1300),
124         CPU_DVFS("cpu_g", 0, 1, MHZ, 481, 481, 652, 652, 807, 807,  948,  948,  948, 1117, 1171, 1206, 1300),
125         CPU_DVFS("cpu_g", 0, 2, MHZ, 540, 540, 711, 711, 883, 883, 1039, 1039, 1039, 1178, 1206, 1300),
126         CPU_DVFS("cpu_g", 0, 3, MHZ, 570, 570, 777, 777, 931, 931, 1102, 1102, 1102, 1216, 1300),
127
128         CPU_DVFS("cpu_g", 1, 0, MHZ,   1, 399, 399, 541, 541, 684,  684,  817,  817,  817, 1026, 1102, 1149, 1187, 1225, 1282, 1300),
129         CPU_DVFS("cpu_g", 1, 1, MHZ,   1, 481, 481, 652, 652, 807,  807,  948,  948,  948, 1117, 1171, 1206, 1300),
130         CPU_DVFS("cpu_g", 1, 2, MHZ,   1, 540, 540, 711, 711, 883,  883, 1039, 1039, 1039, 1178, 1206, 1300),
131         CPU_DVFS("cpu_g", 1, 3, MHZ,   1, 570, 570, 777, 777, 931,  931, 1102, 1102, 1102, 1216, 1300),
132
133         CPU_DVFS("cpu_g", 2, 1, MHZ, 481, 481, 652, 652, 807, 807,  948,  948,  948, 1117, 1171, 1206, 1254, 1292, 1311, 1400),
134         CPU_DVFS("cpu_g", 2, 2, MHZ, 540, 540, 711, 711, 883, 883, 1039, 1039, 1039, 1178, 1206, 1263, 1301, 1400),
135         CPU_DVFS("cpu_g", 2, 3, MHZ, 570, 570, 777, 777, 931, 931, 1102, 1102, 1102, 1216, 1255, 1304, 1400),
136
137         CPU_DVFS("cpu_g", 3, 1, MHZ,   1, 481, 481, 652, 652, 807,  807,  948,  948,  948, 1117, 1171, 1206, 1254, 1292, 1311, 1400),
138         CPU_DVFS("cpu_g", 3, 2, MHZ,   1, 540, 540, 711, 711, 883,  883, 1039, 1039, 1039, 1178, 1206, 1263, 1301, 1400),
139         CPU_DVFS("cpu_g", 3, 3, MHZ,   1, 570, 570, 777, 777, 931,  931, 1102, 1102, 1102, 1216, 1255, 1304, 1400),
140
141 #endif
142         /*
143          * "Safe entry" to be used when no match for chip speedo, process
144          *  corner is found (just to boot at low rate); must be the last one
145          */
146         CPU_DVFS("cpu_g",-1,-1, MHZ,   1,   1, 216, 216, 300),
147 };
148
149 #define CORE_DVFS(_clk_name, _speedo_id, _auto, _mult, _freqs...)       \
150         {                                                       \
151                 .clk_name       = _clk_name,                    \
152                 .speedo_id      = _speedo_id,                   \
153                 .process_id     = -1,                           \
154                 .freqs          = {_freqs},                     \
155                 .freqs_mult     = _mult,                        \
156                 .millivolts     = core_millivolts,              \
157                 .auto_dvfs      = _auto,                        \
158                 .dvfs_rail      = &tegra3_dvfs_rail_vdd_core,   \
159         }
160
161 static struct dvfs core_dvfs_table[] = {
162 #if 0
163         /* Core voltages (mV):             1000,   1050,   1100,   1150,    1200,    1250,    1300 */
164         /* Clock limits for internal blocks, PLLs */
165         CORE_DVFS("cpu_lp", 0, 1, KHZ,   294500, 342000, 427000, 484000,  500000,  500000,  500000),
166         CORE_DVFS("cpu_lp", 1, 1, KHZ,   294500, 342000, 427000, 484000,  500000,  500000,  500000),
167         CORE_DVFS("cpu_lp", 2, 1, KHZ,   304000, 370000, 437000, 503000,  541000,  579000,  620000),
168
169         CORE_DVFS("emc",    0, 1, KHZ,   266500, 266500, 266500, 266500,  533000,  533000,  533000),
170         CORE_DVFS("emc",    1, 1, KHZ,   408000, 408000, 408000, 408000,  667000,  667000,  667000),
171         CORE_DVFS("emc",    2, 1, KHZ,   408000, 408000, 408000, 408000,  667000,  667000,  800000),
172
173         CORE_DVFS("sbus",   0, 1, KHZ,   136000, 163000, 191000, 216000,  216000,  216000,  216000),
174         CORE_DVFS("sbus",   1, 1, KHZ,   136000, 163000, 191000, 216000,  245000,  245000,  245000),
175         CORE_DVFS("sbus",   2, 1, KHZ,   140000, 169000, 203000, 228000,  254000,  279000,  300000),
176
177         CORE_DVFS("vde",    0, 1, KHZ,   228000, 275000, 332000, 380000,  416000,  416000,  416000),
178         CORE_DVFS("mpe",    0, 1, KHZ,   234000, 285000, 332000, 380000,  416000,  416000,  416000),
179         CORE_DVFS("2d",     0, 1, KHZ,   267000, 285000, 332000, 380000,  416000,  416000,  416000),
180         CORE_DVFS("epp",    0, 1, KHZ,   267000, 285000, 332000, 380000,  416000,  416000,  416000),
181         CORE_DVFS("3d",     0, 1, KHZ,   234000, 285000, 332000, 380000,  416000,  416000,  416000),
182         CORE_DVFS("3d2",    0, 1, KHZ,   234000, 285000, 332000, 380000,  416000,  416000,  416000),
183         CORE_DVFS("vi",     0, 1, KHZ,   216000, 285000, 300000, 300000,  300000,  300000,  300000),
184         CORE_DVFS("se",     0, 1, KHZ,   267000, 285000, 332000, 380000,  416000,  416000,  416000),
185
186         CORE_DVFS("vde",    1, 1, KHZ,   228000, 275000, 332000, 380000,  416000,  416000,  416000),
187         CORE_DVFS("mpe",    1, 1, KHZ,   234000, 285000, 332000, 380000,  416000,  416000,  416000),
188         CORE_DVFS("2d",     1, 1, KHZ,   267000, 285000, 332000, 380000,  416000,  416000,  416000),
189         CORE_DVFS("epp",    1, 1, KHZ,   267000, 285000, 332000, 380000,  416000,  416000,  416000),
190         CORE_DVFS("3d",     1, 1, KHZ,   234000, 285000, 332000, 380000,  416000,  416000,  416000),
191         CORE_DVFS("3d2",    1, 1, KHZ,   234000, 285000, 332000, 380000,  416000,  416000,  416000),
192         CORE_DVFS("vi",     1, 1, KHZ,   216000, 285000, 300000, 300000,  300000,  300000,  300000),
193         CORE_DVFS("se",     1, 1, KHZ,   267000, 285000, 332000, 380000,  416000,  416000,  416000),
194
195         CORE_DVFS("vde",    2, 1, KHZ,   247000, 304000, 361000, 408000,  446000,  484000,  520000),
196         CORE_DVFS("mpe",    2, 1, KHZ,   247000, 304000, 361000, 408000,  446000,  484000,  520000),
197         CORE_DVFS("2d",     2, 1, KHZ,   267000, 304000, 361000, 408000,  446000,  484000,  520000),
198         CORE_DVFS("epp",    2, 1, KHZ,   267000, 304000, 361000, 408000,  446000,  484000,  520000),
199         CORE_DVFS("3d",     2, 1, KHZ,   247000, 304000, 361000, 408000,  446000,  484000,  520000),
200         CORE_DVFS("3d2",    2, 1, KHZ,   247000, 304000, 361000, 408000,  446000,  484000,  520000),
201         CORE_DVFS("vi",     2, 1, KHZ,   247000, 300000, 300000, 300000,  300000,  300000,  300000),
202         CORE_DVFS("se",     2, 1, KHZ,   267000, 304000, 361000, 408000,  446000,  484000,  520000),
203
204         CORE_DVFS("host1x",-1, 1, KHZ,   152000, 188000, 222000, 254000,  267000,  267000,  267000),
205
206         CORE_DVFS("cbus",   0, 1, KHZ,   228000, 275000, 332000, 380000,  416000,  416000,  416000),
207         CORE_DVFS("cbus",   1, 1, KHZ,   228000, 275000, 332000, 380000,  416000,  416000,  416000),
208         CORE_DVFS("cbus",   2, 1, KHZ,   247000, 304000, 361000, 408000,  446000,  484000,  520000),
209
210         CORE_DVFS("pll_c",  -1, 1, KHZ,   600000, 600000, 800000, 800000, 1066000, 1066000, 1066000),
211         CORE_DVFS("pll_m",  -1, 1, KHZ,   600000, 600000, 800000, 800000, 1066000, 1066000, 1066000),
212
213         /* Core voltages (mV):             1000,   1050,   1100,   1150,    1200,   1250,    1300 */
214         /* Clock limits for I/O peripherals */
215         CORE_DVFS("mipi",   0, 1, KHZ,        1,      1,      1,      1,      1,       1,       1),
216         CORE_DVFS("mipi",   1, 1, KHZ,        1,      1,      1,      1,  60000,   60000,   60000),
217         CORE_DVFS("mipi",   2, 1, KHZ,        1,      1,      1,      1,  60000,   60000,   60000),
218
219         CORE_DVFS("sdmmc1",-1, 1, KHZ,   104000, 104000, 104000, 104000, 208000,  208000,  208000),
220         CORE_DVFS("sdmmc3",-1, 1, KHZ,   104000, 104000, 104000, 104000, 208000,  208000,  208000),
221         CORE_DVFS("ndflash",-1,1, KHZ,   110000, 166000, 166000, 166000, 166000,  166000,  166000),
222         CORE_DVFS("nor",   -1, 1, KHZ,   100000, 126000, 126000, 133000, 133000,  133000,  133000),
223         CORE_DVFS("sbc1",  -1, 1, KHZ,    40000,  60000,  60000,  60000, 100000,  100000,  100000),
224         CORE_DVFS("sbc2",  -1, 1, KHZ,    40000,  60000,  60000,  60000, 100000,  100000,  100000),
225         CORE_DVFS("sbc3",  -1, 1, KHZ,    40000,  60000,  60000,  60000, 100000,  100000,  100000),
226         CORE_DVFS("sbc4",  -1, 1, KHZ,    40000,  60000,  60000,  60000, 100000,  100000,  100000),
227         CORE_DVFS("sbc5",  -1, 1, KHZ,    40000,  60000,  60000,  60000, 100000,  100000,  100000),
228         CORE_DVFS("sbc6",  -1, 1, KHZ,    40000,  60000,  60000,  60000, 100000,  100000,  100000),
229         CORE_DVFS("tvo",   -1, 1, KHZ,        1, 297000, 297000, 297000, 297000,  297000,  297000),
230         CORE_DVFS("dsi",   -1, 1, KHZ,   430000, 430000, 430000, 430000, 500000,  500000,  500000),
231         CORE_DVFS("fuse_burn", -1, 1, KHZ,        0,      0,      0,  26000,  26000,   26000,   26000),
232
233         /*
234          * The clock rate for the display controllers that determines the
235          * necessary core voltage depends on a divider that is internal
236          * to the display block.  Disable auto-dvfs on the display clocks,
237          * and let the display driver call tegra_dvfs_set_rate manually
238          */
239         CORE_DVFS("disp1", -1, 0, KHZ,   120000, 120000, 120000, 120000, 190000,  190000,  190000),
240         CORE_DVFS("disp2", -1, 0, KHZ,   120000, 120000, 120000, 120000, 190000,  190000,  190000),
241 #endif
242 };
243
244
245 int tegra_dvfs_disable_core_set(const char *arg, const struct kernel_param *kp)
246 {
247         int ret;
248
249         ret = param_set_bool(arg, kp);
250         if (ret)
251                 return ret;
252
253         if (tegra_dvfs_core_disabled)
254                 tegra_dvfs_rail_disable(&tegra3_dvfs_rail_vdd_core);
255         else
256                 tegra_dvfs_rail_enable(&tegra3_dvfs_rail_vdd_core);
257
258         return 0;
259 }
260
261 int tegra_dvfs_disable_cpu_set(const char *arg, const struct kernel_param *kp)
262 {
263         int ret;
264
265         ret = param_set_bool(arg, kp);
266         if (ret)
267                 return ret;
268
269         if (tegra_dvfs_cpu_disabled)
270                 tegra_dvfs_rail_disable(&tegra3_dvfs_rail_vdd_cpu);
271         else
272                 tegra_dvfs_rail_enable(&tegra3_dvfs_rail_vdd_cpu);
273
274         return 0;
275 }
276
277 int tegra_dvfs_disable_get(char *buffer, const struct kernel_param *kp)
278 {
279         return param_get_bool(buffer, kp);
280 }
281
282 static struct kernel_param_ops tegra_dvfs_disable_core_ops = {
283         .set = tegra_dvfs_disable_core_set,
284         .get = tegra_dvfs_disable_get,
285 };
286
287 static struct kernel_param_ops tegra_dvfs_disable_cpu_ops = {
288         .set = tegra_dvfs_disable_cpu_set,
289         .get = tegra_dvfs_disable_get,
290 };
291
292 module_param_cb(disable_core, &tegra_dvfs_disable_core_ops,
293         &tegra_dvfs_core_disabled, 0644);
294 module_param_cb(disable_cpu, &tegra_dvfs_disable_cpu_ops,
295         &tegra_dvfs_cpu_disabled, 0644);
296
297 static void __init init_dvfs_one(struct dvfs *d, int nominal_mv_index)
298 {
299         int ret;
300         struct clk *c = tegra_get_clock_by_name(d->clk_name);
301
302         if (!c) {
303                 pr_debug("tegra3_dvfs: no clock found for %s\n",
304                         d->clk_name);
305                 return;
306         }
307
308         if (d->auto_dvfs) {
309                 /* Update max rate for auto-dvfs clocks */
310                 BUG_ON(!d->freqs[nominal_mv_index]);
311                 tegra_init_max_rate(
312                         c, d->freqs[nominal_mv_index] * d->freqs_mult);
313         }
314         d->max_millivolts = d->dvfs_rail->nominal_millivolts;
315
316         ret = tegra_enable_dvfs_on_clk(c, d);
317         if (ret)
318                 pr_err("tegra3_dvfs: failed to enable dvfs on %s\n",
319                         c->name);
320 }
321
322 static bool __init match_dvfs_one(struct dvfs *d, int speedo_id, int process_id)
323 {
324         if ((d->process_id != -1 && d->process_id != process_id) ||
325                 (d->speedo_id != -1 && d->speedo_id != speedo_id)) {
326                 pr_debug("tegra3_dvfs: rejected %s speedo %d,"
327                         " process %d\n", d->clk_name, d->speedo_id,
328                         d->process_id);
329                 return false;
330         }
331         return true;
332 }
333
334 static int __init get_cpu_nominal_mv_index(
335         int speedo_id, int process_id, struct dvfs **cpu_dvfs)
336 {
337         int i, j, mv;
338         struct dvfs *d;
339         struct clk *c;
340
341         /*
342          * Start with nominal level for the chips with this speedo_id. Then,
343          * make sure cpu nominal voltage is below core ("solve from cpu to
344          * core at nominal").
345          */
346         BUG_ON(speedo_id >= ARRAY_SIZE(cpu_speedo_nominal_millivolts));
347         mv = cpu_speedo_nominal_millivolts[speedo_id];
348         if (tegra3_dvfs_rail_vdd_core.nominal_millivolts)
349                 mv = min(mv, tegra3_dvfs_rail_vdd_core.nominal_millivolts +
350                         core_below_cpu);
351
352         /*
353          * Find matching cpu dvfs entry, and use it to determine index to the
354          * final nominal voltage, that satisfies the following requirements:
355          * - allows CPU to run at minimum of the maximum rates specified in
356          *   the dvfs entry and clock tree
357          * - does not violate cpu_to_core dependency as determined above
358          */
359         for (i = 0, j = 0; j <  ARRAY_SIZE(cpu_dvfs_table); j++) {
360                 d = &cpu_dvfs_table[j];
361                 if (match_dvfs_one(d, speedo_id, process_id)) {
362                         c = tegra_get_clock_by_name(d->clk_name);
363                         BUG_ON(!c);
364
365                         for (; i < MAX_DVFS_FREQS; i++) {
366                                 if ((d->freqs[i] == 0) ||
367                                     (cpu_millivolts[i] == 0) ||
368                                     (mv < cpu_millivolts[i]))
369                                         break;
370
371                                 if (c->max_rate <= d->freqs[i]*d->freqs_mult) {
372                                         i++;
373                                         break;
374                                 }
375                         }
376                         break;
377                 }
378         }
379
380         BUG_ON(i == 0);
381         if (j == (ARRAY_SIZE(cpu_dvfs_table) - 1))
382                 pr_err("tegra3_dvfs: WARNING!!!\n"
383                        "tegra3_dvfs: no cpu dvfs table found for chip speedo_id"
384                        " %d and process_id %d: set CPU rate limit at %lu\n"
385                        "tegra3_dvfs: WARNING!!!\n",
386                        speedo_id, process_id, d->freqs[i-1] * d->freqs_mult);
387
388         *cpu_dvfs = d;
389         return (i - 1);
390 }
391
392 static int __init get_core_nominal_mv_index(int speedo_id)
393 {
394         int i, mv;
395         int core_edp_limit = get_core_edp();
396
397         /*
398          * Start with nominal level for the chips with this speedo_id. Then,
399          * make sure core nominal voltage is below edp limit for the board
400          * (if edp limit is set).
401          */
402         BUG_ON(speedo_id >= ARRAY_SIZE(core_speedo_nominal_millivolts));
403         mv = core_speedo_nominal_millivolts[speedo_id];
404
405         if (core_edp_limit)
406                 mv = min(mv, core_edp_limit);
407
408         /* Round nominal level down to the nearest core scaling step */
409         for (i = 0; i < MAX_DVFS_FREQS; i++) {
410                 if ((core_millivolts[i] == 0) || (mv < core_millivolts[i]))
411                         break;
412         }
413
414         if (i == 0) {
415                 pr_err("tegra3_dvfs: unable to adjust core dvfs table to"
416                        " nominal voltage %d\n", mv);
417                 return -ENOSYS;
418         }
419         return (i - 1);
420 }
421
422 void __init tegra_soc_init_dvfs(void)
423 {
424         int cpu_speedo_id = tegra_cpu_speedo_id();
425         int soc_speedo_id = tegra_soc_speedo_id();
426         int cpu_process_id = tegra_cpu_process_id();
427         int core_process_id = tegra_core_process_id();
428
429         int i;
430         int core_nominal_mv_index;
431         int cpu_nominal_mv_index;
432         struct dvfs *cpu_dvfs = NULL;
433
434 #ifndef CONFIG_TEGRA_CORE_DVFS
435         tegra_dvfs_core_disabled = true;
436 #endif
437 #ifndef CONFIG_TEGRA_CPU_DVFS
438         tegra_dvfs_cpu_disabled = true;
439 #endif
440
441         BUG_ON(VDD_SAFE_STEP > (cpu_below_core + core_below_cpu));
442
443         /*
444          * Find nominal voltages for core (1st) and cpu rails before rail
445          * init. Nominal voltage index in the scaling ladder will also be
446          * used to determine max dvfs frequency for the respective domains.
447          */
448         core_nominal_mv_index = get_core_nominal_mv_index(soc_speedo_id);
449         if (core_nominal_mv_index < 0) {
450                 tegra3_dvfs_rail_vdd_core.disabled = true;
451                 tegra_dvfs_core_disabled = true;
452                 core_nominal_mv_index = 0;
453         }
454         tegra3_dvfs_rail_vdd_core.nominal_millivolts =
455                 core_millivolts[core_nominal_mv_index];
456
457         cpu_nominal_mv_index = get_cpu_nominal_mv_index(
458                 cpu_speedo_id, cpu_process_id, &cpu_dvfs);
459         BUG_ON((cpu_nominal_mv_index < 0) || (!cpu_dvfs));
460         tegra3_dvfs_rail_vdd_cpu.nominal_millivolts =
461                 cpu_millivolts[cpu_nominal_mv_index];
462
463         /* Init rail structures and dependencies */
464         tegra_dvfs_init_rails(tegra3_dvfs_rails, ARRAY_SIZE(tegra3_dvfs_rails));
465         tegra_dvfs_add_relationships(tegra3_dvfs_relationships,
466                 ARRAY_SIZE(tegra3_dvfs_relationships));
467
468         /* Search core dvfs table for speedo/process matching entries and
469            initialize dvfs-ed clocks */
470         for (i = 0; i <  ARRAY_SIZE(core_dvfs_table); i++) {
471                 struct dvfs *d = &core_dvfs_table[i];
472                 if (!match_dvfs_one(d, soc_speedo_id, core_process_id))
473                         continue;
474                 init_dvfs_one(d, core_nominal_mv_index);
475         }
476
477         /* Initialize matching cpu dvfs entry already found when nominal
478            voltage was determined */
479         init_dvfs_one(cpu_dvfs, cpu_nominal_mv_index);
480
481         /* Finally disable dvfs on rails if necessary */
482         if (tegra_dvfs_core_disabled)
483                 tegra_dvfs_rail_disable(&tegra3_dvfs_rail_vdd_core);
484         if (tegra_dvfs_cpu_disabled)
485                 tegra_dvfs_rail_disable(&tegra3_dvfs_rail_vdd_cpu);
486
487         pr_info("tegra dvfs: VDD_CPU nominal %dmV, scaling %s\n",
488                 tegra3_dvfs_rail_vdd_cpu.nominal_millivolts,
489                 tegra_dvfs_cpu_disabled ? "disabled" : "enabled");
490         pr_info("tegra dvfs: VDD_CORE nominal %dmV, scaling %s\n",
491                 tegra3_dvfs_rail_vdd_core.nominal_millivolts,
492                 tegra_dvfs_core_disabled ? "disabled" : "enabled");
493 }