hts221.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * STMicroelectronics hts221 sensor driver
  3. *
  4. * Copyright 2016 STMicroelectronics Inc.
  5. *
  6. * Lorenzo Bianconi <lorenzo.bianconi@st.com>
  7. *
  8. * Licensed under the GPL-2.
  9. */
  10. #ifndef HTS221_H
  11. #define HTS221_H
  12. #define HTS221_DEV_NAME "hts221"
  13. #include <linux/iio/iio.h>
  14. enum hts221_sensor_type {
  15. HTS221_SENSOR_H,
  16. HTS221_SENSOR_T,
  17. HTS221_SENSOR_MAX,
  18. };
  19. struct hts221_sensor {
  20. u8 cur_avg_idx;
  21. int slope, b_gen;
  22. };
  23. struct hts221_hw {
  24. const char *name;
  25. struct device *dev;
  26. struct regmap *regmap;
  27. struct iio_trigger *trig;
  28. int irq;
  29. struct hts221_sensor sensors[HTS221_SENSOR_MAX];
  30. bool enabled;
  31. u8 odr;
  32. /* Ensure natural alignment of timestamp */
  33. struct {
  34. __le16 channels[2];
  35. s64 ts __aligned(8);
  36. } scan;
  37. };
  38. extern const struct dev_pm_ops hts221_pm_ops;
  39. int hts221_probe(struct device *dev, int irq, const char *name,
  40. struct regmap *regmap);
  41. int hts221_set_enable(struct hts221_hw *hw, bool enable);
  42. int hts221_allocate_buffers(struct hts221_hw *hw);
  43. int hts221_allocate_trigger(struct hts221_hw *hw);
  44. #endif /* HTS221_H */