ms5611.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef _MS5611_H
  9. #define _MS5611_H
  10. #include <linux/device.h>
  11. #include <linux/iio/iio.h>
  12. #include <linux/mutex.h>
  13. #define MS5611_RESET 0x1e
  14. #define MS5611_READ_ADC 0x00
  15. #define MS5611_READ_PROM_WORD 0xA0
  16. #define MS5611_PROM_WORDS_NB 8
  17. enum {
  18. MS5611,
  19. MS5607,
  20. };
  21. /*
  22. * OverSampling Rate descriptor.
  23. * Warning: cmd MUST be kept aligned on a word boundary (see
  24. * m5611_spi_read_adc_temp_and_pressure in ms5611_spi.c).
  25. */
  26. struct ms5611_osr {
  27. unsigned long conv_usec;
  28. u8 cmd;
  29. unsigned short rate;
  30. };
  31. struct ms5611_state {
  32. void *client;
  33. struct mutex lock;
  34. const struct ms5611_osr *pressure_osr;
  35. const struct ms5611_osr *temp_osr;
  36. u16 prom[MS5611_PROM_WORDS_NB];
  37. int (*reset)(struct ms5611_state *st);
  38. int (*read_prom_word)(struct ms5611_state *st, int index, u16 *word);
  39. int (*read_adc_temp_and_pressure)(struct ms5611_state *st,
  40. s32 *temp, s32 *pressure);
  41. int (*compensate_temp_and_pressure)(struct ms5611_state *st, s32 *temp,
  42. s32 *pressure);
  43. };
  44. int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
  45. const char *name, int type);
  46. #endif /* _MS5611_H */