blob: d81cc4d70f631376eb692b81110b864e5587888f [file] [log] [blame]
Matt Wagantall6115d782012-06-07 20:13:51 -07001/*
Duy Truonge833aca2013-02-12 13:35:08 -08002 * Copyright (c) 2011-2012, The Linux Foundation. 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,
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 Wagantall6115d782012-06-07 20:13:51 -070038 .vdd[HFPLL_VDD_NOM] = 1050000,
Matt Wagantall87465f52012-07-23 22:03:06 -070039 .vdd[HFPLL_VDD_HIGH] = 1150000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070040};
41
Matt Wagantall1f3762d2012-06-08 19:08:48 -070042static struct scalable scalable[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070043 [CPU0] = {
Matt Wagantall6115d782012-06-07 20:13:51 -070044 .hfpll_phys_base = 0x00903200,
Matt Wagantall6115d782012-06-07 20:13:51 -070045 .aux_clk_sel_phys = 0x02088014,
46 .aux_clk_sel = 3,
Matt Wagantalla133dbf2012-09-27 19:56:57 -070047 .sec_clk_sel = 2,
Matt Wagantall6115d782012-06-07 20:13:51 -070048 .l2cpmr_iaddr = 0x4501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070049 .vreg[VREG_CORE] = { "krait0", 1300000 },
Matt Wagantall6115d782012-06-07 20:13:51 -070050 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055 [CPU1] = {
Matt Wagantall6115d782012-06-07 20:13:51 -070056 .hfpll_phys_base = 0x00903300,
Matt Wagantall6115d782012-06-07 20:13:51 -070057 .aux_clk_sel_phys = 0x02098014,
58 .aux_clk_sel = 3,
Matt Wagantalla133dbf2012-09-27 19:56:57 -070059 .sec_clk_sel = 2,
Matt Wagantall6115d782012-06-07 20:13:51 -070060 .l2cpmr_iaddr = 0x5501,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070061 .vreg[VREG_CORE] = { "krait1", 1300000 },
Matt Wagantall6115d782012-06-07 20:13:51 -070062 .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 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070067 [L2] = {
Matt Wagantall6115d782012-06-07 20:13:51 -070068 .hfpll_phys_base = 0x00903400,
Matt Wagantall6115d782012-06-07 20:13:51 -070069 .aux_clk_sel_phys = 0x02011028,
70 .aux_clk_sel = 3,
Matt Wagantalla133dbf2012-09-27 19:56:57 -070071 .sec_clk_sel = 2,
Matt Wagantall6115d782012-06-07 20:13:51 -070072 .l2cpmr_iaddr = 0x0500,
73 .vreg[VREG_HFPLL_A] = { "l2_s8", 2050000 },
74 .vreg[VREG_HFPLL_B] = { "l2_l23", 1800000 },
75 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076};
77
Matt Wagantall1f3762d2012-06-08 19:08:48 -070078static struct msm_bus_paths bw_level_tbl[] __initdata = {
Stephen Boydf2770c32011-12-07 18:52:30 -080079 [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(3600), /* At least 450 MHz on bus. */
85 [6] = BW_MBPS(3936), /* At least 492 MHz on bus. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070086};
87
Matt Wagantall1f3762d2012-06-08 19:08:48 -070088static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089 .usecase = bw_level_tbl,
90 .num_usecases = ARRAY_SIZE(bw_level_tbl),
91 .active_only = 1,
Matt Wagantall6115d782012-06-07 20:13:51 -070092 .name = "acpuclk-8960",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093};
94
Matt Wagantall1f3762d2012-06-08 19:08:48 -070095static struct l2_level l2_freq_tbl[] __initdata = {
Matt Wagantalla133dbf2012-09-27 19:56:57 -070096 [0] = { { 384000, PLL_8, 0, 0x00 }, 1050000, 1050000, 1 },
97 [1] = { { 432000, HFPLL, 2, 0x20 }, 1050000, 1050000, 2 },
98 [2] = { { 486000, HFPLL, 2, 0x24 }, 1050000, 1050000, 2 },
99 [3] = { { 540000, HFPLL, 2, 0x28 }, 1050000, 1050000, 2 },
100 [4] = { { 594000, HFPLL, 1, 0x16 }, 1050000, 1050000, 2 },
101 [5] = { { 648000, HFPLL, 1, 0x18 }, 1050000, 1050000, 4 },
102 [6] = { { 702000, HFPLL, 1, 0x1A }, 1050000, 1050000, 4 },
103 [7] = { { 756000, HFPLL, 1, 0x1C }, 1150000, 1150000, 4 },
104 [8] = { { 810000, HFPLL, 1, 0x1E }, 1150000, 1150000, 4 },
105 [9] = { { 864000, HFPLL, 1, 0x20 }, 1150000, 1150000, 4 },
106 [10] = { { 918000, HFPLL, 1, 0x22 }, 1150000, 1150000, 6 },
107 [11] = { { 972000, HFPLL, 1, 0x24 }, 1150000, 1150000, 6 },
108 [12] = { { 1026000, HFPLL, 1, 0x26 }, 1150000, 1150000, 6 },
109 [13] = { { 1080000, HFPLL, 1, 0x28 }, 1150000, 1150000, 6 },
110 [14] = { { 1134000, HFPLL, 1, 0x2A }, 1150000, 1150000, 6 },
111 [15] = { { 1188000, HFPLL, 1, 0x2C }, 1150000, 1150000, 6 },
112 [16] = { { 1242000, HFPLL, 1, 0x2E }, 1150000, 1150000, 6 },
113 [17] = { { 1296000, HFPLL, 1, 0x30 }, 1150000, 1150000, 6 },
114 [18] = { { 1350000, HFPLL, 1, 0x32 }, 1150000, 1150000, 6 },
Stephen Boyd2b73ee02012-09-11 21:08:13 -0700115 { }
Stephen Boyd1be9bf62011-11-21 10:51:46 -0800116};
117
Stephen Boydc13b6792012-09-14 11:25:34 -0700118#define AVS(x) .avsdscr_setting = (x)
119
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700120static struct acpu_level acpu_freq_tbl_slow[] __initdata = {
Matt Wagantalla133dbf2012-09-27 19:56:57 -0700121 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 950000, AVS(0x40001F) },
122 { 0, { 432000, HFPLL, 2, 0x20 }, L2(6), 975000 },
123 { 1, { 486000, HFPLL, 2, 0x24 }, L2(6), 975000 },
124 { 0, { 540000, HFPLL, 2, 0x28 }, L2(6), 1000000 },
125 { 1, { 594000, HFPLL, 1, 0x16 }, L2(6), 1000000 },
126 { 0, { 648000, HFPLL, 1, 0x18 }, L2(6), 1025000 },
127 { 1, { 702000, HFPLL, 1, 0x1A }, L2(6), 1025000 },
128 { 0, { 756000, HFPLL, 1, 0x1C }, L2(6), 1075000 },
129 { 1, { 810000, HFPLL, 1, 0x1E }, L2(6), 1075000 },
130 { 0, { 864000, HFPLL, 1, 0x20 }, L2(6), 1100000 },
131 { 1, { 918000, HFPLL, 1, 0x22 }, L2(6), 1100000 },
132 { 0, { 972000, HFPLL, 1, 0x24 }, L2(6), 1125000 },
133 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(6), 1125000 },
134 { 0, { 1080000, HFPLL, 1, 0x28 }, L2(18), 1175000, AVS(0x400015) },
135 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(18), 1175000, AVS(0x400015) },
136 { 0, { 1188000, HFPLL, 1, 0x2C }, L2(18), 1200000, AVS(0x400015) },
137 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(18), 1200000, AVS(0x400015) },
138 { 0, { 1296000, HFPLL, 1, 0x30 }, L2(18), 1225000, AVS(0x400015) },
139 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(18), 1225000, AVS(0x400015) },
140 { 0, { 1404000, HFPLL, 1, 0x34 }, L2(18), 1237500, AVS(0x400015) },
141 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(18), 1237500, AVS(0x100018) },
142 { 1, { 1512000, HFPLL, 1, 0x38 }, L2(18), 1250000, AVS(0x400012) },
Stephen Boyd5766f682011-12-27 19:21:08 -0800143 { 0, { 0 } }
144};
145
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700146static struct acpu_level acpu_freq_tbl_nom[] __initdata = {
Matt Wagantalla133dbf2012-09-27 19:56:57 -0700147 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 900000, AVS(0x40007F) },
148 { 0, { 432000, HFPLL, 2, 0x20 }, L2(6), 925000 },
149 { 1, { 486000, HFPLL, 2, 0x24 }, L2(6), 925000 },
150 { 0, { 540000, HFPLL, 2, 0x28 }, L2(6), 950000 },
151 { 1, { 594000, HFPLL, 1, 0x16 }, L2(6), 950000 },
152 { 0, { 648000, HFPLL, 1, 0x18 }, L2(6), 975000 },
153 { 1, { 702000, HFPLL, 1, 0x1A }, L2(6), 975000 },
154 { 0, { 756000, HFPLL, 1, 0x1C }, L2(6), 1025000 },
155 { 1, { 810000, HFPLL, 1, 0x1E }, L2(6), 1025000 },
156 { 0, { 864000, HFPLL, 1, 0x20 }, L2(6), 1050000 },
157 { 1, { 918000, HFPLL, 1, 0x22 }, L2(6), 1050000 },
158 { 0, { 972000, HFPLL, 1, 0x24 }, L2(6), 1075000 },
159 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(6), 1075000 },
160 { 0, { 1080000, HFPLL, 1, 0x28 }, L2(18), 1125000, AVS(0x400015) },
161 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(18), 1125000, AVS(0x400015) },
162 { 0, { 1188000, HFPLL, 1, 0x2C }, L2(18), 1150000, AVS(0x400015) },
163 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(18), 1150000, AVS(0x400015) },
164 { 0, { 1296000, HFPLL, 1, 0x30 }, L2(18), 1175000, AVS(0x400015) },
165 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(18), 1175000, AVS(0x400015) },
166 { 0, { 1404000, HFPLL, 1, 0x34 }, L2(18), 1187500, AVS(0x400015) },
167 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(18), 1187500, AVS(0x100018) },
168 { 1, { 1512000, HFPLL, 1, 0x38 }, L2(18), 1200000, AVS(0x400012) },
Stephen Boyd9d0fab12011-12-08 10:56:06 -0800169 { 0, { 0 } }
170};
171
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700172static struct acpu_level acpu_freq_tbl_fast[] __initdata = {
Matt Wagantalla133dbf2012-09-27 19:56:57 -0700173 { 1, { 384000, PLL_8, 0, 0x00 }, L2(0), 850000, AVS(0x4000FF) },
174 { 0, { 432000, HFPLL, 2, 0x20 }, L2(6), 875000 },
175 { 1, { 486000, HFPLL, 2, 0x24 }, L2(6), 875000 },
176 { 0, { 540000, HFPLL, 2, 0x28 }, L2(6), 900000 },
177 { 1, { 594000, HFPLL, 1, 0x16 }, L2(6), 900000 },
178 { 0, { 648000, HFPLL, 1, 0x18 }, L2(6), 925000 },
179 { 1, { 702000, HFPLL, 1, 0x1A }, L2(6), 925000 },
180 { 0, { 756000, HFPLL, 1, 0x1C }, L2(6), 975000 },
181 { 1, { 810000, HFPLL, 1, 0x1E }, L2(6), 975000 },
182 { 0, { 864000, HFPLL, 1, 0x20 }, L2(6), 1000000 },
183 { 1, { 918000, HFPLL, 1, 0x22 }, L2(6), 1000000 },
184 { 0, { 972000, HFPLL, 1, 0x24 }, L2(6), 1025000 },
185 { 1, { 1026000, HFPLL, 1, 0x26 }, L2(6), 1025000 },
186 { 0, { 1080000, HFPLL, 1, 0x28 }, L2(18), 1075000, AVS(0x10001B) },
187 { 1, { 1134000, HFPLL, 1, 0x2A }, L2(18), 1075000, AVS(0x10001B) },
188 { 0, { 1188000, HFPLL, 1, 0x2C }, L2(18), 1100000, AVS(0x10001B) },
189 { 1, { 1242000, HFPLL, 1, 0x2E }, L2(18), 1100000, AVS(0x10001B) },
190 { 0, { 1296000, HFPLL, 1, 0x30 }, L2(18), 1125000, AVS(0x10001B) },
191 { 1, { 1350000, HFPLL, 1, 0x32 }, L2(18), 1125000, AVS(0x400012) },
192 { 0, { 1404000, HFPLL, 1, 0x34 }, L2(18), 1137500, AVS(0x400012) },
193 { 1, { 1458000, HFPLL, 1, 0x36 }, L2(18), 1137500, AVS(0x400012) },
194 { 1, { 1512000, HFPLL, 1, 0x38 }, L2(18), 1150000, AVS(0x400012) },
Stephen Boyd1be9bf62011-11-21 10:51:46 -0800195 { 0, { 0 } }
196};
197
Patrick Daly02db5a82012-08-24 14:22:06 -0700198static struct pvs_table pvs_tables[NUM_SPEED_BINS][NUM_PVS] __initdata = {
199[0][PVS_SLOW] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow), 0 },
200[0][PVS_NOMINAL] = { acpu_freq_tbl_nom, sizeof(acpu_freq_tbl_nom), 25000 },
201[0][PVS_FAST] = { acpu_freq_tbl_fast, sizeof(acpu_freq_tbl_fast), 25000 },
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700202};
203
204static struct acpuclk_krait_params acpuclk_8960_params __initdata = {
Matt Wagantall6115d782012-06-07 20:13:51 -0700205 .scalable = scalable,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700206 .scalable_size = sizeof(scalable),
207 .hfpll_data = &hfpll_data,
208 .pvs_tables = pvs_tables,
Matt Wagantall6115d782012-06-07 20:13:51 -0700209 .l2_freq_tbl = l2_freq_tbl,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700210 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
211 .bus_scale = &bus_scale_data,
Matt Wagantall519e94f2012-09-17 17:51:06 -0700212 .pte_efuse_phys = 0x007000C0,
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700213 .stby_khz = 384000,
Matt Wagantall6d9ebee2011-08-26 12:15:24 -0700214};
215
Matt Wagantallbf430eb2012-03-22 11:45:49 -0700216static int __init acpuclk_8960_probe(struct platform_device *pdev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700217{
Matt Wagantall6115d782012-06-07 20:13:51 -0700218 return acpuclk_krait_init(&pdev->dev, &acpuclk_8960_params);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700219}
Matt Wagantallec57f062011-08-16 23:54:46 -0700220
Matt Wagantallbf430eb2012-03-22 11:45:49 -0700221static struct platform_driver acpuclk_8960_driver = {
222 .driver = {
223 .name = "acpuclk-8960",
224 .owner = THIS_MODULE,
225 },
Matt Wagantallec57f062011-08-16 23:54:46 -0700226};
Tianyi Gou7c6b81f2011-12-07 23:09:08 -0800227
Matt Wagantallbf430eb2012-03-22 11:45:49 -0700228static int __init acpuclk_8960_init(void)
229{
230 return platform_driver_probe(&acpuclk_8960_driver, acpuclk_8960_probe);
231}
232device_initcall(acpuclk_8960_init);