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