static void max1619_remote_crit(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { struct max1619_data *data = client->data; if (operation == SENSORS_PROC_REAL_INFO) *nrels_mag = 0; /* magnitude */ else if (operation == SENSORS_PROC_REAL_READ) { max1619_update_client(client); results[0] = TEMP_FROM_REG(data->remote_max); results[1] = TEMP_FROM_REG(data->remote_hyst); *nrels_mag = 2; } else if (operation == SENSORS_PROC_REAL_WRITE) { if (*nrels_mag >= 1) { data->remote_max = TEMP_TO_REG(results[0]); i2c_smbus_write_byte_data(client, MAX1619_REG_W_REMOTE_TMAX, data->remote_max); } if (*nrels_mag >= 2) { data->remote_hyst = TEMP_TO_REG(results[1]); i2c_smbus_write_byte_data(client, MAX1619_REG_W_REMOTE_THYST, data->remote_hyst); } } }
/* Return 0 for temp and disallow writes if pin used for in4 */ void sis5595_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { struct sis5595_data *data = client->data; if (operation == SENSORS_PROC_REAL_INFO) *nrels_mag = 1; else if (operation == SENSORS_PROC_REAL_READ) { if(data->maxins == 3) { sis5595_update_client(client); results[0] = TEMP_FROM_REG(data->temp_over); results[1] = TEMP_FROM_REG(data->temp_hyst); results[2] = TEMP_FROM_REG(data->temp); } else { results[0] = 0; results[1] = 0; results[2] = 0; } *nrels_mag = 3; } else if (operation == SENSORS_PROC_REAL_WRITE) { if(data->maxins == 3) { if (*nrels_mag >= 1) { data->temp_over = TEMP_TO_REG(results[0]); sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over); } if (*nrels_mag >= 2) { data->temp_hyst = TEMP_TO_REG(results[1]); sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst); } } } }
/* Called when we have found a new GL520SM. It should set limits, etc. */ void gl520_init_client(struct i2c_client *client) { /* Power-on defaults (bit 7=1) */ gl520_write_value(client, GL520_REG_CONF, 0x80); /* No noisy output (bit 2=1), Comparator mode (bit 3=0), two fans (bit4=0), standby mode (bit6=0) */ gl520_write_value(client, GL520_REG_CONF, 0x04); /* Never interrupts */ gl520_write_value(client, GL520_REG_MASK, 0x00); gl520_write_value(client, GL520_REG_TEMP1_HYST, TEMP_TO_REG(GL520_INIT_TEMP_HYST)); gl520_write_value(client, GL520_REG_TEMP1_OVER, TEMP_TO_REG(GL520_INIT_TEMP_OVER)); /* We set Temp2, but not Vin4. */ gl520_write_value(client, GL520_REG_TEMP2_HYST, TEMP_TO_REG(GL520_INIT_TEMP_HYST)); gl520_write_value(client, GL520_REG_TEMP2_OVER, TEMP_TO_REG(GL520_INIT_TEMP_OVER)); gl520_write_value(client, GL520_REG_MISC, (DIV_TO_REG(2) << 6) | (DIV_TO_REG(2) << 4)); gl520_write_value(client, GL520_REG_FAN_LIMIT, (FAN_TO_REG(GL520_INIT_FAN_MIN_1, 2) << 8) | FAN_TO_REG(GL520_INIT_FAN_MIN_2, 2)); gl520_write_value(client, GL520_REG_VIN1_LIMIT, (IN_TO_REG(GL520_INIT_VIN_MAX_1) << 8) | IN_TO_REG(GL520_INIT_VIN_MIN_1)); gl520_write_value(client, GL520_REG_VIN2_LIMIT, (IN_TO_REG(GL520_INIT_VIN_MAX_2) << 8) | IN_TO_REG(GL520_INIT_VIN_MIN_2)); gl520_write_value(client, GL520_REG_VIN3_LIMIT, (IN_TO_REG(GL520_INIT_VIN_MAX_3) << 8) | IN_TO_REG(GL520_INIT_VIN_MIN_3)); gl520_write_value(client, GL520_REG_VDD_LIMIT, (VDD_TO_REG(GL520_INIT_VDD_MAX) << 8) | VDD_TO_REG(GL520_INIT_VDD_MIN)); /* Clear status register (bit 5=1), start (bit6=1) */ gl520_write_value(client, GL520_REG_CONF, 0x24); gl520_write_value(client, GL520_REG_CONF, 0x44); }
/* Called when we have found a new SIS5595. It should set limits, etc. */ void sis5595_init_client(struct i2c_client *client) { struct sis5595_data *data = client->data; /* Reset all except Watchdog values and last conversion values This sets fan-divs to 2, among others */ sis5595_write_value(client, SIS5595_REG_CONFIG, 0x80); sis5595_write_value(client, SIS5595_REG_IN_MIN(0), IN_TO_REG(SIS5595_INIT_IN_MIN_0)); sis5595_write_value(client, SIS5595_REG_IN_MAX(0), IN_TO_REG(SIS5595_INIT_IN_MAX_0)); sis5595_write_value(client, SIS5595_REG_IN_MIN(1), IN_TO_REG(SIS5595_INIT_IN_MIN_1)); sis5595_write_value(client, SIS5595_REG_IN_MAX(1), IN_TO_REG(SIS5595_INIT_IN_MAX_1)); sis5595_write_value(client, SIS5595_REG_IN_MIN(2), IN_TO_REG(SIS5595_INIT_IN_MIN_2)); sis5595_write_value(client, SIS5595_REG_IN_MAX(2), IN_TO_REG(SIS5595_INIT_IN_MAX_2)); sis5595_write_value(client, SIS5595_REG_IN_MIN(3), IN_TO_REG(SIS5595_INIT_IN_MIN_3)); sis5595_write_value(client, SIS5595_REG_IN_MAX(3), IN_TO_REG(SIS5595_INIT_IN_MAX_3)); sis5595_write_value(client, SIS5595_REG_FAN_MIN(1), FAN_TO_REG(SIS5595_INIT_FAN_MIN_1, 2)); sis5595_write_value(client, SIS5595_REG_FAN_MIN(2), FAN_TO_REG(SIS5595_INIT_FAN_MIN_2, 2)); if(data->maxins == 4) { sis5595_write_value(client, SIS5595_REG_IN_MIN(4), IN_TO_REG(SIS5595_INIT_IN_MIN_4)); sis5595_write_value(client, SIS5595_REG_IN_MAX(4), IN_TO_REG(SIS5595_INIT_IN_MAX_4)); } else { sis5595_write_value(client, SIS5595_REG_TEMP_OVER, TEMP_TO_REG(SIS5595_INIT_TEMP_OVER)); sis5595_write_value(client, SIS5595_REG_TEMP_HYST, TEMP_TO_REG(SIS5595_INIT_TEMP_HYST)); } /* Start monitoring */ sis5595_write_value(client, SIS5595_REG_CONFIG, (sis5595_read_value(client, SIS5595_REG_CONFIG) & 0xf7) | 0x01); }
static void set_temp_high(struct device *dev, const char *buf, int nr) { struct i2c_client *client = to_i2c_client(dev); struct lm87_data *data = i2c_get_clientdata(client); long val = simple_strtol(buf, NULL, 10); mutex_lock(&data->update_lock); data->temp_high[nr] = TEMP_TO_REG(val); lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]); mutex_unlock(&data->update_lock); }
static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { struct lm78_data *data = dev_get_drvdata(dev); long val = simple_strtol(buf, NULL, 10); mutex_lock(&data->update_lock); data->temp_hyst = TEMP_TO_REG(val); lm78_write_value(data, LM78_REG_TEMP_HYST, data->temp_hyst); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); struct lm92_data *data = i2c_get_clientdata(client); long val = simple_strtol(buf, NULL, 10); mutex_lock(&data->update_lock); data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, swab16(TEMP_TO_REG(data->temp1_hyst))); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); struct gl520_data *data = i2c_get_clientdata(client); int n = to_sensor_dev_attr(attr)->index; long v = simple_strtol(buf, NULL, 10); mutex_lock(&data->update_lock); data->temp_max[n] = TEMP_TO_REG(v); gl520_write_value(client, GL520_REG_TEMP_MAX[n], data->temp_max[n]); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int index = to_sensor_dev_attr(attr)->index; struct i2c_client *client = to_i2c_client(dev); struct adm1025_data *data = i2c_get_clientdata(client); long val = simple_strtol(buf, NULL, 10); mutex_lock(&data->update_lock); data->temp_max[index] = TEMP_TO_REG(val); i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(index), data->temp_max[index]); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct i2c_client *client = to_i2c_client(dev); struct lm83_data *data = i2c_get_clientdata(client); long val = simple_strtol(buf, NULL, 10); int nr = attr->index; mutex_lock(&data->update_lock); data->temp[nr] = TEMP_TO_REG(val); i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], data->temp[nr]); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp_over(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { struct lm78_data *data = dev_get_drvdata(dev); long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; mutex_lock(&data->update_lock); data->temp_over = TEMP_TO_REG(val); lm78_write_value(data, LM78_REG_TEMP_OVER, data->temp_over); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct lm92_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; int nr = attr->index; long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; mutex_lock(&data->update_lock); data->temp[nr] = TEMP_TO_REG(val); i2c_smbus_write_word_swapped(client, regs[nr], data->temp[nr]); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int index = to_sensor_dev_attr(attr)->index; struct adm1025_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; mutex_lock(&data->update_lock); data->temp_max[index] = TEMP_TO_REG(val); i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(index), data->temp_max[index]); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); struct lm92_data *data = i2c_get_clientdata(client); long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; mutex_lock(&data->update_lock); data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; i2c_smbus_write_word_swapped(client, LM92_REG_TEMP_HYST, TEMP_TO_REG(data->temp1_hyst)); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp_max_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); struct gl520_data *data = i2c_get_clientdata(client); int n = to_sensor_dev_attr(attr)->index; long v; int err; err = kstrtol(buf, 10, &v); if (err) return err; mutex_lock(&data->update_lock); data->temp_max_hyst[n] = TEMP_TO_REG(v); gl520_write_value(client, GL520_REG_TEMP_MAX_HYST[n], data->temp_max_hyst[n]); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int nr = sensor_attr->index; struct smsc47m192_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; mutex_lock(&data->update_lock); data->temp_max[nr] = TEMP_TO_REG(val); i2c_smbus_write_byte_data(client, SMSC47M192_REG_TEMP_MAX[nr], data->temp_max[nr]); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct lm92_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; mutex_lock(&data->update_lock); data->temp[t_hyst] = TEMP_FROM_REG(data->temp[attr->index]) - val; i2c_smbus_write_word_swapped(client, LM92_REG_TEMP_HYST, TEMP_TO_REG(data->temp[t_hyst])); mutex_unlock(&data->update_lock); return count; }
static ssize_t set_temp_offset(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int nr = sensor_attr->index; struct smsc47m192_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; u8 sfr = i2c_smbus_read_byte_data(client, SMSC47M192_REG_SFR); long val; int err; err = kstrtol(buf, 10, &val); if (err) return err; mutex_lock(&data->update_lock); data->temp_offset[nr] = TEMP_TO_REG(val); if (nr > 1) i2c_smbus_write_byte_data(client, SMSC47M192_REG_TEMP_OFFSET(nr), data->temp_offset[nr]); else if (data->temp_offset[nr] != 0) { /* * offset[0] and offset[1] share the same register, * SFR bit 4 activates offset[0] */ i2c_smbus_write_byte_data(client, SMSC47M192_REG_SFR, (sfr & 0xef) | (nr == 0 ? 0x10 : 0)); data->temp_offset[1-nr] = 0; i2c_smbus_write_byte_data(client, SMSC47M192_REG_TEMP_OFFSET(nr), data->temp_offset[nr]); } else if ((sfr & 0x10) == (nr == 0 ? 0x10 : 0)) i2c_smbus_write_byte_data(client, SMSC47M192_REG_TEMP_OFFSET(nr), 0); mutex_unlock(&data->update_lock); return count; }
/* Called when we have found a new MTP008. It should set limits, etc. */ void mtp008_init_client(struct i2c_client *client) { int vid; u8 save1, save2; struct mtp008_data *data; data = client->data; /* * Initialize the Myson MTP008 hardware monitoring chip. * Save the pin settings that the BIOS hopefully set. */ save1 = mtp008_read_value(client, MTP008_REG_PIN_CTRL1); save2 = mtp008_read_value(client, MTP008_REG_PIN_CTRL2); mtp008_write_value(client, MTP008_REG_CONFIG, (mtp008_read_value(client, MTP008_REG_CONFIG) & 0x7f) | 0x80); mtp008_write_value(client, MTP008_REG_PIN_CTRL1, save1); mtp008_write_value(client, MTP008_REG_PIN_CTRL2, save2); mtp008_getsensortype(data, save2); /* * Retrieve the VID setting (needed for the default limits). */ vid = mtp008_read_value(client, MTP008_REG_VID_FANDIV) & 0x0f; vid |= (mtp008_read_value(client, MTP008_REG_RESET_VID4) & 0x01) << 4; vid = VID_FROM_REG(vid); /* * Set the default limits. * * Setting temp sensors is done as follows: * * Register 0x57: 0 0 0 0 x x x x * | \ / +-- AIN5/VT3 * | +----- AIN4/VT2/PII * +-------- VT1/PII */ mtp008_write_value(client, MTP008_REG_IN_MAX(0), IN_TO_REG(MTP008_INIT_IN_MAX_0)); mtp008_write_value(client, MTP008_REG_IN_MIN(0), IN_TO_REG(MTP008_INIT_IN_MIN_0)); mtp008_write_value(client, MTP008_REG_IN_MAX(1), IN_TO_REG(MTP008_INIT_IN_MAX_1)); mtp008_write_value(client, MTP008_REG_IN_MIN(1), IN_TO_REG(MTP008_INIT_IN_MIN_1)); mtp008_write_value(client, MTP008_REG_IN_MAX(2), IN_TO_REG(MTP008_INIT_IN_MAX_2)); mtp008_write_value(client, MTP008_REG_IN_MIN(2), IN_TO_REG(MTP008_INIT_IN_MIN_2)); mtp008_write_value(client, MTP008_REG_IN_MAX(3), IN_TO_REG(MTP008_INIT_IN_MAX_3)); mtp008_write_value(client, MTP008_REG_IN_MIN(3), IN_TO_REG(MTP008_INIT_IN_MIN_3)); mtp008_write_value(client, MTP008_REG_IN_MAX(5), IN_TO_REG(MTP008_INIT_IN_MAX_5)); mtp008_write_value(client, MTP008_REG_IN_MIN(5), IN_TO_REG(MTP008_INIT_IN_MIN_5)); mtp008_write_value(client, MTP008_REG_IN_MAX(6), IN_TO_REG(MTP008_INIT_IN_MAX_6)); mtp008_write_value(client, MTP008_REG_IN_MIN(6), IN_TO_REG(MTP008_INIT_IN_MIN_6)); mtp008_write_value(client, MTP008_REG_TEMP_MAX, TEMP_TO_REG(MTP008_INIT_TEMP_OVER)); mtp008_write_value(client, MTP008_REG_TEMP_MIN, TEMP_TO_REG(MTP008_INIT_TEMP_HYST)); mtp008_write_value(client, MTP008_REG_IN_MAX(4), TEMP_TO_REG(MTP008_INIT_TEMP2_OVER)); mtp008_write_value(client, MTP008_REG_IN_MIN(4), TEMP_TO_REG(MTP008_INIT_TEMP2_HYST)); mtp008_write_value(client, MTP008_REG_FAN_MIN(1), FAN_TO_REG(MTP008_INIT_FAN_MIN_1, 2)); mtp008_write_value(client, MTP008_REG_FAN_MIN(2), FAN_TO_REG(MTP008_INIT_FAN_MIN_2, 2)); mtp008_write_value(client, MTP008_REG_FAN_MIN(3), FAN_TO_REG(MTP008_INIT_FAN_MIN_3, 2)); /* * Start monitoring. */ mtp008_write_value( client, MTP008_REG_CONFIG, (mtp008_read_value(client, MTP008_REG_CONFIG) & 0xf7) | 0x01 ); }