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