#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/delay.h>
#include <linux/wait.h>
#include <linux/slab.h>
#include <linux/platform_data/apds990x.h>
#define APDS990X_ENABLE …
#define APDS990X_ATIME …
#define APDS990X_PTIME …
#define APDS990X_WTIME …
#define APDS990X_AILTL …
#define APDS990X_AILTH …
#define APDS990X_AIHTL …
#define APDS990X_AIHTH …
#define APDS990X_PILTL …
#define APDS990X_PILTH …
#define APDS990X_PIHTL …
#define APDS990X_PIHTH …
#define APDS990X_PERS …
#define APDS990X_CONFIG …
#define APDS990X_PPCOUNT …
#define APDS990X_CONTROL …
#define APDS990X_REV …
#define APDS990X_ID …
#define APDS990X_STATUS …
#define APDS990X_CDATAL …
#define APDS990X_CDATAH …
#define APDS990X_IRDATAL …
#define APDS990X_IRDATAH …
#define APDS990X_PDATAL …
#define APDS990X_PDATAH …
#define APDS990X_MAX_AGAIN …
#define APDS990X_EN_PIEN …
#define APDS990X_EN_AIEN …
#define APDS990X_EN_WEN …
#define APDS990X_EN_PEN …
#define APDS990X_EN_AEN …
#define APDS990X_EN_PON …
#define APDS990X_EN_DISABLE_ALL …
#define APDS990X_ST_PINT …
#define APDS990X_ST_AINT …
#define APDS990x_CMD_TYPE_MASK …
#define APDS990x_CMD_TYPE_RB …
#define APDS990x_CMD_TYPE_INC …
#define APDS990x_CMD_TYPE_SPE …
#define APDS990x_ADDR_SHIFT …
#define APDS990x_CMD …
#define APDS990X_INT_ACK_ALS …
#define APDS990X_INT_ACK_PS …
#define APDS990X_INT_ACK_BOTH …
#define APDS990X_PTIME_DEFAULT …
#define APDS990X_WTIME_DEFAULT …
#define APDS990X_TIME_TO_ADC …
#define APDS990X_APERS_SHIFT …
#define APDS990X_PPERS_SHIFT …
#define APDS990X_ID_0 …
#define APDS990X_ID_4 …
#define APDS990X_ID_29 …
#define APDS_PGAIN_1X …
#define APDS_PDIODE_IR …
#define APDS990X_LUX_OUTPUT_SCALE …
struct reverse_factors { … };
struct apds990x_chip { … };
#define APDS_CALIB_SCALER …
#define APDS_LUX_NEUTRAL_CALIB_VALUE …
#define APDS_PROX_NEUTRAL_CALIB_VALUE …
#define APDS_PROX_DEF_THRES …
#define APDS_PROX_HYSTERESIS …
#define APDS_LUX_DEF_THRES_HI …
#define APDS_LUX_DEF_THRES_LO …
#define APDS_DEFAULT_PROX_PERS …
#define APDS_TIMEOUT …
#define APDS_STARTUP_DELAY …
#define APDS_RANGE …
#define APDS_PROX_RANGE …
#define APDS_LUX_GAIN_LO_LIMIT …
#define APDS_LUX_GAIN_LO_LIMIT_STRICT …
#define TIMESTEP …
#define TIME_STEP_SCALER …
#define APDS_LUX_AVERAGING_TIME …
#define APDS_LUX_DEFAULT_RATE …
static const u8 again[] = …;
static const u16 arates_hz[] = …;
static const u8 apersis[] = …;
static const char reg_vcc[] = …;
static const char reg_vled[] = …;
static int apds990x_read_byte(struct apds990x_chip *chip, u8 reg, u8 *data)
{ … }
static int apds990x_read_word(struct apds990x_chip *chip, u8 reg, u16 *data)
{ … }
static int apds990x_write_byte(struct apds990x_chip *chip, u8 reg, u8 data)
{ … }
static int apds990x_write_word(struct apds990x_chip *chip, u8 reg, u16 data)
{ … }
static int apds990x_mode_on(struct apds990x_chip *chip)
{ … }
static u16 apds990x_lux_to_threshold(struct apds990x_chip *chip, u32 lux)
{ … }
static inline int apds990x_set_atime(struct apds990x_chip *chip, u32 time_ms)
{ … }
static int apds990x_refresh_pthres(struct apds990x_chip *chip, int data)
{ … }
static int apds990x_refresh_athres(struct apds990x_chip *chip)
{ … }
static void apds990x_force_a_refresh(struct apds990x_chip *chip)
{ … }
static void apds990x_force_p_refresh(struct apds990x_chip *chip)
{ … }
static int apds990x_calc_again(struct apds990x_chip *chip)
{ … }
static int apds990x_get_lux(struct apds990x_chip *chip, int clear, int ir)
{ … }
static int apds990x_ack_int(struct apds990x_chip *chip, u8 mode)
{ … }
static irqreturn_t apds990x_irq(int irq, void *data)
{ … }
static int apds990x_configure(struct apds990x_chip *chip)
{ … }
static int apds990x_detect(struct apds990x_chip *chip)
{ … }
#ifdef CONFIG_PM
static int apds990x_chip_on(struct apds990x_chip *chip)
{ … }
#endif
static int apds990x_chip_off(struct apds990x_chip *chip)
{ … }
static ssize_t apds990x_lux_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(lux0_input, S_IRUGO, apds990x_lux_show, NULL);
static ssize_t apds990x_lux_range_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(lux0_sensor_range, S_IRUGO, apds990x_lux_range_show, NULL);
static ssize_t apds990x_lux_calib_format_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(lux0_calibscale_default, S_IRUGO,
apds990x_lux_calib_format_show, NULL);
static ssize_t apds990x_lux_calib_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t apds990x_lux_calib_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR(lux0_calibscale, S_IRUGO | S_IWUSR, apds990x_lux_calib_show,
apds990x_lux_calib_store);
static ssize_t apds990x_rate_avail(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t apds990x_rate_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static int apds990x_set_arate(struct apds990x_chip *chip, int rate)
{ … }
static ssize_t apds990x_rate_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR(lux0_rate_avail, S_IRUGO, apds990x_rate_avail, NULL);
static DEVICE_ATTR(lux0_rate, S_IRUGO | S_IWUSR, apds990x_rate_show,
apds990x_rate_store);
static ssize_t apds990x_prox_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(prox0_raw, S_IRUGO, apds990x_prox_show, NULL);
static ssize_t apds990x_prox_range_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(prox0_sensor_range, S_IRUGO, apds990x_prox_range_show, NULL);
static ssize_t apds990x_prox_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t apds990x_prox_enable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR(prox0_raw_en, S_IRUGO | S_IWUSR, apds990x_prox_enable_show,
apds990x_prox_enable_store);
static const char *reporting_modes[] = …;
static ssize_t apds990x_prox_reporting_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t apds990x_prox_reporting_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR(prox0_reporting_mode, S_IRUGO | S_IWUSR,
apds990x_prox_reporting_mode_show,
apds990x_prox_reporting_mode_store);
static ssize_t apds990x_prox_reporting_avail_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(prox0_reporting_mode_avail, S_IRUGO | S_IWUSR,
apds990x_prox_reporting_avail_show, NULL);
static ssize_t apds990x_lux_thresh_above_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t apds990x_lux_thresh_below_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target,
const char *buf)
{ … }
static ssize_t apds990x_lux_thresh_above_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t apds990x_lux_thresh_below_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR(lux0_thresh_above_value, S_IRUGO | S_IWUSR,
apds990x_lux_thresh_above_show,
apds990x_lux_thresh_above_store);
static DEVICE_ATTR(lux0_thresh_below_value, S_IRUGO | S_IWUSR,
apds990x_lux_thresh_below_show,
apds990x_lux_thresh_below_store);
static ssize_t apds990x_prox_threshold_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t apds990x_prox_threshold_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR(prox0_thresh_above_value, S_IRUGO | S_IWUSR,
apds990x_prox_threshold_show,
apds990x_prox_threshold_store);
static ssize_t apds990x_power_state_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t apds990x_power_state_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR(power_state, S_IRUGO | S_IWUSR,
apds990x_power_state_show,
apds990x_power_state_store);
static ssize_t apds990x_chip_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(chip_id, S_IRUGO, apds990x_chip_id_show, NULL);
static struct attribute *sysfs_attrs_ctrl[] = …;
static const struct attribute_group apds990x_attribute_group[] = …;
static int apds990x_probe(struct i2c_client *client)
{ … }
static void apds990x_remove(struct i2c_client *client)
{ … }
#ifdef CONFIG_PM_SLEEP
static int apds990x_suspend(struct device *dev)
{ … }
static int apds990x_resume(struct device *dev)
{ … }
#endif
#ifdef CONFIG_PM
static int apds990x_runtime_suspend(struct device *dev)
{ … }
static int apds990x_runtime_resume(struct device *dev)
{ … }
#endif
static const struct i2c_device_id apds990x_id[] = …;
MODULE_DEVICE_TABLE(i2c, apds990x_id);
static const struct dev_pm_ops apds990x_pm_ops = …;
static struct i2c_driver apds990x_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;