blob: ba4b29c7c65ac9e601834b179d327aa6708698dd [file] [log] [blame]
Siddartha Mohanadoss17607d22011-10-05 10:36:20 -07001/*
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 * Qualcomm PMIC 8921/8018 ADC driver header file
15 *
16 */
17
18#ifndef __PM8XXX_ADC_H
19#define __PM8XXX_ADC_H
20
21#include <linux/kernel.h>
22#include <linux/list.h>
23
24/**
25 * enum pm8xxx_adc_channels - PM8XXX AMUX arbiter channels
26 * %CHANNEL_VCOIN: Backup voltage for certain register set
27 * %CHANNEL_VBAT: Battery voltage
28 * %CHANNEL_DCIN: Charger input voltage without internal OVP
29 * %CHANNEL_ICHG: Charge-current monitor
30 * %CHANNEL_VPH_PWR: Main system power
31 * %CHANNEL_IBAT: Battery charge current
32 * %CHANNEL_MPP_1: 16:1 pre-mux unity scale MPP input
33 * %CHANNEL_MPP_2: 16:1 pre-mux 1/3 scale MPP input
34 * %CHANNEL_BATT_THERM: Battery temperature
35 * %CHANNEL_BATT_ID: Battery detection
36 * %CHANNEL_USBIN: Charger input voltage with internal OVP
37 * %CHANNEL_DIE_TEMP: Pmic_die temperature
38 * %CHANNEL_625MV: 625mv reference channel
39 * %CHANNEL_125V: 1.25v reference channel
40 * %CHANNEL_CHG_TEMP: Charger temperature
41 * %CHANNEL_MUXOFF: Channel to reduce input load on the mux
42 * %CHANNEL_NONE: Do not use this channel
43 */
44enum pm8xxx_adc_channels {
45 CHANNEL_VCOIN = 0,
46 CHANNEL_VBAT,
47 CHANNEL_DCIN,
48 CHANNEL_ICHG,
49 CHANNEL_VPH_PWR,
50 CHANNEL_IBAT,
51 CHANNEL_MPP_1,
52 CHANNEL_MPP_2,
53 CHANNEL_BATT_THERM,
54 CHANNEL_BATT_ID,
55 CHANNEL_USBIN,
56 CHANNEL_DIE_TEMP,
57 CHANNEL_625MV,
58 CHANNEL_125V,
59 CHANNEL_CHG_TEMP,
60 CHANNEL_MUXOFF,
61 CHANNEL_NONE,
62 ADC_MPP_1_ATEST_8 = 20,
63 ADC_MPP_1_USB_SNS_DIV20,
64 ADC_MPP_1_DCIN_SNS_DIV20,
65 ADC_MPP_1_AMUX3,
66 ADC_MPP_1_AMUX4,
67 ADC_MPP_1_AMUX5,
68 ADC_MPP_1_AMUX6,
69 ADC_MPP_1_AMUX7,
70 ADC_MPP_1_AMUX8,
71 ADC_MPP_1_ATEST_1,
72 ADC_MPP_1_ATEST_2,
73 ADC_MPP_1_ATEST_3,
74 ADC_MPP_1_ATEST_4,
75 ADC_MPP_1_ATEST_5,
76 ADC_MPP_1_ATEST_6,
77 ADC_MPP_1_ATEST_7,
78 ADC_MPP_1_CHANNEL_NONE,
79 ADC_MPP_2_ATEST_8 = 40,
80 ADC_MPP_2_USB_SNS_DIV20,
81 ADC_MPP_2_DCIN_SNS_DIV20,
82 ADC_MPP_2_AMUX3,
83 ADC_MPP_2_AMUX4,
84 ADC_MPP_2_AMUX5,
85 ADC_MPP_2_AMUX6,
86 ADC_MPP_2_AMUX7,
87 ADC_MPP_2_AMUX8,
88 ADC_MPP_2_ATEST_1,
89 ADC_MPP_2_ATEST_2,
90 ADC_MPP_2_ATEST_3,
91 ADC_MPP_2_ATEST_4,
92 ADC_MPP_2_ATEST_5,
93 ADC_MPP_2_ATEST_6,
94 ADC_MPP_2_ATEST_7,
95 ADC_MPP_2_CHANNEL_NONE,
96};
97
98#define PM8XXX_ADC_PMIC_0 0x0
99
100#define PM8XXX_CHANNEL_ADC_625_MV 625
101#define PM8XXX_CHANNEL_MPP_SCALE1_IDX 20
102#define PM8XXX_CHANNEL_MPP_SCALE3_IDX 40
103
104#define PM8XXX_AMUX_MPP_3 0x3
105#define PM8XXX_AMUX_MPP_4 0x4
106#define PM8XXX_AMUX_MPP_5 0x5
107#define PM8XXX_AMUX_MPP_6 0x6
108#define PM8XXX_AMUX_MPP_7 0x7
109#define PM8XXX_AMUX_MPP_8 0x8
110
111#define PM8XXX_ADC_DEV_NAME "pm8xxx-adc"
112
113/**
114 * enum pm8xxx_adc_decimation_type - Sampling rate supported
115 * %ADC_DECIMATION_TYPE1: 512
116 * %ADC_DECIMATION_TYPE2: 1K
117 * %ADC_DECIMATION_TYPE3: 2K
118 * %ADC_DECIMATION_TYPE4: 4k
119 * %ADC_DECIMATION_NONE: Do not use this Sampling type
120 *
121 * The Sampling rate is specific to each channel of the PM8XXX ADC arbiter.
122 */
123enum pm8xxx_adc_decimation_type {
124 ADC_DECIMATION_TYPE1 = 0,
125 ADC_DECIMATION_TYPE2,
126 ADC_DECIMATION_TYPE3,
127 ADC_DECIMATION_TYPE4,
128 ADC_DECIMATION_NONE,
129};
130
131/**
132 * enum pm8xxx_adc_calib_type - PM8XXX ADC Calibration type
133 * %ADC_CALIB_ABSOLUTE: Use 625mV and 1.25V reference channels
134 * %ADC_CALIB_RATIOMETRIC: Use reference Voltage/GND
135 * %ADC_CALIB_CONFIG_NONE: Do not use this calibration type
136 *
137 * Use the input reference voltage depending on the calibration type
138 * to calcluate the offset and gain parameters. The calibration is
139 * specific to each channel of the PM8XXX ADC.
140 */
141enum pm8xxx_adc_calib_type {
142 ADC_CALIB_ABSOLUTE = 0,
143 ADC_CALIB_RATIOMETRIC,
144 ADC_CALIB_NONE,
145};
146
147/**
148 * enum pm8xxx_adc_channel_scaling_param - pre-scaling AMUX ratio
149 * %CHAN_PATH_SCALING1: ratio of {1, 1}
150 * %CHAN_PATH_SCALING2: ratio of {1, 3}
151 * %CHAN_PATH_SCALING3: ratio of {1, 4}
152 * %CHAN_PATH_SCALING4: ratio of {1, 6}
153 * %CHAN_PATH_NONE: Do not use this pre-scaling ratio type
154 *
155 * The pre-scaling is applied for signals to be within the voltage range
156 * of the ADC.
157 */
158enum pm8xxx_adc_channel_scaling_param {
159 CHAN_PATH_SCALING1 = 0,
160 CHAN_PATH_SCALING2,
161 CHAN_PATH_SCALING3,
162 CHAN_PATH_SCALING4,
163 CHAN_PATH_SCALING_NONE,
164};
165
166/**
167 * enum pm8xxx_adc_amux_input_rsv - HK/XOADC reference voltage
168 * %AMUX_RSV0: XO_IN/XOADC_GND
169 * %AMUX_RSV1: PMIC_IN/XOADC_GND
170 * %AMUX_RSV2: PMIC_IN/BMS_CSP
171 * %AMUX_RSV3: not used
172 * %AMUX_RSV4: XOADC_GND/XOADC_GND
173 * %AMUX_RSV5: XOADC_VREF/XOADC_GND
174 * %AMUX_NONE: Do not use this input reference voltage selection
175 */
176enum pm8xxx_adc_amux_input_rsv {
177 AMUX_RSV0 = 0,
178 AMUX_RSV1,
179 AMUX_RSV2,
180 AMUX_RSV3,
181 AMUX_RSV4,
182 AMUX_RSV5,
183 AMUX_NONE,
184};
185
186/**
187 * enum pm8xxx_adc_premux_mpp_scale_type - 16:1 pre-mux scale ratio
188 * %PREMUX_MPP_SCALE_0: No scaling to the input signal
189 * %PREMUX_MPP_SCALE_1: Unity scaling selected by the user for MPP input
190 * %PREMUX_MPP_SCALE_1_DIV3: 1/3 pre-scale to the input MPP signal
191 * %PREMUX_MPP_NONE: Do not use this pre-scale mpp type
192 */
193enum pm8xxx_adc_premux_mpp_scale_type {
194 PREMUX_MPP_SCALE_0 = 0,
195 PREMUX_MPP_SCALE_1,
196 PREMUX_MPP_SCALE_1_DIV3,
197 PREMUX_MPP_NONE,
198};
199
200/**
201 * enum pm8xxx_adc_scale_fn_type - Scaling function for pm8921 pre calibrated
202 * digital data relative to ADC reference
203 * %ADC_SCALE_DEFAULT: Default scaling to convert raw adc code to voltage
204 * %ADC_SCALE_BATT_THERM: Conversion to temperature based on btm parameters
205 * %ADC_SCALE_PMIC_THERM: Returns result in milli degree's Centigrade
206 * %ADC_SCALE_XTERN_CHGR_CUR: Returns current across 0.1 ohm resistor
207 * %ADC_SCALE_XOTHERM: Returns XO thermistor voltage in degree's Centigrade
208 * %ADC_SCALE_NONE: Do not use this scaling type
209 */
210enum pm8xxx_adc_scale_fn_type {
211 ADC_SCALE_DEFAULT = 0,
212 ADC_SCALE_BATT_THERM,
213 ADC_SCALE_PA_THERM,
214 ADC_SCALE_PMIC_THERM,
215 ADC_SCALE_XOTHERM,
216 ADC_SCALE_NONE,
217};
218
219/**
220 * struct pm8xxx_adc_linear_graph - Represent ADC characteristics
221 * @offset: Offset with respect to the actual curve
222 * @dy: Numerator slope to calculate the gain
223 * @dx: Denominator slope to calculate the gain
Siddartha Mohanadossae39c902011-11-09 17:54:31 -0800224 * @adc_vref: A/D word of the voltage reference used for the channel
225 * @adc_gnd: A/D word of the ground reference used for the channel
Siddartha Mohanadoss17607d22011-10-05 10:36:20 -0700226 *
227 * Each ADC device has different offset and gain parameters which are computed
228 * to calibrate the device.
229 */
230struct pm8xxx_adc_linear_graph {
231 int32_t offset;
232 int32_t dy;
233 int32_t dx;
Siddartha Mohanadossae39c902011-11-09 17:54:31 -0800234 int32_t adc_vref;
235 int32_t adc_gnd;
Siddartha Mohanadoss17607d22011-10-05 10:36:20 -0700236};
237
238/**
239 * struct pm8xxx_adc_map_pt - Map the graph representation for ADC channel
240 * @x: Represent the ADC digitized code
241 * @y: Represent the physical data which can be temperature, voltage,
242 * resistance
243 */
244struct pm8xxx_adc_map_pt {
245 int32_t x;
246 int32_t y;
247};
248
249/**
250 * struct pm8xxx_adc_scaling_ratio - Represent scaling ratio for adc input
251 * @num: Numerator scaling parameter
252 * @den: Denominator scaling parameter
253 */
254struct pm8xxx_adc_scaling_ratio {
255 int32_t num;
256 int32_t den;
257};
258
259/**
260 * struct pm8xxx_adc_properties - Represent the ADC properties
261 * @adc_reference: Reference voltage for PM8XXX ADC
262 * @bitresolution: ADC bit resolution for PM8XXX ADC
263 * @biploar: Polarity for PM8XXX ADC
264 */
265struct pm8xxx_adc_properties {
266 uint32_t adc_vdd_reference;
267 uint32_t bitresolution;
268 bool bipolar;
269};
270
271/**
272 * struct pm8xxx_adc_chan_properties - Represent channel properties of the ADC
273 * @offset_gain_numerator: The inverse numerator of the gain applied to the
274 * input channel
275 * @offset_gain_denominator: The inverse denominator of the gain applied to the
276 * input channel
277 * @adc_graph: ADC graph for the channel of struct type pm8xxx_adc_linear_graph
278 */
279struct pm8xxx_adc_chan_properties {
280 uint32_t offset_gain_numerator;
281 uint32_t offset_gain_denominator;
282 struct pm8xxx_adc_linear_graph adc_graph[2];
283};
284
285/**
286 * struct pm8xxx_adc_chan_result - Represent the result of the PM8XXX ADC
287 * @chan: The channel number of the requested conversion
288 * @adc_code: The pre-calibrated digital output of a given ADC relative to the
289 * the ADC reference
290 * @measurement: In units specific for a given ADC; most ADC uses reference
291 * voltage but some ADC uses reference current. This measurement
292 * here is a number relative to a reference of a given ADC
293 * @physical: The data meaningful for each individual channel whether it is
294 * voltage, current, temperature, etc.
295 */
296struct pm8xxx_adc_chan_result {
297 uint32_t chan;
298 int32_t adc_code;
299 int64_t measurement;
300 int64_t physical;
301};
302
303#if defined(CONFIG_SENSORS_PM8XXX_ADC) \
304 || defined(CONFIG_SENSORS_PM8XXX_ADC_MODULE)
305/**
306 * pm8xxx_adc_scale_default() - Scales the pre-calibrated digital output
307 * of an ADC to the ADC reference and compensates for the
308 * gain and offset.
309 * @adc_code: pre-calibrated digital ouput of the ADC.
310 * @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
311 * reference voltage.
312 * @chan_prop: individual channel properties to compensate the i/p scaling,
313 * slope and offset.
314 * @chan_rslt: Physical result to be stored.
315 */
316int32_t pm8xxx_adc_scale_default(int32_t adc_code,
317 const struct pm8xxx_adc_properties *adc_prop,
318 const struct pm8xxx_adc_chan_properties *chan_prop,
319 struct pm8xxx_adc_chan_result *chan_rslt);
320/**
321 * pm8xxx_adc_scale_tdkntcg_therm() - Scales the pre-calibrated digital output
322 * of an ADC to the ADC reference and compensates for the
323 * gain and offset. Returns the temperature of the xo therm in mili
324 degC.
325 * @adc_code: pre-calibrated digital ouput of the ADC.
326 * @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
327 * reference voltage.
328 * @chan_prop: individual channel properties to compensate the i/p scaling,
329 * slope and offset.
330 * @chan_rslt: physical result to be stored.
331 */
332int32_t pm8xxx_adc_tdkntcg_therm(int32_t adc_code,
333 const struct pm8xxx_adc_properties *adc_prop,
334 const struct pm8xxx_adc_chan_properties *chan_prop,
335 struct pm8xxx_adc_chan_result *chan_rslt);
336/**
337 * pm8xxx_adc_scale_batt_therm() - Scales the pre-calibrated digital output
338 * of an ADC to the ADC reference and compensates for the
339 * gain and offset. Returns the temperature in degC.
340 * @adc_code: pre-calibrated digital ouput of the ADC.
341 * @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
342 * reference voltage.
343 * @chan_prop: individual channel properties to compensate the i/p scaling,
344 * slope and offset.
345 * @chan_rslt: physical result to be stored.
346 */
347int32_t pm8xxx_adc_scale_batt_therm(int32_t adc_code,
348 const struct pm8xxx_adc_properties *adc_prop,
349 const struct pm8xxx_adc_chan_properties *chan_prop,
350 struct pm8xxx_adc_chan_result *chan_rslt);
351/**
352 * pm8xxx_adc_scale_pa_therm() - Scales the pre-calibrated digital output
353 * of an ADC to the ADC reference and compensates for the
354 * gain and offset. Returns the temperature in degC.
355 * @adc_code: pre-calibrated digital ouput of the ADC.
356 * @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
357 * reference voltage.
358 * @chan_prop: individual channel properties to compensate the i/p scaling,
359 * slope and offset.
360 * @chan_rslt: physical result to be stored.
361 */
362int32_t pm8xxx_adc_scale_pa_therm(int32_t adc_code,
363 const struct pm8xxx_adc_properties *adc_prop,
364 const struct pm8xxx_adc_chan_properties *chan_prop,
365 struct pm8xxx_adc_chan_result *chan_rslt);
366/**
367 * pm8xxx_adc_scale_pmic_therm() - Scales the pre-calibrated digital output
368 * of an ADC to the ADC reference and compensates for the
369 * gain and offset. Performs the AMUX out as 2mv/K and returns
370 * the temperature in mili degC.
371 * @adc_code: pre-calibrated digital ouput of the ADC.
372 * @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
373 * reference voltage.
374 * @chan_prop: individual channel properties to compensate the i/p scaling,
375 * slope and offset.
376 * @chan_rslt: physical result to be stored.
377 */
378int32_t pm8xxx_adc_scale_pmic_therm(int32_t adc_code,
379 const struct pm8xxx_adc_properties *adc_prop,
380 const struct pm8xxx_adc_chan_properties *chan_prop,
381 struct pm8xxx_adc_chan_result *chan_rslt);
382#else
383static inline int32_t pm8xxx_adc_scale_default(int32_t adc_code,
384 const struct pm8xxx_adc_properties *adc_prop,
385 const struct pm8xxx_adc_chan_properties *chan_prop,
386 struct pm8xxx_adc_chan_result *chan_rslt)
387{ return -ENXIO; }
388static inline int32_t pm8xxx_adc_tdkntcg_therm(int32_t adc_code,
389 const struct pm8xxx_adc_properties *adc_prop,
390 const struct pm8xxx_adc_chan_properties *chan_prop,
391 struct pm8xxx_adc_chan_result *chan_rslt)
392{ return -ENXIO; }
393static inline int32_t pm8xxx_adc_scale_batt_therm(int32_t adc_code,
394 const struct pm8xxx_adc_properties *adc_prop,
395 const struct pm8xxx_adc_chan_properties *chan_prop,
396 struct pm8xxx_adc_chan_result *chan_rslt)
397{ return -ENXIO; }
398static inline int32_t pm8xxx_adc_scale_pa_therm(int32_t adc_code,
399 const struct pm8xxx_adc_properties *adc_prop,
400 const struct pm8xxx_adc_chan_properties *chan_prop,
401 struct pm8xxx_adc_chan_result *chan_rslt)
402{ return -ENXIO; }
403static inline int32_t pm8xxx_adc_scale_pmic_therm(int32_t adc_code,
404 const struct pm8xxx_adc_properties *adc_prop,
405 const struct pm8xxx_adc_chan_properties *chan_prop,
406 struct pm8xxx_adc_chan_result *chan_rslt)
407{ return -ENXIO; }
408#endif
409
410/**
411 * struct pm8xxx_adc_scale_fn - Scaling function prototype
412 * @chan: Function pointer to one of the scaling functions
413 * which takes the adc properties, channel properties,
414 * and returns the physical result
415 */
416struct pm8xxx_adc_scale_fn {
417 int32_t (*chan) (int32_t,
418 const struct pm8xxx_adc_properties *,
419 const struct pm8xxx_adc_chan_properties *,
420 struct pm8xxx_adc_chan_result *);
421};
422
423/**
424 * struct pm8xxx_adc_amux - AMUX properties for individual channel
425 * @name: Channel name
426 * @channel_name: Channel in integer used from pm8xxx_adc_channels
427 * @chan_path_prescaling: Channel scaling performed on the input signal
428 * @adc_rsv: Input reference Voltage/GND selection to the ADC
429 * @adc_decimation: Sampling rate desired for the channel
430 * adc_scale_fn: Scaling function to convert to the data meaningful for
431 * each individual channel whether it is voltage, current,
432 * temperature, etc and compensates the channel properties
433 */
434struct pm8xxx_adc_amux {
435 char *name;
436 enum pm8xxx_adc_channels channel_name;
437 enum pm8xxx_adc_channel_scaling_param chan_path_prescaling;
438 enum pm8xxx_adc_amux_input_rsv adc_rsv;
439 enum pm8xxx_adc_decimation_type adc_decimation;
440 enum pm8xxx_adc_scale_fn_type adc_scale_fn;
441};
442
443/**
444 * struct pm8xxx_adc_arb_btm_param - PM8XXX ADC BTM parameters to set threshold
445 * temperature for client notification
446 * @low_thr_temp: low temperature threshold request for notification
447 * @high_thr_temp: high temperature threshold request for notification
448 * @low_thr_voltage: low temperature converted to voltage by arbiter driver
449 * @high_thr_voltage: high temperature converted to voltage by arbiter driver
450 * @interval: Interval period to check for temperature notification
451 * @btm_warm_fn: Remote function call for warm threshold.
452 * @btm_cool_fn: Remote function call for cold threshold.
453 *
454 * BTM client passes the parameters to be set for the
455 * temperature threshold notifications. The client is
456 * responsible for setting the new threshold
457 * levels once the thresholds are reached
458 */
459struct pm8xxx_adc_arb_btm_param {
Siddartha Mohanadossae39c902011-11-09 17:54:31 -0800460 int32_t low_thr_temp;
461 int32_t high_thr_temp;
Siddartha Mohanadoss17607d22011-10-05 10:36:20 -0700462 uint64_t low_thr_voltage;
463 uint64_t high_thr_voltage;
464 int32_t interval;
465 void (*btm_warm_fn) (bool);
466 void (*btm_cool_fn) (bool);
467};
468
Siddartha Mohanadossae39c902011-11-09 17:54:31 -0800469int32_t pm8xxx_adc_batt_scaler(struct pm8xxx_adc_arb_btm_param *,
470 const struct pm8xxx_adc_properties *adc_prop,
471 const struct pm8xxx_adc_chan_properties *chan_prop);
Siddartha Mohanadoss17607d22011-10-05 10:36:20 -0700472/**
473 * struct pm8xxx_adc_platform_data - PM8XXX ADC platform data
474 * @adc_prop: ADC specific parameters, voltage and channel setup
475 * @adc_channel: Channel properties of the ADC arbiter
476 * @adc_num_board_channel: Number of channels added in the board file
477 * @adc_mpp_base: PM8XXX MPP0 base passed from board file. This is used
478 * to offset the PM8XXX MPP passed to configure the
479 * the MPP to AMUX mapping.
480 */
481struct pm8xxx_adc_platform_data {
482 struct pm8xxx_adc_properties *adc_prop;
483 struct pm8xxx_adc_amux *adc_channel;
484 uint32_t adc_num_board_channel;
485 uint32_t adc_mpp_base;
486};
487
488/* Public API */
489#if defined(CONFIG_SENSORS_PM8XXX_ADC) \
490 || defined(CONFIG_SENSORS_PM8XXX_ADC_MODULE)
491/**
492 * pm8xxx_adc_read() - Performs ADC read on the channel.
493 * @channel: Input channel to perform the ADC read.
494 * @result: Structure pointer of type adc_chan_result
495 * in which the ADC read results are stored.
496 */
497uint32_t pm8xxx_adc_read(enum pm8xxx_adc_channels channel,
498 struct pm8xxx_adc_chan_result *result);
499/**
500 * pm8xxx_adc_mpp_config_read() - Configure's the PM8XXX MPP
501 * to AMUX6 and performs an ADC read.
502 *
503 * On PM8921 ADC the MPP needs to first be configured
504 * as an analog input to the AMUX pre-mux channel before
505 * issuing a read request. PM8921 MPP 8 is mapped to AMUX8
506 * and is common between remote processor's.
507 *
508 * On PM8018 ADC the MPP is directly connected to the AMUX
509 * pre-mux. Therefore clients of the PM8018 MPP do not need
510 * to configure the MPP as an analog input to the pre-mux.
511 * Clients can directly issue request on the pre-mux AMUX
512 * channel to read the ADC on the MPP. Clients can directly
513 * call the pm8xxx_adc_read().
514 * @mpp_num PM8XXX MPP number to configure to AMUX6.
515 * @channel: Input channel to perform the ADC read.
516 * a) 'ADC_MPP_1_AMUX6' if the input voltage is less than 1.8V
517 * b) 'ADC_MPP_2_AMUX6' if the input voltage is greater then 1.8V
518 * the input voltage is pre-divided by 3 and passed to the ADC.
519 * The appropriate scaling function needs to be selected to let
520 * the driver know a post scaling is required before returning
521 * the result.
522 * @result: Structure pointer of type adc_chan_result
523 * in which the ADC read results are stored.
524 */
525uint32_t pm8xxx_adc_mpp_config_read(uint32_t mpp_num,
526 enum pm8xxx_adc_channels channel,
527 struct pm8xxx_adc_chan_result *result);
528/**
529 * pm8xxx_adc_btm_start() - Configure the BTM registers and start
530 monitoring the BATT_THERM channel for
531 threshold warm/cold temperature set
532 by the Battery client. The btm_start
533 api is to be used after calling the
534 pm8xxx_btm_configure() api which sets
535 the temperature thresholds, interval
536 and functions to call when warm/cold
537 events are triggered.
538 * @param: none.
539 */
540uint32_t pm8xxx_adc_btm_start(void);
541
542/**
543 * pm8xxx_adc_btm_end() - Configures the BTM registers to stop
544 * monitoring the BATT_THERM channel for
545 * warm/cold events and disables the
546 * interval timer.
547 * @param: none.
548 */
549uint32_t pm8xxx_adc_btm_end(void);
550
551/**
552 * pm8xxx_adc_btm_configure() - Configures the BATT_THERM channel
553 * parameters for warm/cold thresholds.
554 * Sets the interval timer for perfoming
555 * reading the temperature done by the HW.
556 * @btm_param: Structure pointer of type adc_arb_btm_param *
557 * which client provides for threshold warm/cold,
558 * interval and functions to call when warm/cold
559 * events are triggered.
560 */
561uint32_t pm8xxx_adc_btm_configure(struct pm8xxx_adc_arb_btm_param *);
562#else
563static inline uint32_t pm8xxx_adc_read(uint32_t channel,
564 struct pm8xxx_adc_chan_result *result)
565{ return -ENXIO; }
566static inline uint32_t pm8xxx_adc_mpp_config_read(uint32_t mpp_num,
567 enum pm8xxx_adc_channels channel,
568 struct pm8xxx_adc_chan_result *result)
569{ return -ENXIO; }
570static inline uint32_t pm8xxx_adc_btm_start(void)
571{ return -ENXIO; }
572static inline uint32_t pm8xxx_adc_btm_end(void)
573{ return -ENXIO; }
574static inline uint32_t pm8xxx_adc_btm_configure(
575 struct pm8xxx_adc_arb_btm_param *param)
576{ return -ENXIO; }
577#endif
578
579#endif /* PM8XXX_ADC_H */