Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / iio / gyro / mpu3050.h
blob835b0249c376981a21f560130aee7609f766d4bb
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <linux/iio/iio.h>
3 #include <linux/mutex.h>
4 #include <linux/regmap.h>
5 #include <linux/regulator/consumer.h>
6 #include <linux/i2c.h>
8 /**
9 * enum mpu3050_fullscale - indicates the full range of the sensor in deg/sec
11 enum mpu3050_fullscale {
12 FS_250_DPS = 0,
13 FS_500_DPS,
14 FS_1000_DPS,
15 FS_2000_DPS,
18 /**
19 * enum mpu3050_lpf - indicates the low pass filter width
21 enum mpu3050_lpf {
22 /* This implicity sets sample frequency to 8 kHz */
23 LPF_256_HZ_NOLPF = 0,
24 /* All others sets the sample frequency to 1 kHz */
25 LPF_188_HZ,
26 LPF_98_HZ,
27 LPF_42_HZ,
28 LPF_20_HZ,
29 LPF_10_HZ,
30 LPF_5_HZ,
31 LPF_2100_HZ_NOLPF,
34 enum mpu3050_axis {
35 AXIS_X = 0,
36 AXIS_Y,
37 AXIS_Z,
38 AXIS_MAX,
41 /**
42 * struct mpu3050 - instance state container for the device
43 * @dev: parent device for this instance
44 * @orientation: mounting matrix, flipped axis etc
45 * @map: regmap to reach the registers
46 * @lock: serialization lock to marshal all requests
47 * @irq: the IRQ used for this device
48 * @regs: the regulators to power this device
49 * @fullscale: the current fullscale setting for the device
50 * @lpf: digital low pass filter setting for the device
51 * @divisor: base frequency divider: divides 8 or 1 kHz
52 * @calibration: the three signed 16-bit calibration settings that
53 * get written into the offset registers for each axis to compensate
54 * for DC offsets
55 * @trig: trigger for the MPU-3050 interrupt, if present
56 * @hw_irq_trigger: hardware interrupt trigger is in use
57 * @irq_actl: interrupt is active low
58 * @irq_latch: latched IRQ, this means that it is a level IRQ
59 * @irq_opendrain: the interrupt line shall be configured open drain
60 * @pending_fifo_footer: tells us if there is a pending footer in the FIFO
61 * that we have to read out first when handling the FIFO
62 * @hw_timestamp: latest hardware timestamp from the trigger IRQ, when in
63 * use
64 * @i2cmux: an I2C mux reflecting the fact that this sensor is a hub with
65 * a pass-through I2C interface coming out of it: this device needs to be
66 * powered up in order to reach devices on the other side of this mux
68 struct mpu3050 {
69 struct device *dev;
70 struct iio_mount_matrix orientation;
71 struct regmap *map;
72 struct mutex lock;
73 int irq;
74 struct regulator_bulk_data regs[2];
75 enum mpu3050_fullscale fullscale;
76 enum mpu3050_lpf lpf;
77 u8 divisor;
78 s16 calibration[3];
79 struct iio_trigger *trig;
80 bool hw_irq_trigger;
81 bool irq_actl;
82 bool irq_latch;
83 bool irq_opendrain;
84 bool pending_fifo_footer;
85 s64 hw_timestamp;
86 struct i2c_mux_core *i2cmux;
89 /* Probe called from different transports */
90 int mpu3050_common_probe(struct device *dev,
91 struct regmap *map,
92 int irq,
93 const char *name);
94 int mpu3050_common_remove(struct device *dev);
96 /* PM ops */
97 extern const struct dev_pm_ops mpu3050_dev_pm_ops;