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()
456 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) in tmp007_probe()
457 return -EOPNOTSUPP; in tmp007_probe()
460 dev_err(&client->dev, "TMP007 not found\n"); in tmp007_probe()
461 return -ENODEV; in tmp007_probe()
464 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in tmp007_probe()
466 return -ENOMEM; in tmp007_probe()
470 data->client = client; in tmp007_probe()
471 mutex_init(&data->lock); in tmp007_probe()
473 indio_dev->name = "tmp007"; in tmp007_probe()
474 indio_dev->modes = INDIO_DIRECT_MODE; in tmp007_probe()
475 indio_dev->info = &tmp007_info; in tmp007_probe()
477 indio_dev->channels = tmp007_channels; in tmp007_probe()
478 indio_dev->num_channels = ARRAY_SIZE(tmp007_channels); in tmp007_probe()
483 * 2. ALERT enable in tmp007_probe()
487 ret = i2c_smbus_read_word_swapped(data->client, TMP007_CONFIG); in tmp007_probe()
491 data->config = ret; in tmp007_probe()
492 data->config |= (TMP007_CONFIG_CONV_EN | TMP007_CONFIG_ALERT_EN | TMP007_CONFIG_TC_EN); in tmp007_probe()
494 ret = i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG, in tmp007_probe()
495 data->config); in tmp007_probe()
499 ret = devm_add_action_or_reset(&client->dev, tmp007_powerdown_action_cb, data); in tmp007_probe()
504 * Only the following flags can activate ALERT pin. Data conversion/validity flags in tmp007_probe()
514 ret = i2c_smbus_read_word_swapped(data->client, TMP007_STATUS_MASK); in tmp007_probe()
518 data->status_mask = ret; in tmp007_probe()
519 data->status_mask |= (TMP007_STATUS_OHF | TMP007_STATUS_OLF in tmp007_probe()
522 ret = i2c_smbus_write_word_swapped(data->client, TMP007_STATUS_MASK, data->status_mask); in tmp007_probe()
526 if (client->irq) { in tmp007_probe()
527 ret = devm_request_threaded_irq(&client->dev, client->irq, in tmp007_probe()
530 tmp007_id->name, indio_dev); in tmp007_probe()
532 dev_err(&client->dev, "irq request error %d\n", -ret); in tmp007_probe()
537 return devm_iio_device_register(&client->dev, indio_dev); in tmp007_probe()
553 return i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG, in tmp007_resume()
554 data->config | TMP007_CONFIG_CONV_EN); in tmp007_resume()