blob: 38658a221bd41c4ff7e775a58dd6b474396f47c9 [file] [log] [blame]
Patrick Daly6578e0c2012-07-19 18:50:02 -07001/*
Matt Wagantallf9a4d322013-01-14 18:01:24 -08002 * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Patrick Daly6578e0c2012-07-19 18:50:02 -07003 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <mach/rpm-regulator.h>
18#include <mach/msm_bus_board.h>
19#include <mach/msm_bus.h>
20
21#include "acpuclock.h"
22#include "acpuclock-krait.h"
23
24static struct hfpll_data hfpll_data __initdata = {
25 .mode_offset = 0x00,
26 .l_offset = 0x08,
27 .m_offset = 0x0C,
28 .n_offset = 0x10,
29 .config_offset = 0x04,
30 .config_val = 0x7845C665,
31 .has_droop_ctl = true,
32 .droop_offset = 0x14,
33 .droop_val = 0x0108C000,
34 .low_vdd_l_max = 37,
35 .nom_vdd_l_max = 74,
36 .vdd[HFPLL_VDD_NONE] = 0,
37 .vdd[HFPLL_VDD_LOW] = 945000,
38 .vdd[HFPLL_VDD_NOM] = 1050000,
39 .vdd[HFPLL_VDD_HIGH] = 1150000,
40};
41
42static struct scalable scalable[] __initdata = {
43 [CPU0] = {
44 .hfpll_phys_base = 0x00903200,
45 .aux_clk_sel_phys = 0x02088014,
46 .aux_clk_sel = 3,
Matt Wagantall6cd5d752012-09-27 19:56:57 -070047 .sec_clk_sel = 2,
Patrick Daly6578e0c2012-07-19 18:50:02 -070048 .l2cpmr_iaddr = 0x4501,
49 .vreg[VREG_CORE] = { "krait0", 1300000 },
50 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
51 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
52 .vreg[VREG_HFPLL_A] = { "krait0_s8", 2050000 },
53 .vreg[VREG_HFPLL_B] = { "krait0_l23", 1800000 },
54 },
55 [CPU1] = {
56 .hfpll_phys_base = 0x00903300,
57 .aux_clk_sel_phys = 0x02098014,
58 .aux_clk_sel = 3,
Matt Wagantall6cd5d752012-09-27 19:56:57 -070059 .sec_clk_sel = 2,
Patrick Daly6578e0c2012-07-19 18:50:02 -070060 .l2cpmr_iaddr = 0x5501,
61 .vreg[VREG_CORE] = { "krait1", 1300000 },
62 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
63 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
64 .vreg[VREG_HFPLL_A] = { "krait1_s8", 2050000 },
65 .vreg[VREG_HFPLL_B] = { "krait1_l23", 1800000 },
66 },
67 [L2] = {
68 .hfpll_phys_base = 0x00903400,
69 .aux_clk_sel_phys = 0x02011028,
70 .aux_clk_sel = 3,
Matt Wagantall6cd5d752012-09-27 19:56:57 -070071 .sec_clk_sel = 2,
Patrick Daly6578e0c2012-07-19 18:50:02 -070072 .l2cpmr_iaddr = 0x0500,
73 .vreg[VREG_HFPLL_A] = { "l2_s8", 2050000 },
74 .vreg[VREG_HFPLL_B] = { "l2_l23", 1800000 },
75 },
76};
77
78static struct msm_bus_paths bw_level_tbl[] __initdata = {
79 [0] = BW_MBPS(640), /* At least 80 MHz on bus. */
80 [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */
81 [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */
82 [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */
83 [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */
84 [5] = BW_MBPS(4264), /* At least 533 MHz on bus. */
85};
86
87static struct msm_bus_scale_pdata bus_scale_data __initdata = {
88 .usecase = bw_level_tbl,
89 .num_usecases = ARRAY_SIZE(bw_level_tbl),
90 .active_only = 1,
91 .name = "acpuclk-8960ab",
92};
93
94static struct l2_level l2_freq_tbl[] __initdata = {
Matt Wagantall6cd5d752012-09-27 19:56:57 -070095 [0] = { { 384000, PLL_8, 0, 0x00 }, 1050000, 1050000, 1 },
96 [1] = { { 486000, HFPLL, 2, 0x24 }, 1050000, 1050000, 2 },
97 [2] = { { 594000, HFPLL, 1, 0x16 }, 1050000, 1050000, 2 },
98 [3] = { { 702000, HFPLL, 1, 0x1A }, 1050000, 1050000, 4 },
99 [4] = { { 810000, HFPLL, 1, 0x1E }, 1050000, 1050000, 4 },
100 [5] = { { 918000, HFPLL, 1, 0x22 }, 1150000, 1150000, 5 },
101 [6] = { { 1026000, HFPLL, 1, 0x26 }, 1150000, 1150000, 5 },
102 [7] = { { 1134000, HFPLL, 1, 0x2A }, 1150000, 1150000, 5 },
103 [8] = { { 1242000, HFPLL, 1, 0x2E }, 1150000, 1150000, 5 },
104 [9] = { { 1350000, HFPLL, 1, 0x32 }, 1150000, 1150000, 5 },
Stephen Boyd791bca92012-09-11 21:08:13 -0700105 { }
Patrick Daly6578e0c2012-07-19 18:50:02 -0700106};
107
Patrick Daly2352b352012-11-06 16:40:54 -0800108#define AVS(x) .avsdscr_setting = (x)
109
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700110static struct acpu_level freq_tbl_PVS0[] __initdata = {
Patrick Daly2352b352012-11-06 16:40:54 -0800111 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 950000, AVS(0x70001F) },
112 { 1, { 486000, HFPLL, 2, 0x24 }, L2(3), 950000, AVS(0x0) },
113 { 1, { 594000, HFPLL, 1, 0x16 }, L2(3), 975000, AVS(0x0) },
114 { 1, { 702000, HFPLL, 1, 0x1A }, L2(3), 1000000, AVS(0x0) },
115 { 1, { 810000, HFPLL, 1, 0x1E }, L2(3), 1025000, AVS(0x0) },
116 { 1, { 918000, HFPLL, 1, 0x22 }, L2(3), 1050000, AVS(0x0) },
117 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(3), 1075000, AVS(0x0) },
118 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(9), 1100000, AVS(0x70000D) },
119 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(9), 1125000, AVS(0x0) },
120 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(9), 1150000, AVS(0x0) },
121 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(9), 1175000, AVS(0x0) },
122 { 1, { 1566000, HFPLL, 1, 0x3A }, L2(9), 1200000, AVS(0x0) },
123 { 1, { 1674000, HFPLL, 1, 0x3E }, L2(9), 1225000, AVS(0x0) },
124 { 1, { 1728000, HFPLL, 1, 0x40 }, L2(9), 1250000, AVS(0x70000B) },
Patrick Daly6578e0c2012-07-19 18:50:02 -0700125 { 0, { 0 } }
126};
127
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700128static struct acpu_level freq_tbl_PVS1[] __initdata = {
Patrick Daly2352b352012-11-06 16:40:54 -0800129 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 925000, AVS(0x70001F) },
130 { 1, { 486000, HFPLL, 2, 0x24 }, L2(3), 925000, AVS(0x0) },
131 { 1, { 594000, HFPLL, 1, 0x16 }, L2(3), 950000, AVS(0x0) },
132 { 1, { 702000, HFPLL, 1, 0x1A }, L2(3), 975000, AVS(0x0) },
133 { 1, { 810000, HFPLL, 1, 0x1E }, L2(3), 1000000, AVS(0x0) },
134 { 1, { 918000, HFPLL, 1, 0x22 }, L2(3), 1025000, AVS(0x0) },
135 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(3), 1050000, AVS(0x0) },
136 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(9), 1075000, AVS(0x70000D) },
137 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(9), 1100000, AVS(0x0) },
138 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(9), 1125000, AVS(0x0) },
139 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(9), 1150000, AVS(0x0) },
140 { 1, { 1566000, HFPLL, 1, 0x3A }, L2(9), 1175000, AVS(0x0) },
141 { 1, { 1674000, HFPLL, 1, 0x3E }, L2(9), 1200000, AVS(0x0) },
142 { 1, { 1728000, HFPLL, 1, 0x40 }, L2(9), 1225000, AVS(0x70000B) },
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700143 { 0, { 0 } }
144};
145
146static struct acpu_level freq_tbl_PVS2[] __initdata = {
Patrick Daly2352b352012-11-06 16:40:54 -0800147 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 900000, AVS(0x70001F) },
148 { 1, { 486000, HFPLL, 2, 0x24 }, L2(3), 900000, AVS(0x0) },
149 { 1, { 594000, HFPLL, 1, 0x16 }, L2(3), 925000, AVS(0x0) },
150 { 1, { 702000, HFPLL, 1, 0x1A }, L2(3), 950000, AVS(0x0) },
151 { 1, { 810000, HFPLL, 1, 0x1E }, L2(3), 975000, AVS(0x0) },
152 { 1, { 918000, HFPLL, 1, 0x22 }, L2(3), 1000000, AVS(0x0) },
153 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(3), 1025000, AVS(0x0) },
154 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(9), 1050000, AVS(0x70000D) },
155 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(9), 1075000, AVS(0x0) },
156 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(9), 1100000, AVS(0x0) },
157 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(9), 1125000, AVS(0x0) },
158 { 1, { 1566000, HFPLL, 1, 0x3A }, L2(9), 1150000, AVS(0x0) },
159 { 1, { 1674000, HFPLL, 1, 0x3E }, L2(9), 1175000, AVS(0x0) },
160 { 1, { 1728000, HFPLL, 1, 0x40 }, L2(9), 1200000, AVS(0x70000B) },
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700161 { 0, { 0 } }
162};
163
164static struct acpu_level freq_tbl_PVS3[] __initdata = {
Patrick Daly2352b352012-11-06 16:40:54 -0800165 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 900000, AVS(0x70001F) },
166 { 1, { 486000, HFPLL, 2, 0x24 }, L2(3), 900000, AVS(0x0) },
167 { 1, { 594000, HFPLL, 1, 0x16 }, L2(3), 900000, AVS(0x0) },
168 { 1, { 702000, HFPLL, 1, 0x1A }, L2(3), 925000, AVS(0x0) },
169 { 1, { 810000, HFPLL, 1, 0x1E }, L2(3), 950000, AVS(0x0) },
170 { 1, { 918000, HFPLL, 1, 0x22 }, L2(3), 975000, AVS(0x0) },
171 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(3), 1000000, AVS(0x0) },
172 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(9), 1025000, AVS(0x70000D) },
173 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(9), 1050000, AVS(0x0) },
174 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(9), 1075000, AVS(0x0) },
175 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(9), 1100000, AVS(0x0) },
176 { 1, { 1566000, HFPLL, 1, 0x3A }, L2(9), 1125000, AVS(0x0) },
177 { 1, { 1674000, HFPLL, 1, 0x3E }, L2(9), 1150000, AVS(0x0) },
178 { 1, { 1728000, HFPLL, 1, 0x40 }, L2(9), 1175000, AVS(0x70000B) },
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700179 { 0, { 0 } }
180};
181
182static struct acpu_level freq_tbl_PVS4[] __initdata = {
Patrick Daly2352b352012-11-06 16:40:54 -0800183 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 875000, AVS(0x70001F) },
184 { 1, { 486000, HFPLL, 2, 0x24 }, L2(3), 875000, AVS(0x0) },
185 { 1, { 594000, HFPLL, 1, 0x16 }, L2(3), 875000, AVS(0x0) },
186 { 1, { 702000, HFPLL, 1, 0x1A }, L2(3), 900000, AVS(0x0) },
187 { 1, { 810000, HFPLL, 1, 0x1E }, L2(3), 925000, AVS(0x0) },
188 { 1, { 918000, HFPLL, 1, 0x22 }, L2(3), 950000, AVS(0x0) },
189 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(3), 975000, AVS(0x0) },
190 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(9), 1000000, AVS(0x70000D) },
191 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(9), 1025000, AVS(0x0) },
192 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(9), 1050000, AVS(0x0) },
193 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(9), 1075000, AVS(0x0) },
194 { 1, { 1566000, HFPLL, 1, 0x3A }, L2(9), 1100000, AVS(0x0) },
195 { 1, { 1674000, HFPLL, 1, 0x3E }, L2(9), 1125000, AVS(0x0) },
196 { 1, { 1728000, HFPLL, 1, 0x40 }, L2(9), 1150000, AVS(0x70000B) },
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700197 { 0, { 0 } }
198};
199
200static struct acpu_level freq_tbl_PVS5[] __initdata = {
Patrick Daly2352b352012-11-06 16:40:54 -0800201 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 875000, AVS(0x70001F) },
202 { 1, { 486000, HFPLL, 2, 0x24 }, L2(3), 875000, AVS(0x0) },
203 { 1, { 594000, HFPLL, 1, 0x16 }, L2(3), 875000, AVS(0x0) },
204 { 1, { 702000, HFPLL, 1, 0x1A }, L2(3), 875000, AVS(0x0) },
205 { 1, { 810000, HFPLL, 1, 0x1E }, L2(3), 900000, AVS(0x0) },
206 { 1, { 918000, HFPLL, 1, 0x22 }, L2(3), 925000, AVS(0x0) },
207 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(3), 950000, AVS(0x0) },
208 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(9), 975000, AVS(0x70000D) },
209 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(9), 1000000, AVS(0x0) },
210 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(9), 1025000, AVS(0x0) },
211 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(9), 1050000, AVS(0x0) },
212 { 1, { 1566000, HFPLL, 1, 0x3A }, L2(9), 1075000, AVS(0x0) },
213 { 1, { 1674000, HFPLL, 1, 0x3E }, L2(9), 1100000, AVS(0x0) },
214 { 1, { 1728000, HFPLL, 1, 0x40 }, L2(9), 1125000, AVS(0x70000B) },
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700215 { 0, { 0 } }
216};
217
218static struct acpu_level freq_tbl_PVS6[] __initdata = {
Patrick Daly2352b352012-11-06 16:40:54 -0800219 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 850000, AVS(0x70001F) },
220 { 1, { 486000, HFPLL, 2, 0x24 }, L2(3), 850000, AVS(0x0) },
221 { 1, { 594000, HFPLL, 1, 0x16 }, L2(3), 850000, AVS(0x0) },
222 { 1, { 702000, HFPLL, 1, 0x1A }, L2(3), 850000, AVS(0x0) },
223 { 1, { 810000, HFPLL, 1, 0x1E }, L2(3), 875000, AVS(0x0) },
224 { 1, { 918000, HFPLL, 1, 0x22 }, L2(3), 900000, AVS(0x0) },
225 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(3), 925000, AVS(0x0) },
226 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(9), 950000, AVS(0x70000D) },
227 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(9), 975000, AVS(0x0) },
228 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(9), 1000000, AVS(0x0) },
229 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(9), 1025000, AVS(0x0) },
230 { 1, { 1566000, HFPLL, 1, 0x3A }, L2(9), 1050000, AVS(0x0) },
231 { 1, { 1674000, HFPLL, 1, 0x3E }, L2(9), 1075000, AVS(0x0) },
232 { 1, { 1728000, HFPLL, 1, 0x40 }, L2(9), 1100000, AVS(0x70000B) },
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700233 { 0, { 0 } }
234};
235
Patrick Daly18d2d482012-08-24 14:22:06 -0700236static struct pvs_table pvs_tables[NUM_SPEED_BINS][NUM_PVS] __initdata = {
Patrick Daly5ef4ec32012-10-26 13:41:58 -0700237[0][0] = { freq_tbl_PVS0, sizeof(freq_tbl_PVS0), 0 },
Patrick Dalydec45872012-11-28 12:12:05 -0800238[0][1] = { freq_tbl_PVS1, sizeof(freq_tbl_PVS1), 25000 },
239[0][2] = { freq_tbl_PVS2, sizeof(freq_tbl_PVS2), 25000 },
240[0][3] = { freq_tbl_PVS3, sizeof(freq_tbl_PVS3), 25000 },
241[0][4] = { freq_tbl_PVS4, sizeof(freq_tbl_PVS4), 25000 },
242[0][5] = { freq_tbl_PVS5, sizeof(freq_tbl_PVS5), 25000 },
243[0][6] = { freq_tbl_PVS6, sizeof(freq_tbl_PVS6), 25000 },
Patrick Daly6578e0c2012-07-19 18:50:02 -0700244};
245
246static struct acpuclk_krait_params acpuclk_8960ab_params __initdata = {
247 .scalable = scalable,
248 .scalable_size = sizeof(scalable),
249 .hfpll_data = &hfpll_data,
250 .pvs_tables = pvs_tables,
251 .l2_freq_tbl = l2_freq_tbl,
252 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
253 .bus_scale = &bus_scale_data,
Matt Wagantallee2b4372012-09-17 17:51:06 -0700254 .pte_efuse_phys = 0x007000C0,
Matt Wagantallf9a4d322013-01-14 18:01:24 -0800255 .get_bin_info = get_krait_bin_format_a,
Patrick Daly05686c32012-08-22 14:23:28 -0700256 .stby_khz = 384000,
Patrick Daly6578e0c2012-07-19 18:50:02 -0700257};
258
259static int __init acpuclk_8960ab_probe(struct platform_device *pdev)
260{
261 return acpuclk_krait_init(&pdev->dev, &acpuclk_8960ab_params);
262}
263
264static struct platform_driver acpuclk_8960ab_driver = {
265 .driver = {
266 .name = "acpuclk-8960ab",
267 .owner = THIS_MODULE,
268 },
269};
270
271static int __init acpuclk_8960ab_init(void)
272{
273 return platform_driver_probe(&acpuclk_8960ab_driver,
274 acpuclk_8960ab_probe);
275}
276device_initcall(acpuclk_8960ab_init);