Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
apds990x.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/delay.h>
#include <linux/wait.h>
#include <linux/slab.h>
#include <linux/i2c/apds990x.h>

Go to the source code of this file.

Data Structures

struct  reverse_factors
 
struct  apds990x_chip
 

Macros

#define APDS990X_ENABLE   0x00 /* Enable of states and interrupts */
 
#define APDS990X_ATIME   0x01 /* ALS ADC time */
 
#define APDS990X_PTIME   0x02 /* Proximity ADC time */
 
#define APDS990X_WTIME   0x03 /* Wait time */
 
#define APDS990X_AILTL   0x04 /* ALS interrupt low threshold low byte */
 
#define APDS990X_AILTH   0x05 /* ALS interrupt low threshold hi byte */
 
#define APDS990X_AIHTL   0x06 /* ALS interrupt hi threshold low byte */
 
#define APDS990X_AIHTH   0x07 /* ALS interrupt hi threshold hi byte */
 
#define APDS990X_PILTL   0x08 /* Proximity interrupt low threshold low byte */
 
#define APDS990X_PILTH   0x09 /* Proximity interrupt low threshold hi byte */
 
#define APDS990X_PIHTL   0x0a /* Proximity interrupt hi threshold low byte */
 
#define APDS990X_PIHTH   0x0b /* Proximity interrupt hi threshold hi byte */
 
#define APDS990X_PERS   0x0c /* Interrupt persistence filters */
 
#define APDS990X_CONFIG   0x0d /* Configuration */
 
#define APDS990X_PPCOUNT   0x0e /* Proximity pulse count */
 
#define APDS990X_CONTROL   0x0f /* Gain control register */
 
#define APDS990X_REV   0x11 /* Revision Number */
 
#define APDS990X_ID   0x12 /* Device ID */
 
#define APDS990X_STATUS   0x13 /* Device status */
 
#define APDS990X_CDATAL   0x14 /* Clear ADC low data register */
 
#define APDS990X_CDATAH   0x15 /* Clear ADC high data register */
 
#define APDS990X_IRDATAL   0x16 /* IR ADC low data register */
 
#define APDS990X_IRDATAH   0x17 /* IR ADC high data register */
 
#define APDS990X_PDATAL   0x18 /* Proximity ADC low data register */
 
#define APDS990X_PDATAH   0x19 /* Proximity ADC high data register */
 
#define APDS990X_MAX_AGAIN   3
 
#define APDS990X_EN_PIEN   (0x1 << 5)
 
#define APDS990X_EN_AIEN   (0x1 << 4)
 
#define APDS990X_EN_WEN   (0x1 << 3)
 
#define APDS990X_EN_PEN   (0x1 << 2)
 
#define APDS990X_EN_AEN   (0x1 << 1)
 
#define APDS990X_EN_PON   (0x1 << 0)
 
#define APDS990X_EN_DISABLE_ALL   0
 
#define APDS990X_ST_PINT   (0x1 << 5)
 
#define APDS990X_ST_AINT   (0x1 << 4)
 
#define APDS990x_CMD_TYPE_MASK   (0x03 << 5)
 
#define APDS990x_CMD_TYPE_RB   (0x00 << 5) /* Repeated byte */
 
#define APDS990x_CMD_TYPE_INC   (0x01 << 5) /* Auto increment */
 
#define APDS990x_CMD_TYPE_SPE   (0x03 << 5) /* Special function */
 
#define APDS990x_ADDR_SHIFT   0
 
#define APDS990x_CMD   0x80
 
#define APDS990X_INT_ACK_ALS   0x6
 
#define APDS990X_INT_ACK_PS   0x5
 
#define APDS990X_INT_ACK_BOTH   0x7
 
#define APDS990X_PTIME_DEFAULT   0xff /* Recommended conversion time 2.7ms*/
 
#define APDS990X_WTIME_DEFAULT   0xee /* ~50ms wait time */
 
#define APDS990X_TIME_TO_ADC   1024 /* One timetick as ADC count value */
 
#define APDS990X_APERS_SHIFT   0
 
#define APDS990X_PPERS_SHIFT   4
 
#define APDS990X_ID_0   0x0
 
#define APDS990X_ID_4   0x4
 
#define APDS990X_ID_29   0x29
 
#define APDS_PGAIN_1X   0x0
 
#define APDS_PDIODE_IR   0x2
 
#define APDS990X_LUX_OUTPUT_SCALE   10
 
#define APDS_CALIB_SCALER   8192
 
#define APDS_LUX_NEUTRAL_CALIB_VALUE   (1 * APDS_CALIB_SCALER)
 
#define APDS_PROX_NEUTRAL_CALIB_VALUE   (1 * APDS_CALIB_SCALER)
 
#define APDS_PROX_DEF_THRES   600
 
#define APDS_PROX_HYSTERESIS   50
 
#define APDS_LUX_DEF_THRES_HI   101
 
#define APDS_LUX_DEF_THRES_LO   100
 
#define APDS_DEFAULT_PROX_PERS   1
 
#define APDS_TIMEOUT   2000
 
#define APDS_STARTUP_DELAY   25000 /* us */
 
#define APDS_RANGE   65535
 
#define APDS_PROX_RANGE   1023
 
#define APDS_LUX_GAIN_LO_LIMIT   100
 
#define APDS_LUX_GAIN_LO_LIMIT_STRICT   25
 
#define TIMESTEP   87 /* 2.7ms is about 87 / 32 */
 
#define TIME_STEP_SCALER   32
 
#define APDS_LUX_AVERAGING_TIME   50 /* tolerates 50/60Hz ripple */
 
#define APDS_LUX_DEFAULT_RATE   200
 
#define apds990x_suspend   NULL
 
#define apds990x_resume   NULL
 
#define apds990x_shutdown   NULL
 

Functions

 MODULE_DEVICE_TABLE (i2c, apds990x_id)
 
 module_i2c_driver (apds990x_driver)
 
 MODULE_DESCRIPTION ("APDS990X combined ALS and proximity sensor")
 
 MODULE_AUTHOR ("Samu Onkalo, Nokia Corporation")
 
 MODULE_LICENSE ("GPL v2")
 

Macro Definition Documentation

#define APDS990x_ADDR_SHIFT   0

Definition at line 86 of file apds990x.c.

#define APDS990X_AIHTH   0x07 /* ALS interrupt hi threshold hi byte */

Definition at line 45 of file apds990x.c.

#define APDS990X_AIHTL   0x06 /* ALS interrupt hi threshold low byte */

Definition at line 44 of file apds990x.c.

#define APDS990X_AILTH   0x05 /* ALS interrupt low threshold hi byte */

Definition at line 43 of file apds990x.c.

#define APDS990X_AILTL   0x04 /* ALS interrupt low threshold low byte */

Definition at line 42 of file apds990x.c.

#define APDS990X_APERS_SHIFT   0

Definition at line 103 of file apds990x.c.

#define APDS990X_ATIME   0x01 /* ALS ADC time */

Definition at line 39 of file apds990x.c.

#define APDS990X_CDATAH   0x15 /* Clear ADC high data register */

Definition at line 58 of file apds990x.c.

#define APDS990X_CDATAL   0x14 /* Clear ADC low data register */

Definition at line 57 of file apds990x.c.

#define APDS990x_CMD   0x80

Definition at line 87 of file apds990x.c.

#define APDS990x_CMD_TYPE_INC   (0x01 << 5) /* Auto increment */

Definition at line 83 of file apds990x.c.

#define APDS990x_CMD_TYPE_MASK   (0x03 << 5)

Definition at line 81 of file apds990x.c.

#define APDS990x_CMD_TYPE_RB   (0x00 << 5) /* Repeated byte */

Definition at line 82 of file apds990x.c.

#define APDS990x_CMD_TYPE_SPE   (0x03 << 5) /* Special function */

Definition at line 84 of file apds990x.c.

#define APDS990X_CONFIG   0x0d /* Configuration */

Definition at line 51 of file apds990x.c.

#define APDS990X_CONTROL   0x0f /* Gain control register */

Definition at line 53 of file apds990x.c.

#define APDS990X_EN_AEN   (0x1 << 1)

Definition at line 72 of file apds990x.c.

#define APDS990X_EN_AIEN   (0x1 << 4)

Definition at line 69 of file apds990x.c.

#define APDS990X_EN_DISABLE_ALL   0

Definition at line 74 of file apds990x.c.

#define APDS990X_EN_PEN   (0x1 << 2)

Definition at line 71 of file apds990x.c.

#define APDS990X_EN_PIEN   (0x1 << 5)

Definition at line 68 of file apds990x.c.

#define APDS990X_EN_PON   (0x1 << 0)

Definition at line 73 of file apds990x.c.

#define APDS990X_EN_WEN   (0x1 << 3)

Definition at line 70 of file apds990x.c.

#define APDS990X_ENABLE   0x00 /* Enable of states and interrupts */

Definition at line 38 of file apds990x.c.

#define APDS990X_ID   0x12 /* Device ID */

Definition at line 55 of file apds990x.c.

#define APDS990X_ID_0   0x0

Definition at line 107 of file apds990x.c.

#define APDS990X_ID_29   0x29

Definition at line 109 of file apds990x.c.

#define APDS990X_ID_4   0x4

Definition at line 108 of file apds990x.c.

#define APDS990X_INT_ACK_ALS   0x6

Definition at line 90 of file apds990x.c.

#define APDS990X_INT_ACK_BOTH   0x7

Definition at line 92 of file apds990x.c.

#define APDS990X_INT_ACK_PS   0x5

Definition at line 91 of file apds990x.c.

#define APDS990X_IRDATAH   0x17 /* IR ADC high data register */

Definition at line 60 of file apds990x.c.

#define APDS990X_IRDATAL   0x16 /* IR ADC low data register */

Definition at line 59 of file apds990x.c.

#define APDS990X_LUX_OUTPUT_SCALE   10

Definition at line 115 of file apds990x.c.

#define APDS990X_MAX_AGAIN   3

Definition at line 65 of file apds990x.c.

#define APDS990X_PDATAH   0x19 /* Proximity ADC high data register */

Definition at line 62 of file apds990x.c.

#define APDS990X_PDATAL   0x18 /* Proximity ADC low data register */

Definition at line 61 of file apds990x.c.

#define APDS990X_PERS   0x0c /* Interrupt persistence filters */

Definition at line 50 of file apds990x.c.

#define APDS990X_PIHTH   0x0b /* Proximity interrupt hi threshold hi byte */

Definition at line 49 of file apds990x.c.

#define APDS990X_PIHTL   0x0a /* Proximity interrupt hi threshold low byte */

Definition at line 48 of file apds990x.c.

#define APDS990X_PILTH   0x09 /* Proximity interrupt low threshold hi byte */

Definition at line 47 of file apds990x.c.

#define APDS990X_PILTL   0x08 /* Proximity interrupt low threshold low byte */

Definition at line 46 of file apds990x.c.

#define APDS990X_PPCOUNT   0x0e /* Proximity pulse count */

Definition at line 52 of file apds990x.c.

#define APDS990X_PPERS_SHIFT   4

Definition at line 104 of file apds990x.c.

#define APDS990X_PTIME   0x02 /* Proximity ADC time */

Definition at line 40 of file apds990x.c.

#define APDS990X_PTIME_DEFAULT   0xff /* Recommended conversion time 2.7ms*/

Definition at line 95 of file apds990x.c.

#define apds990x_resume   NULL

Definition at line 1232 of file apds990x.c.

#define APDS990X_REV   0x11 /* Revision Number */

Definition at line 54 of file apds990x.c.

#define apds990x_shutdown   NULL

Definition at line 1233 of file apds990x.c.

#define APDS990X_ST_AINT   (0x1 << 4)

Definition at line 78 of file apds990x.c.

#define APDS990X_ST_PINT   (0x1 << 5)

Definition at line 77 of file apds990x.c.

#define APDS990X_STATUS   0x13 /* Device status */

Definition at line 56 of file apds990x.c.

#define apds990x_suspend   NULL

Definition at line 1231 of file apds990x.c.

#define APDS990X_TIME_TO_ADC   1024 /* One timetick as ADC count value */

Definition at line 100 of file apds990x.c.

#define APDS990X_WTIME   0x03 /* Wait time */

Definition at line 41 of file apds990x.c.

#define APDS990X_WTIME_DEFAULT   0xee /* ~50ms wait time */

Definition at line 98 of file apds990x.c.

#define APDS_CALIB_SCALER   8192

Definition at line 167 of file apds990x.c.

#define APDS_DEFAULT_PROX_PERS   1

Definition at line 175 of file apds990x.c.

#define APDS_LUX_AVERAGING_TIME   50 /* tolerates 50/60Hz ripple */

Definition at line 187 of file apds990x.c.

#define APDS_LUX_DEF_THRES_HI   101

Definition at line 173 of file apds990x.c.

#define APDS_LUX_DEF_THRES_LO   100

Definition at line 174 of file apds990x.c.

#define APDS_LUX_DEFAULT_RATE   200

Definition at line 188 of file apds990x.c.

#define APDS_LUX_GAIN_LO_LIMIT   100

Definition at line 181 of file apds990x.c.

#define APDS_LUX_GAIN_LO_LIMIT_STRICT   25

Definition at line 182 of file apds990x.c.

#define APDS_LUX_NEUTRAL_CALIB_VALUE   (1 * APDS_CALIB_SCALER)

Definition at line 168 of file apds990x.c.

#define APDS_PDIODE_IR   0x2

Definition at line 113 of file apds990x.c.

#define APDS_PGAIN_1X   0x0

Definition at line 112 of file apds990x.c.

#define APDS_PROX_DEF_THRES   600

Definition at line 171 of file apds990x.c.

#define APDS_PROX_HYSTERESIS   50

Definition at line 172 of file apds990x.c.

#define APDS_PROX_NEUTRAL_CALIB_VALUE   (1 * APDS_CALIB_SCALER)

Definition at line 169 of file apds990x.c.

#define APDS_PROX_RANGE   1023

Definition at line 180 of file apds990x.c.

#define APDS_RANGE   65535

Definition at line 179 of file apds990x.c.

#define APDS_STARTUP_DELAY   25000 /* us */

Definition at line 178 of file apds990x.c.

#define APDS_TIMEOUT   2000

Definition at line 177 of file apds990x.c.

#define TIME_STEP_SCALER   32

Definition at line 185 of file apds990x.c.

#define TIMESTEP   87 /* 2.7ms is about 87 / 32 */

Definition at line 184 of file apds990x.c.

Function Documentation

MODULE_AUTHOR ( "Samu  Onkalo,
Nokia Corporation"   
)
MODULE_DESCRIPTION ( "APDS990X combined ALS and proximity sensor"  )
MODULE_DEVICE_TABLE ( i2c  ,
apds990x_id   
)
module_i2c_driver ( apds990x_driver  )
MODULE_LICENSE ( "GPL v2 )