xref: /linux/drivers/iio/imu/inv_mpu6050/inv_mpu_magn.h (revision 2b703bbda2713fd2a7d98029ea6c44f9c3159f34)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2019 TDK-InvenSense, Inc.
4  */
5 
6 #ifndef INV_MPU_MAGN_H_
7 #define INV_MPU_MAGN_H_
8 
9 #include <linux/kernel.h>
10 
11 #include "inv_mpu_iio.h"
12 
13 /* Magnetometer maximum frequency */
14 #define INV_MPU_MAGN_FREQ_HZ_MAX	50
15 
16 int inv_mpu_magn_probe(struct inv_mpu6050_state *st);
17 
18 /**
19  * inv_mpu_magn_get_scale() - get magnetometer scale value
20  * @st: driver internal state
21  *
22  * Returns IIO data format.
23  */
24 static inline int inv_mpu_magn_get_scale(const struct inv_mpu6050_state *st,
25 					 const struct iio_chan_spec *chan,
26 					 int *val, int *val2)
27 {
28 	*val = 0;
29 	*val2 = st->magn_raw_to_gauss[chan->address];
30 	return IIO_VAL_INT_PLUS_MICRO;
31 }
32 
33 int inv_mpu_magn_set_rate(const struct inv_mpu6050_state *st, int fifo_rate);
34 
35 int inv_mpu_magn_set_orient(struct inv_mpu6050_state *st);
36 
37 int inv_mpu_magn_read(struct inv_mpu6050_state *st, int axis, int *val);
38 
39 #endif		/* INV_MPU_MAGN_H_ */
40