#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/platform_data/bh1770glc.h>
#include <linux/regulator/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/workqueue.h>
#include <linux/delay.h>
#include <linux/wait.h>
#include <linux/slab.h>
#define BH1770_ALS_CONTROL …
#define BH1770_PS_CONTROL …
#define BH1770_I_LED …
#define BH1770_I_LED3 …
#define BH1770_ALS_PS_MEAS …
#define BH1770_PS_MEAS_RATE …
#define BH1770_ALS_MEAS_RATE …
#define BH1770_PART_ID …
#define BH1770_MANUFACT_ID …
#define BH1770_ALS_DATA_0 …
#define BH1770_ALS_DATA_1 …
#define BH1770_ALS_PS_STATUS …
#define BH1770_PS_DATA_LED1 …
#define BH1770_PS_DATA_LED2 …
#define BH1770_PS_DATA_LED3 …
#define BH1770_INTERRUPT …
#define BH1770_PS_TH_LED1 …
#define BH1770_PS_TH_LED2 …
#define BH1770_PS_TH_LED3 …
#define BH1770_ALS_TH_UP_0 …
#define BH1770_ALS_TH_UP_1 …
#define BH1770_ALS_TH_LOW_0 …
#define BH1770_ALS_TH_LOW_1 …
#define BH1770_MANUFACT_ROHM …
#define BH1770_MANUFACT_OSRAM …
#define BH1770_PART …
#define BH1770_PART_MASK …
#define BH1770_REV_MASK …
#define BH1770_REV_SHIFT …
#define BH1770_REV_0 …
#define BH1770_REV_1 …
#define BH1770_STANDBY …
#define BH1770_FORCED …
#define BH1770_STANDALONE …
#define BH1770_SWRESET …
#define BH1770_PS_TRIG_MEAS …
#define BH1770_ALS_TRIG_MEAS …
#define BH1770_INT_OUTPUT_MODE …
#define BH1770_INT_POLARITY …
#define BH1770_INT_ALS_ENA …
#define BH1770_INT_PS_ENA …
#define BH1770_INT_LED1_DATA …
#define BH1770_INT_LED1_INT …
#define BH1770_INT_LED2_DATA …
#define BH1770_INT_LED2_INT …
#define BH1770_INT_LED3_DATA …
#define BH1770_INT_LED3_INT …
#define BH1770_INT_LEDS_INT …
#define BH1770_INT_ALS_DATA …
#define BH1770_INT_ALS_INT …
#define BH1770_LED1 …
#define BH1770_DISABLE …
#define BH1770_ENABLE …
#define BH1770_PROX_CHANNELS …
#define BH1770_LUX_DEFAULT_RATE …
#define BH1770_PROX_DEFAULT_RATE …
#define BH1770_PROX_DEF_RATE_THRESH …
#define BH1770_STARTUP_DELAY …
#define BH1770_RESET_TIME …
#define BH1770_TIMEOUT …
#define BH1770_LUX_RANGE …
#define BH1770_PROX_RANGE …
#define BH1770_COEF_SCALER …
#define BH1770_CALIB_SCALER …
#define BH1770_LUX_NEUTRAL_CALIB_VALUE …
#define BH1770_LUX_DEF_THRES …
#define BH1770_PROX_DEF_THRES …
#define BH1770_PROX_DEF_ABS_THRES …
#define BH1770_DEFAULT_PERSISTENCE …
#define BH1770_PROX_MAX_PERSISTENCE …
#define BH1770_LUX_GA_SCALE …
#define BH1770_LUX_CF_SCALE …
#define BH1770_NEUTRAL_CF …
#define BH1770_LUX_CORR_SCALE …
#define PROX_ABOVE_THRESHOLD …
#define PROX_BELOW_THRESHOLD …
#define PROX_IGNORE_LUX_LIMIT …
struct bh1770_chip { … };
static const char reg_vcc[] = …;
static const char reg_vleds[] = …;
static const s16 prox_rates_hz[] = …;
static const s16 prox_rates_ms[] = …;
static const s16 lux_rates_hz[] = …;
static inline int bh1770_lux_interrupt_control(struct bh1770_chip *chip,
int lux)
{ … }
static inline int bh1770_prox_interrupt_control(struct bh1770_chip *chip,
int ps)
{ … }
static int bh1770_lux_rate(struct bh1770_chip *chip, int rate_index)
{ … }
static int bh1770_prox_rate(struct bh1770_chip *chip, int mode)
{ … }
static inline int bh1770_led_cfg(struct bh1770_chip *chip)
{ … }
static inline u8 bh1770_psraw_to_adjusted(struct bh1770_chip *chip, u8 psraw)
{ … }
static inline u8 bh1770_psadjusted_to_raw(struct bh1770_chip *chip, u8 ps)
{ … }
static int bh1770_prox_set_threshold(struct bh1770_chip *chip)
{ … }
static inline u16 bh1770_lux_raw_to_adjusted(struct bh1770_chip *chip, u16 raw)
{ … }
static inline u16 bh1770_lux_adjusted_to_raw(struct bh1770_chip *chip,
u16 adjusted)
{ … }
static int bh1770_lux_update_thresholds(struct bh1770_chip *chip,
u16 threshold_hi, u16 threshold_lo)
{ … }
static int bh1770_lux_get_result(struct bh1770_chip *chip)
{ … }
static u32 bh1770_get_corr_value(struct bh1770_chip *chip)
{ … }
static int bh1770_lux_read_result(struct bh1770_chip *chip)
{ … }
static int bh1770_chip_on(struct bh1770_chip *chip)
{ … }
static void bh1770_chip_off(struct bh1770_chip *chip)
{ … }
static int bh1770_prox_mode_control(struct bh1770_chip *chip)
{ … }
static int bh1770_prox_read_result(struct bh1770_chip *chip)
{ … }
static int bh1770_detect(struct bh1770_chip *chip)
{ … }
static void bh1770_prox_work(struct work_struct *work)
{ … }
static irqreturn_t bh1770_irq(int irq, void *data)
{ … }
static ssize_t bh1770_power_state_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t bh1770_power_state_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_lux_result_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_lux_range_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_prox_enable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t bh1770_prox_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_prox_result_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_prox_range_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_get_prox_rate_avail(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_get_prox_rate_above(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_get_prox_rate_below(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static int bh1770_prox_rate_validate(int rate)
{ … }
static ssize_t bh1770_set_prox_rate_above(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t bh1770_set_prox_rate_below(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t bh1770_get_prox_thres(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_set_prox_thres(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t bh1770_prox_persistence_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_prox_persistence_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t bh1770_prox_abs_thres_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_prox_abs_thres_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t bh1770_chip_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_lux_calib_default_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_lux_calib_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_lux_calib_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t bh1770_get_lux_rate_avail(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_get_lux_rate(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_set_lux_rate(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t bh1770_get_lux_thresh_above(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_get_lux_thresh_below(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target,
const char *buf)
{ … }
static ssize_t bh1770_set_lux_thresh_above(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static ssize_t bh1770_set_lux_thresh_below(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{ … }
static DEVICE_ATTR(prox0_raw_en, S_IRUGO | S_IWUSR, bh1770_prox_enable_show,
bh1770_prox_enable_store);
static DEVICE_ATTR(prox0_thresh_above1_value, S_IRUGO | S_IWUSR,
bh1770_prox_abs_thres_show,
bh1770_prox_abs_thres_store);
static DEVICE_ATTR(prox0_thresh_above0_value, S_IRUGO | S_IWUSR,
bh1770_get_prox_thres,
bh1770_set_prox_thres);
static DEVICE_ATTR(prox0_raw, S_IRUGO, bh1770_prox_result_show, NULL);
static DEVICE_ATTR(prox0_sensor_range, S_IRUGO, bh1770_prox_range_show, NULL);
static DEVICE_ATTR(prox0_thresh_above_count, S_IRUGO | S_IWUSR,
bh1770_prox_persistence_show,
bh1770_prox_persistence_store);
static DEVICE_ATTR(prox0_rate_above, S_IRUGO | S_IWUSR,
bh1770_get_prox_rate_above,
bh1770_set_prox_rate_above);
static DEVICE_ATTR(prox0_rate_below, S_IRUGO | S_IWUSR,
bh1770_get_prox_rate_below,
bh1770_set_prox_rate_below);
static DEVICE_ATTR(prox0_rate_avail, S_IRUGO, bh1770_get_prox_rate_avail, NULL);
static DEVICE_ATTR(lux0_calibscale, S_IRUGO | S_IWUSR, bh1770_lux_calib_show,
bh1770_lux_calib_store);
static DEVICE_ATTR(lux0_calibscale_default, S_IRUGO,
bh1770_lux_calib_default_show,
NULL);
static DEVICE_ATTR(lux0_input, S_IRUGO, bh1770_lux_result_show, NULL);
static DEVICE_ATTR(lux0_sensor_range, S_IRUGO, bh1770_lux_range_show, NULL);
static DEVICE_ATTR(lux0_rate, S_IRUGO | S_IWUSR, bh1770_get_lux_rate,
bh1770_set_lux_rate);
static DEVICE_ATTR(lux0_rate_avail, S_IRUGO, bh1770_get_lux_rate_avail, NULL);
static DEVICE_ATTR(lux0_thresh_above_value, S_IRUGO | S_IWUSR,
bh1770_get_lux_thresh_above,
bh1770_set_lux_thresh_above);
static DEVICE_ATTR(lux0_thresh_below_value, S_IRUGO | S_IWUSR,
bh1770_get_lux_thresh_below,
bh1770_set_lux_thresh_below);
static DEVICE_ATTR(chip_id, S_IRUGO, bh1770_chip_id_show, NULL);
static DEVICE_ATTR(power_state, S_IRUGO | S_IWUSR, bh1770_power_state_show,
bh1770_power_state_store);
static struct attribute *sysfs_attrs[] = …;
static const struct attribute_group bh1770_attribute_group = …;
static int bh1770_probe(struct i2c_client *client)
{ … }
static void bh1770_remove(struct i2c_client *client)
{ … }
#ifdef CONFIG_PM_SLEEP
static int bh1770_suspend(struct device *dev)
{ … }
static int bh1770_resume(struct device *dev)
{ … }
#endif
#ifdef CONFIG_PM
static int bh1770_runtime_suspend(struct device *dev)
{ … }
static int bh1770_runtime_resume(struct device *dev)
{ … }
#endif
static const struct i2c_device_id bh1770_id[] = …;
MODULE_DEVICE_TABLE(i2c, bh1770_id);
static const struct dev_pm_ops bh1770_pm_ops = …;
static struct i2c_driver bh1770_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;