diff --git a/CHANGES b/CHANGES index 2b9b3ac2..ea472f6e 100644 --- a/CHANGES +++ b/CHANGES @@ -39,6 +39,7 @@ ask CVS about it: fan -> fan1; fix temp2 limit writes Module pcf8591: new Module w83781d: Add W83697HF support + Program decode-vaio.pl: new Program i2cdump: Add i2c block read capability (requires i2c-2.6.3) Program init/sensors: New SysV init script Program mkpatch.pl: Add support for fscscy, add more help entries diff --git a/doc/progs b/doc/progs index 9c852415..2ad20c73 100644 --- a/doc/progs +++ b/doc/progs @@ -77,6 +77,10 @@ see useful_addresses.html. It will only work for the installed eeprom module from the src/ directory, not for the old one in the i2c/drivers/ directory. +* prog/eeprom/decode-vaio.pl (written in Perl 5, not installed) + This program decodes the information in a Sony Vaio laptop + identification eeprom at 0x57. + * prog/eepromer/eepromer (written in C, not installed) This program reads and writes eeproms. Danger: Do not use this to write your DRAM DIMM eeproms. diff --git a/prog/eeprom/decode-vaio.pl b/prog/eeprom/decode-vaio.pl new file mode 100755 index 00000000..f9fe6e82 --- /dev/null +++ b/prog/eeprom/decode-vaio.pl @@ -0,0 +1,132 @@ +#!/usr/bin/perl -w +# +# Copyright 2002 Jean Delvare +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Version 0.1 2002-02-06 Jean Delvare +# +# EEPROM data decoding for Sony Vaio laptops. +# +# Two assumptions: lm_sensors-2.x installed, +# and Perl is at /usr/bin/perl +# +# Please note that this is a guess-only work. I don't expect much help from +# Sony, so if someone can provide information, please contact me. I used my +# PCG-GR214EP as a base, but I can't promise that this script will work with +# other models. Any feedback appreciated anyway. +# + +use strict; + +sub print_item +{ + my ($label,$value) = @_; + + printf("\%20s : \%s\n",$label,$value); +} + +sub decode_char +{ + my ($bus,$addr,$base,$offset,$length) = @_; + + my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); + open(FH,$filename) || die "Can't open $filename"; + my $line=; + close(FH); + + my @bytes=split(/[ \n]/,$line); + @bytes=@bytes[$offset..$offset+$length-1]; + my $string=''; + my $item; + while(defined($item=shift(@bytes))) + { + $string.=chr($item); + } + + return($string); +} + +sub decode_string +{ + my ($bus,$addr,$base,$offset,$length) = @_; + + my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); + open(FH,$filename) || die "Can't open $filename"; + my $line=; + close(FH); + + my @bytes=split(/[ \n]/,$line); + @bytes=@bytes[$offset..$offset+$length-1]; + my $string=''; + my $item; + while(defined($item=shift(@bytes)) && ($item!=0)) + { + $string.=chr($item); + } + + return($string); +} + +sub decode_string32 +{ + my ($bus,$addr,$base) = @_; + + my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); + open(FH,$filename) || die "Can't open $filename"; + my $line=; + close(FH); + $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data".($base+16).'-'.($base+31); + open(FH,$filename) || die "Can't open $filename"; + $line.=; + close(FH); + + my @bytes=split(/[ \n]/,$line); + my $string=''; + my $item; + while(defined($item=shift(@bytes)) && ($item!=0)) + { + $string.=chr($item); + } + + return($string); +} + +sub vaio_decode +{ + my ($bus,$addr) = @_; + + print_item('Model name',decode_string32($bus,$addr,128).' ['.decode_char($bus,$addr,160,10,4).']'); + print_item('Revision',decode_string($bus,$addr,160,0,10)); + print_item('Serial number',decode_string32($bus,$addr,192)); + print_item('Timestamp',decode_string32($bus,$addr,224)); +} + +print("Sony Vaio EEPROM Decoder\n"); +print("Written by Jean Delvare. Copyright 2002.\n"); +print("Version 0.1\n\n"); + +if ( -r '/proc/sys/dev/sensors/eeprom-i2c-0-57') +{ + vaio_decode('0','57'); +} +else +{ + print("Vaio eeprom not found. Please make sure that the eeprom module is loaded.\n"); + print("If you believe this is an error, please contact me \n"); + print("so that we may see how to fix the problem.\n"); +} + +print("\n");