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