linux/drivers/hwmon/chipcap2.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * cc2.c - Support for the Amphenol ChipCap 2 relative humidity, temperature sensor
 *
 * Part numbers supported:
 * CC2D23, CC2D23S, CC2D25, CC2D25S, CC2D33, CC2D33S, CC2D35, CC2D35S
 *
 * Author: Javier Carrasco <[email protected]>
 *
 * Datasheet and application notes:
 * https://www.amphenol-sensors.com/en/telaire/humidity/527-humidity-sensors/3095-chipcap-2
 */

#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/hwmon.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>

#define CC2_START_CM
#define CC2_START_NOM
#define CC2_R_ALARM_H_ON
#define CC2_R_ALARM_H_OFF
#define CC2_R_ALARM_L_ON
#define CC2_R_ALARM_L_OFF
#define CC2_RW_OFFSET
#define CC2_W_ALARM_H_ON
#define CC2_W_ALARM_H_OFF
#define CC2_W_ALARM_L_ON
#define CC2_W_ALARM_L_OFF

#define CC2_STATUS_FIELD
#define CC2_STATUS_VALID_DATA
#define CC2_STATUS_STALE_DATA
#define CC2_STATUS_CMD_MODE

#define CC2_RESPONSE_FIELD
#define CC2_RESPONSE_BUSY
#define CC2_RESPONSE_ACK
#define CC2_RESPONSE_NACK

#define CC2_ERR_CORR_EEPROM
#define CC2_ERR_UNCORR_EEPROM
#define CC2_ERR_RAM_PARITY
#define CC2_ERR_CONFIG_LOAD

#define CC2_EEPROM_SIZE
#define CC2_EEPROM_DATA_LEN
#define CC2_MEASUREMENT_DATA_LEN

#define CC2_RH_DATA_FIELD

/* ensure clean off -> on transitions */
#define CC2_POWER_CYCLE_MS

#define CC2_STARTUP_TO_DATA_MS
#define CC2_RESP_START_CM_US
#define CC2_RESP_EEPROM_R_US
#define CC2_RESP_EEPROM_W_MS
#define CC2_STARTUP_TIME_US

#define CC2_RH_MAX

#define CC2_CM_RETRIES

struct cc2_rh_alarm_info {};

struct cc2_data {};

enum cc2_chan_addr {};

/* %RH as a per cent mille from a register value */
static long cc2_rh_convert(u16 data)
{}

/* convert %RH to a register value */
static u16 cc2_rh_to_reg(long data)
{}

/* temperature in milli degrees celsius from a register value */
static long cc2_temp_convert(u16 data)
{}

static int cc2_enable(struct cc2_data *data)
{}

static void cc2_disable(struct cc2_data *data)
{}

static int cc2_cmd_response_diagnostic(struct device *dev, u8 status)
{}

static int cc2_read_command_status(struct i2c_client *client)
{}

/*
 * The command mode is only accessible after sending the START_CM command in the
 * first 10 ms after power-up. Only in case the command window is missed,
 * CC2_CM_RETRIES retries are attempted before giving up and returning an error.
 */
static int cc2_command_mode_start(struct cc2_data *data)
{}

/* Sending a Start_NOM command finishes the command mode immediately with no
 * reply and the device enters normal operation mode
 */
static int cc2_command_mode_finish(struct cc2_data *data)
{}

static int cc2_write_reg(struct cc2_data *data, u8 reg, u16 val)
{}

static int cc2_read_reg(struct cc2_data *data, u8 reg, u16 *val)
{}

static int cc2_get_reg_val(struct cc2_data *data, u8 reg, long *val)
{}

static int cc2_data_fetch(struct i2c_client *client,
			  enum hwmon_sensor_types type, long *val)
{}

static int cc2_read_measurement(struct cc2_data *data,
				enum hwmon_sensor_types type, long *val)
{}

/*
 * A measurement requires enabling the device, waiting for the automatic
 * measurement to finish, reading the measurement data and disabling the device
 * again.
 */
static int cc2_measurement(struct cc2_data *data, enum hwmon_sensor_types type,
			   long *val)
{}

/*
 * In order to check alarm status, the corresponding ALARM_OFF (hysteresis)
 * register must be read and a new measurement must be carried out to trigger
 * the alarm signals. Given that the device carries out a measurement after
 * exiting the command mode, there is no need to force two power-up sequences.
 * Instead, a NOM command is sent and the device is disabled after the
 * measurement is read.
 */
static int cc2_read_hyst_and_measure(struct cc2_data *data, u8 reg,
				     long *hyst, long *measurement)
{}

static umode_t cc2_is_visible(const void *data, enum hwmon_sensor_types type,
			      u32 attr, int channel)
{}

static irqreturn_t cc2_ready_interrupt(int irq, void *data)
{}

static irqreturn_t cc2_low_interrupt(int irq, void *data)
{}

static irqreturn_t cc2_high_interrupt(int irq, void *data)
{}

static int cc2_humidity_min_alarm_status(struct cc2_data *data, long *val)
{}

static int cc2_humidity_max_alarm_status(struct cc2_data *data, long *val)
{}

static int cc2_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
		    int channel, long *val)
{}

static int cc2_write(struct device *dev, enum hwmon_sensor_types type, u32 attr,
		     int channel, long val)
{}

static int cc2_request_ready_irq(struct cc2_data *data, struct device *dev)
{}

static int cc2_request_alarm_irqs(struct cc2_data *data, struct device *dev)
{}

static const struct hwmon_channel_info *cc2_info[] =;

static const struct hwmon_ops cc2_hwmon_ops =;

static const struct hwmon_chip_info cc2_chip_info =;

static int cc2_probe(struct i2c_client *client)
{}

static void cc2_remove(struct i2c_client *client)
{}

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

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

static struct i2c_driver cc2_driver =;
module_i2c_driver();

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