blob: 4e4fabd4a63f5ed462a3ffc850c41a07db399202 [file] [log] [blame]
Matt Wagantallf5cc3892012-06-07 19:47:02 -07001/*
2 * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
3 *
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
Matt Wagantall1f3762d2012-06-08 19:08:48 -070024static struct hfpll_data hfpll_data __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -070025 .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,
Matt Wagantall87465f52012-07-23 22:03:06 -070034 .low_vdd_l_max = 22,
35 .nom_vdd_l_max = 42,
36 .vdd[HFPLL_VDD_NONE] = 0,
37 .vdd[HFPLL_VDD_LOW] = 945000,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070038 .vdd[HFPLL_VDD_NOM] = 1050000,
Matt Wagantall87465f52012-07-23 22:03:06 -070039 .vdd[HFPLL_VDD_HIGH] = 1150000,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070040};
41
Matt Wagantall1f3762d2012-06-08 19:08:48 -070042static struct scalable scalable[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -070043 [CPU0] = {
44 .hfpll_phys_base = 0x00903200,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070045 .aux_clk_sel_phys = 0x02088014,
46 .aux_clk_sel = 3,
47 .l2cpmr_iaddr = 0x4501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070048 .vreg[VREG_CORE] = { "krait0", 1300000 },
Matt Wagantallf5cc3892012-06-07 19:47:02 -070049 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
50 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
51 .vreg[VREG_HFPLL_A] = { "krait0_hfpll", 1800000 },
52 },
53 [CPU1] = {
54 .hfpll_phys_base = 0x00903240,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070055 .aux_clk_sel_phys = 0x02098014,
56 .aux_clk_sel = 3,
57 .l2cpmr_iaddr = 0x5501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070058 .vreg[VREG_CORE] = { "krait1", 1300000 },
Matt Wagantallf5cc3892012-06-07 19:47:02 -070059 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
60 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
61 .vreg[VREG_HFPLL_A] = { "krait1_hfpll", 1800000 },
62 },
63 [CPU2] = {
64 .hfpll_phys_base = 0x00903280,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070065 .aux_clk_sel_phys = 0x020A8014,
66 .aux_clk_sel = 3,
67 .l2cpmr_iaddr = 0x6501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070068 .vreg[VREG_CORE] = { "krait2", 1300000 },
Matt Wagantallf5cc3892012-06-07 19:47:02 -070069 .vreg[VREG_MEM] = { "krait2_mem", 1150000 },
70 .vreg[VREG_DIG] = { "krait2_dig", 1150000 },
71 .vreg[VREG_HFPLL_A] = { "krait2_hfpll", 1800000 },
72 },
73 [CPU3] = {
74 .hfpll_phys_base = 0x009032C0,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070075 .aux_clk_sel_phys = 0x020B8014,
76 .aux_clk_sel = 3,
77 .l2cpmr_iaddr = 0x7501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070078 .vreg[VREG_CORE] = { "krait3", 1300000 },
Matt Wagantallf5cc3892012-06-07 19:47:02 -070079 .vreg[VREG_MEM] = { "krait3_mem", 1150000 },
80 .vreg[VREG_DIG] = { "krait3_dig", 1150000 },
81 .vreg[VREG_HFPLL_A] = { "krait3_hfpll", 1800000 },
82 },
83 [L2] = {
84 .hfpll_phys_base = 0x00903300,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070085 .aux_clk_sel_phys = 0x02011028,
86 .aux_clk_sel = 3,
87 .l2cpmr_iaddr = 0x0500,
88 .vreg[VREG_HFPLL_A] = { "l2_hfpll", 1800000 },
89 },
90};
91
Matt Wagantall1f3762d2012-06-08 19:08:48 -070092static struct msm_bus_paths bw_level_tbl[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -070093 [0] = BW_MBPS(640), /* At least 80 MHz on bus. */
94 [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */
95 [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */
96 [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */
97 [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */
98 [5] = BW_MBPS(4264), /* At least 533 MHz on bus. */
99};
100
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700101static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700102 .usecase = bw_level_tbl,
103 .num_usecases = ARRAY_SIZE(bw_level_tbl),
104 .active_only = 1,
105 .name = "acpuclk-8064",
106};
107
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700108static struct l2_level l2_freq_tbl[] __initdata __initdata = {
Tianyi Gou7122a2f2012-10-03 18:31:28 -0700109 [0] = { { 384000, PLL_8, 0, 2, 0x00 }, 950000, 1050000, 1 },
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700110 [1] = { { 432000, HFPLL, 2, 0, 0x20 }, 1050000, 1050000, 2 },
111 [2] = { { 486000, HFPLL, 2, 0, 0x24 }, 1050000, 1050000, 2 },
112 [3] = { { 540000, HFPLL, 2, 0, 0x28 }, 1050000, 1050000, 2 },
113 [4] = { { 594000, HFPLL, 1, 0, 0x16 }, 1050000, 1050000, 2 },
114 [5] = { { 648000, HFPLL, 1, 0, 0x18 }, 1050000, 1050000, 4 },
115 [6] = { { 702000, HFPLL, 1, 0, 0x1A }, 1050000, 1050000, 4 },
116 [7] = { { 756000, HFPLL, 1, 0, 0x1C }, 1150000, 1150000, 4 },
117 [8] = { { 810000, HFPLL, 1, 0, 0x1E }, 1150000, 1150000, 4 },
118 [9] = { { 864000, HFPLL, 1, 0, 0x20 }, 1150000, 1150000, 4 },
119 [10] = { { 918000, HFPLL, 1, 0, 0x22 }, 1150000, 1150000, 5 },
120 [11] = { { 972000, HFPLL, 1, 0, 0x24 }, 1150000, 1150000, 5 },
121 [12] = { { 1026000, HFPLL, 1, 0, 0x26 }, 1150000, 1150000, 5 },
122 [13] = { { 1080000, HFPLL, 1, 0, 0x28 }, 1150000, 1150000, 5 },
123 [14] = { { 1134000, HFPLL, 1, 0, 0x2A }, 1150000, 1150000, 5 },
Tianyi Gou729cb2a2012-08-03 11:06:18 -0700124 [15] = { { 1188000, HFPLL, 1, 0, 0x2C }, 1150000, 1150000, 5 },
Stephen Boyd2b73ee02012-09-11 21:08:13 -0700125 { }
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700126};
127
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700128static struct acpu_level acpu_freq_tbl_slow[] __initdata = {
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700129 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(0), 950000 },
130 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(6), 975000 },
131 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(6), 975000 },
132 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(6), 1000000 },
133 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(6), 1000000 },
134 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(6), 1025000 },
135 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(6), 1025000 },
136 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(6), 1075000 },
137 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(6), 1075000 },
138 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(6), 1100000 },
139 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(6), 1100000 },
140 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(6), 1125000 },
141 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(6), 1125000 },
Tianyi Gou729cb2a2012-08-03 11:06:18 -0700142 { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(15), 1175000 },
143 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(15), 1175000 },
144 { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(15), 1200000 },
145 { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(15), 1200000 },
146 { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(15), 1225000 },
147 { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(15), 1225000 },
148 { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(15), 1237500 },
149 { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(15), 1237500 },
150 { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(15), 1250000 },
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700151 { 0, { 0 } }
152};
153
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700154static struct acpu_level acpu_freq_tbl_nom[] __initdata = {
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700155 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(0), 900000 },
156 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(6), 925000 },
157 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(6), 925000 },
158 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(6), 950000 },
159 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(6), 950000 },
160 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(6), 975000 },
161 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(6), 975000 },
162 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(6), 1025000 },
163 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(6), 1025000 },
164 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(6), 1050000 },
165 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(6), 1050000 },
166 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(6), 1075000 },
167 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(6), 1075000 },
Tianyi Gou729cb2a2012-08-03 11:06:18 -0700168 { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(15), 1125000 },
169 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(15), 1125000 },
170 { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(15), 1150000 },
171 { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(15), 1150000 },
172 { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(15), 1175000 },
173 { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(15), 1175000 },
174 { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(15), 1187500 },
175 { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(15), 1187500 },
176 { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(15), 1200000 },
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700177 { 0, { 0 } }
178};
179
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700180static struct acpu_level acpu_freq_tbl_fast[] __initdata = {
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700181 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(0), 850000 },
182 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(6), 875000 },
183 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(6), 875000 },
184 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(6), 900000 },
185 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(6), 900000 },
186 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(6), 925000 },
187 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(6), 925000 },
188 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(6), 975000 },
189 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(6), 975000 },
190 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(6), 1000000 },
191 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(6), 1000000 },
192 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(6), 1025000 },
193 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(6), 1025000 },
Tianyi Gou729cb2a2012-08-03 11:06:18 -0700194 { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(15), 1075000 },
195 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(15), 1075000 },
196 { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(15), 1100000 },
197 { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(15), 1100000 },
198 { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(15), 1125000 },
199 { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(15), 1125000 },
200 { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(15), 1137500 },
201 { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(15), 1137500 },
202 { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(15), 1150000 },
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700203 { 0, { 0 } }
204};
205
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700206static struct pvs_table pvs_tables[NUM_PVS] __initdata = {
Matt Wagantall9515bc22012-07-19 18:13:40 -0700207[PVS_SLOW] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow), 0 },
208[PVS_NOMINAL] = { acpu_freq_tbl_nom, sizeof(acpu_freq_tbl_nom), 25000 },
209[PVS_FAST] = { acpu_freq_tbl_fast, sizeof(acpu_freq_tbl_fast), 25000 },
210/* TODO: update the faster table when data is available */
211[PVS_FASTER] = { acpu_freq_tbl_fast, sizeof(acpu_freq_tbl_fast), 25000 },
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700212};
213
214static struct acpuclk_krait_params acpuclk_8064_params __initdata = {
215 .scalable = scalable,
216 .scalable_size = sizeof(scalable),
217 .hfpll_data = &hfpll_data,
218 .pvs_tables = pvs_tables,
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700219 .l2_freq_tbl = l2_freq_tbl,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700220 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
221 .bus_scale = &bus_scale_data,
Matt Wagantall519e94f2012-09-17 17:51:06 -0700222 .pte_efuse_phys = 0x007000C0,
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700223 .stby_khz = 384000,
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700224};
225
226static int __init acpuclk_8064_probe(struct platform_device *pdev)
227{
228 return acpuclk_krait_init(&pdev->dev, &acpuclk_8064_params);
229}
230
231static struct platform_driver acpuclk_8064_driver = {
232 .driver = {
233 .name = "acpuclk-8064",
234 .owner = THIS_MODULE,
235 },
236};
237
238static int __init acpuclk_8064_init(void)
239{
240 return platform_driver_probe(&acpuclk_8064_driver,
241 acpuclk_8064_probe);
242}
243device_initcall(acpuclk_8064_init);