From 142256a07522d7e50e5b187378446c40e70a4ff6 Mon Sep 17 00:00:00 2001 From: Philip Edelbrock Date: Sun, 28 Feb 1999 17:24:41 +0000 Subject: [PATCH] (Phil) Getting closer to better EEPROM detection. Checksum test now works for EEPROMs on PC-100 DIMMs. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@278 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/detect/detect.pl | 15 +++++++++++++-- prog/detect/sensors-detect | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/prog/detect/detect.pl b/prog/detect/detect.pl index 0a9b2d6f..5c04d928 100755 --- a/prog/detect/detect.pl +++ b/prog/detect/detect.pl @@ -214,7 +214,7 @@ use subs qw(lm78_detect lm78_isa_detect lm78_alias_detect lm75_detect name => "Serial EEPROM", driver => "eeprom", i2c_addrs => [0x50..0x57], - i2c_detect => sub { eeprom_detect 0, @_ }, + i2c_detect => sub { eeprom_detect @_ }, } ); @@ -1290,12 +1290,23 @@ sub sis5595_isa_detect # $_[1]: Address # Returns: undef if not detected, (5) if detected. # Registers used: -# 0x??: PC-100 Checksum +# 0x00-0x63: PC-100 Data and Checksum sub eeprom_detect { my ($file,$addr) = @_; + # Check the checksum for validity (only works for PC-100 DIMMs) + my $checksum = 0; + for (my $i = 0; $i <= 62; $i = $i + 1) { + $checksum = $checksum + i2c_smbus_read_byte_data($file,$i); + } + $checksum=$checksum & 255; + if (i2c_smbus_read_byte_data($file,63) == $checksum) { + return (8); + } + # Even if checksum test fails, it still may be an eeprom return (1); } + ################ # MAIN PROGRAM # ################ diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 0a9b2d6f..5c04d928 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -214,7 +214,7 @@ use subs qw(lm78_detect lm78_isa_detect lm78_alias_detect lm75_detect name => "Serial EEPROM", driver => "eeprom", i2c_addrs => [0x50..0x57], - i2c_detect => sub { eeprom_detect 0, @_ }, + i2c_detect => sub { eeprom_detect @_ }, } ); @@ -1290,12 +1290,23 @@ sub sis5595_isa_detect # $_[1]: Address # Returns: undef if not detected, (5) if detected. # Registers used: -# 0x??: PC-100 Checksum +# 0x00-0x63: PC-100 Data and Checksum sub eeprom_detect { my ($file,$addr) = @_; + # Check the checksum for validity (only works for PC-100 DIMMs) + my $checksum = 0; + for (my $i = 0; $i <= 62; $i = $i + 1) { + $checksum = $checksum + i2c_smbus_read_byte_data($file,$i); + } + $checksum=$checksum & 255; + if (i2c_smbus_read_byte_data($file,63) == $checksum) { + return (8); + } + # Even if checksum test fails, it still may be an eeprom return (1); } + ################ # MAIN PROGRAM # ################