linux/drivers/iio/temperature/mlx90632.c

// SPDX-License-Identifier: GPL-2.0
/*
 * mlx90632.c - Melexis MLX90632 contactless IR temperature sensor
 *
 * Copyright (c) 2017 Melexis <[email protected]>
 *
 * Driver for the Melexis MLX90632 I2C 16-bit IR thermopile sensor
 */
#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/iopoll.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/limits.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/math64.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>

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

/* Memory sections addresses */
#define MLX90632_ADDR_RAM
#define MLX90632_ADDR_EEPROM

/* EEPROM addresses - used at startup */
#define MLX90632_EE_CTRL
#define MLX90632_EE_I2C_ADDR
#define MLX90632_EE_VERSION
#define MLX90632_EE_P_R
#define MLX90632_EE_P_G
#define MLX90632_EE_P_T
#define MLX90632_EE_P_O
#define MLX90632_EE_Aa
#define MLX90632_EE_Ab
#define MLX90632_EE_Ba
#define MLX90632_EE_Bb
#define MLX90632_EE_Ca
#define MLX90632_EE_Cb
#define MLX90632_EE_Da
#define MLX90632_EE_Db
#define MLX90632_EE_Ea
#define MLX90632_EE_Eb
#define MLX90632_EE_Fa
#define MLX90632_EE_Fb
#define MLX90632_EE_Ga

#define MLX90632_EE_Gb
#define MLX90632_EE_Ka

#define MLX90632_EE_Ha
#define MLX90632_EE_Hb

#define MLX90632_EE_MEDICAL_MEAS1
#define MLX90632_EE_MEDICAL_MEAS2
#define MLX90632_EE_EXTENDED_MEAS1
#define MLX90632_EE_EXTENDED_MEAS2
#define MLX90632_EE_EXTENDED_MEAS3

/* Register addresses - volatile */
#define MLX90632_REG_I2C_ADDR

/* Control register address - volatile */
#define MLX90632_REG_CONTROL
#define MLX90632_CFG_PWR_MASK
#define MLX90632_CFG_MTYP_MASK
#define MLX90632_CFG_SOB_MASK

/* PowerModes statuses */
#define MLX90632_PWR_STATUS(ctrl_val)
#define MLX90632_PWR_STATUS_HALT
#define MLX90632_PWR_STATUS_SLEEP_STEP
#define MLX90632_PWR_STATUS_STEP
#define MLX90632_PWR_STATUS_CONTINUOUS

#define MLX90632_EE_RR
#define MLX90632_REFRESH_RATE(ee_val)
					/* Extract Refresh Rate from ee register */
#define MLX90632_REFRESH_RATE_STATUS(refresh_rate)

/* Measurement types */
#define MLX90632_MTYP_MEDICAL
#define MLX90632_MTYP_EXTENDED

/* Measurement type select*/
#define MLX90632_MTYP_STATUS(ctrl_val)
#define MLX90632_MTYP_STATUS_MEDICAL
#define MLX90632_MTYP_STATUS_EXTENDED

/* I2C command register - volatile */
#define MLX90632_REG_I2C_CMD

/* Device status register - volatile */
#define MLX90632_REG_STATUS
#define MLX90632_STAT_BUSY
#define MLX90632_STAT_EE_BUSY
#define MLX90632_STAT_BRST
#define MLX90632_STAT_CYCLE_POS
#define MLX90632_STAT_DATA_RDY

/* RAM_MEAS address-es for each channel */
#define MLX90632_RAM_1(meas_num)
#define MLX90632_RAM_2(meas_num)
#define MLX90632_RAM_3(meas_num)

/* Name important RAM_MEAS channels */
#define MLX90632_RAM_DSP5_EXTENDED_AMBIENT_1
#define MLX90632_RAM_DSP5_EXTENDED_AMBIENT_2
#define MLX90632_RAM_DSP5_EXTENDED_OBJECT_1
#define MLX90632_RAM_DSP5_EXTENDED_OBJECT_2
#define MLX90632_RAM_DSP5_EXTENDED_OBJECT_3
#define MLX90632_RAM_DSP5_EXTENDED_OBJECT_4
#define MLX90632_RAM_DSP5_EXTENDED_OBJECT_5
#define MLX90632_RAM_DSP5_EXTENDED_OBJECT_6

/* Magic constants */
#define MLX90632_ID_MEDICAL
#define MLX90632_ID_CONSUMER
#define MLX90632_ID_EXTENDED
#define MLX90632_ID_MASK
#define MLX90632_DSP_VERSION
#define MLX90632_DSP_MASK
#define MLX90632_RESET_CMD
#define MLX90632_REF_12
#define MLX90632_REF_3
#define MLX90632_MAX_MEAS_NUM
#define MLX90632_SLEEP_DELAY_MS
#define MLX90632_EXTENDED_LIMIT
#define MLX90632_MEAS_MAX_TIME

/**
 * struct mlx90632_data - private data for the MLX90632 device
 * @client: I2C client of the device
 * @lock: Internal mutex for multiple reads for single measurement
 * @regmap: Regmap of the device
 * @emissivity: Object emissivity from 0 to 1000 where 1000 = 1.
 * @mtyp: Measurement type physical sensor configuration for extended range
 *        calculations
 * @object_ambient_temperature: Ambient temperature at object (might differ of
 *                              the ambient temperature of sensor.
 * @regulator: Regulator of the device
 * @powerstatus: Current POWER status of the device
 * @interaction_ts: Timestamp of the last temperature read that is used
 *		    for power management in jiffies
 */
struct mlx90632_data {};

static const struct regmap_range mlx90632_volatile_reg_range[] =;

static const struct regmap_access_table mlx90632_volatile_regs_tbl =;

static const struct regmap_range mlx90632_read_reg_range[] =;

static const struct regmap_access_table mlx90632_readable_regs_tbl =;

static const struct regmap_range mlx90632_no_write_reg_range[] =;

static const struct regmap_access_table mlx90632_writeable_regs_tbl =;

static const struct regmap_config mlx90632_regmap =;

static int mlx90632_pwr_set_sleep_step(struct regmap *regmap)
{}

static int mlx90632_pwr_continuous(struct regmap *regmap)
{}

/**
 * mlx90632_reset_delay() - Give the mlx90632 some time to reset properly
 * If this is not done, the following I2C command(s) will not be accepted.
 */
static void mlx90632_reset_delay(void)
{}

static int mlx90632_get_measurement_time(struct regmap *regmap, u16 meas)
{}

static int mlx90632_calculate_dataset_ready_time(struct mlx90632_data *data)
{}

/**
 * mlx90632_perform_measurement() - Trigger and retrieve current measurement cycle
 * @data: pointer to mlx90632_data object containing regmap information
 *
 * Perform a measurement and return latest measurement cycle position reported
 * by sensor. This is a blocking function for 500ms, as that is default sensor
 * refresh rate.
 */
static int mlx90632_perform_measurement(struct mlx90632_data *data)
{}

/**
 * mlx90632_perform_measurement_burst() - Trigger and retrieve current measurement
 * cycle in step sleep mode
 * @data: pointer to mlx90632_data object containing regmap information
 *
 * Perform a measurement and return 2 as measurement cycle position reported
 * by sensor. This is a blocking function for amount dependent on the sensor
 * refresh rate.
 */
static int mlx90632_perform_measurement_burst(struct mlx90632_data *data)
{}

static int mlx90632_set_meas_type(struct mlx90632_data *data, u8 type)
{}

static int mlx90632_channel_new_select(int perform_ret, uint8_t *channel_new,
				       uint8_t *channel_old)
{}

static int mlx90632_read_ambient_raw(struct regmap *regmap,
				     s16 *ambient_new_raw, s16 *ambient_old_raw)
{}

static int mlx90632_read_object_raw(struct regmap *regmap,
				    int perform_measurement_ret,
				    s16 *object_new_raw, s16 *object_old_raw)
{}

static int mlx90632_read_all_channel(struct mlx90632_data *data,
				     s16 *ambient_new_raw, s16 *ambient_old_raw,
				     s16 *object_new_raw, s16 *object_old_raw)
{}

static int mlx90632_read_ambient_raw_extended(struct regmap *regmap,
					      s16 *ambient_new_raw, s16 *ambient_old_raw)
{}

static int mlx90632_read_object_raw_extended(struct regmap *regmap, s16 *object_new_raw)
{}

static int mlx90632_read_all_channel_extended(struct mlx90632_data *data, s16 *object_new_raw,
					      s16 *ambient_new_raw, s16 *ambient_old_raw)
{}

static int mlx90632_read_ee_register(struct regmap *regmap, u16 reg_lsb,
				     s32 *reg_value)
{}

static s64 mlx90632_preprocess_temp_amb(s16 ambient_new_raw,
					s16 ambient_old_raw, s16 Gb)
{}

static s64 mlx90632_preprocess_temp_obj(s16 object_new_raw, s16 object_old_raw,
					s16 ambient_new_raw,
					s16 ambient_old_raw, s16 Ka)
{}

static s64 mlx90632_preprocess_temp_obj_extended(s16 object_new_raw, s16 ambient_new_raw,
						 s16 ambient_old_raw, s16 Ka)
{}

static s32 mlx90632_calc_temp_ambient(s16 ambient_new_raw, s16 ambient_old_raw,
				      s32 P_T, s32 P_R, s32 P_G, s32 P_O, s16 Gb)
{}

static s32 mlx90632_calc_temp_object_iteration(s32 prev_object_temp, s64 object,
					       s64 TAdut, s64 TAdut4, s32 Fa, s32 Fb,
					       s32 Ga, s16 Ha, s16 Hb,
					       u16 emissivity)
{}

static s64 mlx90632_calc_ta4(s64 TAdut, s64 scale)
{}

static s32 mlx90632_calc_temp_object(s64 object, s64 ambient, s32 Ea, s32 Eb,
				     s32 Fa, s32 Fb, s32 Ga, s16 Ha, s16 Hb,
				     u16 tmp_emi)
{}

static s32 mlx90632_calc_temp_object_extended(s64 object, s64 ambient, s64 reflected,
					      s32 Ea, s32 Eb, s32 Fa, s32 Fb, s32 Ga,
					      s16 Ha, s16 Hb, u16 tmp_emi)
{}

static int mlx90632_calc_object_dsp105(struct mlx90632_data *data, int *val)
{}

static int mlx90632_calc_ambient_dsp105(struct mlx90632_data *data, int *val)
{}

static int mlx90632_get_refresh_rate(struct mlx90632_data *data,
				     int *refresh_rate)
{}

static const int mlx90632_freqs[][2] =;

/**
 * mlx90632_pm_interraction_wakeup() - Measure time between user interactions to change powermode
 * @data: pointer to mlx90632_data object containing interaction_ts information
 *
 * Switch to continuous mode when interaction is faster than MLX90632_MEAS_MAX_TIME. Update the
 * interaction_ts for each function call with the jiffies to enable measurement between function
 * calls. Initial value of the interaction_ts needs to be set before this function call.
 */
static int mlx90632_pm_interraction_wakeup(struct mlx90632_data *data)
{}

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

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

static int mlx90632_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 mlx90632_channels[] =;

static const struct iio_info mlx90632_info =;

static void mlx90632_sleep(void *_data)
{}

static int mlx90632_suspend(struct mlx90632_data *data)
{}

static int mlx90632_wakeup(struct mlx90632_data *data)
{}

static void mlx90632_disable_regulator(void *_data)
{}

static int mlx90632_enable_regulator(struct mlx90632_data *data)
{}

static int mlx90632_probe(struct i2c_client *client)
{}

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

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

static int mlx90632_pm_suspend(struct device *dev)
{}

static int mlx90632_pm_resume(struct device *dev)
{}

static int mlx90632_pm_runtime_suspend(struct device *dev)
{}

static const struct dev_pm_ops mlx90632_pm_ops =;

static struct i2c_driver mlx90632_driver =;
module_i2c_driver();

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