linux/drivers/iio/temperature/mlx90635.c

// SPDX-License-Identifier: GPL-2.0
/*
 * mlx90635.c - Melexis MLX90635 contactless IR temperature sensor
 *
 * Copyright (c) 2023 Melexis <[email protected]>
 *
 * Driver for the Melexis MLX90635 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>

/* Memory sections addresses */
#define MLX90635_ADDR_RAM
#define MLX90635_ADDR_EEPROM

/* EEPROM addresses - used at startup */
#define MLX90635_EE_I2C_CFG
#define MLX90635_EE_CTRL1
#define MLX90635_EE_CTRL2

#define MLX90635_EE_Ha
#define MLX90635_EE_Hb
#define MLX90635_EE_Fa
#define MLX90635_EE_FASCALE
#define MLX90635_EE_Ga
#define MLX90635_EE_Fb
#define MLX90635_EE_Ea
#define MLX90635_EE_Eb
#define MLX90635_EE_P_G
#define MLX90635_EE_P_O
#define MLX90635_EE_Aa
#define MLX90635_EE_VERSION
#define MLX90635_EE_Gb

/* Device status register - volatile */
#define MLX90635_REG_STATUS
#define MLX90635_STAT_BUSY
#define MLX90635_STAT_BRST
#define MLX90635_STAT_CYCLE_POS
#define MLX90635_STAT_END_CONV
#define MLX90635_STAT_DATA_RDY

/* EEPROM control register address - volatile */
#define MLX90635_REG_EE
#define MLX90635_EE_ACTIVE
#define MLX90635_EE_BUSY_MASK

#define MLX90635_REG_CMD

/* Control register1 address - volatile */
#define MLX90635_REG_CTRL1
#define MLX90635_CTRL1_REFRESH_RATE_MASK
#define MLX90635_CTRL1_RES_CTRL_MASK
#define MLX90635_CTRL1_TABLE_MASK

/* Control register2 address - volatile */
#define MLX90635_REG_CTRL2
#define MLX90635_CTRL2_BURST_CNT_MASK
#define MLX90635_CTRL2_MODE_MASK
#define MLX90635_CTRL2_SOB_MASK

/* PowerModes statuses */
#define MLX90635_PWR_STATUS_HALT
#define MLX90635_PWR_STATUS_SLEEP_STEP
#define MLX90635_PWR_STATUS_STEP
#define MLX90635_PWR_STATUS_CONTINUOUS

/* Measurement data addresses */
#define MLX90635_RESULT_1
#define MLX90635_RESULT_2
#define MLX90635_RESULT_3
#define MLX90635_RESULT_4
#define MLX90635_RESULT_5

/* Timings (ms) */
#define MLX90635_TIMING_RST_MIN
#define MLX90635_TIMING_RST_MAX
#define MLX90635_TIMING_POLLING
#define MLX90635_TIMING_EE_ACTIVE_MIN
#define MLX90635_TIMING_EE_ACTIVE_MAX

/* Magic constants */
#define MLX90635_ID_DSPv1
#define MLX90635_RESET_CMD
#define MLX90635_MAX_MEAS_NUM
#define MLX90635_PTAT_DIV
#define MLX90635_IR_DIV
#define MLX90635_SLEEP_DELAY_MS
#define MLX90635_MEAS_MAX_TIME
#define MLX90635_READ_RETRIES
#define MLX90635_VERSION_MASK
#define MLX90635_DSP_VERSION(reg)
#define MLX90635_DSP_FIXED


/**
 * struct mlx90635_data - private data for the MLX90635 device
 * @client: I2C client of the device
 * @lock: Internal mutex because multiple reads are needed for single triggered
 *	  measurement to ensure data consistency
 * @regmap: Regmap of the device registers
 * @regmap_ee: Regmap of the device EEPROM which can be cached
 * @emissivity: Object emissivity from 0 to 1000 where 1000 = 1
 * @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 mlx90635_data {};

static const struct regmap_range mlx90635_volatile_reg_range[] =;

static const struct regmap_access_table mlx90635_volatile_regs_tbl =;

static const struct regmap_range mlx90635_read_reg_range[] =;

static const struct regmap_access_table mlx90635_readable_regs_tbl =;

static const struct regmap_range mlx90635_no_write_reg_range[] =;

static const struct regmap_access_table mlx90635_writeable_regs_tbl =;

static const struct regmap_config mlx90635_regmap =;

static const struct regmap_range mlx90635_read_ee_range[] =;

static const struct regmap_access_table mlx90635_readable_ees_tbl =;

static const struct regmap_range mlx90635_no_write_ee_range[] =;

static const struct regmap_access_table mlx90635_writeable_ees_tbl =;

static const struct regmap_config mlx90635_regmap_ee =;

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

static int mlx90635_pwr_sleep_step(struct mlx90635_data *data)
{}

static int mlx90635_pwr_continuous(struct mlx90635_data *data)
{}

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

static int mlx90635_read_ee_ambient(struct regmap *regmap, s16 *PG, s16 *PO, s16 *Gb)
{}

static int mlx90635_read_ee_object(struct regmap *regmap, u32 *Ea, u32 *Eb, u32 *Fa, s16 *Fb,
				   s16 *Ga, s16 *Gb, s16 *Ha, s16 *Hb, u16 *Fa_scale)
{}

static int mlx90635_calculate_dataset_ready_time(struct mlx90635_data *data, int *refresh_time)
{}

static int mlx90635_perform_measurement_burst(struct mlx90635_data *data)
{}

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

static int mlx90635_read_object_raw(struct regmap *regmap, s16 *object_raw)
{}

static int mlx90635_read_all_channel(struct mlx90635_data *data,
				     s16 *ambient_new_raw, s16 *ambient_old_raw,
				     s16 *object_raw)
{}

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

static s64 mlx90635_preprocess_temp_obj(s16 object_raw,
					s16 ambient_new_raw,
					s16 ambient_old_raw, s16 Gb)
{}

static s32 mlx90635_calc_temp_ambient(s16 ambient_new_raw, s16 ambient_old_raw,
				      u16 P_G, u16 P_O, s16 Gb)
{}

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

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

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

static int mlx90635_calc_object(struct mlx90635_data *data, int *val)
{}

static int mlx90635_calc_ambient(struct mlx90635_data *data, int *val)
{}

static int mlx90635_get_refresh_rate(struct mlx90635_data *data,
				     unsigned int *refresh_rate)
{}

static const struct {} mlx90635_freqs[] =;

/**
 * mlx90635_pm_interaction_wakeup() - Measure time between user interactions to change powermode
 * @data: pointer to mlx90635_data object containing interaction_ts information
 *
 * Switch to continuous mode when interaction is faster than MLX90635_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 mlx90635_pm_interaction_wakeup(struct mlx90635_data *data)
{}

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

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

static int mlx90635_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 mlx90635_channels[] =;

static const struct iio_info mlx90635_info =;

static void mlx90635_sleep(void *_data)
{}

static int mlx90635_suspend(struct mlx90635_data *data)
{}

static int mlx90635_wakeup(struct mlx90635_data *data)
{}

static void mlx90635_disable_regulator(void *_data)
{}

static int mlx90635_enable_regulator(struct mlx90635_data *data)
{}

static int mlx90635_probe(struct i2c_client *client)
{}

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

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

static int mlx90635_pm_suspend(struct device *dev)
{}

static int mlx90635_pm_resume(struct device *dev)
{}

static int mlx90635_pm_runtime_suspend(struct device *dev)
{}

static const struct dev_pm_ops mlx90635_pm_ops =;

static struct i2c_driver mlx90635_driver =;
module_i2c_driver();

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