blob: 176940277884f9145b43eaa9637579386eb0f1bd [file] [log] [blame]
Praveen Chidambaram48197dd2013-03-21 15:51:43 -06001/* Copyright (c) 2010-2013, The Linux Foundation. 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,
Murali Nalajala82123b02013-10-04 16:00:19 +053027 MSM_SPM_L2_MODE_PC_NO_RPM,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028 MSM_SPM_L2_MODE_POWER_COLLAPSE,
29};
30
31#if defined(CONFIG_MSM_SPM_V1)
32
33enum {
34 MSM_SPM_REG_SAW_AVS_CTL,
35 MSM_SPM_REG_SAW_CFG,
36 MSM_SPM_REG_SAW_SPM_CTL,
37 MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY,
38 MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY,
39 MSM_SPM_REG_SAW_SLP_CLK_EN,
40 MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN,
41 MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN,
42 MSM_SPM_REG_SAW_SLP_CLMP_EN,
43 MSM_SPM_REG_SAW_SLP_RST_EN,
44 MSM_SPM_REG_SAW_SPM_MPM_CFG,
45 MSM_SPM_REG_NR_INITIALIZE,
46
47 MSM_SPM_REG_SAW_VCTL = MSM_SPM_REG_NR_INITIALIZE,
48 MSM_SPM_REG_SAW_STS,
49 MSM_SPM_REG_SAW_SPM_PMIC_CTL,
50 MSM_SPM_REG_NR
51};
52
53struct msm_spm_platform_data {
54 void __iomem *reg_base_addr;
55 uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE];
56
57 uint8_t awake_vlevel;
58 uint8_t retention_vlevel;
59 uint8_t collapse_vlevel;
60 uint8_t retention_mid_vlevel;
61 uint8_t collapse_mid_vlevel;
62
63 uint32_t vctl_timeout_us;
64};
65
66#elif defined(CONFIG_MSM_SPM_V2)
67
68enum {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069 MSM_SPM_REG_SAW2_CFG,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070 MSM_SPM_REG_SAW2_AVS_CTL,
71 MSM_SPM_REG_SAW2_AVS_HYSTERESIS,
72 MSM_SPM_REG_SAW2_SPM_CTL,
73 MSM_SPM_REG_SAW2_PMIC_DLY,
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060074 MSM_SPM_REG_SAW2_AVS_LIMIT,
75 MSM_SPM_REG_SAW2_AVS_DLY,
76 MSM_SPM_REG_SAW2_SPM_DLY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070077 MSM_SPM_REG_SAW2_PMIC_DATA_0,
78 MSM_SPM_REG_SAW2_PMIC_DATA_1,
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060079 MSM_SPM_REG_SAW2_PMIC_DATA_2,
80 MSM_SPM_REG_SAW2_PMIC_DATA_3,
81 MSM_SPM_REG_SAW2_PMIC_DATA_4,
82 MSM_SPM_REG_SAW2_PMIC_DATA_5,
83 MSM_SPM_REG_SAW2_PMIC_DATA_6,
84 MSM_SPM_REG_SAW2_PMIC_DATA_7,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085 MSM_SPM_REG_SAW2_RST,
86
Mahesh Sivasubramaniand740fab2012-01-20 13:49:47 -070087 MSM_SPM_REG_NR_INITIALIZE = MSM_SPM_REG_SAW2_RST,
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060088
Mahesh Sivasubramaniand740fab2012-01-20 13:49:47 -070089 MSM_SPM_REG_SAW2_ID,
90 MSM_SPM_REG_SAW2_SECURE,
91 MSM_SPM_REG_SAW2_STS0,
92 MSM_SPM_REG_SAW2_STS1,
93 MSM_SPM_REG_SAW2_VCTL,
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -060094 MSM_SPM_REG_SAW2_SEQ_ENTRY,
95 MSM_SPM_REG_SAW2_SPM_STS,
96 MSM_SPM_REG_SAW2_AVS_STS,
97 MSM_SPM_REG_SAW2_PMIC_STS,
98 MSM_SPM_REG_SAW2_VERSION,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600100 MSM_SPM_REG_NR,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101};
102
103struct msm_spm_seq_entry {
104 uint32_t mode;
105 uint8_t *cmd;
106 bool notify_rpm;
107};
108
109struct msm_spm_platform_data {
110 void __iomem *reg_base_addr;
111 uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE];
112
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600113 uint32_t ver_reg;
114 uint32_t vctl_port;
115 uint32_t phase_port;
Praveen Chidambaram1dbe4952012-10-03 17:06:02 -0600116 uint32_t pfm_port;
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600117
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700118 uint8_t awake_vlevel;
119 uint32_t vctl_timeout_us;
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600120 uint32_t avs_timeout_us;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700121
122 uint32_t num_modes;
123 struct msm_spm_seq_entry *modes;
124};
125#endif
126
127#if defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2)
128
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600129/* Public functions */
130
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700131int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm);
132int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel);
Praveen Chidambaram4133ba12012-09-29 22:27:03 -0600133unsigned int msm_spm_get_vdd(unsigned int cpu);
Syed Rameez Mustafa20e04ec2012-12-10 12:20:52 -0800134#if defined(CONFIG_MSM_SPM_V2)
Praveen Chidambaramc0750ca2012-01-08 10:03:28 -0700135int msm_spm_turn_on_cpu_rail(unsigned int cpu);
Syed Rameez Mustafa20e04ec2012-12-10 12:20:52 -0800136#else
137static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu)
138{
139 return -ENOSYS;
140}
141#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600143/* Internal low power management specific functions */
144
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600145void msm_spm_reinit(void);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600146int msm_spm_init(struct msm_spm_platform_data *data, int nr_devs);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600147int msm_spm_device_init(void);
148
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700149#if defined(CONFIG_MSM_L2_SPM)
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600150
151/* Public functions */
152
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153int msm_spm_l2_set_low_power_mode(unsigned int mode, bool notify_rpm);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600154int msm_spm_apcs_set_phase(unsigned int phase_cnt);
Praveen Chidambaram1dbe4952012-10-03 17:06:02 -0600155int msm_spm_enable_fts_lpm(uint32_t mode);
156
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600157/* Internal low power management specific functions */
158
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700159int msm_spm_l2_init(struct msm_spm_platform_data *data);
Maheshkumar Sivasubramanian4ac23762011-11-02 10:03:06 -0600160void msm_spm_l2_reinit(void);
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600161
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700162#else
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600163
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700164static inline int msm_spm_l2_set_low_power_mode(unsigned int mode,
165 bool notify_rpm)
166{
167 return -ENOSYS;
168}
Praveen Chidambaram48197dd2013-03-21 15:51:43 -0600169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700170static inline int msm_spm_l2_init(struct msm_spm_platform_data *data)
171{
172 return -ENOSYS;
173}
Praveen Chidambaram48197dd2013-03-21 15:51:43 -0600174
Maheshkumar Sivasubramanian4ac23762011-11-02 10:03:06 -0600175static inline void msm_spm_l2_reinit(void)
176{
177 /* empty */
178}
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600179
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600180static inline int msm_spm_apcs_set_phase(unsigned int phase_cnt)
181{
182 return -ENOSYS;
183}
Praveen Chidambaram1dbe4952012-10-03 17:06:02 -0600184
185static inline int msm_spm_enable_fts_lpm(uint32_t mode)
186{
187 return -ENOSYS;
188}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700189#endif /* defined(CONFIG_MSM_L2_SPM) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700190#else /* defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700191static inline int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm)
192{
193 return -ENOSYS;
194}
195
196static inline int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel)
197{
198 return -ENOSYS;
199}
200
Praveen Chidambaram4133ba12012-09-29 22:27:03 -0600201static inline unsigned int msm_spm_get_vdd(unsigned int cpu)
202{
203 return 0;
204}
205
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700206static inline void msm_spm_reinit(void)
207{
208 /* empty */
209}
210
Praveen Chidambaramc0750ca2012-01-08 10:03:28 -0700211static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu)
212{
213 return -ENOSYS;
214}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700215
Praveen Chidambaramaa9d52b2012-04-02 11:09:47 -0600216static inline int msm_spm_device_init(void)
217{
218 return -ENOSYS;
219}
220
221#endif /*defined(CONFIG_MSM_SPM_V1) || defined (CONFIG_MSM_SPM_V2) */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222#endif /* __ARCH_ARM_MACH_MSM_SPM_H */