blob: 19629defc736459580514584d3bf037c3b4cdf86 [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.
Matt Wagantalle9b715a2012-01-04 18:16:14 -080094 * @reg: Regulator handle.
Matt Wagantall75473eb2012-05-31 15:23:22 -070095 * @rpm_reg: RPM Regulator handle.
Matt Wagantalle9b715a2012-01-04 18:16:14 -080096 * @cur_vdd: Last-set voltage in uV.
97 * @peak_ua: Maximum current draw expected in uA.
98 */
99struct vreg {
Matt Wagantall75473eb2012-05-31 15:23:22 -0700100 const char *name;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800101 const int max_vdd;
102 const int peak_ua;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800103 struct regulator *reg;
Matt Wagantall75473eb2012-05-31 15:23:22 -0700104 struct rpm_regulator *rpm_reg;
Matt Wagantalle9b715a2012-01-04 18:16:14 -0800105 int cur_vdd;
106};
107
108/**
109 * struct core_speed - Clock tree and configuration parameters.
110 * @khz: Clock rate in KHz.
111 * @src: Clock source ID.
112 * @pri_src_sel: Input to select on the primary MUX.
113 * @sec_src_sel: Input to select on the secondary MUX.
114 * @pll_l_val: HFPLL "L" value to be applied when an HFPLL source is selected.
115 */
116struct core_speed {
117 const unsigned long khz;
118 const int src;
119 const u32 pri_src_sel;
120 const u32 sec_src_sel;
121 const u32 pll_l_val;
122};
123
124/**
125 * struct l2_level - L2 clock rate and associated voltage and b/w requirements.
126 * @speed: L2 clock configuration.
127 * @vdd_dig: vdd_dig voltage in uV.
128 * @vdd_mem: vdd_mem voltage in uV.
129 * @bw_level: Bandwidth performance level number.
130 */
131struct l2_level {
132 const struct core_speed speed;
133 const int vdd_dig;
134 const int vdd_mem;
135 const unsigned int bw_level;
136};
137
138/**
139 * struct acpu_level - CPU clock rate and L2 rate and voltage requirements.
140 * @use_for_scaling: Flag indicating whether or not the level should be used.
141 * @speed: CPU clock configuration.
142 * @l2_level: L2 configuration to use.
143 * @vdd_core: CPU core voltage in uV.
144 */
145struct acpu_level {
146 const int use_for_scaling;
147 const struct core_speed speed;
148 const struct l2_level *l2_level;
149 const int vdd_core;
150};
151
152/**
153 * struct hfpll_data - Descriptive data of HFPLL hardware.
154 * @mode_offset: Mode register offset from base address.
155 * @l_offset: "L" value register offset from base address.
156 * @m_offset: "M" value register offset from base address.
157 * @n_offset: "N" value register offset from base address.
158 * @config_offset: Configuration register offset from base address.
159 * @config_val: Value to initialize the @config_offset register to.
160 * @vdd: voltage requirements for each VDD level.
161 */
162struct hfpll_data {
163 const u32 mode_offset;
164 const u32 l_offset;
165 const u32 m_offset;
166 const u32 n_offset;
167 const u32 config_offset;
168 const u32 config_val;
169 const u32 low_vdd_l_max;
170 const int vdd[NUM_HFPLL_VDD];
171};
172
173/**
174 * struct scalable - Register locations and state associated with a scalable HW.
175 * @hfpll_phys_base: Physical base address of HFPLL register.
176 * @hfpll_base: Virtual base address of HFPLL registers.
177 * @aux_clk_sel_addr: Virtual address of auxiliary MUX.
178 * @aux_clk_sel: Auxiliary mux input to select at boot.
179 * @l2cpmr_iaddr: Indirect address of the CPMR MUX/divider CP15 register.
180 * @hfpll_data: Descriptive data of HFPLL hardware.
181 * @cur_speed: Pointer to currently-set speed.
182 * @l2_vote: L2 performance level vote associate with the current CPU speed.
183 * @vreg: Array of voltage regulators needed by the scalable.
184 */
185struct scalable {
186 const u32 hfpll_phys_base;
187 void __iomem *hfpll_base;
188 void __iomem *aux_clk_sel_addr;
189 const u32 aux_clk_sel;
190 const u32 l2cpmr_iaddr;
191 const struct hfpll_data *hfpll_data;
192 const struct core_speed *cur_speed;
193 const struct l2_level *l2_vote;
194 struct vreg vreg[NUM_VREG];
195};
196
197/**
198 * struct acpuclk_krait_params - SoC specific driver parameters.
199 * @scalable: Array of scalables.
200 * @pvs_acpu_freq_tbl: Array of CPU frequency tables.
201 * @l2_freq_tbl: L2 frequency table.
202 * @l2_freq_tbl_size: Number of rows in @l2_freq_tbl.
203 * @qfprom_phys_base: Physical base address of QFPROM.
204 * @bus_scale_data: MSM bus driver parameters.
205 */
206struct acpuclk_krait_params {
207 struct scalable *scalable;
208 const struct acpu_level *pvs_acpu_freq_tbl[NUM_PVS];
209 const struct l2_level *l2_freq_tbl;
210 const size_t l2_freq_tbl_size;
211 const u32 qfprom_phys_base;
212 struct msm_bus_scale_pdata *bus_scale_data;
213};
214
215/**
216 * acpuclk_krait_init - Initialize the Krait CPU clock driver give SoC params.
217 */
218extern int acpuclk_krait_init(struct device *dev,
219 const struct acpuclk_krait_params *params);
220
221#endif