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