blob: e41a3d83e95d367bf83f0fbda6ef278537a7515b [file] [log] [blame]
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +02001/*
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
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020018#define HTS221_DATA_SIZE 2
19
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020020enum hts221_sensor_type {
21 HTS221_SENSOR_H,
22 HTS221_SENSOR_T,
23 HTS221_SENSOR_MAX,
24};
25
26struct hts221_sensor {
27 u8 cur_avg_idx;
28 int slope, b_gen;
29};
30
31struct hts221_hw {
32 const char *name;
33 struct device *dev;
Lorenzo Bianconi62177922018-01-08 23:12:30 +010034 struct regmap *regmap;
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020035
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020036 struct iio_trigger *trig;
37 int irq;
38
39 struct hts221_sensor sensors[HTS221_SENSOR_MAX];
40
Lorenzo Bianconib7079ee2017-05-14 17:45:44 +020041 bool enabled;
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020042 u8 odr;
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020043};
44
Lorenzo Bianconib7079ee2017-05-14 17:45:44 +020045extern const struct dev_pm_ops hts221_pm_ops;
46
Lorenzo Bianconie1ca1142017-12-30 00:33:04 +010047int hts221_probe(struct device *dev, int irq, const char *name,
Lorenzo Bianconi62177922018-01-08 23:12:30 +010048 struct regmap *regmap);
Lorenzo Bianconie3e25442017-07-17 19:39:00 +020049int hts221_set_enable(struct hts221_hw *hw, bool enable);
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020050int hts221_allocate_buffers(struct hts221_hw *hw);
51int hts221_allocate_trigger(struct hts221_hw *hw);
52
53#endif /* HTS221_H */