From 0463566da75b44c98716dde296472bd430d33991 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 25 May 2008 10:07:25 +0000 Subject: [PATCH] Improve MAX6657, MAX6658, MAX6659 detection. Adjust the confidence value of ADM1032, MAX6680/MAX6681 and TMP401. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5264 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/detect/sensors-detect | 58 ++++++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/CHANGES b/CHANGES index a3d3033c..5b0b7e4a 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ lm-sensors CHANGES file SVN-HEAD sensors-detect: Add Intel SCH (bus) support Add SMSC EMC6D103 support + Improve MAX6657, MAX6658, MAX6659 detection 3.0.2 (2008-05-18) documentation: Delete the FAQ, now maintained on the wiki diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index e6c8a4ad..afce735e 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -1094,13 +1094,13 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis645 @pci_adapters_sis96x); name => "Maxim MAX6657/MAX6658/MAX6659", driver => "lm90", i2c_addrs => [0x4c], - i2c_detect => sub { lm90_detect(4, @_); }, + i2c_detect => sub { max6657_detect(@_); }, }, { name => "Maxim MAX6659", driver => "lm90", i2c_addrs => [0x4d..0x4e], # 0x4c is handled above - i2c_detect => sub { lm90_detect(4, @_); }, + i2c_detect => sub { max6657_detect(@_); }, }, { name => "Maxim MAX6648/MAX6692", @@ -3958,14 +3958,12 @@ sub lm83_detect } # $_[0]: Chip to detect -# (0 = LM90, 1=LM89/LM99, 2=LM86, 3=ADM1032, 4=MAX6657/MAX6658/MAX6659, +# (0 = LM90, 1 = LM89/LM99, 2 = LM86, 3 = ADM1032, # 5 = ADT7461, 6 = MAX6648/MAX6692, 7 = MAX6680/MAX6681, -# 8 = W83L771W/G), 9 = TI TMP401 +# 8 = W83L771W/G, 9 = TI TMP401) # $_[1]: A reference to the file descriptor to access this chip. # $_[2]: Address -# Returns: undef if not detected, 4, 6 or 8 if detected. -# The Maxim chips MAX6657, MAX6658 and MAX6659 have a low confidence -# value (4) because they don't have a die revision register. +# Returns: undef if not detected, 6 or 8 if detected. # Registers used: # 0x03: Configuration # 0x04: Conversion rate @@ -4005,15 +4003,7 @@ sub lm90_detect return if ($conf & 0x3f) != 0; return if $rate > 0x0a; return if $mid != 0x41; # Analog Devices - return 8 if ($cid & 0xf0) == 0x40; # ADM1032 - } - if ($chip == 4) { - return if ($conf & 0x1f) != ($mid & 0x0f); # No low nibble, - # returns previous low nibble - return if $rate > 0x09; - return if $mid != 0x4d; # Maxim - return if $cid != 0x4d; # No register, returns previous value - return 4; + return 6 if ($cid & 0xf0) == 0x40; # ADM1032 } if ($chip == 5) { return if ($conf & 0x1b) != 0; @@ -4033,7 +4023,7 @@ sub lm90_detect return if $rate > 0x07; return if $mid != 0x4d; # Maxim return if $cid != 0x01; # MAX6680/MAX6681 - return 6; + return 8; } if ($chip == 8) { return if ($conf & 0x2a) != 0; @@ -4047,11 +4037,43 @@ sub lm90_detect return if $rate > 0x0F; return if $mid != 0x55; # Texas Instruments return if $cid != 0x11; # TMP401 - return 6; + return 8; } return; } +# $_[0]: A reference to the file descriptor to access this chip. +# $_[1]: Address +# Returns: undef if not detected, 5 if detected. +# Registers used: +# 0x03: Configuration (no low nibble) +# 0x04: Conversion rate +# 0xfe: Manufacturer ID +# 0xff: no register +sub max6657_detect +{ + my ($file, $addr) = @_; + my $mid = i2c_smbus_read_byte_data($file, 0xfe); + my $cid = i2c_smbus_read_byte_data($file, 0xff); + my $conf = i2c_smbus_read_byte_data($file, 0x03); + + return if $mid != 0x4d; # Maxim + return if ($conf & 0x1f) != 0x0d; # No low nibble, + # returns previous low nibble + return if $cid != 0x4d; # No register, returns previous value + + my $rate = i2c_smbus_read_byte_data($file, 0x04); + return if $rate > 0x09; + + $cid = i2c_smbus_read_byte_data($file, 0xff); + $conf = i2c_smbus_read_byte_data($file, 0x03); + return if ($conf & 0x0f) != $rate; # No low nibble, + # returns previous low nibble + return if $cid != $rate; # No register, returns previous value + + return 5; +} + # $_[0]: Chip to detect # (1 = LM63, 2 = F75363SG, 3 = LM64) # $_[1]: A reference to the file descriptor to access this chip.