blob: d04ce0335ed0a6113fbbf2c97b10dc9ebf29fc06 [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,
40 .low_vdd_l_max = 40,
41 .vdd[HFPLL_VDD_NONE] = LVL_NONE,
42 .vdd[HFPLL_VDD_LOW] = LVL_LOW,
43 .vdd[HFPLL_VDD_NOM] = LVL_NOM,
44};
45
Matt Wagantall1f3762d2012-06-08 19:08:48 -070046static struct scalable scalable[] __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -070047 [CPU0] = {
48 .hfpll_phys_base = 0x00903200,
Matt Wagantall6dcfa922012-06-07 20:13:51 -070049 .aux_clk_sel_phys = 0x02088014,
50 .aux_clk_sel = 3,
51 .l2cpmr_iaddr = 0x4501,
52 .vreg[VREG_CORE] = { "krait0", 1300000, 1740000 },
53 .vreg[VREG_MEM] = { "krait0_mem", 1150000 },
54 .vreg[VREG_DIG] = { "krait0_dig", 1150000 },
55 .vreg[VREG_HFPLL_A] = { "krait0_hfpll", 1800000 },
56 },
57 [CPU1] = {
58 .hfpll_phys_base = 0x00903300,
Matt Wagantall6dcfa922012-06-07 20:13:51 -070059 .aux_clk_sel_phys = 0x02098014,
60 .aux_clk_sel = 3,
61 .l2cpmr_iaddr = 0x5501,
62 .vreg[VREG_CORE] = { "krait1", 1300000, 1740000 },
63 .vreg[VREG_MEM] = { "krait1_mem", 1150000 },
64 .vreg[VREG_DIG] = { "krait1_dig", 1150000 },
65 .vreg[VREG_HFPLL_A] = { "krait1_hfpll", 1800000 },
66 },
67 [L2] = {
68 .hfpll_phys_base = 0x00903400,
Matt Wagantall6dcfa922012-06-07 20:13:51 -070069 .aux_clk_sel_phys = 0x02011028,
70 .aux_clk_sel = 3,
71 .l2cpmr_iaddr = 0x0500,
72 .vreg[VREG_HFPLL_A] = { "l2_hfpll", 1800000 },
73 },
74};
75
Matt Wagantall1f3762d2012-06-08 19:08:48 -070076static struct msm_bus_paths bw_level_tbl[] __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -070077 [0] = BW_MBPS(640), /* At least 80 MHz on bus. */
78 [1] = BW_MBPS(1064), /* At least 133 MHz on bus. */
79 [2] = BW_MBPS(1600), /* At least 200 MHz on bus. */
80 [3] = BW_MBPS(2128), /* At least 266 MHz on bus. */
81 [4] = BW_MBPS(3200), /* At least 400 MHz on bus. */
82 [5] = BW_MBPS(3600), /* At least 450 MHz on bus. */
83 [6] = BW_MBPS(3936), /* At least 492 MHz on bus. */
84 [7] = BW_MBPS(4264), /* At least 533 MHz on bus. */
85};
86
Matt Wagantall1f3762d2012-06-08 19:08:48 -070087static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -070088 .usecase = bw_level_tbl,
89 .num_usecases = ARRAY_SIZE(bw_level_tbl),
90 .active_only = 1,
91 .name = "acpuclk-8930",
92};
93
94/* TODO: Update vdd_dig, vdd_mem and bw when data is available. */
Matt Wagantall1f3762d2012-06-08 19:08:48 -070095static struct l2_level l2_freq_tbl[] __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -070096 [0] = { {STBY_KHZ, QSB, 0, 0, 0x00 }, LVL_NOM, 1050000, 0 },
97 [1] = { { 384000, PLL_8, 0, 2, 0x00 }, LVL_NOM, 1050000, 1 },
98 [2] = { { 432000, HFPLL, 2, 0, 0x20 }, LVL_NOM, 1050000, 2 },
99 [3] = { { 486000, HFPLL, 2, 0, 0x24 }, LVL_NOM, 1050000, 2 },
100 [4] = { { 540000, HFPLL, 2, 0, 0x28 }, LVL_NOM, 1050000, 2 },
101 [5] = { { 594000, HFPLL, 1, 0, 0x16 }, LVL_NOM, 1050000, 2 },
102 [6] = { { 648000, HFPLL, 1, 0, 0x18 }, LVL_NOM, 1050000, 4 },
103 [7] = { { 702000, HFPLL, 1, 0, 0x1A }, LVL_NOM, 1050000, 4 },
104 [8] = { { 756000, HFPLL, 1, 0, 0x1C }, LVL_HIGH, 1150000, 4 },
105 [9] = { { 810000, HFPLL, 1, 0, 0x1E }, LVL_HIGH, 1150000, 4 },
106 [10] = { { 864000, HFPLL, 1, 0, 0x20 }, LVL_HIGH, 1150000, 4 },
107 [11] = { { 918000, HFPLL, 1, 0, 0x22 }, LVL_HIGH, 1150000, 7 },
108 [12] = { { 972000, HFPLL, 1, 0, 0x24 }, LVL_HIGH, 1150000, 7 },
109 [13] = { { 1026000, HFPLL, 1, 0, 0x26 }, LVL_HIGH, 1150000, 7 },
110 [14] = { { 1080000, HFPLL, 1, 0, 0x28 }, LVL_HIGH, 1150000, 7 },
111 [15] = { { 1134000, HFPLL, 1, 0, 0x2A }, LVL_HIGH, 1150000, 7 },
112 [16] = { { 1188000, HFPLL, 1, 0, 0x2C }, LVL_HIGH, 1150000, 7 },
113};
114
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700115static struct acpu_level acpu_freq_tbl_slow[] __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700116 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 950000 },
117 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 950000 },
118 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(6), 975000 },
119 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(6), 975000 },
120 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(6), 1000000 },
121 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(6), 1000000 },
122 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(6), 1025000 },
123 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(6), 1025000 },
124 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(11), 1075000 },
125 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(11), 1075000 },
126 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(11), 1100000 },
127 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(11), 1100000 },
128 { 1, { 972000, HFPLL, 1, 0, 0x24 }, L2(11), 1125000 },
129 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(11), 1125000 },
130 { 1, { 1080000, HFPLL, 1, 0, 0x28 }, L2(16), 1175000 },
131 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(16), 1175000 },
132 { 1, { 1188000, HFPLL, 1, 0, 0x2C }, L2(16), 1200000 },
133 { 0, { 0 } }
134};
135
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700136static struct acpu_level acpu_freq_tbl_nom[] __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700137 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 925000 },
138 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 925000 },
139 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(6), 950000 },
140 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(6), 950000 },
141 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(6), 975000 },
142 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(6), 975000 },
143 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(6), 1000000 },
144 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(6), 1000000 },
145 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(11), 1050000 },
146 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(11), 1050000 },
147 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(11), 1075000 },
148 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(11), 1075000 },
149 { 1, { 972000, HFPLL, 1, 0, 0x24 }, L2(11), 1100000 },
150 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(11), 1100000 },
151 { 1, { 1080000, HFPLL, 1, 0, 0x28 }, L2(16), 1150000 },
152 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(16), 1150000 },
153 { 1, { 1188000, HFPLL, 1, 0, 0x2C }, L2(16), 1175000 },
154 { 0, { 0 } }
155};
156
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700157static struct acpu_level acpu_freq_tbl_fast[] __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700158 { 0, { STBY_KHZ, QSB, 0, 0, 0x00 }, L2(0), 900000 },
159 { 1, { 384000, PLL_8, 0, 2, 0x00 }, L2(1), 900000 },
160 { 1, { 432000, HFPLL, 2, 0, 0x20 }, L2(6), 900000 },
161 { 1, { 486000, HFPLL, 2, 0, 0x24 }, L2(6), 900000 },
162 { 1, { 540000, HFPLL, 2, 0, 0x28 }, L2(6), 925000 },
163 { 1, { 594000, HFPLL, 1, 0, 0x16 }, L2(6), 925000 },
164 { 1, { 648000, HFPLL, 1, 0, 0x18 }, L2(6), 950000 },
165 { 1, { 702000, HFPLL, 1, 0, 0x1A }, L2(6), 950000 },
166 { 1, { 756000, HFPLL, 1, 0, 0x1C }, L2(11), 1000000 },
167 { 1, { 810000, HFPLL, 1, 0, 0x1E }, L2(11), 1000000 },
168 { 1, { 864000, HFPLL, 1, 0, 0x20 }, L2(11), 1025000 },
169 { 1, { 918000, HFPLL, 1, 0, 0x22 }, L2(11), 1025000 },
170 { 1, { 972000, HFPLL, 1, 0, 0x24 }, L2(11), 1050000 },
171 { 1, { 1026000, HFPLL, 1, 0, 0x26 }, L2(11), 1050000 },
172 { 1, { 1080000, HFPLL, 1, 0, 0x28 }, L2(16), 1100000 },
173 { 1, { 1134000, HFPLL, 1, 0, 0x2A }, L2(16), 1100000 },
174 { 1, { 1188000, HFPLL, 1, 0, 0x2C }, L2(16), 1125000 },
175 { 0, { 0 } }
176};
177
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700178static struct pvs_table pvs_tables[NUM_PVS] __initdata = {
179 [PVS_SLOW] = { acpu_freq_tbl_slow, sizeof(acpu_freq_tbl_slow) },
180 [PVS_NOMINAL] = { acpu_freq_tbl_nom, sizeof(acpu_freq_tbl_nom) },
181 [PVS_FAST] = { acpu_freq_tbl_fast, sizeof(acpu_freq_tbl_fast) },
182};
183
184static struct acpuclk_krait_params acpuclk_8930_params __initdata = {
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700185 .scalable = scalable,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700186 .scalable_size = sizeof(scalable),
187 .hfpll_data = &hfpll_data,
188 .pvs_tables = pvs_tables,
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700189 .l2_freq_tbl = l2_freq_tbl,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700190 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
191 .bus_scale = &bus_scale_data,
Matt Wagantall6dcfa922012-06-07 20:13:51 -0700192 .qfprom_phys_base = 0x00700000,
193};
194
195static int __init acpuclk_8930_probe(struct platform_device *pdev)
196{
197 return acpuclk_krait_init(&pdev->dev, &acpuclk_8930_params);
198}
199
200static struct platform_driver acpuclk_8930_driver = {
201 .driver = {
202 .name = "acpuclk-8930",
203 .owner = THIS_MODULE,
204 },
205};
206
207static int __init acpuclk_8930_init(void)
208{
209 return platform_driver_probe(&acpuclk_8930_driver,
210 acpuclk_8930_probe);
211}
212device_initcall(acpuclk_8930_init);