blob: 7694e7ab1880fac16f9efca7975eabfefadc4565 [file] [log] [blame]
Daniel Willerudcf169432011-03-05 11:46:01 +01001/*
2 * Copyright (C) 2010 ST-Ericsson SA
3 * Licensed under GPLv2.
4 *
5 * Author: Arun R Murthy <arun.murthy@stericsson.com>
Daniel Willerud63219922011-03-05 11:46:13 +01006 * Author: Daniel Willerud <daniel.willerud@stericsson.com>
Lee Jones73482342013-02-26 10:06:55 +00007 * Author: M'boumba Cedric Madianga <cedric.madianga@stericsson.com>
Daniel Willerudcf169432011-03-05 11:46:01 +01008 */
9
10#ifndef _AB8500_GPADC_H
11#define _AB8500_GPADC_H
12
Lee Jones73482342013-02-26 10:06:55 +000013/* GPADC source: From datasheet(ADCSwSel[4:0] in GPADCCtrl2
14 * and ADCHwSel[4:0] in GPADCCtrl3 ) */
Daniel Willerudcf169432011-03-05 11:46:01 +010015#define BAT_CTRL 0x01
16#define BTEMP_BALL 0x02
17#define MAIN_CHARGER_V 0x03
18#define ACC_DETECT1 0x04
19#define ACC_DETECT2 0x05
20#define ADC_AUX1 0x06
21#define ADC_AUX2 0x07
22#define MAIN_BAT_V 0x08
23#define VBUS_V 0x09
24#define MAIN_CHARGER_C 0x0A
25#define USB_CHARGER_C 0x0B
26#define BK_BAT_V 0x0C
27#define DIE_TEMP 0x0D
28
Lee Jones73482342013-02-26 10:06:55 +000029#define SAMPLE_1 1
30#define SAMPLE_4 4
31#define SAMPLE_8 8
32#define SAMPLE_16 16
33#define RISING_EDGE 0
34#define FALLING_EDGE 1
35
36/* Arbitrary ADC conversion type constants */
37#define ADC_SW 0
38#define ADC_HW 1
39
40
Daniel Willerud63219922011-03-05 11:46:13 +010041struct ab8500_gpadc;
42
43struct ab8500_gpadc *ab8500_gpadc_get(char *name);
Lee Jones73482342013-02-26 10:06:55 +000044int ab8500_gpadc_sw_hw_convert(struct ab8500_gpadc *gpadc, u8 channel,
45 u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type);
46static inline int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 channel)
47{
48 return ab8500_gpadc_sw_hw_convert(gpadc, channel,
49 SAMPLE_16, 0, 0, ADC_SW);
50}
51
52int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel,
53 u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type);
Karl Komierowskibd4a40b2011-08-10 15:09:43 +020054int ab8500_gpadc_ad_to_voltage(struct ab8500_gpadc *gpadc,
Lee Jones73482342013-02-26 10:06:55 +000055 u8 channel, int ad_value);
Daniel Willerudcf169432011-03-05 11:46:01 +010056
57#endif /* _AB8500_GPADC_H */