Lines Matching +full:gain +full:- +full:milli

1 // SPDX-License-Identifier: GPL-2.0
8 * 7-bit I2C slave address: 0x57
205 mutex_lock(&isl29501->lock); in isl29501_register_read()
206 if (reg->msb) { in isl29501_register_read()
207 ret = i2c_smbus_read_byte_data(isl29501->client, reg->msb); in isl29501_register_read()
213 if (reg->lsb) { in isl29501_register_read()
214 ret = i2c_smbus_read_byte_data(isl29501->client, reg->lsb); in isl29501_register_read()
219 mutex_unlock(&isl29501->lock); in isl29501_register_read()
225 mutex_unlock(&isl29501->lock); in isl29501_register_read()
237 if (!reg->msb && value > U8_MAX) in isl29501_register_write()
238 return -ERANGE; in isl29501_register_write()
241 return -ERANGE; in isl29501_register_write()
243 mutex_lock(&isl29501->lock); in isl29501_register_write()
244 if (reg->msb) { in isl29501_register_write()
245 ret = i2c_smbus_write_byte_data(isl29501->client, in isl29501_register_write()
246 reg->msb, value >> 8); in isl29501_register_write()
251 ret = i2c_smbus_write_byte_data(isl29501->client, reg->lsb, value); in isl29501_register_write()
254 mutex_unlock(&isl29501->lock); in isl29501_register_write()
266 u32 value, gain, coeff, exp; in isl29501_read_ext() local
271 ret = isl29501_register_read(isl29501, reg, &gain); in isl29501_read_ext()
275 value = gain; in isl29501_read_ext()
292 return -EINVAL; in isl29501_read_ext()
318 return -EINVAL; in isl29501_set_shadow_coeff()
320 isl29501->shadow_coeffs[coeff] = val; in isl29501_set_shadow_coeff()
345 return -EINVAL; in isl29501_write_coeff()
399 return -ERANGE; in isl29501_write_ext()
412 return -ERANGE; in isl29501_write_ext()
427 corr = isl29501->shadow_coeffs[i]; in isl29501_write_ext()
431 dev_dbg(&isl29501->client->dev, in isl29501_write_ext()
446 corr = isl29501->shadow_coeffs[i]; in isl29501_write_ext()
463 return -EINVAL; in isl29501_write_ext()
510 .scan_index = -1,
516 .scan_index = -1,
523 .scan_index = -1,
530 .scan_index = -1,
543 ret = i2c_smbus_write_byte_data(isl29501->client, in isl29501_reset_registers()
547 dev_err(&isl29501->client->dev, in isl29501_reset_registers()
552 ret = i2c_smbus_write_byte_data(isl29501->client, in isl29501_reset_registers()
556 dev_err(&isl29501->client->dev, in isl29501_reset_registers()
566 ret = i2c_smbus_write_byte_data(isl29501->client, in isl29501_begin_acquisition()
570 dev_err(&isl29501->client->dev, in isl29501_begin_acquisition()
618 switch (chan->type) { in isl29501_get_raw()
652 return -EINVAL; in isl29501_get_raw()
663 switch (chan->type) { in isl29501_get_scale()
690 return -EINVAL; in isl29501_get_scale()
698 *val = isl29501_current_scale_table[current_scale - 1][0]; in isl29501_get_scale()
699 *val2 = isl29501_current_scale_table[current_scale - 1][1]; in isl29501_get_scale()
703 /* temperature = raw_temperature * 125 / 100000 (milli °C) */ in isl29501_get_scale()
709 return -EINVAL; in isl29501_get_scale()
717 switch (chan->type) { in isl29501_get_calibbias()
727 return -EINVAL; in isl29501_get_calibbias()
742 return -EINVAL; in isl29501_get_inttime()
762 /* freq = 1 / (0.000450 * (sample_time + 1) * 10^-6) */ in isl29501_get_freq()
792 return -EINVAL; in isl29501_read_raw()
800 switch (chan->type) { in isl29501_set_raw()
804 return -EINVAL; in isl29501_set_raw()
822 return -EINVAL; in isl29501_set_inttime()
831 if (chan->type != IIO_CURRENT) in isl29501_set_scale()
832 return -EINVAL; in isl29501_set_scale()
843 return -EINVAL; in isl29501_set_scale()
850 switch (chan->type) { in isl29501_set_calibbias()
860 return -EINVAL; in isl29501_set_calibbias()
870 /* sample_freq = 1 / (0.000450 * (sample_time + 1) * 10^-6) */ in isl29501_set_freq()
875 sample_time -= 1; in isl29501_set_freq()
878 return -ERANGE; in isl29501_set_freq()
901 return -EINVAL; in isl29501_write_raw()
915 ret = i2c_smbus_read_byte_data(isl29501->client, ISL29501_DEVICE_ID); in isl29501_init_chip()
917 dev_err(&isl29501->client->dev, "Error reading device id\n"); in isl29501_init_chip()
922 dev_err(&isl29501->client->dev, in isl29501_init_chip()
925 return -ENODEV; in isl29501_init_chip()
938 struct iio_dev *indio_dev = pf->indio_dev; in isl29501_trigger_handler()
940 const unsigned long *active_mask = indio_dev->active_scan_mask; in isl29501_trigger_handler()
941 u32 buffer[4] __aligned(8) = {}; /* 1x16-bit + naturally aligned ts */ in isl29501_trigger_handler()
946 iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp); in isl29501_trigger_handler()
947 iio_trigger_notify_done(indio_dev->trig); in isl29501_trigger_handler()
958 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*isl29501)); in isl29501_probe()
960 return -ENOMEM; in isl29501_probe()
965 isl29501->client = client; in isl29501_probe()
967 mutex_init(&isl29501->lock); in isl29501_probe()
973 indio_dev->modes = INDIO_DIRECT_MODE; in isl29501_probe()
974 indio_dev->channels = isl29501_channels; in isl29501_probe()
975 indio_dev->num_channels = ARRAY_SIZE(isl29501_channels); in isl29501_probe()
976 indio_dev->name = client->name; in isl29501_probe()
977 indio_dev->info = &isl29501_info; in isl29501_probe()
979 ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, in isl29501_probe()
984 dev_err(&client->dev, "unable to setup iio triggered buffer\n"); in isl29501_probe()
988 return devm_iio_device_register(&client->dev, indio_dev); in isl29501_probe()