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, |
| 27 | RPM_REGULATOR_TYPE_MAX = RPM_REGULATOR_TYPE_NCP, |
| 28 | }; |
| 29 | |
| 30 | struct request_member { |
| 31 | int word; |
| 32 | unsigned int mask; |
| 33 | int shift; |
| 34 | }; |
| 35 | |
| 36 | /* Possible RPM regulator request members */ |
| 37 | struct rpm_vreg_parts { |
| 38 | struct request_member mV; /* voltage: used if voltage is in mV */ |
| 39 | struct request_member uV; /* voltage: used if voltage is in uV */ |
| 40 | struct request_member ip; /* peak current in mA */ |
| 41 | struct request_member pd; /* pull down enable */ |
| 42 | struct request_member ia; /* average current in mA */ |
| 43 | struct request_member fm; /* force mode */ |
| 44 | struct request_member pm; /* power mode */ |
| 45 | struct request_member pc; /* pin control */ |
| 46 | struct request_member pf; /* pin function */ |
| 47 | struct request_member enable_state; /* NCP and switch */ |
| 48 | struct request_member comp_mode; /* NCP */ |
| 49 | struct request_member freq; /* frequency: NCP and SMPS */ |
| 50 | struct request_member freq_clk_src; /* clock source: SMPS */ |
| 51 | struct request_member hpm; /* switch: control OCP and SS */ |
| 52 | int request_len; |
| 53 | }; |
| 54 | |
| 55 | struct vreg_range { |
| 56 | int min_uV; |
| 57 | int max_uV; |
| 58 | int step_uV; |
| 59 | unsigned n_voltages; |
| 60 | }; |
| 61 | |
| 62 | struct vreg_set_points { |
| 63 | struct vreg_range *range; |
| 64 | int count; |
| 65 | unsigned n_voltages; |
| 66 | }; |
| 67 | |
| 68 | struct vreg { |
| 69 | struct msm_rpm_iv_pair req[2]; |
| 70 | struct msm_rpm_iv_pair prev_active_req[2]; |
| 71 | struct msm_rpm_iv_pair prev_sleep_req[2]; |
| 72 | struct rpm_regulator_init_data pdata; |
| 73 | struct regulator_desc rdesc; |
| 74 | struct regulator_desc rdesc_pc; |
| 75 | struct regulator_dev *rdev; |
| 76 | struct regulator_dev *rdev_pc; |
| 77 | struct vreg_set_points *set_points; |
| 78 | struct rpm_vreg_parts *part; |
| 79 | int type; |
| 80 | int id; |
| 81 | struct mutex pc_lock; |
| 82 | int save_uV; |
| 83 | int mode; |
| 84 | bool is_enabled; |
| 85 | bool is_enabled_pc; |
| 86 | const int hpm_min_load; |
| 87 | int active_min_uV_vote[RPM_VREG_VOTER_COUNT]; |
| 88 | int sleep_min_uV_vote[RPM_VREG_VOTER_COUNT]; |
| 89 | }; |
| 90 | |
| 91 | struct vreg_config { |
| 92 | struct vreg *vregs; |
| 93 | int vregs_len; |
| 94 | |
| 95 | int vreg_id_min; |
| 96 | int vreg_id_max; |
| 97 | |
| 98 | int pin_func_none; |
| 99 | int pin_func_sleep_b; |
| 100 | |
| 101 | unsigned int mode_lpm; |
| 102 | unsigned int mode_hpm; |
| 103 | |
| 104 | struct vreg_set_points **set_points; |
| 105 | int set_points_len; |
| 106 | |
| 107 | const char **label_pin_ctrl; |
| 108 | int label_pin_ctrl_len; |
| 109 | const char **label_pin_func; |
| 110 | int label_pin_func_len; |
| 111 | const char **label_force_mode; |
| 112 | int label_force_mode_len; |
| 113 | const char **label_power_mode; |
| 114 | int label_power_mode_len; |
| 115 | |
| 116 | int (*is_real_id) (int vreg_id); |
| 117 | int (*pc_id_to_real_id) (int vreg_id); |
| 118 | |
| 119 | /* Legacy options to be used with MSM8660 */ |
| 120 | int use_legacy_optimum_mode; |
| 121 | int ia_follows_ip; |
| 122 | }; |
| 123 | |
| 124 | #define REQUEST_MEMBER(_word, _mask, _shift) \ |
| 125 | { \ |
| 126 | .word = _word, \ |
| 127 | .mask = _mask, \ |
| 128 | .shift = _shift, \ |
| 129 | } |
| 130 | |
| 131 | #define VOLTAGE_RANGE(_min_uV, _max_uV, _step_uV) \ |
| 132 | { \ |
| 133 | .min_uV = _min_uV, \ |
| 134 | .max_uV = _max_uV, \ |
| 135 | .step_uV = _step_uV, \ |
| 136 | } |
| 137 | |
| 138 | #define SET_POINTS(_ranges) \ |
| 139 | { \ |
| 140 | .range = _ranges, \ |
| 141 | .count = ARRAY_SIZE(_ranges), \ |
| 142 | }; |
| 143 | |
| 144 | #define MICRO_TO_MILLI(uV) ((uV) / 1000) |
| 145 | #define MILLI_TO_MICRO(mV) ((mV) * 1000) |
| 146 | |
| 147 | #if defined(CONFIG_ARCH_MSM8X60) |
| 148 | struct vreg_config *get_config_8660(void); |
| 149 | #else |
| 150 | static inline struct vreg_config *get_config_8660(void) |
| 151 | { |
| 152 | return NULL; |
| 153 | } |
| 154 | #endif |
| 155 | |
| 156 | #if defined(CONFIG_ARCH_MSM8960) || defined(CONFIG_ARCH_APQ8064) |
| 157 | struct vreg_config *get_config_8960(void); |
| 158 | #else |
| 159 | static inline struct vreg_config *get_config_8960(void) |
| 160 | { |
| 161 | return NULL; |
| 162 | } |
| 163 | #endif |
| 164 | |
David Collins | 6ef12bf | 2011-08-31 14:08:15 -0700 | [diff] [blame^] | 165 | #if defined(CONFIG_ARCH_MSM9615) |
| 166 | struct vreg_config *get_config_9615(void); |
| 167 | #else |
| 168 | static inline struct vreg_config *get_config_9615(void) |
| 169 | { |
| 170 | return NULL; |
| 171 | } |
| 172 | #endif |
| 173 | |
David Collins | 6f032ba | 2011-08-31 14:08:15 -0700 | [diff] [blame] | 174 | #endif |