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