#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/jiffies.h>
#include <linux/of.h>
#include <linux/util_macros.h>
enum adt_sysfs_id { … };
#define REG_DEVREV2 …
#define REG_IMON …
#define REG_VTT …
#define REG_EXTEND3 …
#define REG_VOLTAGE_BASE …
#define REG_TEMP_BASE …
#define REG_TACH_BASE …
#define REG_PWM_BASE …
#define REG_PWM_MAX_BASE …
#define REG_DEVID …
#define REG_VENDID …
#define REG_DEVID2 …
#define REG_CONFIG1 …
#define REG_STATUS1 …
#define REG_STATUS2 …
#define REG_VID …
#define REG_VOLTAGE_MIN_BASE …
#define REG_VOLTAGE_MAX_BASE …
#define REG_TEMP_MIN_BASE …
#define REG_TEMP_MAX_BASE …
#define REG_TACH_MIN_BASE …
#define REG_PWM_CONFIG_BASE …
#define REG_TEMP_TRANGE_BASE …
#define REG_ENHANCE_ACOUSTICS1 …
#define REG_ENHANCE_ACOUSTICS2 …
#define REG_PWM_MIN_BASE …
#define REG_TEMP_TMIN_BASE …
#define REG_TEMP_THERM_BASE …
#define REG_REMOTE1_HYSTERSIS …
#define REG_REMOTE2_HYSTERSIS …
#define REG_TEMP_OFFSET_BASE …
#define REG_CONFIG2 …
#define REG_EXTEND1 …
#define REG_EXTEND2 …
#define REG_CONFIG3 …
#define REG_CONFIG5 …
#define REG_CONFIG4 …
#define REG_STATUS4 …
#define REG_VTT_MIN …
#define REG_VTT_MAX …
#define REG_IMON_MIN …
#define REG_IMON_MAX …
#define VID_VIDSEL …
#define CONFIG2_ATTN …
#define CONFIG3_SMBALERT …
#define CONFIG3_THERM …
#define CONFIG4_PINFUNC …
#define CONFIG4_THERM …
#define CONFIG4_SMBALERT …
#define CONFIG4_MAXDUTY …
#define CONFIG4_ATTN_IN10 …
#define CONFIG4_ATTN_IN43 …
#define CONFIG5_TWOSCOMP …
#define CONFIG5_TEMPOFFSET …
#define CONFIG5_VIDGPIO …
#define ADT7475_VOLTAGE_COUNT …
#define ADT7475_TEMP_COUNT …
#define ADT7475_TACH_COUNT …
#define ADT7475_PWM_COUNT …
#define adt7475_read(reg) …
#define TACH_REG(idx) …
#define TACH_MIN_REG(idx) …
#define PWM_REG(idx) …
#define PWM_MAX_REG(idx) …
#define PWM_MIN_REG(idx) …
#define PWM_CONFIG_REG(idx) …
#define VOLTAGE_REG(idx) …
#define VOLTAGE_MIN_REG(idx) …
#define VOLTAGE_MAX_REG(idx) …
#define TEMP_REG(idx) …
#define TEMP_MIN_REG(idx) …
#define TEMP_MAX_REG(idx) …
#define TEMP_TMIN_REG(idx) …
#define TEMP_THERM_REG(idx) …
#define TEMP_OFFSET_REG(idx) …
#define TEMP_TRANGE_REG(idx) …
static const unsigned short normal_i2c[] = …;
enum chips { … };
static const struct i2c_device_id adt7475_id[] = …;
MODULE_DEVICE_TABLE(i2c, adt7475_id);
static const struct of_device_id __maybe_unused adt7475_of_match[] = …;
MODULE_DEVICE_TABLE(of, adt7475_of_match);
struct adt7475_data { … };
static struct i2c_driver adt7475_driver;
static struct adt7475_data *adt7475_update_device(struct device *dev);
static void adt7475_read_hystersis(struct i2c_client *client);
static void adt7475_read_pwm(struct i2c_client *client, int index);
static inline u16 temp2reg(struct adt7475_data *data, long val)
{ … }
static inline int reg2temp(struct adt7475_data *data, u16 reg)
{ … }
static inline int tach2rpm(u16 tach)
{ … }
static inline u16 rpm2tach(unsigned long rpm)
{ … }
static const int adt7473_in_scaling[ADT7475_VOLTAGE_COUNT + 2][2] = …;
static inline int reg2volt(int channel, u16 reg, u8 bypass_attn)
{ … }
static inline u16 volt2reg(int channel, long volt, u8 bypass_attn)
{ … }
static int adt7475_read_word(struct i2c_client *client, int reg)
{ … }
static void adt7475_write_word(struct i2c_client *client, int reg, u16 val)
{ … }
static ssize_t voltage_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t voltage_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static ssize_t temp_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t temp_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static const int ad7475_st_map[] = …;
static ssize_t temp_st_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t temp_st_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static const int autorange_table[] = …;
static ssize_t point2_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t point2_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t tach_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t tach_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t pwm_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t pwmchan_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t pwmctrl_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t pwm_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t stall_disable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t stall_disable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static int hw_set_pwm(struct i2c_client *client, int index,
unsigned int pwmctl, unsigned int pwmchan)
{ … }
static ssize_t pwmchan_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static ssize_t pwmctrl_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static const int pwmfreq_table[] = …;
static ssize_t pwmfreq_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t pwmfreq_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static ssize_t pwm_use_point2_pwm_at_crit_show(struct device *dev,
struct device_attribute *devattr,
char *buf)
{ … }
static ssize_t pwm_use_point2_pwm_at_crit_store(struct device *dev,
struct device_attribute *devattr,
const char *buf, size_t count)
{ … }
static ssize_t vrm_show(struct device *dev, struct device_attribute *devattr,
char *buf)
{ … }
static ssize_t vrm_store(struct device *dev, struct device_attribute *devattr,
const char *buf, size_t count)
{ … }
static ssize_t cpu0_vid_show(struct device *dev,
struct device_attribute *devattr, char *buf)
{ … }
static SENSOR_DEVICE_ATTR_2_RO(in0_input, voltage, INPUT, 0);
static SENSOR_DEVICE_ATTR_2_RW(in0_max, voltage, MAX, 0);
static SENSOR_DEVICE_ATTR_2_RW(in0_min, voltage, MIN, 0);
static SENSOR_DEVICE_ATTR_2_RO(in0_alarm, voltage, ALARM, 0);
static SENSOR_DEVICE_ATTR_2_RO(in1_input, voltage, INPUT, 1);
static SENSOR_DEVICE_ATTR_2_RW(in1_max, voltage, MAX, 1);
static SENSOR_DEVICE_ATTR_2_RW(in1_min, voltage, MIN, 1);
static SENSOR_DEVICE_ATTR_2_RO(in1_alarm, voltage, ALARM, 1);
static SENSOR_DEVICE_ATTR_2_RO(in2_input, voltage, INPUT, 2);
static SENSOR_DEVICE_ATTR_2_RW(in2_max, voltage, MAX, 2);
static SENSOR_DEVICE_ATTR_2_RW(in2_min, voltage, MIN, 2);
static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, voltage, ALARM, 2);
static SENSOR_DEVICE_ATTR_2_RO(in3_input, voltage, INPUT, 3);
static SENSOR_DEVICE_ATTR_2_RW(in3_max, voltage, MAX, 3);
static SENSOR_DEVICE_ATTR_2_RW(in3_min, voltage, MIN, 3);
static SENSOR_DEVICE_ATTR_2_RO(in3_alarm, voltage, ALARM, 3);
static SENSOR_DEVICE_ATTR_2_RO(in4_input, voltage, INPUT, 4);
static SENSOR_DEVICE_ATTR_2_RW(in4_max, voltage, MAX, 4);
static SENSOR_DEVICE_ATTR_2_RW(in4_min, voltage, MIN, 4);
static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, voltage, ALARM, 8);
static SENSOR_DEVICE_ATTR_2_RO(in5_input, voltage, INPUT, 5);
static SENSOR_DEVICE_ATTR_2_RW(in5_max, voltage, MAX, 5);
static SENSOR_DEVICE_ATTR_2_RW(in5_min, voltage, MIN, 5);
static SENSOR_DEVICE_ATTR_2_RO(in5_alarm, voltage, ALARM, 31);
static SENSOR_DEVICE_ATTR_2_RO(in6_input, voltage, INPUT, 6);
static SENSOR_DEVICE_ATTR_2_RW(in6_max, voltage, MAX, 6);
static SENSOR_DEVICE_ATTR_2_RW(in6_min, voltage, MIN, 6);
static SENSOR_DEVICE_ATTR_2_RO(in6_alarm, voltage, ALARM, 30);
static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, INPUT, 0);
static SENSOR_DEVICE_ATTR_2_RO(temp1_alarm, temp, ALARM, 0);
static SENSOR_DEVICE_ATTR_2_RO(temp1_fault, temp, FAULT, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, MAX, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_min, temp, MIN, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_offset, temp, OFFSET, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_auto_point1_temp, temp, AUTOMIN, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_auto_point2_temp, point2, 0, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_crit, temp, THERM, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_crit_hyst, temp, HYSTERSIS, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_smoothing, temp_st, 0, 0);
static SENSOR_DEVICE_ATTR_2_RO(temp2_input, temp, INPUT, 1);
static SENSOR_DEVICE_ATTR_2_RO(temp2_alarm, temp, ALARM, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, MAX, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_min, temp, MIN, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_offset, temp, OFFSET, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point1_temp, temp, AUTOMIN, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point2_temp, point2, 0, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_crit, temp, THERM, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_crit_hyst, temp, HYSTERSIS, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_smoothing, temp_st, 0, 1);
static SENSOR_DEVICE_ATTR_2_RO(temp3_input, temp, INPUT, 2);
static SENSOR_DEVICE_ATTR_2_RO(temp3_alarm, temp, ALARM, 2);
static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, temp, FAULT, 2);
static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, MAX, 2);
static SENSOR_DEVICE_ATTR_2_RW(temp3_min, temp, MIN, 2);
static SENSOR_DEVICE_ATTR_2_RW(temp3_offset, temp, OFFSET, 2);
static SENSOR_DEVICE_ATTR_2_RW(temp3_auto_point1_temp, temp, AUTOMIN, 2);
static SENSOR_DEVICE_ATTR_2_RW(temp3_auto_point2_temp, point2, 0, 2);
static SENSOR_DEVICE_ATTR_2_RW(temp3_crit, temp, THERM, 2);
static SENSOR_DEVICE_ATTR_2_RW(temp3_crit_hyst, temp, HYSTERSIS, 2);
static SENSOR_DEVICE_ATTR_2_RW(temp3_smoothing, temp_st, 0, 2);
static SENSOR_DEVICE_ATTR_2_RO(fan1_input, tach, INPUT, 0);
static SENSOR_DEVICE_ATTR_2_RW(fan1_min, tach, MIN, 0);
static SENSOR_DEVICE_ATTR_2_RO(fan1_alarm, tach, ALARM, 0);
static SENSOR_DEVICE_ATTR_2_RO(fan2_input, tach, INPUT, 1);
static SENSOR_DEVICE_ATTR_2_RW(fan2_min, tach, MIN, 1);
static SENSOR_DEVICE_ATTR_2_RO(fan2_alarm, tach, ALARM, 1);
static SENSOR_DEVICE_ATTR_2_RO(fan3_input, tach, INPUT, 2);
static SENSOR_DEVICE_ATTR_2_RW(fan3_min, tach, MIN, 2);
static SENSOR_DEVICE_ATTR_2_RO(fan3_alarm, tach, ALARM, 2);
static SENSOR_DEVICE_ATTR_2_RO(fan4_input, tach, INPUT, 3);
static SENSOR_DEVICE_ATTR_2_RW(fan4_min, tach, MIN, 3);
static SENSOR_DEVICE_ATTR_2_RO(fan4_alarm, tach, ALARM, 3);
static SENSOR_DEVICE_ATTR_2_RW(pwm1, pwm, INPUT, 0);
static SENSOR_DEVICE_ATTR_2_RW(pwm1_freq, pwmfreq, INPUT, 0);
static SENSOR_DEVICE_ATTR_2_RW(pwm1_enable, pwmctrl, INPUT, 0);
static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_channels_temp, pwmchan, INPUT, 0);
static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point1_pwm, pwm, MIN, 0);
static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point2_pwm, pwm, MAX, 0);
static SENSOR_DEVICE_ATTR_2_RW(pwm1_stall_disable, stall_disable, 0, 0);
static SENSOR_DEVICE_ATTR_2_RW(pwm2, pwm, INPUT, 1);
static SENSOR_DEVICE_ATTR_2_RW(pwm2_freq, pwmfreq, INPUT, 1);
static SENSOR_DEVICE_ATTR_2_RW(pwm2_enable, pwmctrl, INPUT, 1);
static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_channels_temp, pwmchan, INPUT, 1);
static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point1_pwm, pwm, MIN, 1);
static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point2_pwm, pwm, MAX, 1);
static SENSOR_DEVICE_ATTR_2_RW(pwm2_stall_disable, stall_disable, 0, 1);
static SENSOR_DEVICE_ATTR_2_RW(pwm3, pwm, INPUT, 2);
static SENSOR_DEVICE_ATTR_2_RW(pwm3_freq, pwmfreq, INPUT, 2);
static SENSOR_DEVICE_ATTR_2_RW(pwm3_enable, pwmctrl, INPUT, 2);
static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_channels_temp, pwmchan, INPUT, 2);
static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point1_pwm, pwm, MIN, 2);
static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point2_pwm, pwm, MAX, 2);
static SENSOR_DEVICE_ATTR_2_RW(pwm3_stall_disable, stall_disable, 0, 2);
static DEVICE_ATTR_RW(pwm_use_point2_pwm_at_crit);
static DEVICE_ATTR_RW(vrm);
static DEVICE_ATTR_RO(cpu0_vid);
static struct attribute *adt7475_attrs[] = …;
static struct attribute *fan4_attrs[] = …;
static struct attribute *pwm2_attrs[] = …;
static struct attribute *in0_attrs[] = …;
static struct attribute *in3_attrs[] = …;
static struct attribute *in4_attrs[] = …;
static struct attribute *in5_attrs[] = …;
static struct attribute *in6_attrs[] = …;
static struct attribute *vid_attrs[] = …;
static const struct attribute_group adt7475_attr_group = …;
static const struct attribute_group fan4_attr_group = …;
static const struct attribute_group pwm2_attr_group = …;
static const struct attribute_group in0_attr_group = …;
static const struct attribute_group in3_attr_group = …;
static const struct attribute_group in4_attr_group = …;
static const struct attribute_group in5_attr_group = …;
static const struct attribute_group in6_attr_group = …;
static const struct attribute_group vid_attr_group = …;
static int adt7475_detect(struct i2c_client *client,
struct i2c_board_info *info)
{ … }
static int adt7475_update_limits(struct i2c_client *client)
{ … }
static int load_config3(const struct i2c_client *client, const char *propname)
{ … }
static int load_config4(const struct i2c_client *client, const char *propname)
{ … }
static int load_config(const struct i2c_client *client, enum chips chip)
{ … }
static int set_property_bit(const struct i2c_client *client, char *property,
u8 *config, u8 bit_index)
{ … }
static int load_attenuators(const struct i2c_client *client, enum chips chip,
struct adt7475_data *data)
{ … }
static int adt7475_set_pwm_polarity(struct i2c_client *client)
{ … }
static int adt7475_probe(struct i2c_client *client)
{ … }
static struct i2c_driver adt7475_driver = …;
static void adt7475_read_hystersis(struct i2c_client *client)
{ … }
static void adt7475_read_pwm(struct i2c_client *client, int index)
{ … }
static int adt7475_update_measure(struct device *dev)
{ … }
static struct adt7475_data *adt7475_update_device(struct device *dev)
{ … }
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;