import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / accelerometer / mpu6050g / mpu6xxx_hwselftest.h
1
2 #ifndef MPU6XXX_HWSELFTEST_H
3 #define MPU6XXX_HWSELFTEST_H
4
5 #define MPU6XXX_HWSELFTEST 1
6
7 #define REG_6500_XG_ST_DATA 0x0
8 #define REG_6500_XA_ST_DATA 0xD
9 #define REG_6500_XA_OFFS_H 0x77
10 #define REG_6500_YA_OFFS_H 0x7A
11 #define REG_6500_ZA_OFFS_H 0x7D
12 #define REG_6500_ACCEL_CONFIG2 0x1D
13 #define BIT_ACCEL_FCHOCIE_B 0x08
14 #define BIT_FIFO_SIZE_1K 0x40
15
16 #define REG_INT_ENABLE 0x38
17 #define REG_FIFO_EN 0x23
18 #define REG_USER_CTRL 0x6a
19 #define BIT_FIFO_RST 0x04
20 #define BIT_FIFO_EN 0x40
21 #define REG_CONFIG 0x1a
22 #define REG_SAMPLE_RATE_DIV 0x19
23 #define REG_GYRO_CONFIG 0x1b
24 #define REG_ACCEL_CONFIG 0x1c
25 #define BITS_GYRO_OUT 0x70
26 #define BIT_ACCEL_OUT 0x08
27 #define REG_FIFO_COUNT_H 0x72
28 #define REG_FIFO_R_W 0x74
29 #define BITS_SELF_TEST_EN 0xe0
30 #define DEF_ST_COMPASS_RESULT_SHIFT 2
31 #define DEF_ST_ACCEL_RESULT_SHIFT 1
32
33
34 /* sample rate */
35 #define DEF_SELFTEST_SAMPLE_RATE 0
36 /* full scale setting dps */
37 #define DEF_SELFTEST_GYRO_FS (0 << 3)
38 #define DEF_SELFTEST_ACCEL_FS (2 << 3)
39 #define DEF_SELFTEST_GYRO_SENS (32768 / 250)
40 /* wait time before collecting data */
41 #define DEF_GYRO_WAIT_TIME 10
42 #define DEF_ST_STABLE_TIME 20
43 #define DEF_ST_6500_STABLE_TIME 20
44 #define DEF_GYRO_SCALE 131
45 #define DEF_ST_PRECISION 1000
46 #define DEF_ST_ACCEL_FS_MG 8000UL
47 #define DEF_ST_SCALE (1L << 15)
48 #define DEF_ST_TRY_TIMES 2
49
50 /*---- MPU6500 Self Test Pass/Fail Criteria ----*/
51 /* Gyro Offset Max Value (dps) */
52 #define DEF_GYRO_OFFSET_MAX 20
53 /* Gyro Self Test Absolute Limits ST_AL (dps) */
54 #define DEF_GYRO_ST_AL 60
55 /* Accel Self Test Absolute Limits ST_AL (mg) */
56 #define DEF_ACCEL_ST_AL_MIN 225
57 #define DEF_ACCEL_ST_AL_MAX 675
58 #define DEF_6500_ACCEL_ST_SHIFT_DELTA 500
59 #define DEF_6500_GYRO_CT_SHIFT_DELTA 500
60 #define DEF_ST_MPU6500_ACCEL_LPF 2
61 #define DEF_ST_6500_ACCEL_FS_MG 2000UL
62 #define DEF_SELFTEST_6500_ACCEL_FS (0 << 3)
63
64
65 #define THREE_AXIS 3
66 #define BYTES_PER_SENSOR 6
67
68 #define ONE_K_HZ 1000
69 #define INV_MPU_SAMPLE_RATE_CHANGE_STABLE 50
70 #define INIT_ST_SAMPLES 200
71 #define FIFO_COUNT_BYTE 2
72
73 /* device enum */
74 enum inv_devices {
75 INV_MPU6050,
76 INV_MPU9150,
77 INV_MPU6500,
78 INV_MPU9250,
79 INV_MPU9350,
80 INV_MPU6515,
81 };
82
83 enum inv_filter_e {
84 INV_FILTER_256HZ_NOLPF2 = 0,
85 INV_FILTER_188HZ,
86 INV_FILTER_98HZ,
87 INV_FILTER_42HZ,
88 INV_FILTER_20HZ,
89 INV_FILTER_10HZ,
90 INV_FILTER_5HZ,
91 INV_FILTER_2100HZ_NOLPF,
92 NUM_FILTER
93 };
94
95 struct inv_selftest_device {
96 u8 *name;
97 enum inv_devices chip_type;
98 u16 sample_rate_div;
99 u16 config;
100 u16 gyro_config;
101 u16 accel_config;
102 int accel_bias[3];
103 int gyro_bias[3];
104 int accel_bias_st[3];
105 int gyro_bias_st[3];
106 u16 samples;//selftest sample number
107 };
108
109
110 static const u16 mpu_6500_st_tb[256] = {
111 2620, 2646, 2672, 2699, 2726, 2753, 2781, 2808,
112 2837, 2865, 2894, 2923, 2952, 2981, 3011, 3041,
113 3072, 3102, 3133, 3165, 3196, 3228, 3261, 3293,
114 3326, 3359, 3393, 3427, 3461, 3496, 3531, 3566,
115 3602, 3638, 3674, 3711, 3748, 3786, 3823, 3862,
116 3900, 3939, 3979, 4019, 4059, 4099, 4140, 4182,
117 4224, 4266, 4308, 4352, 4395, 4439, 4483, 4528,
118 4574, 4619, 4665, 4712, 4759, 4807, 4855, 4903,
119 4953, 5002, 5052, 5103, 5154, 5205, 5257, 5310,
120 5363, 5417, 5471, 5525, 5581, 5636, 5693, 5750,
121 5807, 5865, 5924, 5983, 6043, 6104, 6165, 6226,
122 6289, 6351, 6415, 6479, 6544, 6609, 6675, 6742,
123 6810, 6878, 6946, 7016, 7086, 7157, 7229, 7301,
124 7374, 7448, 7522, 7597, 7673, 7750, 7828, 7906,
125 7985, 8065, 8145, 8227, 8309, 8392, 8476, 8561,
126 8647, 8733, 8820, 8909, 8998, 9088, 9178, 9270,
127 9363, 9457, 9551, 9647, 9743, 9841, 9939, 10038,
128 10139, 10240, 10343, 10446, 10550, 10656, 10763, 10870,
129 10979, 11089, 11200, 11312, 11425, 11539, 11654, 11771,
130 11889, 12008, 12128, 12249, 12371, 12495, 12620, 12746,
131 12874, 13002, 13132, 13264, 13396, 13530, 13666, 13802,
132 13940, 14080, 14221, 14363, 14506, 14652, 14798, 14946,
133 15096, 15247, 15399, 15553, 15709, 15866, 16024, 16184,
134 16346, 16510, 16675, 16842, 17010, 17180, 17352, 17526,
135 17701, 17878, 18057, 18237, 18420, 18604, 18790, 18978,
136 19167, 19359, 19553, 19748, 19946, 20145, 20347, 20550,
137 20756, 20963, 21173, 21385, 21598, 21814, 22033, 22253,
138 22475, 22700, 22927, 23156, 23388, 23622, 23858, 24097,
139 24338, 24581, 24827, 25075, 25326, 25579, 25835, 26093,
140 26354, 26618, 26884, 27153, 27424, 27699, 27976, 28255,
141 28538, 28823, 29112, 29403, 29697, 29994, 30294, 30597,
142 30903, 31212, 31524, 31839, 32157, 32479, 32804
143 };
144
145 #endif /* #ifndef MPU6XXX_HWSELFTEST_H */