blob: 8749b99b94f74ff2d61bc9efb0a152ab12b47658 [file] [log] [blame]
Nick Reuter53974e72013-12-30 23:42:37 -06001/* include/linux/cm3628.h
2 *
3 * Copyright (C) 2010 HTC, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __LINUX_CM3628_H
17#define __LINUX_CM3628_H
18
19#define CM3628_I2C_NAME "cm3628"
20
21/* Define Slave Address*/
22/*#define ALS_slave_address 0x30
23#define ALS_slave_read 0x31
24#define PS_slave_address 0x32
25#define PS_slave_read 0x33*/
26/*Define ALS Command Code*/
27#define ALS_cmd_cmd 0x00
28#define ALS_average 0x01
29#define ALS_high_thd_msb 0x02
30#define ALS_high_thd_lsb 0x03
31#define ALS_low_thd_msb 0x04
32#define ALS_low_thd_lsb 0x05
33/* Define PS Command Code*/
34#define PS_cmd_cmd 0x00
35#define PS_thd 0x01
36#define PS_cancel 0x02
37#define PS_default 0x03
38/*Define Interrupt address*/
39/*#define check_interrupt_add 0x18*/
40
41/*sl29028*/
42
43#define ALS_CALIBRATED 0x6DA5
44#define PS_CALIBRATED 0x5053
45
46
47/*cm3628*/
48/*for ALS command 00h*/
49#define CM3628_ALS_IT_50ms (0 << 6)
50#define CM3628_ALS_IT_100ms (1 << 6)
51#define CM3628_ALS_IT_200ms (2 << 6)
52#define CM3628_ALS_IT_400ms (3 << 6)
53#define CM3628_ALS_PERS_1 (0 << 4)
54#define CM3628_ALS_PERS_2 (1 << 4)
55#define CM3628_ALS_PERS_4 (2 << 4)
56#define CM3628_ALS_PERS_8 (3 << 4)
57#define CM3628_ALS_BIT2_Default_1 (1 << 2)
58#define CM3628_ALS_INT_EN (1 << 1) /*enable/disable Interrupt*/
59#define CM3628_ALS_SD (1 << 0)/*enable/disable ALS func*/
60
61/*for ALS command 01h*/
62#define CM3628_ALS_RES (1 << 6)
63#define CM3628_ALS_AV_1 (0 << 4)
64#define CM3628_ALS_AV_2 (1 << 4)
65#define CM3628_ALS_AV_4 (2 << 4)
66#define CM3628_ALS_AV_8 (3 << 4)
67#define CM3628_ALS_HS (1 << 3)
68
69/*for PS command 00h*/
70#define CM3628_PS_DR_1_80 (0 << 6)
71#define CM3628_PS_DR_1_160 (1 << 6)
72#define CM3628_PS_DR_1_320 (2 << 6)
73#define CM3628_PS_DR_1_640 (3 << 6)
74#define CM3628_PS_IT_1T (0 << 4)
75#define CM3628_PS_IT_1_3T (1 << 4)
76#define CM3628_PS_IT_1_6T (2 << 4)
77#define CM3628_PS_IT_2T (3 << 4)
78#define CM3628_PS_PERS_1 (0 << 2)
79#define CM3628_PS_PERS_2 (1 << 2)
80#define CM3628_PS_PERS_3 (2 << 2)
81#define CM3628_PS_PERS_4 (3 << 2)
82#define CM3628_PS_INT_EN (1 << 1)/*enable/disable Interrupt*/
83#define CM3628_PS_SD (1 << 0)/*enable/disable PS func, 1:disable , 0: enable*/
84
85/*for PS command 03h*/
86#define CM3628_PS_MS (1 << 4)
87#define CM3628_PS_HYS (1 << 0)
88#define CM3628_PS_SMART_PERS (1 << 1)
89#define CM3628_IT_4X_ES (1 << 6)/*for integration time*/
90#define CM3628_IT_4X_MP (1 << 7)/*for integration time*/
91
92extern unsigned int ps_kparam1;
93extern unsigned int ps_kparam2;
94extern unsigned int als_kadc;
95struct cm3628_platform_data {
96 int intr;
97 uint16_t levels[10];
98 uint16_t golden_adc;
99 int (*power)(int, uint8_t); /* power to the chip */
100 int (*re_power)(uint8_t); /* power to the chip */
101 uint8_t ALS_IT;
102 uint8_t ALS_PERS;
103 uint8_t ALS_AV;
104 uint8_t ALS_HS;
105 uint8_t PS_DR;
106 uint8_t PS_IT;
107 uint8_t PS_PERS;
108 uint8_t PS_MS;
109 uint8_t PS_HYS;
110 uint16_t ALS_slave_address;
111 uint16_t PS_slave_address;
112 uint16_t check_interrupt_add;
113 uint8_t ps_thd_set;
114 uint8_t inte_cancel_set;
115 /*command code 0x02, intelligent cancel level, for ps calibration*/
116 uint8_t ps_conf2_val; /* PS_CONF2 value */
117 uint8_t ps_calibration_rule;
118 uint8_t ps_conf1_val;
119 uint8_t *mapping_table;
120 uint8_t mapping_size;
121 uint8_t ps_base_index;
122 uint8_t enable_polling_ignore;
123 uint8_t ps_thd_no_cal;
124 uint8_t ps_thd_with_cal;
125 uint8_t is_cmd;
126 uint8_t ps_adc_offset;
127 uint8_t ps_adc_offset2;
128 uint8_t ps_debounce;
129 uint16_t ps_delay_time;
130 uint8_t ps_reset_thd;
131};
132
133#endif