Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 1 | /* |
Xiaozhe Shi | 767fdb6 | 2013-01-10 15:09:08 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 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 | * Qualcomm PMIC QPNP ADC driver header file |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #ifndef __QPNP_ADC_H |
| 19 | #define __QPNP_ADC_H |
| 20 | |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/list.h> |
| 23 | /** |
| 24 | * enum qpnp_vadc_channels - QPNP AMUX arbiter channels |
| 25 | */ |
| 26 | enum qpnp_vadc_channels { |
| 27 | USBIN = 0, |
| 28 | DCIN, |
| 29 | VCHG_SNS, |
| 30 | SPARE1_03, |
Siddartha Mohanadoss | 2cadeba | 2012-11-13 18:40:27 -0800 | [diff] [blame] | 31 | USB_ID_MV, |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 32 | VCOIN, |
| 33 | VBAT_SNS, |
| 34 | VSYS, |
| 35 | DIE_TEMP, |
| 36 | REF_625MV, |
| 37 | REF_125V, |
| 38 | CHG_TEMP, |
| 39 | SPARE1, |
| 40 | SPARE2, |
| 41 | GND_REF, |
| 42 | VDD_VADC, |
| 43 | P_MUX1_1_1, |
| 44 | P_MUX2_1_1, |
| 45 | P_MUX3_1_1, |
| 46 | P_MUX4_1_1, |
| 47 | P_MUX5_1_1, |
| 48 | P_MUX6_1_1, |
| 49 | P_MUX7_1_1, |
| 50 | P_MUX8_1_1, |
| 51 | P_MUX9_1_1, |
| 52 | P_MUX10_1_1, |
| 53 | P_MUX11_1_1, |
| 54 | P_MUX12_1_1, |
| 55 | P_MUX13_1_1, |
| 56 | P_MUX14_1_1, |
| 57 | P_MUX15_1_1, |
| 58 | P_MUX16_1_1, |
| 59 | P_MUX1_1_3, |
| 60 | P_MUX2_1_3, |
| 61 | P_MUX3_1_3, |
| 62 | P_MUX4_1_3, |
| 63 | P_MUX5_1_3, |
| 64 | P_MUX6_1_3, |
| 65 | P_MUX7_1_3, |
| 66 | P_MUX8_1_3, |
| 67 | P_MUX9_1_3, |
| 68 | P_MUX10_1_3, |
| 69 | P_MUX11_1_3, |
| 70 | P_MUX12_1_3, |
| 71 | P_MUX13_1_3, |
| 72 | P_MUX14_1_3, |
| 73 | P_MUX15_1_3, |
| 74 | P_MUX16_1_3, |
| 75 | LR_MUX1_BATT_THERM, |
| 76 | LR_MUX2_BAT_ID, |
| 77 | LR_MUX3_XO_THERM, |
| 78 | LR_MUX4_AMUX_THM1, |
| 79 | LR_MUX5_AMUX_THM2, |
| 80 | LR_MUX6_AMUX_THM3, |
| 81 | LR_MUX7_HW_ID, |
| 82 | LR_MUX8_AMUX_THM4, |
| 83 | LR_MUX9_AMUX_THM5, |
Siddartha Mohanadoss | 2cadeba | 2012-11-13 18:40:27 -0800 | [diff] [blame] | 84 | LR_MUX10_USB_ID_LV, |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 85 | AMUX_PU1, |
| 86 | AMUX_PU2, |
| 87 | LR_MUX3_BUF_XO_THERM_BUF, |
Siddartha Mohanadoss | 2cadeba | 2012-11-13 18:40:27 -0800 | [diff] [blame] | 88 | LR_MUX1_PU1_BAT_THERM = 112, |
| 89 | LR_MUX2_PU1_BAT_ID = 113, |
| 90 | LR_MUX3_PU1_XO_THERM = 114, |
| 91 | LR_MUX4_PU1_AMUX_THM1 = 115, |
| 92 | LR_MUX5_PU1_AMUX_THM2 = 116, |
| 93 | LR_MUX6_PU1_AMUX_THM3 = 117, |
| 94 | LR_MUX7_PU1_AMUX_HW_ID = 118, |
| 95 | LR_MUX8_PU1_AMUX_THM4 = 119, |
| 96 | LR_MUX9_PU1_AMUX_THM5 = 120, |
| 97 | LR_MUX10_PU1_AMUX_USB_ID_LV = 121, |
| 98 | LR_MUX3_BUF_PU1_XO_THERM_BUF = 124, |
| 99 | LR_MUX1_PU2_BAT_THERM = 176, |
| 100 | LR_MUX2_PU2_BAT_ID = 177, |
| 101 | LR_MUX3_PU2_XO_THERM = 178, |
| 102 | LR_MUX4_PU2_AMUX_THM1 = 179, |
| 103 | LR_MUX5_PU2_AMUX_THM2 = 180, |
| 104 | LR_MUX6_PU2_AMUX_THM3 = 181, |
| 105 | LR_MUX7_PU2_AMUX_HW_ID = 182, |
| 106 | LR_MUX8_PU2_AMUX_THM4 = 183, |
| 107 | LR_MUX9_PU2_AMUX_THM5 = 184, |
| 108 | LR_MUX10_PU2_AMUX_USB_ID_LV = 185, |
| 109 | LR_MUX3_BUF_PU2_XO_THERM_BUF = 188, |
| 110 | LR_MUX1_PU1_PU2_BAT_THERM = 240, |
| 111 | LR_MUX2_PU1_PU2_BAT_ID = 241, |
| 112 | LR_MUX3_PU1_PU2_XO_THERM = 242, |
| 113 | LR_MUX4_PU1_PU2_AMUX_THM1 = 243, |
| 114 | LR_MUX5_PU1_PU2_AMUX_THM2 = 244, |
| 115 | LR_MUX6_PU1_PU2_AMUX_THM3 = 245, |
| 116 | LR_MUX7_PU1_PU2_AMUX_HW_ID = 246, |
| 117 | LR_MUX8_PU1_PU2_AMUX_THM4 = 247, |
| 118 | LR_MUX9_PU1_PU2_AMUX_THM5 = 248, |
| 119 | LR_MUX10_PU1_PU2_AMUX_USB_ID_LV = 249, |
| 120 | LR_MUX3_BUF_PU1_PU2_XO_THERM_BUF = 252, |
| 121 | ALL_OFF = 255, |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 122 | ADC_MAX_NUM, |
| 123 | }; |
| 124 | |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 125 | /** |
| 126 | * enum qpnp_iadc_channels - QPNP IADC channel list |
| 127 | */ |
| 128 | enum qpnp_iadc_channels { |
| 129 | INTERNAL_RSENSE = 0, |
| 130 | EXTERNAL_RSENSE, |
| 131 | ALT_LEAD_PAIR, |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 132 | GAIN_CALIBRATION_17P857MV, |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 133 | OFFSET_CALIBRATION_SHORT_CADC_LEADS, |
| 134 | OFFSET_CALIBRATION_CSP_CSN, |
| 135 | OFFSET_CALIBRATION_CSP2_CSN2, |
| 136 | IADC_MUX_NUM, |
| 137 | }; |
| 138 | |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 139 | #define QPNP_ADC_625_UV 625000 |
Siddartha Mohanadoss | 1c21831 | 2012-11-08 11:30:43 -0800 | [diff] [blame] | 140 | #define QPNP_ADC_HWMON_NAME_LENGTH 64 |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 141 | |
| 142 | /** |
| 143 | * enum qpnp_adc_decimation_type - Sampling rate supported. |
| 144 | * %DECIMATION_TYPE1: 512 |
| 145 | * %DECIMATION_TYPE2: 1K |
| 146 | * %DECIMATION_TYPE3: 2K |
| 147 | * %DECIMATION_TYPE4: 4k |
| 148 | * %DECIMATION_NONE: Do not use this Sampling type. |
| 149 | * |
| 150 | * The Sampling rate is specific to each channel of the QPNP ADC arbiter. |
| 151 | */ |
| 152 | enum qpnp_adc_decimation_type { |
| 153 | DECIMATION_TYPE1 = 0, |
| 154 | DECIMATION_TYPE2, |
| 155 | DECIMATION_TYPE3, |
| 156 | DECIMATION_TYPE4, |
| 157 | DECIMATION_NONE, |
| 158 | }; |
| 159 | |
| 160 | /** |
| 161 | * enum qpnp_adc_calib_type - QPNP ADC Calibration type. |
| 162 | * %ADC_CALIB_ABSOLUTE: Use 625mV and 1.25V reference channels. |
| 163 | * %ADC_CALIB_RATIOMETRIC: Use reference Voltage/GND. |
| 164 | * %ADC_CALIB_CONFIG_NONE: Do not use this calibration type. |
| 165 | * |
| 166 | * Use the input reference voltage depending on the calibration type |
| 167 | * to calcluate the offset and gain parameters. The calibration is |
| 168 | * specific to each channel of the QPNP ADC. |
| 169 | */ |
| 170 | enum qpnp_adc_calib_type { |
| 171 | CALIB_ABSOLUTE = 0, |
| 172 | CALIB_RATIOMETRIC, |
| 173 | CALIB_NONE, |
| 174 | }; |
| 175 | |
| 176 | /** |
| 177 | * enum qpnp_adc_channel_scaling_param - pre-scaling AMUX ratio. |
Siddartha Mohanadoss | 5ace110 | 2012-08-20 23:18:10 -0700 | [diff] [blame] | 178 | * %CHAN_PATH_SCALING0: ratio of {1, 1} |
| 179 | * %CHAN_PATH_SCALING1: ratio of {1, 3} |
| 180 | * %CHAN_PATH_SCALING2: ratio of {1, 4} |
| 181 | * %CHAN_PATH_SCALING3: ratio of {1, 6} |
| 182 | * %CHAN_PATH_SCALING4: ratio of {1, 20} |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 183 | * %CHAN_PATH_NONE: Do not use this pre-scaling ratio type. |
| 184 | * |
| 185 | * The pre-scaling is applied for signals to be within the voltage range |
| 186 | * of the ADC. |
| 187 | */ |
| 188 | enum qpnp_adc_channel_scaling_param { |
Siddartha Mohanadoss | 5ace110 | 2012-08-20 23:18:10 -0700 | [diff] [blame] | 189 | PATH_SCALING0 = 0, |
| 190 | PATH_SCALING1, |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 191 | PATH_SCALING2, |
| 192 | PATH_SCALING3, |
| 193 | PATH_SCALING4, |
| 194 | PATH_SCALING_NONE, |
| 195 | }; |
| 196 | |
| 197 | /** |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 198 | * enum qpnp_adc_scale_fn_type - Scaling function for pm8941 pre calibrated |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 199 | * digital data relative to ADC reference. |
| 200 | * %ADC_SCALE_DEFAULT: Default scaling to convert raw adc code to voltage. |
| 201 | * %ADC_SCALE_BATT_THERM: Conversion to temperature based on btm parameters. |
Siddartha Mohanadoss | e77edf1 | 2012-09-13 14:26:32 -0700 | [diff] [blame] | 202 | * %ADC_SCALE_THERM_100K_PULLUP: Returns temperature in degC. |
| 203 | * Uses a mapping table with 100K pullup. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 204 | * %ADC_SCALE_PMIC_THERM: Returns result in milli degree's Centigrade. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 205 | * %ADC_SCALE_XOTHERM: Returns XO thermistor voltage in degree's Centigrade. |
Siddartha Mohanadoss | e77edf1 | 2012-09-13 14:26:32 -0700 | [diff] [blame] | 206 | * %ADC_SCALE_THERM_150K_PULLUP: Returns temperature in degC. |
| 207 | * Uses a mapping table with 150K pullup. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 208 | * %ADC_SCALE_NONE: Do not use this scaling type. |
| 209 | */ |
| 210 | enum qpnp_adc_scale_fn_type { |
| 211 | SCALE_DEFAULT = 0, |
| 212 | SCALE_BATT_THERM, |
Siddartha Mohanadoss | e77edf1 | 2012-09-13 14:26:32 -0700 | [diff] [blame] | 213 | SCALE_THERM_100K_PULLUP, |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 214 | SCALE_PMIC_THERM, |
| 215 | SCALE_XOTHERM, |
Siddartha Mohanadoss | e77edf1 | 2012-09-13 14:26:32 -0700 | [diff] [blame] | 216 | SCALE_THERM_150K_PULLUP, |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 217 | SCALE_NONE, |
| 218 | }; |
| 219 | |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 220 | |
| 221 | /** |
| 222 | * enum qpnp_adc_tm_rscale_fn_type - Scaling function used to convert the |
| 223 | * channels input voltage/temperature to corresponding ADC code that is |
| 224 | * applied for thresholds. Check the corresponding channels scaling to |
| 225 | * determine the appropriate temperature/voltage units that are passed |
| 226 | * to the scaling function. Example battery follows the power supply |
| 227 | * framework that needs its units to be in decidegreesC so it passes |
| 228 | * deci-degreesC. PA_THERM clients pass the temperature in degrees. |
| 229 | * The order below should match the one in the driver for |
| 230 | * adc_tm_rscale_fn[]. |
| 231 | */ |
| 232 | enum qpnp_adc_tm_rscale_fn_type { |
| 233 | SCALE_R_VBATT = 0, |
| 234 | SCALE_RBATT_THERM, |
| 235 | SCALE_R_USB_ID, |
| 236 | SCALE_RPMIC_THERM, |
| 237 | SCALE_RSCALE_NONE, |
| 238 | }; |
| 239 | |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 240 | /** |
| 241 | * enum qpnp_adc_fast_avg_ctl - Provides ability to obtain single result |
| 242 | * from the ADC that is an average of multiple measurement |
| 243 | * samples. Select number of samples for use in fast |
| 244 | * average mode (i.e. 2 ^ value). |
| 245 | * %ADC_FAST_AVG_SAMPLE_1: 0x0 = 1 |
| 246 | * %ADC_FAST_AVG_SAMPLE_2: 0x1 = 2 |
| 247 | * %ADC_FAST_AVG_SAMPLE_4: 0x2 = 4 |
| 248 | * %ADC_FAST_AVG_SAMPLE_8: 0x3 = 8 |
| 249 | * %ADC_FAST_AVG_SAMPLE_16: 0x4 = 16 |
| 250 | * %ADC_FAST_AVG_SAMPLE_32: 0x5 = 32 |
| 251 | * %ADC_FAST_AVG_SAMPLE_64: 0x6 = 64 |
| 252 | * %ADC_FAST_AVG_SAMPLE_128: 0x7 = 128 |
| 253 | * %ADC_FAST_AVG_SAMPLE_256: 0x8 = 256 |
| 254 | * %ADC_FAST_AVG_SAMPLE_512: 0x9 = 512 |
| 255 | */ |
| 256 | enum qpnp_adc_fast_avg_ctl { |
| 257 | ADC_FAST_AVG_SAMPLE_1 = 0, |
| 258 | ADC_FAST_AVG_SAMPLE_2, |
| 259 | ADC_FAST_AVG_SAMPLE_4, |
| 260 | ADC_FAST_AVG_SAMPLE_8, |
| 261 | ADC_FAST_AVG_SAMPLE_16, |
| 262 | ADC_FAST_AVG_SAMPLE_32, |
| 263 | ADC_FAST_AVG_SAMPLE_64, |
| 264 | ADC_FAST_AVG_SAMPLE_128, |
| 265 | ADC_FAST_AVG_SAMPLE_256, |
| 266 | ADC_FAST_AVG_SAMPLE_512, |
| 267 | ADC_FAST_AVG_SAMPLE_NONE, |
| 268 | }; |
| 269 | |
| 270 | /** |
| 271 | * enum qpnp_adc_hw_settle_time - Time between AMUX getting configured and |
| 272 | * the ADC starting conversion. Delay = 100us * value for |
| 273 | * value < 11 and 2ms * (value - 10) otherwise. |
| 274 | * %ADC_CHANNEL_HW_SETTLE_DELAY_0US: 0us |
| 275 | * %ADC_CHANNEL_HW_SETTLE_DELAY_100US: 100us |
| 276 | * %ADC_CHANNEL_HW_SETTLE_DELAY_200US: 200us |
| 277 | * %ADC_CHANNEL_HW_SETTLE_DELAY_300US: 300us |
| 278 | * %ADC_CHANNEL_HW_SETTLE_DELAY_400US: 400us |
| 279 | * %ADC_CHANNEL_HW_SETTLE_DELAY_500US: 500us |
| 280 | * %ADC_CHANNEL_HW_SETTLE_DELAY_600US: 600us |
| 281 | * %ADC_CHANNEL_HW_SETTLE_DELAY_700US: 700us |
| 282 | * %ADC_CHANNEL_HW_SETTLE_DELAY_800US: 800us |
| 283 | * %ADC_CHANNEL_HW_SETTLE_DELAY_900US: 900us |
| 284 | * %ADC_CHANNEL_HW_SETTLE_DELAY_1MS: 1ms |
| 285 | * %ADC_CHANNEL_HW_SETTLE_DELAY_2MS: 2ms |
| 286 | * %ADC_CHANNEL_HW_SETTLE_DELAY_4MS: 4ms |
| 287 | * %ADC_CHANNEL_HW_SETTLE_DELAY_6MS: 6ms |
| 288 | * %ADC_CHANNEL_HW_SETTLE_DELAY_8MS: 8ms |
| 289 | * %ADC_CHANNEL_HW_SETTLE_DELAY_10MS: 10ms |
| 290 | * %ADC_CHANNEL_HW_SETTLE_NONE |
| 291 | */ |
| 292 | enum qpnp_adc_hw_settle_time { |
| 293 | ADC_CHANNEL_HW_SETTLE_DELAY_0US = 0, |
| 294 | ADC_CHANNEL_HW_SETTLE_DELAY_100US, |
| 295 | ADC_CHANNEL_HW_SETTLE_DELAY_2000US, |
| 296 | ADC_CHANNEL_HW_SETTLE_DELAY_300US, |
| 297 | ADC_CHANNEL_HW_SETTLE_DELAY_400US, |
| 298 | ADC_CHANNEL_HW_SETTLE_DELAY_500US, |
| 299 | ADC_CHANNEL_HW_SETTLE_DELAY_600US, |
| 300 | ADC_CHANNEL_HW_SETTLE_DELAY_700US, |
| 301 | ADC_CHANNEL_HW_SETTLE_DELAY_800US, |
| 302 | ADC_CHANNEL_HW_SETTLE_DELAY_900US, |
| 303 | ADC_CHANNEL_HW_SETTLE_DELAY_1MS, |
| 304 | ADC_CHANNEL_HW_SETTLE_DELAY_2MS, |
| 305 | ADC_CHANNEL_HW_SETTLE_DELAY_4MS, |
| 306 | ADC_CHANNEL_HW_SETTLE_DELAY_6MS, |
| 307 | ADC_CHANNEL_HW_SETTLE_DELAY_8MS, |
| 308 | ADC_CHANNEL_HW_SETTLE_DELAY_10MS, |
| 309 | ADC_CHANNEL_HW_SETTLE_NONE, |
| 310 | }; |
| 311 | |
| 312 | /** |
| 313 | * enum qpnp_vadc_mode_sel - Selects the basic mode of operation. |
| 314 | * - The normal mode is used for single measurement. |
| 315 | * - The Conversion sequencer is used to trigger an |
| 316 | * ADC read when a HW trigger is selected. |
| 317 | * - The measurement interval performs a single or |
| 318 | * continous measurement at a specified interval/delay. |
| 319 | * %ADC_OP_NORMAL_MODE : Normal mode used for single measurement. |
| 320 | * %ADC_OP_CONVERSION_SEQUENCER : Conversion sequencer used to trigger |
| 321 | * an ADC read on a HW supported trigger. |
| 322 | * Refer to enum qpnp_vadc_trigger for |
| 323 | * supported HW triggers. |
| 324 | * %ADC_OP_MEASUREMENT_INTERVAL : The measurement interval performs a |
| 325 | * single or continous measurement after a specified delay. |
| 326 | * For delay look at qpnp_adc_meas_timer. |
| 327 | */ |
| 328 | enum qpnp_vadc_mode_sel { |
| 329 | ADC_OP_NORMAL_MODE = 0, |
| 330 | ADC_OP_CONVERSION_SEQUENCER, |
| 331 | ADC_OP_MEASUREMENT_INTERVAL, |
| 332 | ADC_OP_MODE_NONE, |
| 333 | }; |
| 334 | |
| 335 | /** |
| 336 | * enum qpnp_vadc_trigger - Select the HW trigger to be used while |
| 337 | * measuring the ADC reading. |
| 338 | * %ADC_GSM_PA_ON : GSM power amplifier on. |
| 339 | * %ADC_TX_GTR_THRES : Transmit power greater than threshold. |
| 340 | * %ADC_CAMERA_FLASH_RAMP : Flash ramp up done. |
| 341 | * %ADC_DTEST : DTEST. |
| 342 | */ |
| 343 | enum qpnp_vadc_trigger { |
| 344 | ADC_GSM_PA_ON = 0, |
| 345 | ADC_TX_GTR_THRES, |
| 346 | ADC_CAMERA_FLASH_RAMP, |
| 347 | ADC_DTEST, |
| 348 | ADC_SEQ_NONE, |
| 349 | }; |
| 350 | |
| 351 | /** |
| 352 | * enum qpnp_vadc_conv_seq_timeout - Select delay (0 to 15ms) from |
| 353 | * conversion request to triggering conversion sequencer |
| 354 | * hold off time. |
| 355 | */ |
| 356 | enum qpnp_vadc_conv_seq_timeout { |
| 357 | ADC_CONV_SEQ_TIMEOUT_0MS = 0, |
| 358 | ADC_CONV_SEQ_TIMEOUT_1MS, |
| 359 | ADC_CONV_SEQ_TIMEOUT_2MS, |
| 360 | ADC_CONV_SEQ_TIMEOUT_3MS, |
| 361 | ADC_CONV_SEQ_TIMEOUT_4MS, |
| 362 | ADC_CONV_SEQ_TIMEOUT_5MS, |
| 363 | ADC_CONV_SEQ_TIMEOUT_6MS, |
| 364 | ADC_CONV_SEQ_TIMEOUT_7MS, |
| 365 | ADC_CONV_SEQ_TIMEOUT_8MS, |
| 366 | ADC_CONV_SEQ_TIMEOUT_9MS, |
| 367 | ADC_CONV_SEQ_TIMEOUT_10MS, |
| 368 | ADC_CONV_SEQ_TIMEOUT_11MS, |
| 369 | ADC_CONV_SEQ_TIMEOUT_12MS, |
| 370 | ADC_CONV_SEQ_TIMEOUT_13MS, |
| 371 | ADC_CONV_SEQ_TIMEOUT_14MS, |
| 372 | ADC_CONV_SEQ_TIMEOUT_15MS, |
| 373 | ADC_CONV_SEQ_TIMEOUT_NONE, |
| 374 | }; |
| 375 | |
| 376 | /** |
| 377 | * enum qpnp_adc_conv_seq_holdoff - Select delay from conversion |
| 378 | * trigger signal (i.e. adc_conv_seq_trig) transition |
| 379 | * to ADC enable. Delay = 25us * (value + 1). |
| 380 | */ |
| 381 | enum qpnp_adc_conv_seq_holdoff { |
| 382 | ADC_SEQ_HOLD_25US = 0, |
| 383 | ADC_SEQ_HOLD_50US, |
| 384 | ADC_SEQ_HOLD_75US, |
| 385 | ADC_SEQ_HOLD_100US, |
| 386 | ADC_SEQ_HOLD_125US, |
| 387 | ADC_SEQ_HOLD_150US, |
| 388 | ADC_SEQ_HOLD_175US, |
| 389 | ADC_SEQ_HOLD_200US, |
| 390 | ADC_SEQ_HOLD_225US, |
| 391 | ADC_SEQ_HOLD_250US, |
| 392 | ADC_SEQ_HOLD_275US, |
| 393 | ADC_SEQ_HOLD_300US, |
| 394 | ADC_SEQ_HOLD_325US, |
| 395 | ADC_SEQ_HOLD_350US, |
| 396 | ADC_SEQ_HOLD_375US, |
| 397 | ADC_SEQ_HOLD_400US, |
| 398 | ADC_SEQ_HOLD_NONE, |
| 399 | }; |
| 400 | |
| 401 | /** |
| 402 | * enum qpnp_adc_conv_seq_state - Conversion sequencer operating state |
| 403 | * %ADC_CONV_SEQ_IDLE : Sequencer is in idle. |
| 404 | * %ADC_CONV_TRIG_RISE : Waiting for rising edge trigger. |
| 405 | * %ADC_CONV_TRIG_HOLDOFF : Waiting for rising trigger hold off time. |
| 406 | * %ADC_CONV_MEAS_RISE : Measuring selected ADC signal. |
| 407 | * %ADC_CONV_TRIG_FALL : Waiting for falling trigger edge. |
| 408 | * %ADC_CONV_FALL_HOLDOFF : Waiting for falling trigger hold off time. |
| 409 | * %ADC_CONV_MEAS_FALL : Measuring selected ADC signal. |
| 410 | * %ADC_CONV_ERROR : Aberrant Hardware problem. |
| 411 | */ |
| 412 | enum qpnp_adc_conv_seq_state { |
| 413 | ADC_CONV_SEQ_IDLE = 0, |
| 414 | ADC_CONV_TRIG_RISE, |
| 415 | ADC_CONV_TRIG_HOLDOFF, |
| 416 | ADC_CONV_MEAS_RISE, |
| 417 | ADC_CONV_TRIG_FALL, |
| 418 | ADC_CONV_FALL_HOLDOFF, |
| 419 | ADC_CONV_MEAS_FALL, |
| 420 | ADC_CONV_ERROR, |
| 421 | ADC_CONV_NONE, |
| 422 | }; |
| 423 | |
| 424 | /** |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 425 | * enum qpnp_adc_meas_timer_1 - Selects the measurement interval time. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 426 | * If value = 0, use 0ms else use 2^(value + 4)/ 32768). |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 427 | * The timer period is used by the USB_ID. Do not set a polling rate |
| 428 | * greater than 1 second on PMIC 2.0. The max polling rate on the PMIC 2.0 |
| 429 | * appears to be limited to 1 second. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 430 | * %ADC_MEAS_INTERVAL_0MS : 0ms |
| 431 | * %ADC_MEAS_INTERVAL_1P0MS : 1ms |
| 432 | * %ADC_MEAS_INTERVAL_2P0MS : 2ms |
| 433 | * %ADC_MEAS_INTERVAL_3P9MS : 3.9ms |
| 434 | * %ADC_MEAS_INTERVAL_7P8MS : 7.8ms |
| 435 | * %ADC_MEAS_INTERVAL_15P6MS : 15.6ms |
| 436 | * %ADC_MEAS_INTERVAL_31P3MS : 31.3ms |
| 437 | * %ADC_MEAS_INTERVAL_62P5MS : 62.5ms |
| 438 | * %ADC_MEAS_INTERVAL_125MS : 125ms |
| 439 | * %ADC_MEAS_INTERVAL_250MS : 250ms |
| 440 | * %ADC_MEAS_INTERVAL_500MS : 500ms |
| 441 | * %ADC_MEAS_INTERVAL_1S : 1seconds |
| 442 | * %ADC_MEAS_INTERVAL_2S : 2seconds |
| 443 | * %ADC_MEAS_INTERVAL_4S : 4seconds |
| 444 | * %ADC_MEAS_INTERVAL_8S : 8seconds |
| 445 | * %ADC_MEAS_INTERVAL_16S: 16seconds |
| 446 | */ |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 447 | enum qpnp_adc_meas_timer_1 { |
| 448 | ADC_MEAS1_INTERVAL_0MS = 0, |
| 449 | ADC_MEAS1_INTERVAL_1P0MS, |
| 450 | ADC_MEAS1_INTERVAL_2P0MS, |
| 451 | ADC_MEAS1_INTERVAL_3P9MS, |
| 452 | ADC_MEAS1_INTERVAL_7P8MS, |
| 453 | ADC_MEAS1_INTERVAL_15P6MS, |
| 454 | ADC_MEAS1_INTERVAL_31P3MS, |
| 455 | ADC_MEAS1_INTERVAL_62P5MS, |
| 456 | ADC_MEAS1_INTERVAL_125MS, |
| 457 | ADC_MEAS1_INTERVAL_250MS, |
| 458 | ADC_MEAS1_INTERVAL_500MS, |
| 459 | ADC_MEAS1_INTERVAL_1S, |
| 460 | ADC_MEAS1_INTERVAL_2S, |
| 461 | ADC_MEAS1_INTERVAL_4S, |
| 462 | ADC_MEAS1_INTERVAL_8S, |
| 463 | ADC_MEAS1_INTERVAL_16S, |
| 464 | ADC_MEAS1_INTERVAL_NONE, |
| 465 | }; |
| 466 | |
| 467 | /** |
| 468 | * enum qpnp_adc_meas_timer_2 - Selects the measurement interval time. |
| 469 | * If value = 0, use 0ms else use 2^(value + 4)/ 32768). |
| 470 | * The timer period is used by the batt_therm. Do not set a polling rate |
| 471 | * greater than 1 second on PMIC 2.0. The max polling rate on the PMIC 2.0 |
| 472 | * appears to be limited to 1 second. |
| 473 | * %ADC_MEAS_INTERVAL_0MS : 0ms |
| 474 | * %ADC_MEAS_INTERVAL_100MS : 100ms |
| 475 | * %ADC_MEAS_INTERVAL_200MS : 200ms |
| 476 | * %ADC_MEAS_INTERVAL_300MS : 300ms |
| 477 | * %ADC_MEAS_INTERVAL_400MS : 400ms |
| 478 | * %ADC_MEAS_INTERVAL_500MS : 500ms |
| 479 | * %ADC_MEAS_INTERVAL_600MS : 600ms |
| 480 | * %ADC_MEAS_INTERVAL_700MS : 700ms |
| 481 | * %ADC_MEAS_INTERVAL_800MS : 800ms |
| 482 | * %ADC_MEAS_INTERVAL_900MS : 900ms |
| 483 | * %ADC_MEAS_INTERVAL_1S: 1seconds |
| 484 | * %ADC_MEAS_INTERVAL_1P1S: 1.1seconds |
| 485 | * %ADC_MEAS_INTERVAL_1P2S: 1.2seconds |
| 486 | * %ADC_MEAS_INTERVAL_1P3S: 1.3seconds |
| 487 | * %ADC_MEAS_INTERVAL_1P4S: 1.4seconds |
| 488 | * %ADC_MEAS_INTERVAL_1P5S: 1.5seconds |
| 489 | */ |
| 490 | enum qpnp_adc_meas_timer_2 { |
| 491 | ADC_MEAS2_INTERVAL_0MS = 0, |
| 492 | ADC_MEAS2_INTERVAL_100MS, |
| 493 | ADC_MEAS2_INTERVAL_200MS, |
| 494 | ADC_MEAS2_INTERVAL_300MS, |
| 495 | ADC_MEAS2_INTERVAL_400MS, |
| 496 | ADC_MEAS2_INTERVAL_500MS, |
| 497 | ADC_MEAS2_INTERVAL_600MS, |
| 498 | ADC_MEAS2_INTERVAL_700MS, |
| 499 | ADC_MEAS2_INTERVAL_800MS, |
| 500 | ADC_MEAS2_INTERVAL_900MS, |
| 501 | ADC_MEAS2_INTERVAL_1S, |
| 502 | ADC_MEAS2_INTERVAL_1P1S, |
| 503 | ADC_MEAS2_INTERVAL_1P2S, |
| 504 | ADC_MEAS2_INTERVAL_1P3S, |
| 505 | ADC_MEAS2_INTERVAL_1P4S, |
| 506 | ADC_MEAS2_INTERVAL_1P5S, |
| 507 | ADC_MEAS2_INTERVAL_NONE, |
| 508 | }; |
| 509 | |
| 510 | /** |
| 511 | * enum qpnp_adc_meas_timer_3 - Selects the measurement interval time. |
| 512 | * If value = 0, use 0ms else use 2^(value + 4)/ 32768). |
| 513 | * Do not set a polling rate greater than 1 second on PMIC 2.0. |
| 514 | * The max polling rate on the PMIC 2.0 appears to be limited to 1 second. |
| 515 | * %ADC_MEAS_INTERVAL_0MS : 0ms |
| 516 | * %ADC_MEAS_INTERVAL_1S : 1seconds |
| 517 | * %ADC_MEAS_INTERVAL_2S : 2seconds |
| 518 | * %ADC_MEAS_INTERVAL_3S : 3seconds |
| 519 | * %ADC_MEAS_INTERVAL_4S : 4seconds |
| 520 | * %ADC_MEAS_INTERVAL_5S : 5seconds |
| 521 | * %ADC_MEAS_INTERVAL_6S: 6seconds |
| 522 | * %ADC_MEAS_INTERVAL_7S : 7seconds |
| 523 | * %ADC_MEAS_INTERVAL_8S : 8seconds |
| 524 | * %ADC_MEAS_INTERVAL_9S : 9seconds |
| 525 | * %ADC_MEAS_INTERVAL_10S : 10seconds |
| 526 | * %ADC_MEAS_INTERVAL_11S : 11seconds |
| 527 | * %ADC_MEAS_INTERVAL_12S : 12seconds |
| 528 | * %ADC_MEAS_INTERVAL_13S : 13seconds |
| 529 | * %ADC_MEAS_INTERVAL_14S : 14seconds |
| 530 | * %ADC_MEAS_INTERVAL_15S : 15seconds |
| 531 | */ |
| 532 | enum qpnp_adc_meas_timer_3 { |
| 533 | ADC_MEAS3_INTERVAL_0S = 0, |
| 534 | ADC_MEAS3_INTERVAL_1S, |
| 535 | ADC_MEAS3_INTERVAL_2S, |
| 536 | ADC_MEAS3_INTERVAL_3S, |
| 537 | ADC_MEAS3_INTERVAL_4S, |
| 538 | ADC_MEAS3_INTERVAL_5S, |
| 539 | ADC_MEAS3_INTERVAL_6S, |
| 540 | ADC_MEAS3_INTERVAL_7S, |
| 541 | ADC_MEAS3_INTERVAL_8S, |
| 542 | ADC_MEAS3_INTERVAL_9S, |
| 543 | ADC_MEAS3_INTERVAL_10S, |
| 544 | ADC_MEAS3_INTERVAL_11S, |
| 545 | ADC_MEAS3_INTERVAL_12S, |
| 546 | ADC_MEAS3_INTERVAL_13S, |
| 547 | ADC_MEAS3_INTERVAL_14S, |
| 548 | ADC_MEAS3_INTERVAL_15S, |
| 549 | ADC_MEAS3_INTERVAL_NONE, |
| 550 | }; |
| 551 | |
| 552 | /** |
| 553 | * enum qpnp_adc_meas_timer_select - Selects the timer for which |
| 554 | * the appropriate polling frequency is set. |
| 555 | * %ADC_MEAS_TIMER_SELECT1 - Select this timer if the client is USB_ID. |
| 556 | * %ADC_MEAS_TIMER_SELECT2 - Select this timer if the client is batt_therm. |
| 557 | * %ADC_MEAS_TIMER_SELECT3 - The timer is added only for completion. It is |
| 558 | * not used by kernel space clients and user space clients cannot set |
| 559 | * the polling frequency. The driver will set a appropriate polling |
| 560 | * frequency to measure the user space clients from qpnp_adc_meas_timer_3. |
| 561 | */ |
| 562 | enum qpnp_adc_meas_timer_select { |
| 563 | ADC_MEAS_TIMER_SELECT1 = 0, |
| 564 | ADC_MEAS_TIMER_SELECT2, |
| 565 | ADC_MEAS_TIMER_SELECT3, |
| 566 | ADC_MEAS_TIMER_NUM, |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 567 | }; |
| 568 | |
| 569 | /** |
| 570 | * enum qpnp_adc_meas_interval_op_ctl - Select operating mode. |
| 571 | * %ADC_MEAS_INTERVAL_OP_SINGLE : Conduct single measurement at specified time |
| 572 | * delay. |
| 573 | * %ADC_MEAS_INTERVAL_OP_CONTINUOUS : Make measurements at measurement interval |
| 574 | * times. |
| 575 | */ |
| 576 | enum qpnp_adc_meas_interval_op_ctl { |
| 577 | ADC_MEAS_INTERVAL_OP_SINGLE = 0, |
| 578 | ADC_MEAS_INTERVAL_OP_CONTINUOUS, |
| 579 | ADC_MEAS_INTERVAL_OP_NONE, |
| 580 | }; |
| 581 | |
| 582 | /** |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 583 | * Channel selection registers for each of the configurable measurements |
| 584 | * Channels allotment is set at device config for a channel. |
| 585 | * The USB_ID, BATT_THERM, PMIC_THERM and VBAT channels are used by the |
| 586 | * kernel space USB, Battery and IADC drivers. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 587 | * The other 3 channels are configurable for use by userspace clients. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 588 | */ |
| 589 | enum qpnp_adc_tm_channel_select { |
| 590 | QPNP_ADC_TM_M0_ADC_CH_SEL_CTL = 0x48, |
| 591 | QPNP_ADC_TM_M1_ADC_CH_SEL_CTL = 0x68, |
| 592 | QPNP_ADC_TM_M2_ADC_CH_SEL_CTL = 0x70, |
| 593 | QPNP_ADC_TM_M3_ADC_CH_SEL_CTL = 0x78, |
| 594 | QPNP_ADC_TM_M4_ADC_CH_SEL_CTL = 0x80, |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 595 | QPNP_ADC_TM_M5_ADC_CH_SEL_CTL = 0x88, |
| 596 | QPNP_ADC_TM_M6_ADC_CH_SEL_CTL = 0x90, |
| 597 | QPNP_ADC_TM_M7_ADC_CH_SEL_CTL = 0x98, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 598 | QPNP_ADC_TM_CH_SELECT_NONE |
| 599 | }; |
| 600 | |
| 601 | /** |
| 602 | * struct qpnp_adc_tm_config - Represent ADC Thermal Monitor configuration. |
| 603 | * @channel: ADC channel for which thermal monitoring is requested. |
| 604 | * @adc_code: The pre-calibrated digital output of a given ADC releative to the |
| 605 | * ADC reference. |
| 606 | * @high_thr_temp: Temperature at which high threshold notification is required. |
| 607 | * @low_thr_temp: Temperature at which low threshold notification is required. |
| 608 | * @low_thr_voltage : Low threshold voltage ADC code used for reverse |
| 609 | * calibration. |
| 610 | * @high_thr_voltage: High threshold voltage ADC code used for reverse |
| 611 | * calibration. |
| 612 | */ |
| 613 | struct qpnp_adc_tm_config { |
| 614 | int channel; |
| 615 | int adc_code; |
| 616 | int high_thr_temp; |
| 617 | int low_thr_temp; |
| 618 | int64_t high_thr_voltage; |
| 619 | int64_t low_thr_voltage; |
| 620 | }; |
| 621 | |
| 622 | /** |
| 623 | * enum qpnp_adc_tm_trip_type - Type for setting high/low temperature/voltage. |
| 624 | * %ADC_TM_TRIP_HIGH_WARM: Setting high temperature. Note that high temperature |
| 625 | * corresponds to low voltage. Driver handles this case |
| 626 | * appropriately to set high/low thresholds for voltage. |
| 627 | * threshold. |
| 628 | * %ADC_TM_TRIP_LOW_COOL: Setting low temperature. |
| 629 | */ |
| 630 | enum qpnp_adc_tm_trip_type { |
| 631 | ADC_TM_TRIP_HIGH_WARM = 0, |
| 632 | ADC_TM_TRIP_LOW_COOL, |
| 633 | ADC_TM_TRIP_NUM, |
| 634 | }; |
| 635 | |
| 636 | /** |
| 637 | * enum qpnp_tm_state - This lets the client know whether the threshold |
| 638 | * that was crossed was high/low. |
| 639 | * %ADC_TM_HIGH_STATE: Client is notified of crossing the requested high |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 640 | * voltage threshold. |
| 641 | * %ADC_TM_COOL_STATE: Client is notified of crossing the requested cool |
| 642 | * temperature threshold. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 643 | * %ADC_TM_LOW_STATE: Client is notified of crossing the requested low |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 644 | * voltage threshold. |
| 645 | * %ADC_TM_WARM_STATE: Client is notified of crossing the requested high |
| 646 | * temperature threshold. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 647 | */ |
| 648 | enum qpnp_tm_state { |
| 649 | ADC_TM_HIGH_STATE = 0, |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 650 | ADC_TM_COOL_STATE = ADC_TM_HIGH_STATE, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 651 | ADC_TM_LOW_STATE, |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 652 | ADC_TM_WARM_STATE = ADC_TM_LOW_STATE, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 653 | ADC_TM_STATE_NUM, |
| 654 | }; |
| 655 | |
| 656 | /** |
| 657 | * enum qpnp_state_request - Request to enable/disable the corresponding |
| 658 | * high/low voltage/temperature thresholds. |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 659 | * %ADC_TM_HIGH_THR_ENABLE: Enable high voltage threshold. |
| 660 | * %ADC_TM_COOL_THR_ENABLE = Enables cool temperature threshold. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 661 | * %ADC_TM_LOW_THR_ENABLE: Enable low voltage/temperature threshold. |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 662 | * %ADC_TM_WARM_THR_ENABLE = Enables warm temperature threshold. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 663 | * %ADC_TM_HIGH_LOW_THR_ENABLE: Enable high and low voltage/temperature |
| 664 | * threshold. |
| 665 | * %ADC_TM_HIGH_THR_DISABLE: Disable high voltage/temperature threshold. |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 666 | * %ADC_TM_COOL_THR_ENABLE = Disables cool temperature threshold. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 667 | * %ADC_TM_LOW_THR_DISABLE: Disable low voltage/temperature threshold. |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 668 | * %ADC_TM_WARM_THR_ENABLE = Disables warm temperature threshold. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 669 | * %ADC_TM_HIGH_THR_DISABLE: Disable high and low voltage/temperature |
| 670 | * threshold. |
| 671 | */ |
| 672 | enum qpnp_state_request { |
| 673 | ADC_TM_HIGH_THR_ENABLE = 0, |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 674 | ADC_TM_COOL_THR_ENABLE = ADC_TM_HIGH_THR_ENABLE, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 675 | ADC_TM_LOW_THR_ENABLE, |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 676 | ADC_TM_WARM_THR_ENABLE = ADC_TM_LOW_THR_ENABLE, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 677 | ADC_TM_HIGH_LOW_THR_ENABLE, |
| 678 | ADC_TM_HIGH_THR_DISABLE, |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 679 | ADC_TM_COOL_THR_DISABLE = ADC_TM_HIGH_THR_DISABLE, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 680 | ADC_TM_LOW_THR_DISABLE, |
Siddartha Mohanadoss | b8109da | 2013-03-25 09:53:43 -0700 | [diff] [blame] | 681 | ADC_TM_WARM_THR_DISABLE = ADC_TM_LOW_THR_DISABLE, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 682 | ADC_TM_HIGH_LOW_THR_DISABLE, |
| 683 | ADC_TM_THR_NUM, |
| 684 | }; |
| 685 | |
| 686 | /** |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 687 | * struct qpnp_adc_tm_btm_param - Represent Battery temperature threshold |
| 688 | * monitoring configuration. |
| 689 | * @high_temp: High temperature threshold for which notification is requested. |
| 690 | * @low_temp: Low temperature threshold for which notification is requested. |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 691 | * @high_thr_voltage: High voltage for which notification is requested. |
| 692 | * @low_thr_voltage: Low voltage for which notification is requested. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 693 | * @state_request: Enable/disable the corresponding high and low temperature |
| 694 | * thresholds. |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 695 | * @timer_interval1: Select polling rate from qpnp_adc_meas_timer_1 type. |
| 696 | * @timer_interval2: Select polling rate from qpnp_adc_meas_timer_2 type. |
| 697 | * @timer_interval3: Select polling rate from qpnp_adc_meas_timer_3 type. |
Siddartha Mohanadoss | d71e240 | 2013-02-01 17:36:23 -0800 | [diff] [blame] | 698 | * @btmid_ctx: A context of void type. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 699 | * @threshold_notification: Notification callback once threshold are crossed. |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 700 | * units to be used for High/Low temperature and voltage notification - |
| 701 | * This depends on the clients usage. Check the rscaling function |
| 702 | * for the appropriate channel nodes. |
| 703 | * @Batt therm clients temperature units is decidegreesCentigrate. |
| 704 | * @USB_ID inputs the voltage units in milli-volts. |
| 705 | * @PA_THERM inputs the units in degC. |
| 706 | * @PMIC_THERM inputs the units in millidegC. |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 707 | */ |
| 708 | struct qpnp_adc_tm_btm_param { |
| 709 | int32_t high_temp; |
| 710 | int32_t low_temp; |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 711 | int32_t high_thr; |
| 712 | int32_t low_thr; |
| 713 | enum qpnp_vadc_channels channel; |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 714 | enum qpnp_state_request state_request; |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 715 | enum qpnp_adc_meas_timer_1 timer_interval; |
| 716 | enum qpnp_adc_meas_timer_2 timer_interval2; |
| 717 | enum qpnp_adc_meas_timer_3 timer_interval3; |
Siddartha Mohanadoss | d71e240 | 2013-02-01 17:36:23 -0800 | [diff] [blame] | 718 | void *btm_ctx; |
| 719 | void (*threshold_notification) (enum qpnp_tm_state state, |
| 720 | void *ctx); |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 721 | }; |
| 722 | |
| 723 | /** |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 724 | * struct qpnp_vadc_linear_graph - Represent ADC characteristics. |
| 725 | * @dy: Numerator slope to calculate the gain. |
| 726 | * @dx: Denominator slope to calculate the gain. |
| 727 | * @adc_vref: A/D word of the voltage reference used for the channel. |
| 728 | * @adc_gnd: A/D word of the ground reference used for the channel. |
| 729 | * |
| 730 | * Each ADC device has different offset and gain parameters which are computed |
| 731 | * to calibrate the device. |
| 732 | */ |
| 733 | struct qpnp_vadc_linear_graph { |
| 734 | int64_t dy; |
| 735 | int64_t dx; |
| 736 | int64_t adc_vref; |
| 737 | int64_t adc_gnd; |
| 738 | }; |
| 739 | |
| 740 | /** |
| 741 | * struct qpnp_vadc_map_pt - Map the graph representation for ADC channel |
| 742 | * @x: Represent the ADC digitized code. |
| 743 | * @y: Represent the physical data which can be temperature, voltage, |
| 744 | * resistance. |
| 745 | */ |
| 746 | struct qpnp_vadc_map_pt { |
| 747 | int32_t x; |
| 748 | int32_t y; |
| 749 | }; |
| 750 | |
| 751 | /** |
| 752 | * struct qpnp_vadc_scaling_ratio - Represent scaling ratio for adc input. |
| 753 | * @num: Numerator scaling parameter. |
| 754 | * @den: Denominator scaling parameter. |
| 755 | */ |
| 756 | struct qpnp_vadc_scaling_ratio { |
| 757 | int32_t num; |
| 758 | int32_t den; |
| 759 | }; |
| 760 | |
| 761 | /** |
| 762 | * struct qpnp_adc_properties - Represent the ADC properties. |
| 763 | * @adc_reference: Reference voltage for QPNP ADC. |
| 764 | * @bitresolution: ADC bit resolution for QPNP ADC. |
| 765 | * @biploar: Polarity for QPNP ADC. |
| 766 | */ |
| 767 | struct qpnp_adc_properties { |
| 768 | uint32_t adc_vdd_reference; |
| 769 | uint32_t bitresolution; |
| 770 | bool bipolar; |
| 771 | }; |
| 772 | |
| 773 | /** |
| 774 | * struct qpnp_vadc_chan_properties - Represent channel properties of the ADC. |
| 775 | * @offset_gain_numerator: The inverse numerator of the gain applied to the |
| 776 | * input channel. |
| 777 | * @offset_gain_denominator: The inverse denominator of the gain applied to the |
| 778 | * input channel. |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 779 | * @high_thr: High threshold voltage that is requested to be set. |
| 780 | * @low_thr: Low threshold voltage that is requested to be set. |
| 781 | * @timer_select: Choosen from one of the 3 timers to set the polling rate for |
| 782 | * the VADC_BTM channel. |
| 783 | * @meas_interval1: Polling rate to set for timer 1. |
| 784 | * @meas_interval2: Polling rate to set for timer 2. |
| 785 | * @tm_channel_select: BTM channel number for the 5 VADC_BTM channels. |
| 786 | * @state_request: User can select either enable or disable high/low or both |
| 787 | * activation levels based on the qpnp_state_request type. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 788 | * @adc_graph: ADC graph for the channel of struct type qpnp_adc_linear_graph. |
| 789 | */ |
| 790 | struct qpnp_vadc_chan_properties { |
| 791 | uint32_t offset_gain_numerator; |
| 792 | uint32_t offset_gain_denominator; |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 793 | uint32_t high_thr; |
| 794 | uint32_t low_thr; |
| 795 | enum qpnp_adc_meas_timer_select timer_select; |
| 796 | enum qpnp_adc_meas_timer_1 meas_interval1; |
| 797 | enum qpnp_adc_meas_timer_2 meas_interval2; |
| 798 | enum qpnp_adc_tm_channel_select tm_channel_select; |
| 799 | enum qpnp_state_request state_request; |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 800 | struct qpnp_vadc_linear_graph adc_graph[2]; |
| 801 | }; |
| 802 | |
| 803 | /** |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 804 | * struct qpnp_vadc_result - Represent the result of the QPNP ADC. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 805 | * @chan: The channel number of the requested conversion. |
| 806 | * @adc_code: The pre-calibrated digital output of a given ADC relative to the |
| 807 | * the ADC reference. |
| 808 | * @measurement: In units specific for a given ADC; most ADC uses reference |
| 809 | * voltage but some ADC uses reference current. This measurement |
| 810 | * here is a number relative to a reference of a given ADC. |
| 811 | * @physical: The data meaningful for each individual channel whether it is |
| 812 | * voltage, current, temperature, etc. |
| 813 | * All voltage units are represented in micro - volts. |
| 814 | * -Battery temperature units are represented as 0.1 DegC. |
| 815 | * -PA Therm temperature units are represented as DegC. |
| 816 | * -PMIC Die temperature units are represented as 0.001 DegC. |
| 817 | */ |
| 818 | struct qpnp_vadc_result { |
| 819 | uint32_t chan; |
| 820 | int32_t adc_code; |
| 821 | int64_t measurement; |
| 822 | int64_t physical; |
| 823 | }; |
| 824 | |
| 825 | /** |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 826 | * struct qpnp_adc_amux - AMUX properties for individual channel |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 827 | * @name: Channel string name. |
| 828 | * @channel_num: Channel in integer used from qpnp_adc_channels. |
| 829 | * @chan_path_prescaling: Channel scaling performed on the input signal. |
| 830 | * @adc_decimation: Sampling rate desired for the channel. |
| 831 | * adc_scale_fn: Scaling function to convert to the data meaningful for |
| 832 | * each individual channel whether it is voltage, current, |
| 833 | * temperature, etc and compensates the channel properties. |
| 834 | */ |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 835 | struct qpnp_adc_amux { |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 836 | char *name; |
| 837 | enum qpnp_vadc_channels channel_num; |
| 838 | enum qpnp_adc_channel_scaling_param chan_path_prescaling; |
| 839 | enum qpnp_adc_decimation_type adc_decimation; |
| 840 | enum qpnp_adc_scale_fn_type adc_scale_fn; |
| 841 | enum qpnp_adc_fast_avg_ctl fast_avg_setup; |
| 842 | enum qpnp_adc_hw_settle_time hw_settle_time; |
| 843 | }; |
| 844 | |
| 845 | /** |
| 846 | * struct qpnp_vadc_scaling_ratio |
| 847 | * |
| 848 | */ |
| 849 | static const struct qpnp_vadc_scaling_ratio qpnp_vadc_amux_scaling_ratio[] = { |
| 850 | {1, 1}, |
| 851 | {1, 3}, |
| 852 | {1, 4}, |
| 853 | {1, 6}, |
| 854 | {1, 20} |
| 855 | }; |
| 856 | |
| 857 | /** |
| 858 | * struct qpnp_vadc_scale_fn - Scaling function prototype |
| 859 | * @chan: Function pointer to one of the scaling functions |
| 860 | * which takes the adc properties, channel properties, |
| 861 | * and returns the physical result |
| 862 | */ |
| 863 | struct qpnp_vadc_scale_fn { |
| 864 | int32_t (*chan) (int32_t, |
| 865 | const struct qpnp_adc_properties *, |
| 866 | const struct qpnp_vadc_chan_properties *, |
| 867 | struct qpnp_vadc_result *); |
| 868 | }; |
| 869 | |
| 870 | /** |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 871 | * struct qpnp_adc_tm_reverse_scale_fn - Reverse scaling prototype |
| 872 | * @chan: Function pointer to one of the scaling functions |
| 873 | * which takes the adc properties, channel properties, |
| 874 | * and returns the physical result |
| 875 | */ |
| 876 | struct qpnp_adc_tm_reverse_scale_fn { |
| 877 | int32_t (*chan) (struct qpnp_adc_tm_btm_param *, |
| 878 | uint32_t *, uint32_t *); |
| 879 | }; |
| 880 | |
| 881 | /** |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 882 | * struct qpnp_iadc_calib - IADC channel calibration structure. |
| 883 | * @channel - Channel for which the historical offset and gain is |
| 884 | * calculated. Available channels are internal rsense, |
| 885 | * external rsense and alternate lead pairs. |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 886 | * @offset_raw - raw Offset value for the channel. |
| 887 | * @gain_raw - raw Gain of the channel. |
| 888 | * @ideal_offset_uv - ideal offset value for the channel. |
| 889 | * @ideal_gain_nv - ideal gain for the channel. |
| 890 | * @offset_uv - converted value of offset in uV. |
| 891 | * @gain_uv - converted value of gain in uV. |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 892 | */ |
| 893 | struct qpnp_iadc_calib { |
| 894 | enum qpnp_iadc_channels channel; |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 895 | uint16_t offset_raw; |
| 896 | uint16_t gain_raw; |
| 897 | uint32_t ideal_offset_uv; |
| 898 | uint32_t ideal_gain_nv; |
| 899 | uint32_t offset_uv; |
| 900 | uint32_t gain_uv; |
| 901 | }; |
| 902 | |
| 903 | /** |
| 904 | * struct qpnp_iadc_result - IADC read result structure. |
| 905 | * @oresult_uv - Result of ADC in uV. |
| 906 | * @result_ua - Result of ADC in uA. |
| 907 | */ |
| 908 | struct qpnp_iadc_result { |
| 909 | int32_t result_uv; |
| 910 | int32_t result_ua; |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 911 | }; |
| 912 | |
| 913 | /** |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 914 | * struct qpnp_adc_drv - QPNP ADC device structure. |
| 915 | * @spmi - spmi device for ADC peripheral. |
| 916 | * @offset - base offset for the ADC peripheral. |
| 917 | * @adc_prop - ADC properties specific to the ADC peripheral. |
| 918 | * @amux_prop - AMUX properties representing the ADC peripheral. |
| 919 | * @adc_channels - ADC channel properties for the ADC peripheral. |
Siddartha Mohanadoss | 1210995 | 2012-11-20 14:57:51 -0800 | [diff] [blame] | 920 | * @adc_irq_eoc - End of Conversion IRQ. |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 921 | * @adc_irq_fifo_not_empty - Conversion sequencer request written |
| 922 | * to FIFO when not empty. |
| 923 | * @adc_irq_conv_seq_timeout - Conversion sequencer trigger timeout. |
| 924 | * @adc_high_thr_irq - Output higher than high threshold set for measurement. |
| 925 | * @adc_low_thr_irq - Output lower than low threshold set for measurement. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 926 | * @adc_lock - ADC lock for access to the peripheral. |
| 927 | * @adc_rslt_completion - ADC result notification after interrupt |
| 928 | * is received. |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 929 | * @calib - Internal rsens calibration values for gain and offset. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 930 | */ |
| 931 | struct qpnp_adc_drv { |
| 932 | struct spmi_device *spmi; |
| 933 | uint8_t slave; |
| 934 | uint16_t offset; |
| 935 | struct qpnp_adc_properties *adc_prop; |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 936 | struct qpnp_adc_amux_properties *amux_prop; |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 937 | struct qpnp_adc_amux *adc_channels; |
Siddartha Mohanadoss | 1210995 | 2012-11-20 14:57:51 -0800 | [diff] [blame] | 938 | int adc_irq_eoc; |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 939 | int adc_irq_fifo_not_empty; |
| 940 | int adc_irq_conv_seq_timeout; |
| 941 | int adc_high_thr_irq; |
| 942 | int adc_low_thr_irq; |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 943 | struct mutex adc_lock; |
| 944 | struct completion adc_rslt_completion; |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 945 | struct qpnp_iadc_calib calib; |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 946 | }; |
| 947 | |
| 948 | /** |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 949 | * struct qpnp_adc_amux_properties - QPNP VADC amux channel property. |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 950 | * @amux_channel - Refer to the qpnp_vadc_channel list. |
| 951 | * @decimation - Sampling rate supported for the channel. |
| 952 | * @mode_sel - The basic mode of operation. |
| 953 | * @hw_settle_time - The time between AMUX being configured and the |
| 954 | * start of conversion. |
| 955 | * @fast_avg_setup - Ability to provide single result from the ADC |
| 956 | * that is an average of multiple measurements. |
| 957 | * @trigger_channel - HW trigger channel for conversion sequencer. |
| 958 | * @chan_prop - Represent the channel properties of the ADC. |
| 959 | */ |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 960 | struct qpnp_adc_amux_properties { |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 961 | uint32_t amux_channel; |
| 962 | uint32_t decimation; |
| 963 | uint32_t mode_sel; |
| 964 | uint32_t hw_settle_time; |
| 965 | uint32_t fast_avg_setup; |
| 966 | enum qpnp_vadc_trigger trigger_channel; |
| 967 | struct qpnp_vadc_chan_properties chan_prop[0]; |
| 968 | }; |
| 969 | |
| 970 | /* Public API */ |
| 971 | #if defined(CONFIG_SENSORS_QPNP_ADC_VOLTAGE) \ |
| 972 | || defined(CONFIG_SENSORS_QPNP_ADC_VOLTAGE_MODULE) |
| 973 | /** |
| 974 | * qpnp_vadc_read() - Performs ADC read on the channel. |
| 975 | * @channel: Input channel to perform the ADC read. |
| 976 | * @result: Structure pointer of type adc_chan_result |
| 977 | * in which the ADC read results are stored. |
| 978 | */ |
| 979 | int32_t qpnp_vadc_read(enum qpnp_vadc_channels channel, |
| 980 | struct qpnp_vadc_result *result); |
| 981 | |
| 982 | /** |
| 983 | * qpnp_vadc_conv_seq_request() - Performs ADC read on the conversion |
| 984 | * sequencer channel. |
| 985 | * @channel: Input channel to perform the ADC read. |
| 986 | * @result: Structure pointer of type adc_chan_result |
| 987 | * in which the ADC read results are stored. |
| 988 | */ |
| 989 | int32_t qpnp_vadc_conv_seq_request( |
| 990 | enum qpnp_vadc_trigger trigger_channel, |
| 991 | enum qpnp_vadc_channels channel, |
| 992 | struct qpnp_vadc_result *result); |
| 993 | |
| 994 | /** |
| 995 | * qpnp_vadc_check_result() - Performs check on the ADC raw code. |
| 996 | * @data: Data used for verifying the range of the ADC code. |
| 997 | */ |
| 998 | int32_t qpnp_vadc_check_result(int32_t *data); |
| 999 | |
| 1000 | /** |
| 1001 | * qpnp_adc_get_devicetree_data() - Abstracts the ADC devicetree data. |
| 1002 | * @spmi: spmi ADC device. |
| 1003 | * @adc_qpnp: spmi device tree node structure |
| 1004 | */ |
| 1005 | int32_t qpnp_adc_get_devicetree_data(struct spmi_device *spmi, |
| 1006 | struct qpnp_adc_drv *adc_qpnp); |
| 1007 | |
| 1008 | /** |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 1009 | * qpnp_adc_scale_default() - Scales the pre-calibrated digital output |
| 1010 | * of an ADC to the ADC reference and compensates for the |
| 1011 | * gain and offset. |
| 1012 | * @adc_code: pre-calibrated digital ouput of the ADC. |
| 1013 | * @adc_prop: adc properties of the qpnp adc such as bit resolution, |
| 1014 | * reference voltage. |
| 1015 | * @chan_prop: Individual channel properties to compensate the i/p scaling, |
| 1016 | * slope and offset. |
| 1017 | * @chan_rslt: Physical result to be stored. |
| 1018 | */ |
| 1019 | int32_t qpnp_adc_scale_default(int32_t adc_code, |
| 1020 | const struct qpnp_adc_properties *adc_prop, |
| 1021 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1022 | struct qpnp_vadc_result *chan_rslt); |
Siddartha Mohanadoss | 5ace110 | 2012-08-20 23:18:10 -0700 | [diff] [blame] | 1023 | /** |
| 1024 | * qpnp_adc_scale_pmic_therm() - Scales the pre-calibrated digital output |
| 1025 | * of an ADC to the ADC reference and compensates for the |
| 1026 | * gain and offset. Performs the AMUX out as 2mV/K and returns |
| 1027 | * the temperature in milli degC. |
| 1028 | * @adc_code: pre-calibrated digital ouput of the ADC. |
| 1029 | * @adc_prop: adc properties of the qpnp adc such as bit resolution, |
| 1030 | * reference voltage. |
| 1031 | * @chan_prop: Individual channel properties to compensate the i/p scaling, |
| 1032 | * slope and offset. |
| 1033 | * @chan_rslt: Physical result to be stored. |
| 1034 | */ |
| 1035 | int32_t qpnp_adc_scale_pmic_therm(int32_t adc_code, |
| 1036 | const struct qpnp_adc_properties *adc_prop, |
| 1037 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1038 | struct qpnp_vadc_result *chan_rslt); |
| 1039 | /** |
| 1040 | * qpnp_adc_scale_batt_therm() - Scales the pre-calibrated digital output |
| 1041 | * of an ADC to the ADC reference and compensates for the |
| 1042 | * gain and offset. Returns the temperature in degC. |
| 1043 | * @adc_code: pre-calibrated digital ouput of the ADC. |
| 1044 | * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, |
| 1045 | * reference voltage. |
| 1046 | * @chan_prop: individual channel properties to compensate the i/p scaling, |
| 1047 | * slope and offset. |
| 1048 | * @chan_rslt: physical result to be stored. |
| 1049 | */ |
| 1050 | int32_t qpnp_adc_scale_batt_therm(int32_t adc_code, |
| 1051 | const struct qpnp_adc_properties *adc_prop, |
| 1052 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1053 | struct qpnp_vadc_result *chan_rslt); |
| 1054 | /** |
| 1055 | * qpnp_adc_scale_batt_id() - Scales the pre-calibrated digital output |
| 1056 | * of an ADC to the ADC reference and compensates for the |
| 1057 | * gain and offset. |
| 1058 | * @adc_code: pre-calibrated digital ouput of the ADC. |
| 1059 | * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, |
| 1060 | * reference voltage. |
| 1061 | * @chan_prop: individual channel properties to compensate the i/p scaling, |
| 1062 | * slope and offset. |
| 1063 | * @chan_rslt: physical result to be stored. |
| 1064 | */ |
| 1065 | int32_t qpnp_adc_scale_batt_id(int32_t adc_code, |
| 1066 | const struct qpnp_adc_properties *adc_prop, |
| 1067 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1068 | struct qpnp_vadc_result *chan_rslt); |
| 1069 | /** |
| 1070 | * qpnp_adc_scale_tdkntcg_therm() - Scales the pre-calibrated digital output |
| 1071 | * of an ADC to the ADC reference and compensates for the |
| 1072 | * gain and offset. Returns the temperature of the xo therm in mili |
| 1073 | degC. |
| 1074 | * @adc_code: pre-calibrated digital ouput of the ADC. |
| 1075 | * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, |
| 1076 | * reference voltage. |
| 1077 | * @chan_prop: individual channel properties to compensate the i/p scaling, |
| 1078 | * slope and offset. |
| 1079 | * @chan_rslt: physical result to be stored. |
| 1080 | */ |
| 1081 | int32_t qpnp_adc_tdkntcg_therm(int32_t adc_code, |
| 1082 | const struct qpnp_adc_properties *adc_prop, |
| 1083 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1084 | struct qpnp_vadc_result *chan_rslt); |
| 1085 | /** |
Siddartha Mohanadoss | e77edf1 | 2012-09-13 14:26:32 -0700 | [diff] [blame] | 1086 | * qpnp_adc_scale_therm_pu1() - Scales the pre-calibrated digital output |
| 1087 | * of an ADC to the ADC reference and compensates for the |
| 1088 | * gain and offset. Returns the temperature of the therm in degC. |
| 1089 | * It uses a mapping table computed for a 150K pull-up. |
| 1090 | * Pull-up1 is an internal pull-up on the AMUX of 150K. |
| 1091 | * @adc_code: pre-calibrated digital ouput of the ADC. |
| 1092 | * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, |
| 1093 | * reference voltage. |
| 1094 | * @chan_prop: individual channel properties to compensate the i/p scaling, |
| 1095 | * slope and offset. |
| 1096 | * @chan_rslt: physical result to be stored. |
| 1097 | */ |
| 1098 | int32_t qpnp_adc_scale_therm_pu1(int32_t adc_code, |
| 1099 | const struct qpnp_adc_properties *adc_prop, |
| 1100 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1101 | struct qpnp_vadc_result *chan_rslt); |
| 1102 | /** |
| 1103 | * qpnp_adc_scale_therm_pu2() - Scales the pre-calibrated digital output |
| 1104 | * of an ADC to the ADC reference and compensates for the |
| 1105 | * gain and offset. Returns the temperature of the therm in degC. |
| 1106 | * It uses a mapping table computed for a 100K pull-up. |
| 1107 | * Pull-up2 is an internal pull-up on the AMUX of 100K. |
| 1108 | * @adc_code: pre-calibrated digital ouput of the ADC. |
| 1109 | * @adc_prop: adc properties of the pm8xxx adc such as bit resolution, |
| 1110 | * reference voltage. |
| 1111 | * @chan_prop: individual channel properties to compensate the i/p scaling, |
| 1112 | * slope and offset. |
| 1113 | * @chan_rslt: physical result to be stored. |
| 1114 | */ |
| 1115 | int32_t qpnp_adc_scale_therm_pu2(int32_t adc_code, |
| 1116 | const struct qpnp_adc_properties *adc_prop, |
| 1117 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1118 | struct qpnp_vadc_result *chan_rslt); |
| 1119 | /** |
Siddartha Mohanadoss | 5ace110 | 2012-08-20 23:18:10 -0700 | [diff] [blame] | 1120 | * qpnp_vadc_is_ready() - Clients can use this API to check if the |
| 1121 | * device is ready to use. |
| 1122 | * @result: 0 on success and -EPROBE_DEFER when probe for the device |
| 1123 | * has not occured. |
| 1124 | */ |
| 1125 | int32_t qpnp_vadc_is_ready(void); |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 1126 | /** |
| 1127 | * qpnp_adc_tm_scaler() - Performs reverse calibration. |
| 1128 | * @config: Thermal monitoring configuration. |
| 1129 | * @adc_prop: adc properties of the qpnp adc such as bit resolution and |
| 1130 | * reference voltage. |
| 1131 | * @chan_prop: Individual channel properties to compensate the i/p scaling, |
| 1132 | * slope and offset. |
| 1133 | */ |
| 1134 | static inline int32_t qpnp_adc_tm_scaler(struct qpnp_adc_tm_config *tm_config, |
| 1135 | const struct qpnp_adc_properties *adc_prop, |
| 1136 | const struct qpnp_vadc_chan_properties *chan_prop) |
| 1137 | { return -ENXIO; } |
| 1138 | /** |
| 1139 | * qpnp_get_vadc_gain_and_offset() - Obtains the VADC gain and offset |
| 1140 | * for absolute and ratiometric calibration. |
| 1141 | * @param: The result in which the ADC offset and gain values are stored. |
| 1142 | * @type: The calibration type whether client needs the absolute or |
| 1143 | * ratiometric gain and offset values. |
| 1144 | */ |
| 1145 | int32_t qpnp_get_vadc_gain_and_offset(struct qpnp_vadc_linear_graph *param, |
| 1146 | enum qpnp_adc_calib_type calib_type); |
| 1147 | /** |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1148 | * qpnp_adc_scale_millidegc_pmic_voltage_thr() - Performs reverse calibration |
| 1149 | * on the low/high temperature threshold values passed by the |
| 1150 | * client. The function coverts milldegC to voltage threshold |
| 1151 | * and accounts for the corresponding channels scaling as (2mV/K). |
| 1152 | * @param: The input parameters that contain the low/high temperature |
| 1153 | * values. |
| 1154 | * @low_threshold: The low threshold value that needs to be updated with |
| 1155 | * the above calibrated voltage value. |
| 1156 | * @high_threshold: The low threshold value that needs to be updated with |
| 1157 | * the above calibrated voltage value. |
| 1158 | */ |
| 1159 | int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr( |
| 1160 | struct qpnp_adc_tm_btm_param *param, |
| 1161 | uint32_t *low_threshold, uint32_t *high_threshold); |
| 1162 | /** |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 1163 | * qpnp_adc_btm_scaler() - Performs reverse calibration on the low/high |
| 1164 | * temperature threshold values passed by the client. |
| 1165 | * The function maps the temperature to voltage and applies |
| 1166 | * ratiometric calibration on the voltage values. |
| 1167 | * @param: The input parameters that contain the low/high temperature |
| 1168 | * values. |
| 1169 | * @low_threshold: The low threshold value that needs to be updated with |
| 1170 | * the above calibrated voltage value. |
| 1171 | * @high_threshold: The low threshold value that needs to be updated with |
| 1172 | * the above calibrated voltage value. |
| 1173 | */ |
| 1174 | int32_t qpnp_adc_btm_scaler(struct qpnp_adc_tm_btm_param *param, |
| 1175 | uint32_t *low_threshold, uint32_t *high_threshold); |
| 1176 | /** |
| 1177 | * qpnp_adc_tm_scale_therm_voltage_pu2() - Performs reverse calibration |
| 1178 | * and convert given temperature to voltage on supported |
| 1179 | * thermistor channels using 100k pull-up. |
| 1180 | * @param: The input temperature values. |
| 1181 | */ |
| 1182 | int32_t qpnp_adc_tm_scale_therm_voltage_pu2(struct qpnp_adc_tm_config *param); |
| 1183 | /** |
| 1184 | * qpnp_adc_tm_scale_therm_voltage_pu2() - Performs reverse calibration |
| 1185 | * and converts the given ADC code to temperature for |
| 1186 | * thermistor channels using 100k pull-up. |
| 1187 | * @reg: The input ADC code. |
| 1188 | * @result: The physical measurement temperature on the thermistor. |
| 1189 | */ |
| 1190 | int32_t qpnp_adc_tm_scale_voltage_therm_pu2(uint32_t reg, int64_t *result); |
| 1191 | /** |
| 1192 | * qpnp_adc_usb_scaler() - Performs reverse calibration on the low/high |
| 1193 | * voltage threshold values passed by the client. |
| 1194 | * The function applies ratiometric calibration on the |
| 1195 | * voltage values. |
| 1196 | * @param: The input parameters that contain the low/high voltage |
| 1197 | * threshold values. |
| 1198 | * @low_threshold: The low threshold value that needs to be updated with |
| 1199 | * the above calibrated voltage value. |
| 1200 | * @high_threshold: The low threshold value that needs to be updated with |
| 1201 | * the above calibrated voltage value. |
| 1202 | */ |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1203 | int32_t qpnp_adc_usb_scaler(struct qpnp_adc_tm_btm_param *param, |
| 1204 | uint32_t *low_threshold, uint32_t *high_threshold); |
| 1205 | /** |
| 1206 | * qpnp_adc_vbatt_rscaler() - Performs reverse calibration on the low/high |
| 1207 | * voltage threshold values passed by the client. |
| 1208 | * The function applies ratiometric calibration on the |
| 1209 | * voltage values. |
| 1210 | * @param: The input parameters that contain the low/high voltage |
| 1211 | * threshold values. |
| 1212 | * @low_threshold: The low threshold value that needs to be updated with |
| 1213 | * the above calibrated voltage value. |
| 1214 | * @high_threshold: The low threshold value that needs to be updated with |
| 1215 | * the above calibrated voltage value. |
| 1216 | */ |
| 1217 | int32_t qpnp_adc_vbatt_rscaler(struct qpnp_adc_tm_btm_param *param, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 1218 | uint32_t *low_threshold, uint32_t *high_threshold); |
Siddartha Mohanadoss | a32ea2a | 2013-02-12 09:58:31 -0800 | [diff] [blame] | 1219 | /** |
| 1220 | * qpnp_vadc_iadc_sync_request() - Performs Voltage ADC read and |
| 1221 | * locks the peripheral. When performing simultaneous |
| 1222 | * voltage and current request the VADC peripheral is |
| 1223 | * prepared for conversion and the IADC sync conversion |
| 1224 | * is done from the IADC peripheral. |
| 1225 | * @channel: Input channel to perform the voltage ADC read. |
| 1226 | */ |
| 1227 | int32_t qpnp_vadc_iadc_sync_request(enum qpnp_vadc_channels channel); |
| 1228 | /** |
| 1229 | * qpnp_vadc_iadc_sync_complete_request() - Reads the ADC result and |
| 1230 | * unlocks the peripheral. |
| 1231 | * @result: Structure pointer of type adc_chan_result |
| 1232 | * in which the ADC read results are stored. |
| 1233 | */ |
| 1234 | int32_t qpnp_vadc_iadc_sync_complete_request( |
| 1235 | enum qpnp_vadc_channels channel, struct qpnp_vadc_result *result); |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 1236 | #else |
| 1237 | static inline int32_t qpnp_vadc_read(uint32_t channel, |
| 1238 | struct qpnp_vadc_result *result) |
| 1239 | { return -ENXIO; } |
| 1240 | static inline int32_t qpnp_vadc_conv_seq_request( |
| 1241 | enum qpnp_vadc_trigger trigger_channel, |
| 1242 | enum qpnp_vadc_channels channel, |
| 1243 | struct qpnp_vadc_result *result) |
| 1244 | { return -ENXIO; } |
| 1245 | static inline int32_t qpnp_adc_scale_default(int32_t adc_code, |
| 1246 | const struct qpnp_adc_properties *adc_prop, |
Siddartha Mohanadoss | 5ace110 | 2012-08-20 23:18:10 -0700 | [diff] [blame] | 1247 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1248 | struct qpnp_vadc_result *chan_rslt) |
| 1249 | { return -ENXIO; } |
| 1250 | static inline int32_t qpnp_adc_scale_pmic_therm(int32_t adc_code, |
| 1251 | const struct qpnp_adc_properties *adc_prop, |
| 1252 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1253 | struct qpnp_vadc_result *chan_rslt) |
| 1254 | { return -ENXIO; } |
| 1255 | static inline int32_t qpnp_adc_scale_batt_therm(int32_t adc_code, |
| 1256 | const struct qpnp_adc_properties *adc_prop, |
| 1257 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1258 | struct qpnp_vadc_result *chan_rslt) |
| 1259 | { return -ENXIO; } |
| 1260 | static inline int32_t qpnp_adc_scale_batt_id(int32_t adc_code, |
| 1261 | const struct qpnp_adc_properties *adc_prop, |
| 1262 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1263 | struct qpnp_vadc_result *chan_rslt) |
| 1264 | { return -ENXIO; } |
| 1265 | static inline int32_t qpnp_adc_tdkntcg_therm(int32_t adc_code, |
| 1266 | const struct qpnp_adc_properties *adc_prop, |
| 1267 | const struct qpnp_vadc_chan_properties *chan_prop, |
| 1268 | struct qpnp_vadc_result *chan_rslt) |
| 1269 | { return -ENXIO; } |
Siddartha Mohanadoss | e77edf1 | 2012-09-13 14:26:32 -0700 | [diff] [blame] | 1270 | static inline int32_t qpnp_adc_scale_therm_pu1(int32_t adc_code, |
| 1271 | const struct qpnp_adc_properties *adc_prop, |
| 1272 | const struct qpnp_vadc_chan_properties *chan_prop, |
David Keitel | c96dc85 | 2013-03-04 14:57:34 -0800 | [diff] [blame] | 1273 | struct qpnp_vadc_result *chan_rslt) |
Siddartha Mohanadoss | e77edf1 | 2012-09-13 14:26:32 -0700 | [diff] [blame] | 1274 | { return -ENXIO; } |
| 1275 | static inline int32_t qpnp_adc_scale_therm_pu2(int32_t adc_code, |
| 1276 | const struct qpnp_adc_properties *adc_prop, |
| 1277 | const struct qpnp_vadc_chan_properties *chan_prop, |
David Keitel | c96dc85 | 2013-03-04 14:57:34 -0800 | [diff] [blame] | 1278 | struct qpnp_vadc_result *chan_rslt) |
Siddartha Mohanadoss | e77edf1 | 2012-09-13 14:26:32 -0700 | [diff] [blame] | 1279 | { return -ENXIO; } |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 1280 | static inline int32_t qpnp_vadc_is_ready(void) |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 1281 | { return -ENXIO; } |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 1282 | static inline int32_t qpnp_get_vadc_gain_and_offset( |
| 1283 | struct qpnp_vadc_linear_graph *param, |
| 1284 | enum qpnp_adc_calib_type calib_type) |
| 1285 | { return -ENXIO; } |
| 1286 | static inline int32_t qpnp_adc_usb_scaler( |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1287 | struct qpnp_adc_tm_btm_param *param, |
| 1288 | uint32_t *low_threshold, uint32_t *high_threshold) |
| 1289 | { return -ENXIO; } |
| 1290 | static inline int32_t qpnp_adc_vbatt_rscaler( |
| 1291 | struct qpnp_adc_tm_btm_param *param, |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 1292 | uint32_t *low_threshold, uint32_t *high_threshold) |
| 1293 | { return -ENXIO; } |
| 1294 | static inline int32_t qpnp_adc_btm_scaler( |
| 1295 | struct qpnp_adc_tm_btm_param *param, |
| 1296 | uint32_t *low_threshold, uint32_t *high_threshold) |
| 1297 | { return -ENXIO; } |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1298 | static inline int32_t qpnp_adc_scale_millidegc_pmic_voltage_thr( |
| 1299 | struct qpnp_adc_tm_btm_param *param, |
| 1300 | uint32_t *low_threshold, uint32_t *high_threshold) |
| 1301 | { return -ENXIO; } |
Siddartha Mohanadoss | d0f4fd1 | 2012-11-20 16:28:40 -0800 | [diff] [blame] | 1302 | static inline int32_t qpnp_adc_tm_scale_therm_voltage_pu2( |
| 1303 | struct qpnp_adc_tm_config *param) |
| 1304 | { return -ENXIO; } |
| 1305 | static inline int32_t qpnp_adc_tm_scale_voltage_therm_pu2( |
| 1306 | uint32_t reg, int64_t *result) |
| 1307 | { return -ENXIO; } |
Siddartha Mohanadoss | a32ea2a | 2013-02-12 09:58:31 -0800 | [diff] [blame] | 1308 | static inline int32_t qpnp_vadc_iadc_sync_request( |
| 1309 | enum qpnp_vadc_channels channel) |
| 1310 | { return -ENXIO; } |
| 1311 | static inline int32_t qpnp_vadc_iadc_sync_complete_request( |
| 1312 | enum qpnp_vadc_channels channel, |
| 1313 | struct qpnp_vadc_result *result) |
| 1314 | { return -ENXIO; } |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 1315 | #endif |
| 1316 | |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1317 | /* Public API */ |
| 1318 | #if defined(CONFIG_SENSORS_QPNP_ADC_CURRENT) \ |
| 1319 | || defined(CONFIG_SENSORS_QPNP_ADC_CURRENT_MODULE) |
| 1320 | /** |
| 1321 | * qpnp_iadc_read() - Performs ADC read on the current channel. |
| 1322 | * @channel: Input channel to perform the ADC read. |
Siddartha Mohanadoss | a32ea2a | 2013-02-12 09:58:31 -0800 | [diff] [blame] | 1323 | * @result: Current across rsense in mA. |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1324 | */ |
| 1325 | int32_t qpnp_iadc_read(enum qpnp_iadc_channels channel, |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 1326 | struct qpnp_iadc_result *result); |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1327 | /** |
Xiaozhe Shi | 767fdb6 | 2013-01-10 15:09:08 -0800 | [diff] [blame] | 1328 | * qpnp_iadc_get_rsense() - Reads the RDS resistance value from the |
| 1329 | trim registers. |
| 1330 | * @rsense: RDS resistance in nOhms. |
| 1331 | */ |
| 1332 | int32_t qpnp_iadc_get_rsense(int32_t *rsense); |
| 1333 | /** |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 1334 | * qpnp_iadc_get_gain_and_offset() - Performs gain calibration |
| 1335 | * over 17.8571mV and offset over selected |
| 1336 | * channel. Channel can be internal rsense, |
| 1337 | * external rsense and alternate lead pair. |
| 1338 | * @result: result structure where the gain and offset is stored of |
| 1339 | * type qpnp_iadc_calib. |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1340 | */ |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 1341 | int32_t qpnp_iadc_get_gain_and_offset(struct qpnp_iadc_calib *result); |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1342 | /** |
Siddartha Mohanadoss | 5ace110 | 2012-08-20 23:18:10 -0700 | [diff] [blame] | 1343 | * qpnp_iadc_is_ready() - Clients can use this API to check if the |
| 1344 | * device is ready to use. |
| 1345 | * @result: 0 on success and -EPROBE_DEFER when probe for the device |
| 1346 | * has not occured. |
| 1347 | */ |
| 1348 | int32_t qpnp_iadc_is_ready(void); |
Siddartha Mohanadoss | a32ea2a | 2013-02-12 09:58:31 -0800 | [diff] [blame] | 1349 | /** |
| 1350 | * qpnp_iadc_vadc_sync_read() - Performs synchronous VADC and IADC read. |
| 1351 | * The api is to be used only by the BMS to perform |
| 1352 | * simultaneous VADC and IADC measurement for battery voltage |
| 1353 | * and current. |
| 1354 | * @i_channel: Input battery current channel to perform the IADC read. |
| 1355 | * @i_result: Current across the rsense in mA. |
| 1356 | * @v_channel: Input battery voltage channel to perform VADC read. |
| 1357 | * @v_result: Voltage on the vbatt channel with units in mV. |
| 1358 | */ |
| 1359 | int32_t qpnp_iadc_vadc_sync_read( |
| 1360 | enum qpnp_iadc_channels i_channel, struct qpnp_iadc_result *i_result, |
| 1361 | enum qpnp_vadc_channels v_channel, struct qpnp_vadc_result *v_result); |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1362 | #else |
| 1363 | static inline int32_t qpnp_iadc_read(enum qpnp_iadc_channels channel, |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 1364 | struct qpnp_iadc_result *result) |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1365 | { return -ENXIO; } |
Siddartha Mohanadoss | 563166b | 2013-02-20 12:47:24 -0800 | [diff] [blame] | 1366 | static inline int32_t qpnp_iadc_get_rsense(int32_t *rsense) |
| 1367 | { return -ENXIO; } |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 1368 | static inline int32_t qpnp_iadc_get_gain_and_offset(struct qpnp_iadc_calib |
| 1369 | *result) |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1370 | { return -ENXIO; } |
Siddartha Mohanadoss | 5e2988d | 2012-09-24 17:03:56 -0700 | [diff] [blame] | 1371 | static inline int32_t qpnp_iadc_is_ready(void) |
Siddartha Mohanadoss | 5ace110 | 2012-08-20 23:18:10 -0700 | [diff] [blame] | 1372 | { return -ENXIO; } |
Siddartha Mohanadoss | a32ea2a | 2013-02-12 09:58:31 -0800 | [diff] [blame] | 1373 | static inline int32_t qpnp_iadc_vadc_sync_read( |
| 1374 | enum qpnp_iadc_channels i_channel, struct qpnp_iadc_result *i_result, |
| 1375 | enum qpnp_vadc_channels v_channel, struct qpnp_vadc_result *v_result) |
| 1376 | { return -ENXIO; } |
Siddartha Mohanadoss | c4a6af1 | 2012-07-13 18:50:12 -0700 | [diff] [blame] | 1377 | #endif |
| 1378 | |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1379 | /* Public API */ |
| 1380 | #if defined(CONFIG_THERMAL_QPNP_ADC_TM) \ |
| 1381 | || defined(CONFIG_THERMAL_QPNP_ADC_TM_MODULE) |
| 1382 | /** |
| 1383 | * qpnp_adc_tm_usbid_configure() - Configures Channel 0 of VADC_BTM to |
| 1384 | * monitor USB_ID channel using 100k internal pull-up. |
| 1385 | * USB driver passes the high/low voltage threshold along |
| 1386 | * with the notification callback once the set thresholds |
| 1387 | * are crossed. |
| 1388 | * @param: Structure pointer of qpnp_adc_tm_usbid_param type. |
| 1389 | * Clients pass the low/high voltage along with the threshold |
| 1390 | * notification callback. |
| 1391 | */ |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1392 | int32_t qpnp_adc_tm_usbid_configure(struct qpnp_adc_tm_btm_param *param); |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1393 | /** |
| 1394 | * qpnp_adc_tm_usbid_end() - Disables the monitoring of channel 0 thats |
| 1395 | * assigned for monitoring USB_ID. Disables the low/high |
| 1396 | * threshold activation for channel 0 as well. |
| 1397 | * @param: none. |
| 1398 | */ |
| 1399 | int32_t qpnp_adc_tm_usbid_end(void); |
| 1400 | /** |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1401 | * qpnp_adc_tm_channel_measure() - Configures kernel clients a channel to |
| 1402 | * monitor the corresponding ADC channel for threshold detection. |
| 1403 | * Driver passes the high/low voltage threshold along |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1404 | * with the notification callback once the set thresholds |
| 1405 | * are crossed. |
| 1406 | * @param: Structure pointer of qpnp_adc_tm_btm_param type. |
| 1407 | * Clients pass the low/high temperature along with the threshold |
| 1408 | * notification callback. |
| 1409 | */ |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1410 | int32_t qpnp_adc_tm_channel_measure(struct qpnp_adc_tm_btm_param *param); |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1411 | /** |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1412 | * qpnp_adc_tm_disable_chan_meas() - Disables the monitoring of channel thats |
| 1413 | * assigned for monitoring kernel clients. Disables the low/high |
| 1414 | * threshold activation for the corresponding channel. |
| 1415 | * @param: Structure pointer of qpnp_adc_tm_btm_param type. |
| 1416 | * This is used to identify the channel for which the corresponding |
| 1417 | * channels high/low threshold notification will be disabled. |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1418 | */ |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1419 | int32_t qpnp_adc_tm_disable_chan_meas(struct qpnp_adc_tm_btm_param *param); |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1420 | /** |
| 1421 | * qpnp_adc_tm_is_ready() - Clients can use this API to check if the |
| 1422 | * device is ready to use. |
| 1423 | * @result: 0 on success and -EPROBE_DEFER when probe for the device |
| 1424 | * has not occured. |
| 1425 | */ |
| 1426 | int32_t qpnp_adc_tm_is_ready(void); |
| 1427 | #else |
| 1428 | static inline int32_t qpnp_adc_tm_usbid_configure( |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1429 | struct qpnp_adc_tm_btm_param *param) |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1430 | { return -ENXIO; } |
| 1431 | static inline int32_t qpnp_adc_tm_usbid_end(void) |
| 1432 | { return -ENXIO; } |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1433 | static inline int32_t qpnp_adc_tm_channel_measure( |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1434 | struct qpnp_adc_tm_btm_param *param) |
| 1435 | { return -ENXIO; } |
Siddartha Mohanadoss | a3e3551 | 2013-02-22 17:06:07 -0800 | [diff] [blame] | 1436 | static inline int32_t qpnp_adc_tm_disable_chan_meas(void) |
Siddartha Mohanadoss | 31f6096 | 2012-11-27 14:11:02 -0800 | [diff] [blame] | 1437 | { return -ENXIO; } |
| 1438 | static inline int32_t qpnp_adc_tm_is_ready(void) |
| 1439 | { return -ENXIO; } |
| 1440 | #endif |
| 1441 | |
Siddartha Mohanadoss | 7b116e1 | 2012-06-05 23:27:46 -0700 | [diff] [blame] | 1442 | #endif |