Thomas Gleixner | fda8d26 | 2019-05-28 09:57:06 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 2 | /* |
| 3 | * STMicroelectronics hts221 sensor driver |
| 4 | * |
| 5 | * Copyright 2016 STMicroelectronics Inc. |
| 6 | * |
| 7 | * Lorenzo Bianconi <lorenzo.bianconi@st.com> |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 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 | |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 17 | enum hts221_sensor_type { |
| 18 | HTS221_SENSOR_H, |
| 19 | HTS221_SENSOR_T, |
| 20 | HTS221_SENSOR_MAX, |
| 21 | }; |
| 22 | |
| 23 | struct hts221_sensor { |
| 24 | u8 cur_avg_idx; |
| 25 | int slope, b_gen; |
| 26 | }; |
| 27 | |
| 28 | struct hts221_hw { |
| 29 | const char *name; |
| 30 | struct device *dev; |
Lorenzo Bianconi | 6217792 | 2018-01-08 23:12:30 +0100 | [diff] [blame] | 31 | struct regmap *regmap; |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 32 | |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 33 | struct iio_trigger *trig; |
| 34 | int irq; |
| 35 | |
| 36 | struct hts221_sensor sensors[HTS221_SENSOR_MAX]; |
| 37 | |
Lorenzo Bianconi | b7079ee | 2017-05-14 17:45:44 +0200 | [diff] [blame] | 38 | bool enabled; |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 39 | u8 odr; |
Jonathan Cameron | 5c49056 | 2020-06-07 16:53:53 +0100 | [diff] [blame] | 40 | /* Ensure natural alignment of timestamp */ |
| 41 | struct { |
| 42 | __le16 channels[2]; |
| 43 | s64 ts __aligned(8); |
| 44 | } scan; |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 45 | }; |
| 46 | |
Lorenzo Bianconi | b7079ee | 2017-05-14 17:45:44 +0200 | [diff] [blame] | 47 | extern const struct dev_pm_ops hts221_pm_ops; |
| 48 | |
Lorenzo Bianconi | e1ca114 | 2017-12-30 00:33:04 +0100 | [diff] [blame] | 49 | int hts221_probe(struct device *dev, int irq, const char *name, |
Lorenzo Bianconi | 6217792 | 2018-01-08 23:12:30 +0100 | [diff] [blame] | 50 | struct regmap *regmap); |
Lorenzo Bianconi | e3e2544 | 2017-07-17 19:39:00 +0200 | [diff] [blame] | 51 | int hts221_set_enable(struct hts221_hw *hw, bool enable); |
Alexandru Ardelean | 7d17577 | 2020-05-22 09:56:16 +0300 | [diff] [blame] | 52 | int hts221_allocate_buffers(struct iio_dev *iio_dev); |
| 53 | int hts221_allocate_trigger(struct iio_dev *iio_dev); |
Lorenzo Bianconi | e4a70e3 | 2016-10-13 22:06:04 +0200 | [diff] [blame] | 54 | |
| 55 | #endif /* HTS221_H */ |