16cfdb150STomasz Duszynski /* SPDX-License-Identifier: GPL-2.0 */ 2c0644160STomasz Duszynski /* 3c0644160STomasz Duszynski * MS5611 pressure and temperature sensor driver 4c0644160STomasz Duszynski * 5c0644160STomasz Duszynski * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com> 6c0644160STomasz Duszynski * 7c0644160STomasz Duszynski */ 8c0644160STomasz Duszynski 9c0644160STomasz Duszynski #ifndef _MS5611_H 10c0644160STomasz Duszynski #define _MS5611_H 11c0644160STomasz Duszynski 12c0644160STomasz Duszynski #include <linux/device.h> 13c0644160STomasz Duszynski #include <linux/iio/iio.h> 14c0644160STomasz Duszynski #include <linux/mutex.h> 15c0644160STomasz Duszynski 16c0644160STomasz Duszynski #define MS5611_RESET 0x1e 17c0644160STomasz Duszynski #define MS5611_READ_ADC 0x00 18c0644160STomasz Duszynski #define MS5611_READ_PROM_WORD 0xA0 19c0644160STomasz Duszynski #define MS5611_PROM_WORDS_NB 8 20c0644160STomasz Duszynski 219690d81aSTomasz Duszynski enum { 229690d81aSTomasz Duszynski MS5611, 239690d81aSTomasz Duszynski MS5607, 249690d81aSTomasz Duszynski }; 259690d81aSTomasz Duszynski 26033691a9SGregor Boirie /* 27033691a9SGregor Boirie * OverSampling Rate descriptor. 28033691a9SGregor Boirie * Warning: cmd MUST be kept aligned on a word boundary (see 29033691a9SGregor Boirie * m5611_spi_read_adc_temp_and_pressure in ms5611_spi.c). 30033691a9SGregor Boirie */ 31033691a9SGregor Boirie struct ms5611_osr { 32033691a9SGregor Boirie unsigned long conv_usec; 33033691a9SGregor Boirie u8 cmd; 34033691a9SGregor Boirie unsigned short rate; 35033691a9SGregor Boirie }; 36033691a9SGregor Boirie 37c0644160STomasz Duszynski struct ms5611_state { 38c0644160STomasz Duszynski void *client; 39c0644160STomasz Duszynski struct mutex lock; 40c0644160STomasz Duszynski 41033691a9SGregor Boirie const struct ms5611_osr *pressure_osr; 42033691a9SGregor Boirie const struct ms5611_osr *temp_osr; 43033691a9SGregor Boirie 44*17f442e7SMitja Spes u16 prom[MS5611_PROM_WORDS_NB]; 45*17f442e7SMitja Spes 46dc19fa63SLars-Peter Clausen int (*reset)(struct ms5611_state *st); 47dc19fa63SLars-Peter Clausen int (*read_prom_word)(struct ms5611_state *st, int index, u16 *word); 48dc19fa63SLars-Peter Clausen int (*read_adc_temp_and_pressure)(struct ms5611_state *st, 49c0644160STomasz Duszynski s32 *temp, s32 *pressure); 50c0644160STomasz Duszynski 51*17f442e7SMitja Spes int (*compensate_temp_and_pressure)(struct ms5611_state *st, s32 *temp, 52*17f442e7SMitja Spes s32 *pressure); 53c0644160STomasz Duszynski }; 54c0644160STomasz Duszynski 55eac635ebSGrégor Boirie int ms5611_probe(struct iio_dev *indio_dev, struct device *dev, 56eac635ebSGrégor Boirie const char *name, int type); 57c0644160STomasz Duszynski 58c0644160STomasz Duszynski #endif /* _MS5611_H */ 59