Loading Documentation/hwmon/lm90 +17 −0 Original line number Original line Diff line number Diff line Loading @@ -84,6 +84,17 @@ Supported chips: Addresses scanned: I2C 0x4c Addresses scanned: I2C 0x4c Datasheet: Publicly available at the Maxim website Datasheet: Publicly available at the Maxim website http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3500 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3500 * Maxim MAX6695 Prefix: 'max6695' Addresses scanned: I2C 0x18 Datasheet: Publicly available at the Maxim website http://www.maxim-ic.com/datasheet/index.mvp/id/4199 * Maxim MAX6696 Prefix: 'max6695' Addresses scanned: I2C 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d and 0x4e Datasheet: Publicly available at the Maxim website http://www.maxim-ic.com/datasheet/index.mvp/id/4199 * Winbond/Nuvoton W83L771AWG/ASG * Winbond/Nuvoton W83L771AWG/ASG Prefix: 'w83l771' Prefix: 'w83l771' Addresses scanned: I2C 0x4c Addresses scanned: I2C 0x4c Loading Loading @@ -152,6 +163,12 @@ MAX6680 and MAX6681: * Selectable address * Selectable address * Remote sensor type selection * Remote sensor type selection MAX6695 and MAX6696: * Better local resolution * Selectable address (max6696) * Second critical temperature limit * Two remote sensors W83L771AWG/ASG W83L771AWG/ASG * The AWG and ASG variants only differ in package format. * The AWG and ASG variants only differ in package format. * Filter and alert configuration register at 0xBF * Filter and alert configuration register at 0xBF Loading drivers/hwmon/Kconfig +2 −2 Original line number Original line Diff line number Diff line Loading @@ -614,8 +614,8 @@ config SENSORS_LM90 If you say yes here you get support for National Semiconductor LM90, If you say yes here you get support for National Semiconductor LM90, LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, Maxim LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, Maxim MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659, MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659, MAX6680, MAX6681 and MAX6692, and Winbond/Nuvoton W83L771AWG/ASG MAX6680, MAX6681, MAX6692, MAX6695, MAX6696, and Winbond/Nuvoton sensor chips. W83L771AWG/ASG sensor chips. This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module will be called lm90. will be called lm90. Loading drivers/hwmon/lm90.c +228 −22 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,11 @@ * chips. The MAX6680 and MAX6681 only differ in the pinout so they can * chips. The MAX6680 and MAX6681 only differ in the pinout so they can * be treated identically. * be treated identically. * * * This driver also supports the MAX6695 and MAX6696, two other sensor * chips made by Maxim. These are also quite similar to other Maxim * chips, but support three temperature sensors instead of two. MAX6695 * and MAX6696 only differ in the pinout so they can be treated identically. * * This driver also supports the ADT7461 chip from Analog Devices. * This driver also supports the ADT7461 chip from Analog Devices. * It's supported in both compatibility and extended mode. It is mostly * It's supported in both compatibility and extended mode. It is mostly * compatible with LM90 except for a data format difference for the * compatible with LM90 except for a data format difference for the Loading Loading @@ -96,7 +101,7 @@ static const unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, max6646, w83l771 }; max6646, w83l771, max6696 }; /* /* * The LM90 registers * The LM90 registers Loading Loading @@ -137,9 +142,10 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, #define LM90_REG_R_TCRIT_HYST 0x21 #define LM90_REG_R_TCRIT_HYST 0x21 #define LM90_REG_W_TCRIT_HYST 0x21 #define LM90_REG_W_TCRIT_HYST 0x21 /* MAX6646/6647/6649/6657/6658/6659 registers */ /* MAX6646/6647/6649/6657/6658/6659/6695/6696 registers */ #define MAX6657_REG_R_LOCAL_TEMPL 0x11 #define MAX6657_REG_R_LOCAL_TEMPL 0x11 #define MAX6696_REG_R_STATUS2 0x12 #define MAX6659_REG_R_REMOTE_EMERG 0x16 #define MAX6659_REG_R_REMOTE_EMERG 0x16 #define MAX6659_REG_W_REMOTE_EMERG 0x16 #define MAX6659_REG_W_REMOTE_EMERG 0x16 #define MAX6659_REG_R_LOCAL_EMERG 0x17 #define MAX6659_REG_R_LOCAL_EMERG 0x17 Loading @@ -154,6 +160,8 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, #define LM90_HAVE_LOCAL_EXT (1 << 2) /* extended local temperature */ #define LM90_HAVE_LOCAL_EXT (1 << 2) /* extended local temperature */ #define LM90_HAVE_REM_LIMIT_EXT (1 << 3) /* extended remote limit */ #define LM90_HAVE_REM_LIMIT_EXT (1 << 3) /* extended remote limit */ #define LM90_HAVE_EMERGENCY (1 << 4) /* 3rd upper (emergency) limit */ #define LM90_HAVE_EMERGENCY (1 << 4) /* 3rd upper (emergency) limit */ #define LM90_HAVE_EMERGENCY_ALARM (1 << 5)/* emergency alarm */ #define LM90_HAVE_TEMP3 (1 << 6) /* 3rd temperature sensor */ /* /* * Functions declaration * Functions declaration Loading @@ -166,6 +174,9 @@ static void lm90_init_client(struct i2c_client *client); static void lm90_alert(struct i2c_client *client, unsigned int flag); static void lm90_alert(struct i2c_client *client, unsigned int flag); static int lm90_remove(struct i2c_client *client); static int lm90_remove(struct i2c_client *client); static struct lm90_data *lm90_update_device(struct device *dev); static struct lm90_data *lm90_update_device(struct device *dev); static inline void lm90_select_remote_channel(struct i2c_client *client, struct lm90_data *data, int channel); /* /* * Driver data (common to all clients) * Driver data (common to all clients) Loading @@ -186,6 +197,8 @@ static const struct i2c_device_id lm90_id[] = { { "max6659", max6659 }, { "max6659", max6659 }, { "max6680", max6680 }, { "max6680", max6680 }, { "max6681", max6680 }, { "max6681", max6680 }, { "max6695", max6696 }, { "max6696", max6696 }, { "w83l771", w83l771 }, { "w83l771", w83l771 }, { } { } }; }; Loading Loading @@ -217,22 +230,29 @@ struct lm90_data { int flags; int flags; u8 config_orig; /* Original configuration register value */ u8 config_orig; /* Original configuration register value */ u8 alert_alarms; /* Which alarm bits trigger ALERT# */ u16 alert_alarms; /* Which alarm bits trigger ALERT# */ /* Upper 8 bits for max6695/96 */ /* registers values */ /* registers values */ s8 temp8[6]; /* 0: local low limit s8 temp8[8]; /* 0: local low limit 1: local high limit 1: local high limit 2: local critical limit 2: local critical limit 3: remote critical limit 3: remote critical limit 4: local emergency limit (max6659 only) 4: local emergency limit (max6659 and max6695/96) 5: remote emergency limit (max6659 only) */ 5: remote emergency limit (max6659 and max6695/96) s16 temp11[5]; /* 0: remote input 6: remote 2 critical limit (max6695/96 only) 7: remote 2 emergency limit (max6695/96 only) */ s16 temp11[8]; /* 0: remote input 1: remote low limit 1: remote low limit 2: remote high limit 2: remote high limit 3: remote offset (except max6646 and max6657/58/59) 3: remote offset (except max6646, max6657/58/59, 4: local input */ and max6695/96) 4: local input 5: remote 2 input (max6695/96 only) 6: remote 2 low limit (max6695/96 only) 7: remote 2 high limit (ma6695/96 only) */ u8 temp_hyst; u8 temp_hyst; u8 alarms; /* bitvector */ u16 alarms; /* bitvector (upper 8 bits for max6695/96) */ }; }; /* /* Loading Loading @@ -390,13 +410,15 @@ static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) const char *buf, size_t count) { { static const u8 reg[6] = { static const u8 reg[8] = { LM90_REG_W_LOCAL_LOW, LM90_REG_W_LOCAL_LOW, LM90_REG_W_LOCAL_HIGH, LM90_REG_W_LOCAL_HIGH, LM90_REG_W_LOCAL_CRIT, LM90_REG_W_LOCAL_CRIT, LM90_REG_W_REMOTE_CRIT, LM90_REG_W_REMOTE_CRIT, MAX6659_REG_W_LOCAL_EMERG, MAX6659_REG_W_LOCAL_EMERG, MAX6659_REG_W_REMOTE_EMERG, MAX6659_REG_W_REMOTE_EMERG, LM90_REG_W_REMOTE_CRIT, MAX6659_REG_W_REMOTE_EMERG, }; }; struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); Loading @@ -421,7 +443,11 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, data->temp8[nr] = temp_to_u8(val); data->temp8[nr] = temp_to_u8(val); else else data->temp8[nr] = temp_to_s8(val); data->temp8[nr] = temp_to_s8(val); lm90_select_remote_channel(client, data, nr >= 6); i2c_smbus_write_byte_data(client, reg[nr], data->temp8[nr]); i2c_smbus_write_byte_data(client, reg[nr], data->temp8[nr]); lm90_select_remote_channel(client, data, 0); mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock); return count; return count; } } Loading Loading @@ -453,10 +479,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, struct { struct { u8 high; u8 high; u8 low; u8 low; } reg[3] = { int channel; { LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL }, } reg[5] = { { LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL }, { LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL, 0 }, { LM90_REG_W_REMOTE_OFFSH, LM90_REG_W_REMOTE_OFFSL } { LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL, 0 }, { LM90_REG_W_REMOTE_OFFSH, LM90_REG_W_REMOTE_OFFSL, 0 }, { LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL, 1 }, { LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL, 1 } }; }; struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); Loading Loading @@ -485,11 +514,14 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, else else data->temp11[index] = temp_to_s8(val) << 8; data->temp11[index] = temp_to_s8(val) << 8; lm90_select_remote_channel(client, data, reg[nr].channel); i2c_smbus_write_byte_data(client, reg[nr].high, i2c_smbus_write_byte_data(client, reg[nr].high, data->temp11[index] >> 8); data->temp11[index] >> 8); if (data->flags & LM90_HAVE_REM_LIMIT_EXT) if (data->flags & LM90_HAVE_REM_LIMIT_EXT) i2c_smbus_write_byte_data(client, reg[nr].low, i2c_smbus_write_byte_data(client, reg[nr].low, data->temp11[index] & 0xff); data->temp11[index] & 0xff); lm90_select_remote_channel(client, data, 0); mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock); return count; return count; } } Loading Loading @@ -643,6 +675,62 @@ static const struct attribute_group lm90_emergency_group = { .attrs = lm90_emergency_attributes, .attrs = lm90_emergency_attributes, }; }; static SENSOR_DEVICE_ATTR(temp1_emergency_alarm, S_IRUGO, show_alarm, NULL, 15); static SENSOR_DEVICE_ATTR(temp2_emergency_alarm, S_IRUGO, show_alarm, NULL, 13); static struct attribute *lm90_emergency_alarm_attributes[] = { &sensor_dev_attr_temp1_emergency_alarm.dev_attr.attr, &sensor_dev_attr_temp2_emergency_alarm.dev_attr.attr, NULL }; static const struct attribute_group lm90_emergency_alarm_group = { .attrs = lm90_emergency_alarm_attributes, }; /* * Additional attributes for devices with 3 temperature sensors */ static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp11, NULL, 0, 5); static SENSOR_DEVICE_ATTR_2(temp3_min, S_IWUSR | S_IRUGO, show_temp11, set_temp11, 3, 6); static SENSOR_DEVICE_ATTR_2(temp3_max, S_IWUSR | S_IRUGO, show_temp11, set_temp11, 4, 7); static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp8, set_temp8, 6); static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_temphyst, NULL, 6); static SENSOR_DEVICE_ATTR(temp3_emergency, S_IWUSR | S_IRUGO, show_temp8, set_temp8, 7); static SENSOR_DEVICE_ATTR(temp3_emergency_hyst, S_IRUGO, show_temphyst, NULL, 7); static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 9); static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 10); static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_alarm, NULL, 11); static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 12); static SENSOR_DEVICE_ATTR(temp3_emergency_alarm, S_IRUGO, show_alarm, NULL, 14); static struct attribute *lm90_temp3_attributes[] = { &sensor_dev_attr_temp3_input.dev_attr.attr, &sensor_dev_attr_temp3_min.dev_attr.attr, &sensor_dev_attr_temp3_max.dev_attr.attr, &sensor_dev_attr_temp3_crit.dev_attr.attr, &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr, &sensor_dev_attr_temp3_emergency.dev_attr.attr, &sensor_dev_attr_temp3_emergency_hyst.dev_attr.attr, &sensor_dev_attr_temp3_fault.dev_attr.attr, &sensor_dev_attr_temp3_min_alarm.dev_attr.attr, &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr, &sensor_dev_attr_temp3_emergency_alarm.dev_attr.attr, NULL }; static const struct attribute_group lm90_temp3_group = { .attrs = lm90_temp3_attributes, }; /* pec used for ADM1032 only */ /* pec used for ADM1032 only */ static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, char *buf) char *buf) Loading Loading @@ -720,6 +808,30 @@ static int lm90_read_reg(struct i2c_client *client, u8 reg, u8 *value) return 0; return 0; } } /* * client->update_lock must be held when calling this function (unless we are * in detection or initialization steps), and while a remote channel other * than channel 0 is selected. Also, calling code must make sure to re-select * external channel 0 before releasing the lock. This is necessary because * various registers have different meanings as a result of selecting a * non-default remote channel. */ static inline void lm90_select_remote_channel(struct i2c_client *client, struct lm90_data *data, int channel) { u8 config; if (data->kind == max6696) { lm90_read_reg(client, LM90_REG_R_CONFIG1, &config); config &= ~0x08; if (channel) config |= 0x08; i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); } } /* Return 0 if detection is successful, -ENODEV otherwise */ /* Return 0 if detection is successful, -ENODEV otherwise */ static int lm90_detect(struct i2c_client *new_client, static int lm90_detect(struct i2c_client *new_client, struct i2c_board_info *info) struct i2c_board_info *info) Loading Loading @@ -794,6 +906,23 @@ static int lm90_detect(struct i2c_client *new_client, } } } else } else if (man_id == 0x4D) { /* Maxim */ if (man_id == 0x4D) { /* Maxim */ int reg_emerg, reg_emerg2, reg_status2; /* * We read MAX6659_REG_R_REMOTE_EMERG twice, and re-read * LM90_REG_R_MAN_ID in between. If MAX6659_REG_R_REMOTE_EMERG * exists, both readings will reflect the same value. Otherwise, * the readings will be different. */ if ((reg_emerg = i2c_smbus_read_byte_data(new_client, MAX6659_REG_R_REMOTE_EMERG)) < 0 || i2c_smbus_read_byte_data(new_client, LM90_REG_R_MAN_ID) < 0 || (reg_emerg2 = i2c_smbus_read_byte_data(new_client, MAX6659_REG_R_REMOTE_EMERG)) < 0 || (reg_status2 = i2c_smbus_read_byte_data(new_client, MAX6696_REG_R_STATUS2)) < 0) return -ENODEV; /* /* * The MAX6657, MAX6658 and MAX6659 do NOT have a chip_id * The MAX6657, MAX6658 and MAX6659 do NOT have a chip_id * register. Reading from that address will return the last * register. Reading from that address will return the last Loading @@ -816,6 +945,24 @@ static int lm90_detect(struct i2c_client *new_client, else else name = "max6659"; name = "max6659"; } else } else /* * Even though MAX6695 and MAX6696 do not have a chip ID * register, reading it returns 0x01. Bit 4 of the config1 * register is unused and should return zero when read. Bit 0 of * the status2 register is unused and should return zero when * read. * * MAX6695 and MAX6696 have an additional set of temperature * limit registers. We can detect those chips by checking if * one of those registers exists. */ if (chip_id == 0x01 && (reg_config1 & 0x10) == 0x00 && (reg_status2 & 0x01) == 0x00 && reg_emerg == reg_emerg2 && reg_convrate <= 0x07) { name = "max6696"; } else /* /* * The chip_id register of the MAX6680 and MAX6681 holds the * The chip_id register of the MAX6680 and MAX6681 holds the * revision of the chip. The lowest bit of the config1 register * revision of the chip. The lowest bit of the config1 register Loading Loading @@ -861,6 +1008,11 @@ static int lm90_detect(struct i2c_client *new_client, static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data) static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data) { { if (data->flags & LM90_HAVE_TEMP3) sysfs_remove_group(&client->dev.kobj, &lm90_temp3_group); if (data->flags & LM90_HAVE_EMERGENCY_ALARM) sysfs_remove_group(&client->dev.kobj, &lm90_emergency_alarm_group); if (data->flags & LM90_HAVE_EMERGENCY) if (data->flags & LM90_HAVE_EMERGENCY) sysfs_remove_group(&client->dev.kobj, sysfs_remove_group(&client->dev.kobj, &lm90_emergency_group); &lm90_emergency_group); Loading Loading @@ -901,6 +1053,9 @@ static int lm90_probe(struct i2c_client *new_client, case lm86: case lm86: data->alert_alarms = 0x7b; data->alert_alarms = 0x7b; break; break; case max6696: data->alert_alarms = 0x187c; break; default: default: data->alert_alarms = 0x7c; data->alert_alarms = 0x7c; break; break; Loading @@ -908,20 +1063,24 @@ static int lm90_probe(struct i2c_client *new_client, /* Set chip capabilities */ /* Set chip capabilities */ if (data->kind != max6657 && data->kind != max6659 if (data->kind != max6657 && data->kind != max6659 && data->kind != max6646) && data->kind != max6646 && data->kind != max6696) data->flags |= LM90_HAVE_OFFSET; data->flags |= LM90_HAVE_OFFSET; if (data->kind == max6657 || data->kind == max6659 if (data->kind == max6657 || data->kind == max6659 || data->kind == max6646) || data->kind == max6646 || data->kind == max6696) data->flags |= LM90_HAVE_LOCAL_EXT; data->flags |= LM90_HAVE_LOCAL_EXT; if (data->kind != max6657 && data->kind != max6659 if (data->kind != max6657 && data->kind != max6659 && data->kind != max6646 && data->kind != max6680) && data->kind != max6646 && data->kind != max6680 && data->kind != max6696) data->flags |= LM90_HAVE_REM_LIMIT_EXT; data->flags |= LM90_HAVE_REM_LIMIT_EXT; if (data->kind == max6659) if (data->kind == max6659 || data->kind == max6696) data->flags |= LM90_HAVE_EMERGENCY; data->flags |= LM90_HAVE_EMERGENCY; if (data->kind == max6696) data->flags |= LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3; /* Initialize the LM90 chip */ /* Initialize the LM90 chip */ lm90_init_client(new_client); lm90_init_client(new_client); Loading @@ -946,6 +1105,18 @@ static int lm90_probe(struct i2c_client *new_client, if (err) if (err) goto exit_remove_files; goto exit_remove_files; } } if (data->flags & LM90_HAVE_EMERGENCY_ALARM) { err = sysfs_create_group(&new_client->dev.kobj, &lm90_emergency_alarm_group); if (err) goto exit_remove_files; } if (data->flags & LM90_HAVE_TEMP3) { err = sysfs_create_group(&new_client->dev.kobj, &lm90_temp3_group); if (err) goto exit_remove_files; } data->hwmon_dev = hwmon_device_register(&new_client->dev); data->hwmon_dev = hwmon_device_register(&new_client->dev); if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) { Loading Loading @@ -993,6 +1164,12 @@ static void lm90_init_client(struct i2c_client *client) if (data->kind == max6680) if (data->kind == max6680) config |= 0x18; config |= 0x18; /* * Select external channel 0 for max6695/96 */ if (data->kind == max6696) config &= ~0x08; config &= 0xBF; /* run */ config &= 0xBF; /* run */ if (config != data->config_orig) /* Only write if changed */ if (config != data->config_orig) /* Only write if changed */ i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); Loading @@ -1016,10 +1193,14 @@ static int lm90_remove(struct i2c_client *client) static void lm90_alert(struct i2c_client *client, unsigned int flag) static void lm90_alert(struct i2c_client *client, unsigned int flag) { { struct lm90_data *data = i2c_get_clientdata(client); struct lm90_data *data = i2c_get_clientdata(client); u8 config, alarms; u8 config, alarms, alarms2 = 0; lm90_read_reg(client, LM90_REG_R_STATUS, &alarms); lm90_read_reg(client, LM90_REG_R_STATUS, &alarms); if ((alarms & 0x7f) == 0) { if (data->kind == max6696) lm90_read_reg(client, MAX6696_REG_R_STATUS2, &alarms2); if ((alarms & 0x7f) == 0 && (alarms2 & 0xfe) == 0) { dev_info(&client->dev, "Everything OK\n"); dev_info(&client->dev, "Everything OK\n"); } else { } else { if (alarms & 0x61) if (alarms & 0x61) Loading @@ -1032,6 +1213,10 @@ static void lm90_alert(struct i2c_client *client, unsigned int flag) dev_warn(&client->dev, dev_warn(&client->dev, "temp%d diode open, please check!\n", 2); "temp%d diode open, please check!\n", 2); if (alarms2 & 0x18) dev_warn(&client->dev, "temp%d out of range, please check!\n", 3); /* Disable ALERT# output, because these chips don't implement /* Disable ALERT# output, because these chips don't implement SMBus alert correctly; they should only hold the alert line SMBus alert correctly; they should only hold the alert line low briefly. */ low briefly. */ Loading Loading @@ -1087,6 +1272,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) if (time_after(jiffies, data->last_updated + HZ / 2 + HZ / 10) if (time_after(jiffies, data->last_updated + HZ / 2 + HZ / 10) || !data->valid) { || !data->valid) { u8 h, l; u8 h, l; u8 alarms; dev_dbg(&client->dev, "Updating lm90 data.\n"); dev_dbg(&client->dev, "Updating lm90 data.\n"); lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[0]); lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[0]); Loading Loading @@ -1135,7 +1321,27 @@ static struct lm90_data *lm90_update_device(struct device *dev) lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG, lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG, &data->temp8[5]); &data->temp8[5]); } } lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms); lm90_read_reg(client, LM90_REG_R_STATUS, &alarms); data->alarms = alarms; /* save as 16 bit value */ if (data->kind == max6696) { lm90_select_remote_channel(client, data, 1); lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[6]); lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG, &data->temp8[7]); lm90_read16(client, LM90_REG_R_REMOTE_TEMPH, LM90_REG_R_REMOTE_TEMPL, &data->temp11[5]); if (!lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h)) data->temp11[6] = h << 8; if (!lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h)) data->temp11[7] = h << 8; lm90_select_remote_channel(client, data, 0); if (!lm90_read_reg(client, MAX6696_REG_R_STATUS2, &alarms)) data->alarms |= alarms << 8; } /* Re-enable ALERT# output if it was originally enabled and /* Re-enable ALERT# output if it was originally enabled and * relevant alarms are all clear */ * relevant alarms are all clear */ Loading Loading
Documentation/hwmon/lm90 +17 −0 Original line number Original line Diff line number Diff line Loading @@ -84,6 +84,17 @@ Supported chips: Addresses scanned: I2C 0x4c Addresses scanned: I2C 0x4c Datasheet: Publicly available at the Maxim website Datasheet: Publicly available at the Maxim website http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3500 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3500 * Maxim MAX6695 Prefix: 'max6695' Addresses scanned: I2C 0x18 Datasheet: Publicly available at the Maxim website http://www.maxim-ic.com/datasheet/index.mvp/id/4199 * Maxim MAX6696 Prefix: 'max6695' Addresses scanned: I2C 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d and 0x4e Datasheet: Publicly available at the Maxim website http://www.maxim-ic.com/datasheet/index.mvp/id/4199 * Winbond/Nuvoton W83L771AWG/ASG * Winbond/Nuvoton W83L771AWG/ASG Prefix: 'w83l771' Prefix: 'w83l771' Addresses scanned: I2C 0x4c Addresses scanned: I2C 0x4c Loading Loading @@ -152,6 +163,12 @@ MAX6680 and MAX6681: * Selectable address * Selectable address * Remote sensor type selection * Remote sensor type selection MAX6695 and MAX6696: * Better local resolution * Selectable address (max6696) * Second critical temperature limit * Two remote sensors W83L771AWG/ASG W83L771AWG/ASG * The AWG and ASG variants only differ in package format. * The AWG and ASG variants only differ in package format. * Filter and alert configuration register at 0xBF * Filter and alert configuration register at 0xBF Loading
drivers/hwmon/Kconfig +2 −2 Original line number Original line Diff line number Diff line Loading @@ -614,8 +614,8 @@ config SENSORS_LM90 If you say yes here you get support for National Semiconductor LM90, If you say yes here you get support for National Semiconductor LM90, LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, Maxim LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, Maxim MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659, MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659, MAX6680, MAX6681 and MAX6692, and Winbond/Nuvoton W83L771AWG/ASG MAX6680, MAX6681, MAX6692, MAX6695, MAX6696, and Winbond/Nuvoton sensor chips. W83L771AWG/ASG sensor chips. This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module will be called lm90. will be called lm90. Loading
drivers/hwmon/lm90.c +228 −22 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,11 @@ * chips. The MAX6680 and MAX6681 only differ in the pinout so they can * chips. The MAX6680 and MAX6681 only differ in the pinout so they can * be treated identically. * be treated identically. * * * This driver also supports the MAX6695 and MAX6696, two other sensor * chips made by Maxim. These are also quite similar to other Maxim * chips, but support three temperature sensors instead of two. MAX6695 * and MAX6696 only differ in the pinout so they can be treated identically. * * This driver also supports the ADT7461 chip from Analog Devices. * This driver also supports the ADT7461 chip from Analog Devices. * It's supported in both compatibility and extended mode. It is mostly * It's supported in both compatibility and extended mode. It is mostly * compatible with LM90 except for a data format difference for the * compatible with LM90 except for a data format difference for the Loading Loading @@ -96,7 +101,7 @@ static const unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, max6646, w83l771 }; max6646, w83l771, max6696 }; /* /* * The LM90 registers * The LM90 registers Loading Loading @@ -137,9 +142,10 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, #define LM90_REG_R_TCRIT_HYST 0x21 #define LM90_REG_R_TCRIT_HYST 0x21 #define LM90_REG_W_TCRIT_HYST 0x21 #define LM90_REG_W_TCRIT_HYST 0x21 /* MAX6646/6647/6649/6657/6658/6659 registers */ /* MAX6646/6647/6649/6657/6658/6659/6695/6696 registers */ #define MAX6657_REG_R_LOCAL_TEMPL 0x11 #define MAX6657_REG_R_LOCAL_TEMPL 0x11 #define MAX6696_REG_R_STATUS2 0x12 #define MAX6659_REG_R_REMOTE_EMERG 0x16 #define MAX6659_REG_R_REMOTE_EMERG 0x16 #define MAX6659_REG_W_REMOTE_EMERG 0x16 #define MAX6659_REG_W_REMOTE_EMERG 0x16 #define MAX6659_REG_R_LOCAL_EMERG 0x17 #define MAX6659_REG_R_LOCAL_EMERG 0x17 Loading @@ -154,6 +160,8 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, #define LM90_HAVE_LOCAL_EXT (1 << 2) /* extended local temperature */ #define LM90_HAVE_LOCAL_EXT (1 << 2) /* extended local temperature */ #define LM90_HAVE_REM_LIMIT_EXT (1 << 3) /* extended remote limit */ #define LM90_HAVE_REM_LIMIT_EXT (1 << 3) /* extended remote limit */ #define LM90_HAVE_EMERGENCY (1 << 4) /* 3rd upper (emergency) limit */ #define LM90_HAVE_EMERGENCY (1 << 4) /* 3rd upper (emergency) limit */ #define LM90_HAVE_EMERGENCY_ALARM (1 << 5)/* emergency alarm */ #define LM90_HAVE_TEMP3 (1 << 6) /* 3rd temperature sensor */ /* /* * Functions declaration * Functions declaration Loading @@ -166,6 +174,9 @@ static void lm90_init_client(struct i2c_client *client); static void lm90_alert(struct i2c_client *client, unsigned int flag); static void lm90_alert(struct i2c_client *client, unsigned int flag); static int lm90_remove(struct i2c_client *client); static int lm90_remove(struct i2c_client *client); static struct lm90_data *lm90_update_device(struct device *dev); static struct lm90_data *lm90_update_device(struct device *dev); static inline void lm90_select_remote_channel(struct i2c_client *client, struct lm90_data *data, int channel); /* /* * Driver data (common to all clients) * Driver data (common to all clients) Loading @@ -186,6 +197,8 @@ static const struct i2c_device_id lm90_id[] = { { "max6659", max6659 }, { "max6659", max6659 }, { "max6680", max6680 }, { "max6680", max6680 }, { "max6681", max6680 }, { "max6681", max6680 }, { "max6695", max6696 }, { "max6696", max6696 }, { "w83l771", w83l771 }, { "w83l771", w83l771 }, { } { } }; }; Loading Loading @@ -217,22 +230,29 @@ struct lm90_data { int flags; int flags; u8 config_orig; /* Original configuration register value */ u8 config_orig; /* Original configuration register value */ u8 alert_alarms; /* Which alarm bits trigger ALERT# */ u16 alert_alarms; /* Which alarm bits trigger ALERT# */ /* Upper 8 bits for max6695/96 */ /* registers values */ /* registers values */ s8 temp8[6]; /* 0: local low limit s8 temp8[8]; /* 0: local low limit 1: local high limit 1: local high limit 2: local critical limit 2: local critical limit 3: remote critical limit 3: remote critical limit 4: local emergency limit (max6659 only) 4: local emergency limit (max6659 and max6695/96) 5: remote emergency limit (max6659 only) */ 5: remote emergency limit (max6659 and max6695/96) s16 temp11[5]; /* 0: remote input 6: remote 2 critical limit (max6695/96 only) 7: remote 2 emergency limit (max6695/96 only) */ s16 temp11[8]; /* 0: remote input 1: remote low limit 1: remote low limit 2: remote high limit 2: remote high limit 3: remote offset (except max6646 and max6657/58/59) 3: remote offset (except max6646, max6657/58/59, 4: local input */ and max6695/96) 4: local input 5: remote 2 input (max6695/96 only) 6: remote 2 low limit (max6695/96 only) 7: remote 2 high limit (ma6695/96 only) */ u8 temp_hyst; u8 temp_hyst; u8 alarms; /* bitvector */ u16 alarms; /* bitvector (upper 8 bits for max6695/96) */ }; }; /* /* Loading Loading @@ -390,13 +410,15 @@ static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) const char *buf, size_t count) { { static const u8 reg[6] = { static const u8 reg[8] = { LM90_REG_W_LOCAL_LOW, LM90_REG_W_LOCAL_LOW, LM90_REG_W_LOCAL_HIGH, LM90_REG_W_LOCAL_HIGH, LM90_REG_W_LOCAL_CRIT, LM90_REG_W_LOCAL_CRIT, LM90_REG_W_REMOTE_CRIT, LM90_REG_W_REMOTE_CRIT, MAX6659_REG_W_LOCAL_EMERG, MAX6659_REG_W_LOCAL_EMERG, MAX6659_REG_W_REMOTE_EMERG, MAX6659_REG_W_REMOTE_EMERG, LM90_REG_W_REMOTE_CRIT, MAX6659_REG_W_REMOTE_EMERG, }; }; struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); Loading @@ -421,7 +443,11 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, data->temp8[nr] = temp_to_u8(val); data->temp8[nr] = temp_to_u8(val); else else data->temp8[nr] = temp_to_s8(val); data->temp8[nr] = temp_to_s8(val); lm90_select_remote_channel(client, data, nr >= 6); i2c_smbus_write_byte_data(client, reg[nr], data->temp8[nr]); i2c_smbus_write_byte_data(client, reg[nr], data->temp8[nr]); lm90_select_remote_channel(client, data, 0); mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock); return count; return count; } } Loading Loading @@ -453,10 +479,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, struct { struct { u8 high; u8 high; u8 low; u8 low; } reg[3] = { int channel; { LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL }, } reg[5] = { { LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL }, { LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL, 0 }, { LM90_REG_W_REMOTE_OFFSH, LM90_REG_W_REMOTE_OFFSL } { LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL, 0 }, { LM90_REG_W_REMOTE_OFFSH, LM90_REG_W_REMOTE_OFFSL, 0 }, { LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL, 1 }, { LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL, 1 } }; }; struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); Loading Loading @@ -485,11 +514,14 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, else else data->temp11[index] = temp_to_s8(val) << 8; data->temp11[index] = temp_to_s8(val) << 8; lm90_select_remote_channel(client, data, reg[nr].channel); i2c_smbus_write_byte_data(client, reg[nr].high, i2c_smbus_write_byte_data(client, reg[nr].high, data->temp11[index] >> 8); data->temp11[index] >> 8); if (data->flags & LM90_HAVE_REM_LIMIT_EXT) if (data->flags & LM90_HAVE_REM_LIMIT_EXT) i2c_smbus_write_byte_data(client, reg[nr].low, i2c_smbus_write_byte_data(client, reg[nr].low, data->temp11[index] & 0xff); data->temp11[index] & 0xff); lm90_select_remote_channel(client, data, 0); mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock); return count; return count; } } Loading Loading @@ -643,6 +675,62 @@ static const struct attribute_group lm90_emergency_group = { .attrs = lm90_emergency_attributes, .attrs = lm90_emergency_attributes, }; }; static SENSOR_DEVICE_ATTR(temp1_emergency_alarm, S_IRUGO, show_alarm, NULL, 15); static SENSOR_DEVICE_ATTR(temp2_emergency_alarm, S_IRUGO, show_alarm, NULL, 13); static struct attribute *lm90_emergency_alarm_attributes[] = { &sensor_dev_attr_temp1_emergency_alarm.dev_attr.attr, &sensor_dev_attr_temp2_emergency_alarm.dev_attr.attr, NULL }; static const struct attribute_group lm90_emergency_alarm_group = { .attrs = lm90_emergency_alarm_attributes, }; /* * Additional attributes for devices with 3 temperature sensors */ static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp11, NULL, 0, 5); static SENSOR_DEVICE_ATTR_2(temp3_min, S_IWUSR | S_IRUGO, show_temp11, set_temp11, 3, 6); static SENSOR_DEVICE_ATTR_2(temp3_max, S_IWUSR | S_IRUGO, show_temp11, set_temp11, 4, 7); static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp8, set_temp8, 6); static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_temphyst, NULL, 6); static SENSOR_DEVICE_ATTR(temp3_emergency, S_IWUSR | S_IRUGO, show_temp8, set_temp8, 7); static SENSOR_DEVICE_ATTR(temp3_emergency_hyst, S_IRUGO, show_temphyst, NULL, 7); static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 9); static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 10); static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_alarm, NULL, 11); static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 12); static SENSOR_DEVICE_ATTR(temp3_emergency_alarm, S_IRUGO, show_alarm, NULL, 14); static struct attribute *lm90_temp3_attributes[] = { &sensor_dev_attr_temp3_input.dev_attr.attr, &sensor_dev_attr_temp3_min.dev_attr.attr, &sensor_dev_attr_temp3_max.dev_attr.attr, &sensor_dev_attr_temp3_crit.dev_attr.attr, &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr, &sensor_dev_attr_temp3_emergency.dev_attr.attr, &sensor_dev_attr_temp3_emergency_hyst.dev_attr.attr, &sensor_dev_attr_temp3_fault.dev_attr.attr, &sensor_dev_attr_temp3_min_alarm.dev_attr.attr, &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr, &sensor_dev_attr_temp3_emergency_alarm.dev_attr.attr, NULL }; static const struct attribute_group lm90_temp3_group = { .attrs = lm90_temp3_attributes, }; /* pec used for ADM1032 only */ /* pec used for ADM1032 only */ static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, char *buf) char *buf) Loading Loading @@ -720,6 +808,30 @@ static int lm90_read_reg(struct i2c_client *client, u8 reg, u8 *value) return 0; return 0; } } /* * client->update_lock must be held when calling this function (unless we are * in detection or initialization steps), and while a remote channel other * than channel 0 is selected. Also, calling code must make sure to re-select * external channel 0 before releasing the lock. This is necessary because * various registers have different meanings as a result of selecting a * non-default remote channel. */ static inline void lm90_select_remote_channel(struct i2c_client *client, struct lm90_data *data, int channel) { u8 config; if (data->kind == max6696) { lm90_read_reg(client, LM90_REG_R_CONFIG1, &config); config &= ~0x08; if (channel) config |= 0x08; i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); } } /* Return 0 if detection is successful, -ENODEV otherwise */ /* Return 0 if detection is successful, -ENODEV otherwise */ static int lm90_detect(struct i2c_client *new_client, static int lm90_detect(struct i2c_client *new_client, struct i2c_board_info *info) struct i2c_board_info *info) Loading Loading @@ -794,6 +906,23 @@ static int lm90_detect(struct i2c_client *new_client, } } } else } else if (man_id == 0x4D) { /* Maxim */ if (man_id == 0x4D) { /* Maxim */ int reg_emerg, reg_emerg2, reg_status2; /* * We read MAX6659_REG_R_REMOTE_EMERG twice, and re-read * LM90_REG_R_MAN_ID in between. If MAX6659_REG_R_REMOTE_EMERG * exists, both readings will reflect the same value. Otherwise, * the readings will be different. */ if ((reg_emerg = i2c_smbus_read_byte_data(new_client, MAX6659_REG_R_REMOTE_EMERG)) < 0 || i2c_smbus_read_byte_data(new_client, LM90_REG_R_MAN_ID) < 0 || (reg_emerg2 = i2c_smbus_read_byte_data(new_client, MAX6659_REG_R_REMOTE_EMERG)) < 0 || (reg_status2 = i2c_smbus_read_byte_data(new_client, MAX6696_REG_R_STATUS2)) < 0) return -ENODEV; /* /* * The MAX6657, MAX6658 and MAX6659 do NOT have a chip_id * The MAX6657, MAX6658 and MAX6659 do NOT have a chip_id * register. Reading from that address will return the last * register. Reading from that address will return the last Loading @@ -816,6 +945,24 @@ static int lm90_detect(struct i2c_client *new_client, else else name = "max6659"; name = "max6659"; } else } else /* * Even though MAX6695 and MAX6696 do not have a chip ID * register, reading it returns 0x01. Bit 4 of the config1 * register is unused and should return zero when read. Bit 0 of * the status2 register is unused and should return zero when * read. * * MAX6695 and MAX6696 have an additional set of temperature * limit registers. We can detect those chips by checking if * one of those registers exists. */ if (chip_id == 0x01 && (reg_config1 & 0x10) == 0x00 && (reg_status2 & 0x01) == 0x00 && reg_emerg == reg_emerg2 && reg_convrate <= 0x07) { name = "max6696"; } else /* /* * The chip_id register of the MAX6680 and MAX6681 holds the * The chip_id register of the MAX6680 and MAX6681 holds the * revision of the chip. The lowest bit of the config1 register * revision of the chip. The lowest bit of the config1 register Loading Loading @@ -861,6 +1008,11 @@ static int lm90_detect(struct i2c_client *new_client, static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data) static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data) { { if (data->flags & LM90_HAVE_TEMP3) sysfs_remove_group(&client->dev.kobj, &lm90_temp3_group); if (data->flags & LM90_HAVE_EMERGENCY_ALARM) sysfs_remove_group(&client->dev.kobj, &lm90_emergency_alarm_group); if (data->flags & LM90_HAVE_EMERGENCY) if (data->flags & LM90_HAVE_EMERGENCY) sysfs_remove_group(&client->dev.kobj, sysfs_remove_group(&client->dev.kobj, &lm90_emergency_group); &lm90_emergency_group); Loading Loading @@ -901,6 +1053,9 @@ static int lm90_probe(struct i2c_client *new_client, case lm86: case lm86: data->alert_alarms = 0x7b; data->alert_alarms = 0x7b; break; break; case max6696: data->alert_alarms = 0x187c; break; default: default: data->alert_alarms = 0x7c; data->alert_alarms = 0x7c; break; break; Loading @@ -908,20 +1063,24 @@ static int lm90_probe(struct i2c_client *new_client, /* Set chip capabilities */ /* Set chip capabilities */ if (data->kind != max6657 && data->kind != max6659 if (data->kind != max6657 && data->kind != max6659 && data->kind != max6646) && data->kind != max6646 && data->kind != max6696) data->flags |= LM90_HAVE_OFFSET; data->flags |= LM90_HAVE_OFFSET; if (data->kind == max6657 || data->kind == max6659 if (data->kind == max6657 || data->kind == max6659 || data->kind == max6646) || data->kind == max6646 || data->kind == max6696) data->flags |= LM90_HAVE_LOCAL_EXT; data->flags |= LM90_HAVE_LOCAL_EXT; if (data->kind != max6657 && data->kind != max6659 if (data->kind != max6657 && data->kind != max6659 && data->kind != max6646 && data->kind != max6680) && data->kind != max6646 && data->kind != max6680 && data->kind != max6696) data->flags |= LM90_HAVE_REM_LIMIT_EXT; data->flags |= LM90_HAVE_REM_LIMIT_EXT; if (data->kind == max6659) if (data->kind == max6659 || data->kind == max6696) data->flags |= LM90_HAVE_EMERGENCY; data->flags |= LM90_HAVE_EMERGENCY; if (data->kind == max6696) data->flags |= LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3; /* Initialize the LM90 chip */ /* Initialize the LM90 chip */ lm90_init_client(new_client); lm90_init_client(new_client); Loading @@ -946,6 +1105,18 @@ static int lm90_probe(struct i2c_client *new_client, if (err) if (err) goto exit_remove_files; goto exit_remove_files; } } if (data->flags & LM90_HAVE_EMERGENCY_ALARM) { err = sysfs_create_group(&new_client->dev.kobj, &lm90_emergency_alarm_group); if (err) goto exit_remove_files; } if (data->flags & LM90_HAVE_TEMP3) { err = sysfs_create_group(&new_client->dev.kobj, &lm90_temp3_group); if (err) goto exit_remove_files; } data->hwmon_dev = hwmon_device_register(&new_client->dev); data->hwmon_dev = hwmon_device_register(&new_client->dev); if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) { Loading Loading @@ -993,6 +1164,12 @@ static void lm90_init_client(struct i2c_client *client) if (data->kind == max6680) if (data->kind == max6680) config |= 0x18; config |= 0x18; /* * Select external channel 0 for max6695/96 */ if (data->kind == max6696) config &= ~0x08; config &= 0xBF; /* run */ config &= 0xBF; /* run */ if (config != data->config_orig) /* Only write if changed */ if (config != data->config_orig) /* Only write if changed */ i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); Loading @@ -1016,10 +1193,14 @@ static int lm90_remove(struct i2c_client *client) static void lm90_alert(struct i2c_client *client, unsigned int flag) static void lm90_alert(struct i2c_client *client, unsigned int flag) { { struct lm90_data *data = i2c_get_clientdata(client); struct lm90_data *data = i2c_get_clientdata(client); u8 config, alarms; u8 config, alarms, alarms2 = 0; lm90_read_reg(client, LM90_REG_R_STATUS, &alarms); lm90_read_reg(client, LM90_REG_R_STATUS, &alarms); if ((alarms & 0x7f) == 0) { if (data->kind == max6696) lm90_read_reg(client, MAX6696_REG_R_STATUS2, &alarms2); if ((alarms & 0x7f) == 0 && (alarms2 & 0xfe) == 0) { dev_info(&client->dev, "Everything OK\n"); dev_info(&client->dev, "Everything OK\n"); } else { } else { if (alarms & 0x61) if (alarms & 0x61) Loading @@ -1032,6 +1213,10 @@ static void lm90_alert(struct i2c_client *client, unsigned int flag) dev_warn(&client->dev, dev_warn(&client->dev, "temp%d diode open, please check!\n", 2); "temp%d diode open, please check!\n", 2); if (alarms2 & 0x18) dev_warn(&client->dev, "temp%d out of range, please check!\n", 3); /* Disable ALERT# output, because these chips don't implement /* Disable ALERT# output, because these chips don't implement SMBus alert correctly; they should only hold the alert line SMBus alert correctly; they should only hold the alert line low briefly. */ low briefly. */ Loading Loading @@ -1087,6 +1272,7 @@ static struct lm90_data *lm90_update_device(struct device *dev) if (time_after(jiffies, data->last_updated + HZ / 2 + HZ / 10) if (time_after(jiffies, data->last_updated + HZ / 2 + HZ / 10) || !data->valid) { || !data->valid) { u8 h, l; u8 h, l; u8 alarms; dev_dbg(&client->dev, "Updating lm90 data.\n"); dev_dbg(&client->dev, "Updating lm90 data.\n"); lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[0]); lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[0]); Loading Loading @@ -1135,7 +1321,27 @@ static struct lm90_data *lm90_update_device(struct device *dev) lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG, lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG, &data->temp8[5]); &data->temp8[5]); } } lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms); lm90_read_reg(client, LM90_REG_R_STATUS, &alarms); data->alarms = alarms; /* save as 16 bit value */ if (data->kind == max6696) { lm90_select_remote_channel(client, data, 1); lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[6]); lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG, &data->temp8[7]); lm90_read16(client, LM90_REG_R_REMOTE_TEMPH, LM90_REG_R_REMOTE_TEMPL, &data->temp11[5]); if (!lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h)) data->temp11[6] = h << 8; if (!lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h)) data->temp11[7] = h << 8; lm90_select_remote_channel(client, data, 0); if (!lm90_read_reg(client, MAX6696_REG_R_STATUS2, &alarms)) data->alarms |= alarms << 8; } /* Re-enable ALERT# output if it was originally enabled and /* Re-enable ALERT# output if it was originally enabled and * relevant alarms are all clear */ * relevant alarms are all clear */ Loading