1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
/* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __ARCH_ARM_MACH_MSM_SPM_H
#define __ARCH_ARM_MACH_MSM_SPM_H
enum {
MSM_SPM_MODE_DISABLED,
MSM_SPM_MODE_CLOCK_GATING,
MSM_SPM_MODE_POWER_RETENTION,
MSM_SPM_MODE_POWER_COLLAPSE,
MSM_SPM_MODE_NR
};
enum {
MSM_SPM_L2_MODE_DISABLED = MSM_SPM_MODE_DISABLED,
MSM_SPM_L2_MODE_RETENTION,
MSM_SPM_L2_MODE_GDHS,
MSM_SPM_L2_MODE_POWER_COLLAPSE,
};
#if defined(CONFIG_MSM_SPM_V1)
enum {
MSM_SPM_REG_SAW_AVS_CTL,
MSM_SPM_REG_SAW_CFG,
MSM_SPM_REG_SAW_SPM_CTL,
MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY,
MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY,
MSM_SPM_REG_SAW_SLP_CLK_EN,
MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN,
MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN,
MSM_SPM_REG_SAW_SLP_CLMP_EN,
MSM_SPM_REG_SAW_SLP_RST_EN,
MSM_SPM_REG_SAW_SPM_MPM_CFG,
MSM_SPM_REG_NR_INITIALIZE,
MSM_SPM_REG_SAW_VCTL = MSM_SPM_REG_NR_INITIALIZE,
MSM_SPM_REG_SAW_STS,
MSM_SPM_REG_SAW_SPM_PMIC_CTL,
MSM_SPM_REG_NR
};
struct msm_spm_platform_data {
void __iomem *reg_base_addr;
uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE];
uint8_t awake_vlevel;
uint8_t retention_vlevel;
uint8_t collapse_vlevel;
uint8_t retention_mid_vlevel;
uint8_t collapse_mid_vlevel;
uint32_t vctl_timeout_us;
};
#elif defined(CONFIG_MSM_SPM_V2)
enum {
MSM_SPM_REG_SAW2_CFG,
MSM_SPM_REG_SAW2_AVS_CTL,
MSM_SPM_REG_SAW2_AVS_HYSTERESIS,
MSM_SPM_REG_SAW2_SPM_CTL,
MSM_SPM_REG_SAW2_PMIC_DLY,
MSM_SPM_REG_SAW2_AVS_LIMIT,
MSM_SPM_REG_SAW2_AVS_DLY,
MSM_SPM_REG_SAW2_SPM_DLY,
MSM_SPM_REG_SAW2_PMIC_DATA_0,
MSM_SPM_REG_SAW2_PMIC_DATA_1,
MSM_SPM_REG_SAW2_PMIC_DATA_2,
MSM_SPM_REG_SAW2_PMIC_DATA_3,
MSM_SPM_REG_SAW2_PMIC_DATA_4,
MSM_SPM_REG_SAW2_PMIC_DATA_5,
MSM_SPM_REG_SAW2_PMIC_DATA_6,
MSM_SPM_REG_SAW2_PMIC_DATA_7,
MSM_SPM_REG_SAW2_RST,
MSM_SPM_REG_NR_INITIALIZE = MSM_SPM_REG_SAW2_RST,
MSM_SPM_REG_SAW2_ID,
MSM_SPM_REG_SAW2_SECURE,
MSM_SPM_REG_SAW2_STS0,
MSM_SPM_REG_SAW2_STS1,
MSM_SPM_REG_SAW2_VCTL,
MSM_SPM_REG_SAW2_SEQ_ENTRY,
MSM_SPM_REG_SAW2_SPM_STS,
MSM_SPM_REG_SAW2_AVS_STS,
MSM_SPM_REG_SAW2_PMIC_STS,
MSM_SPM_REG_SAW2_VERSION,
MSM_SPM_REG_NR,
};
struct msm_spm_seq_entry {
uint32_t mode;
uint8_t *cmd;
bool notify_rpm;
};
struct msm_spm_platform_data {
void __iomem *reg_base_addr;
uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE];
uint32_t ver_reg;
uint32_t vctl_port;
uint32_t phase_port;
uint8_t awake_vlevel;
uint32_t vctl_timeout_us;
uint32_t avs_timeout_us;
uint32_t num_modes;
struct msm_spm_seq_entry *modes;
};
#endif
#if defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2)
/* Public functions */
/**
* msm_spm_set_low_power_mode() - Configure SPM start address for low power mode
* @mode: SPM LPM mode to enter
* @notify_rpm: Notify RPM in this mode
*/
int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm);
/**
* msm_spm_set_vdd(): Set core voltage
* @cpu: core id
* @vlevel: Encoded PMIC data.
*/
int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel);
/**
* msm_spm_get_vdd(): Get core voltage
* @cpu: core id
* @return: Returns encoded PMIC data.
*/
unsigned int msm_spm_get_vdd(unsigned int cpu);
/**
* msm_spm_turn_on_cpu_rail(): Power on cpu rail before turning on core
* @cpu: core id
*/
int msm_spm_turn_on_cpu_rail(unsigned int cpu);
/* Internal low power management specific functions */
/**
* msm_spm_reinit(): Reinitialize SPM registers
*/
void msm_spm_reinit(void);
/**
* msm_spm_init(): Board initalization function
* @data: platform specific SPM register configuration data
* @nr_devs: Number of SPM devices being initialized
*/
int msm_spm_init(struct msm_spm_platform_data *data, int nr_devs);
/**
* msm_spm_device_init(): Device tree initialization function
*/
int msm_spm_device_init(void);
#if defined(CONFIG_MSM_L2_SPM)
/* Public functions */
/**
* msm_spm_l2_set_low_power_mode(): Configure L2 SPM start address
* for low power mode
* @mode: SPM LPM mode to enter
* @notify_rpm: Notify RPM in this mode
*/
int msm_spm_l2_set_low_power_mode(unsigned int mode, bool notify_rpm);
/**
* msm_spm_apcs_set_vdd(): Set Apps processor core sub-system voltage
* @vlevel: Encoded PMIC data.
*/
int msm_spm_apcs_set_vdd(unsigned int vlevel);
/**
* msm_spm_apcs_set_phase(): Set number of SMPS phases.
* phase_cnt: Number of phases to be set active
*/
int msm_spm_apcs_set_phase(unsigned int phase_cnt);
/* Internal low power management specific functions */
/**
* msm_spm_l2_init(): Board initialization function
* @data: SPM target specific register configuration
*/
int msm_spm_l2_init(struct msm_spm_platform_data *data);
/**
* msm_spm_l2_reinit(): Reinitialize L2 SPM registers
*/
void msm_spm_l2_reinit(void);
#else
static inline int msm_spm_l2_set_low_power_mode(unsigned int mode,
bool notify_rpm)
{
return -ENOSYS;
}
static inline int msm_spm_l2_init(struct msm_spm_platform_data *data)
{
return -ENOSYS;
}
static inline void msm_spm_l2_reinit(void)
{
/* empty */
}
static inline int msm_spm_apcs_set_vdd(unsigned int vlevel)
{
return -ENOSYS;
}
static inline int msm_spm_apcs_set_phase(unsigned int phase_cnt)
{
return -ENOSYS;
}
#endif /* defined(CONFIG_MSM_L2_SPM) */
#else /* defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2) */
static inline int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm)
{
return -ENOSYS;
}
static inline int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel)
{
return -ENOSYS;
}
static inline unsigned int msm_spm_get_vdd(unsigned int cpu)
{
return 0;
}
static inline void msm_spm_reinit(void)
{
/* empty */
}
static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu)
{
return -ENOSYS;
}
static inline int msm_spm_device_init(void)
{
return -ENOSYS;
}
#endif /*defined(CONFIG_MSM_SPM_V1) || defined (CONFIG_MSM_SPM_V2) */
#endif /* __ARCH_ARM_MACH_MSM_SPM_H */
|