Lines Matching +full:sot +full:- +full:5 +full:x3

1 // SPDX-License-Identifier: GPL-2.0
39 #define OPT4001_CTRL_OPER_MODE_MASK GENMASK(5, 4)
51 #define OPT4001_CTRL_OPER_MODE_CONTINUOUS 0x3
57 #define OPT4001_CTRL_CONVERSION_3_4MS 0x3
93 .name = "opt4001-sot-5x3"
99 .name = "opt4001-picostar"
145 return -EINVAL; in opt4001_als_time_to_index()
166 struct device *dev = &chip->client->dev; in opt4001_read_lux_value()
178 ret = regmap_read(chip->regmap, OPT4001_LIGHT1_MSB, &light1); in opt4001_read_lux_value()
184 ret = regmap_read(chip->regmap, OPT4001_LIGHT1_LSB, &light2); in opt4001_read_lux_value()
198 return -EIO; in opt4001_read_lux_value()
201 lux_raw = lux_raw * chip->chip_info->mul; in opt4001_read_lux_value()
202 *val = div_u64_rem(lux_raw, chip->chip_info->div, val2); in opt4001_read_lux_value()
210 struct device *dev = &chip->client->dev; in opt4001_set_conf()
215 reg |= FIELD_PREP(OPT4001_CTRL_CONV_TIME_MASK, chip->int_time); in opt4001_set_conf()
218 ret = regmap_write(chip->regmap, OPT4001_CTRL, reg); in opt4001_set_conf()
227 struct device *dev = &chip->client->dev; in opt4001_power_down()
231 ret = regmap_read(chip->regmap, OPT4001_DEVICE_ID, &reg); in opt4001_power_down()
240 ret = regmap_write(chip->regmap, OPT4001_CTRL, reg); in opt4001_power_down()
274 *val2 = opt4001_int_time_reg[chip->int_time][0]; in opt4001_read_raw()
277 return -EINVAL; in opt4001_read_raw()
293 chip->int_time = int_time; in opt4001_write_raw()
296 return -EINVAL; in opt4001_write_raw()
313 return -EINVAL; in opt4001_read_available()
325 chip->int_time = OPT4001_DEFAULT_CONVERSION_TIME; in opt4001_load_defaults()
383 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); in opt4001_probe()
385 return -ENOMEM; in opt4001_probe()
389 ret = devm_regulator_get_enable(&client->dev, "vdd"); in opt4001_probe()
391 return dev_err_probe(&client->dev, ret, "Failed to enable vdd supply\n"); in opt4001_probe()
393 chip->regmap = devm_regmap_init_i2c(client, &opt4001_regmap_config); in opt4001_probe()
394 if (IS_ERR(chip->regmap)) in opt4001_probe()
395 return dev_err_probe(&client->dev, PTR_ERR(chip->regmap), in opt4001_probe()
397 chip->client = client; in opt4001_probe()
399 indio_dev->info = &opt4001_info_no_irq; in opt4001_probe()
401 ret = regmap_reinit_cache(chip->regmap, &opt4001_regmap_config); in opt4001_probe()
403 return dev_err_probe(&client->dev, ret, in opt4001_probe()
406 ret = regmap_read(chip->regmap, OPT4001_DEVICE_ID, &dev_id); in opt4001_probe()
408 return dev_err_probe(&client->dev, ret, in opt4001_probe()
413 dev_warn(&client->dev, "Device ID: %#04x unknown\n", dev_id); in opt4001_probe()
415 chip->chip_info = i2c_get_match_data(client); in opt4001_probe()
417 indio_dev->channels = opt4001_channels; in opt4001_probe()
418 indio_dev->num_channels = ARRAY_SIZE(opt4001_channels); in opt4001_probe()
419 indio_dev->modes = INDIO_DIRECT_MODE; in opt4001_probe()
420 indio_dev->name = chip->chip_info->name; in opt4001_probe()
424 return dev_err_probe(&client->dev, ret, in opt4001_probe()
427 ret = devm_add_action_or_reset(&client->dev, in opt4001_probe()
431 return dev_err_probe(&client->dev, ret, in opt4001_probe()
434 return devm_iio_device_register(&client->dev, indio_dev); in opt4001_probe()
442 { "opt4001-sot-5x3", (kernel_ulong_t)&opt4001_sot_5x3_info },
443 { "opt4001-picostar", (kernel_ulong_t)&opt4001_picostar_info },
449 { .compatible = "ti,opt4001-sot-5x3", .data = &opt4001_sot_5x3_info},
450 { .compatible = "ti,opt4001-picostar", .data = &opt4001_picostar_info},
465 MODULE_AUTHOR("Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com>");