#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/irq.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/buffer.h>
#include <linux/util_macros.h>
#define SI1145_REG_PART_ID …
#define SI1145_REG_REV_ID …
#define SI1145_REG_SEQ_ID …
#define SI1145_REG_INT_CFG …
#define SI1145_REG_IRQ_ENABLE …
#define SI1145_REG_IRQ_MODE …
#define SI1145_REG_HW_KEY …
#define SI1145_REG_MEAS_RATE …
#define SI1145_REG_PS_LED21 …
#define SI1145_REG_PS_LED3 …
#define SI1145_REG_UCOEF1 …
#define SI1145_REG_UCOEF2 …
#define SI1145_REG_UCOEF3 …
#define SI1145_REG_UCOEF4 …
#define SI1145_REG_PARAM_WR …
#define SI1145_REG_COMMAND …
#define SI1145_REG_RESPONSE …
#define SI1145_REG_IRQ_STATUS …
#define SI1145_REG_ALSVIS_DATA …
#define SI1145_REG_ALSIR_DATA …
#define SI1145_REG_PS1_DATA …
#define SI1145_REG_PS2_DATA …
#define SI1145_REG_PS3_DATA …
#define SI1145_REG_AUX_DATA …
#define SI1145_REG_PARAM_RD …
#define SI1145_REG_CHIP_STAT …
#define SI1145_UCOEF1_DEFAULT …
#define SI1145_UCOEF2_DEFAULT …
#define SI1145_UCOEF3_DEFAULT …
#define SI1145_UCOEF4_DEFAULT …
#define SI1145_PS_LED_REG(ch) …
#define SI1145_PS_LED_SHIFT(ch) …
#define SI1145_PARAM_CHLIST …
#define SI1145_PARAM_PSLED12_SELECT …
#define SI1145_PARAM_PSLED3_SELECT …
#define SI1145_PARAM_PS_ENCODING …
#define SI1145_PARAM_ALS_ENCODING …
#define SI1145_PARAM_PS1_ADC_MUX …
#define SI1145_PARAM_PS2_ADC_MUX …
#define SI1145_PARAM_PS3_ADC_MUX …
#define SI1145_PARAM_PS_ADC_COUNTER …
#define SI1145_PARAM_PS_ADC_GAIN …
#define SI1145_PARAM_PS_ADC_MISC …
#define SI1145_PARAM_ALS_ADC_MUX …
#define SI1145_PARAM_ALSIR_ADC_MUX …
#define SI1145_PARAM_AUX_ADC_MUX …
#define SI1145_PARAM_ALSVIS_ADC_COUNTER …
#define SI1145_PARAM_ALSVIS_ADC_GAIN …
#define SI1145_PARAM_ALSVIS_ADC_MISC …
#define SI1145_PARAM_LED_RECOVERY …
#define SI1145_PARAM_ALSIR_ADC_COUNTER …
#define SI1145_PARAM_ALSIR_ADC_GAIN …
#define SI1145_PARAM_ALSIR_ADC_MISC …
#define SI1145_PARAM_ADC_OFFSET …
#define SI1145_CHLIST_EN_PS1 …
#define SI1145_CHLIST_EN_PS2 …
#define SI1145_CHLIST_EN_PS3 …
#define SI1145_CHLIST_EN_ALSVIS …
#define SI1145_CHLIST_EN_ALSIR …
#define SI1145_CHLIST_EN_AUX …
#define SI1145_CHLIST_EN_UV …
#define SI1145_PS_ADC_MODE_NORMAL …
#define SI1145_ADC_MISC_RANGE …
#define SI1145_CMD_NOP …
#define SI1145_CMD_RESET …
#define SI1145_CMD_PS_FORCE …
#define SI1145_CMD_ALS_FORCE …
#define SI1145_CMD_PSALS_FORCE …
#define SI1145_CMD_PS_PAUSE …
#define SI1145_CMD_ALS_PAUSE …
#define SI1145_CMD_PSALS_PAUSE …
#define SI1145_CMD_PS_AUTO …
#define SI1145_CMD_ALS_AUTO …
#define SI1145_CMD_PSALS_AUTO …
#define SI1145_CMD_PARAM_QUERY …
#define SI1145_CMD_PARAM_SET …
#define SI1145_RSP_INVALID_SETTING …
#define SI1145_RSP_COUNTER_MASK …
#define SI1145_COMMAND_MINSLEEP_MS …
#define SI1145_COMMAND_TIMEOUT_MS …
#define SI1145_INT_CFG_OE …
#define SI1145_INT_CFG_MODE …
#define SI1145_MASK_ALL_IE …
#define SI1145_MUX_TEMP …
#define SI1145_MUX_VDD …
#define SI1145_LED_CURRENT_45mA …
enum { … };
struct si1145_part_info { … };
struct si1145_data { … };
static int __si1145_command_reset(struct si1145_data *data)
{ … }
static int si1145_command(struct si1145_data *data, u8 cmd)
{ … }
static int si1145_param_update(struct si1145_data *data, u8 op, u8 param,
u8 value)
{ … }
static int si1145_param_set(struct si1145_data *data, u8 param, u8 value)
{ … }
static int si1145_param_query(struct si1145_data *data, u8 param)
{ … }
static u16 si1145_uncompress(u8 x)
{ … }
static u8 si1145_compress(u16 x)
{ … }
static int si1145_set_meas_rate(struct si1145_data *data, int interval)
{ … }
static int si1145_read_samp_freq(struct si1145_data *data, int *val, int *val2)
{ … }
static int si1145_store_samp_freq(struct si1145_data *data, int val)
{ … }
static irqreturn_t si1145_trigger_handler(int irq, void *private)
{ … }
static int si1145_set_chlist(struct iio_dev *indio_dev, unsigned long scan_mask)
{ … }
static int si1145_measure(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan)
{ … }
static const int si1145_proximity_scale_available[] = …;
static const int si1145_intensity_scale_available[] = …;
static IIO_CONST_ATTR(in_proximity_scale_available,
"128 64 32 16 8 4");
static IIO_CONST_ATTR(in_intensity_scale_available,
"128 64 32 16 8 4 2 1");
static IIO_CONST_ATTR(in_intensity_ir_scale_available,
"128 64 32 16 8 4 2 1");
static int si1145_scale_from_adcgain(int regval)
{ … }
static int si1145_proximity_adcgain_from_scale(int val, int val2)
{ … }
static int si1145_intensity_adcgain_from_scale(int val, int val2)
{ … }
static int si1145_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
static int si1145_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
#define SI1145_ST …
#define SI1145_INTENSITY_CHANNEL(_si) …
#define SI1145_INTENSITY_IR_CHANNEL(_si) …
#define SI1145_TEMP_CHANNEL(_si) …
#define SI1145_UV_CHANNEL(_si) …
#define SI1145_PROXIMITY_CHANNEL(_si, _ch) …
#define SI1145_VOLTAGE_CHANNEL(_si) …
#define SI1145_CURRENT_CHANNEL(_ch) …
static const struct iio_chan_spec si1132_channels[] = …;
static const struct iio_chan_spec si1141_channels[] = …;
static const struct iio_chan_spec si1142_channels[] = …;
static const struct iio_chan_spec si1143_channels[] = …;
static const struct iio_chan_spec si1145_channels[] = …;
static const struct iio_chan_spec si1146_channels[] = …;
static const struct iio_chan_spec si1147_channels[] = …;
static struct attribute *si1132_attributes[] = …;
static struct attribute *si114x_attributes[] = …;
static const struct attribute_group si1132_attribute_group = …;
static const struct attribute_group si114x_attribute_group = …;
static const struct iio_info si1132_info = …;
static const struct iio_info si114x_info = …;
#define SI1145_PART(id, iio_info, chans, leds, uncompressed_meas_rate) …
static const struct si1145_part_info si1145_part_info[] = …;
static int si1145_initialize(struct si1145_data *data)
{ … }
static int si1145_buffer_preenable(struct iio_dev *indio_dev)
{ … }
static bool si1145_validate_scan_mask(struct iio_dev *indio_dev,
const unsigned long *scan_mask)
{ … }
static const struct iio_buffer_setup_ops si1145_buffer_setup_ops = …;
static int si1145_trigger_set_state(struct iio_trigger *trig, bool state)
{ … }
static const struct iio_trigger_ops si1145_trigger_ops = …;
static int si1145_probe_trigger(struct iio_dev *indio_dev)
{ … }
static int si1145_probe(struct i2c_client *client)
{ … }
static const struct i2c_device_id si1145_ids[] = …;
MODULE_DEVICE_TABLE(i2c, si1145_ids);
static struct i2c_driver si1145_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;