Praveen Chidambaram | c0750ca | 2012-01-08 10:03:28 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 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 |
| 15 | enum { |
| 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 | |
| 23 | enum { |
| 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 | |
| 32 | enum { |
| 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 | |
| 52 | struct 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 | |
| 67 | enum { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 68 | MSM_SPM_REG_SAW2_CFG, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 69 | 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 Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 73 | MSM_SPM_REG_SAW2_AVS_LIMIT, |
| 74 | MSM_SPM_REG_SAW2_AVS_DLY, |
| 75 | MSM_SPM_REG_SAW2_SPM_DLY, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 76 | MSM_SPM_REG_SAW2_PMIC_DATA_0, |
| 77 | MSM_SPM_REG_SAW2_PMIC_DATA_1, |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 78 | 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 84 | MSM_SPM_REG_SAW2_RST, |
| 85 | |
Mahesh Sivasubramanian | d740fab | 2012-01-20 13:49:47 -0700 | [diff] [blame] | 86 | MSM_SPM_REG_NR_INITIALIZE = MSM_SPM_REG_SAW2_RST, |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 87 | |
Mahesh Sivasubramanian | d740fab | 2012-01-20 13:49:47 -0700 | [diff] [blame] | 88 | 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 Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 93 | 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 98 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 99 | MSM_SPM_REG_NR, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | struct msm_spm_seq_entry { |
| 103 | uint32_t mode; |
| 104 | uint8_t *cmd; |
| 105 | bool notify_rpm; |
| 106 | }; |
| 107 | |
| 108 | struct msm_spm_platform_data { |
| 109 | void __iomem *reg_base_addr; |
| 110 | uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE]; |
| 111 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 112 | uint32_t ver_reg; |
| 113 | uint32_t vctl_port; |
| 114 | uint32_t phase_port; |
| 115 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 116 | uint8_t awake_vlevel; |
| 117 | uint32_t vctl_timeout_us; |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 118 | uint32_t avs_timeout_us; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 119 | |
| 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 Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 127 | /* 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 134 | int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm); |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 135 | |
| 136 | /** |
| 137 | * msm_spm_set_vdd(): Set core voltage |
| 138 | * @cpu: core id |
| 139 | * @vlevel: Encoded PMIC data. |
| 140 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 141 | int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel); |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 142 | |
| 143 | /** |
| 144 | * msm_spm_turn_on_cpu_rail(): Power on cpu rail before turning on core |
| 145 | * @cpu: core id |
| 146 | */ |
Praveen Chidambaram | c0750ca | 2012-01-08 10:03:28 -0700 | [diff] [blame] | 147 | int msm_spm_turn_on_cpu_rail(unsigned int cpu); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 148 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 149 | |
| 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 | */ |
| 156 | void msm_spm_allow_x_cpu_set_vdd(bool allowed); |
| 157 | |
| 158 | /** |
| 159 | * msm_spm_reinit(): Reinitialize SPM registers |
| 160 | */ |
| 161 | void 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 | */ |
| 168 | int msm_spm_init(struct msm_spm_platform_data *data, int nr_devs); |
| 169 | |
| 170 | /** |
| 171 | * msm_spm_device_init(): Device tree initialization function |
| 172 | */ |
| 173 | int msm_spm_device_init(void); |
| 174 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 175 | #if defined(CONFIG_MSM_L2_SPM) |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 176 | |
| 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 185 | int msm_spm_l2_set_low_power_mode(unsigned int mode, bool notify_rpm); |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * msm_spm_apcs_set_vdd(): Set Apps processor core sub-system voltage |
| 189 | * @vlevel: Encoded PMIC data. |
| 190 | */ |
| 191 | int 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 | */ |
| 197 | int 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 205 | int msm_spm_l2_init(struct msm_spm_platform_data *data); |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 206 | |
| 207 | /** |
| 208 | * msm_spm_l2_reinit(): Reinitialize L2 SPM registers |
| 209 | */ |
Maheshkumar Sivasubramanian | 4ac2376 | 2011-11-02 10:03:06 -0600 | [diff] [blame] | 210 | void msm_spm_l2_reinit(void); |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 211 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 212 | #else |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 213 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 214 | static inline int msm_spm_l2_set_low_power_mode(unsigned int mode, |
| 215 | bool notify_rpm) |
| 216 | { |
| 217 | return -ENOSYS; |
| 218 | } |
| 219 | static inline int msm_spm_l2_init(struct msm_spm_platform_data *data) |
| 220 | { |
| 221 | return -ENOSYS; |
| 222 | } |
Maheshkumar Sivasubramanian | 4ac2376 | 2011-11-02 10:03:06 -0600 | [diff] [blame] | 223 | static inline void msm_spm_l2_reinit(void) |
| 224 | { |
| 225 | /* empty */ |
| 226 | } |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 227 | |
| 228 | static inline int msm_spm_apcs_set_vdd(unsigned int vlevel) |
| 229 | { |
| 230 | return -ENOSYS; |
| 231 | } |
| 232 | |
| 233 | static inline int msm_spm_apcs_set_phase(unsigned int phase_cnt) |
| 234 | { |
| 235 | return -ENOSYS; |
| 236 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 237 | #endif /* defined(CONFIG_MSM_L2_SPM) */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 238 | #else /* defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2) */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 239 | static inline int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm) |
| 240 | { |
| 241 | return -ENOSYS; |
| 242 | } |
| 243 | |
| 244 | static inline int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel) |
| 245 | { |
| 246 | return -ENOSYS; |
| 247 | } |
| 248 | |
| 249 | static inline void msm_spm_reinit(void) |
| 250 | { |
| 251 | /* empty */ |
| 252 | } |
| 253 | |
| 254 | static inline void msm_spm_allow_x_cpu_set_vdd(bool allowed) |
| 255 | { |
| 256 | /* empty */ |
| 257 | } |
| 258 | |
Praveen Chidambaram | c0750ca | 2012-01-08 10:03:28 -0700 | [diff] [blame] | 259 | static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu) |
| 260 | { |
| 261 | return -ENOSYS; |
| 262 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 263 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 264 | static 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 270 | #endif /* __ARCH_ARM_MACH_MSM_SPM_H */ |