linux/drivers/iio/light/opt4001.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2023 Axis Communications AB
 *
 * Datasheet: https://www.ti.com/lit/gpn/opt4001
 *
 * Device driver for the Texas Instruments OPT4001.
 */

#include <linux/bitfield.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>

/* OPT4001 register set */
#define OPT4001_LIGHT1_MSB
#define OPT4001_LIGHT1_LSB
#define OPT4001_CTRL
#define OPT4001_DEVICE_ID

/* OPT4001 register mask */
#define OPT4001_EXPONENT_MASK
#define OPT4001_MSB_MASK
#define OPT4001_LSB_MASK
#define OPT4001_COUNTER_MASK
#define OPT4001_CRC_MASK

/* OPT4001 device id mask */
#define OPT4001_DEVICE_ID_MASK

/* OPT4001 control registers mask */
#define OPT4001_CTRL_QWAKE_MASK
#define OPT4001_CTRL_RANGE_MASK
#define OPT4001_CTRL_CONV_TIME_MASK
#define OPT4001_CTRL_OPER_MODE_MASK
#define OPT4001_CTRL_LATCH_MASK
#define OPT4001_CTRL_INT_POL_MASK
#define OPT4001_CTRL_FAULT_COUNT

/* OPT4001 constants */
#define OPT4001_DEVICE_ID_VAL

/* OPT4001 operating modes */
#define OPT4001_CTRL_OPER_MODE_OFF
#define OPT4001_CTRL_OPER_MODE_FORCED
#define OPT4001_CTRL_OPER_MODE_ONE_SHOT
#define OPT4001_CTRL_OPER_MODE_CONTINUOUS

/* OPT4001 conversion control register definitions */
#define OPT4001_CTRL_CONVERSION_0_6MS
#define OPT4001_CTRL_CONVERSION_1MS
#define OPT4001_CTRL_CONVERSION_1_8MS
#define OPT4001_CTRL_CONVERSION_3_4MS
#define OPT4001_CTRL_CONVERSION_6_5MS
#define OPT4001_CTRL_CONVERSION_12_7MS
#define OPT4001_CTRL_CONVERSION_25MS
#define OPT4001_CTRL_CONVERSION_50MS
#define OPT4001_CTRL_CONVERSION_100MS
#define OPT4001_CTRL_CONVERSION_200MS
#define OPT4001_CTRL_CONVERSION_400MS
#define OPT4001_CTRL_CONVERSION_800MS

/* OPT4001 scale light level range definitions */
#define OPT4001_CTRL_LIGHT_SCALE_AUTO

/* OPT4001 default values */
#define OPT4001_DEFAULT_CONVERSION_TIME

/*
 * The different packaging of OPT4001 has different constants used when calculating
 * lux values.
 */
struct opt4001_chip_info {};

struct opt4001_chip {};

static const struct opt4001_chip_info opt4001_sot_5x3_info =;

static const struct opt4001_chip_info opt4001_picostar_info =;

static const int opt4001_int_time_available[][2] =;

/*
 * Conversion time is integration time + time to set register
 * this is used as integration time.
 */
static const int opt4001_int_time_reg[][2] =;

static int opt4001_als_time_to_index(const u32 als_integration_time)
{}

static u8 opt4001_calculate_crc(u8 exp, u32 mantissa, u8 count)
{}

static int opt4001_read_lux_value(struct iio_dev *indio_dev,
				  int *val, int *val2)
{}

static int opt4001_set_conf(struct opt4001_chip *chip)
{}

static int opt4001_power_down(struct opt4001_chip *chip)
{}

static void opt4001_chip_off_action(void *data)
{}

static const struct iio_chan_spec opt4001_channels[] =;

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

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

static int opt4001_read_available(struct iio_dev *indio_dev,
				  struct iio_chan_spec const *chan,
				  const int **vals, int *type, int *length,
				  long mask)
{}

static const struct iio_info opt4001_info_no_irq =;

static int opt4001_load_defaults(struct opt4001_chip *chip)
{}

static bool opt4001_readable_reg(struct device *dev, unsigned int reg)
{}

static bool opt4001_writable_reg(struct device *dev, unsigned int reg)
{}

static bool opt4001_volatile_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_config opt4001_regmap_config =;

static int opt4001_probe(struct i2c_client *client)
{}

/*
 * The compatible string determines which constants to use depending on
 * opt4001 packaging
 */
static const struct i2c_device_id opt4001_id[] =;
MODULE_DEVICE_TABLE(i2c, opt4001_id);

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

static struct i2c_driver opt4001_driver =;
module_i2c_driver();

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