David Collins | 6f032ba | 2011-08-31 14:08:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #ifndef __ARCH_ARM_MACH_MSM_RPM_REGULATOR_INT_H |
| 15 | #define __ARCH_ARM_MACH_MSM_RPM_REGULATOR_INT_H |
| 16 | |
| 17 | #include <linux/regulator/driver.h> |
| 18 | #include <mach/rpm.h> |
| 19 | #include <mach/rpm-regulator.h> |
| 20 | |
| 21 | /* Possible RPM regulator request types */ |
| 22 | enum rpm_regulator_type { |
| 23 | RPM_REGULATOR_TYPE_LDO, |
| 24 | RPM_REGULATOR_TYPE_SMPS, |
| 25 | RPM_REGULATOR_TYPE_VS, |
| 26 | RPM_REGULATOR_TYPE_NCP, |
David Collins | 0ac31fe | 2012-02-08 13:53:34 -0800 | [diff] [blame] | 27 | RPM_REGULATOR_TYPE_CORNER, |
| 28 | RPM_REGULATOR_TYPE_MAX = RPM_REGULATOR_TYPE_CORNER, |
David Collins | 6f032ba | 2011-08-31 14:08:15 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | struct request_member { |
| 32 | int word; |
| 33 | unsigned int mask; |
| 34 | int shift; |
| 35 | }; |
| 36 | |
| 37 | /* Possible RPM regulator request members */ |
| 38 | struct rpm_vreg_parts { |
| 39 | struct request_member mV; /* voltage: used if voltage is in mV */ |
| 40 | struct request_member uV; /* voltage: used if voltage is in uV */ |
| 41 | struct request_member ip; /* peak current in mA */ |
| 42 | struct request_member pd; /* pull down enable */ |
| 43 | struct request_member ia; /* average current in mA */ |
| 44 | struct request_member fm; /* force mode */ |
| 45 | struct request_member pm; /* power mode */ |
| 46 | struct request_member pc; /* pin control */ |
| 47 | struct request_member pf; /* pin function */ |
| 48 | struct request_member enable_state; /* NCP and switch */ |
| 49 | struct request_member comp_mode; /* NCP */ |
| 50 | struct request_member freq; /* frequency: NCP and SMPS */ |
| 51 | struct request_member freq_clk_src; /* clock source: SMPS */ |
| 52 | struct request_member hpm; /* switch: control OCP and SS */ |
| 53 | int request_len; |
| 54 | }; |
| 55 | |
| 56 | struct vreg_range { |
| 57 | int min_uV; |
| 58 | int max_uV; |
| 59 | int step_uV; |
| 60 | unsigned n_voltages; |
| 61 | }; |
| 62 | |
| 63 | struct vreg_set_points { |
| 64 | struct vreg_range *range; |
| 65 | int count; |
| 66 | unsigned n_voltages; |
| 67 | }; |
| 68 | |
| 69 | struct vreg { |
| 70 | struct msm_rpm_iv_pair req[2]; |
| 71 | struct msm_rpm_iv_pair prev_active_req[2]; |
| 72 | struct msm_rpm_iv_pair prev_sleep_req[2]; |
| 73 | struct rpm_regulator_init_data pdata; |
| 74 | struct regulator_desc rdesc; |
| 75 | struct regulator_desc rdesc_pc; |
| 76 | struct regulator_dev *rdev; |
| 77 | struct regulator_dev *rdev_pc; |
| 78 | struct vreg_set_points *set_points; |
| 79 | struct rpm_vreg_parts *part; |
| 80 | int type; |
| 81 | int id; |
| 82 | struct mutex pc_lock; |
| 83 | int save_uV; |
| 84 | int mode; |
| 85 | bool is_enabled; |
| 86 | bool is_enabled_pc; |
| 87 | const int hpm_min_load; |
| 88 | int active_min_uV_vote[RPM_VREG_VOTER_COUNT]; |
| 89 | int sleep_min_uV_vote[RPM_VREG_VOTER_COUNT]; |
| 90 | }; |
| 91 | |
| 92 | struct vreg_config { |
| 93 | struct vreg *vregs; |
| 94 | int vregs_len; |
| 95 | |
| 96 | int vreg_id_min; |
| 97 | int vreg_id_max; |
| 98 | |
| 99 | int pin_func_none; |
| 100 | int pin_func_sleep_b; |
| 101 | |
| 102 | unsigned int mode_lpm; |
| 103 | unsigned int mode_hpm; |
| 104 | |
| 105 | struct vreg_set_points **set_points; |
| 106 | int set_points_len; |
| 107 | |
| 108 | const char **label_pin_ctrl; |
| 109 | int label_pin_ctrl_len; |
| 110 | const char **label_pin_func; |
| 111 | int label_pin_func_len; |
| 112 | const char **label_force_mode; |
| 113 | int label_force_mode_len; |
| 114 | const char **label_power_mode; |
| 115 | int label_power_mode_len; |
| 116 | |
| 117 | int (*is_real_id) (int vreg_id); |
| 118 | int (*pc_id_to_real_id) (int vreg_id); |
| 119 | |
| 120 | /* Legacy options to be used with MSM8660 */ |
| 121 | int use_legacy_optimum_mode; |
| 122 | int ia_follows_ip; |
| 123 | }; |
| 124 | |
| 125 | #define REQUEST_MEMBER(_word, _mask, _shift) \ |
| 126 | { \ |
| 127 | .word = _word, \ |
| 128 | .mask = _mask, \ |
| 129 | .shift = _shift, \ |
| 130 | } |
| 131 | |
| 132 | #define VOLTAGE_RANGE(_min_uV, _max_uV, _step_uV) \ |
| 133 | { \ |
| 134 | .min_uV = _min_uV, \ |
| 135 | .max_uV = _max_uV, \ |
| 136 | .step_uV = _step_uV, \ |
| 137 | } |
| 138 | |
| 139 | #define SET_POINTS(_ranges) \ |
| 140 | { \ |
| 141 | .range = _ranges, \ |
| 142 | .count = ARRAY_SIZE(_ranges), \ |
| 143 | }; |
| 144 | |
| 145 | #define MICRO_TO_MILLI(uV) ((uV) / 1000) |
| 146 | #define MILLI_TO_MICRO(mV) ((mV) * 1000) |
| 147 | |
David Collins | 5779cea | 2012-01-05 15:09:21 -0800 | [diff] [blame] | 148 | #if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM8X60) |
David Collins | 6f032ba | 2011-08-31 14:08:15 -0700 | [diff] [blame] | 149 | struct vreg_config *get_config_8660(void); |
| 150 | #else |
| 151 | static inline struct vreg_config *get_config_8660(void) |
| 152 | { |
| 153 | return NULL; |
| 154 | } |
| 155 | #endif |
| 156 | |
David Collins | 5779cea | 2012-01-05 15:09:21 -0800 | [diff] [blame] | 157 | #if defined(CONFIG_MSM_RPM_REGULATOR) && \ |
| 158 | (defined(CONFIG_ARCH_MSM8960) || defined(CONFIG_ARCH_APQ8064)) |
David Collins | 6f032ba | 2011-08-31 14:08:15 -0700 | [diff] [blame] | 159 | struct vreg_config *get_config_8960(void); |
| 160 | #else |
| 161 | static inline struct vreg_config *get_config_8960(void) |
| 162 | { |
| 163 | return NULL; |
| 164 | } |
| 165 | #endif |
| 166 | |
David Collins | 5779cea | 2012-01-05 15:09:21 -0800 | [diff] [blame] | 167 | #if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM9615) |
David Collins | 6ef12bf | 2011-08-31 14:08:15 -0700 | [diff] [blame] | 168 | struct vreg_config *get_config_9615(void); |
| 169 | #else |
| 170 | static inline struct vreg_config *get_config_9615(void) |
| 171 | { |
| 172 | return NULL; |
| 173 | } |
| 174 | #endif |
| 175 | |
David Collins | 5779cea | 2012-01-05 15:09:21 -0800 | [diff] [blame] | 176 | #if defined(CONFIG_MSM_RPM_REGULATOR) && defined(CONFIG_ARCH_MSM8930) |
| 177 | struct vreg_config *get_config_8930(void); |
| 178 | #else |
| 179 | static inline struct vreg_config *get_config_8930(void) |
| 180 | { |
| 181 | return NULL; |
| 182 | } |
| 183 | #endif |
| 184 | |
David Collins | 6f032ba | 2011-08-31 14:08:15 -0700 | [diff] [blame] | 185 | #endif |