linux/drivers/iio/light/vl6180.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * vl6180.c - Support for STMicroelectronics VL6180 ALS, range and proximity
 * sensor
 *
 * Copyright 2017 Peter Meerwald-Stadler <[email protected]>
 * Copyright 2017 Manivannan Sadhasivam <[email protected]>
 *
 * IIO driver for VL6180 (7-bit I2C slave address 0x29)
 *
 * Range: 0 to 100mm
 * ALS: < 1 Lux up to 100 kLux
 * IR: 850nm
 *
 * TODO: irq, threshold events, continuous mode, hardware buffer
 */

#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/util_macros.h>

#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>

#define VL6180_DRV_NAME

/* Device identification register and value */
#define VL6180_MODEL_ID
#define VL6180_MODEL_ID_VAL

/* Configuration registers */
#define VL6180_INTR_CONFIG
#define VL6180_INTR_CLEAR
#define VL6180_OUT_OF_RESET
#define VL6180_HOLD
#define VL6180_RANGE_START
#define VL6180_ALS_START
#define VL6180_ALS_GAIN
#define VL6180_ALS_IT

/* Status registers */
#define VL6180_RANGE_STATUS
#define VL6180_ALS_STATUS
#define VL6180_INTR_STATUS

/* Result value registers */
#define VL6180_ALS_VALUE
#define VL6180_RANGE_VALUE
#define VL6180_RANGE_RATE

/* bits of the RANGE_START and ALS_START register */
#define VL6180_MODE_CONT
#define VL6180_STARTSTOP

/* bits of the INTR_STATUS and INTR_CONFIG register */
#define VL6180_ALS_READY
#define VL6180_RANGE_READY

/* bits of the INTR_CLEAR register */
#define VL6180_CLEAR_ERROR
#define VL6180_CLEAR_ALS
#define VL6180_CLEAR_RANGE

/* bits of the HOLD register */
#define VL6180_HOLD_ON

/* default value for the ALS_IT register */
#define VL6180_ALS_IT_100

/* values for the ALS_GAIN register */
#define VL6180_ALS_GAIN_1
#define VL6180_ALS_GAIN_1_25
#define VL6180_ALS_GAIN_1_67
#define VL6180_ALS_GAIN_2_5
#define VL6180_ALS_GAIN_5
#define VL6180_ALS_GAIN_10
#define VL6180_ALS_GAIN_20
#define VL6180_ALS_GAIN_40

struct vl6180_data {};

enum {};

/**
 * struct vl6180_chan_regs - Registers for accessing channels
 * @drdy_mask:			Data ready bit in status register
 * @start_reg:			Conversion start register
 * @value_reg:			Result value register
 * @word:			Register word length
 */
struct vl6180_chan_regs {};

static const struct vl6180_chan_regs vl6180_chan_regs_table[] =;

static int vl6180_read(struct i2c_client *client, u16 cmd, void *databuf,
		       u8 len)
{}

static int vl6180_read_byte(struct i2c_client *client, u16 cmd)
{}

static int vl6180_read_word(struct i2c_client *client, u16 cmd)
{}

static int vl6180_write_byte(struct i2c_client *client, u16 cmd, u8 val)
{}

static int vl6180_write_word(struct i2c_client *client, u16 cmd, u16 val)
{}

static int vl6180_measure(struct vl6180_data *data, int addr)
{}

static const struct iio_chan_spec vl6180_channels[] =;

/*
 * Available Ambient Light Sensor gain settings, 1/1000th, and
 * corresponding setting for the VL6180_ALS_GAIN register
 */
static const int vl6180_als_gain_tab[8] =;
static const u8 vl6180_als_gain_tab_bits[8] =;

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

static IIO_CONST_ATTR(als_gain_available, "1 1.25 1.67 2.5 5 10 20 40");

static struct attribute *vl6180_attributes[] =;

static const struct attribute_group vl6180_attribute_group =;

/* HOLD is needed before updating any config registers */
static int vl6180_hold(struct vl6180_data *data, bool hold)
{}

static int vl6180_set_als_gain(struct vl6180_data *data, int val, int val2)
{}

static int vl6180_set_it(struct vl6180_data *data, int val, int val2)
{}

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

static const struct iio_info vl6180_info =;

static int vl6180_init(struct vl6180_data *data)
{}

static int vl6180_probe(struct i2c_client *client)
{}

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

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

static struct i2c_driver vl6180_driver =;

module_i2c_driver();

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