linux/drivers/iio/light/si1133.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * si1133.c - Support for Silabs SI1133 combined ambient
 * light and UV index sensors
 *
 * Copyright 2018 Maxime Roussin-Belanger <[email protected]>
 */

#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/regmap.h>

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

#include <linux/util_macros.h>

#include <linux/unaligned.h>

#define SI1133_REG_PART_ID
#define SI1133_REG_REV_ID
#define SI1133_REG_MFR_ID
#define SI1133_REG_INFO0
#define SI1133_REG_INFO1

#define SI1133_PART_ID

#define SI1133_REG_HOSTIN0
#define SI1133_REG_COMMAND
#define SI1133_REG_IRQ_ENABLE
#define SI1133_REG_RESPONSE1
#define SI1133_REG_RESPONSE0
#define SI1133_REG_IRQ_STATUS
#define SI1133_REG_MEAS_RATE

#define SI1133_IRQ_CHANNEL_ENABLE

#define SI1133_CMD_RESET_CTR
#define SI1133_CMD_RESET_SW
#define SI1133_CMD_FORCE
#define SI1133_CMD_START_AUTONOMOUS
#define SI1133_CMD_PARAM_SET
#define SI1133_CMD_PARAM_QUERY
#define SI1133_CMD_PARAM_MASK

#define SI1133_CMD_ERR_MASK
#define SI1133_CMD_SEQ_MASK
#define SI1133_MAX_CMD_CTR

#define SI1133_PARAM_REG_CHAN_LIST
#define SI1133_PARAM_REG_ADCCONFIG(x)
#define SI1133_PARAM_REG_ADCSENS(x)
#define SI1133_PARAM_REG_ADCPOST(x)

#define SI1133_ADCMUX_MASK

#define SI1133_ADCCONFIG_DECIM_RATE(x)

#define SI1133_ADCSENS_SCALE_MASK
#define SI1133_ADCSENS_SCALE_SHIFT
#define SI1133_ADCSENS_HSIG_MASK
#define SI1133_ADCSENS_HSIG_SHIFT
#define SI1133_ADCSENS_HW_GAIN_MASK
#define SI1133_ADCSENS_NB_MEAS(x)

#define SI1133_ADCPOST_24BIT_EN
#define SI1133_ADCPOST_POSTSHIFT_BITQTY(x)

#define SI1133_PARAM_ADCMUX_SMALL_IR
#define SI1133_PARAM_ADCMUX_MED_IR
#define SI1133_PARAM_ADCMUX_LARGE_IR
#define SI1133_PARAM_ADCMUX_WHITE
#define SI1133_PARAM_ADCMUX_LARGE_WHITE
#define SI1133_PARAM_ADCMUX_UV
#define SI1133_PARAM_ADCMUX_UV_DEEP

#define SI1133_ERR_INVALID_CMD
#define SI1133_ERR_INVALID_LOCATION_CMD
#define SI1133_ERR_SATURATION_ADC_OR_OVERFLOW_ACCUMULATION
#define SI1133_ERR_OUTPUT_BUFFER_OVERFLOW

#define SI1133_COMPLETION_TIMEOUT_MS

#define SI1133_CMD_MINSLEEP_US_LOW
#define SI1133_CMD_MINSLEEP_US_HIGH
#define SI1133_CMD_TIMEOUT_MS
#define SI1133_CMD_LUX_TIMEOUT_MS
#define SI1133_CMD_TIMEOUT_US

#define SI1133_REG_HOSTOUT(x)

#define SI1133_MEASUREMENT_FREQUENCY

#define SI1133_X_ORDER_MASK
#define SI1133_Y_ORDER_MASK
#define si1133_get_x_order(m)
#define si1133_get_y_order(m)

#define SI1133_LUX_ADC_MASK
#define SI1133_ADC_THRESHOLD
#define SI1133_INPUT_FRACTION_HIGH
#define SI1133_INPUT_FRACTION_LOW
#define SI1133_LUX_OUTPUT_FRACTION
#define SI1133_LUX_BUFFER_SIZE
#define SI1133_MEASURE_BUFFER_SIZE

static const int si1133_scale_available[] =;

static IIO_CONST_ATTR(scale_available, "1 2 4 8 16 32 64 128");

static IIO_CONST_ATTR_INT_TIME_AVAIL("0.0244 0.0488 0.0975 0.195 0.390 0.780 "
				     "1.560 3.120 6.24 12.48 25.0 50.0");

/* A.K.A. HW_GAIN in datasheet */
enum si1133_int_time {};

/* Integration time in milliseconds, nanoseconds */
static const int si1133_int_time_table[][2] =;

static const struct regmap_range si1133_reg_ranges[] =;

static const struct regmap_range si1133_reg_ro_ranges[] =;

static const struct regmap_range si1133_precious_ranges[] =;

static const struct regmap_access_table si1133_write_ranges_table =;

static const struct regmap_access_table si1133_read_ranges_table =;

static const struct regmap_access_table si1133_precious_table =;

static const struct regmap_config si1133_regmap_config =;

struct si1133_data {};

struct si1133_coeff {};

struct si1133_lux_coeff {};

static const struct si1133_lux_coeff lux_coeff =;

static int si1133_calculate_polynomial_inner(s32 input, u8 fraction, u16 mag,
					     s8 shift)
{}

static int si1133_calculate_output(s32 x, s32 y, u8 x_order, u8 y_order,
				   u8 input_fraction, s8 sign,
				   const struct si1133_coeff *coeffs)
{}

/*
 * The algorithm is from:
 * https://siliconlabs.github.io/Gecko_SDK_Doc/efm32zg/html/si1133_8c_source.html#l00716
 */
static int si1133_calc_polynomial(s32 x, s32 y, u8 input_fraction, u8 num_coeff,
				  const struct si1133_coeff *coeffs)
{}

static int si1133_cmd_reset_sw(struct si1133_data *data)
{}

static int si1133_parse_response_err(struct device *dev, u32 resp, u8 cmd)
{}

static int si1133_cmd_reset_counter(struct si1133_data *data)
{}

static int si1133_command(struct si1133_data *data, u8 cmd)
{}

static int si1133_param_set(struct si1133_data *data, u8 param, u32 value)
{}

static int si1133_param_query(struct si1133_data *data, u8 param, u32 *result)
{}

#define SI1133_CHANNEL(_ch, _type) \

static const struct iio_chan_spec si1133_channels[] =;

static int si1133_get_int_time_index(int milliseconds, int nanoseconds)
{}

static int si1133_set_integration_time(struct si1133_data *data, u8 adc,
				       int milliseconds, int nanoseconds)
{}

static int si1133_set_chlist(struct si1133_data *data, u8 scan_mask)
{}

static int si1133_chan_set_adcconfig(struct si1133_data *data, u8 adc,
				     u8 adc_config)
{}

static int si1133_update_adcconfig(struct si1133_data *data, uint8_t adc,
				   u8 mask, u8 shift, u8 value)
{}

static int si1133_set_adcmux(struct si1133_data *data, u8 adc, u8 mux)
{}

static int si1133_force_measurement(struct si1133_data *data)
{}

static int si1133_bulk_read(struct si1133_data *data, u8 start_reg, u8 length,
			    u8 *buffer)
{}

static int si1133_measure(struct si1133_data *data,
			  struct iio_chan_spec const *chan,
			  int *val)
{}

static irqreturn_t si1133_threaded_irq_handler(int irq, void *private)
{}

static int si1133_scale_to_swgain(int scale_integer, int scale_fractional)
{}

static int si1133_chan_set_adcsens(struct si1133_data *data, u8 adc,
				   u8 adc_sens)
{}

static int si1133_update_adcsens(struct si1133_data *data, u8 mask,
				 u8 shift, u8 value)
{}

static int si1133_get_lux(struct si1133_data *data, int *val)
{}

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

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

static struct attribute *si1133_attributes[] =;

static const struct attribute_group si1133_attribute_group =;

static const struct iio_info si1133_info =;

/*
 * si1133_init_lux_channels - Configure 3 different channels(adc) (1,2 and 3)
 * The channel configuration for the lux measurement was taken from :
 * https://siliconlabs.github.io/Gecko_SDK_Doc/efm32zg/html/si1133_8c_source.html#l00578
 *
 * Reserved the channel 0 for the other raw measurements
 */
static int si1133_init_lux_channels(struct si1133_data *data)
{}

static int si1133_initialize(struct si1133_data *data)
{}

static int si1133_validate_ids(struct iio_dev *iio_dev)
{}

static int si1133_probe(struct i2c_client *client)
{}

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

static struct i2c_driver si1133_driver =;

module_i2c_driver();

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