#include <linux/delay.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/regulator/consumer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/events.h>
#define CM36651_I2C_ADDR_PS …
#define CM36651_ARA …
#define CM36651_CS_CONF1 …
#define CM36651_CS_CONF2 …
#define CM36651_ALS_WH_M …
#define CM36651_ALS_WH_L …
#define CM36651_ALS_WL_M …
#define CM36651_ALS_WL_L …
#define CM36651_CS_CONF3 …
#define CM36651_CS_CONF_REG_NUM …
#define CM36651_PS_CONF1 …
#define CM36651_PS_THD …
#define CM36651_PS_CANC …
#define CM36651_PS_CONF2 …
#define CM36651_PS_REG_NUM …
#define CM36651_ALS_ENABLE …
#define CM36651_ALS_DISABLE …
#define CM36651_ALS_INT_EN …
#define CM36651_ALS_THRES …
#define CM36651_CS_CONF2_DEFAULT_BIT …
#define CM36651_CS_IT1 …
#define CM36651_CS_IT2 …
#define CM36651_CS_IT3 …
#define CM36651_CS_IT4 …
#define CM36651_PS_ENABLE …
#define CM36651_PS_DISABLE …
#define CM36651_PS_INT_EN …
#define CM36651_PS_PERS2 …
#define CM36651_PS_PERS3 …
#define CM36651_PS_PERS4 …
#define CM36651_PS_IT1 …
#define CM36651_PS_IT2 …
#define CM36651_PS_IT3 …
#define CM36651_PS_IT4 …
#define CM36651_PS_DR1 …
#define CM36651_PS_DR2 …
#define CM36651_PS_DR3 …
#define CM36651_PS_DR4 …
#define CM36651_PS_INITIAL_THD …
#define CM36651_PS_CANC_DEFAULT …
#define CM36651_PS_HYS1 …
#define CM36651_PS_HYS2 …
#define CM36651_PS_SMART_PERS_EN …
#define CM36651_PS_DIR_INT …
#define CM36651_PS_MS …
#define CM36651_CS_COLOR_NUM …
#define CM36651_CLOSE_PROXIMITY …
#define CM36651_FAR_PROXIMITY …
#define CM36651_CS_INT_TIME_AVAIL …
#define CM36651_PS_INT_TIME_AVAIL …
enum cm36651_operation_mode { … };
enum cm36651_light_channel_idx { … };
enum cm36651_command { … };
static const u8 cm36651_cs_reg[CM36651_CS_CONF_REG_NUM] = …;
static const u8 cm36651_ps_reg[CM36651_PS_REG_NUM] = …;
struct cm36651_data { … };
static int cm36651_setup_reg(struct cm36651_data *cm36651)
{ … }
static int cm36651_read_output(struct cm36651_data *cm36651,
struct iio_chan_spec const *chan, int *val)
{ … }
static irqreturn_t cm36651_irq_handler(int irq, void *data)
{ … }
static int cm36651_set_operation_mode(struct cm36651_data *cm36651, int cmd)
{ … }
static int cm36651_read_channel(struct cm36651_data *cm36651,
struct iio_chan_spec const *chan, int *val)
{ … }
static int cm36651_read_int_time(struct cm36651_data *cm36651,
struct iio_chan_spec const *chan, int *val2)
{ … }
static int cm36651_write_int_time(struct cm36651_data *cm36651,
struct iio_chan_spec const *chan, int val)
{ … }
static int cm36651_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
static int cm36651_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
static int cm36651_read_prox_thresh(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir,
enum iio_event_info info,
int *val, int *val2)
{ … }
static int cm36651_write_prox_thresh(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir,
enum iio_event_info info,
int val, int val2)
{ … }
static int cm36651_write_prox_event_config(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir,
int state)
{ … }
static int cm36651_read_prox_event_config(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir)
{ … }
#define CM36651_LIGHT_CHANNEL(_color, _idx) … \
static const struct iio_event_spec cm36651_event_spec[] = …;
static const struct iio_chan_spec cm36651_channels[] = …;
static IIO_CONST_ATTR(in_illuminance_integration_time_available,
CM36651_CS_INT_TIME_AVAIL);
static IIO_CONST_ATTR(in_proximity_integration_time_available,
CM36651_PS_INT_TIME_AVAIL);
static struct attribute *cm36651_attributes[] = …;
static const struct attribute_group cm36651_attribute_group = …;
static const struct iio_info cm36651_info = …;
static int cm36651_probe(struct i2c_client *client)
{ … }
static void cm36651_remove(struct i2c_client *client)
{ … }
static const struct i2c_device_id cm36651_id[] = …;
MODULE_DEVICE_TABLE(i2c, cm36651_id);
static const struct of_device_id cm36651_of_match[] = …;
MODULE_DEVICE_TABLE(of, cm36651_of_match);
static struct i2c_driver cm36651_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;