blob: 154303b6675f8e338b911c7ae4edf2992287ca8c [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;
115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116 uint8_t awake_vlevel;
117 uint32_t vctl_timeout_us;
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600118 uint32_t avs_timeout_us;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700119
120 uint32_t num_modes;
121 struct msm_spm_seq_entry *modes;
122};
123#endif
124
125#if defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2)
126
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600127/* Public functions */
128
129/**
130 * msm_spm_set_low_power_mode() - Configure SPM start address for low power mode
131 * @mode: SPM LPM mode to enter
132 * @notify_rpm: Notify RPM in this mode
133 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700134int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600135
136/**
137 * msm_spm_set_vdd(): Set core voltage
138 * @cpu: core id
139 * @vlevel: Encoded PMIC data.
140 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700141int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600142
143/**
144 * msm_spm_turn_on_cpu_rail(): Power on cpu rail before turning on core
145 * @cpu: core id
146 */
Praveen Chidambaramc0750ca2012-01-08 10:03:28 -0700147int msm_spm_turn_on_cpu_rail(unsigned int cpu);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700148
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600149
150/* Internal low power management specific functions */
151
152/**
153 * msm_spm_allow_x_cpu_set_vdd(): Turn on/off cross calling to set voltage
154 * @allowed: boolean to indicate on/off.
155 */
156void msm_spm_allow_x_cpu_set_vdd(bool allowed);
157
158/**
159 * msm_spm_reinit(): Reinitialize SPM registers
160 */
161void msm_spm_reinit(void);
162
163/**
164 * msm_spm_init(): Board initalization function
165 * @data: platform specific SPM register configuration data
166 * @nr_devs: Number of SPM devices being initialized
167 */
168int msm_spm_init(struct msm_spm_platform_data *data, int nr_devs);
169
170/**
171 * msm_spm_device_init(): Device tree initialization function
172 */
173int msm_spm_device_init(void);
174
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700175#if defined(CONFIG_MSM_L2_SPM)
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600176
177/* Public functions */
178
179/**
180 * msm_spm_l2_set_low_power_mode(): Configure L2 SPM start address
181 * for low power mode
182 * @mode: SPM LPM mode to enter
183 * @notify_rpm: Notify RPM in this mode
184 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700185int msm_spm_l2_set_low_power_mode(unsigned int mode, bool notify_rpm);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600186
187/**
188 * msm_spm_apcs_set_vdd(): Set Apps processor core sub-system voltage
189 * @vlevel: Encoded PMIC data.
190 */
191int msm_spm_apcs_set_vdd(unsigned int vlevel);
192
193/**
194 * msm_spm_apcs_set_phase(): Set number of SMPS phases.
195 * phase_cnt: Number of phases to be set active
196 */
197int msm_spm_apcs_set_phase(unsigned int phase_cnt);
198
199/* Internal low power management specific functions */
200
201/**
202 * msm_spm_l2_init(): Board initialization function
203 * @data: SPM target specific register configuration
204 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700205int msm_spm_l2_init(struct msm_spm_platform_data *data);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600206
207/**
208 * msm_spm_l2_reinit(): Reinitialize L2 SPM registers
209 */
Maheshkumar Sivasubramanian4ac23762011-11-02 10:03:06 -0600210void msm_spm_l2_reinit(void);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600211
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212#else
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600213
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700214static inline int msm_spm_l2_set_low_power_mode(unsigned int mode,
215 bool notify_rpm)
216{
217 return -ENOSYS;
218}
219static inline int msm_spm_l2_init(struct msm_spm_platform_data *data)
220{
221 return -ENOSYS;
222}
Maheshkumar Sivasubramanian4ac23762011-11-02 10:03:06 -0600223static inline void msm_spm_l2_reinit(void)
224{
225 /* empty */
226}
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600227
228static inline int msm_spm_apcs_set_vdd(unsigned int vlevel)
229{
230 return -ENOSYS;
231}
232
233static inline int msm_spm_apcs_set_phase(unsigned int phase_cnt)
234{
235 return -ENOSYS;
236}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700237#endif /* defined(CONFIG_MSM_L2_SPM) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700238#else /* defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700239static inline int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm)
240{
241 return -ENOSYS;
242}
243
244static inline int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel)
245{
246 return -ENOSYS;
247}
248
249static inline void msm_spm_reinit(void)
250{
251 /* empty */
252}
253
254static inline void msm_spm_allow_x_cpu_set_vdd(bool allowed)
255{
256 /* empty */
257}
258
Praveen Chidambaramc0750ca2012-01-08 10:03:28 -0700259static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu)
260{
261 return -ENOSYS;
262}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700263
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600264static inline int msm_spm_device_init(void)
265{
266 return -ENOSYS;
267}
268
269#endif /*defined(CONFIG_MSM_SPM_V1) || defined (CONFIG_MSM_SPM_V2) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700270#endif /* __ARCH_ARM_MACH_MSM_SPM_H */