GNU Linux-libre 4.19.314-gnu1
[releases.git] / drivers / iio / pressure / ms5611.h
1 /*
2  * MS5611 pressure and temperature sensor driver
3  *
4  * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  */
11
12 #ifndef _MS5611_H
13 #define _MS5611_H
14
15 #include <linux/device.h>
16 #include <linux/iio/iio.h>
17 #include <linux/mutex.h>
18
19 struct regulator;
20
21 #define MS5611_RESET                    0x1e
22 #define MS5611_READ_ADC                 0x00
23 #define MS5611_READ_PROM_WORD           0xA0
24 #define MS5611_PROM_WORDS_NB            8
25
26 enum {
27         MS5611,
28         MS5607,
29 };
30
31 /*
32  * OverSampling Rate descriptor.
33  * Warning: cmd MUST be kept aligned on a word boundary (see
34  * m5611_spi_read_adc_temp_and_pressure in ms5611_spi.c).
35  */
36 struct ms5611_osr {
37         unsigned long conv_usec;
38         u8 cmd;
39         unsigned short rate;
40 };
41
42 struct ms5611_state {
43         void *client;
44         struct mutex lock;
45
46         const struct ms5611_osr *pressure_osr;
47         const struct ms5611_osr *temp_osr;
48
49         u16 prom[MS5611_PROM_WORDS_NB];
50
51         int (*reset)(struct ms5611_state *st);
52         int (*read_prom_word)(struct ms5611_state *st, int index, u16 *word);
53         int (*read_adc_temp_and_pressure)(struct ms5611_state *st,
54                                           s32 *temp, s32 *pressure);
55
56         int (*compensate_temp_and_pressure)(struct ms5611_state *st, s32 *temp,
57                                           s32 *pressure);
58         struct regulator *vdd;
59 };
60
61 int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
62                  const char *name, int type);
63 int ms5611_remove(struct iio_dev *indio_dev);
64
65 #endif /* _MS5611_H */