From 421f0575b0ddf8479752fc307f9ebce1753fd4ac Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 12 Dec 2010 16:54:35 +0000 Subject: [PATCH] Add detection of the Analog Devices ADT7410. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5895 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/detect/sensors-detect | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/CHANGES b/CHANGES index 3de3b5ed..6f513c51 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ SVN HEAD sensors-detect: Improve LM90 and W83L771 detection Fix error seen if I2C bus numbers are not sequential Add detection of SMSC EMC1423 + Add detection of the Analog Devices ADT7410 3.2.0 (2010-10-10) libsensors: Increase MAX_SENSORS_PER_TYPE to 24 diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index fceb267e..61362684 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -596,6 +596,11 @@ use vars qw(@i2c_adapter_names); driver => "adt7475", i2c_addrs => [0x2c..0x2e], i2c_detect => sub { adt7490_detect(@_); }, + }, { + name => "Analog Devices ADT7410", + driver => "to-be-written", + i2c_addrs => [0x48..0x4b], + i2c_detect => sub { adt7410_detect(@_); }, }, { name => "Analog Devices ADT7411", driver => "to-be-written", @@ -4546,6 +4551,41 @@ sub adt7490_detect return 5; } +# Registers used: +# 0x02: Status +# 0x0a: Thyst +# 0x0b: ID +# We also rely on the fact that only the 5 LSB of the address pointer +# are considered, so registers cycle over 32 byte boundaries. +sub adt7410_detect +{ + my ($file, $addr) = @_; + my $status = i2c_smbus_read_byte_data($file, 0x02); + my $thyst = i2c_smbus_read_byte_data($file, 0x0a); + my $id = i2c_smbus_read_byte_data($file, 0x0b); + + # Unused bits + return if ($status & 0x0f); + return if ($thyst & 0xf0); + + # ID register + return if $id != 0xcb; + + # Cycling registers + for (my $i = 2; $i < 16; $i *= 2) { + return if i2c_smbus_read_byte_data($file, 0x0a + $i * 16) != $thyst; + return if i2c_smbus_read_byte_data($file, 0x0b + $i * 16) != $id; + } + + # Non-existent registers (other devices tend to have ID registers there) + return if i2c_smbus_read_byte_data($file, 0x03e) != 0; + return if i2c_smbus_read_byte_data($file, 0x03f) != 0; + return if i2c_smbus_read_byte_data($file, 0x0fe) != 0; + return if i2c_smbus_read_byte_data($file, 0x0ff) != 0; + + return 3; +} + # Registers used: # 0x4d: Device ID # 0x4e: Manufacturer ID