Flemmard | b00bee2 | 2013-04-25 22:02:31 -0700 | [diff] [blame] | 1 | /* include/linux/ewtzmu2.h - EWTZMU compass driver |
| 2 | * |
| 3 | * Copyright (C) 2011 Prolific Technology Inc. |
| 4 | * Author: Kyle Chen |
| 5 | * |
| 6 | * This software is licensed under the terms of the GNU General Public |
| 7 | * License version 2, as published by the Free Software Foundation, and |
| 8 | * may be copied, distributed, and modified under those terms. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef EWTZMU2_H |
| 18 | #define EWTZMU2_H |
| 19 | |
| 20 | #include <linux/ioctl.h> |
| 21 | |
| 22 | #define EWTZMU_I2C_ADDRESS 0x69 |
| 23 | #define EWTZMU_REG_GYROX_H 0xFB |
| 24 | |
| 25 | #define EWTZMU_REG_PWR_MGM 0x3E |
| 26 | #define EWTZMU_SLEP 0x00 |
| 27 | #define EWTZMU_POWERON 0x40 |
| 28 | |
| 29 | #define EWTZMU_INT 0x17 |
| 30 | #define EWTZMU_WTMON 0x08 |
| 31 | |
| 32 | #define EWTZMU_DLPF 0x16 |
| 33 | #define EWTZMU_2000ds_1khz 0x1A |
| 34 | #define EWTZMU_HPF 0x80 |
| 35 | |
| 36 | #define EWTZMU_SMPL 0x15 |
| 37 | #define EWTZMU_100hz 0x09 |
| 38 | |
| 39 | #define EWTZMU_FIFO_CTR 0x14 |
| 40 | #define EWTZMU_stream 0x40 |
| 41 | #define EWTZMU_SAMPLE_100HZ 0x00 |
| 42 | #define EWTZMU_SAMPLE_50HZ 0x01 |
| 43 | #define EWTZMU_SAMPLE_20HZ 0x04 |
| 44 | #define EWTZMU_SAMPLE_16HZ 0x05 |
| 45 | #define EWTZMU_SAMPLE_5HZ 0x13 |
| 46 | |
| 47 | #define EWTZMU_FIFO_STS 0x13 |
| 48 | #define EWTZMU_PNT_H 0x02 |
| 49 | #define EWTZMU_PNT_L 0x00 |
| 50 | |
| 51 | #define EWIO 0x83 |
| 52 | #define EW_IOCTL_SET_INIT _IO(EWIO, 0x01) |
| 53 | #define EW_IOCTL_SET_STANDBY _IO(EWIO, 0x02) |
| 54 | #define EW_IOCTL_READ_CHIPINFO _IOR(EWIO, 0x03, int) |
| 55 | #define EW_IOCTL_READ_SENSORDATA _IOR(EWIO, 0x04, int) |
| 56 | #define EW_IOCTL_READ_SENSORDATA_FIFO _IOR(EWIO, 0x05, int) |
| 57 | #define EW_IOCTL_READ_POSTUREDATA _IOR(EWIO, 0x06, int) |
| 58 | #define EW_IOCTL_WRITE_POSTUREDATA _IOW(EWIO, 0x07, int) |
| 59 | #define EW_IOCTL_READ_CALIDATA _IOR(EWIO, 0x08, int) |
| 60 | #define EW_IOCTL_WRITE_CALIDATA _IOW(EWIO, 0x09, int) |
| 61 | #define EW_IOCTL_READ_GYRODATA _IOR(EWIO, 0x0A, int) |
| 62 | #define EW_IOCTL_WRITE_GYRODATA _IOW(EWIO, 0x0B, int) |
| 63 | #define EW_IOCTL_READ_PEDODATA _IOR(EWIO, 0x0C, long) |
| 64 | #define EW_IOCTL_WRITE_PEDODATA _IOW(EWIO, 0x0D, long) |
| 65 | #define EW_IOCTL_READ_PEDOPARAM _IOR(EWIO, 0x0E, int) |
| 66 | #define EW_IOCTL_WRITE_PEDOPARAM _IOW(EWIO, 0x0F, int) |
| 67 | #define EW_IOCTL_READ_CONTROL _IOR(EWIO, 0x10, int) |
| 68 | #define EW_IOCTL_WRITE_CONTROL _IOW(EWIO, 0x11, int) |
| 69 | #define EW_IOCTL_WRITE_MODE _IOW(EWIO, 0x12, int) |
| 70 | #define EW_IOCTL_WRITE_REPORT _IO(EWIO, 0x13) |
| 71 | #define EW_IOCTL_READ_WIA _IOR(EWIO, 0x14, int) |
| 72 | #define EW_IOCTL_READ_AXISINTERFERENCE _IOR(EWIO, 0x15, int) |
| 73 | #define EW_IOCTL_GET_DIRPOLARITY _IOR(EWIO, 0x16, int) |
| 74 | #define EW_IOCTL_READ_ROTATION_VECTOR _IOR(EWIO, 0x17, int) |
| 75 | #define EW_IOCTL_WRITE_ROTATION_VECTOR _IOW(EWIO, 0x18, int) |
| 76 | #define EW_IOCTL_READ_LINEAR_ACCEL _IOR(EWIO, 0x19, int) |
| 77 | #define EW_IOCTL_WRITE_LINEAR_ACCEL _IOW(EWIO, 0x1A, int) |
| 78 | #define EW_IOCTL_READ_GRAVITY _IOR(EWIO, 0x1B, int) |
| 79 | #define EW_IOCTL_WRITE_GRAVITY _IOW(EWIO, 0x1C, int) |
| 80 | #define EW_IOCTL_SET_SAMPLERATE _IOW(EWIO, 0x1D, int) |
| 81 | |
| 82 | #define EW_IOCTL_WRITE_I2CDATA _IOW(EWIO, 0x1E, int) |
| 83 | #define EW_IOCTL_WRITE_I2CADDR _IOW(EWIO, 0x1F, int) |
| 84 | #define EW_IOCTL_READ_I2CDATA _IOR(EWIO, 0x20, int) |
| 85 | |
| 86 | #define EWDAEIO 0x84 |
| 87 | #define EWDAE_IOCTL_SET_INIT _IO(EWDAEIO, 0x01) |
| 88 | #define EWDAE_IOCTL_SET_STANDBY _IO(EWDAEIO, 0x02) |
| 89 | #define EWDAE_IOCTL_GET_SENSORDATA _IOR(EWDAEIO, 0x03, int) |
| 90 | #define EWDAE_IOCTL_GET_SENSORDATA_FIFO _IOR(EWDAEIO, 0x13, int) |
| 91 | #define EWDAE_IOCTL_SET_POSTURE _IOW(EWDAEIO, 0x04, int) |
| 92 | #define EWDAE_IOCTL_SET_CALIDATA _IOW(EWDAEIO, 0x05, int) |
| 93 | #define EWDAE_IOCTL_SET_GYRODATA _IOW(EWDAEIO, 0x06, int) |
| 94 | #define EWDAE_IOCTL_SET_PEDODATA _IOW(EWDAEIO, 0x07, long) |
| 95 | #define EWDAE_IOCTL_GET_PEDOPARAM _IOR(EWDAEIO, 0x08, int) |
| 96 | #define EWDAE_IOCTL_SET_PEDOPARAM _IOR(EWDAEIO, 0x09, int) |
| 97 | #define EWDAE_IOCTL_SET_CONTROL _IOW(EWDAEIO, 0x0A, int) |
| 98 | #define EWDAE_IOCTL_GET_CONTROL _IOR(EWDAEIO, 0x0B, int) |
| 99 | #define EWDAE_IOCTL_SET_MODE _IOW(EWDAEIO, 0x0C, int) |
| 100 | #define EWDAE_IOCTL_SET_REPORT _IO(EWDAEIO, 0x0D) |
| 101 | #define EWDAE_IOCTL_GET_WIA _IOR(EWDAEIO, 0x0E, int) |
| 102 | #define EWDAE_IOCTL_GET_AXISINTERFERENCE _IOR(EWDAEIO, 0x0F, int) |
| 103 | #define EWDAE_IOCTL_SET_SAMPLERATE _IOW(EWDAEIO, 0x10, int) |
| 104 | #define EWDAE_IOCTL_GET_DIRPOLARITY _IOR(EWDAEIO, 0x11, int) |
| 105 | #define EWDAE_IOCTL_GET_AKM_DATA _IOR(EWDAEIO, 0x12, short[12]) |
| 106 | #define EWDAE_IOCTL_SET_ROTATION_VECTOR _IOW(EWDAEIO, 0x14, int) |
| 107 | #define EWDAE_IOCTL_SET_LINEAR_ACCEL _IOW(EWDAEIO, 0x15, int) |
| 108 | #define EWDAE_IOCTL_SET_GRAVITY _IOW(EWDAEIO, 0x16, int) |
| 109 | #define EWDAE_IOCTL_GET_AKM_READY _IOR(EWDAEIO, 0x17, int) |
| 110 | #define EWDAE_IOCTL_GET_GYRO_CAL_DATA _IOR(EWDAEIO, 0x18, unsigned char[12]) |
| 111 | |
| 112 | #define EWDAE_IOCTL_WRITE_I2CDATA _IOW(EWDAEIO, 0x19, int) |
| 113 | #define EWDAE_IOCTL_WRITE_I2CADDR _IOW(EWDAEIO, 0x1A, int) |
| 114 | #define EWDAE_IOCTL_READ_I2CDATA _IOR(EWDAEIO, 0x1B, int) |
| 115 | |
| 116 | |
| 117 | #define EWHALIO 0x85 |
| 118 | #define EWHAL_IOCTL_GET_SENSORDATA _IOR(EWHALIO, 0x01, int) |
| 119 | #define EWHAL_IOCTL_GET_POSTURE _IOR(EWHALIO, 0x02, int) |
| 120 | #define EWHAL_IOCTL_GET_CALIDATA _IOR(EWHALIO, 0x03, int) |
| 121 | #define EWHAL_IOCTL_GET_GYRODATA _IOR(EWHALIO, 0x04, int) |
| 122 | #define EWHAL_IOCTL_GET_PEDODATA _IOR(EWHALIO, 0x05, long) |
| 123 | #define EWHAL_IOCTL_GET_PEDOPARAM _IOR(EWHALIO, 0x06, int) |
| 124 | #define EWHAL_IOCTL_SET_PEDOPARAM _IOW(EWHALIO, 0x07, int) |
| 125 | #define EWHAL_IOCTL_GET_CONTROL _IOR(EWHALIO, 0x08, int) |
| 126 | #define EWHAL_IOCTL_SET_CONTROL _IOW(EWHALIO, 0x09, int) |
| 127 | #define EWHAL_IOCTL_GET_WIA _IOR(EWHALIO, 0x0A, int) |
| 128 | #define EWHAL_IOCTL_GET_ROTATION_VECTOR _IOR(EWHALIO, 0x0B, int) |
| 129 | #define EWHAL_IOCTL_GET_LINEAR_ACCEL _IOR(EWHALIO, 0x0C, int) |
| 130 | #define EWHAL_IOCTL_GET_GRAVITY _IOR(EWHALIO, 0x0D, int) |
| 131 | |
| 132 | #define EW_CHIPSET 0 |
| 133 | #define EW_BUFSIZE 256 |
| 134 | #define EW_AXIS_INTERFERENCE 127 |
| 135 | #define EW_NORMAL_MODE 0 |
| 136 | #define EW_DEFAULT_POLLING_TIME 200 |
| 137 | #define EW_REPORT_EN_COMPASS 1 |
| 138 | #define EW_REPORT_EN_GYROSCOPE 2 |
| 139 | |
| 140 | #define EW_CB_LENGTH 10 |
| 141 | #define EW_CB_LOOPDELAY 0 |
| 142 | #define EW_CB_RUN 1 |
| 143 | #define EW_CB_ACCCALI 2 |
| 144 | #define EW_CB_MAGCALI 3 |
| 145 | #define EW_CB_ACTIVESENSORS 4 |
| 146 | #define EW_CB_PD_RESET 5 |
| 147 | #define EW_CB_PD_EN_PARAM 6 |
| 148 | #define EW_CB_GYROCALI 7 |
| 149 | #define EW_CB_ALGORITHMLOG 8 |
| 150 | #define EW_CB_UNDEFINE_1 9 |
| 151 | |
| 152 | #define EW_DP_LENGTH 6 |
| 153 | #define EW_DP_ACC_DIR 0 |
| 154 | #define EW_DP_ACC_POLARITY 1 |
| 155 | #define EW_DP_MAG_DIR 2 |
| 156 | #define EW_DP_MAG_POLARITY 3 |
| 157 | #define EW_DP_GYRO_DIR 4 |
| 158 | #define EW_DP_GYRO_POLARITY 5 |
| 159 | |
| 160 | #define EW_PD_LENGTH 10 |
| 161 | #define EW_PD_PRARM_IIR1 0 |
| 162 | #define EW_PD_PRARM_IIR2 1 |
| 163 | #define EW_PD_PRARM_IIR3 2 |
| 164 | #define EW_PD_PRARM_IIR4 3 |
| 165 | #define EW_PD_PRARM_TH1 4 |
| 166 | #define EW_PD_PRARM_TH2 5 |
| 167 | #define EW_PD_PRARM_TH3 6 |
| 168 | #define EW_PD_PRARM_TH4 7 |
| 169 | #define EW_PD_UNDEFINE_1 8 |
| 170 | #define EW_PD_UNDEFINE_2 9 |
| 171 | |
| 172 | #define EW_ACCELEROMETER_SENSOR 0 |
| 173 | #define EW_MAGNETIC_FIELD_SENSOR 1 |
| 174 | #define EW_ORIENTATION_SENSOR 2 |
| 175 | #define EW_ROTATION_VECTOR 3 |
| 176 | #define EW_LINEAR_ACCELERATION 4 |
| 177 | #define EW_GRAVITY 5 |
| 178 | #define EW_GYROSCOPE_SENSOR 6 |
| 179 | #define EW_PEDOMETER_SENSOR 9 |
| 180 | |
| 181 | #define EW_BIT_ACCELEROMETER (1<<EW_ACCELEROMETER_SENSOR) |
| 182 | #define EW_BIT_MAGNETIC_FIELD (1<<EW_MAGNETIC_FIELD_SENSOR) |
| 183 | #define EW_BIT_ORIENTATION (1<<EW_ORIENTATION_SENSOR) |
| 184 | #define EW_BIT_ROTATION_VECTOR (1<<EW_ROTATION_VECTOR) |
| 185 | #define EW_BIT_LINEAR_ACCELERATION (1<<EW_LINEAR_ACCELERATION) |
| 186 | #define EW_BIT_GRAVITY (1<<EW_GRAVITY) |
| 187 | #define EW_BIT_GYROSCOPE (1<<EW_GYROSCOPE_SENSOR) |
| 188 | #define EW_BIT_PEDOMETER (1<<EW_PEDOMETER_SENSOR) |
| 189 | |
| 190 | struct pana_gyro_platform_data { |
| 191 | int reset_line; |
| 192 | int reset_asserted; |
| 193 | int gpio_data_ready_int; |
| 194 | int acc_dir; |
| 195 | int acc_polarity; |
| 196 | int gyro_dir; |
| 197 | int gyro_polarity; |
| 198 | int mag_dir; |
| 199 | int mag_polarity; |
| 200 | int sleep_pin; |
| 201 | void (*config_gyro_diag_gpios)(bool enable); |
| 202 | }; |
| 203 | extern unsigned char gyro_gsensor_kvalue[37]; |
| 204 | |
| 205 | #endif |