xref: /OK3568_Linux_fs/kernel/include/linux/icm2060x.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Definitions for icm2060x chip.
4  */
5 #ifndef __ICM2060X_H
6 #define __ICM2060X_H
7 
8 #include <linux/ioctl.h>
9 #define ICM2060X_PRECISION	16
10 #define ICM2060X_RANGE		2000000
11 
12 #define ICM2060X_SMPLRT_DIV	0x19
13 #define ICM2060X_CONFIG		0x1A
14 #define ICM2060X_GYRO_CONFIG	0x1B
15 #define ICM2060X_ACCEL_CONFIG	0x1C
16 #define ICM2060X_ACCEL_CONFIG2	0x1D
17 #define ICM2060X_LP_ACCEL_ODR   0x1E
18 #define ICM2060X_WOM_THRESH	0x1F
19 #define ICM2060X_FIFO_EN	0x23
20 #define ICM2060X_INT_PIN_CFG	0x37
21 #define ICM2060X_INT_ENABLE	0x38
22 #define ICM2060X_DMP_INT_STATUS	0x39
23 #define ICM2060X_INT_STATUS	0x3A
24 #define ICM2060X_ACCEL_XOUT_H	0x3B
25 #define ICM2060X_TEMP_OUT_H	0x41
26 #define ICM2060X_GYRO_XOUT_H	0x43
27 #define ICM2060X_ACCEL_INTEL_CTRL 0x69
28 #define ICM2060X_USER_CTRL	0x6A
29 #define ICM2060X_PWR_MGMT_1	0x6B
30 #define ICM2060X_PWR_MGMT_2	0x6C
31 #define ICM2060X_PRGM_STRT_ADDRH 0x70
32 #define ICM2060X_FIFO_COUNTH	0x72
33 #define ICM2060X_FIFO_R_W	0x74
34 #define ICM2060X_WHOAMI		0x75
35 
36 /* DEVICE ID */
37 #define ICM20600_DEVICE_ID	0x11
38 #define ICM20607_DEVICE_ID	0x05
39 
40 /* ICM2060X_CONFIG */
41 #define DLPF_CFG_250HZ		0x00
42 #define DLPF_CFG_184HZ		0x01
43 #define DLPF_CFG_98HZ		0x02
44 #define DLPF_CFG_41HZ		0x03
45 #define DLPF_CFG_20HZ		0x04
46 #define DLPF_CFG_10HZ		0x05
47 #define DLPF_CFG_5HZ		0x06
48 #define DLPF_CFG_3600HZ		0x07
49 #define EXT_SYNC_SET_TEMP	0x08
50 #define EXT_SYNC_SET_GYRO_X	0x10
51 #define EXT_SYNC_SET_GYRO_Y	0x18
52 #define EXT_SYNC_SET_GYRO_Z	0x20
53 #define EXT_SYNC_SET_ACCEL_X	0x28
54 #define EXT_SYNC_SET_ACCEL_Y	0x30
55 #define EXT_SYNC_SET_ACCEL_Z	0x38
56 
57 
58 /* ICM2060X_GYRO_CONFIG */
59 #define GFSR_250DPS		(0 << 3)
60 #define GFSR_500DPS		(1 << 3)
61 #define GFSR_1000DPS		(2 << 3)
62 #define GFSR_2000DPS		(3 << 3)
63 
64 /* ICM2060X_ACCEL_CONFIG */
65 #define AFSR_2G		(0 << 3)
66 #define AFSR_4G		(1 << 3)
67 #define AFSR_8G		(2 << 3)
68 #define AFSR_16G	(3 << 3)
69 
70 
71 /* ICM2060X_ACCEL_CONFIG2 */
72 #define A_DLPF_CFG_460HZ	0x00
73 #define A_DLPF_CFG_184HZ	0x01
74 #define A_DLPF_CFG_92HZ		0x02
75 #define A_DLPF_CFG_41HZ		0x03
76 #define A_DLPF_CFG_20HZ		0x04
77 #define A_DLPF_CFG_10HZ		0x05
78 #define A_DLPF_CFG_5HZ		0x06
79 /* #define A_DLPF_CFG_460HZ      0x07 */
80 #define BIT_FIFO_SIZE_1K	0x40
81 #define BIT_ACCEL_FCHOICE_B	0x08
82 
83 
84 /* ICM2060X_LP_ACCEL_ODR */
85 #define LPA_CLK_P24HZ	0x0
86 #define LPA_CLK_P49HZ	0x1
87 #define LPA_CLK_P98HZ	0x2
88 #define LPA_CLK_1P95HZ	0x3
89 #define LPA_CLK_3P91HZ	0x4
90 #define LPA_CLK_7P81HZ	0x5
91 #define LPA_CLK_15P63HZ	0x6
92 #define LPA_CLK_31P25HZ	0x7
93 #define LPA_CLK_62P50HZ	0x8
94 #define LPA_CLK_125HZ	0x9
95 #define LPA_CLK_250HZ	0xa
96 #define LPA_CLK_500HZ	0xb
97 
98 
99 /* ICM2060X_PWR_MGMT_1 */
100 #define BIT_H_RESET		(1<<7)
101 #define BIT_SLEEP		(1<<6)
102 #define BIT_CYCLE		(1<<5)
103 #define BIT_GYRO_STANDBY	(1<<4)
104 #define BIT_PD_PTAT		(1<<3)
105 #define BIT_CLKSEL		(1<<0)
106 
107 #define CLKSEL_INTERNAL		0
108 #define CLKSEL_PLL		1
109 
110 /* ICM2060X_PWR_MGMT_2 */
111 #define BIT_ACCEL_STBY		0x38
112 #define BIT_GYRO_STBY		0x07
113 #define BITS_LPA_WAKE_CTRL	0xC0
114 #define BITS_LPA_WAKE_1HZ	0x00
115 #define BITS_LPA_WAKE_2HZ	0x40
116 #define BITS_LPA_WAKE_20HZ	0x80
117 
118 #define ICM2060X_PWRM1_SLEEP		0x40
119 #define ICM2060X_PWRM1_GYRO_STANDBY	0x10
120 #define ICM2060X_PWRM2_ACCEL_DISABLE	0x38
121 #define ICM2060X_PWRM2_GYRO_DISABLE	0x07
122 
123 /* ICM2060X_ACCEL_INTEL_CTRL */
124 #define BIT_ACCEL_INTEL_EN	0x80
125 #define BIT_ACCEL_INTEL_MODE	0x40
126 
127 
128 /* ICM2060X_USER_CTRL */
129 #define BIT_FIFO_RST		0x04
130 #define BIT_DMP_RST		0x08
131 #define BIT_I2C_MST_EN		0x20
132 #define BIT_FIFO_EN		0x40
133 #define BIT_DMP_EN		0x80
134 
135 
136 /* ICM2060X_FIFO_EN */
137 #define BIT_ACCEL_OUT		0x08
138 #define BITS_GYRO_OUT		0x70
139 
140 
141 /* ICM2060X_INT_PIN_CFG */
142 #define BIT_BYPASS_EN		0x2
143 
144 /* ICM2060X_INT_EN/INT_STATUS */
145 #define BIT_FIFO_OVERLOW	0x80
146 #define BIT_MOT_INT		0x40
147 #define BIT_MPU_RDY		0x04
148 #define BIT_DMP_INT		0x02
149 #define BIT_RAW_RDY		0x01
150 #define DMP_START_ADDR		0x400
151 #define AXIS_NUM 3
152 #define AXIS_ADC_BYTE 2
153 #define SENSOR_PACKET (AXIS_NUM * AXIS_ADC_BYTE)
154 
155 /* self-test parameter */
156 
157 #define DEF_ST_PRECISION		1000
158 #define DEF_ST_ICM2060X_ACCEL_LPF	2
159 #define DEF_STABLE_TIME_ST		50
160 #define DEF_SELFTEST_GYRO_FS		(0 << 3)
161 #define DEF_SELFTEST_ACCEL_FS		(2 << 3)
162 #define DEF_SELFTEST_6500_ACCEL_FS	(0 << 3)
163 #define DEF_SW_SELFTEST_SENSITIVITY	((2000 * DEF_ST_PRECISION) / 32768)
164 
165 #define DEF_SW_SELFTEST_SAMPLE_COUNT	75
166 #define DEF_SW_SELFTEST_SAMPLE_TIME	75
167 #define DEF_SW_ACCEL_CAL_SAMPLE_TIME	50
168 #define DEF_SW_SKIP_COUNT		10
169 
170 #define DEF_ST_6500_STABLE_TIME		20
171 #define BYTES_PER_SENSOR		6
172 #define DEF_SELFTEST_SAMPLE_RATE	0
173 #define DEF_GYRO_WAIT_TIME		50
174 #define THREE_AXIS			3
175 #define INIT_ST_SAMPLES			200
176 #define FIFO_COUNT_BYTE			2
177 #define DEF_ST_TRY_TIMES		2
178 #define REG_6500_XG_ST_DATA		0x0
179 #define REG_6500_XA_ST_DATA		0xD
180 #define BITS_SELF_TEST_EN		0xE0
181 
182 #define DEF_ST_SCAL			(1L << 15)
183 
184 /*---- ICM2060X Self Test Pass/Fail Criteria ----*/
185 /* Gyro Offset Max Value (dps) */
186 #define DEF_GYRO_OFFSET_MAX		20
187 /* Gyro Self Test Absolute Limits ST_AL (dps) */
188 #define DEF_GYRO_ST_AL			60
189 /* Accel Self Test Absolute Limits ST_AL (mg) */
190 #define DEF_ACCEL_ST_AL_MIN		225
191 #define DEF_ACCEL_ST_AL_MAX		675
192 #define DEF_6500_ACCEL_ST_SHIFT_DELTA	500
193 #define DEF_6500_GYRO_CT_SHIFT_DELTA	500
194 #define DEF_ST_ICM2060X_ACCEL_LPF	2
195 #define DEF_ST_6500_ACCEL_FS_MG		2000UL
196 #define DEF_SELFTEST_6500_ACCEL_FS	(0 << 3)
197 
198 #define DEF_SELFTEST_GYRO_SENS		(32768 / 250)
199 #endif
200 
201