Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
tsl2x7x_core.c File Reference
#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/mutex.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/iio/events.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include "tsl2x7x.h"

Go to the source code of this file.

Data Structures

struct  tsl2x7x_parse_result
 
struct  tsl2x7x_als_info
 
struct  tsl2x7x_prox_stat
 
struct  tsl2x7x_chip_info
 
struct  tsl2X7X_chip
 

Macros

#define PROX_STAT_CAL   0
 
#define PROX_STAT_SAMP   1
 
#define MAX_SAMPLES_CAL   200
 
#define TRITON_ID   0x00
 
#define SWORDFISH_ID   0x30
 
#define HALIBUT_ID   0x20
 
#define TSL2X7X_LUX_CALC_OVER_FLOW   65535
 
#define TSL2X7X_MAX_CONFIG_REG   16
 
#define TSL2X7X_CNTRL   0x00
 
#define TSL2X7X_ALS_TIME   0X01
 
#define TSL2X7X_PRX_TIME   0x02
 
#define TSL2X7X_WAIT_TIME   0x03
 
#define TSL2X7X_ALS_MINTHRESHLO   0X04
 
#define TSL2X7X_ALS_MINTHRESHHI   0X05
 
#define TSL2X7X_ALS_MAXTHRESHLO   0X06
 
#define TSL2X7X_ALS_MAXTHRESHHI   0X07
 
#define TSL2X7X_PRX_MINTHRESHLO   0X08
 
#define TSL2X7X_PRX_MINTHRESHHI   0X09
 
#define TSL2X7X_PRX_MAXTHRESHLO   0X0A
 
#define TSL2X7X_PRX_MAXTHRESHHI   0X0B
 
#define TSL2X7X_PERSISTENCE   0x0C
 
#define TSL2X7X_PRX_CONFIG   0x0D
 
#define TSL2X7X_PRX_COUNT   0x0E
 
#define TSL2X7X_GAIN   0x0F
 
#define TSL2X7X_NOTUSED   0x10
 
#define TSL2X7X_REVID   0x11
 
#define TSL2X7X_CHIPID   0x12
 
#define TSL2X7X_STATUS   0x13
 
#define TSL2X7X_ALS_CHAN0LO   0x14
 
#define TSL2X7X_ALS_CHAN0HI   0x15
 
#define TSL2X7X_ALS_CHAN1LO   0x16
 
#define TSL2X7X_ALS_CHAN1HI   0x17
 
#define TSL2X7X_PRX_LO   0x18
 
#define TSL2X7X_PRX_HI   0x19
 
#define TSL2X7X_CMD_REG   0x80
 
#define TSL2X7X_CMD_SPL_FN   0x60
 
#define TSL2X7X_CMD_PROX_INT_CLR   0X05
 
#define TSL2X7X_CMD_ALS_INT_CLR   0x06
 
#define TSL2X7X_CMD_PROXALS_INT_CLR   0X07
 
#define TSL2X7X_CNTL_ADC_ENBL   0x02
 
#define TSL2X7X_CNTL_PWR_ON   0x01
 
#define TSL2X7X_STA_ADC_VALID   0x01
 
#define TSL2X7X_STA_PRX_VALID   0x02
 
#define TSL2X7X_STA_ADC_PRX_VALID
 
#define TSL2X7X_STA_ALS_INTR   0x10
 
#define TSL2X7X_STA_PRX_INTR   0x20
 
#define TSL2X7X_CNTL_REG_CLEAR   0x00
 
#define TSL2X7X_CNTL_PROX_INT_ENBL   0X20
 
#define TSL2X7X_CNTL_ALS_INT_ENBL   0X10
 
#define TSL2X7X_CNTL_WAIT_TMR_ENBL   0X08
 
#define TSL2X7X_CNTL_PROX_DET_ENBL   0X04
 
#define TSL2X7X_CNTL_PWRON   0x01
 
#define TSL2X7X_CNTL_ALSPON_ENBL   0x03
 
#define TSL2X7X_CNTL_INTALSPON_ENBL   0x13
 
#define TSL2X7X_CNTL_PROXPON_ENBL   0x0F
 
#define TSL2X7X_CNTL_INTPROXPON_ENBL   0x2F
 
#define TSL2X7X_DIODE0   0x10
 
#define TSL2X7X_DIODE1   0x20
 
#define TSL2X7X_DIODE_BOTH   0x30
 
#define TSL2X7X_mA100   0x00
 
#define TSL2X7X_mA50   0x40
 
#define TSL2X7X_mA25   0x80
 
#define TSL2X7X_mA13   0xD0
 
#define TSL2X7X_MAX_TIMER_CNT   (0xFF)
 
#define TSL2X7X_EVENT_MASK
 
#define TSL2X7X_MIN_ITIME   3
 

Enumerations

enum  {
  tsl2571, tsl2671, tmd2671, tsl2771,
  tmd2771, tsl2572, tsl2672, tmd2672,
  tsl2772, tmd2772
}
 
enum  { TSL2X7X_CHIP_UNKNOWN = 0, TSL2X7X_CHIP_WORKING = 1, TSL2X7X_CHIP_SUSPENDED = 2 }
 
enum  {
  ALS, PRX, ALSPRX, PRX2,
  ALSPRX2
}
 

Functions

 MODULE_DEVICE_TABLE (i2c, tsl2x7x_idtable)
 
 module_i2c_driver (tsl2x7x_driver)
 
 MODULE_AUTHOR ("J. August Brenner<[email protected]>")
 
 MODULE_DESCRIPTION ("TAOS tsl2x7x ambient and proximity light sensor driver")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define HALIBUT_ID   0x20

Definition at line 43 of file tsl2x7x_core.c.

#define MAX_SAMPLES_CAL   200

Definition at line 38 of file tsl2x7x_core.c.

#define PROX_STAT_CAL   0

Definition at line 36 of file tsl2x7x_core.c.

#define PROX_STAT_SAMP   1

Definition at line 37 of file tsl2x7x_core.c.

#define SWORDFISH_ID   0x30

Definition at line 42 of file tsl2x7x_core.c.

#define TRITON_ID   0x00

Definition at line 41 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_CHAN0HI   0x15

Definition at line 77 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_CHAN0LO   0x14

Definition at line 76 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_CHAN1HI   0x17

Definition at line 79 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_CHAN1LO   0x16

Definition at line 78 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_MAXTHRESHHI   0X07

Definition at line 63 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_MAXTHRESHLO   0X06

Definition at line 62 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_MINTHRESHHI   0X05

Definition at line 61 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_MINTHRESHLO   0X04

Definition at line 60 of file tsl2x7x_core.c.

#define TSL2X7X_ALS_TIME   0X01

Definition at line 57 of file tsl2x7x_core.c.

#define TSL2X7X_CHIPID   0x12

Definition at line 74 of file tsl2x7x_core.c.

#define TSL2X7X_CMD_ALS_INT_CLR   0x06

Definition at line 88 of file tsl2x7x_core.c.

#define TSL2X7X_CMD_PROX_INT_CLR   0X05

Definition at line 87 of file tsl2x7x_core.c.

#define TSL2X7X_CMD_PROXALS_INT_CLR   0X07

Definition at line 89 of file tsl2x7x_core.c.

#define TSL2X7X_CMD_REG   0x80

Definition at line 84 of file tsl2x7x_core.c.

#define TSL2X7X_CMD_SPL_FN   0x60

Definition at line 85 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_ADC_ENBL   0x02

Definition at line 92 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_ALS_INT_ENBL   0X10

Definition at line 106 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_ALSPON_ENBL   0x03

Definition at line 110 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_INTALSPON_ENBL   0x13

Definition at line 111 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_INTPROXPON_ENBL   0x2F

Definition at line 113 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_PROX_DET_ENBL   0X04

Definition at line 108 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_PROX_INT_ENBL   0X20

Definition at line 105 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_PROXPON_ENBL   0x0F

Definition at line 112 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_PWR_ON   0x01

Definition at line 93 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_PWRON   0x01

Definition at line 109 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_REG_CLEAR   0x00

Definition at line 104 of file tsl2x7x_core.c.

#define TSL2X7X_CNTL_WAIT_TMR_ENBL   0X08

Definition at line 107 of file tsl2x7x_core.c.

#define TSL2X7X_CNTRL   0x00

Definition at line 56 of file tsl2x7x_core.c.

#define TSL2X7X_DIODE0   0x10

Definition at line 116 of file tsl2x7x_core.c.

#define TSL2X7X_DIODE1   0x20

Definition at line 117 of file tsl2x7x_core.c.

#define TSL2X7X_DIODE_BOTH   0x30

Definition at line 118 of file tsl2x7x_core.c.

#define TSL2X7X_EVENT_MASK
#define TSL2X7X_GAIN   0x0F

Definition at line 71 of file tsl2x7x_core.c.

#define TSL2X7X_LUX_CALC_OVER_FLOW   65535

Definition at line 46 of file tsl2x7x_core.c.

#define TSL2X7X_mA100   0x00

Definition at line 121 of file tsl2x7x_core.c.

#define TSL2X7X_mA13   0xD0

Definition at line 124 of file tsl2x7x_core.c.

#define TSL2X7X_mA25   0x80

Definition at line 123 of file tsl2x7x_core.c.

#define TSL2X7X_mA50   0x40

Definition at line 122 of file tsl2x7x_core.c.

#define TSL2X7X_MAX_CONFIG_REG   16

Definition at line 53 of file tsl2x7x_core.c.

#define TSL2X7X_MAX_TIMER_CNT   (0xFF)

Definition at line 125 of file tsl2x7x_core.c.

#define TSL2X7X_MIN_ITIME   3

Definition at line 132 of file tsl2x7x_core.c.

#define TSL2X7X_NOTUSED   0x10

Definition at line 72 of file tsl2x7x_core.c.

#define TSL2X7X_PERSISTENCE   0x0C

Definition at line 68 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_CONFIG   0x0D

Definition at line 69 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_COUNT   0x0E

Definition at line 70 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_HI   0x19

Definition at line 81 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_LO   0x18

Definition at line 80 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_MAXTHRESHHI   0X0B

Definition at line 67 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_MAXTHRESHLO   0X0A

Definition at line 66 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_MINTHRESHHI   0X09

Definition at line 65 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_MINTHRESHLO   0X08

Definition at line 64 of file tsl2x7x_core.c.

#define TSL2X7X_PRX_TIME   0x02

Definition at line 58 of file tsl2x7x_core.c.

#define TSL2X7X_REVID   0x11

Definition at line 73 of file tsl2x7x_core.c.

#define TSL2X7X_STA_ADC_PRX_VALID
Value:
TSL2X7X_STA_PRX_VALID)

Definition at line 98 of file tsl2x7x_core.c.

#define TSL2X7X_STA_ADC_VALID   0x01

Definition at line 96 of file tsl2x7x_core.c.

#define TSL2X7X_STA_ALS_INTR   0x10

Definition at line 100 of file tsl2x7x_core.c.

#define TSL2X7X_STA_PRX_INTR   0x20

Definition at line 101 of file tsl2x7x_core.c.

#define TSL2X7X_STA_PRX_VALID   0x02

Definition at line 97 of file tsl2x7x_core.c.

#define TSL2X7X_STATUS   0x13

Definition at line 75 of file tsl2x7x_core.c.

#define TSL2X7X_WAIT_TIME   0x03

Definition at line 59 of file tsl2x7x_core.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
tsl2571 
tsl2671 
tmd2671 
tsl2771 
tmd2771 
tsl2572 
tsl2672 
tmd2672 
tsl2772 
tmd2772 

Definition at line 135 of file tsl2x7x_core.c.

anonymous enum
Enumerator:
TSL2X7X_CHIP_UNKNOWN 
TSL2X7X_CHIP_WORKING 
TSL2X7X_CHIP_SUSPENDED 

Definition at line 148 of file tsl2x7x_core.c.

anonymous enum
Enumerator:
ALS 
PRX 
ALSPRX 
PRX2 
ALSPRX2 

Definition at line 273 of file tsl2x7x_core.c.

Function Documentation

MODULE_AUTHOR ( "J. August Brenner<[email protected]>"  )
MODULE_DESCRIPTION ( "TAOS tsl2x7x ambient and proximity light sensor driver )
MODULE_DEVICE_TABLE ( i2c  ,
tsl2x7x_idtable   
)
module_i2c_driver ( tsl2x7x_driver  )
MODULE_LICENSE ( "GPL"  )