linux/drivers/iio/light/jsa1212.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * JSA1212 Ambient Light & Proximity Sensor Driver
 *
 * Copyright (c) 2014, Intel Corporation.
 *
 * JSA1212 I2C slave address: 0x44(ADDR tied to GND), 0x45(ADDR tied to VDD)
 *
 * TODO: Interrupt support, thresholds, range support.
 */

#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/regmap.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>

/* JSA1212 reg address */
#define JSA1212_CONF_REG
#define JSA1212_INT_REG
#define JSA1212_PXS_LT_REG
#define JSA1212_PXS_HT_REG
#define JSA1212_ALS_TH1_REG
#define JSA1212_ALS_TH2_REG
#define JSA1212_ALS_TH3_REG
#define JSA1212_PXS_DATA_REG
#define JSA1212_ALS_DT1_REG
#define JSA1212_ALS_DT2_REG
#define JSA1212_ALS_RNG_REG
#define JSA1212_MAX_REG

/* JSA1212 reg masks */
#define JSA1212_CONF_MASK
#define JSA1212_INT_MASK
#define JSA1212_PXS_LT_MASK
#define JSA1212_PXS_HT_MASK
#define JSA1212_ALS_TH1_MASK
#define JSA1212_ALS_TH2_LT_MASK
#define JSA1212_ALS_TH2_HT_MASK
#define JSA1212_ALS_TH3_MASK
#define JSA1212_PXS_DATA_MASK
#define JSA1212_ALS_DATA_MASK
#define JSA1212_ALS_DT1_MASK
#define JSA1212_ALS_DT2_MASK
#define JSA1212_ALS_RNG_MASK

/* JSA1212 CONF REG bits */
#define JSA1212_CONF_PXS_MASK
#define JSA1212_CONF_PXS_ENABLE
#define JSA1212_CONF_PXS_DISABLE
#define JSA1212_CONF_ALS_MASK
#define JSA1212_CONF_ALS_ENABLE
#define JSA1212_CONF_ALS_DISABLE
#define JSA1212_CONF_IRDR_MASK
/* Proxmity sensing IRDR current sink settings */
#define JSA1212_CONF_IRDR_200MA
#define JSA1212_CONF_IRDR_100MA
#define JSA1212_CONF_PXS_SLP_MASK
#define JSA1212_CONF_PXS_SLP_0MS
#define JSA1212_CONF_PXS_SLP_12MS
#define JSA1212_CONF_PXS_SLP_50MS
#define JSA1212_CONF_PXS_SLP_75MS
#define JSA1212_CONF_PXS_SLP_100MS
#define JSA1212_CONF_PXS_SLP_200MS
#define JSA1212_CONF_PXS_SLP_400MS
#define JSA1212_CONF_PXS_SLP_800MS

/* JSA1212 INT REG bits */
#define JSA1212_INT_CTRL_MASK
#define JSA1212_INT_CTRL_EITHER
#define JSA1212_INT_CTRL_BOTH
#define JSA1212_INT_ALS_PRST_MASK
#define JSA1212_INT_ALS_PRST_1CONV
#define JSA1212_INT_ALS_PRST_4CONV
#define JSA1212_INT_ALS_PRST_8CONV
#define JSA1212_INT_ALS_PRST_16CONV
#define JSA1212_INT_ALS_FLAG_MASK
#define JSA1212_INT_ALS_FLAG_CLR
#define JSA1212_INT_PXS_PRST_MASK
#define JSA1212_INT_PXS_PRST_1CONV
#define JSA1212_INT_PXS_PRST_4CONV
#define JSA1212_INT_PXS_PRST_8CONV
#define JSA1212_INT_PXS_PRST_16CONV
#define JSA1212_INT_PXS_FLAG_MASK
#define JSA1212_INT_PXS_FLAG_CLR

/* JSA1212 ALS RNG REG bits */
#define JSA1212_ALS_RNG_0_2048
#define JSA1212_ALS_RNG_0_1024
#define JSA1212_ALS_RNG_0_512
#define JSA1212_ALS_RNG_0_256
#define JSA1212_ALS_RNG_0_128

/* JSA1212 INT threshold range */
#define JSA1212_ALS_TH_MIN
#define JSA1212_ALS_TH_MAX
#define JSA1212_PXS_TH_MIN
#define JSA1212_PXS_TH_MAX

#define JSA1212_ALS_DELAY_MS
#define JSA1212_PXS_DELAY_MS

#define JSA1212_DRIVER_NAME
#define JSA1212_REGMAP_NAME

enum jsa1212_op_mode {};

struct jsa1212_data {};

/* ALS range idx to val mapping */
static const int jsa1212_als_range_val[] =;

/* Enables or disables ALS function based on status */
static int jsa1212_als_enable(struct jsa1212_data *data, u8 status)
{}

/* Enables or disables PXS function based on status */
static int jsa1212_pxs_enable(struct jsa1212_data *data, u8 status)
{}

static int jsa1212_read_als_data(struct jsa1212_data *data,
				unsigned int *val)
{}

static int jsa1212_read_pxs_data(struct jsa1212_data *data,
				unsigned int *val)
{}

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

static const struct iio_chan_spec jsa1212_channels[] =;

static const struct iio_info jsa1212_info =;

static int jsa1212_chip_init(struct jsa1212_data *data)
{}

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

static const struct regmap_config jsa1212_regmap_config =;

static int jsa1212_probe(struct i2c_client *client)
{}

 /* power off the device */
static int jsa1212_power_off(struct jsa1212_data *data)
{}

static void jsa1212_remove(struct i2c_client *client)
{}

static int jsa1212_suspend(struct device *dev)
{}

static int jsa1212_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(jsa1212_pm_ops, jsa1212_suspend,
				jsa1212_resume);

static const struct acpi_device_id jsa1212_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, jsa1212_acpi_match);

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

static struct i2c_driver jsa1212_driver =;
module_i2c_driver();

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