2019-05-29 00:57:06 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2016-10-14 04:06:04 +08:00
|
|
|
/*
|
|
|
|
* STMicroelectronics hts221 sensor driver
|
|
|
|
*
|
|
|
|
* Copyright 2016 STMicroelectronics Inc.
|
|
|
|
*
|
|
|
|
* Lorenzo Bianconi <lorenzo.bianconi@st.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HTS221_H
|
|
|
|
#define HTS221_H
|
|
|
|
|
|
|
|
#define HTS221_DEV_NAME "hts221"
|
|
|
|
|
|
|
|
#include <linux/iio/iio.h>
|
2020-11-22 19:56:48 +08:00
|
|
|
#include <linux/regulator/consumer.h>
|
2016-10-14 04:06:04 +08:00
|
|
|
|
|
|
|
enum hts221_sensor_type {
|
|
|
|
HTS221_SENSOR_H,
|
|
|
|
HTS221_SENSOR_T,
|
|
|
|
HTS221_SENSOR_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hts221_sensor {
|
|
|
|
u8 cur_avg_idx;
|
|
|
|
int slope, b_gen;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hts221_hw {
|
|
|
|
const char *name;
|
|
|
|
struct device *dev;
|
2018-01-09 06:12:30 +08:00
|
|
|
struct regmap *regmap;
|
2020-11-22 19:56:48 +08:00
|
|
|
struct regulator *vdd;
|
2016-10-14 04:06:04 +08:00
|
|
|
|
|
|
|
struct iio_trigger *trig;
|
|
|
|
int irq;
|
|
|
|
|
|
|
|
struct hts221_sensor sensors[HTS221_SENSOR_MAX];
|
|
|
|
|
2017-05-14 23:45:44 +08:00
|
|
|
bool enabled;
|
2016-10-14 04:06:04 +08:00
|
|
|
u8 odr;
|
2020-06-07 23:53:53 +08:00
|
|
|
/* Ensure natural alignment of timestamp */
|
|
|
|
struct {
|
|
|
|
__le16 channels[2];
|
|
|
|
s64 ts __aligned(8);
|
|
|
|
} scan;
|
2016-10-14 04:06:04 +08:00
|
|
|
};
|
|
|
|
|
2017-05-14 23:45:44 +08:00
|
|
|
extern const struct dev_pm_ops hts221_pm_ops;
|
|
|
|
|
2017-12-30 07:33:04 +08:00
|
|
|
int hts221_probe(struct device *dev, int irq, const char *name,
|
2018-01-09 06:12:30 +08:00
|
|
|
struct regmap *regmap);
|
2017-07-18 01:39:00 +08:00
|
|
|
int hts221_set_enable(struct hts221_hw *hw, bool enable);
|
2020-05-22 14:56:16 +08:00
|
|
|
int hts221_allocate_buffers(struct iio_dev *iio_dev);
|
|
|
|
int hts221_allocate_trigger(struct iio_dev *iio_dev);
|
2016-10-14 04:06:04 +08:00
|
|
|
|
|
|
|
#endif /* HTS221_H */
|