Changeset 266

Show
Ignore:
Timestamp:
02/23/99 21:28:05 (15 years ago)
Author:
frodo
Message:

Alias detection completed for Nat. Sem. LM7* and Winbond chips

A few ISA detections must still be added; also, I want to add the option not
to scan certain I2C addresses.

Location:
lm-sensors/trunk/prog/detect
Files:
2 modified

Legend:

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

    r265 r266  
    7878); 
    7979 
    80 use subs qw(lm78_detect lm78_isa_detect lm75_detect lm80_detect w83781d_detect 
     80use subs qw(lm78_detect lm78_isa_detect lm78_alias_detect lm75_detect  
     81            lm80_detect w83781d_detect w83781d_alias_detect 
    8182            w83781d_isa_detect gl518sm_detect gl520sm_detect adm9240_detect  
    8283            adm1021_detect); 
     
    9798#      this chip. The function should take one parameter: the ISA address 
    9899#      to probe. 
     100#  alias_detect (optional): For chips which can be both on the ISA and the 
     101#      I2C bus, a function which detectes whether two entries are the same. 
     102#      The function should take three parameters: The ISA address, the 
     103#      I2C bus number, and the I2C address. 
    99104@chip_ids = ( 
    100105     { 
     
    105110       isa_addrs => [0x290], 
    106111       isa_detect => sub { lm78_isa_detect 0, @_ }, 
     112       alias_detect => sub { lm78_alias_detect 0, @_ }, 
    107113     } , 
    108114     { 
     
    113119       isa_addrs => [0x290], 
    114120       isa_detect => sub { lm78_isa_detect 1, @_ }, 
     121       alias_detect => sub { lm78_alias_detect 1, @_ }, 
    115122     } , 
    116123     { 
     
    121128       isa_addrs => [0x290], 
    122129       isa_detect => sub { lm78_isa_detect 2, @_ }, 
     130       alias_detect => sub { lm78_alias_detect 2, @_ }, 
    123131     } , 
    124132     { 
     
    141149       isa_addrs => [0x290], 
    142150       isa_detect => sub { w83781d_isa_detect 0, @_ }, 
     151       alias_detect => sub { w83781d_alias_detect 0, @_ }, 
    143152     } , 
    144153     { 
     
    149158       isa_addrs => [0x290], 
    150159       isa_detect => sub { w83781d_isa_detect 1, @_ }, 
     160       alias_detect => sub { w83781d_alias_detect 1, @_ }, 
    151161     } , 
    152162     { 
     
    157167       isa_addrs => [0x290], 
    158168       isa_detect => sub { w83781d_isa_detect 2, @_ }, 
     169       alias_detect => sub { w83781d_alias_detect 2, @_ }, 
    159170     } , 
    160171     { 
     
    639650#          with field 'algo' containing an algorithm string as appearing 
    640651#               in /proc/bus/i2c 
     652#          with field 'devnr', contianing the /dev/i2c-* number of this 
     653#               adapter; 
    641654#          with field 'driver', containing the driver name for this adapter; 
    642655#          with field 'address', containing the I2C address of the detection; 
     
    659672#          with field 'algo' containing an algorithm string as appearing 
    660673#               in /proc/bus/i2c 
     674#          with field 'devnr', contianing the /dev/i2c-* number of this 
     675#               adapter; 
    661676#          with field 'driver', containing the driver name for this adapter; 
    662677#          with field 'address', containing the I2C address of the detection; 
     
    728743sub add_isa_to_chips_detected 
    729744{ 
    730   my ($chipdriver,$datahash) = @_; 
     745  my ($alias_detect,$chipdriver,$datahash) = @_; 
    731746  my ($detected_ref,$misdetected_ref, $new_detected_ref,$new_misdetected_ref, 
    732747      $i,$j,$found_it); 
     
    740755    push @chips_detected, { driver => $chipdriver, 
    741756                            detected => [], 
    742                             misdetected => [] }; 
     757                            misdetected => [], }; 
    743758  } 
    744759  $new_detected_ref = $chips_detected[$i]->{detected}; 
    745760  $new_misdetected_ref = $chips_detected[$i]->{misdetected}; 
    746  
    747   # Now, we are looking for aliases. To be done. 
    748   # If an alias is found, it is removed from the structure, and the data 
    749   # is put in %$datahash. If not, nothing happens 
    750761   
     762  # Now, we are looking for aliases. An alias can only be the same chiptype. 
     763  # If an alias is found in the detected list, it is removed from the  
     764  # structure, and the data is put in %$datahash. If it is found in the 
     765  # misdetected list, the entry is modified, and this function aborted. 
     766  # If it is not found, nothing happens. 
     767  for ($j = 0; $j < @$new_misdetected_ref; $j++) { 
     768    if (exists $new_misdetected_ref->[$j]->{address} and  
     769        not exists $new_misdetected_ref->[$j]->{isa_addr} and 
     770        defined $alias_detect and 
     771        $new_misdetected_ref->[$j]->{chip_type} eq $datahash->{chip_type}) { 
     772      if (&$alias_detect ($datahash->{isa_addr}, 
     773                          $new_misdetected_ref->[$j]->{devnr}, 
     774                          $new_misdetected_ref->[$j]->{address})) { 
     775        $new_misdetected_ref->[$j] = { %$new_misdetected_ref->[$j], 
     776                                      isa_addr => $datahash->{isa_addr}}; 
     777        return; 
     778      } 
     779    } 
     780  } 
     781 
     782  for ($j = 0; $j < @$new_detected_ref; $j++) { 
     783    if (exists $new_detected_ref->[$j]->{address} and 
     784        not exists $new_detected_ref->[$j]->{isa_addr} and 
     785        $new_detected_ref->[$j]->{chip_type} eq $datahash->{chip_type}) { 
     786      if (&$alias_detect ($datahash->{isa_addr}, 
     787                          $new_detected_ref->[$j]->{devnr}, 
     788                          $new_detected_ref->[$j]->{address})) { 
     789        $new_detected_ref->[$j]->{isa_addr} = $datahash->{isa_addr}; 
     790        ($datahash) = splice (@$new_detected_ref, $j, 1); 
     791        last; 
     792      } 
     793    } 
     794  } 
     795         
    751796  # At long last, we will insert the new reference, looking out whether 
    752797  # some other chip has already claimed this ISA address. 
     
    791836    printf "Client found at address 0x%02x\n",$addr; 
    792837    foreach $chip (@chip_ids) { 
    793       if (contains $addr, @{$$chip{i2c_addrs}}) { 
     838      if (exists $$chip{i2c_addrs} and contains $addr, @{$$chip{i2c_addrs}}) { 
    794839        print "Probing for $$chip{name}... "; 
    795840        if (($conf,@chips) = &{$$chip{i2c_detect}} (\*FILE ,$addr)) { 
     
    808853                                  algorithm => $algorithm_name, 
    809854                                  driver => $adapter_driver, 
     855                                  devnr => $adapter_nr, 
    810856                                }; 
    811857          foreach $add_addr(@chips) { 
     
    818864                                    driver => $adapter_driver, 
    819865                                    main => $addr, 
     866                                    devnr => $adapter_nr, 
    820867                                  }; 
    821868          } 
     
    840887      print "Success!\n"; 
    841888      printf "    (confidence %d, driver `%s')\n", $conf, $$chip{driver}; 
    842       add_isa_to_chips_detected $$chip{driver},  
     889      add_isa_to_chips_detected $$chip{alias_detect},$$chip{driver},  
    843890                                { confidence => $conf, 
    844891                                  isa_addr => $addr, 
     
    910957                ($chip == 2 and ($reg & 0xfe) == 0xc0); 
    911958  return 7; 
     959} 
     960 
     961 
     962# $_[0]: Chip to detect (0 = LM78, 1 = LM78-J, 2 = LM79) 
     963# $_[1]: ISA address 
     964# $_[2]: I2C file handle 
     965# $_[3]: I2C address 
     966sub lm78_alias_detect 
     967{ 
     968  my ($chip,$isa_addr,$file,$i2c_addr) = @_; 
     969  my $i; 
     970  my $readproc = sub { isa_read_byte $isa_addr + 5, $isa_addr + 6, @_ }; 
     971  return 0 unless &$readproc(0x48) == $i2c_addr; 
     972  for ($i = 0x2b; $i <= 0x3d; $i ++) { 
     973    return 0 unless &$readproc($i) == i2c_smbus_read_byte_data($i); 
     974  } 
     975  return 1; 
    912976} 
    913977 
     
    9961060  push @res, (($reg1 & 0x80) >> 4) + 0x48 unless $reg1 & 0x80; 
    9971061  return @res; 
     1062} 
     1063 
     1064# $_[0]: Chip to detect (0 = W83781D, 1 = W83782D, 3 = W83783S) 
     1065# $_[1]: ISA address 
     1066# $_[2]: I2C file handle 
     1067# $_[3]: I2C address 
     1068sub w83781d_alias_detect 
     1069{ 
     1070  my ($chip,$isa_addr,$file,$i2c_addr) = @_; 
     1071  my $i; 
     1072  my $readproc = sub { isa_read_byte $isa_addr + 5, $isa_addr + 6, @_ }; 
     1073  return 0 unless &$readproc(0x48) == $i2c_addr; 
     1074  for ($i = 0x2b; $i <= 0x3d; $i ++) { 
     1075    return 0 unless &$readproc($i) == i2c_smbus_read_byte_data($i); 
     1076  } 
     1077  return 1; 
    9981078} 
    9991079 
  • lm-sensors/trunk/prog/detect/sensors-detect

    r265 r266  
    7878); 
    7979 
    80 use subs qw(lm78_detect lm78_isa_detect lm75_detect lm80_detect w83781d_detect 
     80use subs qw(lm78_detect lm78_isa_detect lm78_alias_detect lm75_detect  
     81            lm80_detect w83781d_detect w83781d_alias_detect 
    8182            w83781d_isa_detect gl518sm_detect gl520sm_detect adm9240_detect  
    8283            adm1021_detect); 
     
    9798#      this chip. The function should take one parameter: the ISA address 
    9899#      to probe. 
     100#  alias_detect (optional): For chips which can be both on the ISA and the 
     101#      I2C bus, a function which detectes whether two entries are the same. 
     102#      The function should take three parameters: The ISA address, the 
     103#      I2C bus number, and the I2C address. 
    99104@chip_ids = ( 
    100105     { 
     
    105110       isa_addrs => [0x290], 
    106111       isa_detect => sub { lm78_isa_detect 0, @_ }, 
     112       alias_detect => sub { lm78_alias_detect 0, @_ }, 
    107113     } , 
    108114     { 
     
    113119       isa_addrs => [0x290], 
    114120       isa_detect => sub { lm78_isa_detect 1, @_ }, 
     121       alias_detect => sub { lm78_alias_detect 1, @_ }, 
    115122     } , 
    116123     { 
     
    121128       isa_addrs => [0x290], 
    122129       isa_detect => sub { lm78_isa_detect 2, @_ }, 
     130       alias_detect => sub { lm78_alias_detect 2, @_ }, 
    123131     } , 
    124132     { 
     
    141149       isa_addrs => [0x290], 
    142150       isa_detect => sub { w83781d_isa_detect 0, @_ }, 
     151       alias_detect => sub { w83781d_alias_detect 0, @_ }, 
    143152     } , 
    144153     { 
     
    149158       isa_addrs => [0x290], 
    150159       isa_detect => sub { w83781d_isa_detect 1, @_ }, 
     160       alias_detect => sub { w83781d_alias_detect 1, @_ }, 
    151161     } , 
    152162     { 
     
    157167       isa_addrs => [0x290], 
    158168       isa_detect => sub { w83781d_isa_detect 2, @_ }, 
     169       alias_detect => sub { w83781d_alias_detect 2, @_ }, 
    159170     } , 
    160171     { 
     
    639650#          with field 'algo' containing an algorithm string as appearing 
    640651#               in /proc/bus/i2c 
     652#          with field 'devnr', contianing the /dev/i2c-* number of this 
     653#               adapter; 
    641654#          with field 'driver', containing the driver name for this adapter; 
    642655#          with field 'address', containing the I2C address of the detection; 
     
    659672#          with field 'algo' containing an algorithm string as appearing 
    660673#               in /proc/bus/i2c 
     674#          with field 'devnr', contianing the /dev/i2c-* number of this 
     675#               adapter; 
    661676#          with field 'driver', containing the driver name for this adapter; 
    662677#          with field 'address', containing the I2C address of the detection; 
     
    728743sub add_isa_to_chips_detected 
    729744{ 
    730   my ($chipdriver,$datahash) = @_; 
     745  my ($alias_detect,$chipdriver,$datahash) = @_; 
    731746  my ($detected_ref,$misdetected_ref, $new_detected_ref,$new_misdetected_ref, 
    732747      $i,$j,$found_it); 
     
    740755    push @chips_detected, { driver => $chipdriver, 
    741756                            detected => [], 
    742                             misdetected => [] }; 
     757                            misdetected => [], }; 
    743758  } 
    744759  $new_detected_ref = $chips_detected[$i]->{detected}; 
    745760  $new_misdetected_ref = $chips_detected[$i]->{misdetected}; 
    746  
    747   # Now, we are looking for aliases. To be done. 
    748   # If an alias is found, it is removed from the structure, and the data 
    749   # is put in %$datahash. If not, nothing happens 
    750761   
     762  # Now, we are looking for aliases. An alias can only be the same chiptype. 
     763  # If an alias is found in the detected list, it is removed from the  
     764  # structure, and the data is put in %$datahash. If it is found in the 
     765  # misdetected list, the entry is modified, and this function aborted. 
     766  # If it is not found, nothing happens. 
     767  for ($j = 0; $j < @$new_misdetected_ref; $j++) { 
     768    if (exists $new_misdetected_ref->[$j]->{address} and  
     769        not exists $new_misdetected_ref->[$j]->{isa_addr} and 
     770        defined $alias_detect and 
     771        $new_misdetected_ref->[$j]->{chip_type} eq $datahash->{chip_type}) { 
     772      if (&$alias_detect ($datahash->{isa_addr}, 
     773                          $new_misdetected_ref->[$j]->{devnr}, 
     774                          $new_misdetected_ref->[$j]->{address})) { 
     775        $new_misdetected_ref->[$j] = { %$new_misdetected_ref->[$j], 
     776                                      isa_addr => $datahash->{isa_addr}}; 
     777        return; 
     778      } 
     779    } 
     780  } 
     781 
     782  for ($j = 0; $j < @$new_detected_ref; $j++) { 
     783    if (exists $new_detected_ref->[$j]->{address} and 
     784        not exists $new_detected_ref->[$j]->{isa_addr} and 
     785        $new_detected_ref->[$j]->{chip_type} eq $datahash->{chip_type}) { 
     786      if (&$alias_detect ($datahash->{isa_addr}, 
     787                          $new_detected_ref->[$j]->{devnr}, 
     788                          $new_detected_ref->[$j]->{address})) { 
     789        $new_detected_ref->[$j]->{isa_addr} = $datahash->{isa_addr}; 
     790        ($datahash) = splice (@$new_detected_ref, $j, 1); 
     791        last; 
     792      } 
     793    } 
     794  } 
     795         
    751796  # At long last, we will insert the new reference, looking out whether 
    752797  # some other chip has already claimed this ISA address. 
     
    791836    printf "Client found at address 0x%02x\n",$addr; 
    792837    foreach $chip (@chip_ids) { 
    793       if (contains $addr, @{$$chip{i2c_addrs}}) { 
     838      if (exists $$chip{i2c_addrs} and contains $addr, @{$$chip{i2c_addrs}}) { 
    794839        print "Probing for $$chip{name}... "; 
    795840        if (($conf,@chips) = &{$$chip{i2c_detect}} (\*FILE ,$addr)) { 
     
    808853                                  algorithm => $algorithm_name, 
    809854                                  driver => $adapter_driver, 
     855                                  devnr => $adapter_nr, 
    810856                                }; 
    811857          foreach $add_addr(@chips) { 
     
    818864                                    driver => $adapter_driver, 
    819865                                    main => $addr, 
     866                                    devnr => $adapter_nr, 
    820867                                  }; 
    821868          } 
     
    840887      print "Success!\n"; 
    841888      printf "    (confidence %d, driver `%s')\n", $conf, $$chip{driver}; 
    842       add_isa_to_chips_detected $$chip{driver},  
     889      add_isa_to_chips_detected $$chip{alias_detect},$$chip{driver},  
    843890                                { confidence => $conf, 
    844891                                  isa_addr => $addr, 
     
    910957                ($chip == 2 and ($reg & 0xfe) == 0xc0); 
    911958  return 7; 
     959} 
     960 
     961 
     962# $_[0]: Chip to detect (0 = LM78, 1 = LM78-J, 2 = LM79) 
     963# $_[1]: ISA address 
     964# $_[2]: I2C file handle 
     965# $_[3]: I2C address 
     966sub lm78_alias_detect 
     967{ 
     968  my ($chip,$isa_addr,$file,$i2c_addr) = @_; 
     969  my $i; 
     970  my $readproc = sub { isa_read_byte $isa_addr + 5, $isa_addr + 6, @_ }; 
     971  return 0 unless &$readproc(0x48) == $i2c_addr; 
     972  for ($i = 0x2b; $i <= 0x3d; $i ++) { 
     973    return 0 unless &$readproc($i) == i2c_smbus_read_byte_data($i); 
     974  } 
     975  return 1; 
    912976} 
    913977 
     
    9961060  push @res, (($reg1 & 0x80) >> 4) + 0x48 unless $reg1 & 0x80; 
    9971061  return @res; 
     1062} 
     1063 
     1064# $_[0]: Chip to detect (0 = W83781D, 1 = W83782D, 3 = W83783S) 
     1065# $_[1]: ISA address 
     1066# $_[2]: I2C file handle 
     1067# $_[3]: I2C address 
     1068sub w83781d_alias_detect 
     1069{ 
     1070  my ($chip,$isa_addr,$file,$i2c_addr) = @_; 
     1071  my $i; 
     1072  my $readproc = sub { isa_read_byte $isa_addr + 5, $isa_addr + 6, @_ }; 
     1073  return 0 unless &$readproc(0x48) == $i2c_addr; 
     1074  for ($i = 0x2b; $i <= 0x3d; $i ++) { 
     1075    return 0 unless &$readproc($i) == i2c_smbus_read_byte_data($i); 
     1076  } 
     1077  return 1; 
    9981078} 
    9991079