ARM64: config: enable DRM relevant config
[firefly-linux-kernel-4.4.55.git] / include / linux / mc3230.h
1 /*
2  *  MCube mc3230 acceleration sensor driver
3  *
4  *  Copyright (C) 2011 MCube Inc.,
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  * *****************************************************************************/
17
18 #ifndef MC3230_H
19 #define MC3230_H
20
21 #include <linux/ioctl.h>
22
23 #define MC3230_REG_CHIP_ID              0x18
24 #define MC3230_REG_X_OUT                        0x0 //RO
25 #define MC3230_REG_Y_OUT                        0x1 //RO
26 #define MC3230_REG_Z_OUT                        0x2 //RO
27 #define MC3230_REG_STAT                         0x04
28 #define MC3230_REG_SLEEP_COUNTER 0x05
29 #define MC3230_REG_INTMOD                       0x06
30 #define MC3230_REG_SYSMOD                       0x07
31 #define MC3230_REG_RATE_SAMP            0x08
32
33 #define MC32X0_XOUT_EX_L_REG                            0x0d
34
35 #define MC3230_REG_RBM_DATA             0x0D
36 #define MC3230_REG_PRODUCT_CODE 0x3b
37
38
39
40
41
42 #define MCIO                            0xA1
43
44 #define RBUFF_SIZE              12      /* Rx buffer size */
45 /* IOCTLs for MC3230 library */
46 #define MC_IOCTL_INIT                  _IO(MCIO, 0x01)
47 #define MC_IOCTL_RESET                    _IO(MCIO, 0x04)
48 #define MC_IOCTL_CLOSE                     _IO(MCIO, 0x02)
49 #define MC_IOCTL_START                       _IO(MCIO, 0x03)
50 #define MC_IOCTL_GETDATA               _IOR(MCIO, 0x08, char[RBUFF_SIZE+1])
51
52 /* IOCTLs for APPs */
53 #define MC_IOCTL_APP_SET_RATE           _IOW(MCIO, 0x10, char)
54
55 #if 0
56 /*wake mode rate Samples/Second (0~2)*/
57 #define MC3230_RATE_128          0
58 #define MC3230_RATE_64          1
59 #define MC3230_RATE_32         2
60 #define MC3230_RATE_16         3
61 #define MC3230_RATE_8             4
62 #define MC3230_RATE_4         5
63 #define MC3230_RATE_2         6
64 #define MC3230_RATE_1         7
65 #endif
66
67 /*sniffr mode rate Samples/Second (3~4)*/
68 #define MC3230_SNIFFR_RATE_32           0
69 #define MC3230_SNIFFR_RATE_16           1
70 #define MC3230_SNIFFR_RATE_8            2
71 #define MC3230_SNIFFR_RATE_1            3
72 #define MC3230_SNIFFR_RATE_SHIFT        3
73
74 //#define ACTIVE_MASK                           1
75 //#define FREAD_MASK                            2
76
77
78 /*status*/
79 #define MC3230_OPEN           1
80 #define MC3230_CLOSE          0
81
82 #define MC3230_RANGE            1500000
83 #define MC3230_IIC_ADDR           0x4c 
84 #define MC3230_PRECISION       8 //8bit data
85 #define MC3230_BOUNDARY        (0x1 << (MC3230_PRECISION - 1))
86 #define MC3230_GRAVITY_STEP   MC3230_RANGE/MC3230_BOUNDARY //110 //2g full scale range
87
88
89 struct mc3230_axis {
90         int x;
91         int y;
92         int z;
93 };
94
95 //#define  GSENSOR_DEV_PATH    "/dev/mma8452_daemon"
96
97
98
99 //add accel calibrate IO
100 typedef struct {
101         unsigned short  x;              /**< X axis */
102         unsigned short  y;              /**< Y axis */
103         unsigned short  z;              /**< Z axis */
104 } GSENSOR_VECTOR3D;
105
106 typedef struct{
107         int x;
108         int y;
109         int z;
110 }SENSOR_DATA;
111 //=========================================add by guanj============================
112 struct mc3230_platform_data {
113         u16     model;
114         u16     swap_xy;
115         u16     swap_xyz;
116         signed char orientation[9];
117         int     (*get_pendown_state)(void);
118         int     (*init_platform_hw)(void);
119         int     (*mc3230_platform_sleep)(void);
120         int     (*mc3230_platform_wakeup)(void);
121         void    (*exit_platform_hw)(void);
122 };
123
124 #define GSENSOR                                                 0x85
125 //#define GSENSOR_IOCTL_INIT                  _IO(GSENSOR,  0x01)
126 #define GSENSOR_IOCTL_READ_CHIPINFO         _IOR(GSENSOR, 0x02, int)
127 #define GSENSOR_IOCTL_READ_SENSORDATA       _IOR(GSENSOR, 0x03, int)
128 #define GSENSOR_IOCTL_READ_OFFSET                       _IOR(GSENSOR, 0x04, GSENSOR_VECTOR3D)
129 #define GSENSOR_IOCTL_READ_GAIN                         _IOR(GSENSOR, 0x05, GSENSOR_VECTOR3D)
130 #define GSENSOR_IOCTL_READ_RAW_DATA                     _IOR(GSENSOR, 0x06, int)
131 #define GSENSOR_IOCTL_SET_CALI                          _IOW(GSENSOR, 0x06, SENSOR_DATA)
132 #define GSENSOR_IOCTL_GET_CALI                          _IOW(GSENSOR, 0x07, SENSOR_DATA)
133 #define GSENSOR_IOCTL_CLR_CALI                          _IO(GSENSOR, 0x08)
134 #define GSENSOR_MCUBE_IOCTL_READ_RBM_DATA               _IOR(GSENSOR, 0x09, SENSOR_DATA)
135 #define GSENSOR_MCUBE_IOCTL_SET_RBM_MODE                _IO(GSENSOR, 0x0a)
136 #define GSENSOR_MCUBE_IOCTL_CLEAR_RBM_MODE              _IO(GSENSOR, 0x0b)
137 #define GSENSOR_MCUBE_IOCTL_SET_CALI                    _IOW(GSENSOR, 0x0c, SENSOR_DATA)
138 #define GSENSOR_MCUBE_IOCTL_REGISTER_MAP                _IO(GSENSOR, 0x0d)
139 #define GSENSOR_IOCTL_SET_CALI_MODE                     _IOW(GSENSOR, 0x0e,int)
140
141
142
143
144 /* IOCTLs for Msensor misc. device library */
145 #define MSENSOR                                            0x83
146 #define MSENSOR_IOCTL_INIT                                      _IO(MSENSOR, 0x01)
147 #define MSENSOR_IOCTL_READ_CHIPINFO                     _IOR(MSENSOR, 0x02, int)
148 #define MSENSOR_IOCTL_READ_SENSORDATA           _IOR(MSENSOR, 0x03, int)
149 #define MSENSOR_IOCTL_READ_POSTUREDATA          _IOR(MSENSOR, 0x04, int)
150 #define MSENSOR_IOCTL_READ_CALIDATA                     _IOR(MSENSOR, 0x05, int)
151 #define MSENSOR_IOCTL_READ_CONTROL                      _IOR(MSENSOR, 0x06, int)
152 #define MSENSOR_IOCTL_SET_CONTROL                       _IOW(MSENSOR, 0x07, int)
153 #define MSENSOR_IOCTL_SET_MODE                  _IOW(MSENSOR, 0x08, int)
154 #define MSENSOR_IOCTL_SET_POSTURE               _IOW(MSENSOR, 0x09, int)
155 #define MSENSOR_IOCTL_SET_CALIDATA              _IOW(MSENSOR, 0x0a, int)
156 #define MSENSOR_IOCTL_SENSOR_ENABLE         _IOW(MSENSOR, 0x51, int)
157 #define MSENSOR_IOCTL_READ_FACTORY_SENSORDATA  _IOW(MSENSOR, 0x52, int)
158
159
160 #if 0
161 /* IOCTLs for AKM library */
162 #define ECS_IOCTL_WRITE                 _IOW(MSENSOR, 0x0b, char*)
163 #define ECS_IOCTL_READ                  _IOWR(MSENSOR, 0x0c, char*)
164 #define ECS_IOCTL_RESET                 _IO(MSENSOR, 0x0d) /* NOT used in AK8975 */
165 #define ECS_IOCTL_SET_MODE              _IOW(MSENSOR, 0x0e, short)
166 #define ECS_IOCTL_GETDATA               _IOR(MSENSOR, 0x0f, char[SENSOR_DATA_SIZE])
167 #define ECS_IOCTL_SET_YPR               _IOW(MSENSOR, 0x10, short[12])
168 #define ECS_IOCTL_GET_OPEN_STATUS       _IOR(MSENSOR, 0x11, int)
169 #define ECS_IOCTL_GET_CLOSE_STATUS      _IOR(MSENSOR, 0x12, int)
170 #define ECS_IOCTL_GET_OSENSOR_STATUS    _IOR(MSENSOR, 0x13, int)
171 #define ECS_IOCTL_GET_DELAY             _IOR(MSENSOR, 0x14, short)
172 #define ECS_IOCTL_GET_PROJECT_NAME      _IOR(MSENSOR, 0x15, char[64])
173 #define ECS_IOCTL_GET_MATRIX            _IOR(MSENSOR, 0x16, short [4][3][3])
174 #define ECS_IOCTL_GET_LAYOUT                    _IOR(MSENSOR, 0x17, int[3])
175 #endif
176 #define ECS_IOCTL_GET_OUTBIT            _IOR(MSENSOR, 0x23, char)
177 #define ECS_IOCTL_GET_ACCEL             _IOR(MSENSOR, 0x24, short[3])
178 #define MMC31XX_IOC_RM                                  _IO(MSENSOR, 0x25)
179 #define MMC31XX_IOC_RRM                                 _IO(MSENSOR, 0x26)
180
181
182
183 /* IOCTLs for MMC31XX device */
184 #define MMC31XX_IOC_TM                                  _IO(MSENSOR, 0x18)
185 #define MMC31XX_IOC_SET                                 _IO(MSENSOR, 0x19)
186 #define MMC31XX_IOC_RESET                               _IO(MSENSOR, 0x1a)
187 #define MMC31XX_IOC_READ                                _IOR(MSENSOR, 0x1b, int[3])
188 #define MMC31XX_IOC_READXYZ                             _IOR(MSENSOR, 0x1c, int[3])
189
190 #define ECOMPASS_IOC_GET_DELAY                  _IOR(MSENSOR, 0x1d, int)
191 #define ECOMPASS_IOC_GET_MFLAG                  _IOR(MSENSOR, 0x1e, short)
192 #define ECOMPASS_IOC_GET_OFLAG                  _IOR(MSENSOR, 0x1f, short)
193 #define ECOMPASS_IOC_GET_OPEN_STATUS    _IOR(MSENSOR, 0x20, int)
194 #define ECOMPASS_IOC_SET_YPR                    _IOW(MSENSOR, 0x21, int[12])
195 #define ECOMPASS_IOC_GET_LAYOUT                 _IOR(MSENSOR, 0X22, int)
196
197
198
199
200 #define ALSPS                                                   0X84
201 #define ALSPS_SET_PS_MODE                                       _IOW(ALSPS, 0x01, int)
202 #define ALSPS_GET_PS_MODE                                       _IOR(ALSPS, 0x02, int)
203 #define ALSPS_GET_PS_DATA                                       _IOR(ALSPS, 0x03, int)
204 #define ALSPS_GET_PS_RAW_DATA                           _IOR(ALSPS, 0x04, int)
205 #define ALSPS_SET_ALS_MODE                                      _IOW(ALSPS, 0x05, int)
206 #define ALSPS_GET_ALS_MODE                                      _IOR(ALSPS, 0x06, int)
207 #define ALSPS_GET_ALS_DATA                                      _IOR(ALSPS, 0x07, int)
208 #define ALSPS_GET_ALS_RAW_DATA                  _IOR(ALSPS, 0x08, int)
209
210 #define GYROSCOPE                                                       0X86
211 #define GYROSCOPE_IOCTL_INIT                                    _IO(GYROSCOPE, 0x01)
212 #define GYROSCOPE_IOCTL_SMT_DATA                        _IOR(GYROSCOPE, 0x02, int)
213 #define GYROSCOPE_IOCTL_READ_SENSORDATA         _IOR(GYROSCOPE, 0x03, int)
214 #define GYROSCOPE_IOCTL_SET_CALI                        _IOW(GYROSCOPE, 0x04, SENSOR_DATA)
215 #define GYROSCOPE_IOCTL_GET_CALI                        _IOW(GYROSCOPE, 0x05, SENSOR_DATA)
216 #define GYROSCOPE_IOCTL_CLR_CALI                        _IO(GYROSCOPE, 0x06)
217
218 #define BROMETER                                                        0X87
219 #define BAROMETER_IOCTL_INIT                            _IO(BROMETER, 0x01)
220 #define BAROMETER_GET_PRESS_DATA                        _IOR(BROMETER, 0x02, int)
221 #define BAROMETER_GET_TEMP_DATA                     _IOR(BROMETER, 0x03, int)
222 #define BAROMETER_IOCTL_READ_CHIPINFO           _IOR(BROMETER, 0x04, int)
223
224 extern long mc3230_ioctl( struct file *file, unsigned int cmd,unsigned long arg,struct i2c_client *client);
225 #endif
226