blob: d46d268d020443a0f35495b346a1b4ea7e0ff5fd [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,
34 .low_vdd_l_max = 40,
35 .vdd[HFPLL_VDD_NONE] = 0,
36 .vdd[HFPLL_VDD_LOW] = 945000,
37 .vdd[HFPLL_VDD_NOM] = 1050000,
38};
39
Matt Wagantall1f3762d2012-06-08 19:08:48 -070040static struct scalable scalable[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -070041 [CPU0] = {
42 .hfpll_phys_base = 0x00903200,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070043 .aux_clk_sel_phys = 0x02088014,
44 .aux_clk_sel = 3,
45 .l2cpmr_iaddr = 0x4501,
46 .vreg[VREG_CORE] = { "krait0", 1300000, 1740000 },
47 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
48 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
49 .vreg[VREG_HFPLL_A] = { "krait0_hfpll", 1800000 },
50 },
51 [CPU1] = {
52 .hfpll_phys_base = 0x00903240,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070053 .aux_clk_sel_phys = 0x02098014,
54 .aux_clk_sel = 3,
55 .l2cpmr_iaddr = 0x5501,
56 .vreg[VREG_CORE] = { "krait1", 1300000, 1740000 },
57 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
58 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
59 .vreg[VREG_HFPLL_A] = { "krait1_hfpll", 1800000 },
60 },
61 [CPU2] = {
62 .hfpll_phys_base = 0x00903280,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070063 .aux_clk_sel_phys = 0x020A8014,
64 .aux_clk_sel = 3,
65 .l2cpmr_iaddr = 0x6501,
66 .vreg[VREG_CORE] = { "krait2", 1300000, 1740000 },
67 .vreg[VREG_MEM] = { "krait2_mem", 1150000 },
68 .vreg[VREG_DIG] = { "krait2_dig", 1150000 },
69 .vreg[VREG_HFPLL_A] = { "krait2_hfpll", 1800000 },
70 },
71 [CPU3] = {
72 .hfpll_phys_base = 0x009032C0,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070073 .aux_clk_sel_phys = 0x020B8014,
74 .aux_clk_sel = 3,
75 .l2cpmr_iaddr = 0x7501,
76 .vreg[VREG_CORE] = { "krait3", 1300000, 1740000 },
77 .vreg[VREG_MEM] = { "krait3_mem", 1150000 },
78 .vreg[VREG_DIG] = { "krait3_dig", 1150000 },
79 .vreg[VREG_HFPLL_A] = { "krait3_hfpll", 1800000 },
80 },
81 [L2] = {
82 .hfpll_phys_base = 0x00903300,
Matt Wagantallf5cc3892012-06-07 19:47:02 -070083 .aux_clk_sel_phys = 0x02011028,
84 .aux_clk_sel = 3,
85 .l2cpmr_iaddr = 0x0500,
86 .vreg[VREG_HFPLL_A] = { "l2_hfpll", 1800000 },
87 },
88};
89
Matt Wagantall1f3762d2012-06-08 19:08:48 -070090static struct msm_bus_paths bw_level_tbl[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -070091 [0] = BW_MBPS(640), /* At least 80 MHz on bus. */
92 [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */
93 [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */
94 [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */
95 [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */
96 [5] = BW_MBPS(4264), /* At least 533 MHz on bus. */
97};
98
Matt Wagantall1f3762d2012-06-08 19:08:48 -070099static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700100 .usecase = bw_level_tbl,
101 .num_usecases = ARRAY_SIZE(bw_level_tbl),
102 .active_only = 1,
103 .name = "acpuclk-8064",
104};
105
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700106static struct l2_level l2_freq_tbl[] __initdata __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700107 [0] = { {STBY_KHZ, QSB, 0, 0, 0x00 }, 1050000, 1050000, 0 },
108 [1] = { { 384000, PLL_8, 0, 2, 0x00 }, 1050000, 1050000, 1 },
109 [2] = { { 432000, HFPLL, 2, 0, 0x20 }, 1050000, 1050000, 2 },
110 [3] = { { 486000, HFPLL, 2, 0, 0x24 }, 1050000, 1050000, 2 },
111 [4] = { { 540000, HFPLL, 2, 0, 0x28 }, 1050000, 1050000, 2 },
112 [5] = { { 594000, HFPLL, 1, 0, 0x16 }, 1050000, 1050000, 2 },
113 [6] = { { 648000, HFPLL, 1, 0, 0x18 }, 1050000, 1050000, 4 },
114 [7] = { { 702000, HFPLL, 1, 0, 0x1A }, 1050000, 1050000, 4 },
115 [8] = { { 756000, HFPLL, 1, 0, 0x1C }, 1150000, 1150000, 4 },
116 [9] = { { 810000, HFPLL, 1, 0, 0x1E }, 1150000, 1150000, 4 },
117 [10] = { { 864000, HFPLL, 1, 0, 0x20 }, 1150000, 1150000, 4 },
118 [11] = { { 918000, HFPLL, 1, 0, 0x22 }, 1150000, 1150000, 5 },
119 [12] = { { 972000, HFPLL, 1, 0, 0x24 }, 1150000, 1150000, 5 },
120 [13] = { { 1026000, HFPLL, 1, 0, 0x26 }, 1150000, 1150000, 5 },
121 [14] = { { 1080000, HFPLL, 1, 0, 0x28 }, 1150000, 1150000, 5 },
122 [15] = { { 1134000, HFPLL, 1, 0, 0x2A }, 1150000, 1150000, 5 },
123};
124
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700125static struct acpu_level acpu_freq_tbl_slow[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700126 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 950000 },
127 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 950000 },
128 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(7), 975000 },
129 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(7), 975000 },
130 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(7), 1000000 },
131 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(7), 1000000 },
132 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(7), 1025000 },
133 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(7), 1025000 },
134 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(7), 1075000 },
135 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(7), 1075000 },
136 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(7), 1100000 },
137 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(7), 1100000 },
138 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(7), 1125000 },
139 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(7), 1125000 },
140 { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(15), 1175000 },
141 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(15), 1175000 },
142 { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(15), 1200000 },
143 { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(15), 1200000 },
144 { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(15), 1225000 },
145 { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(15), 1225000 },
146 { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(15), 1237500 },
147 { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(15), 1237500 },
148 { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(15), 1250000 },
149 { 0, { 0 } }
150};
151
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700152static struct acpu_level acpu_freq_tbl_nom[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700153 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 900000 },
154 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 900000 },
155 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(7), 925000 },
156 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(7), 925000 },
157 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(7), 950000 },
158 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(7), 950000 },
159 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(7), 975000 },
160 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(7), 975000 },
161 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(7), 1025000 },
162 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(7), 1025000 },
163 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(7), 1050000 },
164 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(7), 1050000 },
165 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(7), 1075000 },
166 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(7), 1075000 },
167 { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(15), 1125000 },
168 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(15), 1125000 },
169 { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(15), 1150000 },
170 { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(15), 1150000 },
171 { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(15), 1175000 },
172 { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(15), 1175000 },
173 { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(15), 1187500 },
174 { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(15), 1187500 },
175 { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(15), 1200000 },
176 { 0, { 0 } }
177};
178
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700179static struct acpu_level acpu_freq_tbl_fast[] __initdata = {
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700180 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 850000 },
181 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 850000 },
182 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(7), 875000 },
183 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(7), 875000 },
184 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(7), 900000 },
185 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(7), 900000 },
186 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(7), 925000 },
187 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(7), 925000 },
188 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(7), 975000 },
189 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(7), 975000 },
190 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(7), 1000000 },
191 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(7), 1000000 },
192 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(7), 1025000 },
193 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(7), 1025000 },
194 { 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 },
203 { 0, { 0 } }
204};
205
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700206static struct pvs_table pvs_tables[NUM_PVS] __initdata = {
207 [PVS_SLOW] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow) },
208 [PVS_NOMINAL] = { acpu_freq_tbl_nom, sizeof(acpu_freq_tbl_nom) },
209 [PVS_FAST] = { acpu_freq_tbl_fast, sizeof(acpu_freq_tbl_fast) },
Matt Wagantallf5cc3892012-06-07 19:47:02 -0700210 /* TODO: update the faster table when data is available */
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700211 [PVS_FASTER] = { acpu_freq_tbl_fast, sizeof(acpu_freq_tbl_fast) },
212};
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 Wagantallf5cc3892012-06-07 19:47:02 -0700222 .qfprom_phys_base = 0x00700000,
223};
224
225static int __init acpuclk_8064_probe(struct platform_device *pdev)
226{
227 return acpuclk_krait_init(&pdev->dev, &acpuclk_8064_params);
228}
229
230static struct platform_driver acpuclk_8064_driver = {
231 .driver = {
232 .name = "acpuclk-8064",
233 .owner = THIS_MODULE,
234 },
235};
236
237static int __init acpuclk_8064_init(void)
238{
239 return platform_driver_probe(&acpuclk_8064_driver,
240 acpuclk_8064_probe);
241}
242device_initcall(acpuclk_8064_init);