blob: 031725b9d050649b5497fec7abbefa13caadee9a [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* arch/arm/mach-msm/acpuclock.c
2 *
3 * MSM architecture clock driver
4 *
5 * Copyright (C) 2007 Google, Inc.
6 * Copyright (c) 2007-2011, Code Aurora Forum. All rights reserved.
7 * Author: San Mehat <san@android.com>
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 */
19
20#include <linux/version.h>
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/errno.h>
24#include <linux/string.h>
25#include <linux/delay.h>
26#include <linux/clk.h>
27#include <linux/cpufreq.h>
28#include <linux/mutex.h>
29#include <linux/io.h>
30#include <linux/sort.h>
31#include <linux/remote_spinlock.h>
32#include <mach/board.h>
33#include <mach/msm_iomap.h>
34#include <asm/mach-types.h>
35#include <mach/socinfo.h>
36
37#include "proc_comm.h"
38#include "smd_private.h"
39#include "acpuclock.h"
40
41#define A11S_CLK_CNTL_ADDR (MSM_CSR_BASE + 0x100)
42#define A11S_CLK_SEL_ADDR (MSM_CSR_BASE + 0x104)
43#define A11S_VDD_SVS_PLEVEL_ADDR (MSM_CSR_BASE + 0x124)
44#define PLLn_MODE(n) (MSM_CLK_CTL_BASE + 0x300 + 28 * (n))
45#define PLLn_L_VAL(n) (MSM_CLK_CTL_BASE + 0x304 + 28 * (n))
46
47#define PLL4_MODE (MSM_CLK_CTL_BASE + 0x374)
48#define PLL4_L_VAL (MSM_CLK_CTL_BASE + 0x378)
49
50/* Max CPU frequency allowed by hardware while in standby waiting for an irq. */
51#define MAX_WAIT_FOR_IRQ_KHZ 128000
52
53enum {
54 ACPU_PLL_TCXO = -1,
55 ACPU_PLL_0 = 0,
56 ACPU_PLL_1,
57 ACPU_PLL_2,
58 ACPU_PLL_3,
59 ACPU_PLL_4,
60 ACPU_PLL_END,
61};
62
63static const struct pll {
64 void __iomem *mod_reg;
65 const uint32_t l_val_mask;
66} soc_pll[ACPU_PLL_END] = {
67 [ACPU_PLL_0] = {PLLn_MODE(ACPU_PLL_0), 0x3f},
68 [ACPU_PLL_1] = {PLLn_MODE(ACPU_PLL_1), 0x3f},
69 [ACPU_PLL_2] = {PLLn_MODE(ACPU_PLL_2), 0x3f},
70 [ACPU_PLL_3] = {PLLn_MODE(ACPU_PLL_3), 0x3f},
71 [ACPU_PLL_4] = {PLL4_MODE, 0x3ff},
72};
73
74struct clock_state {
75 struct clkctl_acpu_speed *current_speed;
76 struct mutex lock;
77 uint32_t acpu_switch_time_us;
78 uint32_t max_speed_delta_khz;
79 uint32_t vdd_switch_time_us;
80 unsigned long max_axi_khz;
81 unsigned long wait_for_irq_khz;
82 struct clk *ebi1_clk;
83};
84
85#define PLL_BASE 7
86
87struct shared_pll_control {
88 uint32_t version;
89 struct {
90 /* Denotes if the PLL is ON. Technically, this can be read
91 * directly from the PLL registers, but this feild is here,
92 * so let's use it.
93 */
94 uint32_t on;
95 /* One bit for each processor core. The application processor
96 * is allocated bit position 1. All other bits should be
97 * considered as votes from other processors.
98 */
99 uint32_t votes;
100 } pll[PLL_BASE + ACPU_PLL_END];
101};
102
103struct clkctl_acpu_speed {
104 unsigned int use_for_scaling;
105 unsigned int a11clk_khz;
106 int pll;
107 unsigned int a11clk_src_sel;
108 unsigned int a11clk_src_div;
109 unsigned int ahbclk_khz;
110 unsigned int ahbclk_div;
111 int vdd;
112 unsigned int axiclk_khz;
113 unsigned long lpj; /* loops_per_jiffy */
114 /* Pointers in acpu_freq_tbl[] for max up/down steppings. */
115 struct clkctl_acpu_speed *down[ACPU_PLL_END];
116 struct clkctl_acpu_speed *up[ACPU_PLL_END];
117};
118
119static remote_spinlock_t pll_lock;
120static struct shared_pll_control *pll_control;
121static struct clock_state drv_state = { 0 };
122static struct clkctl_acpu_speed *acpu_freq_tbl;
123
124static void __init acpuclk_init(void);
125
126/*
127 * ACPU freq tables used for different PLLs frequency combinations. The
128 * correct table is selected during init.
129 *
130 * Table stepping up/down entries are calculated during boot to choose the
131 * largest frequency jump that's less than max_speed_delta_khz on each PLL.
132 */
133
134/* 7x01/7x25 normal with GSM capable modem */
135static struct clkctl_acpu_speed pll0_245_pll1_768_pll2_1056_pll4_0[] = {
136 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 },
137 { 1, 122880, ACPU_PLL_0, 4, 1, 61440, 1, 3, 61440 },
138 { 0, 128000, ACPU_PLL_1, 1, 5, 64000, 1, 3, 61440 },
139 { 0, 176000, ACPU_PLL_2, 2, 5, 88000, 1, 3, 61440 },
140 { 1, 245760, ACPU_PLL_0, 4, 0, 81920, 2, 4, 61440 },
141 { 1, 256000, ACPU_PLL_1, 1, 2, 128000, 1, 5, 128000 },
142 { 0, 352000, ACPU_PLL_2, 2, 2, 88000, 3, 5, 128000 },
143 { 1, 384000, ACPU_PLL_1, 1, 1, 128000, 2, 6, 128000 },
144 { 1, 528000, ACPU_PLL_2, 2, 1, 132000, 3, 7, 128000 },
145 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
146};
147
148/* 7x01/7x25 normal with CDMA-only modem */
149static struct clkctl_acpu_speed pll0_196_pll1_768_pll2_1056_pll4_0[] = {
150 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 },
151 { 1, 98304, ACPU_PLL_0, 4, 1, 49152, 1, 3, 24576 },
152 { 0, 128000, ACPU_PLL_1, 1, 5, 64000, 1, 3, 24576 },
153 { 0, 176000, ACPU_PLL_2, 2, 5, 88000, 1, 3, 24576 },
154 { 1, 196608, ACPU_PLL_0, 4, 0, 65536, 2, 4, 24576 },
155 { 1, 256000, ACPU_PLL_1, 1, 2, 128000, 1, 5, 128000 },
156 { 0, 352000, ACPU_PLL_2, 2, 2, 88000, 3, 5, 128000 },
157 { 1, 384000, ACPU_PLL_1, 1, 1, 128000, 2, 6, 128000 },
158 { 1, 528000, ACPU_PLL_2, 2, 1, 132000, 3, 7, 128000 },
159 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
160};
161
162/* 7x01/7x25 turbo with GSM capable modem */
163static struct clkctl_acpu_speed pll0_245_pll1_960_pll2_1056_pll4_0[] = {
164 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 },
165 { 0, 120000, ACPU_PLL_1, 1, 7, 60000, 1, 3, 61440 },
166 { 1, 122880, ACPU_PLL_0, 4, 1, 61440, 1, 3, 61440 },
167 { 0, 176000, ACPU_PLL_2, 2, 5, 88000, 1, 3, 61440 },
168 { 1, 245760, ACPU_PLL_0, 4, 0, 81920, 2, 4, 61440 },
169 { 1, 320000, ACPU_PLL_1, 1, 2, 107000, 2, 5, 120000 },
170 { 0, 352000, ACPU_PLL_2, 2, 2, 88000, 3, 5, 120000 },
171 { 1, 480000, ACPU_PLL_1, 1, 1, 120000, 3, 6, 120000 },
172 { 1, 528000, ACPU_PLL_2, 2, 1, 132000, 3, 7, 122880 },
173 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
174};
175
176/* 7x01/7x25 turbo with CDMA-only modem */
177static struct clkctl_acpu_speed pll0_196_pll1_960_pll2_1056_pll4_0[] = {
178 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 },
179 { 1, 98304, ACPU_PLL_0, 4, 1, 49152, 1, 3, 24576 },
180 { 0, 120000, ACPU_PLL_1, 1, 7, 60000, 1, 3, 24576 },
181 { 0, 176000, ACPU_PLL_2, 2, 5, 88000, 1, 3, 24576 },
182 { 1, 196608, ACPU_PLL_0, 4, 0, 65536, 2, 4, 24576 },
183 { 1, 320000, ACPU_PLL_1, 1, 2, 107000, 2, 5, 120000 },
184 { 0, 352000, ACPU_PLL_2, 2, 2, 88000, 3, 5, 120000 },
185 { 1, 480000, ACPU_PLL_1, 1, 1, 120000, 3, 6, 120000 },
186 { 1, 528000, ACPU_PLL_2, 2, 1, 132000, 3, 7, 120000 },
187 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
188};
189
190/* 7x27 normal with GSM capable modem */
191static struct clkctl_acpu_speed pll0_245_pll1_960_pll2_1200_pll4_0[] = {
192 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 },
193 { 0, 120000, ACPU_PLL_1, 1, 7, 60000, 1, 3, 61440 },
194 { 1, 122880, ACPU_PLL_0, 4, 1, 61440, 1, 3, 61440 },
195 { 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 61440 },
196 { 1, 245760, ACPU_PLL_0, 4, 0, 122880, 1, 4, 61440 },
197 { 1, 320000, ACPU_PLL_1, 1, 2, 160000, 1, 5, 122880 },
198 { 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 122880 },
199 { 1, 480000, ACPU_PLL_1, 1, 1, 160000, 2, 6, 122880 },
200 { 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 122880 },
201 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
202};
203
204/* 7x27 normal with CDMA-only modem */
205static struct clkctl_acpu_speed pll0_196_pll1_960_pll2_1200_pll4_0[] = {
206 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 },
207 { 1, 98304, ACPU_PLL_0, 4, 1, 98304, 0, 3, 49152 },
208 { 0, 120000, ACPU_PLL_1, 1, 7, 60000, 1, 3, 49152 },
209 { 1, 196608, ACPU_PLL_0, 4, 0, 65536, 2, 4, 98304 },
210 { 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 98304 },
211 { 1, 320000, ACPU_PLL_1, 1, 2, 160000, 1, 5, 120000 },
212 { 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 120000 },
213 { 1, 480000, ACPU_PLL_1, 1, 1, 160000, 2, 6, 120000 },
214 { 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 120000 },
215 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
216};
217
218/* 7x27 normal with GSM capable modem - PLL0 and PLL1 swapped */
219static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_0[] = {
220 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 },
221 { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 61440 },
222 { 1, 122880, ACPU_PLL_1, 1, 1, 61440, 1, 3, 61440 },
223 { 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 61440 },
224 { 1, 245760, ACPU_PLL_1, 1, 0, 122880, 1, 4, 61440 },
225 { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 122880 },
226 { 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 122880 },
227 { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 122880 },
228 { 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 122880 },
229 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
230};
231
232/* 7x27 normal with CDMA-only modem - PLL0 and PLL1 swapped */
233static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_0[] = {
234 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 },
235 { 1, 98304, ACPU_PLL_1, 1, 1, 98304, 0, 3, 49152 },
236 { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 49152 },
237 { 1, 196608, ACPU_PLL_1, 1, 0, 65536, 2, 4, 98304 },
238 { 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 98304 },
239 { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 120000 },
240 { 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 120000 },
241 { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 120000 },
242 { 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 120000 },
243 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
244};
245
246/* 7x27 normal with GSM capable modem - PLL0 and PLL1 swapped and pll2 @ 800 */
247static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_800_pll4_0[] = {
248 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 },
249 { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 61440 },
250 { 1, 122880, ACPU_PLL_1, 1, 1, 61440, 1, 3, 61440 },
251 { 0, 200000, ACPU_PLL_2, 2, 3, 66667, 2, 4, 61440 },
252 { 1, 245760, ACPU_PLL_1, 1, 0, 122880, 1, 4, 61440 },
253 { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 122880 },
254 { 0, 400000, ACPU_PLL_2, 2, 1, 133333, 2, 5, 122880 },
255 { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 122880 },
256 { 1, 800000, ACPU_PLL_2, 2, 0, 200000, 3, 7, 122880 },
257 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
258};
259
260/* 7x27 normal with CDMA-only modem - PLL0 and PLL1 swapped and pll2 @ 800 */
261static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_800_pll4_0[] = {
262 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 24576 },
263 { 1, 98304, ACPU_PLL_1, 1, 1, 98304, 0, 3, 49152 },
264 { 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 49152 },
265 { 1, 196608, ACPU_PLL_1, 1, 0, 65536, 2, 4, 98304 },
266 { 0, 200000, ACPU_PLL_2, 2, 3, 66667, 2, 4, 98304 },
267 { 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 120000 },
268 { 0, 400000, ACPU_PLL_2, 2, 1, 133333, 2, 5, 120000 },
269 { 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 6, 120000 },
270 { 1, 800000, ACPU_PLL_2, 2, 0, 200000, 3, 7, 120000 },
271 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
272};
273
274/* 7x27a pll2 at 1200mhz with GSM capable modem */
275static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200_pll4_800[] = {
Trilok Soni7d6c8652011-07-14 15:35:07 +0530276 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 30720 },
277 { 0, 61440, ACPU_PLL_1, 1, 3, 7680, 3, 1, 61440 },
278 { 1, 122880, ACPU_PLL_1, 1, 1, 15360, 3, 2, 61440 },
279 { 1, 245760, ACPU_PLL_1, 1, 0, 30720, 3, 3, 61440 },
280 { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 },
281 { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 122880 },
282 { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 122880 },
283 { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 122880 },
284 { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 },
285 { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700286 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
287};
288
289/* 7x27a pll2 at 1200mhz with CDMA only modem */
290static struct clkctl_acpu_speed pll0_960_pll1_196_pll2_1200_pll4_800[] = {
Trilok Soni7d6c8652011-07-14 15:35:07 +0530291 { 0, 19200, ACPU_PLL_TCXO, 0, 0, 2400, 3, 0, 24576 },
292 { 0, 65536, ACPU_PLL_1, 1, 3, 8192, 3, 1, 49152 },
293 { 1, 98304, ACPU_PLL_1, 1, 1, 12288, 3, 2, 49152 },
294 { 1, 196608, ACPU_PLL_1, 1, 0, 24576, 3, 3, 98304 },
295 { 0, 300000, ACPU_PLL_2, 2, 3, 37500, 3, 4, 150000 },
296 { 1, 320000, ACPU_PLL_0, 4, 2, 40000, 3, 4, 160000 },
297 { 0, 400000, ACPU_PLL_4, 6, 1, 50000, 3, 4, 160000 },
298 { 1, 480000, ACPU_PLL_0, 4, 1, 60000, 3, 5, 160000 },
299 { 1, 600000, ACPU_PLL_2, 2, 1, 75000, 3, 6, 200000 },
300 { 1, 800000, ACPU_PLL_4, 6, 0, 100000, 3, 7, 200000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700301 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0} }
302};
303
304#define PLL_0_MHZ 0
305#define PLL_196_MHZ 10
306#define PLL_245_MHZ 12
307#define PLL_491_MHZ 25
308#define PLL_768_MHZ 40
309#define PLL_800_MHZ 41
310#define PLL_960_MHZ 50
311#define PLL_1056_MHZ 55
312#define PLL_1200_MHZ 62
313
314#define PLL_CONFIG(m0, m1, m2, m4) { \
315 PLL_##m0##_MHZ, PLL_##m1##_MHZ, PLL_##m2##_MHZ, PLL_##m4##_MHZ, \
316 pll0_##m0##_pll1_##m1##_pll2_##m2##_pll4_##m4 \
317}
318
319struct pll_freq_tbl_map {
320 unsigned int pll0_l;
321 unsigned int pll1_l;
322 unsigned int pll2_l;
323 unsigned int pll4_l;
324 struct clkctl_acpu_speed *tbl;
325};
326
327static struct pll_freq_tbl_map acpu_freq_tbl_list[] = {
328 PLL_CONFIG(196, 768, 1056, 0),
329 PLL_CONFIG(245, 768, 1056, 0),
330 PLL_CONFIG(196, 960, 1056, 0),
331 PLL_CONFIG(245, 960, 1056, 0),
332 PLL_CONFIG(196, 960, 1200, 0),
333 PLL_CONFIG(245, 960, 1200, 0),
334 PLL_CONFIG(960, 196, 1200, 0),
335 PLL_CONFIG(960, 245, 1200, 0),
336 PLL_CONFIG(960, 196, 800, 0),
337 PLL_CONFIG(960, 245, 800, 0),
338 PLL_CONFIG(960, 245, 1200, 800),
339 PLL_CONFIG(960, 196, 1200, 800),
340 { 0, 0, 0, 0, 0 }
341};
342
343#ifdef CONFIG_CPU_FREQ_MSM
344static struct cpufreq_frequency_table freq_table[20];
345
346static void __init cpufreq_table_init(void)
347{
348 unsigned int i;
349 unsigned int freq_cnt = 0;
350
351 /* Construct the freq_table table from acpu_freq_tbl since the
352 * freq_table values need to match frequencies specified in
353 * acpu_freq_tbl and acpu_freq_tbl needs to be fixed up during init.
354 */
355 for (i = 0; acpu_freq_tbl[i].a11clk_khz != 0
356 && freq_cnt < ARRAY_SIZE(freq_table)-1; i++) {
357 if (acpu_freq_tbl[i].use_for_scaling) {
358 freq_table[freq_cnt].index = freq_cnt;
359 freq_table[freq_cnt].frequency
360 = acpu_freq_tbl[i].a11clk_khz;
361 freq_cnt++;
362 }
363 }
364
365 /* freq_table not big enough to store all usable freqs. */
366 BUG_ON(acpu_freq_tbl[i].a11clk_khz != 0);
367
368 freq_table[freq_cnt].index = freq_cnt;
369 freq_table[freq_cnt].frequency = CPUFREQ_TABLE_END;
370
371 pr_info("%d scaling frequencies supported.\n", freq_cnt);
372}
373#endif
374
375static void pll_enable(void __iomem *addr, unsigned on)
376{
377 if (on) {
378 writel_relaxed(2, addr);
379 mb();
380 udelay(5);
381 writel_relaxed(6, addr);
382 mb();
383 udelay(50);
384 writel_relaxed(7, addr);
385 } else {
386 writel_relaxed(0, addr);
387 }
388}
389
390static int pc_pll_request(unsigned id, unsigned on)
391{
392 int res = 0;
393 on = !!on;
394
395 if (on)
396 pr_debug("Enabling PLL %d\n", id);
397 else
398 pr_debug("Disabling PLL %d\n", id);
399
400 if (id >= ACPU_PLL_END)
401 return -EINVAL;
402
403 if (pll_control) {
404 remote_spin_lock(&pll_lock);
405 if (on) {
406 pll_control->pll[PLL_BASE + id].votes |= 2;
407 if (!pll_control->pll[PLL_BASE + id].on) {
408 pll_enable(soc_pll[id].mod_reg, 1);
409 pll_control->pll[PLL_BASE + id].on = 1;
410 }
411 } else {
412 pll_control->pll[PLL_BASE + id].votes &= ~2;
413 if (pll_control->pll[PLL_BASE + id].on
414 && !pll_control->pll[PLL_BASE + id].votes) {
415 pll_enable(soc_pll[id].mod_reg, 0);
416 pll_control->pll[PLL_BASE + id].on = 0;
417 }
418 }
419 remote_spin_unlock(&pll_lock);
420 } else {
421 res = msm_proc_comm(PCOM_CLKCTL_RPC_PLL_REQUEST, &id, &on);
422 if (res < 0)
423 return res;
424 else if ((int) id < 0)
425 return -EINVAL;
426 }
427
428 if (on)
429 pr_debug("PLL enabled\n");
430 else
431 pr_debug("PLL disabled\n");
432
433 return res;
434}
435
436
437/*----------------------------------------------------------------------------
438 * ARM11 'owned' clock control
439 *---------------------------------------------------------------------------*/
440
441#define POWER_COLLAPSE_KHZ 19200
442unsigned long acpuclk_power_collapse(void)
443{
444 int ret = acpuclk_get_rate(smp_processor_id());
445 acpuclk_set_rate(smp_processor_id(), POWER_COLLAPSE_KHZ, SETRATE_PC);
446 return ret;
447}
448
449unsigned long acpuclk_wait_for_irq(void)
450{
451 int rate = acpuclk_get_rate(smp_processor_id());
452 if (rate > MAX_WAIT_FOR_IRQ_KHZ)
453 acpuclk_set_rate(smp_processor_id(), drv_state.wait_for_irq_khz,
454 SETRATE_SWFI);
455 return rate;
456}
457
458static int acpuclk_set_vdd_level(int vdd)
459{
460 uint32_t current_vdd;
461
462 /*
463 * NOTE: v1.0 of 7x27a/7x25a chip doesn't have working
464 * VDD switching support.
465 */
466 if ((cpu_is_msm7x27a() || cpu_is_msm7x25a()) &&
467 (SOCINFO_VERSION_MINOR(socinfo_get_version()) < 1))
468 return 0;
469
470 current_vdd = readl_relaxed(A11S_VDD_SVS_PLEVEL_ADDR) & 0x07;
471
472 pr_debug("Switching VDD from %u mV -> %d mV\n",
473 current_vdd, vdd);
474
475 writel_relaxed((1 << 7) | (vdd << 3), A11S_VDD_SVS_PLEVEL_ADDR);
476 mb();
477 udelay(drv_state.vdd_switch_time_us);
478 if ((readl_relaxed(A11S_VDD_SVS_PLEVEL_ADDR) & 0x7) != vdd) {
479 pr_err("VDD set failed\n");
480 return -EIO;
481 }
482
483 pr_debug("VDD switched\n");
484
485 return 0;
486}
487
488/* Set proper dividers for the given clock speed. */
489static void acpuclk_set_div(const struct clkctl_acpu_speed *hunt_s)
490{
491 uint32_t reg_clkctl, reg_clksel, clk_div, src_sel;
492
493 reg_clksel = readl_relaxed(A11S_CLK_SEL_ADDR);
494
495 /* AHB_CLK_DIV */
496 clk_div = (reg_clksel >> 1) & 0x03;
497 /* CLK_SEL_SRC1NO */
498 src_sel = reg_clksel & 1;
499
500 /*
501 * If the new clock divider is higher than the previous, then
502 * program the divider before switching the clock
503 */
504 if (hunt_s->ahbclk_div > clk_div) {
505 reg_clksel &= ~(0x3 << 1);
506 reg_clksel |= (hunt_s->ahbclk_div << 1);
507 writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR);
508 }
509
510 /* Program clock source and divider */
511 reg_clkctl = readl_relaxed(A11S_CLK_CNTL_ADDR);
512 reg_clkctl &= ~(0xFF << (8 * src_sel));
513 reg_clkctl |= hunt_s->a11clk_src_sel << (4 + 8 * src_sel);
514 reg_clkctl |= hunt_s->a11clk_src_div << (0 + 8 * src_sel);
515 writel_relaxed(reg_clkctl, A11S_CLK_CNTL_ADDR);
516
517 /* Program clock source selection */
518 reg_clksel ^= 1;
519 writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR);
520
521 /*
522 * If the new clock divider is lower than the previous, then
523 * program the divider after switching the clock
524 */
525 if (hunt_s->ahbclk_div < clk_div) {
526 reg_clksel &= ~(0x3 << 1);
527 reg_clksel |= (hunt_s->ahbclk_div << 1);
528 writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR);
529 }
530}
531
532int acpuclk_set_rate(int cpu, unsigned long rate, enum setrate_reason reason)
533{
534 uint32_t reg_clkctl;
535 struct clkctl_acpu_speed *cur_s, *tgt_s, *strt_s;
536 int res, rc = 0;
537 unsigned int plls_enabled = 0, pll;
538
539 if (reason == SETRATE_CPUFREQ)
540 mutex_lock(&drv_state.lock);
541
542 strt_s = cur_s = drv_state.current_speed;
543
544 WARN_ONCE(cur_s == NULL, "acpuclk_set_rate: not initialized\n");
545 if (cur_s == NULL) {
546 rc = -ENOENT;
547 goto out;
548 }
549
550 if (rate == cur_s->a11clk_khz)
551 goto out;
552
553 for (tgt_s = acpu_freq_tbl; tgt_s->a11clk_khz != 0; tgt_s++) {
554 if (tgt_s->a11clk_khz == rate)
555 break;
556 }
557
558 if (tgt_s->a11clk_khz == 0) {
559 rc = -EINVAL;
560 goto out;
561 }
562
563 /* Choose the highest speed at or below 'rate' with same PLL. */
564 if (reason != SETRATE_CPUFREQ
565 && tgt_s->a11clk_khz < cur_s->a11clk_khz) {
566 while (tgt_s->pll != ACPU_PLL_TCXO && tgt_s->pll != cur_s->pll)
567 tgt_s--;
568 }
569
570 if (strt_s->pll != ACPU_PLL_TCXO)
571 plls_enabled |= 1 << strt_s->pll;
572
573 if (reason == SETRATE_CPUFREQ) {
574 if (strt_s->pll != tgt_s->pll && tgt_s->pll != ACPU_PLL_TCXO) {
575 rc = pc_pll_request(tgt_s->pll, 1);
576 if (rc < 0) {
577 pr_err("PLL%d enable failed (%d)\n",
578 tgt_s->pll, rc);
579 goto out;
580 }
581 plls_enabled |= 1 << tgt_s->pll;
582 }
583 }
584 /* Need to do this when coming out of power collapse since some modem
585 * firmwares reset the VDD when the application processor enters power
586 * collapse. */
587 if (reason == SETRATE_CPUFREQ || reason == SETRATE_PC) {
588 /* Increase VDD if needed. */
589 if (tgt_s->vdd > cur_s->vdd) {
590 rc = acpuclk_set_vdd_level(tgt_s->vdd);
591 if (rc < 0) {
592 pr_err("Unable to switch ACPU vdd (%d)\n", rc);
593 goto out;
594 }
595 }
596 }
597
598 /* Set wait states for CPU inbetween frequency changes */
599 reg_clkctl = readl_relaxed(A11S_CLK_CNTL_ADDR);
600 reg_clkctl |= (100 << 16); /* set WT_ST_CNT */
601 writel_relaxed(reg_clkctl, A11S_CLK_CNTL_ADDR);
602
603 pr_debug("Switching from ACPU rate %u KHz -> %u KHz\n",
604 strt_s->a11clk_khz, tgt_s->a11clk_khz);
605
606 while (cur_s != tgt_s) {
607 /*
608 * Always jump to target freq if within 256mhz, regulardless of
609 * PLL. If differnece is greater, use the predefinied
610 * steppings in the table.
611 */
612 int d = abs((int)(cur_s->a11clk_khz - tgt_s->a11clk_khz));
613 if (d > drv_state.max_speed_delta_khz) {
614
615 if (tgt_s->a11clk_khz > cur_s->a11clk_khz) {
616 /* Step up: jump to target PLL as early as
617 * possible so indexing using TCXO (up[-1])
618 * never occurs. */
619 if (likely(cur_s->up[tgt_s->pll]))
620 cur_s = cur_s->up[tgt_s->pll];
621 else
622 cur_s = cur_s->up[cur_s->pll];
623 } else {
624 /* Step down: stay on current PLL as long as
625 * possible so indexing using TCXO (down[-1])
626 * never occurs. */
627 if (likely(cur_s->down[cur_s->pll]))
628 cur_s = cur_s->down[cur_s->pll];
629 else
630 cur_s = cur_s->down[tgt_s->pll];
631 }
632
633 if (cur_s == NULL) { /* This should not happen. */
634 pr_err("No stepping frequencies found. "
635 "strt_s:%u tgt_s:%u\n",
636 strt_s->a11clk_khz, tgt_s->a11clk_khz);
637 rc = -EINVAL;
638 goto out;
639 }
640
641 } else {
642 cur_s = tgt_s;
643 }
644
645 pr_debug("STEP khz = %u, pll = %d\n",
646 cur_s->a11clk_khz, cur_s->pll);
647
648 if (cur_s->pll != ACPU_PLL_TCXO
649 && !(plls_enabled & (1 << cur_s->pll))) {
650 rc = pc_pll_request(cur_s->pll, 1);
651 if (rc < 0) {
652 pr_err("PLL%d enable failed (%d)\n",
653 cur_s->pll, rc);
654 goto out;
655 }
656 plls_enabled |= 1 << cur_s->pll;
657 }
658
659 acpuclk_set_div(cur_s);
660 drv_state.current_speed = cur_s;
661 /* Re-adjust lpj for the new clock speed. */
662 loops_per_jiffy = cur_s->lpj;
663 mb();
664 udelay(drv_state.acpu_switch_time_us);
665 }
666
667 /* Nothing else to do for SWFI. */
668 if (reason == SETRATE_SWFI)
669 goto out;
670
671 /* Change the AXI bus frequency if we can. */
672 if (strt_s->axiclk_khz != tgt_s->axiclk_khz) {
673 res = clk_set_rate(drv_state.ebi1_clk,
674 tgt_s->axiclk_khz * 1000);
675 if (res < 0)
676 pr_warning("Setting AXI min rate failed (%d)\n", res);
677 }
678
679 /* Disable PLLs we are not using anymore. */
680 if (tgt_s->pll != ACPU_PLL_TCXO)
681 plls_enabled &= ~(1 << tgt_s->pll);
682 for (pll = ACPU_PLL_0; pll < ACPU_PLL_END; pll++)
683 if (plls_enabled & (1 << pll)) {
684 res = pc_pll_request(pll, 0);
685 if (res < 0)
686 pr_warning("PLL%d disable failed (%d)\n",
687 pll, res);
688 }
689
690 /* Nothing else to do for power collapse. */
691 if (reason == SETRATE_PC)
692 goto out;
693
694 /* Drop VDD level if we can. */
695 if (tgt_s->vdd < strt_s->vdd) {
696 res = acpuclk_set_vdd_level(tgt_s->vdd);
697 if (res < 0)
698 pr_warning("Unable to drop ACPU vdd (%d)\n", res);
699 }
700
701 pr_debug("ACPU speed change complete\n");
702out:
703 if (reason == SETRATE_CPUFREQ)
704 mutex_unlock(&drv_state.lock);
705 return rc;
706}
707
708static void __init acpuclk_init(void)
709{
710 struct clkctl_acpu_speed *speed;
Trilok Soni7d6c8652011-07-14 15:35:07 +0530711 uint32_t div, sel, reg_clksel;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700712 int res;
713
714 /*
715 * Determine the rate of ACPU clock
716 */
717
718 if (!(readl_relaxed(A11S_CLK_SEL_ADDR) & 0x01)) { /* CLK_SEL_SRC1N0 */
719 /* CLK_SRC0_SEL */
720 sel = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 12) & 0x7;
721 /* CLK_SRC0_DIV */
722 div = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 8) & 0x0f;
723 } else {
724 /* CLK_SRC1_SEL */
725 sel = (readl_relaxed(A11S_CLK_CNTL_ADDR) >> 4) & 0x07;
726 /* CLK_SRC1_DIV */
727 div = readl_relaxed(A11S_CLK_CNTL_ADDR) & 0x0f;
728 }
729
730 /* Accomodate bootloaders that might not be implementing the
731 * workaround for the h/w bug in 7x25. */
732 if (cpu_is_msm7x25() && sel == 2)
733 sel = 3;
734
735 for (speed = acpu_freq_tbl; speed->a11clk_khz != 0; speed++) {
736 if (speed->a11clk_src_sel == sel
737 && (speed->a11clk_src_div == div))
738 break;
739 }
740 if (speed->a11clk_khz == 0) {
741 pr_err("Error - ACPU clock reports invalid speed\n");
742 return;
743 }
744
745 drv_state.current_speed = speed;
746 if (speed->pll != ACPU_PLL_TCXO)
747 if (pc_pll_request(speed->pll, 1))
748 pr_warning("Failed to vote for boot PLL\n");
749
Trilok Soni7d6c8652011-07-14 15:35:07 +0530750 /* Fix div2 to 2 for 7x27/5a(aa) targets */
751 if (!cpu_is_msm7x27()) {
752 reg_clksel = readl_relaxed(A11S_CLK_SEL_ADDR);
753 reg_clksel &= ~(0x3 << 14);
754 reg_clksel |= (0x1 << 14);
755 writel_relaxed(reg_clksel, A11S_CLK_SEL_ADDR);
756 }
757
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700758 res = clk_set_rate(drv_state.ebi1_clk, speed->axiclk_khz * 1000);
759 if (res < 0)
760 pr_warning("Setting AXI min rate failed (%d)\n", res);
761 res = clk_enable(drv_state.ebi1_clk);
762 if (res < 0)
763 pr_warning("Enabling AXI clock failed (%d)\n", res);
764
765 pr_info("ACPU running at %d KHz\n", speed->a11clk_khz);
766}
767
768unsigned long acpuclk_get_rate(int cpu)
769{
770 WARN_ONCE(drv_state.current_speed == NULL,
771 "acpuclk_get_rate: not initialized\n");
772 if (drv_state.current_speed)
773 return drv_state.current_speed->a11clk_khz;
774 else
775 return 0;
776}
777
778uint32_t acpuclk_get_switch_time(void)
779{
780 return drv_state.acpu_switch_time_us;
781}
782
783/*----------------------------------------------------------------------------
784 * Clock driver initialization
785 *---------------------------------------------------------------------------*/
786
787#define DIV2REG(n) ((n)-1)
788#define REG2DIV(n) ((n)+1)
789#define SLOWER_BY(div, factor) div = DIV2REG(REG2DIV(div) * factor)
790
791static void __init acpu_freq_tbl_fixup(void)
792{
793 unsigned long pll0_l, pll1_l, pll2_l, pll4_l;
794 int axi_160mhz = 0, axi_200mhz = 0;
795 struct pll_freq_tbl_map *lst;
796 struct clkctl_acpu_speed *t;
797 unsigned int pll0_needs_fixup = 0;
798
799 /* Wait for the PLLs to be initialized and then read their frequency.
800 */
801 do {
802 pll0_l = readl_relaxed(PLLn_L_VAL(0)) &
803 soc_pll[ACPU_PLL_0].l_val_mask;
804 cpu_relax();
805 udelay(50);
806 } while (pll0_l == 0);
807 do {
808 pll1_l = readl_relaxed(PLLn_L_VAL(1)) &
809 soc_pll[ACPU_PLL_1].l_val_mask;
810 cpu_relax();
811 udelay(50);
812 } while (pll1_l == 0);
813 do {
814 pll2_l = readl_relaxed(PLLn_L_VAL(2)) &
815 soc_pll[ACPU_PLL_2].l_val_mask;
816 cpu_relax();
817 udelay(50);
818 } while (pll2_l == 0);
819
820 pr_info("L val: PLL0: %d, PLL1: %d, PLL2: %d\n",
821 (int)pll0_l, (int)pll1_l, (int)pll2_l);
822
823 if (!cpu_is_msm7x27() && !cpu_is_msm7x25a()) {
824 do {
825 pll4_l = readl_relaxed(PLL4_L_VAL) &
826 soc_pll[ACPU_PLL_4].l_val_mask;
827 cpu_relax();
828 udelay(50);
829 } while (pll4_l == 0);
830 pr_info("L val: PLL4: %d\n", (int)pll4_l);
831 } else {
832 pll4_l = 0;
833 }
834
835 /* Some configurations run PLL0 twice as fast. Instead of having
836 * separate tables for this case, we simply fix up the ACPU clock
837 * source divider since it's a simple fix up.
838 */
839 if (pll0_l == PLL_491_MHZ) {
840 pll0_l = PLL_245_MHZ;
841 pll0_needs_fixup = 1;
842 }
843
844 /* Select the right table to use. */
845 for (lst = acpu_freq_tbl_list; lst->tbl != 0; lst++) {
846 if (lst->pll0_l == pll0_l && lst->pll1_l == pll1_l
847 && lst->pll2_l == pll2_l
848 && lst->pll4_l == pll4_l) {
849 acpu_freq_tbl = lst->tbl;
850 break;
851 }
852 }
853
854 if (acpu_freq_tbl == NULL) {
855 pr_crit("Unknown PLL configuration!\n");
856 BUG();
857 }
858
859 /* Fix up PLL0 source divider if necessary. Also, fix up the AXI to
860 * the max that's supported by the board (RAM used in board).
861 */
862 axi_160mhz = (pll0_l == PLL_960_MHZ || pll1_l == PLL_960_MHZ);
863 axi_200mhz = (pll2_l == PLL_1200_MHZ || pll2_l == PLL_800_MHZ);
864 for (t = &acpu_freq_tbl[0]; t->a11clk_khz != 0; t++) {
865
866 if (pll0_needs_fixup && t->pll == ACPU_PLL_0)
867 SLOWER_BY(t->a11clk_src_div, 2);
868 if (axi_160mhz && drv_state.max_axi_khz >= 160000
869 && t->ahbclk_khz > 128000)
870 t->axiclk_khz = 160000;
871 if (axi_200mhz && drv_state.max_axi_khz >= 200000
872 && t->ahbclk_khz > 160000)
873 t->axiclk_khz = 200000;
874 }
875
876 t--;
877 drv_state.max_axi_khz = t->axiclk_khz;
878
879 /* The default 7x27 ACPU clock plan supports running the AXI bus at
880 * 200 MHz. So we don't classify it as Turbo mode.
881 */
882 if (cpu_is_msm7x27())
883 return;
884
885 if (!axi_160mhz)
886 pr_info("Turbo mode not supported.\n");
887 else if (t->axiclk_khz == 160000)
888 pr_info("Turbo mode supported and enabled.\n");
889 else
890 pr_info("Turbo mode supported but not enabled.\n");
891}
892
893/*
894 * Hardware requires the CPU to be dropped to less than MAX_WAIT_FOR_IRQ_KHZ
895 * before entering a wait for irq low-power mode. Find a suitable rate.
896 */
897static unsigned long __init find_wait_for_irq_khz(void)
898{
899 unsigned long found_khz = 0;
900 int i;
901
902 for (i = 0; acpu_freq_tbl[i].a11clk_khz &&
903 acpu_freq_tbl[i].a11clk_khz <= MAX_WAIT_FOR_IRQ_KHZ; i++)
904 found_khz = acpu_freq_tbl[i].a11clk_khz;
905
906 return found_khz;
907}
908
909/* Initalize the lpj field in the acpu_freq_tbl. */
910static void __init lpj_init(void)
911{
912 int i;
913 const struct clkctl_acpu_speed *base_clk = drv_state.current_speed;
914 for (i = 0; acpu_freq_tbl[i].a11clk_khz; i++) {
915 acpu_freq_tbl[i].lpj = cpufreq_scale(loops_per_jiffy,
916 base_clk->a11clk_khz,
917 acpu_freq_tbl[i].a11clk_khz);
918 }
919}
920
921static void __init precompute_stepping(void)
922{
923 int i, step_idx;
924
925#define cur_freq acpu_freq_tbl[i].a11clk_khz
926#define step_freq acpu_freq_tbl[step_idx].a11clk_khz
927#define cur_pll acpu_freq_tbl[i].pll
928#define step_pll acpu_freq_tbl[step_idx].pll
929
930 for (i = 0; acpu_freq_tbl[i].a11clk_khz; i++) {
931
932 /* Calculate max "up" step for each destination PLL */
933 step_idx = i + 1;
934 while (step_freq && (step_freq - cur_freq)
935 <= drv_state.max_speed_delta_khz) {
936 acpu_freq_tbl[i].up[step_pll] =
937 &acpu_freq_tbl[step_idx];
938 step_idx++;
939 }
940 if (step_idx == (i + 1) && step_freq) {
941 pr_crit("Delta between freqs %u KHz and %u KHz is"
942 " too high!\n", cur_freq, step_freq);
943 BUG();
944 }
945
946 /* Calculate max "down" step for each destination PLL */
947 step_idx = i - 1;
948 while (step_idx >= 0 && (cur_freq - step_freq)
949 <= drv_state.max_speed_delta_khz) {
950 acpu_freq_tbl[i].down[step_pll] =
951 &acpu_freq_tbl[step_idx];
952 step_idx--;
953 }
954 if (step_idx == (i - 1) && i > 0) {
955 pr_crit("Delta between freqs %u KHz and %u KHz is"
956 " too high!\n", cur_freq, step_freq);
957 BUG();
958 }
959 }
960}
961
962static void __init print_acpu_freq_tbl(void)
963{
964 struct clkctl_acpu_speed *t;
965 short down_idx[ACPU_PLL_END];
966 short up_idx[ACPU_PLL_END];
967 int i, j;
968
969#define FREQ_IDX(freq_ptr) (freq_ptr - acpu_freq_tbl)
970 pr_info("Id CPU-KHz PLL DIV AHB-KHz ADIV AXI-KHz "
971 "D0 D1 D2 D4 U0 U1 U2 U4\n");
972
973 t = &acpu_freq_tbl[0];
974 for (i = 0; t->a11clk_khz != 0; i++) {
975
976 for (j = 0; j < ACPU_PLL_END; j++) {
977 down_idx[j] = t->down[j] ? FREQ_IDX(t->down[j]) : -1;
978 up_idx[j] = t->up[j] ? FREQ_IDX(t->up[j]) : -1;
979 }
980
981 pr_info("%2d %7d %3d %3d %7d %4d %7d "
982 "%2d %2d %2d %2d %2d %2d %2d %2d\n",
983 i, t->a11clk_khz, t->pll, t->a11clk_src_div + 1,
984 t->ahbclk_khz, t->ahbclk_div + 1, t->axiclk_khz,
985 down_idx[0], down_idx[1], down_idx[2], down_idx[4],
986 up_idx[0], up_idx[1], up_idx[2], up_idx[4]);
987
988 t++;
989 }
990}
991
992static void msm7x25_acpu_pll_hw_bug_fix(void)
993{
994 unsigned int n;
995
996 /* The 7625 has a hardware bug and in order to select PLL2 we
997 * must program PLL3. Use the same table, and just fix up the
998 * numbers on this target. */
999 for (n = 0; acpu_freq_tbl[n].a11clk_khz != 0; n++)
1000 if (acpu_freq_tbl[n].pll == ACPU_PLL_2)
1001 acpu_freq_tbl[n].a11clk_src_sel = 3;
1002}
1003
1004static void shared_pll_control_init(void)
1005{
1006#define PLL_REMOTE_SPINLOCK_ID "S:7"
1007 unsigned smem_size;
1008 remote_spin_lock_init(&pll_lock, PLL_REMOTE_SPINLOCK_ID);
1009 pll_control = smem_get_entry(SMEM_CLKREGIM_SOURCES, &smem_size);
1010
1011 if (!pll_control)
1012 pr_warning("Can't find shared PLL control data structure!\n");
1013 /* There might be more PLLs than what the application processor knows
1014 * about. But the index used for each PLL is guaranteed to remain the
1015 * same. */
1016 else if (smem_size < sizeof(struct shared_pll_control))
1017 pr_warning("Shared PLL control data structure too small!\n");
1018 else if (pll_control->version != 0xCCEE0001)
1019 pr_warning("Shared PLL control version mismatch!\n");
1020 else {
1021 pr_info("Shared PLL control available.\n");
1022 return;
1023 }
1024
1025 pll_control = NULL;
1026 pr_warning("Falling back to proc_comm PLL control.\n");
1027}
1028
1029void __init msm_acpu_clock_init(struct msm_acpu_clock_platform_data *clkdata)
1030{
1031 pr_info("acpu_clock_init()\n");
1032
1033 drv_state.ebi1_clk = clk_get(NULL, "ebi1_acpu_clk");
1034 BUG_ON(IS_ERR(drv_state.ebi1_clk));
1035
1036 mutex_init(&drv_state.lock);
1037 shared_pll_control_init();
1038 drv_state.acpu_switch_time_us = clkdata->acpu_switch_time_us;
1039 drv_state.max_speed_delta_khz = clkdata->max_speed_delta_khz;
1040 drv_state.vdd_switch_time_us = clkdata->vdd_switch_time_us;
1041 drv_state.max_axi_khz = clkdata->max_axi_khz;
1042 acpu_freq_tbl_fixup();
1043 drv_state.wait_for_irq_khz = find_wait_for_irq_khz();
1044 precompute_stepping();
1045 if (cpu_is_msm7x25())
1046 msm7x25_acpu_pll_hw_bug_fix();
1047 acpuclk_init();
1048 lpj_init();
1049 print_acpu_freq_tbl();
1050#ifdef CONFIG_CPU_FREQ_MSM
1051 cpufreq_table_init();
1052 cpufreq_frequency_table_get_attr(freq_table, smp_processor_id());
1053#endif
1054}