Lines Matching +full:cmd +full:- +full:cnt +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
3 * tsys01.c - Support for Measurement-Specialties tsys01 temperature sensor
5 * Copyright (c) 2015 Measurement-Specialties
8 * http://www.meas-spec.com/downloads/TSYS01_Digital_Temperature_Sensor.pdf
34 int (*reset)(void *cli, u8 cmd, unsigned int delay);
37 int (*read_prom_word)(void *cli, int cmd, u16 *word);
43 static const int coeff_mul[] = { -1500000, 1000000, -2000000,
44 4000000, -2000000 };
54 mutex_lock(&dev_data->lock); in tsys01_read_temperature()
55 ret = dev_data->convert_and_read(dev_data->client, in tsys01_read_temperature()
58 mutex_unlock(&dev_data->lock); in tsys01_read_temperature()
65 for (i = 4; i > 0; i--) { in tsys01_read_temperature()
67 (s64)dev_data->prom[5 - i]; in tsys01_read_temperature()
72 temp += coeff_mul[0] * (s64)dev_data->prom[5]; in tsys01_read_temperature()
89 switch (channel->type) { in tsys01_read_raw()
98 return -EINVAL; in tsys01_read_raw()
101 return -EINVAL; in tsys01_read_raw()
118 u8 cnt; in tsys01_crc_valid() local
121 for (cnt = 0; cnt < TSYS01_PROM_WORDS_NB; cnt++) in tsys01_crc_valid()
135 ret = dev_data->read_prom_word(dev_data->client, in tsys01_read_prom()
137 &dev_data->prom[i]); in tsys01_read_prom()
141 ret = sprintf(ptr, "0x%04x ", dev_data->prom[i]); in tsys01_read_prom()
145 if (!tsys01_crc_valid(dev_data->prom)) { in tsys01_read_prom()
146 dev_err(&indio_dev->dev, "prom crc check error\n"); in tsys01_read_prom()
147 return -ENODEV; in tsys01_read_prom()
150 dev_info(&indio_dev->dev, "PROM coefficients : %s\n", buf); in tsys01_read_prom()
160 mutex_init(&dev_data->lock); in tsys01_probe()
162 indio_dev->info = &tsys01_info; in tsys01_probe()
163 indio_dev->name = dev->driver->name; in tsys01_probe()
164 indio_dev->modes = INDIO_DIRECT_MODE; in tsys01_probe()
165 indio_dev->channels = tsys01_channels; in tsys01_probe()
166 indio_dev->num_channels = ARRAY_SIZE(tsys01_channels); in tsys01_probe()
168 ret = dev_data->reset(dev_data->client, TSYS01_RESET, 3000); in tsys01_probe()
184 if (!i2c_check_functionality(client->adapter, in tsys01_i2c_probe()
188 dev_err(&client->dev, in tsys01_i2c_probe()
190 return -EOPNOTSUPP; in tsys01_i2c_probe()
193 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*dev_data)); in tsys01_i2c_probe()
195 return -ENOMEM; in tsys01_i2c_probe()
198 dev_data->client = client; in tsys01_i2c_probe()
199 dev_data->reset = ms_sensors_reset; in tsys01_i2c_probe()
200 dev_data->read_prom_word = ms_sensors_read_prom_word; in tsys01_i2c_probe()
201 dev_data->convert_and_read = ms_sensors_convert_and_read; in tsys01_i2c_probe()
205 return tsys01_probe(indio_dev, &client->dev); in tsys01_i2c_probe()
224 .name = "tsys01",
231 MODULE_DESCRIPTION("Measurement-Specialties tsys01 temperature driver");
232 MODULE_AUTHOR("William Markezana <william.markezana@meas-spec.com>");