Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+39 -21
+9 -5
Documentation/hwmon/lm95245
··· 2 2 ================== 3 3 4 4 Supported chips: 5 - * National Semiconductor LM95245 5 + * TI LM95235 6 + Addresses scanned: I2C 0x18, 0x29, 0x4c 7 + Datasheet: Publicly available at the TI website 8 + http://www.ti.com/lit/ds/symlink/lm95235.pdf 9 + * TI / National Semiconductor LM95245 6 10 Addresses scanned: I2C 0x18, 0x19, 0x29, 0x4c, 0x4d 7 - Datasheet: Publicly available at the National Semiconductor website 8 - http://www.national.com/mpf/LM/LM95245.html 11 + Datasheet: Publicly available at the TI website 12 + http://www.ti.com/lit/ds/symlink/lm95245.pdf 9 13 10 14 11 15 Author: Alexander Stein <alexander.stein@systec-electronic.com> ··· 17 13 Description 18 14 ----------- 19 15 20 - The LM95245 is an 11-bit digital temperature sensor with a 2-wire System 16 + LM95235 and LM95245 are 11-bit digital temperature sensors with a 2-wire System 21 17 Management Bus (SMBus) interface and TruTherm technology that can monitor 22 18 the temperature of a remote diode as well as its own temperature. 23 - The LM95245 can be used to very accurately monitor the temperature of 19 + The chips can be used to very accurately monitor the temperature of 24 20 external devices such as microprocessors. 25 21 26 22 All temperature values are given in millidegrees Celsius. Local temperature
+3 -2
drivers/hwmon/Kconfig
··· 1048 1048 will be called lm95241. 1049 1049 1050 1050 config SENSORS_LM95245 1051 - tristate "National Semiconductor LM95245 sensor chip" 1051 + tristate "National Semiconductor LM95245 and compatibles" 1052 1052 depends on I2C 1053 1053 help 1054 - If you say yes here you get support for LM95245 sensor chip. 1054 + If you say yes here you get support for LM95235 and LM95245 1055 + temperature sensor chips. 1055 1056 1056 1057 This driver can also be built as a module. If so, the module 1057 1058 will be called lm95245.
+27 -14
drivers/hwmon/lm95245.c
··· 1 1 /* 2 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 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 7 * This driver is based on lm95241.c 10 8 * ··· 31 33 #include <linux/err.h> 32 34 #include <linux/mutex.h> 33 35 #include <linux/sysfs.h> 34 - 35 - #define DEVNAME "lm95245" 36 36 37 37 static const unsigned short normal_i2c[] = { 38 38 0x18, 0x19, 0x29, 0x4c, 0x4d, I2C_CLIENT_END }; ··· 94 98 #define STATUS1_LOC 0x01 95 99 96 100 #define MANUFACTURER_ID 0x01 97 - #define DEFAULT_REVISION 0xB3 101 + #define LM95235_REVISION 0xB1 102 + #define LM95245_REVISION 0xB3 98 103 99 104 static const u8 lm95245_reg_address[] = { 100 105 LM95245_REG_R_LOCAL_TEMPH_S, ··· 424 427 struct i2c_board_info *info) 425 428 { 426 429 struct i2c_adapter *adapter = new_client->adapter; 430 + int address = new_client->addr; 431 + const char *name; 432 + int rev, id; 427 433 428 434 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 429 435 return -ENODEV; 430 436 431 - if (i2c_smbus_read_byte_data(new_client, LM95245_REG_R_MAN_ID) 432 - != MANUFACTURER_ID 433 - || i2c_smbus_read_byte_data(new_client, LM95245_REG_R_CHIP_ID) 434 - != DEFAULT_REVISION) 437 + id = i2c_smbus_read_byte_data(new_client, LM95245_REG_R_MAN_ID); 438 + if (id != MANUFACTURER_ID) 435 439 return -ENODEV; 436 440 437 - strlcpy(info->type, DEVNAME, I2C_NAME_SIZE); 441 + rev = i2c_smbus_read_byte_data(new_client, LM95245_REG_R_CHIP_ID); 442 + switch (rev) { 443 + case LM95235_REVISION: 444 + if (address != 0x18 && address != 0x29 && address != 0x4c) 445 + return -ENODEV; 446 + name = "lm95235"; 447 + break; 448 + case LM95245_REVISION: 449 + name = "lm95245"; 450 + break; 451 + default: 452 + return -ENODEV; 453 + } 454 + 455 + strlcpy(info->type, name, I2C_NAME_SIZE); 438 456 return 0; 439 457 } 440 458 ··· 496 484 497 485 /* Driver data (common to all clients) */ 498 486 static const struct i2c_device_id lm95245_id[] = { 499 - { DEVNAME, 0 }, 487 + { "lm95235", 0 }, 488 + { "lm95245", 0 }, 500 489 { } 501 490 }; 502 491 MODULE_DEVICE_TABLE(i2c, lm95245_id); ··· 505 492 static struct i2c_driver lm95245_driver = { 506 493 .class = I2C_CLASS_HWMON, 507 494 .driver = { 508 - .name = DEVNAME, 495 + .name = "lm95245", 509 496 }, 510 497 .probe = lm95245_probe, 511 498 .id_table = lm95245_id, ··· 516 503 module_i2c_driver(lm95245_driver); 517 504 518 505 MODULE_AUTHOR("Alexander Stein <alexander.stein@systec-electronic.com>"); 519 - MODULE_DESCRIPTION("LM95245 sensor driver"); 506 + MODULE_DESCRIPTION("LM95235/LM95245 sensor driver"); 520 507 MODULE_LICENSE("GPL");