linux/drivers/iio/light/tsl2563.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * drivers/iio/light/tsl2563.c
 *
 * Copyright (C) 2008 Nokia Corporation
 *
 * Written by Timo O. Karjalainen <[email protected]>
 * Contact: Amit Kucheria <[email protected]>
 *
 * Converted to IIO driver
 * Amit Kucheria <[email protected]>
 */

#include <linux/bits.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/math.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pm.h>
#include <linux/property.h>
#include <linux/sched.h>
#include <linux/slab.h>

#include <linux/iio/events.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>

/* Use this many bits for fraction part. */
#define ADC_FRAC_BITS

/* Given number of 1/10000's in ADC_FRAC_BITS precision. */
#define FRAC10K(f)

/* Bits used for fraction in calibration coefficients.*/
#define CALIB_FRAC_BITS
/* Decimal 10^(digits in sysfs presentation) */
#define CALIB_BASE_SYSFS

#define TSL2563_CMD
#define TSL2563_CLEARINT

#define TSL2563_REG_CTRL
#define TSL2563_REG_TIMING
#define TSL2563_REG_LOW
#define TSL2563_REG_HIGH
#define TSL2563_REG_INT
#define TSL2563_REG_ID
#define TSL2563_REG_DATA0
#define TSL2563_REG_DATA1

#define TSL2563_CMD_POWER_ON
#define TSL2563_CMD_POWER_OFF
#define TSL2563_CTRL_POWER_MASK

#define TSL2563_TIMING_13MS
#define TSL2563_TIMING_100MS
#define TSL2563_TIMING_400MS
#define TSL2563_TIMING_MASK
#define TSL2563_TIMING_GAIN16
#define TSL2563_TIMING_GAIN1

#define TSL2563_INT_DISABLED
#define TSL2563_INT_LEVEL
#define TSL2563_INT_MASK
#define TSL2563_INT_PERSIST(n)

struct tsl2563_gainlevel_coeff {};

static const struct tsl2563_gainlevel_coeff tsl2563_gainlevel_table[] =;

struct tsl2563_chip {};

static int tsl2563_set_power(struct tsl2563_chip *chip, int on)
{}

/*
 * Return value is 0 for off, 1 for on, or a negative error
 * code if reading failed.
 */
static int tsl2563_get_power(struct tsl2563_chip *chip)
{}

static int tsl2563_configure(struct tsl2563_chip *chip)
{}

static void tsl2563_poweroff_work(struct work_struct *work)
{}

static int tsl2563_detect(struct tsl2563_chip *chip)
{}

static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id)
{}

static int tsl2563_configure_irq(struct tsl2563_chip *chip, bool enable)
{}

/*
 * "Normalized" ADC value is one obtained with 400ms of integration time and
 * 16x gain. This function returns the number of bits of shift needed to
 * convert between normalized values and HW values obtained using given
 * timing and gain settings.
 */
static int tsl2563_adc_shiftbits(u8 timing)
{}

/* Convert a HW ADC value to normalized scale. */
static u32 tsl2563_normalize_adc(u16 adc, u8 timing)
{}

static void tsl2563_wait_adc(struct tsl2563_chip *chip)
{}

static int tsl2563_adjust_gainlevel(struct tsl2563_chip *chip, u16 adc)
{}

static int tsl2563_get_adc(struct tsl2563_chip *chip)
{}

static inline int tsl2563_calib_to_sysfs(u32 calib)
{}

static inline u32 tsl2563_calib_from_sysfs(int value)
{}

/*
 * Conversions between lux and ADC values.
 *
 * The basic formula is lux = c0 * adc0 - c1 * adc1, where c0 and c1 are
 * appropriate constants. Different constants are needed for different
 * kinds of light, determined by the ratio adc1/adc0 (basically the ratio
 * of the intensities in infrared and visible wavelengths). lux_table below
 * lists the upper threshold of the adc1/adc0 ratio and the corresponding
 * constants.
 */

struct tsl2563_lux_coeff {};

static const struct tsl2563_lux_coeff lux_table[] =;

/* Convert normalized, scaled ADC values to lux. */
static unsigned int tsl2563_adc_to_lux(u32 adc0, u32 adc1)
{}

/* Apply calibration coefficient to ADC count. */
static u32 tsl2563_calib_adc(u32 adc, u32 calib)
{}

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

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

static const struct iio_event_spec tsl2563_events[] =;

static const struct iio_chan_spec tsl2563_channels[] =;

static int tsl2563_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 tsl2563_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 irqreturn_t tsl2563_event_handler(int irq, void *private)
{}

static int tsl2563_write_interrupt_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 tsl2563_read_interrupt_config(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan, enum iio_event_type type,
	enum iio_event_direction dir)
{}

static const struct iio_info tsl2563_info_no_irq =;

static const struct iio_info tsl2563_info =;

static int tsl2563_probe(struct i2c_client *client)
{}

static void tsl2563_remove(struct i2c_client *client)
{}

static int tsl2563_suspend(struct device *dev)
{}

static int tsl2563_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(tsl2563_pm_ops, tsl2563_suspend,
				tsl2563_resume);

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

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

static struct i2c_driver tsl2563_i2c_driver =;
module_i2c_driver();

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