Loading...
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
16struct 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
23enum {
24 MS5611,
25 MS5607,
26};
27
28struct ms5611_chip_info {
29 u16 prom[MS5611_PROM_WORDS_NB];
30
31 int (*temp_and_pressure_compensate)(struct ms5611_chip_info *chip_info,
32 s32 *temp, s32 *pressure);
33};
34
35/*
36 * OverSampling Rate descriptor.
37 * Warning: cmd MUST be kept aligned on a word boundary (see
38 * m5611_spi_read_adc_temp_and_pressure in ms5611_spi.c).
39 */
40struct ms5611_osr {
41 unsigned long conv_usec;
42 u8 cmd;
43 unsigned short rate;
44};
45
46struct ms5611_state {
47 void *client;
48 struct mutex lock;
49
50 const struct ms5611_osr *pressure_osr;
51 const struct ms5611_osr *temp_osr;
52
53 int (*reset)(struct device *dev);
54 int (*read_prom_word)(struct device *dev, int index, u16 *word);
55 int (*read_adc_temp_and_pressure)(struct device *dev,
56 s32 *temp, s32 *pressure);
57
58 struct ms5611_chip_info *chip_info;
59 struct regulator *vdd;
60};
61
62int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
63 const char *name, int type);
64int ms5611_remove(struct iio_dev *indio_dev);
65
66#endif /* _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
19struct 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
26enum {
27 MS5611,
28 MS5607,
29};
30
31struct ms5611_chip_info {
32 u16 prom[MS5611_PROM_WORDS_NB];
33
34 int (*temp_and_pressure_compensate)(struct ms5611_chip_info *chip_info,
35 s32 *temp, s32 *pressure);
36};
37
38/*
39 * OverSampling Rate descriptor.
40 * Warning: cmd MUST be kept aligned on a word boundary (see
41 * m5611_spi_read_adc_temp_and_pressure in ms5611_spi.c).
42 */
43struct ms5611_osr {
44 unsigned long conv_usec;
45 u8 cmd;
46 unsigned short rate;
47};
48
49struct ms5611_state {
50 void *client;
51 struct mutex lock;
52
53 const struct ms5611_osr *pressure_osr;
54 const struct ms5611_osr *temp_osr;
55
56 int (*reset)(struct device *dev);
57 int (*read_prom_word)(struct device *dev, int index, u16 *word);
58 int (*read_adc_temp_and_pressure)(struct device *dev,
59 s32 *temp, s32 *pressure);
60
61 struct ms5611_chip_info *chip_info;
62 struct regulator *vdd;
63};
64
65int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
66 const char* name, int type);
67int ms5611_remove(struct iio_dev *indio_dev);
68
69#endif /* _MS5611_H */