blob: bb426d70f5e500342c3236d7263eec129b207995 [file] [log] [blame]
Matt Wagantalle9b715a2012-01-04 18:16:14 -08001/*
Duy Truonge833aca2013-02-12 13:35:08 -08002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Matt Wagantalle9b715a2012-01-04 18:16:14 -08003 *
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
Steve Mucklef132c6c2012-06-06 18:30:57 -070014#include <linux/module.h>
Matt Wagantalle9b715a2012-01-04 18:16:14 -080015#include <linux/platform_device.h>
16#include <linux/of.h>
Matt Wagantalld591bf22012-06-29 11:20:53 -070017#include <mach/rpm-regulator-smd.h>
Matt Wagantalle9b715a2012-01-04 18:16:14 -080018#include <mach/msm_bus_board.h>
19#include <mach/msm_bus.h>
20#include <mach/socinfo.h>
21
22#include "acpuclock.h"
23#include "acpuclock-krait.h"
24
25/* Corner type vreg VDD values */
Matt Wagantallf06e3572012-07-27 12:45:24 -070026#define LVL_NONE RPM_REGULATOR_CORNER_NONE
Matt Wagantalld591bf22012-06-29 11:20:53 -070027#define LVL_LOW RPM_REGULATOR_CORNER_SVS_SOC
28#define LVL_NOM RPM_REGULATOR_CORNER_NORMAL
29#define LVL_HIGH RPM_REGULATOR_CORNER_SUPER_TURBO
Matt Wagantalle9b715a2012-01-04 18:16:14 -080030
Matt Wagantall1f3762d2012-06-08 19:08:48 -070031static struct hfpll_data hfpll_data __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -080032 .mode_offset = 0x00,
33 .l_offset = 0x04,
34 .m_offset = 0x08,
35 .n_offset = 0x0C,
Matt Wagantalla77b7f32012-07-18 16:32:01 -070036 .has_user_reg = true,
37 .user_offset = 0x10,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080038 .config_offset = 0x14,
Matt Wagantalla77b7f32012-07-18 16:32:01 -070039 /* TODO: Verify magic numbers when final values are available. */
40 .user_val = 0x8,
41 .config_val = 0x04D0405D,
42 .low_vco_l_max = 65,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080043 .low_vdd_l_max = 52,
Matt Wagantall87465f52012-07-23 22:03:06 -070044 .nom_vdd_l_max = 104,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080045 .vdd[HFPLL_VDD_NONE] = LVL_NONE,
46 .vdd[HFPLL_VDD_LOW] = LVL_LOW,
47 .vdd[HFPLL_VDD_NOM] = LVL_NOM,
Matt Wagantall87465f52012-07-23 22:03:06 -070048 .vdd[HFPLL_VDD_HIGH] = LVL_HIGH,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080049};
50
Matt Wagantall1f3762d2012-06-08 19:08:48 -070051static struct scalable scalable[] __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -080052 [CPU0] = {
53 .hfpll_phys_base = 0xF908A000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080054 .l2cpmr_iaddr = 0x4501,
Matt Wagantalla133dbf2012-09-27 19:56:57 -070055 .sec_clk_sel = 2,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070056 .vreg[VREG_CORE] = { "krait0", 1050000 },
Matt Wagantall75473eb2012-05-31 15:23:22 -070057 .vreg[VREG_MEM] = { "krait0_mem", 1050000 },
Matt Wagantalld591bf22012-06-29 11:20:53 -070058 .vreg[VREG_DIG] = { "krait0_dig", LVL_HIGH },
Matt Wagantall337cdb72012-06-29 12:07:27 -070059 .vreg[VREG_HFPLL_A] = { "krait0_hfpll_a", 2150000 },
60 .vreg[VREG_HFPLL_B] = { "krait0_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080061 },
62 [CPU1] = {
63 .hfpll_phys_base = 0xF909A000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080064 .l2cpmr_iaddr = 0x5501,
Matt Wagantalla133dbf2012-09-27 19:56:57 -070065 .sec_clk_sel = 2,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070066 .vreg[VREG_CORE] = { "krait1", 1050000 },
Matt Wagantall75473eb2012-05-31 15:23:22 -070067 .vreg[VREG_MEM] = { "krait1_mem", 1050000 },
Matt Wagantalld591bf22012-06-29 11:20:53 -070068 .vreg[VREG_DIG] = { "krait1_dig", LVL_HIGH },
Matt Wagantall337cdb72012-06-29 12:07:27 -070069 .vreg[VREG_HFPLL_A] = { "krait1_hfpll_a", 2150000 },
70 .vreg[VREG_HFPLL_B] = { "krait1_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080071 },
72 [CPU2] = {
73 .hfpll_phys_base = 0xF90AA000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080074 .l2cpmr_iaddr = 0x6501,
Matt Wagantalla133dbf2012-09-27 19:56:57 -070075 .sec_clk_sel = 2,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070076 .vreg[VREG_CORE] = { "krait2", 1050000 },
Matt Wagantall75473eb2012-05-31 15:23:22 -070077 .vreg[VREG_MEM] = { "krait2_mem", 1050000 },
Matt Wagantalld591bf22012-06-29 11:20:53 -070078 .vreg[VREG_DIG] = { "krait2_dig", LVL_HIGH },
Matt Wagantall337cdb72012-06-29 12:07:27 -070079 .vreg[VREG_HFPLL_A] = { "krait2_hfpll_a", 2150000 },
80 .vreg[VREG_HFPLL_B] = { "krait2_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080081 },
82 [CPU3] = {
83 .hfpll_phys_base = 0xF90BA000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080084 .l2cpmr_iaddr = 0x7501,
Matt Wagantalla133dbf2012-09-27 19:56:57 -070085 .sec_clk_sel = 2,
Matt Wagantall6d9c4162012-07-16 18:58:16 -070086 .vreg[VREG_CORE] = { "krait3", 1050000 },
Matt Wagantall75473eb2012-05-31 15:23:22 -070087 .vreg[VREG_MEM] = { "krait3_mem", 1050000 },
Matt Wagantalld591bf22012-06-29 11:20:53 -070088 .vreg[VREG_DIG] = { "krait3_dig", LVL_HIGH },
Matt Wagantall337cdb72012-06-29 12:07:27 -070089 .vreg[VREG_HFPLL_A] = { "krait3_hfpll_a", 2150000 },
90 .vreg[VREG_HFPLL_B] = { "krait3_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080091 },
92 [L2] = {
93 .hfpll_phys_base = 0xF9016000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080094 .l2cpmr_iaddr = 0x0500,
Matt Wagantalla133dbf2012-09-27 19:56:57 -070095 .sec_clk_sel = 2,
Matt Wagantall337cdb72012-06-29 12:07:27 -070096 .vreg[VREG_HFPLL_A] = { "l2_hfpll_a", 2150000 },
97 .vreg[VREG_HFPLL_B] = { "l2_hfpll_b", 1800000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -080098 },
99};
100
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700101static struct msm_bus_paths bw_level_tbl[] __initdata = {
Matt Wagantallf06e3572012-07-27 12:45:24 -0700102 [0] = BW_MBPS(552), /* At least 69 MHz on bus. */
103 [1] = BW_MBPS(1112), /* At least 139 MHz on bus. */
104 [2] = BW_MBPS(2224), /* At least 278 MHz on bus. */
105 [3] = BW_MBPS(4448), /* At least 556 MHz on bus. */
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800106};
107
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700108static struct msm_bus_scale_pdata bus_scale_data __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800109 .usecase = bw_level_tbl,
110 .num_usecases = ARRAY_SIZE(bw_level_tbl),
111 .active_only = 1,
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700112 .name = "acpuclk-8974",
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800113};
114
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700115static struct l2_level l2_freq_tbl[] __initdata = {
Matt Wagantalla133dbf2012-09-27 19:56:57 -0700116 [0] = { { 300000, PLL_0, 0, 0 }, LVL_LOW, 950000, 0 },
117 [1] = { { 384000, HFPLL, 2, 40 }, LVL_NOM, 950000, 1 },
118 [2] = { { 460800, HFPLL, 2, 48 }, LVL_NOM, 950000, 1 },
119 [3] = { { 537600, HFPLL, 1, 28 }, LVL_NOM, 950000, 2 },
120 [4] = { { 576000, HFPLL, 1, 30 }, LVL_NOM, 950000, 2 },
121 [5] = { { 652800, HFPLL, 1, 34 }, LVL_NOM, 950000, 2 },
122 [6] = { { 729600, HFPLL, 1, 38 }, LVL_NOM, 950000, 2 },
123 [7] = { { 806400, HFPLL, 1, 42 }, LVL_NOM, 950000, 2 },
124 [8] = { { 883200, HFPLL, 1, 46 }, LVL_HIGH, 1050000, 2 },
125 [9] = { { 960000, HFPLL, 1, 50 }, LVL_HIGH, 1050000, 2 },
126 [10] = { { 1036800, HFPLL, 1, 54 }, LVL_HIGH, 1050000, 3 },
127 [11] = { { 1113600, HFPLL, 1, 58 }, LVL_HIGH, 1050000, 3 },
128 [12] = { { 1190400, HFPLL, 1, 62 }, LVL_HIGH, 1050000, 3 },
129 [13] = { { 1267200, HFPLL, 1, 66 }, LVL_HIGH, 1050000, 3 },
130 [14] = { { 1344000, HFPLL, 1, 70 }, LVL_HIGH, 1050000, 3 },
131 [15] = { { 1420800, HFPLL, 1, 74 }, LVL_HIGH, 1050000, 3 },
132 [16] = { { 1497600, HFPLL, 1, 78 }, LVL_HIGH, 1050000, 3 },
133 [17] = { { 1574400, HFPLL, 1, 82 }, LVL_HIGH, 1050000, 3 },
134 [18] = { { 1651200, HFPLL, 1, 86 }, LVL_HIGH, 1050000, 3 },
135 [19] = { { 1728000, HFPLL, 1, 90 }, LVL_HIGH, 1050000, 3 },
136 [20] = { { 1804800, HFPLL, 1, 94 }, LVL_HIGH, 1050000, 3 },
137 [21] = { { 1881600, HFPLL, 1, 98 }, LVL_HIGH, 1050000, 3 },
138 [22] = { { 1958400, HFPLL, 1, 102 }, LVL_HIGH, 1050000, 3 },
139 [23] = { { 2035200, HFPLL, 1, 106 }, LVL_HIGH, 1050000, 3 },
140 [24] = { { 2112000, HFPLL, 1, 110 }, LVL_HIGH, 1050000, 3 },
141 [25] = { { 2188800, HFPLL, 1, 114 }, LVL_HIGH, 1050000, 3 },
Stephen Boyd2b73ee02012-09-11 21:08:13 -0700142 { }
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800143};
144
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700145static struct acpu_level acpu_freq_tbl[] __initdata = {
Matt Wagantalla133dbf2012-09-27 19:56:57 -0700146 { 1, { 300000, PLL_0, 0, 0 }, L2(0), 950000, 3200000 },
147 { 1, { 384000, HFPLL, 2, 40 }, L2(3), 950000, 3200000 },
148 { 1, { 460800, HFPLL, 2, 48 }, L2(3), 950000, 3200000 },
149 { 1, { 537600, HFPLL, 1, 28 }, L2(5), 950000, 3200000 },
150 { 1, { 576000, HFPLL, 1, 30 }, L2(5), 950000, 3200000 },
151 { 1, { 652800, HFPLL, 1, 34 }, L2(5), 950000, 3200000 },
152 { 1, { 729600, HFPLL, 1, 38 }, L2(5), 950000, 3200000 },
153 { 1, { 806400, HFPLL, 1, 42 }, L2(7), 950000, 3200000 },
154 { 1, { 883200, HFPLL, 1, 46 }, L2(7), 950000, 3200000 },
155 { 1, { 960000, HFPLL, 1, 50 }, L2(7), 950000, 3200000 },
156 { 1, { 1036800, HFPLL, 1, 54 }, L2(7), 950000, 3200000 },
157 { 1, { 1113600, HFPLL, 1, 58 }, L2(12), 1050000, 3200000 },
158 { 1, { 1190400, HFPLL, 1, 62 }, L2(12), 1050000, 3200000 },
159 { 1, { 1267200, HFPLL, 1, 66 }, L2(12), 1050000, 3200000 },
160 { 1, { 1344000, HFPLL, 1, 70 }, L2(15), 1050000, 3200000 },
161 { 1, { 1420800, HFPLL, 1, 74 }, L2(15), 1050000, 3200000 },
162 { 1, { 1497600, HFPLL, 1, 78 }, L2(16), 1050000, 3200000 },
163 { 0, { 1574400, HFPLL, 1, 82 }, L2(20), 1050000, 3200000 },
164 { 0, { 1651200, HFPLL, 1, 86 }, L2(20), 1050000, 3200000 },
165 { 0, { 1728000, HFPLL, 1, 90 }, L2(20), 1050000, 3200000 },
166 { 0, { 1804800, HFPLL, 1, 94 }, L2(25), 1050000, 3200000 },
167 { 0, { 1881600, HFPLL, 1, 98 }, L2(25), 1050000, 3200000 },
168 { 0, { 1958400, HFPLL, 1, 102 }, L2(25), 1050000, 3200000 },
169 { 0, { 1996800, HFPLL, 1, 104 }, L2(25), 1050000, 3200000 },
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800170 { 0, { 0 } }
171};
172
Patrick Daly02db5a82012-08-24 14:22:06 -0700173static struct pvs_table pvs_tables[NUM_SPEED_BINS][NUM_PVS] __initdata = {
174 [0][PVS_SLOW] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) },
175 [0][PVS_NOMINAL] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) },
176 [0][PVS_FAST] = { acpu_freq_tbl, sizeof(acpu_freq_tbl) },
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700177};
178
179static struct acpuclk_krait_params acpuclk_8974_params __initdata = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800180 .scalable = scalable,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700181 .scalable_size = sizeof(scalable),
182 .hfpll_data = &hfpll_data,
183 .pvs_tables = pvs_tables,
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800184 .l2_freq_tbl = l2_freq_tbl,
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700185 .l2_freq_tbl_size = sizeof(l2_freq_tbl),
186 .bus_scale = &bus_scale_data,
Matt Wagantall519e94f2012-09-17 17:51:06 -0700187 .pte_efuse_phys = 0xFC4B80B0,
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700188 .stby_khz = 300000,
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800189};
190
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700191static int __init acpuclk_8974_probe(struct platform_device *pdev)
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800192{
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700193 return acpuclk_krait_init(&pdev->dev, &acpuclk_8974_params);
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800194}
195
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700196static struct of_device_id acpuclk_8974_match_table[] = {
197 { .compatible = "qcom,acpuclk-8974" },
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800198 {}
199};
200
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700201static struct platform_driver acpuclk_8974_driver = {
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800202 .driver = {
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700203 .name = "acpuclk-8974",
204 .of_match_table = acpuclk_8974_match_table,
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800205 .owner = THIS_MODULE,
206 },
207};
208
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700209static int __init acpuclk_8974_init(void)
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800210{
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700211 return platform_driver_probe(&acpuclk_8974_driver,
212 acpuclk_8974_probe);
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800213}
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700214device_initcall(acpuclk_8974_init);