mpu3050.h 2.7 KB

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