mpu3050.h 2.7 KB

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