Lines Matching +full:alert +full:- +full:celsius
1 // SPDX-License-Identifier: GPL-2.0-only
3 * tmp007.c - Support for TI TMP007 IR thermopile sensor with integrated math engine
7 * Driver for the Texas Instruments I2C 16-bit IR thermopile sensor
9 * (7-bit I2C slave address (0x40 - 0x47), changeable via ADR pins)
78 while (tries-- > 0) { in tmp007_read_temperature()
79 ret = i2c_smbus_read_word_swapped(data->client, in tmp007_read_temperature()
90 return -EIO; in tmp007_read_temperature()
92 return i2c_smbus_read_word_swapped(data->client, reg); in tmp007_read_temperature()
97 return i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG, in tmp007_powerdown()
98 data->config & ~TMP007_CONFIG_CONV_EN); in tmp007_powerdown()
111 switch (channel->channel2) { in tmp007_read_raw()
112 case IIO_MOD_TEMP_AMBIENT: /* LSB: 0.03125 degree Celsius */ in tmp007_read_raw()
113 ret = i2c_smbus_read_word_swapped(data->client, TMP007_TDIE); in tmp007_read_raw()
123 return -EINVAL; in tmp007_read_raw()
135 conv_rate = (data->config & TMP007_CONFIG_CR_MASK) in tmp007_read_raw()
142 return -EINVAL; in tmp007_read_raw()
158 tmp = data->config & ~TMP007_CONFIG_CR_MASK; in tmp007_write_raw()
161 return i2c_smbus_write_word_swapped(data->client, in tmp007_write_raw()
163 data->config = tmp); in tmp007_write_raw()
168 return -EINVAL; in tmp007_write_raw()
177 ret = i2c_smbus_read_word_swapped(data->client, TMP007_STATUS); in tmp007_interrupt_handler()
225 switch (chan->channel2) { in tmp007_write_event_config()
239 return -EINVAL; in tmp007_write_event_config()
242 mutex_lock(&data->lock); in tmp007_write_event_config()
243 ret = i2c_smbus_read_word_swapped(data->client, TMP007_STATUS_MASK); in tmp007_write_event_config()
244 mutex_unlock(&data->lock); in tmp007_write_event_config()
253 return i2c_smbus_write_word_swapped(data->client, TMP007_STATUS_MASK, in tmp007_write_event_config()
254 data->status_mask = ret); in tmp007_write_event_config()
264 switch (chan->channel2) { in tmp007_read_event_config()
278 return -EINVAL; in tmp007_read_event_config()
281 return !!(data->status_mask & mask); in tmp007_read_event_config()
293 switch (chan->channel2) { in tmp007_read_thresh()
294 case IIO_MOD_TEMP_AMBIENT: /* LSB: 0.5 degree Celsius */ in tmp007_read_thresh()
307 return -EINVAL; in tmp007_read_thresh()
310 ret = i2c_smbus_read_word_swapped(data->client, reg); in tmp007_read_thresh()
328 switch (chan->channel2) { in tmp007_write_thresh()
342 return -EINVAL; in tmp007_write_thresh()
345 /* Full scale threshold value is +/- 256 degree Celsius */ in tmp007_write_thresh()
346 if (val < -256 || val > 255) in tmp007_write_thresh()
347 return -EINVAL; in tmp007_write_thresh()
350 return i2c_smbus_write_word_swapped(data->client, reg, (val << 7)); in tmp007_write_thresh()
449 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) in tmp007_probe()
450 return -EOPNOTSUPP; in tmp007_probe()
453 dev_err(&client->dev, "TMP007 not found\n"); in tmp007_probe()
454 return -ENODEV; in tmp007_probe()
457 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in tmp007_probe()
459 return -ENOMEM; in tmp007_probe()
463 data->client = client; in tmp007_probe()
464 mutex_init(&data->lock); in tmp007_probe()
466 indio_dev->name = "tmp007"; in tmp007_probe()
467 indio_dev->modes = INDIO_DIRECT_MODE; in tmp007_probe()
468 indio_dev->info = &tmp007_info; in tmp007_probe()
470 indio_dev->channels = tmp007_channels; in tmp007_probe()
471 indio_dev->num_channels = ARRAY_SIZE(tmp007_channels); in tmp007_probe()
476 * 2. ALERT enable in tmp007_probe()
480 ret = i2c_smbus_read_word_swapped(data->client, TMP007_CONFIG); in tmp007_probe()
484 data->config = ret; in tmp007_probe()
485 data->config |= (TMP007_CONFIG_CONV_EN | TMP007_CONFIG_ALERT_EN | TMP007_CONFIG_TC_EN); in tmp007_probe()
487 ret = i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG, in tmp007_probe()
488 data->config); in tmp007_probe()
493 * Only the following flags can activate ALERT pin. Data conversion/validity flags in tmp007_probe()
503 ret = i2c_smbus_read_word_swapped(data->client, TMP007_STATUS_MASK); in tmp007_probe()
507 data->status_mask = ret; in tmp007_probe()
508 data->status_mask |= (TMP007_STATUS_OHF | TMP007_STATUS_OLF in tmp007_probe()
511 ret = i2c_smbus_write_word_swapped(data->client, TMP007_STATUS_MASK, data->status_mask); in tmp007_probe()
515 if (client->irq) { in tmp007_probe()
516 ret = devm_request_threaded_irq(&client->dev, client->irq, in tmp007_probe()
519 tmp007_id->name, indio_dev); in tmp007_probe()
521 dev_err(&client->dev, "irq request error %d\n", -ret); in tmp007_probe()
559 return i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG, in tmp007_resume()
560 data->config | TMP007_CONFIG_CONV_EN); in tmp007_resume()