Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [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 | |
| 14 | #ifndef __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H |
| 15 | #define __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H |
| 16 | |
| 17 | #include <mach/rpm.h> |
Matt Wagantall | 7cca464 | 2012-02-01 16:43:24 -0800 | [diff] [blame] | 18 | #include "pm.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 19 | |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 20 | enum { |
| 21 | MSM_RPMRS_ID_PXO_CLK = 0, |
| 22 | MSM_RPMRS_ID_L2_CACHE_CTL = 1, |
| 23 | MSM_RPMRS_ID_VDD_DIG_0 = 2, |
| 24 | MSM_RPMRS_ID_VDD_DIG_1 = 3, |
| 25 | MSM_RPMRS_ID_VDD_MEM_0 = 4, |
| 26 | MSM_RPMRS_ID_VDD_MEM_1 = 5, |
| 27 | MSM_RPMRS_ID_RPM_CTL = 6, |
| 28 | MSM_RPMRS_ID_LAST, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | enum { |
| 32 | MSM_RPMRS_PXO_OFF = 0, |
| 33 | MSM_RPMRS_PXO_ON = 1, |
| 34 | }; |
| 35 | |
| 36 | enum { |
| 37 | MSM_RPMRS_L2_CACHE_HSFS_OPEN = 0, |
| 38 | MSM_RPMRS_L2_CACHE_GDHS = 1, |
| 39 | MSM_RPMRS_L2_CACHE_RETENTION = 2, |
| 40 | MSM_RPMRS_L2_CACHE_ACTIVE = 3, |
| 41 | }; |
| 42 | |
Praveen Chidambaram | 9dfa871 | 2011-09-14 16:25:01 -0600 | [diff] [blame] | 43 | enum { |
| 44 | MSM_RPMRS_MASK_RPM_CTL_CPU_HALT = 1, |
| 45 | MSM_RPMRS_MASK_RPM_CTL_MULTI_TIER = 2, |
| 46 | }; |
| 47 | |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 48 | enum { |
| 49 | MSM_RPMRS_VDD_MEM_RET_LOW = 0, |
| 50 | MSM_RPMRS_VDD_MEM_RET_HIGH = 1, |
| 51 | MSM_RPMRS_VDD_MEM_ACTIVE = 2, |
| 52 | MSM_RPMRS_VDD_MEM_MAX = 3, |
| 53 | MSM_RPMRS_VDD_MEM_LAST, |
| 54 | }; |
| 55 | |
| 56 | enum { |
| 57 | MSM_RPMRS_VDD_DIG_RET_LOW = 0, |
| 58 | MSM_RPMRS_VDD_DIG_RET_HIGH = 1, |
| 59 | MSM_RPMRS_VDD_DIG_ACTIVE = 2, |
| 60 | MSM_RPMRS_VDD_DIG_MAX = 3, |
| 61 | MSM_RPMRS_VDD_DIG_LAST, |
| 62 | }; |
| 63 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 64 | #define MSM_RPMRS_LIMITS(_pxo, _l2, _vdd_upper_b, _vdd) { \ |
| 65 | MSM_RPMRS_PXO_##_pxo, \ |
| 66 | MSM_RPMRS_L2_CACHE_##_l2, \ |
| 67 | MSM_RPMRS_VDD_MEM_##_vdd_upper_b, \ |
| 68 | MSM_RPMRS_VDD_MEM_##_vdd, \ |
| 69 | MSM_RPMRS_VDD_DIG_##_vdd_upper_b, \ |
| 70 | MSM_RPMRS_VDD_DIG_##_vdd, \ |
| 71 | {0}, {0}, \ |
| 72 | } |
| 73 | |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 74 | struct msm_rpmrs_limits { |
| 75 | uint32_t pxo; |
| 76 | uint32_t l2_cache; |
| 77 | uint32_t vdd_mem_upper_bound; |
| 78 | uint32_t vdd_mem; |
| 79 | uint32_t vdd_dig_upper_bound; |
| 80 | uint32_t vdd_dig; |
| 81 | |
| 82 | uint32_t latency_us[NR_CPUS]; |
| 83 | uint32_t power[NR_CPUS]; |
| 84 | }; |
| 85 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 86 | struct msm_rpmrs_level { |
| 87 | enum msm_pm_sleep_mode sleep_mode; |
| 88 | struct msm_rpmrs_limits rs_limits; |
| 89 | bool available; |
| 90 | uint32_t latency_us; |
| 91 | uint32_t steady_state_power; |
| 92 | uint32_t energy_overhead; |
| 93 | uint32_t time_overhead_us; |
| 94 | }; |
| 95 | |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 96 | struct msm_rpmrs_platform_data { |
| 97 | struct msm_rpmrs_level *levels; |
| 98 | unsigned int num_levels; |
| 99 | unsigned int vdd_mem_levels[MSM_RPMRS_VDD_MEM_LAST]; |
| 100 | unsigned int vdd_dig_levels[MSM_RPMRS_VDD_DIG_LAST]; |
| 101 | unsigned int vdd_mask; |
| 102 | unsigned int rpmrs_target_id[MSM_RPMRS_ID_LAST]; |
| 103 | }; |
| 104 | |
Vikram Mulukutla | be97fbe | 2012-05-16 21:36:33 -0700 | [diff] [blame] | 105 | #if defined(CONFIG_MSM_RPM) |
| 106 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 107 | int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, int count); |
| 108 | int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, int count); |
Praveen Chidambaram | 9dfa871 | 2011-09-14 16:25:01 -0600 | [diff] [blame] | 109 | int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req, int count, |
| 110 | int *mask); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 111 | |
| 112 | static inline int msm_rpmrs_set_nosleep( |
| 113 | int ctx, struct msm_rpm_iv_pair *req, int count) |
| 114 | { |
| 115 | unsigned long flags; |
| 116 | int rc; |
| 117 | |
| 118 | local_irq_save(flags); |
| 119 | rc = msm_rpmrs_set_noirq(ctx, req, count); |
| 120 | local_irq_restore(flags); |
| 121 | |
| 122 | return rc; |
| 123 | } |
| 124 | |
| 125 | int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, int count); |
| 126 | int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, int count); |
| 127 | |
| 128 | static inline int msm_rpmrs_clear_nosleep( |
| 129 | int ctx, struct msm_rpm_iv_pair *req, int count) |
| 130 | { |
| 131 | unsigned long flags; |
| 132 | int rc; |
| 133 | |
| 134 | local_irq_save(flags); |
| 135 | rc = msm_rpmrs_clear_noirq(ctx, req, count); |
| 136 | local_irq_restore(flags); |
| 137 | |
| 138 | return rc; |
| 139 | } |
| 140 | |
| 141 | void msm_rpmrs_show_resources(void); |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 142 | int msm_rpmrs_levels_init(struct msm_rpmrs_platform_data *data); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 143 | |
Vikram Mulukutla | be97fbe | 2012-05-16 21:36:33 -0700 | [diff] [blame] | 144 | #else |
| 145 | |
| 146 | static inline int msm_rpmrs_set(int ctx, struct msm_rpm_iv_pair *req, |
| 147 | int count) |
| 148 | { |
| 149 | return -ENODEV; |
| 150 | } |
| 151 | |
| 152 | static inline int msm_rpmrs_set_noirq(int ctx, struct msm_rpm_iv_pair *req, |
| 153 | int count) |
| 154 | { |
| 155 | return -ENODEV; |
| 156 | } |
| 157 | |
| 158 | static inline int msm_rpmrs_set_bits_noirq(int ctx, struct msm_rpm_iv_pair *req, |
| 159 | int count, int *mask) |
| 160 | { |
| 161 | return -ENODEV; |
| 162 | } |
| 163 | |
| 164 | static inline int msm_rpmrs_set_nosleep( |
| 165 | int ctx, struct msm_rpm_iv_pair *req, int count) |
| 166 | { |
| 167 | return -ENODEV; |
| 168 | } |
| 169 | |
| 170 | static inline int msm_rpmrs_clear(int ctx, struct msm_rpm_iv_pair *req, |
| 171 | int count) |
| 172 | { |
| 173 | return -ENODEV; |
| 174 | } |
| 175 | |
| 176 | static inline int msm_rpmrs_clear_noirq(int ctx, struct msm_rpm_iv_pair *req, |
| 177 | int count) |
| 178 | { |
| 179 | return -ENODEV; |
| 180 | } |
| 181 | |
| 182 | static inline int msm_rpmrs_clear_nosleep( |
| 183 | int ctx, struct msm_rpm_iv_pair *req, int count) |
| 184 | { |
| 185 | return -ENODEV; |
| 186 | } |
| 187 | |
| 188 | static inline struct msm_rpmrs_limits *msm_rpmrs_lowest_limits( |
| 189 | bool from_idle, enum msm_pm_sleep_mode sleep_mode, uint32_t latency_us, |
| 190 | uint32_t sleep_us) |
| 191 | { |
| 192 | return NULL; |
| 193 | } |
| 194 | |
| 195 | static inline int msm_rpmrs_enter_sleep(uint32_t sclk_count, |
| 196 | struct msm_rpmrs_limits *limits, bool from_idle, bool notify_rpm) |
| 197 | { |
| 198 | return -ENODEV; |
| 199 | } |
| 200 | |
| 201 | static inline void msm_rpmrs_exit_sleep(struct msm_rpmrs_limits *limits, |
| 202 | bool from_idle, bool notify_rpm, bool collapsed) |
| 203 | { |
| 204 | return; |
| 205 | } |
| 206 | |
| 207 | static inline int msm_rpmrs_levels_init(struct msm_rpmrs_platform_data *data) |
| 208 | { |
| 209 | return -ENODEV; |
| 210 | } |
| 211 | |
| 212 | #endif /* CONFIG_MSM_RPM */ |
| 213 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 214 | #endif /* __ARCH_ARM_MACH_MSM_RPM_RESOURCES_H */ |