diff options
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r-- | drivers/hwmon/lm90.c | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 3edeebc0b835..96a701866726 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -12,9 +12,9 @@ | |||
12 | * made by National Semiconductor. Both have an increased remote | 12 | * made by National Semiconductor. Both have an increased remote |
13 | * temperature measurement accuracy (1 degree), and the LM99 | 13 | * temperature measurement accuracy (1 degree), and the LM99 |
14 | * additionally shifts remote temperatures (measured and limits) by 16 | 14 | * additionally shifts remote temperatures (measured and limits) by 16 |
15 | * degrees, which allows for higher temperatures measurement. The | 15 | * degrees, which allows for higher temperatures measurement. |
16 | * driver doesn't handle it since it can be done easily in user-space. | ||
17 | * Note that there is no way to differentiate between both chips. | 16 | * Note that there is no way to differentiate between both chips. |
17 | * When device is auto-detected, the driver will assume an LM99. | ||
18 | * | 18 | * |
19 | * This driver also supports the LM86, another sensor chip made by | 19 | * This driver also supports the LM86, another sensor chip made by |
20 | * National Semiconductor. It is exactly similar to the LM90 except it | 20 | * National Semiconductor. It is exactly similar to the LM90 except it |
@@ -169,8 +169,8 @@ static const struct i2c_device_id lm90_id[] = { | |||
169 | { "adt7461", adt7461 }, | 169 | { "adt7461", adt7461 }, |
170 | { "lm90", lm90 }, | 170 | { "lm90", lm90 }, |
171 | { "lm86", lm86 }, | 171 | { "lm86", lm86 }, |
172 | { "lm89", lm99 }, | 172 | { "lm89", lm86 }, |
173 | { "lm99", lm99 }, /* Missing temperature offset */ | 173 | { "lm99", lm99 }, |
174 | { "max6646", max6646 }, | 174 | { "max6646", max6646 }, |
175 | { "max6647", max6646 }, | 175 | { "max6647", max6646 }, |
176 | { "max6649", max6646 }, | 176 | { "max6649", max6646 }, |
@@ -366,6 +366,10 @@ static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, | |||
366 | else | 366 | else |
367 | temp = temp_from_s8(data->temp8[attr->index]); | 367 | temp = temp_from_s8(data->temp8[attr->index]); |
368 | 368 | ||
369 | /* +16 degrees offset for temp2 for the LM99 */ | ||
370 | if (data->kind == lm99 && attr->index == 3) | ||
371 | temp += 16000; | ||
372 | |||
369 | return sprintf(buf, "%d\n", temp); | 373 | return sprintf(buf, "%d\n", temp); |
370 | } | 374 | } |
371 | 375 | ||
@@ -385,6 +389,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, | |||
385 | long val = simple_strtol(buf, NULL, 10); | 389 | long val = simple_strtol(buf, NULL, 10); |
386 | int nr = attr->index; | 390 | int nr = attr->index; |
387 | 391 | ||
392 | /* +16 degrees offset for temp2 for the LM99 */ | ||
393 | if (data->kind == lm99 && attr->index == 3) | ||
394 | val -= 16000; | ||
395 | |||
388 | mutex_lock(&data->update_lock); | 396 | mutex_lock(&data->update_lock); |
389 | if (data->kind == adt7461) | 397 | if (data->kind == adt7461) |
390 | data->temp8[nr] = temp_to_u8_adt7461(data, val); | 398 | data->temp8[nr] = temp_to_u8_adt7461(data, val); |
@@ -411,6 +419,10 @@ static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, | |||
411 | else | 419 | else |
412 | temp = temp_from_s16(data->temp11[attr->index]); | 420 | temp = temp_from_s16(data->temp11[attr->index]); |
413 | 421 | ||
422 | /* +16 degrees offset for temp2 for the LM99 */ | ||
423 | if (data->kind == lm99 && attr->index <= 2) | ||
424 | temp += 16000; | ||
425 | |||
414 | return sprintf(buf, "%d\n", temp); | 426 | return sprintf(buf, "%d\n", temp); |
415 | } | 427 | } |
416 | 428 | ||
@@ -432,6 +444,10 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, | |||
432 | long val = simple_strtol(buf, NULL, 10); | 444 | long val = simple_strtol(buf, NULL, 10); |
433 | int nr = attr->index; | 445 | int nr = attr->index; |
434 | 446 | ||
447 | /* +16 degrees offset for temp2 for the LM99 */ | ||
448 | if (data->kind == lm99 && attr->index <= 2) | ||
449 | val -= 16000; | ||
450 | |||
435 | mutex_lock(&data->update_lock); | 451 | mutex_lock(&data->update_lock); |
436 | if (data->kind == adt7461) | 452 | if (data->kind == adt7461) |
437 | data->temp11[nr] = temp_to_u16_adt7461(data, val); | 453 | data->temp11[nr] = temp_to_u16_adt7461(data, val); |
@@ -461,9 +477,15 @@ static ssize_t show_temphyst(struct device *dev, struct device_attribute *devatt | |||
461 | 477 | ||
462 | if (data->kind == adt7461) | 478 | if (data->kind == adt7461) |
463 | temp = temp_from_u8_adt7461(data, data->temp8[attr->index]); | 479 | temp = temp_from_u8_adt7461(data, data->temp8[attr->index]); |
480 | else if (data->kind == max6646) | ||
481 | temp = temp_from_u8(data->temp8[attr->index]); | ||
464 | else | 482 | else |
465 | temp = temp_from_s8(data->temp8[attr->index]); | 483 | temp = temp_from_s8(data->temp8[attr->index]); |
466 | 484 | ||
485 | /* +16 degrees offset for temp2 for the LM99 */ | ||
486 | if (data->kind == lm99 && attr->index == 3) | ||
487 | temp += 16000; | ||
488 | |||
467 | return sprintf(buf, "%d\n", temp - temp_from_s8(data->temp_hyst)); | 489 | return sprintf(buf, "%d\n", temp - temp_from_s8(data->temp_hyst)); |
468 | } | 490 | } |
469 | 491 | ||
@@ -473,12 +495,19 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, | |||
473 | struct i2c_client *client = to_i2c_client(dev); | 495 | struct i2c_client *client = to_i2c_client(dev); |
474 | struct lm90_data *data = i2c_get_clientdata(client); | 496 | struct lm90_data *data = i2c_get_clientdata(client); |
475 | long val = simple_strtol(buf, NULL, 10); | 497 | long val = simple_strtol(buf, NULL, 10); |
476 | long hyst; | 498 | int temp; |
477 | 499 | ||
478 | mutex_lock(&data->update_lock); | 500 | mutex_lock(&data->update_lock); |
479 | hyst = temp_from_s8(data->temp8[2]) - val; | 501 | if (data->kind == adt7461) |
502 | temp = temp_from_u8_adt7461(data, data->temp8[2]); | ||
503 | else if (data->kind == max6646) | ||
504 | temp = temp_from_u8(data->temp8[2]); | ||
505 | else | ||
506 | temp = temp_from_s8(data->temp8[2]); | ||
507 | |||
508 | data->temp_hyst = hyst_to_reg(temp - val); | ||
480 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, | 509 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
481 | hyst_to_reg(hyst)); | 510 | data->temp_hyst); |
482 | mutex_unlock(&data->update_lock); | 511 | mutex_unlock(&data->update_lock); |
483 | return count; | 512 | return count; |
484 | } | 513 | } |
@@ -682,6 +711,15 @@ static int lm90_detect(struct i2c_client *new_client, int kind, | |||
682 | } else | 711 | } else |
683 | if ((chip_id & 0xF0) == 0x30) { /* LM89/LM99 */ | 712 | if ((chip_id & 0xF0) == 0x30) { /* LM89/LM99 */ |
684 | kind = lm99; | 713 | kind = lm99; |
714 | dev_info(&adapter->dev, | ||
715 | "Assuming LM99 chip at " | ||
716 | "0x%02x\n", address); | ||
717 | dev_info(&adapter->dev, | ||
718 | "If it is an LM89, pass " | ||
719 | "force_lm86=%d,0x%02x when " | ||
720 | "loading the lm90 driver\n", | ||
721 | i2c_adapter_id(adapter), | ||
722 | address); | ||
685 | } else | 723 | } else |
686 | if (address == 0x4C | 724 | if (address == 0x4C |
687 | && (chip_id & 0xF0) == 0x10) { /* LM86 */ | 725 | && (chip_id & 0xF0) == 0x10) { /* LM86 */ |