Commit 3d849981 authored by Jean Delvare's avatar Jean Delvare

hwmon: (adt7475) Add support for the ADT7490

Add support for the Analog Devices ADT7490 chip. This chip is largely
compatible with the ADT7473 and ADT7475, with additional features.
In particular, it has 6 voltage inputs instead of 2.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Jordan Crouse <jordan@cosmicpenguin.net>
Cc: "Darrick J. Wong" <djwong@us.ibm.com>
parent d656b6fd
...@@ -10,24 +10,31 @@ Supported chips: ...@@ -10,24 +10,31 @@ Supported chips:
Prefix: 'adt7475' Prefix: 'adt7475'
Addresses scanned: I2C 0x2E Addresses scanned: I2C 0x2E
Datasheet: Publicly available at the On Semiconductors website Datasheet: Publicly available at the On Semiconductors website
* Analog Devices ADT7490
Prefix: 'adt7490'
Addresses scanned: I2C 0x2C, 0x2D, 0x2E
Datasheet: Publicly available at the On Semiconductors website
Authors: Authors:
Jordan Crouse Jordan Crouse
Hans de Goede Hans de Goede
Darrick J. Wong (documentation) Darrick J. Wong (documentation)
Jean Delvare
Description Description
----------- -----------
This driver implements support for the Analog Devices ADT7473 and ADT7475 This driver implements support for the Analog Devices ADT7473, ADT7475 and
chip family. Both chips differ only in minor details. They will be ADT7490 chip family. The ADT7473 and ADT7475 differ only in minor details.
collectively designed by the name "ADT747x" in the rest of this document. The ADT7490 has additional features, including extra voltage measurement
inputs and PECI support. All the supported chips will be collectively
designed by the name "ADT747x" in the rest of this document.
The ADT747x uses the 2-wire interface compatible with the SMBus 2.0 The ADT747x uses the 2-wire interface compatible with the SMBus 2.0
specification. Using an analog to digital converter it measures three (3) specification. Using an analog to digital converter it measures three (3)
temperatures and two (2) voltages. It has four (4) 16-bit counters for temperatures and two (2) or more voltages. It has four (4) 16-bit counters
measuring fan speed. There are three (3) PWM outputs that can be used for measuring fan speed. There are three (3) PWM outputs that can be used
to control fan speed. to control fan speed.
A sophisticated control system for the PWM outputs is designed into the A sophisticated control system for the PWM outputs is designed into the
...@@ -45,6 +52,23 @@ The ADT747x samples all inputs continuously. The driver will not read ...@@ -45,6 +52,23 @@ The ADT747x samples all inputs continuously. The driver will not read
the registers more often than once every other second. Further, the registers more often than once every other second. Further,
configuration data is only read once per minute. configuration data is only read once per minute.
Chip Differences Summary
------------------------
ADT7473:
* 2 voltage inputs
* system acoustics optimizations (not implemented)
ADT7475:
* 2 voltage inputs
ADT7490:
* 6 voltage inputs
* 1 Imon input (not implemented)
* PECI support (not implemented)
* 2 GPIO pins (not implemented)
* system acoustics optimizations (not implemented)
Special Features Special Features
---------------- ----------------
......
...@@ -205,11 +205,11 @@ config SENSORS_ADT7473 ...@@ -205,11 +205,11 @@ config SENSORS_ADT7473
will be called adt7473. will be called adt7473.
config SENSORS_ADT7475 config SENSORS_ADT7475
tristate "Analog Devices ADT7473 and ADT7475" tristate "Analog Devices ADT7473, ADT7475 and ADT7490"
depends on I2C && EXPERIMENTAL depends on I2C && EXPERIMENTAL
help help
If you say yes here you get support for the Analog Devices If you say yes here you get support for the Analog Devices
ADT7473 and ADT7475 hardware monitoring chips. ADT7473, ADT7475 and ADT7490 hardware monitoring chips.
This driver can also be build as a module. If so, the module This driver can also be build as a module. If so, the module
will be called adt7475. will be called adt7475.
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* Copyright (C) 2007-2008, Advanced Micro Devices, Inc. * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
* Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net> * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
* Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com> * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
* Copyright (C) 2009 Jean Delvare <khali@linux-fr.org>
*
* Derived from the lm83 driver by Jean Delvare * Derived from the lm83 driver by Jean Delvare
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -39,6 +40,9 @@ ...@@ -39,6 +40,9 @@
/* 7475 Common Registers */ /* 7475 Common Registers */
#define REG_VTT 0x1E /* ADT7490 only */
#define REG_EXTEND3 0x1F /* ADT7490 only */
#define REG_VOLTAGE_BASE 0x20 #define REG_VOLTAGE_BASE 0x20
#define REG_TEMP_BASE 0x25 #define REG_TEMP_BASE 0x25
#define REG_TACH_BASE 0x28 #define REG_TACH_BASE 0x28
...@@ -79,6 +83,11 @@ ...@@ -79,6 +83,11 @@
#define REG_CONFIG5 0x7C #define REG_CONFIG5 0x7C
#define REG_CONFIG4 0x7D #define REG_CONFIG4 0x7D
#define REG_STATUS4 0x81 /* ADT7490 only */
#define REG_VTT_MIN 0x84 /* ADT7490 only */
#define REG_VTT_MAX 0x86 /* ADT7490 only */
#define CONFIG4_MAXDUTY 0x08 #define CONFIG4_MAXDUTY 0x08
#define CONFIG5_TWOSCOMP 0x01 #define CONFIG5_TWOSCOMP 0x01
...@@ -119,11 +128,12 @@ ...@@ -119,11 +128,12 @@
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
I2C_CLIENT_INSMOD_2(adt7473, adt7475); I2C_CLIENT_INSMOD_3(adt7473, adt7475, adt7490);
static const struct i2c_device_id adt7475_id[] = { static const struct i2c_device_id adt7475_id[] = {
{ "adt7473", adt7473 }, { "adt7473", adt7473 },
{ "adt7475", adt7475 }, { "adt7475", adt7475 },
{ "adt7490", adt7490 },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, adt7475_id); MODULE_DEVICE_TABLE(i2c, adt7475_id);
...@@ -139,7 +149,7 @@ struct adt7475_data { ...@@ -139,7 +149,7 @@ struct adt7475_data {
u8 config4; u8 config4;
u8 config5; u8 config5;
u8 has_voltage; u8 has_voltage;
u16 alarms; u32 alarms;
u16 voltage[3][6]; u16 voltage[3][6];
u16 temp[7][3]; u16 temp[7][3];
u16 tach[2][4]; u16 tach[2][4];
...@@ -306,10 +316,17 @@ static ssize_t set_voltage(struct device *dev, struct device_attribute *attr, ...@@ -306,10 +316,17 @@ static ssize_t set_voltage(struct device *dev, struct device_attribute *attr,
data->voltage[sattr->nr][sattr->index] = volt2reg(sattr->index, val); data->voltage[sattr->nr][sattr->index] = volt2reg(sattr->index, val);
if (sattr->nr == MIN) if (sattr->index < ADT7475_VOLTAGE_COUNT) {
reg = VOLTAGE_MIN_REG(sattr->index); if (sattr->nr == MIN)
else reg = VOLTAGE_MIN_REG(sattr->index);
reg = VOLTAGE_MAX_REG(sattr->index); else
reg = VOLTAGE_MAX_REG(sattr->index);
} else {
if (sattr->nr == MIN)
reg = REG_VTT_MIN;
else
reg = REG_VTT_MAX;
}
i2c_smbus_write_byte_data(client, reg, i2c_smbus_write_byte_data(client, reg,
data->voltage[sattr->nr][sattr->index] >> 2); data->voltage[sattr->nr][sattr->index] >> 2);
...@@ -818,6 +835,12 @@ static ssize_t set_pwm_at_crit(struct device *dev, ...@@ -818,6 +835,12 @@ static ssize_t set_pwm_at_crit(struct device *dev,
return count; return count;
} }
static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_voltage, NULL, INPUT, 0);
static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MAX, 0);
static SENSOR_DEVICE_ATTR_2(in0_min, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MIN, 0);
static SENSOR_DEVICE_ATTR_2(in0_alarm, S_IRUGO, show_voltage, NULL, ALARM, 0);
static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 1); static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 1);
static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage, static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MAX, 1); set_voltage, MAX, 1);
...@@ -830,6 +853,24 @@ static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage, ...@@ -830,6 +853,24 @@ static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage,
static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_voltage, static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MIN, 2); set_voltage, MIN, 2);
static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_voltage, NULL, ALARM, 2); static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_voltage, NULL, ALARM, 2);
static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, show_voltage, NULL, INPUT, 3);
static SENSOR_DEVICE_ATTR_2(in3_max, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MAX, 3);
static SENSOR_DEVICE_ATTR_2(in3_min, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MIN, 3);
static SENSOR_DEVICE_ATTR_2(in3_alarm, S_IRUGO, show_voltage, NULL, ALARM, 3);
static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, show_voltage, NULL, INPUT, 4);
static SENSOR_DEVICE_ATTR_2(in4_max, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MAX, 4);
static SENSOR_DEVICE_ATTR_2(in4_min, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MIN, 4);
static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, show_voltage, NULL, ALARM, 8);
static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO, show_voltage, NULL, INPUT, 5);
static SENSOR_DEVICE_ATTR_2(in5_max, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MAX, 5);
static SENSOR_DEVICE_ATTR_2(in5_min, S_IRUGO | S_IWUSR, show_voltage,
set_voltage, MIN, 5);
static SENSOR_DEVICE_ATTR_2(in5_alarm, S_IRUGO, show_voltage, NULL, ALARM, 31);
static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, INPUT, 0); static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, INPUT, 0);
static SENSOR_DEVICE_ATTR_2(temp1_alarm, S_IRUGO, show_temp, NULL, ALARM, 0); static SENSOR_DEVICE_ATTR_2(temp1_alarm, S_IRUGO, show_temp, NULL, ALARM, 0);
static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_temp, NULL, FAULT, 0); static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_temp, NULL, FAULT, 0);
...@@ -1009,7 +1050,29 @@ static struct attribute *adt7475_attrs[] = { ...@@ -1009,7 +1050,29 @@ static struct attribute *adt7475_attrs[] = {
NULL, NULL,
}; };
/* Attributes specific to the ADT7490 */
static struct attribute *adt7490_attrs[] = {
&sensor_dev_attr_in0_input.dev_attr.attr,
&sensor_dev_attr_in0_max.dev_attr.attr,
&sensor_dev_attr_in0_min.dev_attr.attr,
&sensor_dev_attr_in0_alarm.dev_attr.attr,
&sensor_dev_attr_in3_input.dev_attr.attr,
&sensor_dev_attr_in3_max.dev_attr.attr,
&sensor_dev_attr_in3_min.dev_attr.attr,
&sensor_dev_attr_in3_alarm.dev_attr.attr,
&sensor_dev_attr_in4_input.dev_attr.attr,
&sensor_dev_attr_in4_max.dev_attr.attr,
&sensor_dev_attr_in4_min.dev_attr.attr,
&sensor_dev_attr_in4_alarm.dev_attr.attr,
&sensor_dev_attr_in5_input.dev_attr.attr,
&sensor_dev_attr_in5_max.dev_attr.attr,
&sensor_dev_attr_in5_min.dev_attr.attr,
&sensor_dev_attr_in5_alarm.dev_attr.attr,
NULL
};
static struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs }; static struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs };
static struct attribute_group adt7490_attr_group = { .attrs = adt7490_attrs };
static int adt7475_detect(struct i2c_client *client, int kind, static int adt7475_detect(struct i2c_client *client, int kind,
struct i2c_board_info *info) struct i2c_board_info *info)
...@@ -1032,9 +1095,11 @@ static int adt7475_detect(struct i2c_client *client, int kind, ...@@ -1032,9 +1095,11 @@ static int adt7475_detect(struct i2c_client *client, int kind,
name = "adt7473"; name = "adt7473";
else if (devid == 0x75 && client->addr == 0x2e) else if (devid == 0x75 && client->addr == 0x2e)
name = "adt7475"; name = "adt7475";
else if ((devid2 & 0xfc) == 0x6c)
name = "adt7490";
else { else {
dev_dbg(&adapter->dev, dev_dbg(&adapter->dev,
"Couldn't detect an ADT7473 or ADT7475 part at " "Couldn't detect an ADT7473/75/90 part at "
"0x%02x\n", (unsigned int)client->addr); "0x%02x\n", (unsigned int)client->addr);
return -ENODEV; return -ENODEV;
} }
...@@ -1059,6 +1124,9 @@ static int adt7475_probe(struct i2c_client *client, ...@@ -1059,6 +1124,9 @@ static int adt7475_probe(struct i2c_client *client,
/* Initialize device-specific values */ /* Initialize device-specific values */
switch (id->driver_data) { switch (id->driver_data) {
case adt7490:
data->has_voltage = 0x3f; /* in0 to in5 */
break;
default: default:
data->has_voltage = 0x06; /* in1, in2 */ data->has_voltage = 0x06; /* in1, in2 */
} }
...@@ -1072,6 +1140,13 @@ static int adt7475_probe(struct i2c_client *client, ...@@ -1072,6 +1140,13 @@ static int adt7475_probe(struct i2c_client *client,
if (ret) if (ret)
goto efree; goto efree;
if (id->driver_data == adt7490) {
ret = sysfs_create_group(&client->dev.kobj,
&adt7490_attr_group);
if (ret)
goto eremove;
}
data->hwmon_dev = hwmon_device_register(&client->dev); data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
ret = PTR_ERR(data->hwmon_dev); ret = PTR_ERR(data->hwmon_dev);
...@@ -1082,6 +1157,8 @@ static int adt7475_probe(struct i2c_client *client, ...@@ -1082,6 +1157,8 @@ static int adt7475_probe(struct i2c_client *client,
eremove: eremove:
sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group); sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
if (data->has_voltage & 0x39)
sysfs_remove_group(&client->dev.kobj, &adt7490_attr_group);
efree: efree:
kfree(data); kfree(data);
return ret; return ret;
...@@ -1093,6 +1170,8 @@ static int adt7475_remove(struct i2c_client *client) ...@@ -1093,6 +1170,8 @@ static int adt7475_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group); sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
if (data->has_voltage & 0x39)
sysfs_remove_group(&client->dev.kobj, &adt7490_attr_group);
kfree(data); kfree(data);
return 0; return 0;
...@@ -1177,7 +1256,7 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) ...@@ -1177,7 +1256,7 @@ static struct adt7475_data *adt7475_update_device(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct adt7475_data *data = i2c_get_clientdata(client); struct adt7475_data *data = i2c_get_clientdata(client);
u8 ext; u16 ext;
int i; int i;
mutex_lock(&data->lock); mutex_lock(&data->lock);
...@@ -1188,7 +1267,8 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) ...@@ -1188,7 +1267,8 @@ static struct adt7475_data *adt7475_update_device(struct device *dev)
data->alarms = adt7475_read(REG_STATUS2) << 8; data->alarms = adt7475_read(REG_STATUS2) << 8;
data->alarms |= adt7475_read(REG_STATUS1); data->alarms |= adt7475_read(REG_STATUS1);
ext = adt7475_read(REG_EXTEND1); ext = (adt7475_read(REG_EXTEND2) << 8) |
adt7475_read(REG_EXTEND1);
for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) { for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) {
if (!(data->has_voltage & (1 << i))) if (!(data->has_voltage & (1 << i)))
continue; continue;
...@@ -1197,11 +1277,17 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) ...@@ -1197,11 +1277,17 @@ static struct adt7475_data *adt7475_update_device(struct device *dev)
((ext >> (i * 2)) & 3); ((ext >> (i * 2)) & 3);
} }
ext = adt7475_read(REG_EXTEND2);
for (i = 0; i < ADT7475_TEMP_COUNT; i++) for (i = 0; i < ADT7475_TEMP_COUNT; i++)
data->temp[INPUT][i] = data->temp[INPUT][i] =
(adt7475_read(TEMP_REG(i)) << 2) | (adt7475_read(TEMP_REG(i)) << 2) |
((ext >> ((i + 1) * 2)) & 3); ((ext >> ((i + 5) * 2)) & 3);
if (data->has_voltage & (1 << 5)) {
data->alarms |= adt7475_read(REG_STATUS4) << 24;
ext = adt7475_read(REG_EXTEND3);
data->voltage[INPUT][5] = adt7475_read(REG_VTT) << 2 |
((ext >> 4) & 3);
}
for (i = 0; i < ADT7475_TACH_COUNT; i++) for (i = 0; i < ADT7475_TACH_COUNT; i++)
data->tach[INPUT][i] = data->tach[INPUT][i] =
...@@ -1230,6 +1316,11 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) ...@@ -1230,6 +1316,11 @@ static struct adt7475_data *adt7475_update_device(struct device *dev)
adt7475_read(VOLTAGE_MAX_REG(i)) << 2; adt7475_read(VOLTAGE_MAX_REG(i)) << 2;
} }
if (data->has_voltage & (1 << 5)) {
data->voltage[MIN][5] = adt7475_read(REG_VTT_MIN) << 2;
data->voltage[MAX][5] = adt7475_read(REG_VTT_MAX) << 2;
}
for (i = 0; i < ADT7475_TEMP_COUNT; i++) { for (i = 0; i < ADT7475_TEMP_COUNT; i++) {
/* Adjust values so they match the input precision */ /* Adjust values so they match the input precision */
data->temp[MIN][i] = data->temp[MIN][i] =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment