Praveen Chidambaram | 48197dd | 2013-03-21 15:51:43 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2010-2013, The Linux Foundation. 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, |
Murali Nalajala | 82123b0 | 2013-10-04 16:00:19 +0530 | [diff] [blame] | 27 | MSM_SPM_L2_MODE_PC_NO_RPM, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 28 | MSM_SPM_L2_MODE_POWER_COLLAPSE, |
| 29 | }; |
| 30 | |
| 31 | #if defined(CONFIG_MSM_SPM_V1) |
| 32 | |
| 33 | enum { |
| 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 | |
| 53 | struct 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 | |
| 68 | enum { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 69 | MSM_SPM_REG_SAW2_CFG, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 70 | 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 Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 74 | MSM_SPM_REG_SAW2_AVS_LIMIT, |
| 75 | MSM_SPM_REG_SAW2_AVS_DLY, |
| 76 | MSM_SPM_REG_SAW2_SPM_DLY, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 77 | MSM_SPM_REG_SAW2_PMIC_DATA_0, |
| 78 | MSM_SPM_REG_SAW2_PMIC_DATA_1, |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 79 | 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 85 | MSM_SPM_REG_SAW2_RST, |
| 86 | |
Mahesh Sivasubramanian | d740fab | 2012-01-20 13:49:47 -0700 | [diff] [blame] | 87 | MSM_SPM_REG_NR_INITIALIZE = MSM_SPM_REG_SAW2_RST, |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 88 | |
Mahesh Sivasubramanian | d740fab | 2012-01-20 13:49:47 -0700 | [diff] [blame] | 89 | 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 Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 94 | 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 99 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 100 | MSM_SPM_REG_NR, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | struct msm_spm_seq_entry { |
| 104 | uint32_t mode; |
| 105 | uint8_t *cmd; |
| 106 | bool notify_rpm; |
| 107 | }; |
| 108 | |
| 109 | struct msm_spm_platform_data { |
| 110 | void __iomem *reg_base_addr; |
| 111 | uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE]; |
| 112 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 113 | uint32_t ver_reg; |
| 114 | uint32_t vctl_port; |
| 115 | uint32_t phase_port; |
Praveen Chidambaram | 1dbe495 | 2012-10-03 17:06:02 -0600 | [diff] [blame] | 116 | uint32_t pfm_port; |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 117 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 118 | uint8_t awake_vlevel; |
| 119 | uint32_t vctl_timeout_us; |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 120 | uint32_t avs_timeout_us; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 121 | |
| 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 Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 129 | /* Public functions */ |
| 130 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 131 | int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm); |
| 132 | int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel); |
Praveen Chidambaram | 4133ba1 | 2012-09-29 22:27:03 -0600 | [diff] [blame] | 133 | unsigned int msm_spm_get_vdd(unsigned int cpu); |
Syed Rameez Mustafa | 20e04ec | 2012-12-10 12:20:52 -0800 | [diff] [blame] | 134 | #if defined(CONFIG_MSM_SPM_V2) |
Praveen Chidambaram | c0750ca | 2012-01-08 10:03:28 -0700 | [diff] [blame] | 135 | int msm_spm_turn_on_cpu_rail(unsigned int cpu); |
Syed Rameez Mustafa | 20e04ec | 2012-12-10 12:20:52 -0800 | [diff] [blame] | 136 | #else |
| 137 | static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu) |
| 138 | { |
| 139 | return -ENOSYS; |
| 140 | } |
| 141 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 142 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 143 | /* Internal low power management specific functions */ |
| 144 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 145 | void msm_spm_reinit(void); |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 146 | int msm_spm_init(struct msm_spm_platform_data *data, int nr_devs); |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 147 | int msm_spm_device_init(void); |
| 148 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 149 | #if defined(CONFIG_MSM_L2_SPM) |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 150 | |
| 151 | /* Public functions */ |
| 152 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 153 | 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] | 154 | int msm_spm_apcs_set_phase(unsigned int phase_cnt); |
Praveen Chidambaram | 1dbe495 | 2012-10-03 17:06:02 -0600 | [diff] [blame] | 155 | int msm_spm_enable_fts_lpm(uint32_t mode); |
| 156 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 157 | /* Internal low power management specific functions */ |
| 158 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 159 | int msm_spm_l2_init(struct msm_spm_platform_data *data); |
Maheshkumar Sivasubramanian | 4ac2376 | 2011-11-02 10:03:06 -0600 | [diff] [blame] | 160 | void msm_spm_l2_reinit(void); |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 161 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 162 | #else |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 163 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 164 | static inline int msm_spm_l2_set_low_power_mode(unsigned int mode, |
| 165 | bool notify_rpm) |
| 166 | { |
| 167 | return -ENOSYS; |
| 168 | } |
Praveen Chidambaram | 48197dd | 2013-03-21 15:51:43 -0600 | [diff] [blame] | 169 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 170 | static inline int msm_spm_l2_init(struct msm_spm_platform_data *data) |
| 171 | { |
| 172 | return -ENOSYS; |
| 173 | } |
Praveen Chidambaram | 48197dd | 2013-03-21 15:51:43 -0600 | [diff] [blame] | 174 | |
Maheshkumar Sivasubramanian | 4ac2376 | 2011-11-02 10:03:06 -0600 | [diff] [blame] | 175 | static inline void msm_spm_l2_reinit(void) |
| 176 | { |
| 177 | /* empty */ |
| 178 | } |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 179 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 180 | static inline int msm_spm_apcs_set_phase(unsigned int phase_cnt) |
| 181 | { |
| 182 | return -ENOSYS; |
| 183 | } |
Praveen Chidambaram | 1dbe495 | 2012-10-03 17:06:02 -0600 | [diff] [blame] | 184 | |
| 185 | static inline int msm_spm_enable_fts_lpm(uint32_t mode) |
| 186 | { |
| 187 | return -ENOSYS; |
| 188 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 189 | #endif /* defined(CONFIG_MSM_L2_SPM) */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 190 | #else /* defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2) */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 191 | static inline int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm) |
| 192 | { |
| 193 | return -ENOSYS; |
| 194 | } |
| 195 | |
| 196 | static inline int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel) |
| 197 | { |
| 198 | return -ENOSYS; |
| 199 | } |
| 200 | |
Praveen Chidambaram | 4133ba1 | 2012-09-29 22:27:03 -0600 | [diff] [blame] | 201 | static inline unsigned int msm_spm_get_vdd(unsigned int cpu) |
| 202 | { |
| 203 | return 0; |
| 204 | } |
| 205 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 206 | static inline void msm_spm_reinit(void) |
| 207 | { |
| 208 | /* empty */ |
| 209 | } |
| 210 | |
Praveen Chidambaram | c0750ca | 2012-01-08 10:03:28 -0700 | [diff] [blame] | 211 | static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu) |
| 212 | { |
| 213 | return -ENOSYS; |
| 214 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 215 | |
Praveen Chidambaram | aa9d52b | 2012-04-02 11:09:47 -0600 | [diff] [blame] | 216 | static 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 222 | #endif /* __ARCH_ARM_MACH_MSM_SPM_H */ |