Lines Matching refs:isl29501

197 static int isl29501_register_read(struct isl29501_private *isl29501,  in isl29501_register_read()  argument
205 mutex_lock(&isl29501->lock); in isl29501_register_read()
207 ret = i2c_smbus_read_byte_data(isl29501->client, reg->msb); 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()
230 static u32 isl29501_register_write(struct isl29501_private *isl29501, in isl29501_register_write() argument
251 mutex_lock(&isl29501->lock); in isl29501_register_write()
253 ret = i2c_smbus_write_byte_data(isl29501->client, in isl29501_register_write()
259 ret = i2c_smbus_write_byte_data(isl29501->client, reg->lsb, lsb); in isl29501_register_write()
262 mutex_unlock(&isl29501->lock); in isl29501_register_write()
271 struct isl29501_private *isl29501 = iio_priv(indio_dev); in isl29501_read_ext() local
279 ret = isl29501_register_read(isl29501, reg, &gain); in isl29501_read_ext()
289 ret = isl29501_register_read(isl29501, REG_PHASE_EXP, &exp); in isl29501_read_ext()
293 ret = isl29501_register_read(isl29501, reg, &coeff); in isl29501_read_ext()
306 static int isl29501_set_shadow_coeff(struct isl29501_private *isl29501, in isl29501_set_shadow_coeff() argument
328 isl29501->shadow_coeffs[coeff] = val; in isl29501_set_shadow_coeff()
333 static int isl29501_write_coeff(struct isl29501_private *isl29501, in isl29501_write_coeff() argument
356 return isl29501_register_write(isl29501, reg, val); in isl29501_write_coeff()
393 struct isl29501_private *isl29501 = iio_priv(indio_dev); in isl29501_write_ext() local
409 ret = isl29501_register_write(isl29501, reg, val); in isl29501_write_ext()
423 ret = isl29501_set_shadow_coeff(isl29501, reg, val); in isl29501_write_ext()
435 corr = isl29501->shadow_coeffs[i]; in isl29501_write_ext()
439 dev_dbg(&isl29501->client->dev, in isl29501_write_ext()
454 corr = isl29501->shadow_coeffs[i]; in isl29501_write_ext()
460 ret = isl29501_write_coeff(isl29501, i, mantissa); in isl29501_write_ext()
465 ret = isl29501_register_write(isl29501, REG_PHASE_EXP, max_exp); in isl29501_write_ext()
547 static int isl29501_reset_registers(struct isl29501_private *isl29501) in isl29501_reset_registers() argument
551 ret = i2c_smbus_write_byte_data(isl29501->client, in isl29501_reset_registers()
555 dev_err(&isl29501->client->dev, in isl29501_reset_registers()
560 ret = i2c_smbus_write_byte_data(isl29501->client, in isl29501_reset_registers()
564 dev_err(&isl29501->client->dev, in isl29501_reset_registers()
570 static int isl29501_begin_acquisition(struct isl29501_private *isl29501) in isl29501_begin_acquisition() argument
574 ret = i2c_smbus_write_byte_data(isl29501->client, in isl29501_begin_acquisition()
578 dev_err(&isl29501->client->dev, in isl29501_begin_acquisition()
620 static int isl29501_get_raw(struct isl29501_private *isl29501, in isl29501_get_raw() argument
628 ret = isl29501_register_read(isl29501, REG_DISTANCE, raw); in isl29501_get_raw()
634 ret = isl29501_register_read(isl29501, in isl29501_get_raw()
642 ret = isl29501_register_read(isl29501, REG_PHASE, raw); in isl29501_get_raw()
648 ret = isl29501_register_read(isl29501, REG_EMITTER_DAC, raw); in isl29501_get_raw()
654 ret = isl29501_register_read(isl29501, REG_TEMPERATURE, raw); in isl29501_get_raw()
664 static int isl29501_get_scale(struct isl29501_private *isl29501, in isl29501_get_scale() argument
691 ret = isl29501_register_read(isl29501, in isl29501_get_scale()
721 static int isl29501_get_calibbias(struct isl29501_private *isl29501, in isl29501_get_calibbias() argument
727 return isl29501_register_read(isl29501, in isl29501_get_calibbias()
731 return isl29501_register_read(isl29501, in isl29501_get_calibbias()
739 static int isl29501_get_inttime(struct isl29501_private *isl29501, in isl29501_get_inttime() argument
745 ret = isl29501_register_read(isl29501, REG_INT_TIME, &inttime); in isl29501_get_inttime()
758 static int isl29501_get_freq(struct isl29501_private *isl29501, in isl29501_get_freq() argument
766 ret = isl29501_register_read(isl29501, REG_SAMPLE_TIME, &sample_time); in isl29501_get_freq()
786 struct isl29501_private *isl29501 = iio_priv(indio_dev); in isl29501_read_raw() local
790 return isl29501_get_raw(isl29501, chan, val); in isl29501_read_raw()
792 return isl29501_get_scale(isl29501, chan, val, val2); in isl29501_read_raw()
794 return isl29501_get_inttime(isl29501, val, val2); in isl29501_read_raw()
796 return isl29501_get_freq(isl29501, val, val2); in isl29501_read_raw()
798 return isl29501_get_calibbias(isl29501, chan, val); in isl29501_read_raw()
804 static int isl29501_set_raw(struct isl29501_private *isl29501, in isl29501_set_raw() argument
810 return isl29501_register_write(isl29501, REG_EMITTER_DAC, raw); in isl29501_set_raw()
816 static int isl29501_set_inttime(struct isl29501_private *isl29501, in isl29501_set_inttime() argument
824 return isl29501_register_write(isl29501, in isl29501_set_inttime()
833 static int isl29501_set_scale(struct isl29501_private *isl29501, in isl29501_set_scale() argument
845 return isl29501_register_write(isl29501, in isl29501_set_scale()
854 static int isl29501_set_calibbias(struct isl29501_private *isl29501, in isl29501_set_calibbias() argument
860 return isl29501_register_write(isl29501, in isl29501_set_calibbias()
864 return isl29501_register_write(isl29501, in isl29501_set_calibbias()
872 static int isl29501_set_freq(struct isl29501_private *isl29501, in isl29501_set_freq() argument
888 return isl29501_register_write(isl29501, REG_SAMPLE_TIME, sample_time); in isl29501_set_freq()
895 struct isl29501_private *isl29501 = iio_priv(indio_dev); in isl29501_write_raw() local
899 return isl29501_set_raw(isl29501, chan, val); in isl29501_write_raw()
901 return isl29501_set_inttime(isl29501, val, val2); in isl29501_write_raw()
903 return isl29501_set_freq(isl29501, val, val2); in isl29501_write_raw()
905 return isl29501_set_scale(isl29501, chan, val, val2); in isl29501_write_raw()
907 return isl29501_set_calibbias(isl29501, chan, val); in isl29501_write_raw()
919 static int isl29501_init_chip(struct isl29501_private *isl29501) in isl29501_init_chip() argument
923 ret = i2c_smbus_read_byte_data(isl29501->client, ISL29501_DEVICE_ID); in isl29501_init_chip()
925 dev_err(&isl29501->client->dev, "Error reading device id\n"); in isl29501_init_chip()
930 dev_err(&isl29501->client->dev, in isl29501_init_chip()
936 ret = isl29501_reset_registers(isl29501); in isl29501_init_chip()
940 return isl29501_begin_acquisition(isl29501); in isl29501_init_chip()
947 struct isl29501_private *isl29501 = iio_priv(indio_dev); in isl29501_trigger_handler() local
952 isl29501_register_read(isl29501, REG_DISTANCE, buffer); in isl29501_trigger_handler()
964 struct isl29501_private *isl29501; in isl29501_probe() local
967 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*isl29501)); in isl29501_probe()
971 isl29501 = iio_priv(indio_dev); in isl29501_probe()
974 isl29501->client = client; in isl29501_probe()
976 mutex_init(&isl29501->lock); in isl29501_probe()
978 ret = isl29501_init_chip(isl29501); in isl29501_probe()