linux/drivers/iio/light/as73211.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Support for AMS AS73211 JENCOLOR(R) Digital XYZ Sensor and AMS AS7331
 * UVA, UVB and UVC (DUV) Ultraviolet Sensor
 *
 * Author: Christian Eggers <[email protected]>
 *
 * Copyright (c) 2020 ARRI Lighting
 *
 * Color light sensor with 16-bit channels for x, y, z and temperature);
 * 7-bit I2C slave address 0x74 .. 0x77.
 *
 * Datasheets:
 * AS73211: https://ams.com/documents/20143/36005/AS73211_DS000556_3-01.pdf
 * AS7331: https://ams.com/documents/20143/9106314/AS7331_DS001047_4-00.pdf
 */

#include <linux/bitfield.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pm.h>
#include <linux/units.h>

#define AS73211_DRV_NAME

/* AS73211 configuration registers */
#define AS73211_REG_OSR
#define AS73211_REG_AGEN
#define AS73211_REG_CREG1
#define AS73211_REG_CREG2
#define AS73211_REG_CREG3

/* AS73211 output register bank */
#define AS73211_OUT_OSR_STATUS
#define AS73211_OUT_TEMP
#define AS73211_OUT_MRES1
#define AS73211_OUT_MRES2
#define AS73211_OUT_MRES3

#define AS73211_OSR_SS
#define AS73211_OSR_PD
#define AS73211_OSR_SW_RES
#define AS73211_OSR_DOS_MASK
#define AS73211_OSR_DOS_CONFIG
#define AS73211_OSR_DOS_MEASURE

#define AS73211_AGEN_DEVID_MASK
#define AS73211_AGEN_DEVID(x)
#define AS73211_AGEN_MUT_MASK
#define AS73211_AGEN_MUT(x)

#define AS73211_CREG1_GAIN_MASK
#define AS73211_CREG1_GAIN_1
#define AS73211_CREG1_TIME_MASK

#define AS73211_CREG3_CCLK_MASK

#define AS73211_OSR_STATUS_OUTCONVOF
#define AS73211_OSR_STATUS_MRESOF
#define AS73211_OSR_STATUS_ADCOF
#define AS73211_OSR_STATUS_LDATA
#define AS73211_OSR_STATUS_NDATA
#define AS73211_OSR_STATUS_NOTREADY

#define AS73211_SAMPLE_FREQ_BASE

#define AS73211_SAMPLE_TIME_NUM
#define AS73211_SAMPLE_TIME_MAX_MS

/* Available sample frequencies are 1.024MHz multiplied by powers of two. */
static const int as73211_samp_freq_avail[] =;

static const int as73211_hardwaregain_avail[] =;

struct as73211_data;

/**
 * struct as73211_spec_dev_data - device-specific data
 * @intensity_scale:  Function to retrieve intensity scale values.
 * @channels:          Device channels.
 * @num_channels:     Number of channels of the device.
 */
struct as73211_spec_dev_data {};

/**
 * struct as73211_data - Instance data for one AS73211
 * @client: I2C client.
 * @osr:    Cached Operational State Register.
 * @creg1:  Cached Configuration Register 1.
 * @creg2:  Cached Configuration Register 2.
 * @creg3:  Cached Configuration Register 3.
 * @mutex:  Keeps cached registers in sync with the device.
 * @completion: Completion to wait for interrupt.
 * @int_time_avail: Available integration times (depend on sampling frequency).
 * @spec_dev: device-specific configuration.
 */
struct as73211_data {};

#define AS73211_COLOR_CHANNEL(_color, _si, _addr)

#define AS73211_OFFSET_TEMP_INT
#define AS73211_OFFSET_TEMP_MICRO
#define AS73211_SCALE_TEMP_INT
#define AS73211_SCALE_TEMP_MICRO

#define AS73211_SCALE_X
#define AS73211_SCALE_Y
#define AS73211_SCALE_Z

#define AS7331_SCALE_UVA
#define AS7331_SCALE_UVB
#define AS7331_SCALE_UVC

/* Channel order MUST match devices result register order */
#define AS73211_SCAN_INDEX_TEMP
#define AS73211_SCAN_INDEX_X
#define AS73211_SCAN_INDEX_Y
#define AS73211_SCAN_INDEX_Z
#define AS73211_SCAN_INDEX_TS

#define AS73211_SCAN_MASK_COLOR

#define AS73211_SCAN_MASK_ALL

static const struct iio_chan_spec as73211_channels[] =;

static const struct iio_chan_spec as7331_channels[] =;

static unsigned int as73211_integration_time_1024cyc(struct as73211_data *data)
{}

static unsigned int as73211_integration_time_us(struct as73211_data *data,
						 unsigned int integration_time_1024cyc)
{}

static void as73211_integration_time_calc_avail(struct as73211_data *data)
{}

static unsigned int as73211_gain(struct as73211_data *data)
{}

/* must be called with as73211_data::mutex held. */
static int as73211_req_data(struct as73211_data *data)
{}

static int as73211_intensity_scale(struct as73211_data *data, int chan,
				   int *val, int *val2)
{}

static int as7331_intensity_scale(struct as73211_data *data, int chan,
				  int *val, int *val2)
{}

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

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

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

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

static irqreturn_t as73211_ready_handler(int irq __always_unused, void *priv)
{}

static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p)
{}

static const struct iio_info as73211_info =;

static int as73211_power(struct iio_dev *indio_dev, bool state)
{}

static void as73211_power_disable(void *data)
{}

static int as73211_probe(struct i2c_client *client)
{}

static int as73211_suspend(struct device *dev)
{}

static int as73211_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(as73211_pm_ops, as73211_suspend,
				as73211_resume);

static const struct as73211_spec_dev_data as73211_spec =;

static const struct as73211_spec_dev_data as7331_spec =;

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

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

static struct i2c_driver as73211_driver =;
module_i2c_driver();

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