• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define ODR12_5			0x00
76 
77 #define SENSITIVITY_REGS 0x07
78 
79 #ifdef __KERNEL__
80 struct kxtf9_platform_data {
81 	int poll_interval;
82 	int min_interval;
83 
84 	u8 g_range;
85 
86 	u8 axis_map_x;
87 	u8 axis_map_y;
88 	u8 axis_map_z;
89 
90 	u8 negate_x;
91 	u8 negate_y;
92 	u8 negate_z;
93 
94 	u8 data_odr_init;
95 	u8 ctrl_reg1_init;
96 	u8 int_ctrl_init;
97 	u8 tilt_timer_init;
98 	u8 engine_odr_init;
99 	u8 wuf_timer_init;
100 	u8 wuf_thresh_init;
101 	u8 tdt_timer_init;
102 	u8 tdt_h_thresh_init;
103 	u8 tdt_l_thresh_init;
104 	u8 tdt_tap_timer_init;
105 	u8 tdt_total_timer_init;
106 	u8 tdt_latency_timer_init;
107 	u8 tdt_window_timer_init;
108 
109 	int (*init)(void);
110 	void (*exit)(void);
111 	int (*power_on)(void);
112 	int (*power_off)(void);
113 
114 	int (*gpio)(void);
115 
116 	u8 gesture;
117 	u8 sensitivity_low[SENSITIVITY_REGS];
118 	u8 sensitivity_medium[SENSITIVITY_REGS];
119 	u8 sensitivity_high[SENSITIVITY_REGS];
120 };
121 
122 #endif /* __KERNEL__ */
123 
124 #endif  /* __KXTF9_H__ */
125 
126