1fda8d26eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2e4a70e3eSLorenzo Bianconi /* 3e4a70e3eSLorenzo Bianconi * STMicroelectronics hts221 sensor driver 4e4a70e3eSLorenzo Bianconi * 5e4a70e3eSLorenzo Bianconi * Copyright 2016 STMicroelectronics Inc. 6e4a70e3eSLorenzo Bianconi * 7e4a70e3eSLorenzo Bianconi * Lorenzo Bianconi <lorenzo.bianconi@st.com> 8e4a70e3eSLorenzo Bianconi */ 9e4a70e3eSLorenzo Bianconi 10e4a70e3eSLorenzo Bianconi #ifndef HTS221_H 11e4a70e3eSLorenzo Bianconi #define HTS221_H 12e4a70e3eSLorenzo Bianconi 13e4a70e3eSLorenzo Bianconi #define HTS221_DEV_NAME "hts221" 14e4a70e3eSLorenzo Bianconi 15e4a70e3eSLorenzo Bianconi #include <linux/iio/iio.h> 16e4a70e3eSLorenzo Bianconi 17e4a70e3eSLorenzo Bianconi enum hts221_sensor_type { 18e4a70e3eSLorenzo Bianconi HTS221_SENSOR_H, 19e4a70e3eSLorenzo Bianconi HTS221_SENSOR_T, 20e4a70e3eSLorenzo Bianconi HTS221_SENSOR_MAX, 21e4a70e3eSLorenzo Bianconi }; 22e4a70e3eSLorenzo Bianconi 23e4a70e3eSLorenzo Bianconi struct hts221_sensor { 24e4a70e3eSLorenzo Bianconi u8 cur_avg_idx; 25e4a70e3eSLorenzo Bianconi int slope, b_gen; 26e4a70e3eSLorenzo Bianconi }; 27e4a70e3eSLorenzo Bianconi 28e4a70e3eSLorenzo Bianconi struct hts221_hw { 29e4a70e3eSLorenzo Bianconi const char *name; 30e4a70e3eSLorenzo Bianconi struct device *dev; 3162177922SLorenzo Bianconi struct regmap *regmap; 32e4a70e3eSLorenzo Bianconi 33e4a70e3eSLorenzo Bianconi struct iio_trigger *trig; 34e4a70e3eSLorenzo Bianconi int irq; 35e4a70e3eSLorenzo Bianconi 36e4a70e3eSLorenzo Bianconi struct hts221_sensor sensors[HTS221_SENSOR_MAX]; 37e4a70e3eSLorenzo Bianconi 38b7079eeaSLorenzo Bianconi bool enabled; 39e4a70e3eSLorenzo Bianconi u8 odr; 40*5c49056aSJonathan Cameron /* Ensure natural alignment of timestamp */ 41*5c49056aSJonathan Cameron struct { 42*5c49056aSJonathan Cameron __le16 channels[2]; 43*5c49056aSJonathan Cameron s64 ts __aligned(8); 44*5c49056aSJonathan Cameron } scan; 45e4a70e3eSLorenzo Bianconi }; 46e4a70e3eSLorenzo Bianconi 47b7079eeaSLorenzo Bianconi extern const struct dev_pm_ops hts221_pm_ops; 48b7079eeaSLorenzo Bianconi 49e1ca1141SLorenzo Bianconi int hts221_probe(struct device *dev, int irq, const char *name, 5062177922SLorenzo Bianconi struct regmap *regmap); 51e3e25446SLorenzo Bianconi int hts221_set_enable(struct hts221_hw *hw, bool enable); 527d17577dSAlexandru Ardelean int hts221_allocate_buffers(struct iio_dev *iio_dev); 537d17577dSAlexandru Ardelean int hts221_allocate_trigger(struct iio_dev *iio_dev); 54e4a70e3eSLorenzo Bianconi 55e4a70e3eSLorenzo Bianconi #endif /* HTS221_H */ 56