aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/Kconfig4
-rw-r--r--drivers/hwmon/lm87.c25
2 files changed, 21 insertions, 8 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index a2187df5cc78..af43d566d770 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -433,12 +433,12 @@ config SENSORS_LM85
433 will be called lm85. 433 will be called lm85.
434 434
435config SENSORS_LM87 435config SENSORS_LM87
436 tristate "National Semiconductor LM87" 436 tristate "National Semiconductor LM87 and compatibles"
437 depends on I2C 437 depends on I2C
438 select HWMON_VID 438 select HWMON_VID
439 help 439 help
440 If you say yes here you get support for National Semiconductor LM87 440 If you say yes here you get support for National Semiconductor LM87
441 sensor chips. 441 and Analog Devices ADM1024 sensor chips.
442 442
443 This driver can also be built as a module. If so, the module 443 This driver can also be built as a module. If so, the module
444 will be called lm87. 444 will be called lm87.
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index 28cdff0c556b..3ab4c3f0efdd 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -5,7 +5,7 @@
5 * Philip Edelbrock <phil@netroedge.com> 5 * Philip Edelbrock <phil@netroedge.com>
6 * Stephen Rousset <stephen.rousset@rocketlogix.com> 6 * Stephen Rousset <stephen.rousset@rocketlogix.com>
7 * Dan Eaton <dan.eaton@rocketlogix.com> 7 * Dan Eaton <dan.eaton@rocketlogix.com>
8 * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> 8 * Copyright (C) 2004,2007 Jean Delvare <khali@linux-fr.org>
9 * 9 *
10 * Original port to Linux 2.6 by Jeff Oliver. 10 * Original port to Linux 2.6 by Jeff Oliver.
11 * 11 *
@@ -37,6 +37,11 @@
37 * instead. The LM87 is the only hardware monitoring chipset I know of 37 * instead. The LM87 is the only hardware monitoring chipset I know of
38 * which uses amplitude modulation. Be careful when using this feature. 38 * which uses amplitude modulation. Be careful when using this feature.
39 * 39 *
40 * This driver also supports the ADM1024, a sensor chip made by Analog
41 * Devices. That chip is fully compatible with the LM87. Complete
42 * datasheet can be obtained from Analog's website at:
43 * http://www.analog.com/en/prod/0,2877,ADM1024,00.html
44 *
40 * This program is free software; you can redistribute it and/or modify 45 * This program is free software; you can redistribute it and/or modify
41 * it under the terms of the GNU General Public License as published by 46 * it under the terms of the GNU General Public License as published by
42 * the Free Software Foundation; either version 2 of the License, or 47 * the Free Software Foundation; either version 2 of the License, or
@@ -74,7 +79,7 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
74 * Insmod parameters 79 * Insmod parameters
75 */ 80 */
76 81
77I2C_CLIENT_INSMOD_1(lm87); 82I2C_CLIENT_INSMOD_2(lm87, adm1024);
78 83
79/* 84/*
80 * The LM87 registers 85 * The LM87 registers
@@ -662,6 +667,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
662 struct i2c_client *new_client; 667 struct i2c_client *new_client;
663 struct lm87_data *data; 668 struct lm87_data *data;
664 int err = 0; 669 int err = 0;
670 static const char *names[] = { "lm87", "adm1024" };
665 671
666 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 672 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
667 goto exit; 673 goto exit;
@@ -686,11 +692,18 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
686 692
687 /* Now, we do the remaining detection. */ 693 /* Now, we do the remaining detection. */
688 if (kind < 0) { 694 if (kind < 0) {
695 u8 cid = lm87_read_value(new_client, LM87_REG_COMPANY_ID);
689 u8 rev = lm87_read_value(new_client, LM87_REG_REVISION); 696 u8 rev = lm87_read_value(new_client, LM87_REG_REVISION);
690 697
691 if (rev < 0x01 || rev > 0x08 698 if (cid == 0x02 /* National Semiconductor */
692 || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80) 699 && (rev >= 0x01 && rev <= 0x08))
693 || lm87_read_value(new_client, LM87_REG_COMPANY_ID) != 0x02) { 700 kind = lm87;
701 else if (cid == 0x41 /* Analog Devices */
702 && (rev & 0xf0) == 0x10)
703 kind = adm1024;
704
705 if (kind < 0
706 || (lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80)) {
694 dev_dbg(&adapter->dev, 707 dev_dbg(&adapter->dev,
695 "LM87 detection failed at 0x%02x.\n", 708 "LM87 detection failed at 0x%02x.\n",
696 address); 709 address);
@@ -699,7 +712,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
699 } 712 }
700 713
701 /* We can fill in the remaining client fields */ 714 /* We can fill in the remaining client fields */
702 strlcpy(new_client->name, "lm87", I2C_NAME_SIZE); 715 strlcpy(new_client->name, names[kind - 1], I2C_NAME_SIZE);
703 data->valid = 0; 716 data->valid = 0;
704 mutex_init(&data->update_lock); 717 mutex_init(&data->update_lock);
705 718