linux/drivers/iio/light/zopt2201.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * zopt2201.c - Support for IDT ZOPT2201 ambient light and UV B sensor
 *
 * Copyright 2017 Peter Meerwald-Stadler <[email protected]>
 *
 * Datasheet: https://www.idt.com/document/dst/zopt2201-datasheet
 * 7-bit I2C slave addresses 0x53 (default) or 0x52 (programmed)
 *
 * TODO: interrupt support, ALS/UVB raw mode
 */

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

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

#include <linux/unaligned.h>

#define ZOPT2201_DRV_NAME

/* Registers */
#define ZOPT2201_MAIN_CTRL
#define ZOPT2201_LS_MEAS_RATE
#define ZOPT2201_LS_GAIN
#define ZOPT2201_PART_ID
#define ZOPT2201_MAIN_STATUS
#define ZOPT2201_ALS_DATA
#define ZOPT2201_UVB_DATA
#define ZOPT2201_UV_COMP_DATA
#define ZOPT2201_COMP_DATA
#define ZOPT2201_INT_CFG
#define ZOPT2201_INT_PST

#define ZOPT2201_MAIN_CTRL_LS_MODE
#define ZOPT2201_MAIN_CTRL_LS_EN

/* Values for ZOPT2201_LS_MEAS_RATE resolution / bit width */
#define ZOPT2201_MEAS_RES_20BIT
#define ZOPT2201_MEAS_RES_19BIT
#define ZOPT2201_MEAS_RES_18BIT
#define ZOPT2201_MEAS_RES_17BIT
#define ZOPT2201_MEAS_RES_16BIT
#define ZOPT2201_MEAS_RES_13BIT
#define ZOPT2201_MEAS_RES_SHIFT

/* Values for ZOPT2201_LS_MEAS_RATE measurement rate */
#define ZOPT2201_MEAS_FREQ_25MS
#define ZOPT2201_MEAS_FREQ_50MS
#define ZOPT2201_MEAS_FREQ_100MS
#define ZOPT2201_MEAS_FREQ_200MS
#define ZOPT2201_MEAS_FREQ_500MS
#define ZOPT2201_MEAS_FREQ_1000MS
#define ZOPT2201_MEAS_FREQ_2000MS

/* Values for ZOPT2201_LS_GAIN */
#define ZOPT2201_LS_GAIN_1
#define ZOPT2201_LS_GAIN_3
#define ZOPT2201_LS_GAIN_6
#define ZOPT2201_LS_GAIN_9
#define ZOPT2201_LS_GAIN_18

/* Values for ZOPT2201_MAIN_STATUS */
#define ZOPT2201_MAIN_STATUS_POWERON
#define ZOPT2201_MAIN_STATUS_INT
#define ZOPT2201_MAIN_STATUS_DRDY

#define ZOPT2201_PART_NUMBER

struct zopt2201_data {};

static const struct {} zopt2201_gain_als[] =;

static const struct {} zopt2201_gain_uvb[] =;

static const struct {} zopt2201_resolution[] =;

static const struct {} zopt2201_scale_als[] =;

static const struct {} zopt2201_scale_uvb[] =;

static int zopt2201_enable_mode(struct zopt2201_data *data, bool uvb_mode)
{}

static int zopt2201_read(struct zopt2201_data *data, u8 reg)
{}

static const struct iio_chan_spec zopt2201_channels[] =;

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

static int zopt2201_set_resolution(struct zopt2201_data *data, u8 res)
{}

static int zopt2201_write_resolution(struct zopt2201_data *data,
				     int val, int val2)
{}

static int zopt2201_set_gain(struct zopt2201_data *data, u8 gain)
{}

static int zopt2201_write_scale_als_by_idx(struct zopt2201_data *data, int idx)
{}

static int zopt2201_write_scale_als(struct zopt2201_data *data,
				     int val, int val2)
{}

static int zopt2201_write_scale_uvb_by_idx(struct zopt2201_data *data, int idx)
{}

static int zopt2201_write_scale_uvb(struct zopt2201_data *data,
				     int val, int val2)
{}

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

static ssize_t zopt2201_show_int_time_available(struct device *dev,
						struct device_attribute *attr,
						char *buf)
{}

static IIO_DEV_ATTR_INT_TIME_AVAIL(zopt2201_show_int_time_available);

static ssize_t zopt2201_show_als_scale_avail(struct device *dev,
					     struct device_attribute *attr,
					     char *buf)
{}

static ssize_t zopt2201_show_uvb_scale_avail(struct device *dev,
					     struct device_attribute *attr,
					     char *buf)
{}

static IIO_DEVICE_ATTR(in_illuminance_scale_available, 0444,
		       zopt2201_show_als_scale_avail, NULL, 0);
static IIO_DEVICE_ATTR(in_intensity_uv_scale_available, 0444,
		       zopt2201_show_uvb_scale_avail, NULL, 0);

static struct attribute *zopt2201_attributes[] =;

static const struct attribute_group zopt2201_attribute_group =;

static const struct iio_info zopt2201_info =;

static int zopt2201_probe(struct i2c_client *client)
{}

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

static struct i2c_driver zopt2201_driver =;

module_i2c_driver();

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