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