1 /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
3 * File Name : l3g4200d.c
4 * Authors : MH - C&I BU - Application Team
5 * : Carmine Iascone (carmine.iascone@st.com)
6 * : Matteo Dameno (matteo.dameno@st.com)
9 * Description : L3G4200D digital output gyroscope sensor API
11 ********************************************************************************
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
17 * THE PRESENT SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
18 * OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, FOR THE SOLE
19 * PURPOSE TO SUPPORT YOUR APPLICATION DEVELOPMENT.
20 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
21 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
22 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
23 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
25 * THIS SOFTWARE IS SPECIFICALLY DESIGNED FOR EXCLUSIVE USE WITH ST PARTS.
27 ********************************************************************************
30 * VERSION | DATE | AUTHORS | DESCRIPTION
32 * 0.1 | 29/01/2010 | Carmine Iascone | First Release
34 * 0.2 | 09/04/2010 | Carmine Iascone | Updated the struct l3g4200d_t
36 *******************************************************************************/
38 #ifndef __L3G4200D_H__
39 #define __L3G4200D_H__
41 #include <linux/ioctl.h> /* For IOCTL macros */
43 /** This define controls compilation of the master device interface */
44 /*#define L3G4200D_MASTER_DEVICE*/
46 #define L3G4200D_IOCTL_BASE 77
48 #define L3G4200D_IOCTL_SET_DELAY _IOW(L3G4200D_IOCTL_BASE, 0, int)
49 #define L3G4200D_IOCTL_GET_DELAY _IOR(L3G4200D_IOCTL_BASE, 1, int)
50 #define L3G4200D_IOCTL_SET_ENABLE _IOW(L3G4200D_IOCTL_BASE, 2, int)
51 #define L3G4200D_IOCTL_GET_ENABLE _IOR(L3G4200D_IOCTL_BASE, 3, int)
54 #define L3G4200D_FS_250DPS 0x00
55 #define L3G4200D_FS_500DPS 0x10
56 #define L3G4200D_FS_2000DPS 0x30
59 #define PM_NORMAL 0x08
60 #define ENABLE_ALL_AXES 0x07
63 #define L3G4200D_SUSPEND 2
64 #define L3G4200D_OPEN 1
65 #define L3G4200D_CLOSE 0
67 #define ODR100_BW12_5 0x00 /* ODR = 100Hz; BW = 12.5Hz */
68 #define ODR100_BW25 0x10 /* ODR = 100Hz; BW = 25Hz */
69 #define ODR200_BW12_5 0x40 /* ODR = 200Hz; BW = 12.5Hz */
70 #define ODR200_BW25 0x50 /* ODR = 200Hz; BW = 25Hz */
71 #define ODR200_BW50 0x60 /* ODR = 200Hz; BW = 50Hz */
72 #define ODR400_BW25 0x90 /* ODR = 400Hz; BW = 25Hz */
73 #define ODR400_BW50 0xA0 /* ODR = 400Hz; BW = 50Hz */
74 #define ODR400_BW110 0xB0 /* ODR = 400Hz; BW = 110Hz */
75 #define ODR800_BW50 0xE0 /* ODR = 800Hz; BW = 50Hz */
76 #define ODR800_BW100 0xF0 /* ODR = 800Hz; BW = 100Hz */
78 #define L3G4200D_REG_WHO_AM_I 0x0f
79 #define L3G4200D_REG_CTRL_REG1 0x20
80 #define ACTIVE_MASK 0x08
83 struct l3g4200d_platform_data {
93 signed char orientation[9];
97 int (*power_on)(void);
98 int (*power_off)(void);
102 #endif /* __KERNEL__ */
106 /* IOCTLs for MMA8452 library */
107 #define ECS_IOCTL_INIT _IO(MMAIO, 0x01)
108 #define ECS_IOCTL_RESET _IO(MMAIO, 0x04)
109 #define ECS_IOCTL_CLOSE _IO(MMAIO, 0x02)
110 #define ECS_IOCTL_START _IO(MMAIO, 0x03)
111 #define ECS_IOCTL_GETDATA _IOR(MMAIO, 0x08, char[RBUFF_SIZE+1])
113 #define GYROSENSOR_IOCTL_MAGIC 'l'
114 #define GYROSENSOR_IOCTL_GET_ENABLED _IOR(GYROSENSOR_IOCTL_MAGIC, 1, int *)
115 #define GYROSENSOR_IOCTL_ENABLE _IOW(GYROSENSOR_IOCTL_MAGIC, 2, int *)
117 /* IOCTLs for APPs */
118 #define ECS_IOCTL_APP_SET_RATE _IOW(MMAIO, 0x10, char)
120 #define EVENT_TYPE_GYRO_X ABS_RY
121 #define ECS_IOCTL_APP_GET_ABS EVIOCGABS(EVENT_TYPE_GYRO_X)
124 struct l3g4200d_data {
127 struct input_dev *input_dev;
128 struct i2c_client *client;
129 struct work_struct work;
130 struct delayed_work delaywork; /*report second event*/
131 struct l3g4200d_platform_data *pdata;
134 struct l3g4200d_axis {
140 #define GSENSOR_DEV_PATH "/dev/gyrosensors"
143 #endif /* __L3G4200D_H__ */