aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1025.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm1025.c')
-rw-r--r--drivers/hwmon/adm1025.c73
1 files changed, 20 insertions, 53 deletions
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index 4db04d603ec9..db6ac2b04f6f 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -2,7 +2,7 @@
2 * adm1025.c 2 * adm1025.c
3 * 3 *
4 * Copyright (C) 2000 Chen-Yuan Wu <gwu@esoft.com> 4 * Copyright (C) 2000 Chen-Yuan Wu <gwu@esoft.com>
5 * Copyright (C) 2003-2008 Jean Delvare <khali@linux-fr.org> 5 * Copyright (C) 2003-2009 Jean Delvare <khali@linux-fr.org>
6 * 6 *
7 * The ADM1025 is a sensor chip made by Analog Devices. It reports up to 6 7 * The ADM1025 is a sensor chip made by Analog Devices. It reports up to 6
8 * voltages (including its own power source) and up to two temperatures 8 * voltages (including its own power source) and up to two temperatures
@@ -413,67 +413,34 @@ static int adm1025_detect(struct i2c_client *client, int kind,
413 struct i2c_board_info *info) 413 struct i2c_board_info *info)
414{ 414{
415 struct i2c_adapter *adapter = client->adapter; 415 struct i2c_adapter *adapter = client->adapter;
416 const char *name = ""; 416 const char *name;
417 u8 config; 417 u8 man_id, chip_id;
418 418
419 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 419 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
420 return -ENODEV; 420 return -ENODEV;
421 421
422 /* 422 /* Check for unused bits */
423 * Now we do the remaining detection. A negative kind means that 423 if ((i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG) & 0x80)
424 * the driver was loaded with no force parameter (default), so we 424 || (i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS1) & 0xC0)
425 * must both detect and identify the chip. A zero kind means that 425 || (i2c_smbus_read_byte_data(client, ADM1025_REG_STATUS2) & 0xBC)) {
426 * the driver was loaded with the force parameter, the detection 426 dev_dbg(&adapter->dev, "ADM1025 detection failed at 0x%02x\n",
427 * step shall be skipped. A positive kind means that the driver 427 client->addr);
428 * was loaded with the force parameter and a given kind of chip is 428 return -ENODEV;
429 * requested, so both the detection and the identification steps
430 * are skipped.
431 */
432 config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
433 if (kind < 0) { /* detection */
434 if ((config & 0x80) != 0x00
435 || (i2c_smbus_read_byte_data(client,
436 ADM1025_REG_STATUS1) & 0xC0) != 0x00
437 || (i2c_smbus_read_byte_data(client,
438 ADM1025_REG_STATUS2) & 0xBC) != 0x00) {
439 dev_dbg(&adapter->dev,
440 "ADM1025 detection failed at 0x%02x.\n",
441 client->addr);
442 return -ENODEV;
443 }
444 } 429 }
445 430
446 if (kind <= 0) { /* identification */ 431 /* Identification */
447 u8 man_id, chip_id; 432 chip_id = i2c_smbus_read_byte_data(client, ADM1025_REG_CHIP_ID);
448 433 if ((chip_id & 0xF0) != 0x20)
449 man_id = i2c_smbus_read_byte_data(client, ADM1025_REG_MAN_ID); 434 return -ENODEV;
450 chip_id = i2c_smbus_read_byte_data(client, ADM1025_REG_CHIP_ID);
451
452 if (man_id == 0x41) { /* Analog Devices */
453 if ((chip_id & 0xF0) == 0x20) { /* ADM1025/ADM1025A */
454 kind = adm1025;
455 }
456 } else
457 if (man_id == 0xA1) { /* Philips */
458 if (client->addr != 0x2E
459 && (chip_id & 0xF0) == 0x20) { /* NE1619 */
460 kind = ne1619;
461 }
462 }
463
464 if (kind <= 0) { /* identification failed */
465 dev_info(&adapter->dev,
466 "Unsupported chip (man_id=0x%02X, "
467 "chip_id=0x%02X).\n", man_id, chip_id);
468 return -ENODEV;
469 }
470 }
471 435
472 if (kind == adm1025) { 436 man_id = i2c_smbus_read_byte_data(client, ADM1025_REG_MAN_ID);
437 if (man_id == 0x41)
473 name = "adm1025"; 438 name = "adm1025";
474 } else if (kind == ne1619) { 439 else if (man_id == 0xA1 && client->addr != 0x2E)
475 name = "ne1619"; 440 name = "ne1619";
476 } 441 else
442 return -ENODEV;
443
477 strlcpy(info->type, name, I2C_NAME_SIZE); 444 strlcpy(info->type, name, I2C_NAME_SIZE);
478 445
479 return 0; 446 return 0;