linux/drivers/iio/light/vcnl4035.c

// SPDX-License-Identifier: GPL-2.0
/*
 * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60
 *
 * Copyright (c) 2018, DENX Software Engineering GmbH
 * Author: Parthiban Nallathambi <[email protected]>
 *
 * TODO: Proximity
 */
#include <linux/bitops.h>
#include <linux/bitfield.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>

#include <linux/iio/buffer.h>
#include <linux/iio/events.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>

#define VCNL4035_DRV_NAME
#define VCNL4035_IRQ_NAME
#define VCNL4035_REGMAP_NAME

/* Device registers */
#define VCNL4035_ALS_CONF
#define VCNL4035_ALS_THDH
#define VCNL4035_ALS_THDL
#define VCNL4035_ALS_DATA
#define VCNL4035_WHITE_DATA
#define VCNL4035_INT_FLAG
#define VCNL4035_DEV_ID

/* Register masks */
#define VCNL4035_MODE_ALS_MASK
#define VCNL4035_MODE_ALS_WHITE_CHAN
#define VCNL4035_MODE_ALS_INT_MASK
#define VCNL4035_ALS_IT_MASK
#define VCNL4035_ALS_PERS_MASK
#define VCNL4035_INT_ALS_IF_H_MASK
#define VCNL4035_INT_ALS_IF_L_MASK
#define VCNL4035_DEV_ID_MASK

/* Default values */
#define VCNL4035_MODE_ALS_ENABLE
#define VCNL4035_MODE_ALS_DISABLE
#define VCNL4035_MODE_ALS_INT_ENABLE
#define VCNL4035_MODE_ALS_INT_DISABLE
#define VCNL4035_DEV_ID_VAL
#define VCNL4035_ALS_IT_DEFAULT
#define VCNL4035_ALS_PERS_DEFAULT
#define VCNL4035_ALS_THDH_DEFAULT
#define VCNL4035_ALS_THDL_DEFAULT
#define VCNL4035_SLEEP_DELAY_MS

struct vcnl4035_data {};

static inline bool vcnl4035_is_triggered(struct vcnl4035_data *data)
{}

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

/* Triggered buffer */
static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p)
{}

static int vcnl4035_als_drdy_set_state(struct iio_trigger *trigger,
					bool enable_drdy)
{}

static const struct iio_trigger_ops vcnl4035_trigger_ops =;

static int vcnl4035_set_pm_runtime_state(struct vcnl4035_data *data, bool on)
{}

/*
 *	Device IT	INT Time (ms)	Scale (lux/step)
 *	000		50		0.064
 *	001		100		0.032
 *	010		200		0.016
 *	100		400		0.008
 *	101 - 111	800		0.004
 * Values are proportional, so ALS INT is selected for input due to
 * simplicity reason. Integration time value and scaling is
 * calculated based on device INT value
 *
 * Raw value needs to be scaled using ALS steps
 */
static int vcnl4035_read_raw(struct iio_dev *indio_dev,
			    struct iio_chan_spec const *chan, int *val,
			    int *val2, long mask)
{}

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

/* No direct ABI for persistence and threshold, so eventing */
static int vcnl4035_read_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 vcnl4035_write_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 IIO_CONST_ATTR_INT_TIME_AVAIL("50 100 200 400 800");

static struct attribute *vcnl4035_attributes[] =;

static const struct attribute_group vcnl4035_attribute_group =;

static const struct iio_info vcnl4035_info =;

static const struct iio_event_spec vcnl4035_event_spec[] =;

enum vcnl4035_scan_index_order {};

static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops =;

static const struct iio_chan_spec vcnl4035_channels[] =;

static int vcnl4035_set_als_power_state(struct vcnl4035_data *data, u8 status)
{}

static int vcnl4035_init(struct vcnl4035_data *data)
{}

static bool vcnl4035_is_volatile_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_config vcnl4035_regmap_config =;

static int vcnl4035_probe_trigger(struct iio_dev *indio_dev)
{}

static int vcnl4035_probe(struct i2c_client *client)
{}

static void vcnl4035_remove(struct i2c_client *client)
{}

static int vcnl4035_runtime_suspend(struct device *dev)
{}

static int vcnl4035_runtime_resume(struct device *dev)
{}

static DEFINE_RUNTIME_DEV_PM_OPS(vcnl4035_pm_ops, vcnl4035_runtime_suspend,
				 vcnl4035_runtime_resume, NULL);

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

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

static struct i2c_driver vcnl4035_driver =;

module_i2c_driver();

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