blob: c9228195f0a0ff411b1d3b8a569524ff540402d1 [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
Flemmard84cecde2014-01-07 12:01:50 -080033
34#define WS_data 0x0A
Flemmarde2ce3b72013-04-25 21:59:45 -070035#define INT_FLAG 0x0B
36#define CH_ID 0x0C
37
38
39#define ALS_CALIBRATED 0x6DA5
40#define PS_CALIBRATED 0x5053
41
42#define CM3629_ALS_IT_50ms (0 << 6)
43#define CM3629_ALS_IT_100ms (1 << 6)
44#define CM3629_ALS_IT_200ms (2 << 6)
45#define CM3629_ALS_IT_400ms (3 << 6)
46
47#define CM3629_ALS_IT_80ms (0 << 6)
48#define CM3629_ALS_IT_160ms (1 << 6)
49#define CM3629_ALS_IT_320ms (2 << 6)
50#define CM3629_ALS_IT_640ms (3 << 6)
51
52
53#define CM3629_ALS_AV_1 (0 << 4)
54#define CM3629_ALS_AV_2 (1 << 4)
55#define CM3629_ALS_AV_4 (2 << 4)
56#define CM3629_ALS_AV_8 (3 << 4)
57#define CM3629_ALS_PERS_1 (0 << 2)
58#define CM3629_ALS_PERS_2 (1 << 2)
59#define CM3629_ALS_PERS_4 (2 << 2)
60#define CM3629_ALS_PERS_8 (3 << 2)
61#define CM3629_ALS_INT_EN (1 << 1)
62#define CM3629_ALS_SD (1 << 0)
63
64#define CM3629_PS_63_STEPS (0 << 4)
65#define CM3629_PS_120_STEPS (1 << 4)
66#define CM3629_PS_191_STEPS (2 << 4)
67#define CM3629_PS_255_STEPS (3 << 4)
68
69
70
71#define CM3629_PS_DR_1_40 (0 << 6)
72#define CM3629_PS_DR_1_80 (1 << 6)
73#define CM3629_PS_DR_1_160 (2 << 6)
74#define CM3629_PS_DR_1_320 (3 << 6)
75
76#define CM3629_PS_IT_1T (0 << 4)
77#define CM3629_PS_IT_1_3T (1 << 4)
78#define CM3629_PS_IT_1_6T (2 << 4)
79#define CM3629_PS_IT_2T (3 << 4)
80
81#define CM3629_PS1_PERS_1 (0 << 2)
82#define CM3629_PS1_PERS_2 (1 << 2)
83#define CM3629_PS1_PERS_3 (2 << 2)
84#define CM3629_PS1_PERS_4 (3 << 2)
85
86#define CM3629_PS2_SD (1 << 1)
87#define CM3629_PS1_SD (1 << 0)
88
89#define CM3629_PS_ITB_1_2 (0 << 6)
90#define CM3629_PS_ITB_1 (1 << 6)
91#define CM3629_PS_ITB_2 (2 << 6)
92#define CM3629_PS_ITB_4 (3 << 6)
93
94#define CM3629_PS_ITR_1 (0 << 4)
95#define CM3629_PS_ITR_1_2 (1 << 4)
96#define CM3629_PS_ITR_1_4 (2 << 4)
97#define CM3629_PS_ITR_1_8 (3 << 4)
98
99#define CM3629_PS2_INT_DIS (0 << 2)
100#define CM3629_PS2_INT_CLS (1 << 2)
101#define CM3629_PS2_INT_AWY (2 << 2)
102#define CM3629_PS2_INT_BOTH (3 << 2)
103
104#define CM3629_PS1_INT_DIS (0 << 0)
105#define CM3629_PS1_INT_CLS (1 << 0)
106#define CM3629_PS1_INT_AWY (2 << 0)
107#define CM3629_PS1_INT_BOTH (3 << 0)
108
109
110#define CM3629_PS2_PROL_4 (0 << 6)
111#define CM3629_PS2_PROL_8 (1 << 6)
112#define CM3629_PS2_PROL_16 (2 << 6)
113#define CM3629_PS2_PROL_32 (3 << 6)
114
115#define CM3629_PS_INTT (1 << 5)
116#define CM3629_PS_SMART_PRES (1 << 4)
117#define CM3629_PS_PS_FOR (1 << 3)
118#define CM3629_PS_PS_TRIG (1 << 2)
119
120#define CM3629_PS2_PERS_1 (0 << 0)
121#define CM3629_PS2_PERS_2 (1 << 0)
122#define CM3629_PS2_PERS_3 (2 << 0)
123#define CM3629_PS2_PERS_4 (3 << 0)
124
125#define CM3629_PS_MS (1 << 5)
126
127#define CM3629_PS2_SPFLAG (1 << 7)
128#define CM3629_PS1_SPFLAG (1 << 6)
129
130#define CM3629_ALS_IF_L (1 << 5)
131#define CM3629_ALS_IF_H (1 << 4)
132#define CM3629_PS2_IF_CLOSE (1 << 3)
133#define CM3629_PS2_IF_AWAY (1 << 2)
134#define CM3629_PS1_IF_CLOSE (1 << 1)
135#define CM3629_PS1_IF_AWAY (1 << 0)
136
Flemmard84cecde2014-01-07 12:01:50 -0800137
Flemmarde2ce3b72013-04-25 21:59:45 -0700138extern unsigned int ps_kparam1;
139extern unsigned int ps_kparam2;
140extern unsigned int als_kadc;
Flemmard84cecde2014-01-07 12:01:50 -0800141extern unsigned int ws_kadc;
Flemmarde2ce3b72013-04-25 21:59:45 -0700142enum {
143 CAPELLA_CM36282,
144 CAPELLA_CM36292,
145};
146
147enum {
148 CM3629_PS_DISABLE,
149 CM3629_PS1_ONLY,
150 CM3629_PS2_ONLY,
151 CM3629_PS1_PS2_BOTH,
152};
Flemmard84cecde2014-01-07 12:01:50 -0800153int get_lightsensoradc(void);
154int get_lightsensorkadc(void);
Flemmarde2ce3b72013-04-25 21:59:45 -0700155
156struct cm3629_platform_data {
157 int model;
158 int intr;
159 uint16_t levels[10];
Flemmard84cecde2014-01-07 12:01:50 -0800160 uint16_t correction[10];
Flemmarde2ce3b72013-04-25 21:59:45 -0700161 uint16_t golden_adc;
162 int (*power)(int, uint8_t);
163 int (*lpm_power)(uint8_t);
164 uint16_t cm3629_slave_address;
165 uint8_t ps_select;
166 uint8_t ps1_thd_set;
167 uint8_t ps1_thh_diff;
168 uint8_t ps2_thd_set;
169 uint8_t inte_cancel_set;
170
171 uint8_t ps_conf2_val;
172 uint8_t *mapping_table;
173 uint8_t mapping_size;
174 uint8_t ps_base_index;
Flemmarde2ce3b72013-04-25 21:59:45 -0700175 uint8_t ps_calibration_rule;
176 uint8_t ps_conf1_val;
177 uint8_t ps_conf3_val;
Flemmard84cecde2014-01-07 12:01:50 -0800178 uint8_t dynamical_threshold;
Flemmarde2ce3b72013-04-25 21:59:45 -0700179 uint8_t ps1_thd_no_cal;
180 uint8_t ps1_thd_with_cal;
181 uint8_t ps2_thd_no_cal;
182 uint8_t ps2_thd_with_cal;
Flemmard84cecde2014-01-07 12:01:50 -0800183 uint8_t ps_th_add;
Flemmarde2ce3b72013-04-25 21:59:45 -0700184 uint8_t ls_cmd;
185 uint8_t ps1_adc_offset;
186 uint8_t ps2_adc_offset;
187 uint8_t ps_debounce;
188 uint16_t ps_delay_time;
189 unsigned int no_need_change_setting;
190 uint8_t dark_level;
Flemmard84cecde2014-01-07 12:01:50 -0800191 uint16_t w_golden_adc;
Flemmarde2ce3b72013-04-25 21:59:45 -0700192};
193
Flemmarde2ce3b72013-04-25 21:59:45 -0700194#endif