ms5611.h 1.5 KB

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