#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.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>
#define ADM1031_REG_FAN_SPEED(nr) …
#define ADM1031_REG_FAN_DIV(nr) …
#define ADM1031_REG_PWM …
#define ADM1031_REG_FAN_MIN(nr) …
#define ADM1031_REG_FAN_FILTER …
#define ADM1031_REG_TEMP_OFFSET(nr) …
#define ADM1031_REG_TEMP_MAX(nr) …
#define ADM1031_REG_TEMP_MIN(nr) …
#define ADM1031_REG_TEMP_CRIT(nr) …
#define ADM1031_REG_TEMP(nr) …
#define ADM1031_REG_AUTO_TEMP(nr) …
#define ADM1031_REG_STATUS(nr) …
#define ADM1031_REG_CONF1 …
#define ADM1031_REG_CONF2 …
#define ADM1031_REG_EXT_TEMP …
#define ADM1031_CONF1_MONITOR_ENABLE …
#define ADM1031_CONF1_PWM_INVERT …
#define ADM1031_CONF1_AUTO_MODE …
#define ADM1031_CONF2_PWM1_ENABLE …
#define ADM1031_CONF2_PWM2_ENABLE …
#define ADM1031_CONF2_TACH1_ENABLE …
#define ADM1031_CONF2_TACH2_ENABLE …
#define ADM1031_CONF2_TEMP_ENABLE(chan) …
#define ADM1031_UPDATE_RATE_MASK …
#define ADM1031_UPDATE_RATE_SHIFT …
static const unsigned short normal_i2c[] = …;
enum chips { … };
auto_chan_table_t;
struct adm1031_data { … };
static inline u8 adm1031_read_value(struct i2c_client *client, u8 reg)
{ … }
static inline int
adm1031_write_value(struct i2c_client *client, u8 reg, unsigned int value)
{ … }
static struct adm1031_data *adm1031_update_device(struct device *dev)
{ … }
#define TEMP_TO_REG(val) …
#define TEMP_FROM_REG(val) …
#define TEMP_FROM_REG_EXT(val, ext) …
#define TEMP_OFFSET_TO_REG(val) …
#define TEMP_OFFSET_FROM_REG(val) …
#define FAN_FROM_REG(reg, div) …
static int FAN_TO_REG(int reg, int div)
{ … }
#define FAN_DIV_FROM_REG(reg) …
#define PWM_TO_REG(val) …
#define PWM_FROM_REG(val) …
#define FAN_CHAN_FROM_REG(reg) …
#define FAN_CHAN_TO_REG(val, reg) …
#define AUTO_TEMP_MIN_TO_REG(val, reg) …
#define AUTO_TEMP_RANGE_FROM_REG(reg) …
#define AUTO_TEMP_MIN_FROM_REG(reg) …
#define AUTO_TEMP_MIN_FROM_REG_DEG(reg) …
#define AUTO_TEMP_OFF_FROM_REG(reg) …
#define AUTO_TEMP_MAX_FROM_REG(reg) …
static int AUTO_TEMP_MAX_TO_REG(int val, int reg, int pwm)
{ … }
#define GET_FAN_AUTO_BITFIELD(data, idx) …
static const auto_chan_table_t auto_channel_select_table_adm1031 = …;
static const auto_chan_table_t auto_channel_select_table_adm1030 = …;
static int
get_fan_auto_nearest(struct adm1031_data *data, int chan, u8 val, u8 reg)
{ … }
static ssize_t fan_auto_channel_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t
fan_auto_channel_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static SENSOR_DEVICE_ATTR_RW(auto_fan1_channel, fan_auto_channel, 0);
static SENSOR_DEVICE_ATTR_RW(auto_fan2_channel, fan_auto_channel, 1);
static ssize_t auto_temp_off_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t auto_temp_min_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t
auto_temp_min_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t auto_temp_max_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t
auto_temp_max_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static SENSOR_DEVICE_ATTR_RO(auto_temp1_off, auto_temp_off, 0);
static SENSOR_DEVICE_ATTR_RW(auto_temp1_min, auto_temp_min, 0);
static SENSOR_DEVICE_ATTR_RW(auto_temp1_max, auto_temp_max, 0);
static SENSOR_DEVICE_ATTR_RO(auto_temp2_off, auto_temp_off, 1);
static SENSOR_DEVICE_ATTR_RW(auto_temp2_min, auto_temp_min, 1);
static SENSOR_DEVICE_ATTR_RW(auto_temp2_max, auto_temp_max, 1);
static SENSOR_DEVICE_ATTR_RO(auto_temp3_off, auto_temp_off, 2);
static SENSOR_DEVICE_ATTR_RW(auto_temp3_min, auto_temp_min, 2);
static SENSOR_DEVICE_ATTR_RW(auto_temp3_max, auto_temp_max, 2);
static ssize_t pwm_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 SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0);
static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1);
static SENSOR_DEVICE_ATTR_RW(auto_fan1_min_pwm, pwm, 0);
static SENSOR_DEVICE_ATTR_RW(auto_fan2_min_pwm, pwm, 1);
static int trust_fan_readings(struct adm1031_data *data, int chan)
{ … }
static ssize_t fan_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t fan_div_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t fan_min_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static ssize_t fan_div_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0);
static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0);
static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1);
static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);
static ssize_t temp_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t temp_offset_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t temp_min_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t temp_max_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t temp_crit_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t temp_offset_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t temp_min_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static ssize_t temp_max_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static ssize_t temp_crit_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ … }
static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_offset, temp_offset, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0);
static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp_crit, 0);
static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
static SENSOR_DEVICE_ATTR_RW(temp2_offset, temp_offset, 1);
static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1);
static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1);
static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp_crit, 1);
static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
static SENSOR_DEVICE_ATTR_RW(temp3_offset, temp_offset, 2);
static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2);
static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2);
static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp_crit, 2);
static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(alarms);
static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 0);
static SENSOR_DEVICE_ATTR_RO(fan1_fault, alarm, 1);
static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 2);
static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, alarm, 3);
static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 4);
static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 5);
static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6);
static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 7);
static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 8);
static SENSOR_DEVICE_ATTR_RO(fan2_fault, alarm, 9);
static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, alarm, 10);
static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, alarm, 11);
static SENSOR_DEVICE_ATTR_RO(temp3_crit_alarm, alarm, 12);
static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 13);
static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 14);
static const unsigned int update_intervals[] = …;
static ssize_t update_interval_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t update_interval_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(update_interval);
static struct attribute *adm1031_attributes[] = …;
static const struct attribute_group adm1031_group = …;
static struct attribute *adm1031_attributes_opt[] = …;
static const struct attribute_group adm1031_group_opt = …;
static int adm1031_detect(struct i2c_client *client,
struct i2c_board_info *info)
{ … }
static void adm1031_init_client(struct i2c_client *client)
{ … }
static int adm1031_probe(struct i2c_client *client)
{ … }
static const struct i2c_device_id adm1031_id[] = …;
MODULE_DEVICE_TABLE(i2c, adm1031_id);
static struct i2c_driver adm1031_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;