xref: /linux/drivers/iio/pressure/ms5611.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
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 #define MS5611_RESET			0x1e
20 #define MS5611_READ_ADC			0x00
21 #define MS5611_READ_PROM_WORD		0xA0
22 #define MS5611_START_TEMP_CONV		0x58
23 #define MS5611_START_PRESSURE_CONV	0x48
24 
25 #define MS5611_CONV_TIME_MIN		9040
26 #define MS5611_CONV_TIME_MAX		10000
27 
28 #define MS5611_PROM_WORDS_NB		8
29 
30 enum {
31 	MS5611,
32 	MS5607,
33 };
34 
35 struct ms5611_chip_info {
36 	u16 prom[MS5611_PROM_WORDS_NB];
37 
38 	int (*temp_and_pressure_compensate)(struct ms5611_chip_info *chip_info,
39 					    s32 *temp, s32 *pressure);
40 };
41 
42 struct ms5611_state {
43 	void *client;
44 	struct mutex lock;
45 
46 	int (*reset)(struct device *dev);
47 	int (*read_prom_word)(struct device *dev, int index, u16 *word);
48 	int (*read_adc_temp_and_pressure)(struct device *dev,
49 					  s32 *temp, s32 *pressure);
50 
51 	struct ms5611_chip_info *chip_info;
52 };
53 
54 int ms5611_probe(struct iio_dev *indio_dev, struct device *dev, int type);
55 
56 #endif /* _MS5611_H */
57