ab8500-gpadc.h 2.1 KB
Newer Older
A
Arun Murthy 已提交
1 2 3 4 5
/*
 * Copyright (C) 2010 ST-Ericsson SA
 * Licensed under GPLv2.
 *
 * Author: Arun R Murthy <arun.murthy@stericsson.com>
6
 * Author: Daniel Willerud <daniel.willerud@stericsson.com>
7
 * Author: M'boumba Cedric Madianga <cedric.madianga@stericsson.com>
A
Arun Murthy 已提交
8 9 10 11 12
 */

#ifndef	_AB8500_GPADC_H
#define _AB8500_GPADC_H

13 14
/* GPADC source: From datasheet(ADCSwSel[4:0] in GPADCCtrl2
 * and ADCHwSel[4:0] in GPADCCtrl3 ) */
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#define BAT_CTRL		0x01
#define BTEMP_BALL		0x02
#define MAIN_CHARGER_V		0x03
#define ACC_DETECT1		0x04
#define ACC_DETECT2		0x05
#define ADC_AUX1		0x06
#define ADC_AUX2		0x07
#define MAIN_BAT_V		0x08
#define VBUS_V			0x09
#define MAIN_CHARGER_C		0x0A
#define USB_CHARGER_C		0x0B
#define BK_BAT_V		0x0C
#define DIE_TEMP		0x0D
#define USB_ID			0x0E
#define XTAL_TEMP		0x12
#define VBAT_TRUE_MEAS		0x13
#define BAT_CTRL_AND_IBAT	0x1C
#define VBAT_MEAS_AND_IBAT	0x1D
#define VBAT_TRUE_MEAS_AND_IBAT	0x1E
#define BAT_TEMP_AND_IBAT	0x1F

/* Virtual channel used only for ibat convertion to ampere
 * Battery current conversion (ibat) cannot be requested as a single conversion
 *  but it is always in combination with other input requests
 */
#define IBAT_VIRTUAL_CHANNEL		0xFF
A
Arun Murthy 已提交
41

42 43 44 45 46 47 48 49 50 51 52
#define SAMPLE_1        1
#define SAMPLE_4        4
#define SAMPLE_8        8
#define SAMPLE_16       16
#define RISING_EDGE     0
#define FALLING_EDGE    1

/* Arbitrary ADC conversion type constants */
#define ADC_SW				0
#define ADC_HW				1

53 54 55
struct ab8500_gpadc;

struct ab8500_gpadc *ab8500_gpadc_get(char *name);
56 57 58 59 60 61 62 63 64 65
int ab8500_gpadc_sw_hw_convert(struct ab8500_gpadc *gpadc, u8 channel,
		u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type);
static inline int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 channel)
{
	return ab8500_gpadc_sw_hw_convert(gpadc, channel,
			SAMPLE_16, 0, 0, ADC_SW);
}

int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel,
		u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type);
66 67 68
int ab8500_gpadc_double_read_raw(struct ab8500_gpadc *gpadc, u8 channel,
		u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type,
		int *ibat);
69
int ab8500_gpadc_ad_to_voltage(struct ab8500_gpadc *gpadc,
70
		u8 channel, int ad_value);
A
Arun Murthy 已提交
71 72

#endif /* _AB8500_GPADC_H */