linux/drivers/iio/temperature/mlx90614.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * mlx90614.c - Support for Melexis MLX90614/MLX90615 contactless IR temperature sensor
 *
 * Copyright (c) 2014 Peter Meerwald <[email protected]>
 * Copyright (c) 2015 Essensium NV
 * Copyright (c) 2015 Melexis
 *
 * Driver for the Melexis MLX90614/MLX90615 I2C 16-bit IR thermopile sensor
 *
 * MLX90614 - 17-bit ADC + MLX90302 DSP
 * MLX90615 - 16-bit ADC + MLX90325 DSP
 *
 * (7-bit I2C slave address 0x5a, 100KHz bus speed only!)
 *
 * To wake up from sleep mode, the SDA line must be held low while SCL is high
 * for at least 33ms.  This is achieved with an extra GPIO that can be connected
 * directly to the SDA line.  In normal operation, the GPIO is set as input and
 * will not interfere in I2C communication.  While the GPIO is driven low, the
 * i2c adapter is locked since it cannot be used by other clients.  The SCL line
 * always has a pull-up so we do not need an extra GPIO to drive it high.  If
 * the "wakeup" GPIO is not given, power management will be disabled.
 */

#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/jiffies.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>

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

#define MLX90614_OP_RAM
#define MLX90614_OP_EEPROM
#define MLX90614_OP_SLEEP

#define MLX90615_OP_EEPROM
#define MLX90615_OP_RAM
#define MLX90615_OP_SLEEP

/* Control bits in configuration register */
#define MLX90614_CONFIG_IIR_SHIFT
#define MLX90614_CONFIG_IIR_MASK
#define MLX90614_CONFIG_DUAL_SHIFT
#define MLX90614_CONFIG_DUAL_MASK
#define MLX90614_CONFIG_FIR_SHIFT
#define MLX90614_CONFIG_FIR_MASK

#define MLX90615_CONFIG_IIR_SHIFT
#define MLX90615_CONFIG_IIR_MASK

/* Timings (in ms) */
#define MLX90614_TIMING_EEPROM
#define MLX90614_TIMING_WAKEUP
#define MLX90614_TIMING_STARTUP

#define MLX90615_TIMING_WAKEUP

#define MLX90614_AUTOSLEEP_DELAY

/* Magic constants */
#define MLX90614_CONST_OFFSET_DEC
#define MLX90614_CONST_OFFSET_REM
#define MLX90614_CONST_SCALE
#define MLX90614_CONST_FIR

/* Non-constant mask variant of FIELD_GET() and FIELD_PREP() */
#define field_get(_mask, _reg)
#define field_prep(_mask, _val)

struct mlx_chip_info {};

struct mlx90614_data {};

/*
 * Erase an address and write word.
 * The mutex must be locked before calling.
 */
static s32 mlx90614_write_word(const struct i2c_client *client, u8 command,
			       u16 value)
{}

/*
 * Find the IIR value inside iir_values array and return its position
 * which is equivalent to the bit value in sensor register
 */
static inline s32 mlx90614_iir_search(const struct i2c_client *client,
				      int value)
{}

#ifdef CONFIG_PM
/*
 * If @startup is true, make sure MLX90614_TIMING_STARTUP ms have elapsed since
 * the last wake-up.  This is normally only needed to get a valid temperature
 * reading.  EEPROM access does not need such delay.
 * Return 0 on success, <0 on error.
 */
static int mlx90614_power_get(struct mlx90614_data *data, bool startup)
{}

static void mlx90614_power_put(struct mlx90614_data *data)
{}
#else
static inline int mlx90614_power_get(struct mlx90614_data *data, bool startup)
{
	return 0;
}

static inline void mlx90614_power_put(struct mlx90614_data *data)
{
}
#endif

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

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

static int mlx90614_write_raw_get_fmt(struct iio_dev *indio_dev,
				     struct iio_chan_spec const *channel,
				     long mask)
{}

static int mlx90614_read_avail(struct iio_dev *indio_dev,
			       struct iio_chan_spec const *chan,
			       const int **vals, int *type, int *length,
			       long mask)
{}

static const struct iio_chan_spec mlx90614_channels[] =;

static const struct iio_info mlx90614_info =;

#ifdef CONFIG_PM
static int mlx90614_sleep(struct mlx90614_data *data)
{}

static int mlx90614_wakeup(struct mlx90614_data *data)
{}

/* Return wake-up GPIO or NULL if sleep functionality should be disabled. */
static struct gpio_desc *mlx90614_probe_wakeup(struct i2c_client *client)
{}
#else
static inline int mlx90614_sleep(struct mlx90614_data *data)
{
	return -ENOSYS;
}
static inline int mlx90614_wakeup(struct mlx90614_data *data)
{
	return -ENOSYS;
}
static inline struct gpio_desc *mlx90614_probe_wakeup(struct i2c_client *client)
{
	return NULL;
}
#endif

/* Return 0 for single sensor, 1 for dual sensor, <0 on error. */
static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
{}

static int mlx90614_probe(struct i2c_client *client)
{}

static void mlx90614_remove(struct i2c_client *client)
{}

static const struct mlx_chip_info mlx90614_chip_info =;

static const struct mlx_chip_info mlx90615_chip_info =;

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

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

static int mlx90614_pm_suspend(struct device *dev)
{}

static int mlx90614_pm_resume(struct device *dev)
{}

static int mlx90614_pm_runtime_suspend(struct device *dev)
{}

static int mlx90614_pm_runtime_resume(struct device *dev)
{}

static const struct dev_pm_ops mlx90614_pm_ops =;

static struct i2c_driver mlx90614_driver =;
module_i2c_driver();

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