Skip to contentSkip to conversation

adt7473: New driver for Analog Devices ADT7473 sensor chip

PATCH Superseded Darrick J. Wong 3 participants 10 messages Dec 19, 2007 – Feb 19, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 adt7473: New driver for Analog Devices ADT7473 sensor chip

This driver reports voltage, temperature and fan sensor readings on an ADT7473 chip. The ADT7467 chip seems to share some registers with this one, so it may be possible to add support for it, though the therm_adt746x driver seems to cover it ok on a PPC Mac.

---

 drivers/hwmon/Kconfig   |   10 
 drivers/hwmon/Makefile  |    1 
 drivers/hwmon/adt7473.c | 1164 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1175 insertions(+), 0 deletions(-)
drivers/hwmon/Kconfig +10 -0
index af43d56..7ee4893 100644
@@ -143,6 +143,16 @@ config SENSORS_ADT7470
 	  This driver can also be built as a module. If so, the module
 	  will be called adt7470.
 
+config SENSORS_ADT7473
+	tristate "Analog Devices ADT7473"
+	depends on I2C && EXPERIMENTAL
+	help
+	  If you say yes here you get support for the Analog Devices
+	  ADT7473 temperature monitoring chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called adt7473.
+
 config SENSORS_K8TEMP
 	tristate "AMD Athlon64/FX or Opteron temperature sensor"
 	depends on X86 && PCI && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
index 77a3e09..802f6b3 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_SENSORS_ADM1029)	+= adm1029.o
 obj-$(CONFIG_SENSORS_ADM1031)	+= adm1031.o
 obj-$(CONFIG_SENSORS_ADM9240)	+= adm9240.o
 obj-$(CONFIG_SENSORS_ADT7470)	+= adt7470.o
+obj-$(CONFIG_SENSORS_ADT7473)	+= adt7473.o
 obj-$(CONFIG_SENSORS_APPLESMC)	+= applesmc.o
 obj-$(CONFIG_SENSORS_AMS)	+= ams/
 obj-$(CONFIG_SENSORS_ATXP1)	+= atxp1.o
drivers/hwmon/adt7473.c new file +1163 -0

1,163 lines not on this page · raw message

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw

Re: [lm-sensors] [PATCH] adt7473: New driver for Analog Devices

Hi Darrick,

Quoted 6 lines · Darrick J. Wong

This driver reports voltage, temperature and fan sensor readings on an ADT7473 chip. The ADT7467 chip seems to share some registers with this one, so it may be possible to add support for it, though the therm_adt746x driver seems to cover it ok on a PPC Mac.

I've updated the ADT7473 entry on wiki/Devices to point to this post.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw

This driver also had that funny alarm1/alarm2 thing; here's a revision of yesterday's patch with that straightened out.
---
This driver reports voltage, temperature and fan sensor readings on an ADT7473 chip.

---

 drivers/hwmon/Kconfig   |   10 
 drivers/hwmon/Makefile  |    1 
 drivers/hwmon/adt7473.c | 1161 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1172 insertions(+), 0 deletions(-)
drivers/hwmon/Kconfig +10 -0
index af43d56..7ee4893 100644
@@ -143,6 +143,16 @@ config SENSORS_ADT7470
 	  This driver can also be built as a module. If so, the module
 	  will be called adt7470.
 
+config SENSORS_ADT7473
+	tristate "Analog Devices ADT7473"
+	depends on I2C && EXPERIMENTAL
+	help
+	  If you say yes here you get support for the Analog Devices
+	  ADT7473 temperature monitoring chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called adt7473.
+
 config SENSORS_K8TEMP
 	tristate "AMD Athlon64/FX or Opteron temperature sensor"
 	depends on X86 && PCI && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
index 77a3e09..802f6b3 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_SENSORS_ADM1029)	+= adm1029.o
 obj-$(CONFIG_SENSORS_ADM1031)	+= adm1031.o
 obj-$(CONFIG_SENSORS_ADM9240)	+= adm9240.o
 obj-$(CONFIG_SENSORS_ADT7470)	+= adt7470.o
+obj-$(CONFIG_SENSORS_ADT7473)	+= adt7473.o
 obj-$(CONFIG_SENSORS_APPLESMC)	+= applesmc.o
 obj-$(CONFIG_SENSORS_AMS)	+= ams/
 obj-$(CONFIG_SENSORS_ATXP1)	+= atxp1.o
drivers/hwmon/adt7473.c new file +1160 -0

1,160 lines not on this page · raw message

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw

Hi Darrick:

Sorry this took forever for me to review. Just a few little things...

Quoted 6 lines · Darrick J. Wong

This driver also had that funny alarm1/alarm2 thing; here's a revision of yesterday's patch with that straightened out.
---
This driver reports voltage, temperature and fan sensor readings on an ADT7473 chip.

Quoted 8 lines

---

 drivers/hwmon/Kconfig   |   10 
 drivers/hwmon/Makefile  |    1 
 drivers/hwmon/adt7473.c | 1161 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1172 insertions(+), 0 deletions(-)

Documentation/hwmon/adt7473 would be nice.

Quoted 5 lines

new file mode 100644
index 0000000..5528d5c

drivers/hwmon/adt7473.c new file +0 -0
@@ -0,0 +1,1161 @@

(snip)

drivers/hwmon/adt7473.c line 327

Quoted 8 lines
drivers/hwmon/adt7473.c new file +8 -0
+/*
+ * On this chip, voltages are given as a count of steps between a minimum
+ * and maximum voltage, not a direct voltage.
+ */
+static int volt_convert_table[][2] = {
+	{2997, 3},
+	{4395, 4},
+};

That should be const.

(snip)

Quoted 12 lines
drivers/hwmon/adt7473.c new file +12 -0
+static ssize_t show_pwm_auto_temp(struct device *dev,
+				  struct device_attribute *devattr,
+				  char *buf)
+{
+	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+	struct adt7473_data *data = adt7473_update_device(dev);
+	int bhvr = data->pwm_behavior[attr->index] >> ADT7473_PWM_BHVR_SHIFT;
+
+	switch (bhvr) {
+	case 3:
+	case 4:
+	case 7:

drivers/hwmon/adt7473.c line 805

Quoted 10 lines
drivers/hwmon/adt7473.c new file +10 -0
+		return sprintf(buf, "0\n");
+	case 0:
+	case 1:
+	case 5:
+	case 6:
+		return sprintf(buf, "%d\n", bhvr + 1);
+	case 2:
+		return sprintf(buf, "4\n");
+	}
+	BUG();

Given ADT7473_PWM_BHVR_SHIFT is 5, this BUG() is obviously impossible. But I guess it's not obvious to GCC.

(snip)

drivers/hwmon/adt7473.c line 1047

Quoted 9 lines
drivers/hwmon/adt7473.c new file +9 -0
+static int adt7473_attach_adapter(struct i2c_adapter *adapter)
+{
+	/*
+	 * Some NVIDIA cards have an adt7473 attached to the on-board
+	 * i2c controller, but the i2c adapter driver in the binary
+	 * nvidia superblob driver sets class to 0.
+	 */
+	if (!(adapter->class & I2C_CLASS_HWMON) && adapter->class)
+		return 0;

NACK on that comment and associated code: Jean Delvare submitted a patch to NVIDIA over two years ago to fix their bug. Apparently some distros even carry his patch. So, I don't want to encourage such a hack to persist. Please just do the standard check here.

drivers/hwmon/adt7473.c line 1049

Quoted 2 lines
drivers/hwmon/adt7473.c new file +2 -0
+	return i2c_probe(adapter, &addr_data, adt7473_detect);
+}

(snip)

Thanks & regards,

Signature · 8 lines
Mark M. Hoffman
[email protected]


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author Applied
#4 lore raw
Quoted 1 line · Mark M. Hoffman

Documentation/hwmon/adt7473 would be nice.

Ok, I'll generate one.

Quoted 1 line

That should be const.

Applied.

Quoted 4 lines

drivers/hwmon/adt7473.c line 805

Quoted 1 line
drivers/hwmon/adt7473.c new file +1 -0
+	BUG();

Given ADT7473_PWM_BHVR_SHIFT is 5, this BUG() is obviously impossible. But I guess it's not obvious to GCC.

I'll put in a comment to explain that.

Quoted 4 lines

NACK on that comment and associated code: Jean Delvare submitted a patch to NVIDIA over two years ago to fix their bug. Apparently some distros even carry his patch. So, I don't want to encourage such a hack to persist. Please just do the standard check here.

Ok. I wonder if the nouveau people have any intention to reverse-engineer the i2c controller?

Updated patch to follow soon.

--D

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#5 lore raw
Quoted 2 lines · Darrick J. Wong

Ok. I wonder if the nouveau people have any intention to reverse-engineer the i2c controller?

There's probably not much to reverse-engineer, the nvidiafb driver has been supporting the I2C controllers (using software-driven bit-banging) for a long time now. Maybe the hardware can do better but it's probably not a big deal as I2C access on a graphics adapter isn't performance critical.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#6 lore raw

PATCH v2 1/1 adt7473: New driver for Analog Devices ADT7473 sensor chip

In reply to Mark M. Hoffman

adt7473: New driver for Analog Devices ADT7473 sensor chip

This driver reports voltage, temperature and fan sensor readings on an ADT7473 chip.

---

 Documentation/hwmon/adt7473 |   79 +++
 drivers/hwmon/Kconfig       |   10 
 drivers/hwmon/Makefile      |    1 
 drivers/hwmon/adt7473.c     | 1157 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1247 insertions(+), 0 deletions(-)
Documentation/hwmon/adt7473 new file +79 -0
new file mode 100644
index 0000000..22d8b19
@@ -0,0 +1,79 @@
+Kernel driver adt7473
+===========
+
+Supported chips:
+  * Analog Devices ADT7473
+    Prefix: 'adt7473'
+    Addresses scanned: I2C 0x2C, 0x2D, 0x2E
+    Datasheet: Publicly available at the Analog Devices website
+
+Author: Darrick J. Wong
+
+Description
+-----------
+
+This driver implements support for the Analog Devices ADT7473 chip family.
+
+The LM85 uses the 2-wire interface compatible with the SMBUS 2.0
+specification. Using an analog to digital converter it measures three (3)
+temperatures and two (2) voltages. It has three (3) 16-bit counters for
+measuring fan speed. There are three (3) PWM outputs that can be used
+to control fan speed.
+
+A sophisticated control system for the PWM outputs is designed into the
+LM85 that allows fan speed to be adjusted automatically based on any of the
+three temperature sensors. Each PWM output is individually adjustable and
+programmable. Once configured, the ADT7473 will adjust the PWM outputs in
+response to the measured temperatures without further host intervention.
+This feature can also be disabled for manual control of the PWM's.
+
+Each of the measured inputs (voltage, temperature, fan speed) has
+corresponding high/low limit values. The ADT7473 will signal an ALARM if
+any measured value exceeds either limit.
+
+The ADT7473 samples all inputs continuously. The driver will not read
+the registers more often than once every other second. Further,
+configuration data is only read once per minute.
+
+Special Features
+----------------
+
+The ADT7473 have a 10-bit ADC and can therefore measure temperatures
+with 0.25 degC resolution. Temperature readings can be configured either
+for twos complement format or "Offset 64" format, wherein 63 is subtracted
+from the raw value to get the temperature value.
+
+The Analog Devices datasheet is very detailed and describes a procedure for
+determining an optimal configuration for the automatic PWM control.
+
+Hardware Configurations
+-----------------------
+
+The ADT7473 chips have an optional SMBALERT output that can be used to
+signal the chipset in case a limit is exceeded or the temperature sensors
+fail. Individual sensor interrupts can be masked so they won't trigger
+SMBALERT. The SMBALERT output if configured replaces the PWM2 function.
+
+Configuration Notes
+-------------------
+
+Besides standard interfaces driver adds the following:
+
+* PWM Control
+
+* pwm#_auto_point1_pwm and pwm#_auto_point1_temp and
+* pwm#_auto_point2_pwm and pwm#_auto_point2_temp -
+
+point1: Set the pwm speed at a lower temperature bound.
+point2: Set the pwm speed at a higher temperature bound.
+
+The ADT7473 will scale the pwm between the lower and higher pwm speed when
+the temperature is between the two temperature boundaries.  PWM values range
+from 0 (off) to 255 (full speed).
+
+Notes
+-----
+
+The NVIDIA binary driver presents an ADT7473 chip via an on-card i2c bus.
+Unfortunately, they fail to set the i2c adapter class, so this driver may
+fail to find the chip until the nvidia driver is patched.
drivers/hwmon/Kconfig +10 -0
index 410ffe4..368879f 100644
@@ -143,6 +143,16 @@ config SENSORS_ADT7470
 	  This driver can also be built as a module. If so, the module
 	  will be called adt7470.
 
+config SENSORS_ADT7473
+	tristate "Analog Devices ADT7473"
+	depends on I2C && EXPERIMENTAL
+	help
+	  If you say yes here you get support for the Analog Devices
+	  ADT7473 temperature monitoring chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called adt7473.
+
 config SENSORS_K8TEMP
 	tristate "AMD Athlon64/FX or Opteron temperature sensor"
 	depends on X86 && PCI && EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
index 8241613..3bdb05a 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_SENSORS_ADM1031)	+= adm1031.o
 obj-$(CONFIG_SENSORS_ADM9240)	+= adm9240.o
 obj-$(CONFIG_SENSORS_ADS7828)	+= ads7828.o
 obj-$(CONFIG_SENSORS_ADT7470)	+= adt7470.o
+obj-$(CONFIG_SENSORS_ADT7473)	+= adt7473.o
 obj-$(CONFIG_SENSORS_APPLESMC)	+= applesmc.o
 obj-$(CONFIG_SENSORS_AMS)	+= ams/
 obj-$(CONFIG_SENSORS_ATXP1)	+= atxp1.o
drivers/hwmon/adt7473.c new file +1156 -0

1,156 lines not on this page · raw message

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#7 lore raw

Hi Darrick:

Quoted 5 lines · Darrick J. Wong

adt7473: New driver for Analog Devices ADT7473 sensor chip

This driver reports voltage, temperature and fan sensor readings on an ADT7473 chip.

Quoted 9 lines

---

 Documentation/hwmon/adt7473 |   79 +++
 drivers/hwmon/Kconfig       |   10 
 drivers/hwmon/Makefile      |    1 
 drivers/hwmon/adt7473.c     | 1157 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1247 insertions(+), 0 deletions(-)

Applied to hwmon-2.6.git/testing, thanks.

Signature · 8 lines
Mark M. Hoffman
[email protected]


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#8 lore raw

Re: [lm-sensors] [PATCH v2] adt7473: New driver for Analog Devices

In reply to Darrick J. Wong
Quoted 11 lines · Mark M. Hoffman

Hi Darrick:

Quoted 8 lines · Darrick J. Wong

adt7473: New driver for Analog Devices ADT7473 sensor chip

This driver reports voltage, temperature and fan sensor readings on an ADT7473 chip.

---

Quoted 8 lines
Quoted 6 lines
 Documentation/hwmon/adt7473 |   79 +++
 drivers/hwmon/Kconfig       |   10 
 drivers/hwmon/Makefile      |    1 
 drivers/hwmon/adt7473.c     | 1157 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1247 insertions(+), 0 deletions(-)

Applied to hwmon-2.6.git/testing, thanks.

wiki/Devices updated accordingly.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#9 lore raw
In reply to Mark M. Hoffman
Quoted 15 lines · Mark M. Hoffman

drivers/hwmon/adt7473.c line 1047

Quoted 9 lines · Darrick J. Wong
drivers/hwmon/adt7473.c new file +9 -0
+static int adt7473_attach_adapter(struct i2c_adapter *adapter)
+{
+	/*
+	 * Some NVIDIA cards have an adt7473 attached to the on-board
+	 * i2c controller, but the i2c adapter driver in the binary
+	 * nvidia superblob driver sets class to 0.
+	 */
+	if (!(adapter->class & I2C_CLASS_HWMON) && adapter->class)
+		return 0;

NACK on that comment and associated code: Jean Delvare submitted a patch to NVIDIA over two years ago to fix their bug. Apparently some distros even carry his patch. So, I don't want to encourage such a hack to persist. Please just do the standard check here.

For the records: this patch exists but I did not send it to nVidia. For legal/license reasons I do not want to be considered a contributor to the nvidia Linux driver. So someone else will have to send the patch to nVidia. I would hope that this was already done by now, but maybe not.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors