Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 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 | |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 18 | #define HTS221_DATA_SIZE 2 |
| 19 | |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 20 | enum hts221_sensor_type { |
| 21 | HTS221_SENSOR_H, |
| 22 | HTS221_SENSOR_T, |
| 23 | HTS221_SENSOR_MAX, |
| 24 | }; |
| 25 | |
| 26 | struct hts221_sensor { |
| 27 | u8 cur_avg_idx; |
| 28 | int slope, b_gen; |
| 29 | }; |
| 30 | |
| 31 | struct hts221_hw { |
| 32 | const char *name; |
| 33 | struct device *dev; |
Lorenzo Bianconi | 6217792 | 2018-01-08 23:12:30 +0100 | [diff] [blame] | 34 | struct regmap *regmap; |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 35 | |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 36 | struct iio_trigger *trig; |
| 37 | int irq; |
| 38 | |
| 39 | struct hts221_sensor sensors[HTS221_SENSOR_MAX]; |
| 40 | |
Lorenzo Bianconi | b7079ee | 2017-05-14 17:45:44 +0200 | [diff] [blame] | 41 | bool enabled; |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 42 | u8 odr; |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 43 | }; |
| 44 | |
Lorenzo Bianconi | b7079ee | 2017-05-14 17:45:44 +0200 | [diff] [blame] | 45 | extern const struct dev_pm_ops hts221_pm_ops; |
| 46 | |
Lorenzo Bianconi | e1ca114 | 2017-12-30 00:33:04 +0100 | [diff] [blame] | 47 | int hts221_probe(struct device *dev, int irq, const char *name, |
Lorenzo Bianconi | 6217792 | 2018-01-08 23:12:30 +0100 | [diff] [blame] | 48 | struct regmap *regmap); |
Lorenzo Bianconi | e3e2544 | 2017-07-17 19:39:00 +0200 | [diff] [blame] | 49 | int hts221_set_enable(struct hts221_hw *hw, bool enable); |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 50 | int hts221_allocate_buffers(struct hts221_hw *hw); |
| 51 | int hts221_allocate_trigger(struct hts221_hw *hw); |
| 52 | |
| 53 | #endif /* HTS221_H */ |