blob: edac8bb24355d91bc8abcb0b1545be3853a1354a [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#define pr_fmt(fmt) "%s: " fmt, __func__
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/io.h>
18#include <linux/delay.h>
19#include <linux/mutex.h>
20#include <linux/err.h>
21#include <linux/errno.h>
22#include <linux/cpufreq.h>
23#include <linux/cpu.h>
24#include <linux/regulator/consumer.h>
25
26#include <asm/mach-types.h>
27#include <asm/cpu.h>
28
29#include <mach/board.h>
30#include <mach/msm_iomap.h>
31#include <mach/rpm-regulator.h>
32#include <mach/msm_bus.h>
33#include <mach/msm_bus_board.h>
34#include <mach/socinfo.h>
35
36#include "acpuclock.h"
37
38/*
39 * Source IDs.
40 * These must be negative to not overlap with the source IDs
41 * used by the 8x60 local clock driver.
42 */
43#define PLL_8 0
44#define HFPLL -1
45#define QSB -2
46
47/* Mux source selects. */
48#define PRI_SRC_SEL_SEC_SRC 0
49#define PRI_SRC_SEL_HFPLL 1
50#define PRI_SRC_SEL_HFPLL_DIV2 2
51#define SEC_SRC_SEL_QSB 0
52
53/* HFPLL registers offsets. */
54#define HFPLL_MODE 0x00
55#define HFPLL_CONFIG_CTL 0x04
56#define HFPLL_L_VAL 0x08
57#define HFPLL_M_VAL 0x0C
58#define HFPLL_N_VAL 0x10
59#define HFPLL_DROOP_CTL 0x14
60
61/* CP15 L2 indirect addresses. */
62#define L2CPMR_IADDR 0x500
63#define L2CPUCPMR_IADDR 0x501
64
65#define STBY_KHZ 1
66
67#define HFPLL_NOMINAL_VDD 1050000
68#define HFPLL_LOW_VDD 1050000
69#define HFPLL_LOW_VDD_PLL_L_MAX 0x28
70
71#define SECCLKAGD BIT(4)
72
73enum scalables {
74 CPU0 = 0,
75 CPU1,
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -070076 CPU2,
77 CPU3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078 L2,
79 NUM_SCALABLES
80};
81
82enum vregs {
83 VREG_CORE,
84 VREG_MEM,
85 VREG_DIG,
86 NUM_VREG
87};
88
89struct vreg {
90 const char name[15];
91 const unsigned int max_vdd;
92 const int rpm_vreg_voter;
93 const int rpm_vreg_id;
94 struct regulator *reg;
95 unsigned int cur_vdd;
96};
97
98struct core_speed {
99 unsigned int khz;
100 int src;
101 unsigned int pri_src_sel;
102 unsigned int sec_src_sel;
103 unsigned int pll_l_val;
104};
105
106struct l2_level {
107 struct core_speed speed;
108 unsigned int vdd_dig;
109 unsigned int vdd_mem;
110 unsigned int bw_level;
111};
112
113struct acpu_level {
114 unsigned int use_for_scaling;
115 struct core_speed speed;
116 struct l2_level *l2_level;
117 unsigned int vdd_core;
118};
119
120struct scalable {
121 void * __iomem const hfpll_base;
122 void * __iomem const aux_clk_sel;
123 const uint32_t l2cpmr_iaddr;
124 struct core_speed *current_speed;
125 struct l2_level *l2_vote;
126 struct vreg vreg[NUM_VREG];
127 bool first_set_call;
128};
129
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -0700130static struct scalable scalable_8960[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700131 [CPU0] = {
132 .hfpll_base = MSM_HFPLL_BASE + 0x200,
133 .aux_clk_sel = MSM_ACC0_BASE + 0x014,
134 .l2cpmr_iaddr = L2CPUCPMR_IADDR,
135 .vreg[VREG_CORE] = { "krait0", 1150000 },
136 .vreg[VREG_MEM] = { "krait0_mem", 1150000,
137 RPM_VREG_VOTER1,
138 RPM_VREG_ID_PM8921_L24 },
139 .vreg[VREG_DIG] = { "krait0_dig", 1150000,
140 RPM_VREG_VOTER1,
141 RPM_VREG_ID_PM8921_S3 },
142 },
143 [CPU1] = {
144 .hfpll_base = MSM_HFPLL_BASE + 0x300,
145 .aux_clk_sel = MSM_ACC1_BASE + 0x014,
146 .l2cpmr_iaddr = L2CPUCPMR_IADDR,
147 .vreg[VREG_CORE] = { "krait1", 1150000 },
148 .vreg[VREG_MEM] = { "krait0_mem", 1150000,
149 RPM_VREG_VOTER2,
150 RPM_VREG_ID_PM8921_L24 },
151 .vreg[VREG_DIG] = { "krait0_dig", 1150000,
152 RPM_VREG_VOTER2,
153 RPM_VREG_ID_PM8921_S3 },
154 },
155 [L2] = {
156 .hfpll_base = MSM_HFPLL_BASE + 0x400,
157 .aux_clk_sel = MSM_APCS_GCC_BASE + 0x028,
158 .l2cpmr_iaddr = L2CPMR_IADDR,
159 },
160};
161
Stephen Boyd7ad84752011-08-05 14:04:28 -0700162static DEFINE_MUTEX(driver_lock);
163static DEFINE_SPINLOCK(l2_lock);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700164
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -0700165static struct scalable scalable_8064[] = {
166 [CPU0] = {
167 .hfpll_base = MSM_HFPLL_BASE + 0x200,
168 .aux_clk_sel = MSM_ACC0_BASE + 0x014,
169 .l2cpmr_iaddr = L2CPUCPMR_IADDR,
170 .vreg[VREG_CORE] = { "krait0", 1150000 },
171 .vreg[VREG_MEM] = { "krait0_mem", 1150000,
172 RPM_VREG_VOTER1,
173 RPM_VREG_ID_PM8921_L24 },
174 .vreg[VREG_DIG] = { "krait0_dig", 1150000,
175 RPM_VREG_VOTER1,
176 RPM_VREG_ID_PM8921_S3 },
177 },
178 [CPU1] = {
179 .hfpll_base = MSM_HFPLL_BASE + 0x240,
180 .aux_clk_sel = MSM_ACC1_BASE + 0x014,
181 .l2cpmr_iaddr = L2CPUCPMR_IADDR,
182 .vreg[VREG_CORE] = { "krait1", 1150000 },
183 .vreg[VREG_MEM] = { "krait0_mem", 1150000,
184 RPM_VREG_VOTER2,
185 RPM_VREG_ID_PM8921_L24 },
186 .vreg[VREG_DIG] = { "krait0_dig", 1150000,
187 RPM_VREG_VOTER2,
188 RPM_VREG_ID_PM8921_S3 },
189 },
190 [CPU2] = {
191 .hfpll_base = MSM_HFPLL_BASE + 0x280,
192 .aux_clk_sel = MSM_ACC2_BASE + 0x014,
193 .l2cpmr_iaddr = L2CPUCPMR_IADDR,
194 .vreg[VREG_CORE] = { "krait2", 1150000 },
195 .vreg[VREG_MEM] = { "krait0_mem", 1150000,
196 RPM_VREG_VOTER4,
197 RPM_VREG_ID_PM8921_L24 },
198 .vreg[VREG_DIG] = { "krait0_dig", 1150000,
199 RPM_VREG_VOTER4,
200 RPM_VREG_ID_PM8921_S3 },
201 },
202 [CPU3] = {
203 .hfpll_base = MSM_HFPLL_BASE + 0x2C0,
204 .aux_clk_sel = MSM_ACC3_BASE + 0x014,
205 .l2cpmr_iaddr = L2CPUCPMR_IADDR,
206 .vreg[VREG_CORE] = { "krait3", 1150000 },
207 .vreg[VREG_MEM] = { "krait0_mem", 1150000,
208 RPM_VREG_VOTER5,
209 RPM_VREG_ID_PM8921_L24 },
210 .vreg[VREG_DIG] = { "krait0_dig", 1150000,
211 RPM_VREG_VOTER5,
212 RPM_VREG_ID_PM8921_S3 },
213 },
214 [L2] = {
215 .hfpll_base = MSM_HFPLL_BASE + 0x300,
216 .aux_clk_sel = MSM_APCS_GCC_BASE + 0x028,
217 .l2cpmr_iaddr = L2CPMR_IADDR,
218 },
219};
220
221static struct scalable *scalable;
222static struct l2_level *l2_freq_tbl;
223static struct acpu_level *acpu_freq_tbl;
224static int l2_freq_tbl_size;
225static int cpu_boot_idx;
226static int l2_boot_idx;
227
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700228/* Instantaneous bandwidth requests in MB/s. */
229#define BW_MBPS(_bw) \
230 { \
231 .vectors = (struct msm_bus_vectors[]){ \
232 {\
233 .src = MSM_BUS_MASTER_AMPSS_M0, \
234 .dst = MSM_BUS_SLAVE_EBI_CH0, \
235 .ib = (_bw) * 1000000UL, \
236 .ab = (_bw) * 100000UL, \
237 }, \
238 { \
239 .src = MSM_BUS_MASTER_AMPSS_M1, \
240 .dst = MSM_BUS_SLAVE_EBI_CH0, \
241 .ib = (_bw) * 1000000UL, \
242 .ab = (_bw) * 100000UL, \
243 }, \
244 }, \
245 .num_paths = 2, \
246 }
247static struct msm_bus_paths bw_level_tbl[] = {
248 [0] = BW_MBPS(616), /* At least 77 MHz on bus. */
249 [1] = BW_MBPS(1024), /* At least 128 MHz on bus. */
250 [2] = BW_MBPS(1536), /* At least 192 MHz on bus. */
251 [3] = BW_MBPS(2048), /* At least 256 MHz on bus. */
252 [4] = BW_MBPS(3080), /* At least 385 MHz on bus. */
253 [5] = BW_MBPS(3968), /* At least 496 MHz on bus. */
254};
255
256static struct msm_bus_scale_pdata bus_client_pdata = {
257 .usecase = bw_level_tbl,
258 .num_usecases = ARRAY_SIZE(bw_level_tbl),
259 .active_only = 1,
260 .name = "acpuclock",
261};
262
263static uint32_t bus_perf_client;
264
265/* TODO: Update vdd_dig and vdd_mem when voltage data is available. */
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -0700266#define L2(x) (&l2_freq_tbl_8960[(x)])
267static struct l2_level l2_freq_tbl_8960[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700268 [0] = { {STBY_KHZ, QSB, 0, 0, 0x00 }, 1050000, 1050000, 0 },
Matt Wagantalle64d56a2011-07-14 19:35:27 -0700269 [1] = { { 384000, PLL_8, 0, 2, 0x00 }, 1050000, 1050000, 1 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700270 [2] = { { 432000, HFPLL, 2, 0, 0x20 }, 1050000, 1050000, 1 },
271 [3] = { { 486000, HFPLL, 2, 0, 0x24 }, 1050000, 1050000, 1 },
272 [4] = { { 540000, HFPLL, 2, 0, 0x28 }, 1050000, 1050000, 1 },
273 [5] = { { 594000, HFPLL, 1, 0, 0x16 }, 1050000, 1050000, 2 },
274 [6] = { { 648000, HFPLL, 1, 0, 0x18 }, 1050000, 1050000, 2 },
275 [7] = { { 702000, HFPLL, 1, 0, 0x1A }, 1050000, 1050000, 2 },
Matt Wagantalle64d56a2011-07-14 19:35:27 -0700276 [8] = { { 756000, HFPLL, 1, 0, 0x1C }, 1150000, 1150000, 2 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700277 [9] = { { 810000, HFPLL, 1, 0, 0x1E }, 1150000, 1150000, 3 },
278 [10] = { { 864000, HFPLL, 1, 0, 0x20 }, 1150000, 1150000, 3 },
279 [11] = { { 918000, HFPLL, 1, 0, 0x22 }, 1150000, 1150000, 3 },
280 [12] = { { 972000, HFPLL, 1, 0, 0x24 }, 1150000, 1150000, 3 },
Matt Wagantalle64d56a2011-07-14 19:35:27 -0700281 [13] = { { 1026000, HFPLL, 1, 0, 0x26 }, 1150000, 1150000, 4 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282 [14] = { { 1080000, HFPLL, 1, 0, 0x28 }, 1150000, 1150000, 4 },
283 [15] = { { 1134000, HFPLL, 1, 0, 0x2A }, 1150000, 1150000, 4 },
284 [16] = { { 1188000, HFPLL, 1, 0, 0x2C }, 1150000, 1150000, 4 },
Matt Wagantalle64d56a2011-07-14 19:35:27 -0700285 [17] = { { 1242000, HFPLL, 1, 0, 0x2E }, 1150000, 1150000, 5 },
286 [18] = { { 1296000, HFPLL, 1, 0, 0x30 }, 1150000, 1150000, 5 },
287 [19] = { { 1350000, HFPLL, 1, 0, 0x32 }, 1150000, 1150000, 5 },
288 [20] = { { 1404000, HFPLL, 1, 0, 0x34 }, 1150000, 1150000, 5 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700289 [21] = { { 1458000, HFPLL, 1, 0, 0x36 }, 1150000, 1150000, 5 },
290 [22] = { { 1512000, HFPLL, 1, 0, 0x38 }, 1150000, 1150000, 5 },
291 [23] = { { 1566000, HFPLL, 1, 0, 0x3A }, 1150000, 1150000, 5 },
292 [24] = { { 1620000, HFPLL, 1, 0, 0x3C }, 1150000, 1150000, 5 },
293 [25] = { { 1674000, HFPLL, 1, 0, 0x3E }, 1150000, 1150000, 5 },
294};
295
296/* TODO: Update core voltages when data is available. */
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -0700297static struct acpu_level acpu_freq_tbl_8960[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700298 { 0, {STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 1050000 },
299 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 1050000 },
Matt Wagantalle64d56a2011-07-14 19:35:27 -0700300 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(6), 1050000 },
301 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(6), 1050000 },
302 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(6), 1050000 },
303 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(6), 1050000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700304 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(6), 1050000 },
Matt Wagantalle64d56a2011-07-14 19:35:27 -0700305 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(6), 1050000 },
306 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(13), 1150000 },
307 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(13), 1150000 },
308 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(13), 1150000 },
309 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(13), 1150000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310 { 0, { 0 } }
311};
312
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -0700313/* TODO: Update vdd_dig and vdd_mem when voltage data is available. */
314#undef L2
315#define L2(x) (&l2_freq_tbl_8064[(x)])
316static struct l2_level l2_freq_tbl_8064[] = {
317 [0] = { {STBY_KHZ, QSB, 0, 0, 0x00 }, 1050000, 1050000, 0 },
318 [1] = { { 384000, PLL_8, 0, 2, 0x00 }, 1050000, 1050000, 0 },
319 [2] = { { 432000, HFPLL, 2, 0, 0x20 }, 1050000, 1050000, 1 },
320 [3] = { { 486000, HFPLL, 2, 0, 0x24 }, 1050000, 1050000, 1 },
321 [4] = { { 540000, HFPLL, 2, 0, 0x28 }, 1050000, 1050000, 1 },
322 [5] = { { 594000, HFPLL, 1, 0, 0x16 }, 1050000, 1050000, 2 },
323 [6] = { { 648000, HFPLL, 1, 0, 0x18 }, 1050000, 1050000, 2 },
324 [7] = { { 702000, HFPLL, 1, 0, 0x1A }, 1050000, 1050000, 2 },
325 [8] = { { 756000, HFPLL, 1, 0, 0x1C }, 1150000, 1150000, 3 },
326 [9] = { { 810000, HFPLL, 1, 0, 0x1E }, 1150000, 1150000, 3 },
327 [10] = { { 864000, HFPLL, 1, 0, 0x20 }, 1150000, 1150000, 3 },
328 [11] = { { 918000, HFPLL, 1, 0, 0x22 }, 1150000, 1150000, 3 },
329 [12] = { { 972000, HFPLL, 1, 0, 0x24 }, 1150000, 1150000, 3 },
330 [13] = { { 1026000, HFPLL, 1, 0, 0x26 }, 1150000, 1150000, 3 },
331 [14] = { { 1080000, HFPLL, 1, 0, 0x28 }, 1150000, 1150000, 4 },
332 [15] = { { 1134000, HFPLL, 1, 0, 0x2A }, 1150000, 1150000, 4 },
333 [16] = { { 1188000, HFPLL, 1, 0, 0x2C }, 1150000, 1150000, 4 },
334 [17] = { { 1242000, HFPLL, 1, 0, 0x2E }, 1150000, 1150000, 4 },
335 [18] = { { 1296000, HFPLL, 1, 0, 0x30 }, 1150000, 1150000, 4 },
336 [19] = { { 1350000, HFPLL, 1, 0, 0x32 }, 1150000, 1150000, 4 },
337 [20] = { { 1404000, HFPLL, 1, 0, 0x34 }, 1150000, 1150000, 4 },
338 [21] = { { 1458000, HFPLL, 1, 0, 0x36 }, 1150000, 1150000, 5 },
339 [22] = { { 1512000, HFPLL, 1, 0, 0x38 }, 1150000, 1150000, 5 },
340 [23] = { { 1566000, HFPLL, 1, 0, 0x3A }, 1150000, 1150000, 5 },
341 [24] = { { 1620000, HFPLL, 1, 0, 0x3C }, 1150000, 1150000, 5 },
342 [25] = { { 1674000, HFPLL, 1, 0, 0x3E }, 1150000, 1150000, 5 },
343};
344
345/* TODO: Update core voltages when data is available. */
346static struct acpu_level acpu_freq_tbl_8064[] = {
347 { 0, {STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 1050000 },
348 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 1050000 },
349 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(2), 1050000 },
350 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(3), 1050000 },
351 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(4), 1050000 },
352 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(5), 1050000 },
353 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(6), 1050000 },
354 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(7), 1050000 },
355 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(8), 1150000 },
356 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(9), 1150000 },
357 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(10), 1150000 },
358 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(11), 1150000 },
359 { 0, { 0 } }
360};
361
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700362unsigned long acpuclk_get_rate(int cpu)
363{
364 return scalable[cpu].current_speed->khz;
365}
366
367uint32_t acpuclk_get_switch_time(void)
368{
369 return 0;
370}
371
372unsigned long acpuclk_power_collapse(void)
373{
374 int ret = acpuclk_get_rate(smp_processor_id());
375 acpuclk_set_rate(smp_processor_id(), STBY_KHZ, SETRATE_PC);
376 return ret;
377}
378
379unsigned long acpuclk_wait_for_irq(void)
380{
381 int ret = acpuclk_get_rate(smp_processor_id());
382 acpuclk_set_rate(smp_processor_id(), STBY_KHZ, SETRATE_SWFI);
383 return ret;
384}
385
386/* Read an 'indirectly' addressed L2 CP15 register. */
387static uint32_t readl_cp15_l2ind(uint32_t addr)
388{
389 uint32_t regval;
390
391 /*
392 * TODO: CP15 registers are not emulated on RUMI3.
393 * Remove this check if/when they are.
394 */
395 if (machine_is_msm8960_rumi3())
396 return 0;
397
398 asm volatile ("mcr p15, 3, %[l2cpsler], c15, c0, 6\n\t"
399 "mrc p15, 3, %[l2cpdr], c15, c0, 7\n\t"
400 : [l2cpdr]"=r" (regval)
401 : [l2cpsler]"r" (addr)
402 : "cc"
403 );
404 return regval;
405}
406
407/* Write an 'indirectly' addressed L2 CP15 register. */
408static void writel_cp15_l2ind(uint32_t regval, uint32_t addr)
409{
410 /*
411 * TODO: CP15 registers are not emulated on RUMI3.
412 * Remove this check if/when they are.
413 */
414 if (machine_is_msm8960_rumi3())
415 return;
416
417 mb();
418 asm volatile ("mcr p15, 3, %[l2cpsler], c15, c0, 6\n\t"
419 "mcr p15, 3, %[l2cpdr], c15, c0, 7\n\t"
420 :
421 : [l2cpsler]"r" (addr), [l2cpdr]"r" (regval)
422 : "cc"
423 );
424 isb();
425}
426
427/* Get the selected source on primary MUX. */
428static int get_pri_clk_src(struct scalable *sc)
429{
430 uint32_t regval;
431
432 regval = readl_cp15_l2ind(sc->l2cpmr_iaddr);
433 return regval & 0x3;
434}
435
436/* Set the selected source on primary MUX. */
437static void set_pri_clk_src(struct scalable *sc, uint32_t pri_src_sel)
438{
439 uint32_t regval;
440
441 regval = readl_cp15_l2ind(sc->l2cpmr_iaddr);
442 regval &= ~0x3;
443 regval |= (pri_src_sel & 0x3);
444 writel_cp15_l2ind(regval, sc->l2cpmr_iaddr);
445 /* Wait for switch to complete. */
446 mb();
447 udelay(1);
448}
449
450/* Get the selected source on secondary MUX. */
451static int get_sec_clk_src(struct scalable *sc)
452{
453 uint32_t regval;
454
455 regval = readl_cp15_l2ind(sc->l2cpmr_iaddr);
456 return (regval >> 2) & 0x3;
457}
458
459/* Set the selected source on secondary MUX. */
460static void set_sec_clk_src(struct scalable *sc, uint32_t sec_src_sel)
461{
462 uint32_t regval;
463
464 /* Disable secondary source clock gating during switch. */
465 regval = readl_cp15_l2ind(sc->l2cpmr_iaddr);
466 regval |= SECCLKAGD;
467 writel_cp15_l2ind(regval, sc->l2cpmr_iaddr);
468
469 /* Program the MUX. */
470 regval &= ~(0x3 << 2);
471 regval |= ((sec_src_sel & 0x3) << 2);
472 writel_cp15_l2ind(regval, sc->l2cpmr_iaddr);
473
474 /* Wait for switch to complete. */
475 mb();
476 udelay(1);
477
478 /* Re-enable secondary source clock gating. */
479 regval &= ~SECCLKAGD;
480 writel_cp15_l2ind(regval, sc->l2cpmr_iaddr);
481}
482
483/* Enable an already-configured HFPLL. */
484static void hfpll_enable(struct scalable *sc)
485{
486 /* Disable PLL bypass mode. */
487 writel_relaxed(0x2, sc->hfpll_base + HFPLL_MODE);
488
489 /*
490 * H/W requires a 5us delay between disabling the bypass and
491 * de-asserting the reset. Delay 10us just to be safe.
492 */
493 mb();
494 udelay(10);
495
496 /* De-assert active-low PLL reset. */
497 writel_relaxed(0x6, sc->hfpll_base + HFPLL_MODE);
498
499 /* Wait for PLL to lock. */
500 mb();
501 udelay(60);
502
503 /* Enable PLL output. */
504 writel_relaxed(0x7, sc->hfpll_base + HFPLL_MODE);
505}
506
507/* Disable a HFPLL for power-savings or while its being reprogrammed. */
508static void hfpll_disable(struct scalable *sc)
509{
510 /*
511 * Disable the PLL output, disable test mode, enable
512 * the bypass mode, and assert the reset.
513 */
514 writel_relaxed(0, sc->hfpll_base + HFPLL_MODE);
515}
516
517/* Program the HFPLL rate. Assumes HFPLL is already disabled. */
518static void hfpll_set_rate(struct scalable *sc, struct core_speed *tgt_s)
519{
520 writel_relaxed(tgt_s->pll_l_val, sc->hfpll_base + HFPLL_L_VAL);
521}
522
523/* Return the L2 speed that should be applied. */
524static struct l2_level *compute_l2_level(struct scalable *sc,
525 struct l2_level *vote_l)
526{
527 struct l2_level *new_l;
528 int cpu;
529
530 /* Bounds check. */
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -0700531 BUG_ON(vote_l >= (l2_freq_tbl + l2_freq_tbl_size));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700532
533 /* Find max L2 speed vote. */
534 sc->l2_vote = vote_l;
535 new_l = l2_freq_tbl;
536 for_each_present_cpu(cpu)
537 new_l = max(new_l, scalable[cpu].l2_vote);
538
539 return new_l;
540}
541
542/* Update the bus bandwidth request. */
543static void set_bus_bw(unsigned int bw)
544{
545 int ret;
546
547 /* Bounds check. */
548 if (bw >= ARRAY_SIZE(bw_level_tbl)) {
549 pr_err("invalid bandwidth request (%d)\n", bw);
550 return;
551 }
552
553 /* Update bandwidth if request has changed. This may sleep. */
554 ret = msm_bus_scale_client_update_request(bus_perf_client, bw);
555 if (ret)
556 pr_err("bandwidth request failed (%d)\n", ret);
557}
558
559/* Set the CPU or L2 clock speed. */
560static void set_speed(struct scalable *sc, struct core_speed *tgt_s,
561 enum setrate_reason reason)
562{
563 struct core_speed *strt_s = sc->current_speed;
564
565 if (tgt_s == strt_s)
566 return;
567
568 if (strt_s->src == HFPLL && tgt_s->src == HFPLL) {
569 /* Move CPU to QSB source. */
570 /*
571 * TODO: If using QSB here requires elevating voltages,
572 * consider using PLL8 instead.
573 */
574 set_sec_clk_src(sc, SEC_SRC_SEL_QSB);
575 set_pri_clk_src(sc, PRI_SRC_SEL_SEC_SRC);
576
577 /* Program CPU HFPLL. */
578 hfpll_disable(sc);
579 hfpll_set_rate(sc, tgt_s);
580 hfpll_enable(sc);
581
582 /* Move CPU to HFPLL source. */
583 set_pri_clk_src(sc, tgt_s->pri_src_sel);
584 } else if (strt_s->src == HFPLL && tgt_s->src != HFPLL) {
585 /* TODO: Enable source. */
586 /*
587 * If responding to CPU_DEAD we must be running on another
588 * CPU. Therefore, we can't access the downed CPU's CP15
589 * clock MUX registers from here and can't change clock sources.
590 * Just turn off the PLL- since the CPU is down already, halting
591 * its clock should be safe.
592 */
593 if (reason != SETRATE_HOTPLUG || sc == &scalable[L2]) {
594 set_sec_clk_src(sc, tgt_s->sec_src_sel);
595 set_pri_clk_src(sc, tgt_s->pri_src_sel);
596 }
597 hfpll_disable(sc);
598 } else if (strt_s->src != HFPLL && tgt_s->src == HFPLL) {
599 hfpll_set_rate(sc, tgt_s);
600 hfpll_enable(sc);
601 /*
602 * If responding to CPU_UP_PREPARE, we can't change CP15
603 * registers for the CPU that's coming up since we're not
604 * running on that CPU. That's okay though, since the MUX
605 * source was not changed on the way down, either.
606 */
607 if (reason != SETRATE_HOTPLUG || sc == &scalable[L2])
608 set_pri_clk_src(sc, tgt_s->pri_src_sel);
609 /* TODO: Disable source. */
610 } else {
611 /* TODO: Enable source. */
612 if (reason != SETRATE_HOTPLUG || sc == &scalable[L2])
613 set_sec_clk_src(sc, tgt_s->sec_src_sel);
614 /* TODO: Disable source. */
615 }
616
617 sc->current_speed = tgt_s;
618}
619
620/* Apply any per-cpu voltage increases. */
621static int increase_vdd(int cpu, unsigned int vdd_core, unsigned int vdd_mem,
622 unsigned int vdd_dig, enum setrate_reason reason)
623{
624 struct scalable *sc = &scalable[cpu];
625 int rc;
626
627 /*
628 * Increase vdd_mem active-set before vdd_dig and vdd_core.
629 * vdd_mem should be >= both vdd_core and vdd_dig.
630 */
631 if (vdd_mem > sc->vreg[VREG_MEM].cur_vdd) {
632 rc = rpm_vreg_set_voltage(sc->vreg[VREG_MEM].rpm_vreg_id,
633 sc->vreg[VREG_MEM].rpm_vreg_voter, vdd_mem,
634 sc->vreg[VREG_MEM].max_vdd, 0);
635 if (rc) {
636 pr_err("%s: vdd_mem (cpu%d) increase failed (%d)\n",
637 __func__, cpu, rc);
638 return rc;
639 }
640 sc->vreg[VREG_MEM].cur_vdd = vdd_mem;
641 }
642
643 /* Increase vdd_dig active-set vote. */
644 if (vdd_dig > sc->vreg[VREG_DIG].cur_vdd) {
645 rc = rpm_vreg_set_voltage(sc->vreg[VREG_DIG].rpm_vreg_id,
646 sc->vreg[VREG_DIG].rpm_vreg_voter, vdd_dig,
647 sc->vreg[VREG_DIG].max_vdd, 0);
648 if (rc) {
649 pr_err("%s: vdd_dig (cpu%d) increase failed (%d)\n",
650 __func__, cpu, rc);
651 return rc;
652 }
653 sc->vreg[VREG_DIG].cur_vdd = vdd_dig;
654 }
655
656 /*
657 * Update per-CPU core voltage. Don't do this for the hotplug path for
658 * which it should already be correct. Attempting to set it is bad
659 * because we don't know what CPU we are running on at this point, but
660 * the CPU regulator API requires we call it from the affected CPU.
661 */
662 if (vdd_core > sc->vreg[VREG_CORE].cur_vdd
663 && reason != SETRATE_HOTPLUG) {
664 rc = regulator_set_voltage(sc->vreg[VREG_CORE].reg, vdd_core,
665 sc->vreg[VREG_CORE].max_vdd);
666 if (rc) {
667 pr_err("%s: vdd_core (cpu%d) increase failed (%d)\n",
668 __func__, cpu, rc);
669 return rc;
670 }
671 sc->vreg[VREG_CORE].cur_vdd = vdd_core;
672 }
673
674 return rc;
675}
676
677/* Apply any per-cpu voltage decreases. */
678static void decrease_vdd(int cpu, unsigned int vdd_core, unsigned int vdd_mem,
679 unsigned int vdd_dig, enum setrate_reason reason)
680{
681 struct scalable *sc = &scalable[cpu];
682 int ret;
683
684 /*
685 * Update per-CPU core voltage. This must be called on the CPU
686 * that's being affected. Don't do this in the hotplug remove path,
687 * where the rail is off and we're executing on the other CPU.
688 */
689 if (vdd_core < sc->vreg[VREG_CORE].cur_vdd
690 && reason != SETRATE_HOTPLUG) {
691 ret = regulator_set_voltage(sc->vreg[VREG_CORE].reg, vdd_core,
692 sc->vreg[VREG_CORE].max_vdd);
693 if (ret) {
694 pr_err("%s: vdd_core (cpu%d) decrease failed (%d)\n",
695 __func__, cpu, ret);
696 return;
697 }
698 sc->vreg[VREG_CORE].cur_vdd = vdd_core;
699 }
700
701 /* Decrease vdd_dig active-set vote. */
702 if (vdd_dig < sc->vreg[VREG_DIG].cur_vdd) {
703 ret = rpm_vreg_set_voltage(sc->vreg[VREG_DIG].rpm_vreg_id,
704 sc->vreg[VREG_DIG].rpm_vreg_voter, vdd_dig,
705 sc->vreg[VREG_DIG].max_vdd, 0);
706 if (ret) {
707 pr_err("%s: vdd_dig (cpu%d) decrease failed (%d)\n",
708 __func__, cpu, ret);
709 return;
710 }
711 sc->vreg[VREG_DIG].cur_vdd = vdd_dig;
712 }
713
714 /*
715 * Decrease vdd_mem active-set after vdd_dig and vdd_core.
716 * vdd_mem should be >= both vdd_core and vdd_dig.
717 */
718 if (vdd_mem < sc->vreg[VREG_MEM].cur_vdd) {
719 ret = rpm_vreg_set_voltage(sc->vreg[VREG_MEM].rpm_vreg_id,
720 sc->vreg[VREG_MEM].rpm_vreg_voter, vdd_mem,
721 sc->vreg[VREG_MEM].max_vdd, 0);
722 if (ret) {
723 pr_err("%s: vdd_mem (cpu%d) decrease failed (%d)\n",
724 __func__, cpu, ret);
725 return;
726 }
727 sc->vreg[VREG_MEM].cur_vdd = vdd_mem;
728 }
729}
730
731static unsigned int calculate_vdd_mem(struct acpu_level *tgt)
732{
733 return max(tgt->vdd_core, tgt->l2_level->vdd_mem);
734}
735
736static unsigned int calculate_vdd_dig(struct acpu_level *tgt)
737{
738 unsigned int pll_vdd_dig;
739
740 if (tgt->l2_level->speed.pll_l_val > HFPLL_LOW_VDD_PLL_L_MAX)
741 pll_vdd_dig = HFPLL_NOMINAL_VDD;
742 else
743 pll_vdd_dig = HFPLL_LOW_VDD;
744
745 return max(tgt->l2_level->vdd_dig, pll_vdd_dig);
746}
747
748static unsigned int calculate_vdd_core(struct acpu_level *tgt)
749{
750 unsigned int pll_vdd_core;
751
752 if (tgt->speed.pll_l_val > HFPLL_LOW_VDD_PLL_L_MAX)
753 pll_vdd_core = HFPLL_NOMINAL_VDD;
754 else
755 pll_vdd_core = HFPLL_LOW_VDD;
756
757 return max(tgt->vdd_core, pll_vdd_core);
758}
759
760/* Set the CPU's clock rate and adjust the L2 rate, if appropriate. */
761int acpuclk_set_rate(int cpu, unsigned long rate, enum setrate_reason reason)
762{
763 struct core_speed *strt_acpu_s, *tgt_acpu_s;
764 struct l2_level *tgt_l2_l;
765 struct acpu_level *tgt;
766 unsigned int vdd_mem, vdd_dig, vdd_core;
767 unsigned long flags;
768 int rc = 0;
769
770 if (cpu > num_possible_cpus()) {
771 rc = -EINVAL;
772 goto out;
773 }
774
775 if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG)
776 mutex_lock(&driver_lock);
777
778 strt_acpu_s = scalable[cpu].current_speed;
779
780 /* Return early if rate didn't change. */
781 if (rate == strt_acpu_s->khz && scalable[cpu].first_set_call == false)
782 goto out;
783
784 /* Find target frequency. */
785 for (tgt = acpu_freq_tbl; tgt->speed.khz != 0; tgt++) {
786 if (tgt->speed.khz == rate) {
787 tgt_acpu_s = &tgt->speed;
788 break;
789 }
790 }
791 if (tgt->speed.khz == 0) {
792 rc = -EINVAL;
793 goto out;
794 }
795
796 /* Calculate voltage requirements for the current CPU. */
797 vdd_mem = calculate_vdd_mem(tgt);
798 vdd_dig = calculate_vdd_dig(tgt);
799 vdd_core = calculate_vdd_core(tgt);
800
801 /* Increase VDD levels if needed. */
802 if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG) {
803 rc = increase_vdd(cpu, vdd_core, vdd_mem, vdd_dig, reason);
804 if (rc)
805 goto out;
806 }
807
808 pr_debug("Switching from ACPU%d rate %u KHz -> %u KHz\n",
809 cpu, strt_acpu_s->khz, tgt_acpu_s->khz);
810
811 /* Set the CPU speed. */
812 set_speed(&scalable[cpu], tgt_acpu_s, reason);
813
814 /*
815 * Update the L2 vote and apply the rate change. A spinlock is
816 * necessary to ensure L2 rate is calulated and set atomically,
817 * even if acpuclk_set_rate() is called from an atomic context
818 * and the driver_lock mutex is not acquired.
819 */
820 spin_lock_irqsave(&l2_lock, flags);
821 tgt_l2_l = compute_l2_level(&scalable[cpu], tgt->l2_level);
822 set_speed(&scalable[L2], &tgt_l2_l->speed, reason);
823 spin_unlock_irqrestore(&l2_lock, flags);
824
825 /* Nothing else to do for power collapse or SWFI. */
826 if (reason == SETRATE_PC || reason == SETRATE_SWFI)
827 goto out;
828
829 /* Update bus bandwith request. */
830 set_bus_bw(tgt_l2_l->bw_level);
831
832 /* Drop VDD levels if we can. */
833 decrease_vdd(cpu, vdd_core, vdd_mem, vdd_dig, reason);
834
835 scalable[cpu].first_set_call = false;
836 pr_debug("ACPU%d speed change complete\n", cpu);
837
838out:
839 if (reason == SETRATE_CPUFREQ || reason == SETRATE_HOTPLUG)
840 mutex_unlock(&driver_lock);
841 return rc;
842}
843
844/* Initialize a HFPLL at a given rate and enable it. */
845static void __init hfpll_init(struct scalable *sc, struct core_speed *tgt_s)
846{
847 pr_debug("Initializing HFPLL%d\n", sc - scalable);
848
849 /* Disable the PLL for re-programming. */
850 hfpll_disable(sc);
851
852 /* Configure PLL parameters for integer mode. */
853 writel_relaxed(0x7845C665, sc->hfpll_base + HFPLL_CONFIG_CTL);
854 writel_relaxed(0, sc->hfpll_base + HFPLL_M_VAL);
855 writel_relaxed(1, sc->hfpll_base + HFPLL_N_VAL);
856
857 /* Program droop controller. */
858 writel_relaxed(0x0108C000, sc->hfpll_base + HFPLL_DROOP_CTL);
859
860 /* Set an initial rate and enable the PLL. */
861 hfpll_set_rate(sc, tgt_s);
862 hfpll_enable(sc);
863}
864
865/* Voltage regulator initialization. */
866static void __init regulator_init(void)
867{
868 int cpu, ret;
869 struct scalable *sc;
870
871 for_each_possible_cpu(cpu) {
872 sc = &scalable[cpu];
873 sc->vreg[VREG_CORE].reg = regulator_get(NULL,
874 sc->vreg[VREG_CORE].name);
875 if (IS_ERR(sc->vreg[VREG_CORE].reg)) {
876 pr_err("regulator_get(%s) failed (%ld)\n",
877 sc->vreg[VREG_CORE].name,
878 PTR_ERR(sc->vreg[VREG_CORE].reg));
879 BUG();
880 }
881
882 ret = regulator_set_voltage(sc->vreg[VREG_CORE].reg,
883 sc->vreg[VREG_CORE].max_vdd,
884 sc->vreg[VREG_CORE].max_vdd);
885 if (ret)
886 pr_err("regulator_set_voltage(%s) failed"
887 " (%d)\n", sc->vreg[VREG_CORE].name, ret);
888
889 ret = regulator_enable(sc->vreg[VREG_CORE].reg);
890 if (ret)
891 pr_err("regulator_enable(%s) failed (%d)\n",
892 sc->vreg[VREG_CORE].name, ret);
893 }
894}
895
896#define INIT_QSB_ID 0
897#define INIT_HFPLL_ID 1
898/* Set initial rate for a given core. */
899static void __init init_clock_sources(struct scalable *sc,
900 struct core_speed *tgt_s)
901{
902 uint32_t pri_src, regval;
903
904 /*
905 * If the HFPLL is in use, program AUX source for QSB, switch to it,
906 * re-initialize the HFPLL, and switch back to the HFPLL. Otherwise,
907 * the HFPLL is not in use, so we can switch directly to it.
908 */
909 pri_src = get_pri_clk_src(scalable);
910 if (pri_src == PRI_SRC_SEL_HFPLL || pri_src == PRI_SRC_SEL_HFPLL_DIV2) {
911 set_sec_clk_src(sc, SEC_SRC_SEL_QSB);
912 set_pri_clk_src(sc, PRI_SRC_SEL_SEC_SRC);
913 }
914 hfpll_init(sc, tgt_s);
915
916 /* Set PRI_SRC_SEL_HFPLL_DIV2 divider to div-2. */
917 regval = readl_cp15_l2ind(sc->l2cpmr_iaddr);
918 regval &= ~(0x3 << 6);
919 writel_cp15_l2ind(regval, sc->l2cpmr_iaddr);
920
921 /* Select PLL8 as AUX source input to the secondary MUX. */
922 writel_relaxed(0x3, sc->aux_clk_sel);
923
924 set_pri_clk_src(sc, tgt_s->pri_src_sel);
925 sc->current_speed = tgt_s;
926
927 /*
928 * Set this flag so that the first call to acpuclk_set_rate() can drop
929 * voltages and set initial bus bandwidth requests.
930 */
931 sc->first_set_call = true;
932}
933
Matt Wagantall8e726c72011-08-06 00:49:28 -0700934static void __init per_cpu_init(void *data)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700935{
Matt Wagantall8e726c72011-08-06 00:49:28 -0700936 int cpu = smp_processor_id();
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -0700937 init_clock_sources(&scalable[cpu], &acpu_freq_tbl[cpu_boot_idx].speed);
938 scalable[cpu].l2_vote = &l2_freq_tbl[l2_boot_idx];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700939}
940
941/* Register with bus driver. */
942static void __init bus_init(void)
943{
944 int ret;
945
946 bus_perf_client = msm_bus_scale_register_client(&bus_client_pdata);
947 if (!bus_perf_client) {
948 pr_err("unable to register bus client\n");
949 BUG();
950 }
951
952 ret = msm_bus_scale_client_update_request(bus_perf_client,
953 (ARRAY_SIZE(bw_level_tbl)-1));
954 if (ret)
955 pr_err("initial bandwidth request failed (%d)\n", ret);
956}
957
958#ifdef CONFIG_CPU_FREQ_MSM
959static struct cpufreq_frequency_table freq_table[NR_CPUS][30];
960
961static void __init cpufreq_table_init(void)
962{
963 int cpu;
964
965 for_each_possible_cpu(cpu) {
966 int i, freq_cnt = 0;
967 /* Construct the freq_table tables from acpu_freq_tbl. */
968 for (i = 0; acpu_freq_tbl[i].speed.khz != 0
969 && freq_cnt < ARRAY_SIZE(*freq_table); i++) {
970 if (acpu_freq_tbl[i].use_for_scaling) {
971 freq_table[cpu][freq_cnt].index = freq_cnt;
972 freq_table[cpu][freq_cnt].frequency
973 = acpu_freq_tbl[i].speed.khz;
974 freq_cnt++;
975 }
976 }
977 /* freq_table not big enough to store all usable freqs. */
978 BUG_ON(acpu_freq_tbl[i].speed.khz != 0);
979
980 freq_table[cpu][freq_cnt].index = freq_cnt;
981 freq_table[cpu][freq_cnt].frequency = CPUFREQ_TABLE_END;
982
983 pr_info("CPU%d: %d scaling frequencies supported.\n",
984 cpu, freq_cnt);
985
986 /* Register table with CPUFreq. */
987 cpufreq_frequency_table_get_attr(freq_table[cpu], cpu);
988 }
989}
990#else
991static void __init cpufreq_table_init(void) {}
992#endif
993
994#define HOT_UNPLUG_KHZ STBY_KHZ
995static int __cpuinit acpuclock_cpu_callback(struct notifier_block *nfb,
996 unsigned long action, void *hcpu)
997{
998 static int prev_khz[NR_CPUS];
999 static int prev_pri_src[NR_CPUS];
1000 static int prev_sec_src[NR_CPUS];
1001 int cpu = (int)hcpu;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001002
1003 switch (action) {
1004 case CPU_DYING:
1005 case CPU_DYING_FROZEN:
1006 /*
Matt Wagantall27663842011-08-25 15:11:48 -07001007 * On Krait v1, the primary and secondary muxes must be set
1008 * to QSB before L2 power collapse and restored after.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001009 */
Matt Wagantall27663842011-08-25 15:11:48 -07001010 if (cpu_is_krait_v1()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001011 prev_sec_src[cpu] = get_sec_clk_src(&scalable[cpu]);
1012 prev_pri_src[cpu] = get_pri_clk_src(&scalable[cpu]);
1013 set_sec_clk_src(&scalable[cpu], SEC_SRC_SEL_QSB);
1014 set_pri_clk_src(&scalable[cpu], PRI_SRC_SEL_SEC_SRC);
1015 }
1016 break;
1017 case CPU_DEAD:
1018 case CPU_DEAD_FROZEN:
1019 prev_khz[cpu] = acpuclk_get_rate(cpu);
1020 /* Fall through. */
1021 case CPU_UP_CANCELED:
1022 case CPU_UP_CANCELED_FROZEN:
1023 acpuclk_set_rate(cpu, HOT_UNPLUG_KHZ, SETRATE_HOTPLUG);
1024 break;
1025 case CPU_UP_PREPARE:
1026 case CPU_UP_PREPARE_FROZEN:
1027 if (WARN_ON(!prev_khz[cpu]))
1028 prev_khz[cpu] = acpu_freq_tbl->speed.khz;
1029 acpuclk_set_rate(cpu, prev_khz[cpu], SETRATE_HOTPLUG);
1030 break;
1031 case CPU_STARTING:
1032 case CPU_STARTING_FROZEN:
Matt Wagantall27663842011-08-25 15:11:48 -07001033 if (cpu_is_krait_v1()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001034 set_sec_clk_src(&scalable[cpu], prev_sec_src[cpu]);
1035 set_pri_clk_src(&scalable[cpu], prev_pri_src[cpu]);
1036 }
1037 break;
1038 default:
1039 break;
1040 }
1041
1042 return NOTIFY_OK;
1043}
1044
1045static struct notifier_block __cpuinitdata acpuclock_cpu_notifier = {
1046 .notifier_call = acpuclock_cpu_callback,
1047};
1048
1049void __init msm_acpu_clock_init(struct msm_acpu_clock_platform_data *clkdata)
1050{
Vikram Mulukutlaa00149c2011-07-21 18:43:26 -07001051 if (cpu_is_msm8960()) {
1052 scalable = scalable_8960;
1053 acpu_freq_tbl = acpu_freq_tbl_8960;
1054 l2_freq_tbl = l2_freq_tbl_8960;
1055 l2_freq_tbl_size = ARRAY_SIZE(l2_freq_tbl_8960);
1056 l2_boot_idx = 11;
1057 cpu_boot_idx = 11;
1058 } else if (cpu_is_apq8064()) {
1059 scalable = scalable_8064;
1060 acpu_freq_tbl = acpu_freq_tbl_8064;
1061 l2_freq_tbl = l2_freq_tbl_8064;
1062 l2_freq_tbl_size = ARRAY_SIZE(l2_freq_tbl_8064);
1063 l2_boot_idx = 11;
1064 cpu_boot_idx = 11;
1065 }
1066
1067 init_clock_sources(&scalable[L2], &l2_freq_tbl[l2_boot_idx].speed);
Rohit Vaswanice74ba32011-08-15 15:28:36 -07001068 on_each_cpu(per_cpu_init, NULL, true);
Matt Wagantall8e726c72011-08-06 00:49:28 -07001069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001070 regulator_init();
1071 bus_init();
1072 cpufreq_table_init();
1073 register_hotcpu_notifier(&acpuclock_cpu_notifier);
1074}