ms_sensors_i2c.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Measurements Specialties common sensor driver
  3. *
  4. * Copyright (c) 2015 Measurement-Specialties
  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. #ifndef _MS_SENSORS_I2C_H
  11. #define _MS_SENSORS_I2C_H
  12. #include <linux/i2c.h>
  13. #include <linux/mutex.h>
  14. #define MS_SENSORS_TP_PROM_WORDS_NB 7
  15. /**
  16. * struct ms_ht_dev - Humidity/Temperature sensor device structure
  17. * @client: i2c client
  18. * @lock: lock protecting the i2c conversion
  19. * @res_index: index to selected sensor resolution
  20. */
  21. struct ms_ht_dev {
  22. struct i2c_client *client;
  23. struct mutex lock;
  24. u8 res_index;
  25. };
  26. /**
  27. * struct ms_tp_dev - Temperature/Pressure sensor device structure
  28. * @client: i2c client
  29. * @lock: lock protecting the i2c conversion
  30. * @prom: array of PROM coefficients used for conversion. Added element
  31. * for CRC computation
  32. * @res_index: index to selected sensor resolution
  33. */
  34. struct ms_tp_dev {
  35. struct i2c_client *client;
  36. struct mutex lock;
  37. u16 prom[MS_SENSORS_TP_PROM_WORDS_NB + 1];
  38. u8 res_index;
  39. };
  40. int ms_sensors_reset(void *cli, u8 cmd, unsigned int delay);
  41. int ms_sensors_read_prom_word(void *cli, int cmd, u16 *word);
  42. int ms_sensors_convert_and_read(void *cli, u8 conv, u8 rd,
  43. unsigned int delay, u32 *adc);
  44. int ms_sensors_read_serial(struct i2c_client *client, u64 *sn);
  45. ssize_t ms_sensors_show_serial(struct ms_ht_dev *dev_data, char *buf);
  46. ssize_t ms_sensors_write_resolution(struct ms_ht_dev *dev_data, u8 i);
  47. ssize_t ms_sensors_show_battery_low(struct ms_ht_dev *dev_data, char *buf);
  48. ssize_t ms_sensors_show_heater(struct ms_ht_dev *dev_data, char *buf);
  49. ssize_t ms_sensors_write_heater(struct ms_ht_dev *dev_data,
  50. const char *buf, size_t len);
  51. int ms_sensors_ht_read_temperature(struct ms_ht_dev *dev_data,
  52. s32 *temperature);
  53. int ms_sensors_ht_read_humidity(struct ms_ht_dev *dev_data,
  54. u32 *humidity);
  55. int ms_sensors_tp_read_prom(struct ms_tp_dev *dev_data);
  56. int ms_sensors_read_temp_and_pressure(struct ms_tp_dev *dev_data,
  57. int *temperature,
  58. unsigned int *pressure);
  59. #endif /* _MS_SENSORS_I2C_H */