Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * MS5611 pressure and temperature sensor driver
0004  *
0005  * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com>
0006  *
0007  */
0008 
0009 #ifndef _MS5611_H
0010 #define _MS5611_H
0011 
0012 #include <linux/device.h>
0013 #include <linux/iio/iio.h>
0014 #include <linux/mutex.h>
0015 
0016 struct regulator;
0017 
0018 #define MS5611_RESET            0x1e
0019 #define MS5611_READ_ADC         0x00
0020 #define MS5611_READ_PROM_WORD       0xA0
0021 #define MS5611_PROM_WORDS_NB        8
0022 
0023 enum {
0024     MS5611,
0025     MS5607,
0026 };
0027 
0028 struct ms5611_chip_info {
0029     u16 prom[MS5611_PROM_WORDS_NB];
0030 
0031     int (*temp_and_pressure_compensate)(struct ms5611_chip_info *chip_info,
0032                         s32 *temp, s32 *pressure);
0033 };
0034 
0035 /*
0036  * OverSampling Rate descriptor.
0037  * Warning: cmd MUST be kept aligned on a word boundary (see
0038  * m5611_spi_read_adc_temp_and_pressure in ms5611_spi.c).
0039  */
0040 struct ms5611_osr {
0041     unsigned long conv_usec;
0042     u8 cmd;
0043     unsigned short rate;
0044 };
0045 
0046 struct ms5611_state {
0047     void *client;
0048     struct mutex lock;
0049 
0050     const struct ms5611_osr *pressure_osr;
0051     const struct ms5611_osr *temp_osr;
0052 
0053     int (*reset)(struct ms5611_state *st);
0054     int (*read_prom_word)(struct ms5611_state *st, int index, u16 *word);
0055     int (*read_adc_temp_and_pressure)(struct ms5611_state *st,
0056                       s32 *temp, s32 *pressure);
0057 
0058     struct ms5611_chip_info *chip_info;
0059     struct regulator *vdd;
0060 };
0061 
0062 int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
0063          const char *name, int type);
0064 void ms5611_remove(struct iio_dev *indio_dev);
0065 
0066 #endif /* _MS5611_H */