blob: 782ee609aa78c6c4f701bfb665c925e8968df171 [file] [log] [blame]
Matt Wagantall6dcfa922012-06-07 20:13:51 -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
24/* Corner type vreg VDD values */
25#define LVL_NONE RPM_VREG_CORNER_NONE
26#define LVL_LOW RPM_VREG_CORNER_LOW
27#define LVL_NOM RPM_VREG_CORNER_NOMINAL
28#define LVL_HIGH RPM_VREG_CORNER_HIGH
29
Matt Wagantall1f3762d2012-06-08 19:08:48 -070030static struct hfpll_data hfpll_data __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -070031 .mode_offset = 0x00,
32 .l_offset = 0x08,
33 .m_offset = 0x0C,
34 .n_offset = 0x10,
35 .config_offset = 0x04,
36 .config_val = 0x7845C665,
37 .has_droop_ctl = true,
38 .droop_offset = 0x14,
39 .droop_val = 0x0108C000,
Matt Wagantall87465f52012-07-23 22:03:06 -070040 .low_vdd_l_max = 22,
41 .nom_vdd_l_max = 42,
Matt Wagantall6dcfa922012-06-07 20:13:51 -070042 .vdd[HFPLL_VDD_NONE] = LVL_NONE,
43 .vdd[HFPLL_VDD_LOW] = LVL_LOW,
44 .vdd[HFPLL_VDD_NOM] = LVL_NOM,
Matt Wagantall87465f52012-07-23 22:03:06 -070045 .vdd[HFPLL_VDD_HIGH] = LVL_HIGH,
Matt Wagantall6dcfa922012-06-07 20:13:51 -070046};
47
Patrick Daly037d4912012-08-28 13:36:31 -070048static struct scalable scalable_pm8917[] __initdata = {
49 [CPU0] = {
50 .hfpll_phys_base = 0x00903200,
51 .aux_clk_sel_phys = 0x02088014,
52 .aux_clk_sel = 3,
53 .l2cpmr_iaddr = 0x4501,
54 .vreg[VREG_CORE] = { "krait0", 1300000 },
55 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
56 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
57 .vreg[VREG_HFPLL_A] = { "krait0_s8", 2050000 },
58 .vreg[VREG_HFPLL_B] = { "krait0_l23", 1800000 },
59 },
60 [CPU1] = {
61 .hfpll_phys_base = 0x00903300,
62 .aux_clk_sel_phys = 0x02098014,
63 .aux_clk_sel = 3,
64 .l2cpmr_iaddr = 0x5501,
65 .vreg[VREG_CORE] = { "krait1", 1300000 },
66 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
67 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
68 .vreg[VREG_HFPLL_A] = { "krait1_s8", 2050000 },
69 .vreg[VREG_HFPLL_B] = { "krait1_l23", 1800000 },
70 },
71 [L2] = {
72 .hfpll_phys_base = 0x00903400,
73 .aux_clk_sel_phys = 0x02011028,
74 .aux_clk_sel = 3,
75 .l2cpmr_iaddr = 0x0500,
76 .vreg[VREG_HFPLL_A] = { "l2_s8", 2050000 },
77 .vreg[VREG_HFPLL_B] = { "l2_l23", 1800000 },
78 },
79};
80
Matt Wagantall1f3762d2012-06-08 19:08:48 -070081static struct scalable scalable[] __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -070082 [CPU0] = {
83 .hfpll_phys_base = 0x00903200,
Matt Wagantall6dcfa922012-06-07 20:13:51 -070084 .aux_clk_sel_phys = 0x02088014,
85 .aux_clk_sel = 3,
86 .l2cpmr_iaddr = 0x4501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070087 .vreg[VREG_CORE] = { "krait0", 1300000 },
Matt Wagantall6dcfa922012-06-07 20:13:51 -070088 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
89 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
90 .vreg[VREG_HFPLL_A] = { "krait0_hfpll", 1800000 },
91 },
92 [CPU1] = {
93 .hfpll_phys_base = 0x00903300,
Matt Wagantall6dcfa922012-06-07 20:13:51 -070094 .aux_clk_sel_phys = 0x02098014,
95 .aux_clk_sel = 3,
96 .l2cpmr_iaddr = 0x5501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070097 .vreg[VREG_CORE] = { "krait1", 1300000 },
Matt Wagantall6dcfa922012-06-07 20:13:51 -070098 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
99 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
100 .vreg[VREG_HFPLL_A] = { "krait1_hfpll", 1800000 },
101 },
102 [L2] = {
103 .hfpll_phys_base = 0x00903400,
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700104 .aux_clk_sel_phys = 0x02011028,
105 .aux_clk_sel = 3,
106 .l2cpmr_iaddr = 0x0500,
107 .vreg[VREG_HFPLL_A] = { "l2_hfpll", 1800000 },
108 },
109};
110
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700111static struct msm_bus_paths bw_level_tbl[] __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700112 [0] = BW_MBPS(640), /* At least 80 MHz on bus. */
113 [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */
114 [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */
115 [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */
116 [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */
117 [5] = BW_MBPS(3600), /* At least 450 MHz on bus. */
118 [6] = BW_MBPS(3936), /* At least 492 MHz on bus. */
119 [7] = BW_MBPS(4264), /* At least 533 MHz on bus. */
120};
121
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700122static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700123 .usecase = bw_level_tbl,
124 .num_usecases = ARRAY_SIZE(bw_level_tbl),
125 .active_only = 1,
126 .name = "acpuclk-8930",
127};
128
129/* TODO: Update vdd_dig, vdd_mem and bw when data is available. */
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700130static struct l2_level l2_freq_tbl[] __initdata = {
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700131 [0] = { { 384000, PLL_8, 0, 2, 0x00 }, LVL_NOM, 1050000, 1 },
132 [1] = { { 432000, HFPLL, 2, 0, 0x20 }, LVL_NOM, 1050000, 2 },
133 [2] = { { 486000, HFPLL, 2, 0, 0x24 }, LVL_NOM, 1050000, 2 },
134 [3] = { { 540000, HFPLL, 2, 0, 0x28 }, LVL_NOM, 1050000, 2 },
135 [4] = { { 594000, HFPLL, 1, 0, 0x16 }, LVL_NOM, 1050000, 2 },
136 [5] = { { 648000, HFPLL, 1, 0, 0x18 }, LVL_NOM, 1050000, 4 },
137 [6] = { { 702000, HFPLL, 1, 0, 0x1A }, LVL_NOM, 1050000, 4 },
138 [7] = { { 756000, HFPLL, 1, 0, 0x1C }, LVL_HIGH, 1150000, 4 },
139 [8] = { { 810000, HFPLL, 1, 0, 0x1E }, LVL_HIGH, 1150000, 4 },
140 [9] = { { 864000, HFPLL, 1, 0, 0x20 }, LVL_HIGH, 1150000, 4 },
141 [10] = { { 918000, HFPLL, 1, 0, 0x22 }, LVL_HIGH, 1150000, 7 },
142 [11] = { { 972000, HFPLL, 1, 0, 0x24 }, LVL_HIGH, 1150000, 7 },
143 [12] = { { 1026000, HFPLL, 1, 0, 0x26 }, LVL_HIGH, 1150000, 7 },
144 [13] = { { 1080000, HFPLL, 1, 0, 0x28 }, LVL_HIGH, 1150000, 7 },
145 [14] = { { 1134000, HFPLL, 1, 0, 0x2A }, LVL_HIGH, 1150000, 7 },
146 [15] = { { 1188000, HFPLL, 1, 0, 0x2C }, LVL_HIGH, 1150000, 7 },
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700147};
148
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700149static struct acpu_level acpu_freq_tbl_slow[] __initdata = {
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700150 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(0), 950000 },
151 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(5), 975000 },
152 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(5), 975000 },
153 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(5), 1000000 },
154 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(5), 1000000 },
155 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(5), 1025000 },
156 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(5), 1025000 },
157 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(10), 1075000 },
158 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(10), 1075000 },
159 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(10), 1100000 },
160 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(10), 1100000 },
161 { 1, { 972000, HFPLL, 1, 0, 0x24 }, L2(10), 1125000 },
162 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(10), 1125000 },
163 { 1, { 1080000, HFPLL, 1, 0, 0x28 }, L2(15), 1175000 },
164 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(15), 1175000 },
165 { 1, { 1188000, HFPLL, 1, 0, 0x2C }, L2(15), 1200000 },
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700166 { 0, { 0 } }
167};
168
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700169static struct acpu_level acpu_freq_tbl_nom[] __initdata = {
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700170 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(0), 925000 },
171 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(5), 950000 },
172 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(5), 950000 },
173 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(5), 975000 },
174 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(5), 975000 },
175 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(5), 1000000 },
176 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(5), 1000000 },
177 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(10), 1050000 },
178 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(10), 1050000 },
179 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(10), 1075000 },
180 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(10), 1075000 },
181 { 1, { 972000, HFPLL, 1, 0, 0x24 }, L2(10), 1100000 },
182 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(10), 1100000 },
183 { 1, { 1080000, HFPLL, 1, 0, 0x28 }, L2(15), 1150000 },
184 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(15), 1150000 },
185 { 1, { 1188000, HFPLL, 1, 0, 0x2C }, L2(15), 1175000 },
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700186 { 0, { 0 } }
187};
188
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700189static struct acpu_level acpu_freq_tbl_fast[] __initdata = {
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700190 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(0), 900000 },
191 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(5), 900000 },
192 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(5), 900000 },
193 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(5), 925000 },
194 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(5), 925000 },
195 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(5), 950000 },
196 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(5), 950000 },
197 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(10), 1000000 },
198 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(10), 1000000 },
199 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(10), 1025000 },
200 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(10), 1025000 },
201 { 1, { 972000, HFPLL, 1, 0, 0x24 }, L2(10), 1050000 },
202 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(10), 1050000 },
203 { 1, { 1080000, HFPLL, 1, 0, 0x28 }, L2(15), 1100000 },
204 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(15), 1100000 },
205 { 1, { 1188000, HFPLL, 1, 0, 0x2C }, L2(15), 1125000 },
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700206 { 0, { 0 } }
207};
208
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700209static struct pvs_table pvs_tables[NUM_PVS] __initdata = {
Matt Wagantall9515bc22012-07-19 18:13:40 -0700210[PVS_SLOW] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow), 0 },
211[PVS_NOMINAL] = { acpu_freq_tbl_nom, sizeof(acpu_freq_tbl_nom), 25000 },
212[PVS_FAST] = { acpu_freq_tbl_fast, sizeof(acpu_freq_tbl_fast), 25000 },
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700213};
214
215static struct acpuclk_krait_params acpuclk_8930_params __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700216 .scalable = scalable,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700217 .scalable_size = sizeof(scalable),
218 .hfpll_data = &hfpll_data,
219 .pvs_tables = pvs_tables,
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700220 .l2_freq_tbl = l2_freq_tbl,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700221 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
222 .bus_scale = &bus_scale_data,
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700223 .qfprom_phys_base = 0x00700000,
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700224 .stby_khz = 384000,
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700225};
226
227static int __init acpuclk_8930_probe(struct platform_device *pdev)
228{
Patrick Daly037d4912012-08-28 13:36:31 -0700229 struct acpuclk_platform_data *pdata = pdev->dev.platform_data;
230 if (pdata && pdata->uses_pm8917)
231 acpuclk_8930_params.scalable = scalable_pm8917;
232
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700233 return acpuclk_krait_init(&pdev->dev, &acpuclk_8930_params);
234}
235
236static struct platform_driver acpuclk_8930_driver = {
237 .driver = {
238 .name = "acpuclk-8930",
239 .owner = THIS_MODULE,
240 },
241};
242
243static int __init acpuclk_8930_init(void)
244{
245 return platform_driver_probe(&acpuclk_8930_driver,
246 acpuclk_8930_probe);
247}
248device_initcall(acpuclk_8930_init);