blob: 721359e226cb97f7df1c32ad5ddfa20913d82592 [file] [log] [blame]
Thomas Gleixnerfda8d262019-05-28 09:57:06 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +02002/*
3 * STMicroelectronics hts221 sensor driver
4 *
5 * Copyright 2016 STMicroelectronics Inc.
6 *
7 * Lorenzo Bianconi <lorenzo.bianconi@st.com>
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +02008 */
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 Bianconie4a70e32016-10-13 22:06:04 +020017enum hts221_sensor_type {
18 HTS221_SENSOR_H,
19 HTS221_SENSOR_T,
20 HTS221_SENSOR_MAX,
21};
22
23struct hts221_sensor {
24 u8 cur_avg_idx;
25 int slope, b_gen;
26};
27
28struct hts221_hw {
29 const char *name;
30 struct device *dev;
Lorenzo Bianconi62177922018-01-08 23:12:30 +010031 struct regmap *regmap;
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020032
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020033 struct iio_trigger *trig;
34 int irq;
35
36 struct hts221_sensor sensors[HTS221_SENSOR_MAX];
37
Lorenzo Bianconib7079ee2017-05-14 17:45:44 +020038 bool enabled;
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020039 u8 odr;
Jonathan Cameron5c490562020-06-07 16:53:53 +010040 /* Ensure natural alignment of timestamp */
41 struct {
42 __le16 channels[2];
43 s64 ts __aligned(8);
44 } scan;
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020045};
46
Lorenzo Bianconib7079ee2017-05-14 17:45:44 +020047extern const struct dev_pm_ops hts221_pm_ops;
48
Lorenzo Bianconie1ca1142017-12-30 00:33:04 +010049int hts221_probe(struct device *dev, int irq, const char *name,
Lorenzo Bianconi62177922018-01-08 23:12:30 +010050 struct regmap *regmap);
Lorenzo Bianconie3e25442017-07-17 19:39:00 +020051int hts221_set_enable(struct hts221_hw *hw, bool enable);
Alexandru Ardelean7d175772020-05-22 09:56:16 +030052int hts221_allocate_buffers(struct iio_dev *iio_dev);
53int hts221_allocate_trigger(struct iio_dev *iio_dev);
Lorenzo Bianconie4a70e32016-10-13 22:06:04 +020054
55#endif /* HTS221_H */