SmartAudio/lichee/linux-4.9/drivers/input/misc/ltr_553als.h

122 lines
3.2 KiB
C
Executable File

/* Lite-On LTR-553ALS Linux Driver
*
* Copyright (C) 2011 Lite-On Technology Corp (Singapore)
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#ifndef _LTR553_H
#define _LTR553_H
#define LTR553_NAME "ltr553"
/* LTR-553 Registers */
#define LTR553_ALS_CONTR 0x80
#define LTR553_PS_CONTR 0x81
#define LTR553_PS_LED 0x82
#define LTR553_PS_N_PULSES 0x83
#define LTR553_PS_MEAS_RATE 0x84
#define LTR553_ALS_MEAS_RATE 0x85
#define LTR553_REG_PART_ID 0x86
#define LTR553_MANUFACTURER_ID 0x87
#define LTR553_MID 0x05
#define LTR553_PID 0x92
#define LTR553_SLAVE_ADDR 0x23
#define LTR553_INTERRUPT 0x8F
#define LTR553_PS_THRES_UP_0 0x90
#define LTR553_PS_THRES_UP_1 0x91
#define LTR553_PS_THRES_LOW_0 0x92
#define LTR553_PS_THRES_LOW_1 0x93
#define LTR553_ALS_THRES_UP_0 0x97
#define LTR553_ALS_THRES_UP_1 0x98
#define LTR553_ALS_THRES_LOW_0 0x99
#define LTR553_ALS_THRES_LOW_1 0x9A
#define LTR553_INTERRUPT_PERSIST 0x9E
/* 553's Read Only Registers */
#define LTR553_ALS_DATA_CH1_0 0x88
#define LTR553_ALS_DATA_CH1_1 0x89
#define LTR553_ALS_DATA_CH0_0 0x8A
#define LTR553_ALS_DATA_CH0_1 0x8B
#define LTR553_ALS_PS_STATUS 0x8C
#define LTR553_PS_DATA_0 0x8D
#define LTR553_PS_DATA_1 0x8E
/* Basic Operating Modes */
#define MODE_ALS_ON_Range1 0x01
#define MODE_ALS_ON_Range2 0x05
#define MODE_ALS_ON_Range4 0x09
#define MODE_ALS_ON_Range8 0x0D
#define MODE_ALS_ON_Range48 0x19
#define MODE_ALS_ON_Range96 0x1D
#define MODE_ALS_StdBy 0x00
#define MODE_PS_ON_Gain16 0x03
#define MODE_PS_ON_Gain32 0x0B
#define MODE_PS_ON_Gain64 0x0F
#define MODE_PS_StdBy 0x00
#define PS_RANGE16 16
#define PS_RANGE32 32
#define PS_RANGE64 64
#define ALS_RANGE1_320 1
#define ALS_RANGE2_64K 2
/*
* Magic Number
* ============
* Refer to file ioctl-number.txt for allocation
*/
#define LTR553_IOCTL_MAGIC 'c'
/* IOCTLs for ltr553 device */
#define LTR553_IOCTL_PS_ENABLE _IOW(LTR553_IOCTL_MAGIC, 0, char *)
#define LTR553_IOCTL_ALS_ENABLE _IOW(LTR553_IOCTL_MAGIC, 1, char *)
#define LTR553_IOCTL_READ_PS_DATA _IOR(LTR553_IOCTL_MAGIC, 2, char *)
#define LTR553_IOCTL_READ_PS_INT _IOR(LTR553_IOCTL_MAGIC, 3, char *)
#define LTR553_IOCTL_READ_ALS_DATA _IOR(LTR553_IOCTL_MAGIC, 4, char *)
#define LTR553_IOCTL_READ_ALS_INT _IOR(LTR553_IOCTL_MAGIC, 5, char *)
/* Power On response time in ms */
#define PON_DELAY 600
#define WAKEUP_DELAY 10
/* Interrupt vector number to use when probing IRQ number.
* User changeable depending on sys interrupt.
* For IRQ numbers used, see /proc/interrupts.
*/
#define GPIO_INT_NO 32
enum {
DEBUG_INIT = 1U << 0,
DEBUG_REPORT_ALS_DATA = 1U << 1,
DEBUG_REPORT_PS_DATA = 1U << 2,
DEBUG_SUSPEND = 1U << 3,
DEBUG_CONTROL_INFO = 1U << 4,
DEBUG_INT = 1U << 5,
};
#define dprintk(level_mask, fmt, arg...) if (unlikely(debug_mask & level_mask)) \
printk("*ltr_553:*" fmt , ## arg)
int ltr553_devinit(void);
void ltr553_set_client(struct i2c_client *client);
int ltr553_als_power(bool enable);
int ltr553_ps_power(bool enable);
int ltr553_i2c_read_reg(u8 regnum);
int ltr553_als_read(void);
int ltr553_ps_read(void);
#endif