blob: 4b6834dbe8084a0d81cedcd97a3266f87bf49ab7 [file] [log] [blame]
Matt Wagantalle9b715a2012-01-04 18:16:14 -08001/*
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#ifndef __ARCH_ARM_MACH_MSM_ACPUCLOCK_KRAIT_H
15#define __ARCH_ARM_MACH_MSM_ACPUCLOCK_KRAIT_H
16
Matt Wagantall600ea502012-06-08 18:49:53 -070017#define L2(x) (x)
Matt Wagantalle9b715a2012-01-04 18:16:14 -080018#define BW_MBPS(_bw) \
19 { \
20 .vectors = (struct msm_bus_vectors[]){ \
21 {\
22 .src = MSM_BUS_MASTER_AMPSS_M0, \
23 .dst = MSM_BUS_SLAVE_EBI_CH0, \
Rajeev Kulkarnic9162002012-11-22 00:42:58 -080024 .ib = (_bw) * 1000000ULL, \
Matt Wagantalle9b715a2012-01-04 18:16:14 -080025 }, \
26 { \
27 .src = MSM_BUS_MASTER_AMPSS_M1, \
28 .dst = MSM_BUS_SLAVE_EBI_CH0, \
Rajeev Kulkarnic9162002012-11-22 00:42:58 -080029 .ib = (_bw) * 1000000ULL, \
Matt Wagantalle9b715a2012-01-04 18:16:14 -080030 }, \
31 }, \
32 .num_paths = 2, \
33 }
34
35/**
36 * src_id - Clock source IDs.
37 */
38enum src_id {
39 PLL_0 = 0,
40 HFPLL,
Matt Wagantall06e4a1f2012-06-07 18:38:13 -070041 PLL_8,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080042};
43
44/**
45 * enum pvs - IDs to distinguish between CPU frequency tables.
46 */
47enum pvs {
48 PVS_SLOW = 0,
Patrick Daly02db5a82012-08-24 14:22:06 -070049 PVS_NOMINAL = 1,
50 PVS_FAST = 3,
51 PVS_FASTER = 4,
52 NUM_PVS = 7
Matt Wagantalle9b715a2012-01-04 18:16:14 -080053};
54
55/**
Patrick Daly02db5a82012-08-24 14:22:06 -070056 * The maximum number of speed bins.
57 */
58#define NUM_SPEED_BINS (16)
59
60/**
Matt Wagantalle9b715a2012-01-04 18:16:14 -080061 * enum scalables - IDs of frequency scalable hardware blocks.
62 */
63enum scalables {
64 CPU0 = 0,
65 CPU1,
66 CPU2,
67 CPU3,
68 L2,
69};
70
71
72/**
73 * enum hfpll_vdd_level - IDs of HFPLL voltage levels.
74 */
75enum hfpll_vdd_levels {
76 HFPLL_VDD_NONE,
77 HFPLL_VDD_LOW,
78 HFPLL_VDD_NOM,
Matt Wagantall87465f52012-07-23 22:03:06 -070079 HFPLL_VDD_HIGH,
Matt Wagantalle9b715a2012-01-04 18:16:14 -080080 NUM_HFPLL_VDD
81};
82
83/**
84 * enum vregs - IDs of voltage regulators.
85 */
86enum vregs {
87 VREG_CORE,
88 VREG_MEM,
89 VREG_DIG,
90 VREG_HFPLL_A,
91 VREG_HFPLL_B,
92 NUM_VREG
93};
94
95/**
96 * struct vreg - Voltage regulator data.
97 * @name: Name of requlator.
98 * @max_vdd: Limit the maximum-settable voltage.
Matt Wagantalle9b715a2012-01-04 18:16:14 -080099 * @reg: Regulator handle.
Matt Wagantall75473eb2012-05-31 15:23:22 -0700100 * @rpm_reg: RPM Regulator handle.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800101 * @cur_vdd: Last-set voltage in uV.
Matt Wagantall6d9c4162012-07-16 18:58:16 -0700102 * @cur_ua: Last-set current in uA.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800103 */
104struct vreg {
Matt Wagantall75473eb2012-05-31 15:23:22 -0700105 const char *name;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800106 const int max_vdd;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800107 struct regulator *reg;
Matt Wagantall75473eb2012-05-31 15:23:22 -0700108 struct rpm_regulator *rpm_reg;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800109 int cur_vdd;
Matt Wagantall6d9c4162012-07-16 18:58:16 -0700110 int cur_ua;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800111};
112
113/**
114 * struct core_speed - Clock tree and configuration parameters.
115 * @khz: Clock rate in KHz.
116 * @src: Clock source ID.
117 * @pri_src_sel: Input to select on the primary MUX.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800118 * @pll_l_val: HFPLL "L" value to be applied when an HFPLL source is selected.
119 */
120struct core_speed {
Matt Wagantall9c8cb6e2012-07-13 19:39:15 -0700121 unsigned long khz;
122 int src;
123 u32 pri_src_sel;
Matt Wagantall9c8cb6e2012-07-13 19:39:15 -0700124 u32 pll_l_val;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800125};
126
127/**
128 * struct l2_level - L2 clock rate and associated voltage and b/w requirements.
129 * @speed: L2 clock configuration.
130 * @vdd_dig: vdd_dig voltage in uV.
131 * @vdd_mem: vdd_mem voltage in uV.
132 * @bw_level: Bandwidth performance level number.
133 */
134struct l2_level {
135 const struct core_speed speed;
136 const int vdd_dig;
137 const int vdd_mem;
138 const unsigned int bw_level;
139};
140
141/**
142 * struct acpu_level - CPU clock rate and L2 rate and voltage requirements.
143 * @use_for_scaling: Flag indicating whether or not the level should be used.
144 * @speed: CPU clock configuration.
145 * @l2_level: L2 configuration to use.
146 * @vdd_core: CPU core voltage in uV.
Matt Wagantall6d9c4162012-07-16 18:58:16 -0700147 * @ua_core: CPU core current consumption in uA.
Stephen Boydc13b6792012-09-14 11:25:34 -0700148 * @avsdscr_setting: AVS DSCR configuration.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800149 */
150struct acpu_level {
151 const int use_for_scaling;
152 const struct core_speed speed;
Matt Wagantall600ea502012-06-08 18:49:53 -0700153 const unsigned int l2_level;
Matt Wagantall06e4a1f2012-06-07 18:38:13 -0700154 int vdd_core;
Matt Wagantall6d9c4162012-07-16 18:58:16 -0700155 int ua_core;
Stephen Boydc13b6792012-09-14 11:25:34 -0700156 unsigned int avsdscr_setting;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800157};
158
159/**
160 * struct hfpll_data - Descriptive data of HFPLL hardware.
161 * @mode_offset: Mode register offset from base address.
162 * @l_offset: "L" value register offset from base address.
163 * @m_offset: "M" value register offset from base address.
164 * @n_offset: "N" value register offset from base address.
165 * @config_offset: Configuration register offset from base address.
166 * @config_val: Value to initialize the @config_offset register to.
Matt Wagantalla77b7f32012-07-18 16:32:01 -0700167 * @has_user_reg: Indicates the presence of an addition config register.
168 * @user_offset: User register offset from base address, if applicable.
169 * @user_val: Value to initialize the @user_offset register to.
170 * @user_vco_mask: Bit in the @user_offset to enable high-frequency VCO mode.
Matt Wagantall06e4a1f2012-06-07 18:38:13 -0700171 * @has_droop_ctl: Indicates the presence of a voltage droop controller.
172 * @droop_offset: Droop controller register offset from base address.
173 * @droop_val: Value to initialize the @config_offset register to.
174 * @low_vdd_l_max: Maximum "L" value supported at HFPLL_VDD_LOW.
Matt Wagantall87465f52012-07-23 22:03:06 -0700175 * @nom_vdd_l_max: Maximum "L" value supported at HFPLL_VDD_NOM.
Matt Wagantalla77b7f32012-07-18 16:32:01 -0700176 * @low_vco_l_max: Maximum "L" value supported in low-frequency VCO mode.
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700177 * @vdd: voltage requirements for each VDD level for the L2 PLL.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800178 */
179struct hfpll_data {
180 const u32 mode_offset;
181 const u32 l_offset;
182 const u32 m_offset;
183 const u32 n_offset;
184 const u32 config_offset;
185 const u32 config_val;
Matt Wagantalla77b7f32012-07-18 16:32:01 -0700186 const bool has_user_reg;
187 const u32 user_offset;
188 const u32 user_val;
189 const u32 user_vco_mask;
Matt Wagantall06e4a1f2012-06-07 18:38:13 -0700190 const bool has_droop_ctl;
191 const u32 droop_offset;
192 const u32 droop_val;
Patrick Daly02db5a82012-08-24 14:22:06 -0700193 u32 low_vdd_l_max;
194 u32 nom_vdd_l_max;
Matt Wagantalla77b7f32012-07-18 16:32:01 -0700195 const u32 low_vco_l_max;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800196 const int vdd[NUM_HFPLL_VDD];
197};
198
199/**
200 * struct scalable - Register locations and state associated with a scalable HW.
201 * @hfpll_phys_base: Physical base address of HFPLL register.
202 * @hfpll_base: Virtual base address of HFPLL registers.
Matt Wagantall06e4a1f2012-06-07 18:38:13 -0700203 * @aux_clk_sel_phys: Physical address of auxiliary MUX.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800204 * @aux_clk_sel: Auxiliary mux input to select at boot.
Matt Wagantalla133dbf2012-09-27 19:56:57 -0700205 * @sec_clk_sel: Secondary mux input to select at boot.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800206 * @l2cpmr_iaddr: Indirect address of the CPMR MUX/divider CP15 register.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800207 * @cur_speed: Pointer to currently-set speed.
208 * @l2_vote: L2 performance level vote associate with the current CPU speed.
209 * @vreg: Array of voltage regulators needed by the scalable.
Matt Wagantall754ee272012-06-18 13:40:26 -0700210 * @initialized: Flag set to true when per_cpu_init() has been called.
Stephen Boydc13b6792012-09-14 11:25:34 -0700211 * @avs_enabled: True if avs is enabled for the scalabale. False otherwise.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800212 */
213struct scalable {
Matt Wagantall06e4a1f2012-06-07 18:38:13 -0700214 const phys_addr_t hfpll_phys_base;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800215 void __iomem *hfpll_base;
Matt Wagantall06e4a1f2012-06-07 18:38:13 -0700216 const phys_addr_t aux_clk_sel_phys;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800217 const u32 aux_clk_sel;
Matt Wagantalla133dbf2012-09-27 19:56:57 -0700218 const u32 sec_clk_sel;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800219 const u32 l2cpmr_iaddr;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800220 const struct core_speed *cur_speed;
Matt Wagantall600ea502012-06-08 18:49:53 -0700221 unsigned int l2_vote;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800222 struct vreg vreg[NUM_VREG];
Matt Wagantall754ee272012-06-18 13:40:26 -0700223 bool initialized;
Stephen Boydc13b6792012-09-14 11:25:34 -0700224 bool avs_enabled;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800225};
226
227/**
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700228 * struct pvs_table - CPU performance level table and size.
229 * @table: CPU performance level table
230 * @size: sizeof(@table)
Matt Wagantall9515bc22012-07-19 18:13:40 -0700231 * @boost_uv: Voltage boost amount
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700232 */
233struct pvs_table {
234 struct acpu_level *table;
235 size_t size;
Matt Wagantall9515bc22012-07-19 18:13:40 -0700236 int boost_uv;
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700237};
238
239/**
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800240 * struct acpuclk_krait_params - SoC specific driver parameters.
241 * @scalable: Array of scalables.
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700242 * @scalable_size: Size of @scalable.
243 * @hfpll_data: HFPLL configuration data.
Patrick Daly02db5a82012-08-24 14:22:06 -0700244 * @pvs_tables: 2D array of CPU frequency tables.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800245 * @l2_freq_tbl: L2 frequency table.
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700246 * @l2_freq_tbl_size: Size of @l2_freq_tbl.
Matt Wagantall519e94f2012-09-17 17:51:06 -0700247 * @pte_efuse_phys: Physical address of PTE EFUSE.
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700248 * @bus_scale: MSM bus driver parameters.
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700249 * @stby_khz: KHz value corresponding to an always-on clock source.
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800250 */
251struct acpuclk_krait_params {
252 struct scalable *scalable;
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700253 size_t scalable_size;
254 struct hfpll_data *hfpll_data;
Patrick Daly02db5a82012-08-24 14:22:06 -0700255 struct pvs_table (*pvs_tables)[NUM_PVS];
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700256 struct l2_level *l2_freq_tbl;
257 size_t l2_freq_tbl_size;
Matt Wagantall519e94f2012-09-17 17:51:06 -0700258 phys_addr_t pte_efuse_phys;
Matt Wagantall1f3762d2012-06-08 19:08:48 -0700259 struct msm_bus_scale_pdata *bus_scale;
Matt Wagantallb7c231b2012-07-24 18:40:17 -0700260 unsigned long stby_khz;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800261};
262
263/**
Patrick Daly65213ed2012-08-28 13:36:31 -0700264 * struct acpuclk_platform_data - PMIC configuration data.
265 * @uses_pm8917: Boolean indicates presence of pm8917.
266 */
267struct acpuclk_platform_data {
268 bool uses_pm8917;
269};
270
271/**
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800272 * acpuclk_krait_init - Initialize the Krait CPU clock driver give SoC params.
273 */
274extern int acpuclk_krait_init(struct device *dev,
275 const struct acpuclk_krait_params *params);
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800276#endif