linux/drivers/iio/light/ltr390.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * IIO driver for Lite-On LTR390 ALS and UV sensor
 * (7-bit I2C slave address 0x53)
 *
 * Based on the work of:
 *   Shreeya Patel and Shi Zhigang (LTRF216 Driver)
 *
 * Copyright (C) 2023 Anshul Dalal <[email protected]>
 *
 * Datasheet:
 *   https://optoelectronics.liteon.com/upload/download/DS86-2015-0004/LTR-390UV_Final_%20DS_V1%201.pdf
 *
 * TODO:
 *   - Support for configurable gain and resolution
 *   - Sensor suspend/resume support
 *   - Add support for reading the ALS
 *   - Interrupt support
 */

#include <linux/i2c.h>
#include <linux/math.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regmap.h>

#include <linux/iio/iio.h>

#include <asm/unaligned.h>

#define LTR390_MAIN_CTRL
#define LTR390_PART_ID
#define LTR390_UVS_DATA

#define LTR390_SW_RESET
#define LTR390_UVS_MODE
#define LTR390_SENSOR_ENABLE

#define LTR390_PART_NUMBER_ID

/*
 * At 20-bit resolution (integration time: 400ms) and 18x gain, 2300 counts of
 * the sensor are equal to 1 UV Index [Datasheet Page#8].
 *
 * For the default resolution of 18-bit (integration time: 100ms) and default
 * gain of 3x, the counts/uvi are calculated as follows:
 * 2300 / ((3/18) * (100/400)) = 95.83
 */
#define LTR390_COUNTS_PER_UVI

/*
 * Window Factor is needed when the device is under Window glass with coated
 * tinted ink. This is to compensate for the light loss due to the lower
 * transmission rate of the window glass and helps * in calculating lux.
 */
#define LTR390_WINDOW_FACTOR

struct ltr390_data {};

static const struct regmap_config ltr390_regmap_config =;

static int ltr390_register_read(struct ltr390_data *data, u8 register_address)
{}

static int ltr390_read_raw(struct iio_dev *iio_device,
			   struct iio_chan_spec const *chan, int *val,
			   int *val2, long mask)
{}

static const struct iio_info ltr390_info =;

static const struct iio_chan_spec ltr390_channel =;

static int ltr390_probe(struct i2c_client *client)
{}

static const struct i2c_device_id ltr390_id[] =;
MODULE_DEVICE_TABLE(i2c, ltr390_id);

static const struct of_device_id ltr390_of_table[] =;
MODULE_DEVICE_TABLE(of, ltr390_of_table);

static struct i2c_driver ltr390_driver =;
module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();