linux/drivers/hwmon/adt7470.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * A hwmon driver for the Analog Devices ADT7470
 * Copyright (C) 2007 IBM
 *
 * Author: Darrick J. Wong <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/log2.h>
#include <linux/kthread.h>
#include <linux/regmap.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/util_macros.h>

/* Addresses to scan */
static const unsigned short normal_i2c[] =;

/* ADT7470 registers */
#define ADT7470_REG_BASE_ADDR
#define ADT7470_REG_TEMP_BASE_ADDR
#define ADT7470_REG_TEMP_MAX_ADDR
#define ADT7470_REG_FAN_BASE_ADDR
#define ADT7470_REG_FAN_MAX_ADDR
#define ADT7470_REG_PWM_BASE_ADDR
#define ADT7470_REG_PWM_MAX_ADDR
#define ADT7470_REG_PWM_MAX_BASE_ADDR
#define ADT7470_REG_PWM_MAX_MAX_ADDR
#define ADT7470_REG_CFG
#define ADT7470_STRT_MASK
#define ADT7470_TEST_MASK
#define ADT7470_FSPD_MASK
#define ADT7470_T05_STB_MASK
#define ADT7470_REG_ALARM1
#define ADT7470_R1T_ALARM
#define ADT7470_R2T_ALARM
#define ADT7470_R3T_ALARM
#define ADT7470_R4T_ALARM
#define ADT7470_R5T_ALARM
#define ADT7470_R6T_ALARM
#define ADT7470_R7T_ALARM
#define ADT7470_OOL_ALARM
#define ADT7470_REG_ALARM2
#define ADT7470_R8T_ALARM
#define ADT7470_R9T_ALARM
#define ADT7470_R10T_ALARM
#define ADT7470_FAN1_ALARM
#define ADT7470_FAN2_ALARM
#define ADT7470_FAN3_ALARM
#define ADT7470_FAN4_ALARM
#define ADT7470_REG_TEMP_LIMITS_BASE_ADDR
#define ADT7470_REG_TEMP_LIMITS_MAX_ADDR
#define ADT7470_REG_FAN_MIN_BASE_ADDR
#define ADT7470_REG_FAN_MIN_MAX_ADDR
#define ADT7470_REG_FAN_MAX_BASE_ADDR
#define ADT7470_REG_FAN_MAX_MAX_ADDR
#define ADT7470_REG_PWM_CFG_BASE_ADDR
#define ADT7470_REG_PWM12_CFG
#define ADT7470_PWM2_AUTO_MASK
#define ADT7470_PWM1_AUTO_MASK
#define ADT7470_PWM_AUTO_MASK
#define ADT7470_REG_PWM34_CFG
#define ADT7470_PWM3_AUTO_MASK
#define ADT7470_PWM4_AUTO_MASK
#define ADT7470_REG_PWM_MIN_BASE_ADDR
#define ADT7470_REG_PWM_MIN_MAX_ADDR
#define ADT7470_REG_PWM_TEMP_MIN_BASE_ADDR
#define ADT7470_REG_PWM_TEMP_MIN_MAX_ADDR
#define ADT7470_REG_CFG_2
#define ADT7470_REG_ACOUSTICS12
#define ADT7470_REG_ACOUSTICS34
#define ADT7470_REG_DEVICE
#define ADT7470_REG_VENDOR
#define ADT7470_REG_REVISION
#define ADT7470_REG_ALARM1_MASK
#define ADT7470_REG_ALARM2_MASK
#define ADT7470_REG_PWM_AUTO_TEMP_BASE_ADDR
#define ADT7470_REG_PWM_AUTO_TEMP_MAX_ADDR
#define ADT7470_REG_MAX_ADDR

#define ADT7470_TEMP_COUNT
#define ADT7470_TEMP_REG(x)
#define ADT7470_TEMP_MIN_REG(x)
#define ADT7470_TEMP_MAX_REG(x)

#define ADT7470_FAN_COUNT
#define ADT7470_REG_FAN(x)
#define ADT7470_REG_FAN_MIN(x)
#define ADT7470_REG_FAN_MAX(x)

#define ADT7470_PWM_COUNT
#define ADT7470_REG_PWM(x)
#define ADT7470_REG_PWM_MAX(x)
#define ADT7470_REG_PWM_MIN(x)
#define ADT7470_REG_PWM_TMIN(x)
#define ADT7470_REG_PWM_CFG(x)
#define ADT7470_REG_PWM_AUTO_TEMP(x)

#define ALARM2(x)

#define ADT7470_VENDOR
#define ADT7470_DEVICE
/* datasheet only mentions a revision 2 */
#define ADT7470_REVISION

/* "all temps" according to hwmon sysfs interface spec */
#define ADT7470_PWM_ALL_TEMPS

/* How often do we reread sensors values? (In jiffies) */
#define SENSOR_REFRESH_INTERVAL

/* How often do we reread sensor limit values? (In jiffies) */
#define LIMIT_REFRESH_INTERVAL

/* Wait at least 200ms per sensor for 10 sensors */
#define TEMP_COLLECTION_TIME

/* auto update thing won't fire more than every 2s */
#define AUTO_UPDATE_INTERVAL

/* datasheet says to divide this number by the fan reading to get fan rpm */
#define FAN_PERIOD_TO_RPM(x)
#define FAN_RPM_TO_PERIOD
#define FAN_PERIOD_INVALID
#define FAN_DATA_VALID(x)

/* Config registers 1 and 2 include fields for selecting the PWM frequency */
#define ADT7470_CFG_LF
#define ADT7470_FREQ_MASK
#define ADT7470_FREQ_SHIFT

struct adt7470_data {};

/*
 * 16-bit registers on the ADT7470 are low-byte first.  The data sheet says
 * that the low byte must be read before the high byte.
 */
static inline int adt7470_read_word_data(struct adt7470_data *data, unsigned int reg,
					 unsigned int *val)
{}

static inline int adt7470_write_word_data(struct adt7470_data *data, unsigned int reg,
					  unsigned int val)
{}

/* Probe for temperature sensors.  Assumes lock is held */
static int adt7470_read_temperatures(struct adt7470_data *data)
{}

static int adt7470_update_thread(void *p)
{}

static int adt7470_update_sensors(struct adt7470_data *data)
{}

static int adt7470_update_limits(struct adt7470_data *data)
{}

static struct adt7470_data *adt7470_update_device(struct device *dev)
{}

static ssize_t auto_update_interval_show(struct device *dev,
					 struct device_attribute *devattr,
					 char *buf)
{}

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

static ssize_t num_temp_sensors_show(struct device *dev,
				     struct device_attribute *devattr,
				     char *buf)
{}

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

static int adt7470_temp_read(struct device *dev, u32 attr, int channel, long *val)
{}

static int adt7470_temp_write(struct device *dev, u32 attr, int channel, long val)
{}

static ssize_t alarm_mask_show(struct device *dev,
			       struct device_attribute *devattr, char *buf)
{}

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

static int adt7470_fan_read(struct device *dev, u32 attr, int channel, long *val)
{}

static int adt7470_fan_write(struct device *dev, u32 attr, int channel, long val)
{}

static ssize_t force_pwm_max_show(struct device *dev,
				  struct device_attribute *devattr, char *buf)
{}

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

/* These are the valid PWM frequencies to the nearest Hz */
static const int adt7470_freq_map[] =;

static int pwm1_freq_get(struct device *dev)
{}

static int adt7470_pwm_read(struct device *dev, u32 attr, int channel, long *val)
{}

static int pwm1_freq_set(struct device *dev, long freq)
{}

static int adt7470_pwm_write(struct device *dev, u32 attr, int channel, long val)
{}

static ssize_t pwm_max_show(struct device *dev,
			    struct device_attribute *devattr, char *buf)
{}

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

static ssize_t pwm_min_show(struct device *dev,
			    struct device_attribute *devattr, char *buf)
{}

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

static ssize_t pwm_tmax_show(struct device *dev,
			     struct device_attribute *devattr, char *buf)
{}

static ssize_t pwm_tmin_show(struct device *dev,
			     struct device_attribute *devattr, char *buf)
{}

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

static ssize_t pwm_auto_temp_show(struct device *dev,
				  struct device_attribute *devattr, char *buf)
{}

static int cvt_auto_temp(int input)
{}

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

static DEVICE_ATTR_RW(alarm_mask);
static DEVICE_ATTR_RW(num_temp_sensors);
static DEVICE_ATTR_RW(auto_update_interval);

static SENSOR_DEVICE_ATTR_RW(force_pwm_max, force_pwm_max, 0);

static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_pwm, pwm_min, 0);
static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_pwm, pwm_min, 1);
static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_pwm, pwm_min, 2);
static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point1_pwm, pwm_min, 3);

static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm_max, 0);
static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point2_pwm, pwm_max, 1);
static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point2_pwm, pwm_max, 2);
static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point2_pwm, pwm_max, 3);

static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_temp, pwm_tmin, 0);
static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_temp, pwm_tmin, 1);
static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_temp, pwm_tmin, 2);
static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point1_temp, pwm_tmin, 3);

static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point2_temp, pwm_tmax, 0);
static SENSOR_DEVICE_ATTR_RO(pwm2_auto_point2_temp, pwm_tmax, 1);
static SENSOR_DEVICE_ATTR_RO(pwm3_auto_point2_temp, pwm_tmax, 2);
static SENSOR_DEVICE_ATTR_RO(pwm4_auto_point2_temp, pwm_tmax, 3);

static SENSOR_DEVICE_ATTR_RW(pwm1_auto_channels_temp, pwm_auto_temp, 0);
static SENSOR_DEVICE_ATTR_RW(pwm2_auto_channels_temp, pwm_auto_temp, 1);
static SENSOR_DEVICE_ATTR_RW(pwm3_auto_channels_temp, pwm_auto_temp, 2);
static SENSOR_DEVICE_ATTR_RW(pwm4_auto_channels_temp, pwm_auto_temp, 3);

static struct attribute *adt7470_attrs[] =;

ATTRIBUTE_GROUPS();

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

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

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

static const struct hwmon_ops adt7470_hwmon_ops =;

static const struct hwmon_channel_info * const adt7470_info[] =;

static const struct hwmon_chip_info adt7470_chip_info =;

/* Return 0 if detection is successful, -ENODEV otherwise */
static int adt7470_detect(struct i2c_client *client,
			  struct i2c_board_info *info)
{}

static const struct regmap_config adt7470_regmap_config =;

static int adt7470_probe(struct i2c_client *client)
{}

static void adt7470_remove(struct i2c_client *client)
{}

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

static struct i2c_driver adt7470_driver =;

module_i2c_driver();

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