blob: 8623c2bd407dc2933b17bae0070253b9d71aac5a [file] [log] [blame]
Matt Wagantall6115d782012-06-07 20:13:51 -07001/*
2 * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070014#include <linux/kernel.h>
Matt Wagantallbf430eb2012-03-22 11:45:49 -070015#include <linux/module.h>
Matt Wagantallbf430eb2012-03-22 11:45:49 -070016#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#include <mach/rpm-regulator.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <mach/msm_bus_board.h>
Matt Wagantall6115d782012-06-07 20:13:51 -070019#include <mach/msm_bus.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020
21#include "acpuclock.h"
Matt Wagantall6115d782012-06-07 20:13:51 -070022#include "acpuclock-krait.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023
Matt Wagantall1f3762d2012-06-08 19:08:48 -070024static struct hfpll_data hfpll_data __initdata = {
Matt Wagantall6115d782012-06-07 20:13:51 -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] = 850000,
37 .vdd[HFPLL_VDD_NOM] = 1050000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038};
39
Matt Wagantall1f3762d2012-06-08 19:08:48 -070040static struct scalable scalable[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070041 [CPU0] = {
Matt Wagantall6115d782012-06-07 20:13:51 -070042 .hfpll_phys_base = 0x00903200,
Matt Wagantall6115d782012-06-07 20:13:51 -070043 .aux_clk_sel_phys = 0x02088014,
44 .aux_clk_sel = 3,
45 .l2cpmr_iaddr = 0x4501,
46 .vreg[VREG_CORE] = { "krait0", 1300000, 3200000 },
47 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
48 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
49 .vreg[VREG_HFPLL_A] = { "krait0_s8", 2050000 },
50 .vreg[VREG_HFPLL_B] = { "krait0_l23", 1800000 },
51 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052 [CPU1] = {
Matt Wagantall6115d782012-06-07 20:13:51 -070053 .hfpll_phys_base = 0x00903300,
Matt Wagantall6115d782012-06-07 20:13:51 -070054 .aux_clk_sel_phys = 0x02098014,
55 .aux_clk_sel = 3,
56 .l2cpmr_iaddr = 0x5501,
57 .vreg[VREG_CORE] = { "krait1", 1300000, 3200000 },
58 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
59 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
60 .vreg[VREG_HFPLL_A] = { "krait1_s8", 2050000 },
61 .vreg[VREG_HFPLL_B] = { "krait1_l23", 1800000 },
62 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063 [L2] = {
Matt Wagantall6115d782012-06-07 20:13:51 -070064 .hfpll_phys_base = 0x00903400,
Matt Wagantall6115d782012-06-07 20:13:51 -070065 .aux_clk_sel_phys = 0x02011028,
66 .aux_clk_sel = 3,
67 .l2cpmr_iaddr = 0x0500,
68 .vreg[VREG_HFPLL_A] = { "l2_s8", 2050000 },
69 .vreg[VREG_HFPLL_B] = { "l2_l23", 1800000 },
70 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071};
72
Matt Wagantall1f3762d2012-06-08 19:08:48 -070073static struct msm_bus_paths bw_level_tbl[] __initdata = {
Stephen Boydf2770c32011-12-07 18:52:30 -080074 [0] = BW_MBPS(640), /* At least 80 MHz on bus. */
75 [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */
76 [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */
77 [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */
78 [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */
79 [5] = BW_MBPS(3600), /* At least 450 MHz on bus. */
80 [6] = BW_MBPS(3936), /* At least 492 MHz on bus. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081};
82
Matt Wagantall1f3762d2012-06-08 19:08:48 -070083static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084 .usecase = bw_level_tbl,
85 .num_usecases = ARRAY_SIZE(bw_level_tbl),
86 .active_only = 1,
Matt Wagantall6115d782012-06-07 20:13:51 -070087 .name = "acpuclk-8960",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088};
89
Matt Wagantall1f3762d2012-06-08 19:08:48 -070090static struct l2_level l2_freq_tbl[] __initdata = {
Stephen Boyd1be9bf62011-11-21 10:51:46 -080091 [0] = { {STBY_KHZ, QSB, 0, 0, 0x00 }, 1050000, 1050000, 0 },
92 [1] = { { 384000, PLL_8, 0, 2, 0x00 }, 1050000, 1050000, 1 },
Stephen Boydf2770c32011-12-07 18:52:30 -080093 [2] = { { 432000, HFPLL, 2, 0, 0x20 }, 1050000, 1050000, 2 },
94 [3] = { { 486000, HFPLL, 2, 0, 0x24 }, 1050000, 1050000, 2 },
95 [4] = { { 540000, HFPLL, 2, 0, 0x28 }, 1050000, 1050000, 2 },
Stephen Boyd1be9bf62011-11-21 10:51:46 -080096 [5] = { { 594000, HFPLL, 1, 0, 0x16 }, 1050000, 1050000, 2 },
Stephen Boydf2770c32011-12-07 18:52:30 -080097 [6] = { { 648000, HFPLL, 1, 0, 0x18 }, 1050000, 1050000, 4 },
98 [7] = { { 702000, HFPLL, 1, 0, 0x1A }, 1050000, 1050000, 4 },
99 [8] = { { 756000, HFPLL, 1, 0, 0x1C }, 1150000, 1150000, 4 },
100 [9] = { { 810000, HFPLL, 1, 0, 0x1E }, 1150000, 1150000, 4 },
101 [10] = { { 864000, HFPLL, 1, 0, 0x20 }, 1150000, 1150000, 4 },
102 [11] = { { 918000, HFPLL, 1, 0, 0x22 }, 1150000, 1150000, 6 },
103 [12] = { { 972000, HFPLL, 1, 0, 0x24 }, 1150000, 1150000, 6 },
104 [13] = { { 1026000, HFPLL, 1, 0, 0x26 }, 1150000, 1150000, 6 },
105 [14] = { { 1080000, HFPLL, 1, 0, 0x28 }, 1150000, 1150000, 6 },
106 [15] = { { 1134000, HFPLL, 1, 0, 0x2A }, 1150000, 1150000, 6 },
107 [16] = { { 1188000, HFPLL, 1, 0, 0x2C }, 1150000, 1150000, 6 },
Stephen Boyd327ac3c2012-01-11 23:09:18 -0800108 [17] = { { 1242000, HFPLL, 1, 0, 0x2E }, 1150000, 1150000, 6 },
109 [18] = { { 1296000, HFPLL, 1, 0, 0x30 }, 1150000, 1150000, 6 },
110 [19] = { { 1350000, HFPLL, 1, 0, 0x32 }, 1150000, 1150000, 6 },
Stephen Boyd1be9bf62011-11-21 10:51:46 -0800111};
112
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700113static struct acpu_level acpu_freq_tbl_slow[] __initdata = {
Stephen Boyd327ac3c2012-01-11 23:09:18 -0800114 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 950000 },
115 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 950000 },
Stephen Boyd3b61e702012-01-26 16:47:37 -0800116 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(7), 975000 },
117 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(7), 975000 },
118 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(7), 1000000 },
119 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(7), 1000000 },
120 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(7), 1025000 },
121 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(7), 1025000 },
122 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(7), 1075000 },
123 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(7), 1075000 },
124 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(7), 1100000 },
125 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(7), 1100000 },
126 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(7), 1125000 },
127 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(7), 1125000 },
Stephen Boydb2e41d02012-06-01 11:21:13 -0700128 { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(19), 1175000 },
129 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(19), 1175000 },
130 { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(19), 1200000 },
131 { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(19), 1200000 },
132 { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(19), 1225000 },
133 { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(19), 1225000 },
134 { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(19), 1237500 },
135 { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(19), 1237500 },
136 { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(19), 1250000 },
Stephen Boyd5766f682011-12-27 19:21:08 -0800137 { 0, { 0 } }
138};
139
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700140static struct acpu_level acpu_freq_tbl_nom[] __initdata = {
Stephen Boyd327ac3c2012-01-11 23:09:18 -0800141 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 900000 },
142 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 900000 },
Stephen Boyd3b61e702012-01-26 16:47:37 -0800143 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(7), 925000 },
144 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(7), 925000 },
145 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(7), 950000 },
146 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(7), 950000 },
147 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(7), 975000 },
148 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(7), 975000 },
149 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(7), 1025000 },
150 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(7), 1025000 },
151 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(7), 1050000 },
152 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(7), 1050000 },
153 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(7), 1075000 },
154 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(7), 1075000 },
Stephen Boydb2e41d02012-06-01 11:21:13 -0700155 { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(19), 1125000 },
156 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(19), 1125000 },
157 { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(19), 1150000 },
158 { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(19), 1150000 },
159 { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(19), 1175000 },
160 { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(19), 1175000 },
161 { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(19), 1187500 },
162 { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(19), 1187500 },
163 { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(19), 1200000 },
Stephen Boyd9d0fab12011-12-08 10:56:06 -0800164 { 0, { 0 } }
165};
166
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700167static struct acpu_level acpu_freq_tbl_fast[] __initdata = {
Stephen Boyd327ac3c2012-01-11 23:09:18 -0800168 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 850000 },
169 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 850000 },
Stephen Boyd3b61e702012-01-26 16:47:37 -0800170 { 0, { 432000, HFPLL, 2, 0, 0x20 }, L2(7), 875000 },
171 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(7), 875000 },
172 { 0, { 540000, HFPLL, 2, 0, 0x28 }, L2(7), 900000 },
173 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(7), 900000 },
174 { 0, { 648000, HFPLL, 1, 0, 0x18 }, L2(7), 925000 },
175 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(7), 925000 },
176 { 0, { 756000, HFPLL, 1, 0, 0x1C }, L2(7), 975000 },
177 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(7), 975000 },
178 { 0, { 864000, HFPLL, 1, 0, 0x20 }, L2(7), 1000000 },
179 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(7), 1000000 },
180 { 0, { 972000, HFPLL, 1, 0, 0x24 }, L2(7), 1025000 },
181 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(7), 1025000 },
Stephen Boydb2e41d02012-06-01 11:21:13 -0700182 { 0, { 1080000, HFPLL, 1, 0, 0x28 }, L2(19), 1075000 },
183 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(19), 1075000 },
184 { 0, { 1188000, HFPLL, 1, 0, 0x2C }, L2(19), 1100000 },
185 { 1, { 1242000, HFPLL, 1, 0, 0x2E }, L2(19), 1100000 },
186 { 0, { 1296000, HFPLL, 1, 0, 0x30 }, L2(19), 1125000 },
187 { 1, { 1350000, HFPLL, 1, 0, 0x32 }, L2(19), 1125000 },
188 { 0, { 1404000, HFPLL, 1, 0, 0x34 }, L2(19), 1137500 },
189 { 1, { 1458000, HFPLL, 1, 0, 0x36 }, L2(19), 1137500 },
190 { 1, { 1512000, HFPLL, 1, 0, 0x38 }, L2(19), 1150000 },
Stephen Boyd1be9bf62011-11-21 10:51:46 -0800191 { 0, { 0 } }
192};
193
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700194static struct pvs_table pvs_tables[NUM_PVS] __initdata = {
195 [PVS_SLOW] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow) },
196 [PVS_NOMINAL] = { acpu_freq_tbl_nom, sizeof(acpu_freq_tbl_nom) },
197 [PVS_FAST] = { acpu_freq_tbl_fast, sizeof(acpu_freq_tbl_fast) },
198};
199
200static struct acpuclk_krait_params acpuclk_8960_params __initdata = {
Matt Wagantall6115d782012-06-07 20:13:51 -0700201 .scalable = scalable,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700202 .scalable_size = sizeof(scalable),
203 .hfpll_data = &hfpll_data,
204 .pvs_tables = pvs_tables,
Matt Wagantall6115d782012-06-07 20:13:51 -0700205 .l2_freq_tbl = l2_freq_tbl,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700206 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
207 .bus_scale = &bus_scale_data,
Matt Wagantall6115d782012-06-07 20:13:51 -0700208 .qfprom_phys_base = 0x00700000,
Matt Wagantall6d9ebee2011-08-26 12:15:24 -0700209};
210
Matt Wagantallbf430eb2012-03-22 11:45:49 -0700211static int __init acpuclk_8960_probe(struct platform_device *pdev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212{
Matt Wagantall6115d782012-06-07 20:13:51 -0700213 return acpuclk_krait_init(&pdev->dev, &acpuclk_8960_params);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700214}
Matt Wagantallec57f062011-08-16 23:54:46 -0700215
Matt Wagantallbf430eb2012-03-22 11:45:49 -0700216static struct platform_driver acpuclk_8960_driver = {
217 .driver = {
218 .name = "acpuclk-8960",
219 .owner = THIS_MODULE,
220 },
Matt Wagantallec57f062011-08-16 23:54:46 -0700221};
Tianyi Gou7c6b81f2011-12-07 23:09:08 -0800222
Matt Wagantallbf430eb2012-03-22 11:45:49 -0700223static int __init acpuclk_8960_init(void)
224{
225 return platform_driver_probe(&acpuclk_8960_driver, acpuclk_8960_probe);
226}
227device_initcall(acpuclk_8960_init);