blob: 46b821312ff0111ec436f3b47fd97202a2e1c814 [file] [log] [blame]
Flemmarde2ce3b72013-04-25 21:59:45 -07001/* include/linux/cm3629.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_CM3629_H
17#define __LINUX_CM3629_H
18
19#define CM3629_I2C_NAME "CM3629"
20
21
22#define ALS_config_cmd 0x00
23#define ALS_high_thd 0x01
24#define ALS_low_thd 0x02
25
26#define PS_config 0x03
27#define PS_config_ms 0x04
28#define PS_CANC 0x05
29#define PS_1_thd 0x06
30#define PS_2_thd 0x07
31#define PS_data 0x08
32#define ALS_data 0x09
33#define INT_FLAG 0x0B
34#define CH_ID 0x0C
35
36
37#define ALS_CALIBRATED 0x6DA5
38#define PS_CALIBRATED 0x5053
39
40#define CM3629_ALS_IT_50ms (0 << 6)
41#define CM3629_ALS_IT_100ms (1 << 6)
42#define CM3629_ALS_IT_200ms (2 << 6)
43#define CM3629_ALS_IT_400ms (3 << 6)
44
45#define CM3629_ALS_IT_80ms (0 << 6)
46#define CM3629_ALS_IT_160ms (1 << 6)
47#define CM3629_ALS_IT_320ms (2 << 6)
48#define CM3629_ALS_IT_640ms (3 << 6)
49
50
51#define CM3629_ALS_AV_1 (0 << 4)
52#define CM3629_ALS_AV_2 (1 << 4)
53#define CM3629_ALS_AV_4 (2 << 4)
54#define CM3629_ALS_AV_8 (3 << 4)
55#define CM3629_ALS_PERS_1 (0 << 2)
56#define CM3629_ALS_PERS_2 (1 << 2)
57#define CM3629_ALS_PERS_4 (2 << 2)
58#define CM3629_ALS_PERS_8 (3 << 2)
59#define CM3629_ALS_INT_EN (1 << 1)
60#define CM3629_ALS_SD (1 << 0)
61
62#define CM3629_PS_63_STEPS (0 << 4)
63#define CM3629_PS_120_STEPS (1 << 4)
64#define CM3629_PS_191_STEPS (2 << 4)
65#define CM3629_PS_255_STEPS (3 << 4)
66
67
68
69#define CM3629_PS_DR_1_40 (0 << 6)
70#define CM3629_PS_DR_1_80 (1 << 6)
71#define CM3629_PS_DR_1_160 (2 << 6)
72#define CM3629_PS_DR_1_320 (3 << 6)
73
74#define CM3629_PS_IT_1T (0 << 4)
75#define CM3629_PS_IT_1_3T (1 << 4)
76#define CM3629_PS_IT_1_6T (2 << 4)
77#define CM3629_PS_IT_2T (3 << 4)
78
79#define CM3629_PS1_PERS_1 (0 << 2)
80#define CM3629_PS1_PERS_2 (1 << 2)
81#define CM3629_PS1_PERS_3 (2 << 2)
82#define CM3629_PS1_PERS_4 (3 << 2)
83
84#define CM3629_PS2_SD (1 << 1)
85#define CM3629_PS1_SD (1 << 0)
86
87#define CM3629_PS_ITB_1_2 (0 << 6)
88#define CM3629_PS_ITB_1 (1 << 6)
89#define CM3629_PS_ITB_2 (2 << 6)
90#define CM3629_PS_ITB_4 (3 << 6)
91
92#define CM3629_PS_ITR_1 (0 << 4)
93#define CM3629_PS_ITR_1_2 (1 << 4)
94#define CM3629_PS_ITR_1_4 (2 << 4)
95#define CM3629_PS_ITR_1_8 (3 << 4)
96
97#define CM3629_PS2_INT_DIS (0 << 2)
98#define CM3629_PS2_INT_CLS (1 << 2)
99#define CM3629_PS2_INT_AWY (2 << 2)
100#define CM3629_PS2_INT_BOTH (3 << 2)
101
102#define CM3629_PS1_INT_DIS (0 << 0)
103#define CM3629_PS1_INT_CLS (1 << 0)
104#define CM3629_PS1_INT_AWY (2 << 0)
105#define CM3629_PS1_INT_BOTH (3 << 0)
106
107
108#define CM3629_PS2_PROL_4 (0 << 6)
109#define CM3629_PS2_PROL_8 (1 << 6)
110#define CM3629_PS2_PROL_16 (2 << 6)
111#define CM3629_PS2_PROL_32 (3 << 6)
112
113#define CM3629_PS_INTT (1 << 5)
114#define CM3629_PS_SMART_PRES (1 << 4)
115#define CM3629_PS_PS_FOR (1 << 3)
116#define CM3629_PS_PS_TRIG (1 << 2)
117
118#define CM3629_PS2_PERS_1 (0 << 0)
119#define CM3629_PS2_PERS_2 (1 << 0)
120#define CM3629_PS2_PERS_3 (2 << 0)
121#define CM3629_PS2_PERS_4 (3 << 0)
122
123#define CM3629_PS_MS (1 << 5)
124
125#define CM3629_PS2_SPFLAG (1 << 7)
126#define CM3629_PS1_SPFLAG (1 << 6)
127
128#define CM3629_ALS_IF_L (1 << 5)
129#define CM3629_ALS_IF_H (1 << 4)
130#define CM3629_PS2_IF_CLOSE (1 << 3)
131#define CM3629_PS2_IF_AWAY (1 << 2)
132#define CM3629_PS1_IF_CLOSE (1 << 1)
133#define CM3629_PS1_IF_AWAY (1 << 0)
134
135extern unsigned int ps_kparam1;
136extern unsigned int ps_kparam2;
137extern unsigned int als_kadc;
138enum {
139 CAPELLA_CM36282,
140 CAPELLA_CM36292,
141};
142
143enum {
144 CM3629_PS_DISABLE,
145 CM3629_PS1_ONLY,
146 CM3629_PS2_ONLY,
147 CM3629_PS1_PS2_BOTH,
148};
149
150struct cm3629_platform_data {
151 int model;
152 int intr;
153 uint16_t levels[10];
154 uint16_t golden_adc;
155 int (*power)(int, uint8_t);
156 int (*lpm_power)(uint8_t);
157 uint16_t cm3629_slave_address;
158 uint8_t ps_select;
159 uint8_t ps1_thd_set;
160 uint8_t ps1_thh_diff;
161 uint8_t ps2_thd_set;
162 uint8_t inte_cancel_set;
163
164 uint8_t ps_conf2_val;
165 uint8_t *mapping_table;
166 uint8_t mapping_size;
167 uint8_t ps_base_index;
168
169 uint8_t ps_calibration_rule;
170 uint8_t ps_conf1_val;
171 uint8_t ps_conf3_val;
172 uint8_t enable_polling_ignore;
173 uint8_t ps1_thd_no_cal;
174 uint8_t ps1_thd_with_cal;
175 uint8_t ps2_thd_no_cal;
176 uint8_t ps2_thd_with_cal;
177 uint8_t ls_cmd;
178 uint8_t ps1_adc_offset;
179 uint8_t ps2_adc_offset;
180 uint8_t ps_debounce;
181 uint16_t ps_delay_time;
182 unsigned int no_need_change_setting;
183 uint8_t dark_level;
184};
185
186int power_key_check_in_pocket(void);
187#endif