blob: fbf1f5f1bed43965a3055b643b3e9ba802fa3d62 [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
17#define STBY_KHZ 1
18
19#define BW_MBPS(_bw) \
20 { \
21 .vectors = (struct msm_bus_vectors[]){ \
22 {\
23 .src = MSM_BUS_MASTER_AMPSS_M0, \
24 .dst = MSM_BUS_SLAVE_EBI_CH0, \
25 .ib = (_bw) * 1000000UL, \
26 }, \
27 { \
28 .src = MSM_BUS_MASTER_AMPSS_M1, \
29 .dst = MSM_BUS_SLAVE_EBI_CH0, \
30 .ib = (_bw) * 1000000UL, \
31 }, \
32 }, \
33 .num_paths = 2, \
34 }
35
36/**
37 * src_id - Clock source IDs.
38 */
39enum src_id {
40 PLL_0 = 0,
41 HFPLL,
42 QSB,
43};
44
45/**
46 * enum pvs - IDs to distinguish between CPU frequency tables.
47 */
48enum pvs {
49 PVS_SLOW = 0,
50 PVS_NOMINAL,
51 PVS_FAST,
52 PVS_UNKNOWN,
53 NUM_PVS
54};
55
56/**
57 * enum scalables - IDs of frequency scalable hardware blocks.
58 */
59enum scalables {
60 CPU0 = 0,
61 CPU1,
62 CPU2,
63 CPU3,
64 L2,
65};
66
67
68/**
69 * enum hfpll_vdd_level - IDs of HFPLL voltage levels.
70 */
71enum hfpll_vdd_levels {
72 HFPLL_VDD_NONE,
73 HFPLL_VDD_LOW,
74 HFPLL_VDD_NOM,
75 NUM_HFPLL_VDD
76};
77
78/**
79 * enum vregs - IDs of voltage regulators.
80 */
81enum vregs {
82 VREG_CORE,
83 VREG_MEM,
84 VREG_DIG,
85 VREG_HFPLL_A,
86 VREG_HFPLL_B,
87 NUM_VREG
88};
89
90/**
91 * struct vreg - Voltage regulator data.
92 * @name: Name of requlator.
93 * @max_vdd: Limit the maximum-settable voltage.
94 * @rpm_vreg_id: ID to use with rpm_vreg_*() APIs.
95 * @reg: Regulator handle.
96 * @cur_vdd: Last-set voltage in uV.
97 * @peak_ua: Maximum current draw expected in uA.
98 */
99struct vreg {
100 const char name[15];
101 const int max_vdd;
102 const int peak_ua;
103 const int rpm_vreg_voter;
104 const int rpm_vreg_id;
105 struct regulator *reg;
106 int cur_vdd;
107};
108
109/**
110 * struct core_speed - Clock tree and configuration parameters.
111 * @khz: Clock rate in KHz.
112 * @src: Clock source ID.
113 * @pri_src_sel: Input to select on the primary MUX.
114 * @sec_src_sel: Input to select on the secondary MUX.
115 * @pll_l_val: HFPLL "L" value to be applied when an HFPLL source is selected.
116 */
117struct core_speed {
118 const unsigned long khz;
119 const int src;
120 const u32 pri_src_sel;
121 const u32 sec_src_sel;
122 const u32 pll_l_val;
123};
124
125/**
126 * struct l2_level - L2 clock rate and associated voltage and b/w requirements.
127 * @speed: L2 clock configuration.
128 * @vdd_dig: vdd_dig voltage in uV.
129 * @vdd_mem: vdd_mem voltage in uV.
130 * @bw_level: Bandwidth performance level number.
131 */
132struct l2_level {
133 const struct core_speed speed;
134 const int vdd_dig;
135 const int vdd_mem;
136 const unsigned int bw_level;
137};
138
139/**
140 * struct acpu_level - CPU clock rate and L2 rate and voltage requirements.
141 * @use_for_scaling: Flag indicating whether or not the level should be used.
142 * @speed: CPU clock configuration.
143 * @l2_level: L2 configuration to use.
144 * @vdd_core: CPU core voltage in uV.
145 */
146struct acpu_level {
147 const int use_for_scaling;
148 const struct core_speed speed;
149 const struct l2_level *l2_level;
150 const int vdd_core;
151};
152
153/**
154 * struct hfpll_data - Descriptive data of HFPLL hardware.
155 * @mode_offset: Mode register offset from base address.
156 * @l_offset: "L" value register offset from base address.
157 * @m_offset: "M" value register offset from base address.
158 * @n_offset: "N" value register offset from base address.
159 * @config_offset: Configuration register offset from base address.
160 * @config_val: Value to initialize the @config_offset register to.
161 * @vdd: voltage requirements for each VDD level.
162 */
163struct hfpll_data {
164 const u32 mode_offset;
165 const u32 l_offset;
166 const u32 m_offset;
167 const u32 n_offset;
168 const u32 config_offset;
169 const u32 config_val;
170 const u32 low_vdd_l_max;
171 const int vdd[NUM_HFPLL_VDD];
172};
173
174/**
175 * struct scalable - Register locations and state associated with a scalable HW.
176 * @hfpll_phys_base: Physical base address of HFPLL register.
177 * @hfpll_base: Virtual base address of HFPLL registers.
178 * @aux_clk_sel_addr: Virtual address of auxiliary MUX.
179 * @aux_clk_sel: Auxiliary mux input to select at boot.
180 * @l2cpmr_iaddr: Indirect address of the CPMR MUX/divider CP15 register.
181 * @hfpll_data: Descriptive data of HFPLL hardware.
182 * @cur_speed: Pointer to currently-set speed.
183 * @l2_vote: L2 performance level vote associate with the current CPU speed.
184 * @vreg: Array of voltage regulators needed by the scalable.
185 */
186struct scalable {
187 const u32 hfpll_phys_base;
188 void __iomem *hfpll_base;
189 void __iomem *aux_clk_sel_addr;
190 const u32 aux_clk_sel;
191 const u32 l2cpmr_iaddr;
192 const struct hfpll_data *hfpll_data;
193 const struct core_speed *cur_speed;
194 const struct l2_level *l2_vote;
195 struct vreg vreg[NUM_VREG];
196};
197
198/**
199 * struct acpuclk_krait_params - SoC specific driver parameters.
200 * @scalable: Array of scalables.
201 * @pvs_acpu_freq_tbl: Array of CPU frequency tables.
202 * @l2_freq_tbl: L2 frequency table.
203 * @l2_freq_tbl_size: Number of rows in @l2_freq_tbl.
204 * @qfprom_phys_base: Physical base address of QFPROM.
205 * @bus_scale_data: MSM bus driver parameters.
206 */
207struct acpuclk_krait_params {
208 struct scalable *scalable;
209 const struct acpu_level *pvs_acpu_freq_tbl[NUM_PVS];
210 const struct l2_level *l2_freq_tbl;
211 const size_t l2_freq_tbl_size;
212 const u32 qfprom_phys_base;
213 struct msm_bus_scale_pdata *bus_scale_data;
214};
215
216/**
217 * acpuclk_krait_init - Initialize the Krait CPU clock driver give SoC params.
218 */
219extern int acpuclk_krait_init(struct device *dev,
220 const struct acpuclk_krait_params *params);
221
222#endif