Merge branch 'android-tegra' into android-tegra-moto
[firefly-linux-kernel-4.4.55.git] / include / linux / kxtf9.h
1 /*
2  * Copyright (c) 2008-2009, Kionix, Inc. All Rights Reserved.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
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  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18
19 #ifndef __KXTF9_H__
20 #define __KXTF9_H__
21
22 #include <linux/ioctl.h>  /* For IOCTL macros */
23
24 /** This define controls compilation of the master device interface */
25 /*#define KXTF9_MASTER_DEVICE*/
26
27 #define KXTF9_IOCTL_BASE 77
28 /** The following define the IOCTL command values via the ioctl macros */
29 #define KXTF9_IOCTL_SET_DELAY           _IOW(KXTF9_IOCTL_BASE, 0, int)
30 #define KXTF9_IOCTL_GET_DELAY           _IOR(KXTF9_IOCTL_BASE, 1, int)
31 #define KXTF9_IOCTL_SET_ENABLE          _IOW(KXTF9_IOCTL_BASE, 2, int)
32 #define KXTF9_IOCTL_GET_ENABLE          _IOR(KXTF9_IOCTL_BASE, 3, int)
33 #define KXTF9_IOCTL_SET_G_RANGE         _IOW(KXTF9_IOCTL_BASE, 4, int)
34
35 #define KXTF9_IOCTL_SET_TILT_ENABLE     _IOW(KXTF9_IOCTL_BASE, 5, int)
36 #define KXTF9_IOCTL_SET_TAP_ENABLE      _IOW(KXTF9_IOCTL_BASE, 6, int)
37 #define KXTF9_IOCTL_SET_WAKE_ENABLE     _IOW(KXTF9_IOCTL_BASE, 7, int)
38 #define KXTF9_IOCTL_SET_PM_MODE         _IOW(KXTF9_IOCTL_BASE, 8, int)
39 #define KXTF9_IOCTL_SELF_TEST           _IOW(KXTF9_IOCTL_BASE, 9, int)
40 #define KXTF9_IOCTL_SET_SENSITIVITY     _IOW(KXTF9_IOCTL_BASE, 10, int)
41
42 /* CONTROL REGISTER 1 BITS */
43 #define RES_12BIT               0x40
44 #define KXTF9_G_2G              0x00
45 #define KXTF9_G_4G              0x08
46 #define KXTF9_G_8G              0x10
47 #define TPE                     0x01    /* tilt position function enable bit */
48 #define WUFE                    0x02    /* wake-up function enable bit */
49 #define TDTE                    0x04    /* tap/double-tap function enable bit */
50 /* CONTROL REGISTER 3 BITS */
51 #define OTP1_6                  0x00    /* tilt ODR masks */
52 #define OTP6_3                  0x20
53 #define OTP12_5                 0x40
54 #define OTP50                   0x60
55 #define OWUF25                  0x00    /* wuf ODR masks */
56 #define OWUF50                  0x01
57 #define OWUF100                 0x02
58 #define OWUF200                 0x03
59 #define OTDT50                  0x00    /* tdt ODR masks */
60 #define OTDT100                 0x04
61 #define OTDT200                 0x08
62 #define OTDT400                 0x0C
63 /* INTERRUPT CONTROL REGISTER 1 BITS */
64 #define IEN                     0x20    /* interrupt enable */
65 #define IEA                     0x10    /* interrupt polarity */
66 #define IEL                     0x08    /* interrupt response */
67 #define IEU                     0x04    /* alternate unlatched response */
68 /* DATA CONTROL REGISTER BITS */
69 #define ODR800                  0x06    /* lpf output ODR masks */
70 #define ODR400                  0x05
71 #define ODR200                  0x04
72 #define ODR100                  0x03
73 #define ODR50                   0x02
74 #define ODR25                   0x01
75
76 #define SENSITIVITY_REGS 0x07
77
78 #ifdef __KERNEL__
79 struct kxtf9_platform_data {
80         int poll_interval;
81         int min_interval;
82
83         u8 g_range;
84
85         u8 axis_map_x;
86         u8 axis_map_y;
87         u8 axis_map_z;
88
89         u8 negate_x;
90         u8 negate_y;
91         u8 negate_z;
92
93         u8 data_odr_init;
94         u8 ctrl_reg1_init;
95         u8 int_ctrl_init;
96         u8 tilt_timer_init;
97         u8 engine_odr_init;
98         u8 wuf_timer_init;
99         u8 wuf_thresh_init;
100         u8 tdt_timer_init;
101         u8 tdt_h_thresh_init;
102         u8 tdt_l_thresh_init;
103         u8 tdt_tap_timer_init;
104         u8 tdt_total_timer_init;
105         u8 tdt_latency_timer_init;
106         u8 tdt_window_timer_init;
107
108         int (*gpio)(void);
109
110         u8 gesture;
111         u8 sensitivity_low[SENSITIVITY_REGS];
112         u8 sensitivity_medium[SENSITIVITY_REGS];
113         u8 sensitivity_high[SENSITIVITY_REGS];
114 };
115
116 #endif /* __KERNEL__ */
117
118 #endif  /* __KXTF9_H__ */
119