Lines Matching +full:use +full:- +full:prox
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (c) 2016-2017 Brian Masney <masneyb@onstation.org>
10 * - http://www.intersil.com/content/dam/Intersil/documents/isl2/isl29028.pdf
11 * - http://www.intersil.com/content/dam/Intersil/documents/isl2/isl29030.pdf
106 return -EINVAL; in isl29028_find_prox_sleep_index()
112 struct device *dev = regmap_get_device(chip->regmap); in isl29028_set_proxim_sampling()
120 ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, in isl29028_set_proxim_sampling()
130 chip->prox_sampling_int = sampling_int; in isl29028_set_proxim_sampling()
131 chip->prox_sampling_frac = sampling_fract; in isl29028_set_proxim_sampling()
140 ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling_int, in isl29028_enable_proximity()
141 chip->prox_sampling_frac); in isl29028_enable_proximity()
145 ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, in isl29028_enable_proximity()
152 prox_index = isl29028_find_prox_sleep_index(chip->prox_sampling_int, in isl29028_enable_proximity()
153 chip->prox_sampling_frac); in isl29028_enable_proximity()
164 struct device *dev = regmap_get_device(chip->regmap); in isl29028_set_als_scale()
169 ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, in isl29028_set_als_scale()
177 chip->lux_scale = lux_scale; in isl29028_set_als_scale()
187 if (chip->als_ir_mode == mode) in isl29028_set_als_ir_mode()
190 ret = isl29028_set_als_scale(chip, chip->lux_scale); in isl29028_set_als_ir_mode()
196 ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, in isl29028_set_als_ir_mode()
202 ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, in isl29028_set_als_ir_mode()
207 ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, in isl29028_set_als_ir_mode()
212 return regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, in isl29028_set_als_ir_mode()
221 ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE, in isl29028_set_als_ir_mode()
230 chip->als_ir_mode = mode; in isl29028_set_als_ir_mode()
237 struct device *dev = regmap_get_device(chip->regmap); in isl29028_read_als_ir()
242 ret = regmap_read(chip->regmap, ISL29028_REG_ALSIR_L, &lsb); in isl29028_read_als_ir()
250 ret = regmap_read(chip->regmap, ISL29028_REG_ALSIR_U, &msb); in isl29028_read_als_ir()
263 static int isl29028_read_proxim(struct isl29028_chip *chip, int *prox) in isl29028_read_proxim() argument
265 struct device *dev = regmap_get_device(chip->regmap); in isl29028_read_proxim()
269 if (!chip->enable_prox) { in isl29028_read_proxim()
274 chip->enable_prox = true; in isl29028_read_proxim()
277 ret = regmap_read(chip->regmap, ISL29028_REG_PROX_DATA, &data); in isl29028_read_proxim()
284 *prox = data; in isl29028_read_proxim()
291 struct device *dev = regmap_get_device(chip->regmap); in isl29028_als_get()
311 if (chip->lux_scale == 125) in isl29028_als_get()
323 struct device *dev = regmap_get_device(chip->regmap); in isl29028_ir_get()
338 struct device *dev = regmap_get_device(chip->regmap); in isl29028_set_pm_runtime_busy()
359 struct device *dev = regmap_get_device(chip->regmap); in isl29028_write_raw()
366 mutex_lock(&chip->lock); in isl29028_write_raw()
368 ret = -EINVAL; in isl29028_write_raw()
369 switch (chan->type) { in isl29028_write_raw()
406 __func__, chan->type); in isl29028_write_raw()
410 mutex_unlock(&chip->lock); in isl29028_write_raw()
427 struct device *dev = regmap_get_device(chip->regmap); in isl29028_read_raw()
434 mutex_lock(&chip->lock); in isl29028_read_raw()
436 ret = -EINVAL; in isl29028_read_raw()
440 switch (chan->type) { in isl29028_read_raw()
460 if (chan->type != IIO_PROXIMITY) in isl29028_read_raw()
463 *val = chip->prox_sampling_int; in isl29028_read_raw()
464 *val2 = chip->prox_sampling_frac; in isl29028_read_raw()
468 if (chan->type != IIO_LIGHT) in isl29028_read_raw()
470 *val = chip->lux_scale; in isl29028_read_raw()
479 mutex_unlock(&chip->lock); in isl29028_read_raw()
534 struct device *dev = regmap_get_device(chip->regmap); in isl29028_clear_configure_reg()
537 ret = regmap_write(chip->regmap, ISL29028_REG_CONFIGURE, 0x0); in isl29028_clear_configure_reg()
542 chip->als_ir_mode = ISL29028_MODE_NONE; in isl29028_clear_configure_reg()
543 chip->enable_prox = false; in isl29028_clear_configure_reg()
565 .max_register = ISL29028_NUM_REGS - 1,
577 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); in isl29028_probe()
579 return -ENOMEM; in isl29028_probe()
584 mutex_init(&chip->lock); in isl29028_probe()
586 chip->regmap = devm_regmap_init_i2c(client, &isl29028_regmap_config); in isl29028_probe()
587 if (IS_ERR(chip->regmap)) { in isl29028_probe()
588 ret = PTR_ERR(chip->regmap); in isl29028_probe()
589 dev_err(&client->dev, "%s: Error %d initializing regmap\n", in isl29028_probe()
594 chip->enable_prox = false; in isl29028_probe()
595 chip->prox_sampling_int = 20; in isl29028_probe()
596 chip->prox_sampling_frac = 0; in isl29028_probe()
597 chip->lux_scale = 2000; in isl29028_probe()
599 ret = regmap_write(chip->regmap, ISL29028_REG_TEST1_MODE, 0x0); in isl29028_probe()
601 dev_err(&client->dev, in isl29028_probe()
607 ret = regmap_write(chip->regmap, ISL29028_REG_TEST2_MODE, 0x0); in isl29028_probe()
609 dev_err(&client->dev, in isl29028_probe()
619 indio_dev->info = &isl29028_info; in isl29028_probe()
620 indio_dev->channels = isl29028_channels; in isl29028_probe()
621 indio_dev->num_channels = ARRAY_SIZE(isl29028_channels); in isl29028_probe()
622 indio_dev->name = id->name; in isl29028_probe()
623 indio_dev->modes = INDIO_DIRECT_MODE; in isl29028_probe()
625 pm_runtime_enable(&client->dev); in isl29028_probe()
626 pm_runtime_set_autosuspend_delay(&client->dev, in isl29028_probe()
628 pm_runtime_use_autosuspend(&client->dev); in isl29028_probe()
632 dev_err(&client->dev, in isl29028_probe()
648 pm_runtime_disable(&client->dev); in isl29028_remove()
649 pm_runtime_set_suspended(&client->dev); in isl29028_remove()
650 pm_runtime_put_noidle(&client->dev); in isl29028_remove()
661 mutex_lock(&chip->lock); in isl29028_suspend()
665 mutex_unlock(&chip->lock); in isl29028_suspend()
694 { .compatible = "isl,isl29028", }, /* for backward compat., don't use */