Lines Matching +full:pressure +full:- +full:sensor

1 // SPDX-License-Identifier: GPL-2.0-only
3 * t5403.c - Support for EPCOS T5403 pressure/temperature sensor
7 * (7-bit I2C slave address 0x77)
9 * TODO: end-of-conversion irq
25 #define T5403_PT BIT(1) /* 0 .. pressure, 1 .. temperature measurement */
45 #define T5403_C_U16(i) le16_to_cpu(data->c[(i) - 1])
48 static int t5403_read(struct t5403_data *data, bool pressure) in t5403_read() argument
52 int ret = i2c_smbus_write_byte_data(data->client, T5403_COMMAND, in t5403_read()
53 (pressure ? (data->mode << T5403_MODE_SHIFT) : T5403_PT) | in t5403_read()
58 wait_time += pressure ? t5403_pressure_conv_ms[data->mode] : 2; in t5403_read()
62 return i2c_smbus_read_word_data(data->client, T5403_DATA); in t5403_read()
72 mutex_lock(&data->lock); in t5403_comp_pressure()
95 X += ((X - 75000) * (X - 75000) / 0x10000 - 9537) * in t5403_comp_pressure()
102 mutex_unlock(&data->lock); in t5403_comp_pressure()
111 mutex_lock(&data->lock); in t5403_comp_temp()
122 mutex_unlock(&data->lock); in t5403_comp_temp()
135 switch (chan->type) { in t5403_read_raw()
147 return -EINVAL; in t5403_read_raw()
151 *val2 = t5403_pressure_conv_ms[data->mode] * 1000; in t5403_read_raw()
154 return -EINVAL; in t5403_read_raw()
168 return -EINVAL; in t5403_write_raw()
171 mutex_lock(&data->lock); in t5403_write_raw()
172 data->mode = i; in t5403_write_raw()
173 mutex_unlock(&data->lock); in t5403_write_raw()
176 return -EINVAL; in t5403_write_raw()
178 return -EINVAL; in t5403_write_raw()
218 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA | in t5403_probe()
220 return -EOPNOTSUPP; in t5403_probe()
226 return -ENODEV; in t5403_probe()
228 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in t5403_probe()
230 return -ENOMEM; in t5403_probe()
233 data->client = client; in t5403_probe()
234 mutex_init(&data->lock); in t5403_probe()
237 indio_dev->info = &t5403_info; in t5403_probe()
238 indio_dev->name = id->name; in t5403_probe()
239 indio_dev->modes = INDIO_DIRECT_MODE; in t5403_probe()
240 indio_dev->channels = t5403_channels; in t5403_probe()
241 indio_dev->num_channels = ARRAY_SIZE(t5403_channels); in t5403_probe()
243 data->mode = T5403_MODE_STANDARD; in t5403_probe()
245 ret = i2c_smbus_read_i2c_block_data(data->client, T5403_CALIB_DATA, in t5403_probe()
246 sizeof(data->c), (u8 *) data->c); in t5403_probe()
250 return devm_iio_device_register(&client->dev, indio_dev); in t5403_probe()
269 MODULE_DESCRIPTION("EPCOS T5403 pressure/temperature sensor driver");