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