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 
11 #ifndef HTS221_H
12 #define HTS221_H
13 
14 #define HTS221_DEV_NAME		"hts221"
15 
16 #include <linux/iio/iio.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 
34 	struct iio_trigger *trig;
35 	int irq;
36 
37 	struct hts221_sensor sensors[HTS221_SENSOR_MAX];
38 
39 	bool enabled;
40 	u8 odr;
41 	/* Ensure natural alignment of timestamp */
42 	struct {
43 		__le16 channels[2];
44 		s64 ts __aligned(8);
45 	} scan;
46 };
47 
48 extern const struct dev_pm_ops hts221_pm_ops;
49 
50 int hts221_probe(struct device *dev, int irq, const char *name,
51 		 struct regmap *regmap);
52 int hts221_set_enable(struct hts221_hw *hw, bool enable);
53 int hts221_allocate_buffers(struct hts221_hw *hw);
54 int hts221_allocate_trigger(struct hts221_hw *hw);
55 
56 #endif /* HTS221_H */
57