Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0-jb
[firefly-linux-kernel-4.4.55.git] / include / linux / kxtf9.h
1 /* include/linux/kxtf9.h - KXTF9 accelerometer driver\r
2  *\r
3  * Copyright (C) 2010 Kionix, Inc.\r
4  * Written by Kuching Tan <kuchingtan@kionix.com>\r
5  *\r
6  * This program is free software: you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation, either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * This program is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
18  *\r
19  */\r
20 \r
21 #ifndef __KXTF9_H__\r
22 #define __KXTF9_H__\r
23 \r
24 #define KXTF9_I2C_ADDR  0x0F\r
25 /* CTRL_REG1 BITS */\r
26 #define RES_12BIT               0x40\r
27 #define KXTF9_G_2G              0x00\r
28 #define KXTF9_G_4G              0x08\r
29 #define KXTF9_G_8G              0x10\r
30 #define SHIFT_ADJ_2G    4\r
31 #define SHIFT_ADJ_4G    3\r
32 #define SHIFT_ADJ_8G    2\r
33 #define TPE                             0x01    /* tilt position function enable bit */\r
34 #define WUFE                    0x02    /* wake-up function enable bit */\r
35 #define TDTE                    0x04    /* tap/double-tap function enable bit */\r
36 /* CTRL_REG3 BITS */\r
37 #define SRST                    0x80    /* software reset */\r
38 #define DCST                    0x10    /* communication-test function */\r
39 #define OTP1_6                  0x00    /* tilt ODR masks */\r
40 #define OTP6_3                  0x20\r
41 #define OTP12_5                 0x40\r
42 #define OTP50                   0x60\r
43 #define OWUF25                  0x00    /* wuf ODR masks */\r
44 #define OWUF50                  0x01\r
45 #define OWUF100                 0x02\r
46 #define OWUF200                 0x03\r
47 #define OTDT50                  0x00    /* tdt ODR masks */\r
48 #define OTDT100                 0x04\r
49 #define OTDT200                 0x08\r
50 #define OTDT400                 0x0C\r
51 /* INT_CTRL_REG1 BITS */\r
52 #define KXTF9_IEN               0x20    /* interrupt enable */\r
53 #define KXTF9_IEA               0x10    /* interrupt polarity */\r
54 #define KXTF9_IEL               0x08    /* interrupt response */\r
55 #define IEU                             0x04    /* alternate unlatched response */\r
56 /* DATA_CTRL_REG BITS */\r
57 #define ODR800F                 0x06    /* lpf output ODR masks */\r
58 #define ODR400F                 0x05\r
59 #define ODR200F                 0x04\r
60 #define ODR100F                 0x03\r
61 #define ODR50F                  0x02\r
62 #define ODR25F                  0x01\r
63 \r
64 /* Device Meta Data */\r
65 #define DESC_DEV                "KXTF9 3-axis Accelerometer"    // Device Description\r
66 #define VERSION_DEV             "1.1.8"\r
67 #define VER_MAJOR_DEV   1\r
68 #define VER_MINOR_DEV   1\r
69 #define VER_MAINT_DEV   8\r
70 #define MAX_G_DEV               (8.0f)          // Maximum G Level\r
71 #define MAX_SENS_DEV    (1024.0f)       // Maximum Sensitivity\r
72 #define PWR_DEV                 (0.57f)         // Typical Current\r
73 \r
74 /* Input Device Name */\r
75 #define INPUT_NAME_ACC  "kxtf9_accel"\r
76 \r
77 /* Device name for kxtf9 misc. device */\r
78 #define NAME_DEV        "kxtf9"\r
79 #define DIR_DEV         "/dev/kxtf9"\r
80 \r
81 /* IOCTLs for kxtf9 misc. device library */\r
82 #define KXTF9IO                                                                 0x94\r
83 #define KXTF9_IOCTL_GET_COUNT                   _IOR(KXTF9IO, 0x01, int)\r
84 #define KXTF9_IOCTL_GET_MG                              _IOR(KXTF9IO, 0x02, int)\r
85 #define KXTF9_IOCTL_ENABLE_OUTPUT                _IO(KXTF9IO, 0x03)\r
86 #define KXTF9_IOCTL_DISABLE_OUTPUT               _IO(KXTF9IO, 0x04)\r
87 #define KXTF9_IOCTL_GET_ENABLE                  _IOR(KXTF9IO, 0x05, int)\r
88 #define KXTF9_IOCTL_RESET                                _IO(KXTF9IO, 0x06)\r
89 #define KXTF9_IOCTL_UPDATE_ODR                  _IOW(KXTF9IO, 0x07, int)\r
90 #define KXTF9_IOCTL_ENABLE_DCST                  _IO(KXTF9IO, 0x08)\r
91 #define KXTF9_IOCTL_DISABLE_DCST                 _IO(KXTF9IO, 0x09)\r
92 #define KXTF9_IOCTL_GET_DCST_RESP               _IOR(KXTF9IO, 0x0A, int)\r
93 \r
94 \r
95 #ifdef __KERNEL__\r
96 struct kxtf9_platform_data {\r
97         int poll_interval;\r
98         int min_interval;\r
99 \r
100         u8 g_range;\r
101         u8 shift_adj;\r
102         u8 mul_fac;\r
103 \r
104         u8 axis_map_x;\r
105         u8 axis_map_y;\r
106         u8 axis_map_z;\r
107 \r
108         u8 negate_x;\r
109         u8 negate_y;\r
110         u8 negate_z;\r
111 \r
112         u8 data_odr_init;\r
113         u8 ctrl_reg1_init;\r
114         u8 int_ctrl_init;\r
115         u8 tilt_timer_init;\r
116         u8 engine_odr_init;\r
117         u8 wuf_timer_init;\r
118         u8 wuf_thresh_init;\r
119         u8 tdt_timer_init;\r
120         u8 tdt_h_thresh_init;\r
121         u8 tdt_l_thresh_init;\r
122         u8 tdt_tap_timer_init;\r
123         u8 tdt_total_timer_init;\r
124         u8 tdt_latency_timer_init;\r
125         u8 tdt_window_timer_init;\r
126 \r
127         int (*init)(void);\r
128         void (*exit)(void);\r
129         int (*power_on)(void);\r
130         int (*power_off)(void);\r
131 \r
132         int gpio;\r
133 };\r
134 #endif /* __KERNEL__ */\r
135 \r
136 #endif  /* __KXTF9_H__ */\r
137 \r