linux/drivers/hwmon/sht3x.c

// SPDX-License-Identifier: GPL-2.0-or-later
/* Sensirion SHT3x-DIS humidity and temperature sensor driver.
 * The SHT3x comes in many different versions, this driver is for the
 * I2C version only.
 *
 * Copyright (C) 2016 Sensirion AG, Switzerland
 * Author: David Frey <[email protected]>
 * Author: Pascal Sachs <[email protected]>
 */

#include <asm/page.h>
#include <linux/crc8.h>
#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/jiffies.h>

/* commands (high repeatability mode) */
static const unsigned char sht3x_cmd_measure_single_hpm[] =;

/* commands (medium repeatability mode) */
static const unsigned char sht3x_cmd_measure_single_mpm[] =;

/* commands (low repeatability mode) */
static const unsigned char sht3x_cmd_measure_single_lpm[] =;

/* commands for periodic mode */
static const unsigned char sht3x_cmd_measure_periodic_mode[]   =;
static const unsigned char sht3x_cmd_break[]                   =;

/* commands for heater control */
static const unsigned char sht3x_cmd_heater_on[]               =;
static const unsigned char sht3x_cmd_heater_off[]              =;

/* other commands */
static const unsigned char sht3x_cmd_read_status_reg[]         =;
static const unsigned char sht3x_cmd_clear_status_reg[]        =;
static const unsigned char sht3x_cmd_read_serial_number[]      =;

static struct dentry *debugfs;

/* delays for single-shot mode i2c commands, both in us */
#define SHT3X_SINGLE_WAIT_TIME_HPM
#define SHT3X_SINGLE_WAIT_TIME_MPM
#define SHT3X_SINGLE_WAIT_TIME_LPM

#define SHT3X_WORD_LEN
#define SHT3X_CMD_LENGTH
#define SHT3X_CRC8_LEN
#define SHT3X_RESPONSE_LENGTH
#define SHT3X_CRC8_POLYNOMIAL
#define SHT3X_CRC8_INIT
#define SHT3X_MIN_TEMPERATURE
#define SHT3X_MAX_TEMPERATURE
#define SHT3X_MIN_HUMIDITY
#define SHT3X_MAX_HUMIDITY

enum sht3x_chips {};

enum sht3x_limits {};

enum sht3x_repeatability {};

DECLARE_CRC8_TABLE(sht3x_crc8_table);

/* periodic measure commands (high repeatability mode) */
static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] =;

/* periodic measure commands (medium repeatability) */
static const char periodic_measure_commands_mpm[][SHT3X_CMD_LENGTH] =;

/* periodic measure commands (low repeatability mode) */
static const char periodic_measure_commands_lpm[][SHT3X_CMD_LENGTH] =;

struct sht3x_limit_commands {};

static const struct sht3x_limit_commands limit_commands[] =;

#define SHT3X_NUM_LIMIT_CMD

static const u16 mode_to_update_interval[] =;

static const struct hwmon_channel_info * const sht3x_channel_info[] =;

struct sht3x_data {};

static u8 get_mode_from_update_interval(u16 value)
{}

static int sht3x_read_from_command(struct i2c_client *client,
				   struct sht3x_data *data,
				   const char *command,
				   char *buf, int length, u32 wait_time)
{}

static int sht3x_extract_temperature(u16 raw)
{}

static u32 sht3x_extract_humidity(u16 raw)
{}

static struct sht3x_data *sht3x_update_client(struct device *dev)
{}

static int temp1_input_read(struct device *dev)
{}

static int humidity1_input_read(struct device *dev)
{}

/*
 * limits_update must only be called from probe or with data_lock held
 */
static int limits_update(struct sht3x_data *data)
{}

static int temp1_limit_read(struct device *dev, int index)
{}

static int humidity1_limit_read(struct device *dev, int index)
{}

/*
 * limit_write must only be called with data_lock held
 */
static size_t limit_write(struct device *dev,
			  u8 index,
			  int temperature,
			  u32 humidity)
{}

static int temp1_limit_write(struct device *dev, int index, int val)
{}

static int humidity1_limit_write(struct device *dev, int index, int val)
{}

static void sht3x_select_command(struct sht3x_data *data)
{}

static int status_register_read(struct device *dev,
				char *buffer, int length)
{}

static int temp1_alarm_read(struct device *dev)
{}

static int humidity1_alarm_read(struct device *dev)
{}

static ssize_t heater_enable_show(struct device *dev,
				  struct device_attribute *attr,
				  char *buf)
{}

static ssize_t heater_enable_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf,
				   size_t count)
{}

static int update_interval_read(struct device *dev)
{}

static int update_interval_write(struct device *dev, int val)
{}

static ssize_t repeatability_show(struct device *dev,
				  struct device_attribute *attr,
				  char *buf)
{}

static ssize_t repeatability_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf,
				   size_t count)
{}

static SENSOR_DEVICE_ATTR_RW(heater_enable, heater_enable, 0);
static SENSOR_DEVICE_ATTR_RW(repeatability, repeatability, 0);

static struct attribute *sht3x_attrs[] =;

ATTRIBUTE_GROUPS();

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

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

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

static void sht3x_debugfs_init(struct sht3x_data *data)
{}

static void sht3x_debugfs_remove(void *sensor_dir)
{}

static int sht3x_serial_number_read(struct sht3x_data *data)
{}

static const struct hwmon_ops sht3x_ops =;

static const struct hwmon_chip_info sht3x_chip_info =;

static int sht3x_probe(struct i2c_client *client)
{}

/* device ID table */
static const struct i2c_device_id sht3x_ids[] =;

MODULE_DEVICE_TABLE(i2c, sht3x_ids);

static struct i2c_driver sht3x_i2c_driver =;

static int __init sht3x_init(void)
{}
module_init();

static void __exit sht3x_cleanup(void)
{}
module_exit(sht3x_cleanup);

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