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