Lines Matching +full:ltr +full:- +full:390 +full:uv_final_
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * IIO driver for Lite-On LTR390 ALS and UV sensor
4 * (7-bit I2C slave address 0x53)
12 …* https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201…
15 * - Support for configurable gain and resolution
16 * - Sensor suspend/resume support
17 * - Add support for reading the ALS
18 * - Interrupt support
52 * At 20-bit resolution (integration time: 400ms) and 18x gain, 2300 counts of
55 * For the default resolution of 18-bit (integration time: 100ms) and default
92 struct device *dev = &data->client->dev; in ltr390_register_read()
96 ret = regmap_bulk_read(data->regmap, register_address, recieve_buffer, in ltr390_register_read()
110 if (data->mode == mode) in ltr390_set_mode()
115 ret = regmap_clear_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_UVS_MODE); in ltr390_set_mode()
119 ret = regmap_set_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_UVS_MODE); in ltr390_set_mode()
126 data->mode = mode; in ltr390_set_mode()
135 return DIV_ROUND_CLOSEST(23 * data->gain * data->int_time_us, 10 * orig_gain * orig_int_time); in ltr390_counts_per_uvi()
145 guard(mutex)(&data->lock); in ltr390_read_raw()
148 switch (chan->type) { in ltr390_read_raw()
170 return -EINVAL; in ltr390_read_raw()
175 switch (chan->type) { in ltr390_read_raw()
183 *val2 = data->gain * data->int_time_us; in ltr390_read_raw()
187 return -EINVAL; in ltr390_read_raw()
191 *val = data->int_time_us; in ltr390_read_raw()
195 return -EINVAL; in ltr390_read_raw()
230 guard(mutex)(&data->lock); in ltr390_set_gain()
231 ret = regmap_update_bits(data->regmap, in ltr390_set_gain()
237 data->gain = ltr390_gain_map[idx]; in ltr390_set_gain()
241 return -EINVAL; in ltr390_set_gain()
252 guard(mutex)(&data->lock); in ltr390_set_int_time()
253 ret = regmap_update_bits(data->regmap, in ltr390_set_int_time()
260 data->int_time_us = ltr390_int_time_map_us[idx]; in ltr390_set_int_time()
264 return -EINVAL; in ltr390_set_int_time()
282 return -EINVAL; in ltr390_read_avail()
294 return -EINVAL; in ltr390_write_raw()
300 return -EINVAL; in ltr390_write_raw()
305 return -EINVAL; in ltr390_write_raw()
322 dev = &client->dev; in ltr390_probe()
325 return -ENOMEM; in ltr390_probe()
329 data->regmap = devm_regmap_init_i2c(client, <r390_regmap_config); in ltr390_probe()
330 if (IS_ERR(data->regmap)) in ltr390_probe()
331 return dev_err_probe(dev, PTR_ERR(data->regmap), in ltr390_probe()
334 data->client = client; in ltr390_probe()
336 data->int_time_us = 100000; in ltr390_probe()
338 data->gain = 3; in ltr390_probe()
340 data->mode = LTR390_SET_ALS_MODE; in ltr390_probe()
342 mutex_init(&data->lock); in ltr390_probe()
344 indio_dev->info = <r390_info; in ltr390_probe()
345 indio_dev->channels = ltr390_channels; in ltr390_probe()
346 indio_dev->num_channels = ARRAY_SIZE(ltr390_channels); in ltr390_probe()
347 indio_dev->name = "ltr390"; in ltr390_probe()
349 ret = regmap_read(data->regmap, LTR390_PART_ID, &part_number); in ltr390_probe()
359 regmap_set_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_SW_RESET); in ltr390_probe()
364 ret = regmap_set_bits(data->regmap, LTR390_MAIN_CTRL, LTR390_SENSOR_ENABLE); in ltr390_probe()
394 MODULE_DESCRIPTION("Lite-On LTR390 ALS and UV sensor Driver");