blob: 4cdfcf820c3713b4c863fbda06f07d2ec0b28c0d [file] [log] [blame]
Praveen Chidambaramc0750ca2012-01-08 10:03:28 -07001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __ARCH_ARM_MACH_MSM_SPM_H
14#define __ARCH_ARM_MACH_MSM_SPM_H
15enum {
16 MSM_SPM_MODE_DISABLED,
17 MSM_SPM_MODE_CLOCK_GATING,
18 MSM_SPM_MODE_POWER_RETENTION,
19 MSM_SPM_MODE_POWER_COLLAPSE,
20 MSM_SPM_MODE_NR
21};
22
23enum {
24 MSM_SPM_L2_MODE_DISABLED = MSM_SPM_MODE_DISABLED,
25 MSM_SPM_L2_MODE_RETENTION,
26 MSM_SPM_L2_MODE_GDHS,
27 MSM_SPM_L2_MODE_POWER_COLLAPSE,
28};
29
30#if defined(CONFIG_MSM_SPM_V1)
31
32enum {
33 MSM_SPM_REG_SAW_AVS_CTL,
34 MSM_SPM_REG_SAW_CFG,
35 MSM_SPM_REG_SAW_SPM_CTL,
36 MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY,
37 MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY,
38 MSM_SPM_REG_SAW_SLP_CLK_EN,
39 MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN,
40 MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN,
41 MSM_SPM_REG_SAW_SLP_CLMP_EN,
42 MSM_SPM_REG_SAW_SLP_RST_EN,
43 MSM_SPM_REG_SAW_SPM_MPM_CFG,
44 MSM_SPM_REG_NR_INITIALIZE,
45
46 MSM_SPM_REG_SAW_VCTL = MSM_SPM_REG_NR_INITIALIZE,
47 MSM_SPM_REG_SAW_STS,
48 MSM_SPM_REG_SAW_SPM_PMIC_CTL,
49 MSM_SPM_REG_NR
50};
51
52struct msm_spm_platform_data {
53 void __iomem *reg_base_addr;
54 uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE];
55
56 uint8_t awake_vlevel;
57 uint8_t retention_vlevel;
58 uint8_t collapse_vlevel;
59 uint8_t retention_mid_vlevel;
60 uint8_t collapse_mid_vlevel;
61
62 uint32_t vctl_timeout_us;
63};
64
65#elif defined(CONFIG_MSM_SPM_V2)
66
67enum {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068 MSM_SPM_REG_SAW2_CFG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069 MSM_SPM_REG_SAW2_AVS_CTL,
70 MSM_SPM_REG_SAW2_AVS_HYSTERESIS,
71 MSM_SPM_REG_SAW2_SPM_CTL,
72 MSM_SPM_REG_SAW2_PMIC_DLY,
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060073 MSM_SPM_REG_SAW2_AVS_LIMIT,
74 MSM_SPM_REG_SAW2_AVS_DLY,
75 MSM_SPM_REG_SAW2_SPM_DLY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076 MSM_SPM_REG_SAW2_PMIC_DATA_0,
77 MSM_SPM_REG_SAW2_PMIC_DATA_1,
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060078 MSM_SPM_REG_SAW2_PMIC_DATA_2,
79 MSM_SPM_REG_SAW2_PMIC_DATA_3,
80 MSM_SPM_REG_SAW2_PMIC_DATA_4,
81 MSM_SPM_REG_SAW2_PMIC_DATA_5,
82 MSM_SPM_REG_SAW2_PMIC_DATA_6,
83 MSM_SPM_REG_SAW2_PMIC_DATA_7,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084 MSM_SPM_REG_SAW2_RST,
85
Mahesh Sivasubramaniand740fab2012-01-20 13:49:47 -070086 MSM_SPM_REG_NR_INITIALIZE = MSM_SPM_REG_SAW2_RST,
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060087
Mahesh Sivasubramaniand740fab2012-01-20 13:49:47 -070088 MSM_SPM_REG_SAW2_ID,
89 MSM_SPM_REG_SAW2_SECURE,
90 MSM_SPM_REG_SAW2_STS0,
91 MSM_SPM_REG_SAW2_STS1,
92 MSM_SPM_REG_SAW2_VCTL,
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060093 MSM_SPM_REG_SAW2_SEQ_ENTRY,
94 MSM_SPM_REG_SAW2_SPM_STS,
95 MSM_SPM_REG_SAW2_AVS_STS,
96 MSM_SPM_REG_SAW2_PMIC_STS,
97 MSM_SPM_REG_SAW2_VERSION,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060099 MSM_SPM_REG_NR,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100};
101
102struct msm_spm_seq_entry {
103 uint32_t mode;
104 uint8_t *cmd;
105 bool notify_rpm;
106};
107
108struct msm_spm_platform_data {
109 void __iomem *reg_base_addr;
110 uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE];
111
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600112 uint32_t ver_reg;
113 uint32_t vctl_port;
114 uint32_t phase_port;
Praveen Chidambaram1dbe4952012-10-03 17:06:02 -0600115 uint32_t pfm_port;
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600116
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700117 uint8_t awake_vlevel;
118 uint32_t vctl_timeout_us;
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600119 uint32_t avs_timeout_us;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700120
121 uint32_t num_modes;
122 struct msm_spm_seq_entry *modes;
123};
124#endif
125
126#if defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2)
127
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600128/* Public functions */
129
130/**
131 * msm_spm_set_low_power_mode() - Configure SPM start address for low power mode
132 * @mode: SPM LPM mode to enter
133 * @notify_rpm: Notify RPM in this mode
134 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700135int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600136
137/**
138 * msm_spm_set_vdd(): Set core voltage
139 * @cpu: core id
140 * @vlevel: Encoded PMIC data.
141 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600143
144/**
Praveen Chidambaram4133ba12012-09-29 22:27:03 -0600145 * msm_spm_get_vdd(): Get core voltage
146 * @cpu: core id
147 * @return: Returns encoded PMIC data.
148 */
149unsigned int msm_spm_get_vdd(unsigned int cpu);
150
151/**
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600152 * msm_spm_turn_on_cpu_rail(): Power on cpu rail before turning on core
153 * @cpu: core id
154 */
Praveen Chidambaramc0750ca2012-01-08 10:03:28 -0700155int msm_spm_turn_on_cpu_rail(unsigned int cpu);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600157/* Internal low power management specific functions */
158
159/**
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600160 * msm_spm_reinit(): Reinitialize SPM registers
161 */
162void msm_spm_reinit(void);
163
164/**
165 * msm_spm_init(): Board initalization function
166 * @data: platform specific SPM register configuration data
167 * @nr_devs: Number of SPM devices being initialized
168 */
169int msm_spm_init(struct msm_spm_platform_data *data, int nr_devs);
170
171/**
172 * msm_spm_device_init(): Device tree initialization function
173 */
174int msm_spm_device_init(void);
175
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700176#if defined(CONFIG_MSM_L2_SPM)
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600177
178/* Public functions */
179
180/**
181 * msm_spm_l2_set_low_power_mode(): Configure L2 SPM start address
182 * for low power mode
183 * @mode: SPM LPM mode to enter
184 * @notify_rpm: Notify RPM in this mode
185 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700186int msm_spm_l2_set_low_power_mode(unsigned int mode, bool notify_rpm);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600187
188/**
189 * msm_spm_apcs_set_vdd(): Set Apps processor core sub-system voltage
190 * @vlevel: Encoded PMIC data.
191 */
192int msm_spm_apcs_set_vdd(unsigned int vlevel);
193
194/**
195 * msm_spm_apcs_set_phase(): Set number of SMPS phases.
196 * phase_cnt: Number of phases to be set active
197 */
198int msm_spm_apcs_set_phase(unsigned int phase_cnt);
199
Praveen Chidambaram1dbe4952012-10-03 17:06:02 -0600200/** msm_spm_enable_fts_lpm() : Enable FTS to switch to low power
201 * when the cores are in low power modes
202 * @mode: The mode configuration for FTS
203 */
204int msm_spm_enable_fts_lpm(uint32_t mode);
205
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600206/* Internal low power management specific functions */
207
208/**
209 * msm_spm_l2_init(): Board initialization function
210 * @data: SPM target specific register configuration
211 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212int msm_spm_l2_init(struct msm_spm_platform_data *data);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600213
214/**
215 * msm_spm_l2_reinit(): Reinitialize L2 SPM registers
216 */
Maheshkumar Sivasubramanian4ac23762011-11-02 10:03:06 -0600217void msm_spm_l2_reinit(void);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600218
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700219#else
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600220
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700221static inline int msm_spm_l2_set_low_power_mode(unsigned int mode,
222 bool notify_rpm)
223{
224 return -ENOSYS;
225}
226static inline int msm_spm_l2_init(struct msm_spm_platform_data *data)
227{
228 return -ENOSYS;
229}
Maheshkumar Sivasubramanian4ac23762011-11-02 10:03:06 -0600230static inline void msm_spm_l2_reinit(void)
231{
232 /* empty */
233}
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600234
235static inline int msm_spm_apcs_set_vdd(unsigned int vlevel)
236{
237 return -ENOSYS;
238}
239
240static inline int msm_spm_apcs_set_phase(unsigned int phase_cnt)
241{
242 return -ENOSYS;
243}
Praveen Chidambaram1dbe4952012-10-03 17:06:02 -0600244
245static inline int msm_spm_enable_fts_lpm(uint32_t mode)
246{
247 return -ENOSYS;
248}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700249#endif /* defined(CONFIG_MSM_L2_SPM) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700250#else /* defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251static inline int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm)
252{
253 return -ENOSYS;
254}
255
256static inline int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel)
257{
258 return -ENOSYS;
259}
260
Praveen Chidambaram4133ba12012-09-29 22:27:03 -0600261static inline unsigned int msm_spm_get_vdd(unsigned int cpu)
262{
263 return 0;
264}
265
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700266static inline void msm_spm_reinit(void)
267{
268 /* empty */
269}
270
Praveen Chidambaramc0750ca2012-01-08 10:03:28 -0700271static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu)
272{
273 return -ENOSYS;
274}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700275
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600276static inline int msm_spm_device_init(void)
277{
278 return -ENOSYS;
279}
280
281#endif /*defined(CONFIG_MSM_SPM_V1) || defined (CONFIG_MSM_SPM_V2) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282#endif /* __ARCH_ARM_MACH_MSM_SPM_H */