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, |
| 73 | MSM_SPM_REG_SAW2_PMIC_DATA_0, |
| 74 | MSM_SPM_REG_SAW2_PMIC_DATA_1, |
| 75 | MSM_SPM_REG_SAW2_RST, |
| 76 | |
Mahesh Sivasubramanian | d740fab | 2012-01-20 13:49:47 -0700 | [diff] [blame] | 77 | MSM_SPM_REG_NR_INITIALIZE = MSM_SPM_REG_SAW2_RST, |
| 78 | MSM_SPM_REG_SAW2_ID, |
| 79 | MSM_SPM_REG_SAW2_SECURE, |
| 80 | MSM_SPM_REG_SAW2_STS0, |
| 81 | MSM_SPM_REG_SAW2_STS1, |
| 82 | MSM_SPM_REG_SAW2_VCTL, |
| 83 | MSM_SPM_REG_SAW2_SEQ_ENTRY , |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 84 | |
| 85 | MSM_SPM_REG_NR |
| 86 | }; |
| 87 | |
| 88 | struct msm_spm_seq_entry { |
| 89 | uint32_t mode; |
| 90 | uint8_t *cmd; |
| 91 | bool notify_rpm; |
| 92 | }; |
| 93 | |
| 94 | struct msm_spm_platform_data { |
| 95 | void __iomem *reg_base_addr; |
| 96 | uint32_t reg_init_values[MSM_SPM_REG_NR_INITIALIZE]; |
| 97 | |
| 98 | uint8_t awake_vlevel; |
| 99 | uint32_t vctl_timeout_us; |
| 100 | |
| 101 | uint32_t num_modes; |
| 102 | struct msm_spm_seq_entry *modes; |
| 103 | }; |
| 104 | #endif |
| 105 | |
| 106 | #if defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2) |
| 107 | |
| 108 | int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm); |
| 109 | int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel); |
| 110 | void msm_spm_reinit(void); |
| 111 | void msm_spm_allow_x_cpu_set_vdd(bool allowed); |
| 112 | int msm_spm_init(struct msm_spm_platform_data *data, int nr_devs); |
Praveen Chidambaram | c0750ca | 2012-01-08 10:03:28 -0700 | [diff] [blame] | 113 | int msm_spm_turn_on_cpu_rail(unsigned int cpu); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 114 | |
| 115 | #if defined(CONFIG_MSM_L2_SPM) |
| 116 | int msm_spm_l2_set_low_power_mode(unsigned int mode, bool notify_rpm); |
| 117 | int msm_spm_l2_init(struct msm_spm_platform_data *data); |
| 118 | #else |
| 119 | static inline int msm_spm_l2_set_low_power_mode(unsigned int mode, |
| 120 | bool notify_rpm) |
| 121 | { |
| 122 | return -ENOSYS; |
| 123 | } |
| 124 | static inline int msm_spm_l2_init(struct msm_spm_platform_data *data) |
| 125 | { |
| 126 | return -ENOSYS; |
| 127 | } |
| 128 | #endif /* defined(CONFIG_MSM_L2_SPM) */ |
| 129 | |
| 130 | #else /* defined(CONFIG_MSM_SPM_V1) || defined(CONFIG_MSM_SPM_V2) */ |
| 131 | |
| 132 | static inline int msm_spm_set_low_power_mode(unsigned int mode, bool notify_rpm) |
| 133 | { |
| 134 | return -ENOSYS; |
| 135 | } |
| 136 | |
| 137 | static inline int msm_spm_set_vdd(unsigned int cpu, unsigned int vlevel) |
| 138 | { |
| 139 | return -ENOSYS; |
| 140 | } |
| 141 | |
| 142 | static inline void msm_spm_reinit(void) |
| 143 | { |
| 144 | /* empty */ |
| 145 | } |
| 146 | |
| 147 | static inline void msm_spm_allow_x_cpu_set_vdd(bool allowed) |
| 148 | { |
| 149 | /* empty */ |
| 150 | } |
| 151 | |
Praveen Chidambaram | c0750ca | 2012-01-08 10:03:28 -0700 | [diff] [blame] | 152 | static inline int msm_spm_turn_on_cpu_rail(unsigned int cpu) |
| 153 | { |
| 154 | return -ENOSYS; |
| 155 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 156 | #endif /*defined(CONFIG_MSM_SPM_V1) || defined (CONFIG_MSM_SPM_V2) */ |
| 157 | |
| 158 | #endif /* __ARCH_ARM_MACH_MSM_SPM_H */ |