diff options
Diffstat (limited to 'drivers/hwmon/lm90.c')
| -rw-r--r-- | drivers/hwmon/lm90.c | 78 |
1 files changed, 59 insertions, 19 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 6882ce75feee..48833fff4920 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
| @@ -43,6 +43,13 @@ | |||
| 43 | * variants. The extra address and features of the MAX6659 are not | 43 | * variants. The extra address and features of the MAX6659 are not |
| 44 | * supported by this driver. | 44 | * supported by this driver. |
| 45 | * | 45 | * |
| 46 | * This driver also supports the MAX6680 and MAX6681, two other sensor | ||
| 47 | * chips made by Maxim. These are quite similar to the other Maxim | ||
| 48 | * chips. Complete datasheet can be obtained at: | ||
| 49 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3370 | ||
| 50 | * The MAX6680 and MAX6681 only differ in the pinout so they can be | ||
| 51 | * treated identically. | ||
| 52 | * | ||
| 46 | * This driver also supports the ADT7461 chip from Analog Devices but | 53 | * This driver also supports the ADT7461 chip from Analog Devices but |
| 47 | * only in its "compatability mode". If an ADT7461 chip is found but | 54 | * only in its "compatability mode". If an ADT7461 chip is found but |
| 48 | * is configured in non-compatible mode (where its temperature | 55 | * is configured in non-compatible mode (where its temperature |
| @@ -84,20 +91,25 @@ | |||
| 84 | /* | 91 | /* |
| 85 | * Addresses to scan | 92 | * Addresses to scan |
| 86 | * Address is fully defined internally and cannot be changed except for | 93 | * Address is fully defined internally and cannot be changed except for |
| 87 | * MAX6659. | 94 | * MAX6659, MAX6680 and MAX6681. |
| 88 | * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6657 and MAX6658 | 95 | * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6657 and MAX6658 |
| 89 | * have address 0x4c. | 96 | * have address 0x4c. |
| 90 | * ADM1032-2, ADT7461-2, LM89-1, and LM99-1 have address 0x4d. | 97 | * ADM1032-2, ADT7461-2, LM89-1, and LM99-1 have address 0x4d. |
| 91 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). | 98 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). |
| 99 | * MAX6680 and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, | ||
| 100 | * 0x4c, 0x4d or 0x4e. | ||
| 92 | */ | 101 | */ |
| 93 | 102 | ||
| 94 | static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; | 103 | static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a, |
| 104 | 0x29, 0x2a, 0x2b, | ||
| 105 | 0x4c, 0x4d, 0x4e, | ||
| 106 | I2C_CLIENT_END }; | ||
| 95 | 107 | ||
| 96 | /* | 108 | /* |
| 97 | * Insmod parameters | 109 | * Insmod parameters |
| 98 | */ | 110 | */ |
| 99 | 111 | ||
| 100 | I2C_CLIENT_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461); | 112 | I2C_CLIENT_INSMOD_7(lm90, adm1032, lm99, lm86, max6657, adt7461, max6680); |
| 101 | 113 | ||
| 102 | /* | 114 | /* |
| 103 | * The LM90 registers | 115 | * The LM90 registers |
| @@ -359,7 +371,7 @@ static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); | |||
| 359 | /* Individual alarm files */ | 371 | /* Individual alarm files */ |
| 360 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0); | 372 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0); |
| 361 | static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1); | 373 | static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1); |
| 362 | static SENSOR_DEVICE_ATTR(temp2_input_fault, S_IRUGO, show_alarm, NULL, 2); | 374 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); |
| 363 | static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); | 375 | static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); |
| 364 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); | 376 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); |
| 365 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 5); | 377 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 5); |
| @@ -381,7 +393,7 @@ static struct attribute *lm90_attributes[] = { | |||
| 381 | 393 | ||
| 382 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, | 394 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, |
| 383 | &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, | 395 | &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, |
| 384 | &sensor_dev_attr_temp2_input_fault.dev_attr.attr, | 396 | &sensor_dev_attr_temp2_fault.dev_attr.attr, |
| 385 | &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, | 397 | &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, |
| 386 | &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, | 398 | &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, |
| 387 | &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, | 399 | &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, |
| @@ -429,7 +441,7 @@ static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec); | |||
| 429 | */ | 441 | */ |
| 430 | 442 | ||
| 431 | /* The ADM1032 supports PEC but not on write byte transactions, so we need | 443 | /* The ADM1032 supports PEC but not on write byte transactions, so we need |
| 432 | to explicitely ask for a transaction without PEC. */ | 444 | to explicitly ask for a transaction without PEC. */ |
| 433 | static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value) | 445 | static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value) |
| 434 | { | 446 | { |
| 435 | return i2c_smbus_xfer(client->adapter, client->addr, | 447 | return i2c_smbus_xfer(client->adapter, client->addr, |
| @@ -525,7 +537,8 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
| 525 | ®_convrate) < 0) | 537 | ®_convrate) < 0) |
| 526 | goto exit_free; | 538 | goto exit_free; |
| 527 | 539 | ||
| 528 | if (man_id == 0x01) { /* National Semiconductor */ | 540 | if ((address == 0x4C || address == 0x4D) |
| 541 | && man_id == 0x01) { /* National Semiconductor */ | ||
| 529 | u8 reg_config2; | 542 | u8 reg_config2; |
| 530 | 543 | ||
| 531 | if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2, | 544 | if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2, |
| @@ -548,7 +561,8 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
| 548 | } | 561 | } |
| 549 | } | 562 | } |
| 550 | } else | 563 | } else |
| 551 | if (man_id == 0x41) { /* Analog Devices */ | 564 | if ((address == 0x4C || address == 0x4D) |
| 565 | && man_id == 0x41) { /* Analog Devices */ | ||
| 552 | if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ | 566 | if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ |
| 553 | && (reg_config1 & 0x3F) == 0x00 | 567 | && (reg_config1 & 0x3F) == 0x00 |
| 554 | && reg_convrate <= 0x0A) { | 568 | && reg_convrate <= 0x0A) { |
| @@ -562,18 +576,30 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
| 562 | } else | 576 | } else |
| 563 | if (man_id == 0x4D) { /* Maxim */ | 577 | if (man_id == 0x4D) { /* Maxim */ |
| 564 | /* | 578 | /* |
| 565 | * The Maxim variants do NOT have a chip_id register. | 579 | * The MAX6657, MAX6658 and MAX6659 do NOT have a |
| 566 | * Reading from that address will return the last read | 580 | * chip_id register. Reading from that address will |
| 567 | * value, which in our case is those of the man_id | 581 | * return the last read value, which in our case is |
| 568 | * register. Likewise, the config1 register seems to | 582 | * those of the man_id register. Likewise, the config1 |
| 569 | * lack a low nibble, so the value will be those of the | 583 | * register seems to lack a low nibble, so the value |
| 570 | * previous read, so in our case those of the man_id | 584 | * will be those of the previous read, so in our case |
| 571 | * register. | 585 | * those of the man_id register. |
| 572 | */ | 586 | */ |
| 573 | if (chip_id == man_id | 587 | if (chip_id == man_id |
| 588 | && (address == 0x4F || address == 0x4D) | ||
| 574 | && (reg_config1 & 0x1F) == (man_id & 0x0F) | 589 | && (reg_config1 & 0x1F) == (man_id & 0x0F) |
| 575 | && reg_convrate <= 0x09) { | 590 | && reg_convrate <= 0x09) { |
| 576 | kind = max6657; | 591 | kind = max6657; |
| 592 | } else | ||
| 593 | /* The chip_id register of the MAX6680 and MAX6681 | ||
| 594 | * holds the revision of the chip. | ||
| 595 | * the lowest bit of the config1 register is unused | ||
| 596 | * and should return zero when read, so should the | ||
| 597 | * second to last bit of config1 (software reset) | ||
| 598 | */ | ||
| 599 | if (chip_id == 0x01 | ||
| 600 | && (reg_config1 & 0x03) == 0x00 | ||
| 601 | && reg_convrate <= 0x07) { | ||
| 602 | kind = max6680; | ||
| 577 | } | 603 | } |
| 578 | } | 604 | } |
| 579 | 605 | ||
| @@ -599,6 +625,8 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
| 599 | name = "lm86"; | 625 | name = "lm86"; |
| 600 | } else if (kind == max6657) { | 626 | } else if (kind == max6657) { |
| 601 | name = "max6657"; | 627 | name = "max6657"; |
| 628 | } else if (kind == max6680) { | ||
| 629 | name = "max6680"; | ||
| 602 | } else if (kind == adt7461) { | 630 | } else if (kind == adt7461) { |
| 603 | name = "adt7461"; | 631 | name = "adt7461"; |
| 604 | } | 632 | } |
| @@ -646,7 +674,8 @@ exit: | |||
| 646 | 674 | ||
| 647 | static void lm90_init_client(struct i2c_client *client) | 675 | static void lm90_init_client(struct i2c_client *client) |
| 648 | { | 676 | { |
| 649 | u8 config; | 677 | u8 config, config_orig; |
| 678 | struct lm90_data *data = i2c_get_clientdata(client); | ||
| 650 | 679 | ||
| 651 | /* | 680 | /* |
| 652 | * Start the conversions. | 681 | * Start the conversions. |
| @@ -657,9 +686,20 @@ static void lm90_init_client(struct i2c_client *client) | |||
| 657 | dev_warn(&client->dev, "Initialization failed!\n"); | 686 | dev_warn(&client->dev, "Initialization failed!\n"); |
| 658 | return; | 687 | return; |
| 659 | } | 688 | } |
| 660 | if (config & 0x40) | 689 | config_orig = config; |
| 661 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, | 690 | |
| 662 | config & 0xBF); /* run */ | 691 | /* |
| 692 | * Put MAX6680/MAX8881 into extended resolution (bit 0x10, | ||
| 693 | * 0.125 degree resolution) and range (0x08, extend range | ||
| 694 | * to -64 degree) mode for the remote temperature sensor. | ||
| 695 | */ | ||
| 696 | if (data->kind == max6680) { | ||
| 697 | config |= 0x18; | ||
| 698 | } | ||
| 699 | |||
| 700 | config &= 0xBF; /* run */ | ||
| 701 | if (config != config_orig) /* Only write if changed */ | ||
| 702 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); | ||
| 663 | } | 703 | } |
| 664 | 704 | ||
| 665 | static int lm90_detach_client(struct i2c_client *client) | 705 | static int lm90_detach_client(struct i2c_client *client) |
