Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
ab8500-gpadc.c File Reference
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/completion.h>
#include <linux/regulator/consumer.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/mfd/abx500.h>
#include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500/ab8500-gpadc.h>

Go to the source code of this file.

Data Structures

struct  adc_cal_data
 
struct  ab8500_gpadc
 

Macros

#define AB8500_GPADC_CTRL1_REG   0x00
 
#define AB8500_GPADC_CTRL2_REG   0x01
 
#define AB8500_GPADC_CTRL3_REG   0x02
 
#define AB8500_GPADC_AUTO_TIMER_REG   0x03
 
#define AB8500_GPADC_STAT_REG   0x04
 
#define AB8500_GPADC_MANDATAL_REG   0x05
 
#define AB8500_GPADC_MANDATAH_REG   0x06
 
#define AB8500_GPADC_AUTODATAL_REG   0x07
 
#define AB8500_GPADC_AUTODATAH_REG   0x08
 
#define AB8500_GPADC_MUX_CTRL_REG   0x09
 
#define AB8500_GPADC_CAL_1   0x0F
 
#define AB8500_GPADC_CAL_2   0x10
 
#define AB8500_GPADC_CAL_3   0x11
 
#define AB8500_GPADC_CAL_4   0x12
 
#define AB8500_GPADC_CAL_5   0x13
 
#define AB8500_GPADC_CAL_6   0x14
 
#define AB8500_GPADC_CAL_7   0x15
 
#define EN_VINTCORE12   0x04
 
#define EN_VTVOUT   0x02
 
#define EN_GPADC   0x01
 
#define DIS_GPADC   0x00
 
#define SW_AVG_16   0x60
 
#define ADC_SW_CONV   0x04
 
#define EN_ICHAR   0x80
 
#define BTEMP_PULL_UP   0x08
 
#define EN_BUF   0x40
 
#define DIS_ZERO   0x00
 
#define GPADC_BUSY   0x01
 
#define ADC_RESOLUTION   1024
 
#define ADC_CH_BTEMP_MIN   0
 
#define ADC_CH_BTEMP_MAX   1350
 
#define ADC_CH_DIETEMP_MIN   0
 
#define ADC_CH_DIETEMP_MAX   1350
 
#define ADC_CH_CHG_V_MIN   0
 
#define ADC_CH_CHG_V_MAX   20030
 
#define ADC_CH_ACCDET2_MIN   0
 
#define ADC_CH_ACCDET2_MAX   2500
 
#define ADC_CH_VBAT_MIN   2300
 
#define ADC_CH_VBAT_MAX   4800
 
#define ADC_CH_CHG_I_MIN   0
 
#define ADC_CH_CHG_I_MAX   1500
 
#define ADC_CH_BKBAT_MIN   0
 
#define ADC_CH_BKBAT_MAX   3200
 
#define CALIB_SCALE   1000
 

Enumerations

enum  cal_channels { ADC_INPUT_VMAIN = 0, ADC_INPUT_BTEMP, ADC_INPUT_VBAT, NBR_CAL_INPUTS }
 

Functions

struct ab8500_gpadcab8500_gpadc_get (char *name)
 
 EXPORT_SYMBOL (ab8500_gpadc_get)
 
int ab8500_gpadc_ad_to_voltage (struct ab8500_gpadc *gpadc, u8 channel, int ad_value)
 
 EXPORT_SYMBOL (ab8500_gpadc_ad_to_voltage)
 
int ab8500_gpadc_convert (struct ab8500_gpadc *gpadc, u8 channel)
 
 EXPORT_SYMBOL (ab8500_gpadc_convert)
 
int ab8500_gpadc_read_raw (struct ab8500_gpadc *gpadc, u8 channel)
 
 EXPORT_SYMBOL (ab8500_gpadc_read_raw)
 
 subsys_initcall_sync (ab8500_gpadc_init)
 
 module_exit (ab8500_gpadc_exit)
 
 MODULE_LICENSE ("GPL v2")
 
 MODULE_AUTHOR ("Arun R Murthy, Daniel Willerud, Johan Palsson")
 
 MODULE_ALIAS ("platform:ab8500_gpadc")
 
 MODULE_DESCRIPTION ("AB8500 GPADC driver")
 

Macro Definition Documentation

#define AB8500_GPADC_AUTO_TIMER_REG   0x03

Definition at line 32 of file ab8500-gpadc.c.

#define AB8500_GPADC_AUTODATAH_REG   0x08

Definition at line 37 of file ab8500-gpadc.c.

#define AB8500_GPADC_AUTODATAL_REG   0x07

Definition at line 36 of file ab8500-gpadc.c.

#define AB8500_GPADC_CAL_1   0x0F

Definition at line 44 of file ab8500-gpadc.c.

#define AB8500_GPADC_CAL_2   0x10

Definition at line 45 of file ab8500-gpadc.c.

#define AB8500_GPADC_CAL_3   0x11

Definition at line 46 of file ab8500-gpadc.c.

#define AB8500_GPADC_CAL_4   0x12

Definition at line 47 of file ab8500-gpadc.c.

#define AB8500_GPADC_CAL_5   0x13

Definition at line 48 of file ab8500-gpadc.c.

#define AB8500_GPADC_CAL_6   0x14

Definition at line 49 of file ab8500-gpadc.c.

#define AB8500_GPADC_CAL_7   0x15

Definition at line 50 of file ab8500-gpadc.c.

#define AB8500_GPADC_CTRL1_REG   0x00

Definition at line 29 of file ab8500-gpadc.c.

#define AB8500_GPADC_CTRL2_REG   0x01

Definition at line 30 of file ab8500-gpadc.c.

#define AB8500_GPADC_CTRL3_REG   0x02

Definition at line 31 of file ab8500-gpadc.c.

#define AB8500_GPADC_MANDATAH_REG   0x06

Definition at line 35 of file ab8500-gpadc.c.

#define AB8500_GPADC_MANDATAL_REG   0x05

Definition at line 34 of file ab8500-gpadc.c.

#define AB8500_GPADC_MUX_CTRL_REG   0x09

Definition at line 38 of file ab8500-gpadc.c.

#define AB8500_GPADC_STAT_REG   0x04

Definition at line 33 of file ab8500-gpadc.c.

#define ADC_CH_ACCDET2_MAX   2500

Definition at line 74 of file ab8500-gpadc.c.

#define ADC_CH_ACCDET2_MIN   0

Definition at line 73 of file ab8500-gpadc.c.

#define ADC_CH_BKBAT_MAX   3200

Definition at line 80 of file ab8500-gpadc.c.

#define ADC_CH_BKBAT_MIN   0

Definition at line 79 of file ab8500-gpadc.c.

#define ADC_CH_BTEMP_MAX   1350

Definition at line 68 of file ab8500-gpadc.c.

#define ADC_CH_BTEMP_MIN   0

Definition at line 67 of file ab8500-gpadc.c.

#define ADC_CH_CHG_I_MAX   1500

Definition at line 78 of file ab8500-gpadc.c.

#define ADC_CH_CHG_I_MIN   0

Definition at line 77 of file ab8500-gpadc.c.

#define ADC_CH_CHG_V_MAX   20030

Definition at line 72 of file ab8500-gpadc.c.

#define ADC_CH_CHG_V_MIN   0

Definition at line 71 of file ab8500-gpadc.c.

#define ADC_CH_DIETEMP_MAX   1350

Definition at line 70 of file ab8500-gpadc.c.

#define ADC_CH_DIETEMP_MIN   0

Definition at line 69 of file ab8500-gpadc.c.

#define ADC_CH_VBAT_MAX   4800

Definition at line 76 of file ab8500-gpadc.c.

#define ADC_CH_VBAT_MIN   2300

Definition at line 75 of file ab8500-gpadc.c.

#define ADC_RESOLUTION   1024

Definition at line 66 of file ab8500-gpadc.c.

#define ADC_SW_CONV   0x04

Definition at line 58 of file ab8500-gpadc.c.

#define BTEMP_PULL_UP   0x08

Definition at line 60 of file ab8500-gpadc.c.

#define CALIB_SCALE   1000

Definition at line 83 of file ab8500-gpadc.c.

#define DIS_GPADC   0x00

Definition at line 56 of file ab8500-gpadc.c.

#define DIS_ZERO   0x00

Definition at line 62 of file ab8500-gpadc.c.

#define EN_BUF   0x40

Definition at line 61 of file ab8500-gpadc.c.

#define EN_GPADC   0x01

Definition at line 55 of file ab8500-gpadc.c.

#define EN_ICHAR   0x80

Definition at line 59 of file ab8500-gpadc.c.

#define EN_VINTCORE12   0x04

Definition at line 53 of file ab8500-gpadc.c.

#define EN_VTVOUT   0x02

Definition at line 54 of file ab8500-gpadc.c.

#define GPADC_BUSY   0x01

Definition at line 63 of file ab8500-gpadc.c.

#define SW_AVG_16   0x60

Definition at line 57 of file ab8500-gpadc.c.

Enumeration Type Documentation

Enumerator:
ADC_INPUT_VMAIN 
ADC_INPUT_BTEMP 
ADC_INPUT_VBAT 
NBR_CAL_INPUTS 

Definition at line 85 of file ab8500-gpadc.c.

Function Documentation

int ab8500_gpadc_ad_to_voltage ( struct ab8500_gpadc gpadc,
u8  channel,
int  ad_value 
)

ab8500_gpadc_ad_to_voltage() - Convert a raw ADC value to a voltage

Definition at line 149 of file ab8500-gpadc.c.

int ab8500_gpadc_convert ( struct ab8500_gpadc gpadc,
u8  channel 
)

ab8500_gpadc_convert() - gpadc conversion : analog channel to be converted to digital data

This function converts the selected analog i/p to digital data.

Definition at line 247 of file ab8500-gpadc.c.

struct ab8500_gpadc* ab8500_gpadc_get ( char name)
read

ab8500_gpadc_get() - returns a reference to the primary AB8500 GPADC (i.e. the first GPADC in the instance list)

Definition at line 133 of file ab8500-gpadc.c.

int ab8500_gpadc_read_raw ( struct ab8500_gpadc gpadc,
u8  channel 
)

ab8500_gpadc_read_raw() - gpadc read : analog channel to be read

This function obtains the raw ADC value, this then needs to be converted by calling ab8500_gpadc_ad_to_voltage()

Definition at line 275 of file ab8500-gpadc.c.

EXPORT_SYMBOL ( ab8500_gpadc_get  )
EXPORT_SYMBOL ( ab8500_gpadc_ad_to_voltage  )
EXPORT_SYMBOL ( ab8500_gpadc_convert  )
EXPORT_SYMBOL ( ab8500_gpadc_read_raw  )
MODULE_ALIAS ( "platform:ab8500_gpadc"  )
MODULE_AUTHOR ( "Arun R  Murthy,
Daniel  Willerud,
Johan Palsson"   
)
MODULE_DESCRIPTION ( "AB8500 GPADC driver )
module_exit ( ab8500_gpadc_exit  )
MODULE_LICENSE ( "GPL v2 )
subsys_initcall_sync ( ab8500_gpadc_init  )