Changeset 2358

Show
Ignore:
Timestamp:
03/15/04 05:23:54 (9 years ago)
Author:
mmh
Message:

Added custom detection for some SiS chipsets. This resolves a long-
standing false detection problem. Other changes in support of this custom
detection:

1) Changed pci_list to a hash, with keys of the form "1039:0016"
2) Added @kernel_version detection and comparison routine (thanks Khali)
3) Removed legacy sub: read_proc_pci

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/detect/sensors-detect

    r2354 r2358  
    199199     { 
    200200       vendid => 0x1039, 
    201        devid  => 0x0008, 
    202        func => 0, 
    203        procid => "Silicon Integrated Systems SIS5595", 
    204        driver => "i2c-sis5595", 
    205        match => sub {  $_[0] =~ /^SMBus SIS5595 adapter at [0-9,a-f]{4}/ }, 
    206      } , 
    207      { 
    208        vendid => 0x1039, 
    209        devid  => 0x0018, 
    210        func => 0, 
    211        procid => "Silicon Integrated Systems 85C503/5513 (LPC Bridge)", 
    212        driver => "i2c-sis645", 
    213        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    214      } , 
    215      { 
    216        vendid => 0x1039, 
    217201       devid  => 0x5597, 
    218202       func => 0, 
     
    244228       driver => "i2c-sis630", 
    245229       match => sub { $_[0] =~ /^SMBus SIS630 adapter at [0-9,a-f]{4}/ }, 
    246      } , 
    247      { 
    248        vendid => 0x1039, 
    249        devid  => 0x0645, 
    250        func => 0, 
    251        procid => "Silicon Integrated Systems SIS645", 
    252        driver => "i2c-sis645", 
    253        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    254      } , 
    255      { 
    256        vendid => 0x1039, 
    257        devid  => 0x0646, 
    258        func => 0, 
    259        procid => "Silicon Integrated Systems SIS645DX", 
    260        driver => "i2c-sis645", 
    261        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    262      } , 
    263      { 
    264        vendid => 0x1039, 
    265        devid  => 0x0648, 
    266        func => 0, 
    267        procid => "Silicon Integrated Systems SIS648", 
    268        driver => "i2c-sis645", 
    269        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    270      } , 
    271      { 
    272        vendid => 0x1039, 
    273        devid  => 0x0650, 
    274        func => 0, 
    275        procid => "Silicon Integrated Systems SIS650", 
    276        driver => "i2c-sis645", 
    277        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    278      } , 
    279      { 
    280        vendid => 0x1039, 
    281        devid  => 0x0651, 
    282        func => 0, 
    283        procid => "Silicon Integrated Systems SIS651", 
    284        driver => "i2c-sis645", 
    285        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    286      } , 
    287      { 
    288        vendid => 0x1039, 
    289        devid  => 0x0735, 
    290        func => 0, 
    291        procid => "Silicon Integrated Systems SIS735", 
    292        driver => "i2c-sis645", 
    293        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    294      } , 
    295      { 
    296        vendid => 0x1039, 
    297        devid  => 0x0745, 
    298        func => 0, 
    299        procid => "Silicon Integrated Systems SIS745", 
    300        driver => "i2c-sis645", 
    301        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    302      } , 
    303      { 
    304        vendid => 0x1039, 
    305        devid  => 0x0746, 
    306        func => 0, 
    307        procid => "Silicon Integrated Systems SIS746", 
    308        driver => "i2c-sis645", 
    309        match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
    310230     } , 
    311231     { 
     
    792712       match => sub { 0 }, 
    793713     } ,  
     714); 
     715 
     716# The following entries used to appear directly in @pci_adapters. 
     717# Because of the tendency of SiS chipsets to have their real PCI 
     718# IDs obscured, we have to qualify these with a custom detection 
     719# routine before we add them to the @pci_adapters list. 
     720# 
     721use vars qw(@pci_adapters_sis5595 @pci_adapters_sis645 @pci_adapters_sis96x); 
     722@pci_adapters_sis5595 = ( 
     723     { 
     724       vendid => 0x1039, 
     725       devid  => 0x0008, 
     726       func => 0, 
     727       procid => "Silicon Integrated Systems SIS5595", 
     728       driver => "i2c-sis5595", 
     729       match => sub {  $_[0] =~ /^SMBus SIS5595 adapter at [0-9,a-f]{4}/ }, 
     730     } , 
     731); 
     732 
     733@pci_adapters_sis645 = ( 
     734     { 
     735       vendid => 0x1039, 
     736       devid  => 0x0008, 
     737       func => 0, 
     738       procid => "Silicon Integrated Systems SIS5595", 
     739       driver => "i2c-sis645", 
     740       match => sub {  $_[0] =~ /^SiS645 SMBus adapter at [0-9,a-f]{4}/ }, 
     741     } , 
     742     { 
     743       vendid => 0x1039, 
     744       devid  => 0x0016, 
     745       func => 1, 
     746       procid => "Silicon Integrated Systems SMBus Controller", 
     747       driver => "i2c-sis645", 
     748       match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
     749     } , 
     750     { 
     751       vendid => 0x1039, 
     752       devid  => 0x0018, 
     753       func => 0, 
     754       procid => "Silicon Integrated Systems 85C503/5513 (LPC Bridge)", 
     755       driver => "i2c-sis645", 
     756       match => sub { $_[0] =~ /^SiS645 SMBus adapter at 0x[0-9,a-f]{4}/ }, 
     757     } , 
     758); 
     759 
     760@pci_adapters_sis96x = ( 
     761     { 
     762       vendid => 0x1039, 
     763       devid  => 0x0016, 
     764       func => 1, 
     765       procid => "Silicon Integrated Systems SMBus Controller", 
     766       driver => "i2c-sis96x", 
     767       match => sub { $_[0] =~ /^SiS96x SMBus adapter at 0x[0-9,a-f]{4}/ }, 
     768     } , 
    794769); 
    795770 
     
    17791754} 
    17801755 
     1756# [0] -> VERSION 
     1757# [1] -> PATCHLEVEL 
     1758# [2] -> SUBLEVEL 
     1759# [3] -> EXTRAVERSION 
     1760# 
     1761use vars qw(@kernel_version); 
     1762 
     1763sub initialize_kernel_version 
     1764{ 
     1765  `uname -r` =~ /(\d+)\.(\d+)\.(\d+)(.*)/; 
     1766  @kernel_version = ($1, $2, $3, $4); 
     1767} 
     1768 
     1769sub kernel_version_at_least 
     1770{ 
     1771  my ($vers, $plvl, $slvl) = @_; 
     1772  return 1 if ($kernel_version[0]  > $vers || 
     1773                ($kernel_version[0] == $vers &&  
     1774                  ($kernel_version[1]  > $plvl ||  
     1775                    ($kernel_version[1] == $plvl &&  
     1776                      ($kernel_version[2] >= $slvl))))); 
     1777  return 0; 
     1778} 
     1779 
    17811780########### 
    17821781# MODULES # 
     
    17981797############## 
    17991798 
    1800 use vars qw(@pci_list); 
    1801  
    1802 # This function returns a list of hashes. Each hash has some PCI information  
     1799use vars qw(%pci_list); 
     1800 
     1801# This function returns a hash of hashes. Each hash has some PCI information 
    18031802# (more than we will ever need, probably). The most important 
    18041803# fields are 'bus', 'slot', 'func' (they uniquely identify a PCI device in  
    18051804# a computer) and 'vendid','devid' (they uniquely identify a type of device). 
    1806 # /proc/bus/pci/devices is only available on late 2.1 and 2.2 kernels. 
    18071805sub read_proc_dev_pci 
    18081806{ 
    1809   my ($dfn,$vend,@pci_list); 
     1807  my ($dfn,$vend,%pci_list); 
    18101808  open INPUTFILE, "/proc/bus/pci/devices" or return; 
    18111809  while (<INPUTFILE>) { 
     
    18201818    $record->{vendid} = $vend >> 16; 
    18211819    $record->{devid} = $vend & 0xffff; 
    1822   push @pci_list,$record; 
     1820     
     1821    $pci_list{ sprintf("%04x:%04x",$record->{vendid},$record->{devid}) } = 
     1822        $record; 
    18231823  } 
    18241824  close INPUTFILE or return; 
    1825   return @pci_list; 
    1826 } 
    1827  
    1828 # This function returns a list of hashes. Each hash has some PCI  
    1829 # information. The important fields here are 'bus', 'slot', 'func' (they 
    1830 # uniquely identify a PCI device in a computer) and 'desc' (a functional 
    1831 # description of the PCI device). If this is an 'unknown device', the 
    1832 # vendid and devid fields are set instead. 
    1833 sub read_proc_pci 
    1834 { 
    1835   my @pci_list; 
    1836   open INPUTFILE, "/proc/pci" or return; 
    1837   while (<INPUTFILE>) { 
    1838     my $record = {}; 
    1839     if (($record->{bus},$record->{slot},$record->{func}) =  
    1840         /^\s*Bus\s*(\S)+\s*,\s*device\s*(\S+)\s*,\s*function\s*(\S+)\s*:\s*$/) { 
    1841       my $desc = <INPUTFILE>; 
    1842       $_ = <INPUTFILE>; 
    1843       if (($desc =~ /Unknown device/) and 
    1844               (($record->{vendid},$record->{devid}) =  
    1845                          /^\s*Vendor id=(\S+)\.\s*Device id=(\S+)\.$/)) { 
    1846         $record->{vendid} = hex $record->{vendid}; 
    1847         $record->{devid} = hex $record->{devid}; 
    1848       } else { 
    1849         $record->{desc} = $desc; 
    1850       } 
    1851       push @pci_list,$record; 
    1852     } 
    1853   } 
    1854   close INPUTFILE or return; 
    1855   return @pci_list; 
     1825  return %pci_list; 
    18561826} 
    18571827 
    18581828sub initialize_proc_pci 
    18591829{ 
    1860   @pci_list = read_proc_dev_pci; 
    1861   @pci_list = read_proc_pci     if not defined @pci_list; 
    1862   die "Can't access either /proc/bus/pci/ or /proc/pci!"  
    1863                                     if not defined @pci_list; 
     1830  %pci_list = read_proc_dev_pci; 
     1831  die "Can't access /proc/bus/pci/devices!" if not defined %pci_list; 
    18641832} 
    18651833 
     
    18841852} 
    18851853 
     1854sub adapter_pci_detection_sis_96x 
     1855{ 
     1856  my $driver=""; 
     1857 
     1858  # first, determine which driver if any... 
     1859  if (kernel_version_at_least(2,6,0)) { 
     1860    if (exists $pci_list{"1039:0016"}) { 
     1861      $driver = "i2c-sis96x"; 
     1862    } elsif (exists $pci_list{"1039:0008"}) { 
     1863      $driver = "i2c-sis5595"; 
     1864    } 
     1865  } elsif (kernel_version_at_least(2,4,0)) { 
     1866    if (exists $pci_list{"1039:0008"}) { 
     1867      if ((exists $pci_list{"1039:0645"}) || 
     1868          (exists $pci_list{"1039:0646"}) || 
     1869          (exists $pci_list{"1039:0648"}) || 
     1870          (exists $pci_list{"1039:0650"}) || 
     1871          (exists $pci_list{"1039:0651"}) || 
     1872          (exists $pci_list{"1039:0735"}) || 
     1873          (exists $pci_list{"1039:0745"}) || 
     1874          (exists $pci_list{"1039:0746"})) { 
     1875        $driver = "i2c-sis645"; 
     1876      } else { 
     1877        $driver = "i2c-sis5595"; 
     1878      } 
     1879    } elsif ((exists $pci_list{"1039:0016"}) || 
     1880             (exists $pci_list{"1039:0018"})) { 
     1881      $driver = "i2c-sis645"; 
     1882    } 
     1883  } 
     1884 
     1885  # then, add the appropriate entries to @pci_adapters 
     1886  if ($driver eq "i2c-sis5595") { 
     1887    push @pci_adapters, @pci_adapters_sis5595; 
     1888  } elsif ($driver eq "i2c-sis645") { 
     1889    push @pci_adapters, @pci_adapters_sis645; 
     1890  } elsif ($driver eq "i2c-sis96x") { 
     1891    push @pci_adapters, @pci_adapters_sis96x; 
     1892  } 
     1893} 
     1894 
    18861895sub adapter_pci_detection 
    18871896{ 
    1888   my ($device,$try,@res); 
     1897  my ($key,$device,$try,@res); 
    18891898  print "Probing for PCI bus adapters...\n"; 
    18901899 
    1891   foreach $device (@pci_list) { 
     1900  # Custom detection routine for some SiS chipsets 
     1901  adapter_pci_detection_sis_96x(); 
     1902 
     1903  # Generic detection loop 
     1904  while ( ($key, $device) = each %pci_list) { 
    18921905    foreach $try (@pci_adapters) { 
    18931906      if ((defined($device->{vendid}) and  
     
    34043417{ 
    34053418  my ($addr) = @_; 
    3406   my ($adapter,$try,$local_try); 
     3419  my ($key,$adapter,$try,$local_try); 
    34073420  my $found = 0; 
    34083421  foreach $local_try (@pci_adapters) { 
     
    34163429 
    34173430  $found = 0; 
    3418   foreach $adapter (@pci_list) { 
     3431  while ( ($key, $adapter) = each %pci_list) { 
    34193432    if ((defined($adapter->{vendid}) and  
    34203433         $try->{vendid} == $adapter->{vendid} and 
     
    34403453{ 
    34413454  my ($addr) = @_; 
    3442   my ($adapter,$try,$local_try); 
     3455  my ($key,$adapter,$try,$local_try); 
    34433456  my $found = 0; 
    34443457  foreach $local_try (@pci_adapters) { 
     
    34523465 
    34533466  $found = 0; 
    3454   foreach $adapter (@pci_list) { 
     3467  while ( ($key, $adapter) = each %pci_list) { 
    34553468    if ((defined($adapter->{vendid}) and  
    34563469         $try->{vendid} == $adapter->{vendid} and 
     
    34763489{ 
    34773490  my ($addr) = @_; 
    3478   my ($adapter,$try,$local_try); 
     3491  my ($key,$adapter,$try,$local_try); 
    34793492  my $found = 0; 
    34803493  foreach $local_try (@pci_adapters) { 
     
    34883501 
    34893502  $found = 0; 
    3490   foreach $adapter (@pci_list) { 
     3503  while ( ($key, $adapter) = each %pci_list) { 
    34913504    if ((defined($adapter->{vendid}) and  
    34923505         $try->{vendid} == $adapter->{vendid} and 
     
    42664279  initialize_proc_pci; 
    42674280  initialize_modules_list; 
     4281  initialize_kernel_version; 
    42684282 
    42694283  print "\nThis program will help you determine which I2C/SMBus modules you need to\n",