linux/drivers/iio/light/max44009.c

// SPDX-License-Identifier: GPL-2.0
/*
 * max44009.c - Support for MAX44009 Ambient Light Sensor
 *
 * Copyright (c) 2019 Robert Eshleman <[email protected]>
 *
 * Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX44009.pdf
 *
 * TODO: Support continuous mode and configuring from manual mode to
 *	 automatic mode.
 *
 * Default I2C address: 0x4a
 */

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/bits.h>
#include <linux/i2c.h>
#include <linux/iio/events.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/util_macros.h>

#define MAX44009_DRV_NAME

/* Registers in datasheet order */
#define MAX44009_REG_INT_STATUS
#define MAX44009_REG_INT_EN
#define MAX44009_REG_CFG
#define MAX44009_REG_LUX_HI
#define MAX44009_REG_LUX_LO
#define MAX44009_REG_UPPER_THR
#define MAX44009_REG_LOWER_THR
#define MAX44009_REG_THR_TIMER

#define MAX44009_CFG_TIM_MASK
#define MAX44009_CFG_MAN_MODE_MASK

/* The maximum rising threshold for the max44009 */
#define MAX44009_MAXIMUM_THRESHOLD

#define MAX44009_THRESH_EXP_MASK
#define MAX44009_THRESH_EXP_RSHIFT
#define MAX44009_THRESH_MANT_LSHIFT
#define MAX44009_THRESH_MANT_MASK

#define MAX44009_UPPER_THR_MINIMUM

/* The max44009 always scales raw readings by 0.045 and is non-configurable */
#define MAX44009_SCALE_NUMERATOR
#define MAX44009_SCALE_DENOMINATOR

/* The fixed-point fractional multiplier for de-scaling threshold values */
#define MAX44009_FRACT_MULT

static const u32 max44009_int_time_ns_array[] =;

static const char max44009_int_time_str[] =;

struct max44009_data {};

static const struct iio_event_spec max44009_event_spec[] =;

static const struct iio_chan_spec max44009_channels[] =;

static int max44009_read_int_time(struct max44009_data *data)
{}

static int max44009_write_int_time(struct max44009_data *data,
				   int val, int val2)
{}

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

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

static int max44009_lux_raw(u8 hi, u8 lo)
{}

#define MAX44009_READ_LUX_XFER_LEN

static int max44009_read_lux_raw(struct max44009_data *data)
{}

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

static IIO_CONST_ATTR(illuminance_integration_time_available,
		      max44009_int_time_str);

static struct attribute *max44009_attributes[] =;

static const struct attribute_group max44009_attribute_group =;

static int max44009_threshold_byte_from_fraction(int integral, int fractional)
{}

static int max44009_get_thr_reg(enum iio_event_direction dir)
{}

static int max44009_write_event_value(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 max44009_read_threshold(struct iio_dev *indio_dev,
				   enum iio_event_direction dir)
{}

static int max44009_read_event_value(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 max44009_write_event_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 max44009_read_event_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 max44009_info =;

static irqreturn_t max44009_threaded_irq_handler(int irq, void *p)
{}

static int max44009_probe(struct i2c_client *client)
{}

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

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

static struct i2c_driver max44009_driver =;
module_i2c_driver();

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