hts221.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * STMicroelectronics hts221 sensor driver
  4. *
  5. * Copyright 2016 STMicroelectronics Inc.
  6. *
  7. * Lorenzo Bianconi <[email protected]>
  8. */
  9. #ifndef HTS221_H
  10. #define HTS221_H
  11. #define HTS221_DEV_NAME "hts221"
  12. #include <linux/iio/iio.h>
  13. #include <linux/regulator/consumer.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 regulator *vdd;
  28. struct iio_trigger *trig;
  29. int irq;
  30. struct hts221_sensor sensors[HTS221_SENSOR_MAX];
  31. bool enabled;
  32. u8 odr;
  33. /* Ensure natural alignment of timestamp */
  34. struct {
  35. __le16 channels[2];
  36. s64 ts __aligned(8);
  37. } scan;
  38. };
  39. extern const struct dev_pm_ops hts221_pm_ops;
  40. int hts221_probe(struct device *dev, int irq, const char *name,
  41. struct regmap *regmap);
  42. int hts221_set_enable(struct hts221_hw *hw, bool enable);
  43. int hts221_allocate_buffers(struct iio_dev *iio_dev);
  44. int hts221_allocate_trigger(struct iio_dev *iio_dev);
  45. #endif /* HTS221_H */