diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-07-05 16:31:48 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-07-28 03:17:35 -0400 |
commit | 8c1d04192e2ef1e6d38e9d5e9c500e5330d20339 (patch) | |
tree | 06bd055abad6db6660f7a52bc03a6086a8f15391 /drivers | |
parent | fffd80ccc1e6c7e5f13741e17a7d80582ae21fcc (diff) |
hwmon: (lm95241) Add support for LM95231
LM95231 is fully compatible to LM95241; only necessary change is to add
chip detection.
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/Kconfig | 5 | ||||
-rw-r--r-- | drivers/hwmon/lm95241.c | 31 |
2 files changed, 22 insertions, 14 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 166889b326ff..38c2adba8381 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -694,10 +694,11 @@ config SENSORS_LTC4261 | |||
694 | be called ltc4261. | 694 | be called ltc4261. |
695 | 695 | ||
696 | config SENSORS_LM95241 | 696 | config SENSORS_LM95241 |
697 | tristate "National Semiconductor LM95241 sensor chip" | 697 | tristate "National Semiconductor LM95241 and compatibles" |
698 | depends on I2C | 698 | depends on I2C |
699 | help | 699 | help |
700 | If you say yes here you get support for LM95241 sensor chip. | 700 | If you say yes here you get support for LM95231 and LM95241 sensor |
701 | chips. | ||
701 | 702 | ||
702 | This driver can also be built as a module. If so, the module | 703 | This driver can also be built as a module. If so, the module |
703 | will be called lm95241. | 704 | will be called lm95241. |
diff --git a/drivers/hwmon/lm95241.c b/drivers/hwmon/lm95241.c index d3b464b74ced..513901d592a9 100644 --- a/drivers/hwmon/lm95241.c +++ b/drivers/hwmon/lm95241.c | |||
@@ -74,8 +74,9 @@ static const unsigned short normal_i2c[] = { | |||
74 | #define TT_OFF 0 | 74 | #define TT_OFF 0 |
75 | #define TT_ON 1 | 75 | #define TT_ON 1 |
76 | #define TT_MASK 7 | 76 | #define TT_MASK 7 |
77 | #define MANUFACTURER_ID 0x01 | 77 | #define NATSEMI_MAN_ID 0x01 |
78 | #define DEFAULT_REVISION 0xA4 | 78 | #define LM95231_CHIP_ID 0xA1 |
79 | #define LM95241_CHIP_ID 0xA4 | ||
79 | 80 | ||
80 | static const u8 lm95241_reg_address[] = { | 81 | static const u8 lm95241_reg_address[] = { |
81 | LM95241_REG_R_LOCAL_TEMPH, | 82 | LM95241_REG_R_LOCAL_TEMPH, |
@@ -338,20 +339,25 @@ static int lm95241_detect(struct i2c_client *new_client, | |||
338 | struct i2c_board_info *info) | 339 | struct i2c_board_info *info) |
339 | { | 340 | { |
340 | struct i2c_adapter *adapter = new_client->adapter; | 341 | struct i2c_adapter *adapter = new_client->adapter; |
341 | int address = new_client->addr; | ||
342 | const char *name; | 342 | const char *name; |
343 | int mfg_id, chip_id; | ||
343 | 344 | ||
344 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 345 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
345 | return -ENODEV; | 346 | return -ENODEV; |
346 | 347 | ||
347 | if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) | 348 | mfg_id = i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID); |
348 | == MANUFACTURER_ID) | 349 | if (mfg_id != NATSEMI_MAN_ID) |
349 | && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) | 350 | return -ENODEV; |
350 | == DEFAULT_REVISION)) { | 351 | |
351 | name = DEVNAME; | 352 | chip_id = i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID); |
352 | } else { | 353 | switch (chip_id) { |
353 | dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n", | 354 | case LM95231_CHIP_ID: |
354 | address); | 355 | name = "lm95231"; |
356 | break; | ||
357 | case LM95241_CHIP_ID: | ||
358 | name = "lm95241"; | ||
359 | break; | ||
360 | default: | ||
355 | return -ENODEV; | 361 | return -ENODEV; |
356 | } | 362 | } |
357 | 363 | ||
@@ -431,7 +437,8 @@ static int lm95241_remove(struct i2c_client *client) | |||
431 | 437 | ||
432 | /* Driver data (common to all clients) */ | 438 | /* Driver data (common to all clients) */ |
433 | static const struct i2c_device_id lm95241_id[] = { | 439 | static const struct i2c_device_id lm95241_id[] = { |
434 | { DEVNAME, 0 }, | 440 | { "lm95231", 0 }, |
441 | { "lm95241", 0 }, | ||
435 | { } | 442 | { } |
436 | }; | 443 | }; |
437 | MODULE_DEVICE_TABLE(i2c, lm95241_id); | 444 | MODULE_DEVICE_TABLE(i2c, lm95241_id); |