ms5611.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * MS5611 pressure and temperature sensor driver
  4. *
  5. * Copyright (c) Tomasz Duszynski <[email protected]>
  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. struct regulator;
  14. #define MS5611_RESET 0x1e
  15. #define MS5611_READ_ADC 0x00
  16. #define MS5611_READ_PROM_WORD 0xA0
  17. #define MS5611_PROM_WORDS_NB 8
  18. enum {
  19. MS5611,
  20. MS5607,
  21. };
  22. /*
  23. * OverSampling Rate descriptor.
  24. * Warning: cmd MUST be kept aligned on a word boundary (see
  25. * m5611_spi_read_adc_temp_and_pressure in ms5611_spi.c).
  26. */
  27. struct ms5611_osr {
  28. unsigned long conv_usec;
  29. u8 cmd;
  30. unsigned short rate;
  31. };
  32. struct ms5611_state {
  33. void *client;
  34. struct mutex lock;
  35. const struct ms5611_osr *pressure_osr;
  36. const struct ms5611_osr *temp_osr;
  37. u16 prom[MS5611_PROM_WORDS_NB];
  38. int (*reset)(struct ms5611_state *st);
  39. int (*read_prom_word)(struct ms5611_state *st, int index, u16 *word);
  40. int (*read_adc_temp_and_pressure)(struct ms5611_state *st,
  41. s32 *temp, s32 *pressure);
  42. int (*compensate_temp_and_pressure)(struct ms5611_state *st, s32 *temp,
  43. s32 *pressure);
  44. struct regulator *vdd;
  45. };
  46. int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
  47. const char *name, int type);
  48. void ms5611_remove(struct iio_dev *indio_dev);
  49. #endif /* _MS5611_H */