aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm95245.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2014-04-22 11:48:57 -0400
committerGuenter Roeck <linux@roeck-us.net>2014-12-02 06:44:18 -0500
commit162a8dfe73df95e59265e350b2f247b8b35490d1 (patch)
treef51150255441f8c6b9f65c28cf6e725e7c1fe2c6 /drivers/hwmon/lm95245.c
parentf975b3399c0a35439c48b89d1afffc4d86276d0f (diff)
hwmon: (lm95245) Add support for LM95235
LM95235 is register compatible to LM95245. Also update link to LM95245 data sheet, and drop the link to the datasheet from the driver source to simplify code maintenance. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/lm95245.c')
-rw-r--r--drivers/hwmon/lm95245.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/hwmon/lm95245.c b/drivers/hwmon/lm95245.c
index 0ae0dfdafdff..e7aef4561c83 100644
--- a/drivers/hwmon/lm95245.c
+++ b/drivers/hwmon/lm95245.c
@@ -1,10 +1,8 @@
1/* 1/*
2 * Copyright (C) 2011 Alexander Stein <alexander.stein@systec-electronic.com> 2 * Copyright (C) 2011 Alexander Stein <alexander.stein@systec-electronic.com>
3 * 3 *
4 * The LM95245 is a sensor chip made by National Semiconductors. 4 * The LM95245 is a sensor chip made by TI / National Semiconductor.
5 * It reports up to two temperatures (its own plus an external one). 5 * It reports up to two temperatures (its own plus an external one).
6 * Complete datasheet can be obtained from National's website at:
7 * http://www.national.com/ds.cgi/LM/LM95245.pdf
8 * 6 *
9 * This driver is based on lm95241.c 7 * This driver is based on lm95241.c
10 * 8 *
@@ -34,8 +32,6 @@
34#include <linux/mutex.h> 32#include <linux/mutex.h>
35#include <linux/sysfs.h> 33#include <linux/sysfs.h>
36 34
37#define DEVNAME "lm95245"
38
39static const unsigned short normal_i2c[] = { 35static const unsigned short normal_i2c[] = {
40 0x18, 0x19, 0x29, 0x4c, 0x4d, I2C_CLIENT_END }; 36 0x18, 0x19, 0x29, 0x4c, 0x4d, I2C_CLIENT_END };
41 37
@@ -98,7 +94,8 @@ static const unsigned short normal_i2c[] = {
98#define STATUS1_LOC 0x01 94#define STATUS1_LOC 0x01
99 95
100#define MANUFACTURER_ID 0x01 96#define MANUFACTURER_ID 0x01
101#define DEFAULT_REVISION 0xB3 97#define LM95235_REVISION 0xB1
98#define LM95245_REVISION 0xB3
102 99
103static const u8 lm95245_reg_address[] = { 100static const u8 lm95245_reg_address[] = {
104 LM95245_REG_R_LOCAL_TEMPH_S, 101 LM95245_REG_R_LOCAL_TEMPH_S,
@@ -427,17 +424,32 @@ static int lm95245_detect(struct i2c_client *new_client,
427 struct i2c_board_info *info) 424 struct i2c_board_info *info)
428{ 425{
429 struct i2c_adapter *adapter = new_client->adapter; 426 struct i2c_adapter *adapter = new_client->adapter;
427 int address = new_client->addr;
428 const char *name;
429 int rev, id;
430 430
431 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 431 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
432 return -ENODEV; 432 return -ENODEV;
433 433
434 if (i2c_smbus_read_byte_data(new_client, LM95245_REG_R_MAN_ID) 434 id = i2c_smbus_read_byte_data(new_client, LM95245_REG_R_MAN_ID);
435 != MANUFACTURER_ID 435 if (id != MANUFACTURER_ID)
436 || i2c_smbus_read_byte_data(new_client, LM95245_REG_R_CHIP_ID)
437 != DEFAULT_REVISION)
438 return -ENODEV; 436 return -ENODEV;
439 437
440 strlcpy(info->type, DEVNAME, I2C_NAME_SIZE); 438 rev = i2c_smbus_read_byte_data(new_client, LM95245_REG_R_CHIP_ID);
439 switch (rev) {
440 case LM95235_REVISION:
441 if (address != 0x18 && address != 0x29 && address != 0x4c)
442 return -ENODEV;
443 name = "lm95235";
444 break;
445 case LM95245_REVISION:
446 name = "lm95245";
447 break;
448 default:
449 return -ENODEV;
450 }
451
452 strlcpy(info->type, name, I2C_NAME_SIZE);
441 return 0; 453 return 0;
442} 454}
443 455
@@ -484,7 +496,8 @@ static int lm95245_probe(struct i2c_client *client,
484 496
485/* Driver data (common to all clients) */ 497/* Driver data (common to all clients) */
486static const struct i2c_device_id lm95245_id[] = { 498static const struct i2c_device_id lm95245_id[] = {
487 { DEVNAME, 0 }, 499 { "lm95235", 0 },
500 { "lm95245", 0 },
488 { } 501 { }
489}; 502};
490MODULE_DEVICE_TABLE(i2c, lm95245_id); 503MODULE_DEVICE_TABLE(i2c, lm95245_id);
@@ -492,7 +505,7 @@ MODULE_DEVICE_TABLE(i2c, lm95245_id);
492static struct i2c_driver lm95245_driver = { 505static struct i2c_driver lm95245_driver = {
493 .class = I2C_CLASS_HWMON, 506 .class = I2C_CLASS_HWMON,
494 .driver = { 507 .driver = {
495 .name = DEVNAME, 508 .name = "lm95245",
496 }, 509 },
497 .probe = lm95245_probe, 510 .probe = lm95245_probe,
498 .id_table = lm95245_id, 511 .id_table = lm95245_id,
@@ -503,5 +516,5 @@ static struct i2c_driver lm95245_driver = {
503module_i2c_driver(lm95245_driver); 516module_i2c_driver(lm95245_driver);
504 517
505MODULE_AUTHOR("Alexander Stein <alexander.stein@systec-electronic.com>"); 518MODULE_AUTHOR("Alexander Stein <alexander.stein@systec-electronic.com>");
506MODULE_DESCRIPTION("LM95245 sensor driver"); 519MODULE_DESCRIPTION("LM95235/LM95245 sensor driver");
507MODULE_LICENSE("GPL"); 520MODULE_LICENSE("GPL");