Changeset 4129

Show
Ignore:
Timestamp:
09/01/06 21:22:13 (7 years ago)
Author:
khali
Message:

Attempt to make sensors-detect slightly more user-friendly, part three.

* Give a name to Super-I/O chip families.
* Merge the two Winbond families.
* Be smarter when testing Super-I/O chips, read the device ID only once.
* When an unknown chip is found, print the ID only once.
* Reformat the warning message when a module isn't found.

Files:
1 modified

Legend:

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

    r4128 r4129  
    14311431     }, 
    14321432     { 
    1433        name => "ITE IT8201R/IT8203R/IT8206R/IT8266R overclocking controller", 
     1433       name => "ITE IT8201R/IT8203R/IT8206R/IT8266R", 
    14341434       driver => "not-a-sensor", 
    14351435       i2c_addrs => [0x4e], 
     
    16441644@superio_ids = ( 
    16451645  { 
     1646    family => "ITE", 
    16461647    enter => 
    16471648    { 
     
    16851686  }, 
    16861687  { 
     1688    family => "National Semiconductor", 
    16871689    enter => 
    16881690    { 
     
    18051807  }, 
    18061808  { 
     1809    family => "SMSC", 
    18071810    enter => 
    18081811    { 
     
    18101813      0x4e => [0x55], 
    18111814    }, 
    1812     exit => [0xaa], 
    18131815    chips => 
    18141816    [ 
     
    18741876  }, 
    18751877  { 
     1878    family => "VIA/Winbond/Fintek", 
    18761879    enter => 
    18771880    { 
     
    18791882      0x4e => [0x87, 0x87], 
    18801883    }, 
    1881     exit => [0xaa], 
    18821884    chips => 
    18831885    [ 
     
    19261928      }, 
    19271929      { 
     1930        name => "Winbond W83627EHF/EHG Super IO Sensors", 
     1931        driver => "w83627ehf", 
     1932        # W83627EHF datasheet says 0x886x but 0x8853 was seen, thus the 
     1933        # broader mask. W83627EHG was seen with ID 0x8863. 
     1934        devid => 0x8840, 
     1935        devid_mask => 0xFFC0, 
     1936        logdev => 0x0b, 
     1937      }, 
     1938      { 
     1939        name => "Winbond W83627DHG Super IO Sensors", 
     1940        driver => "w83627ehf", 
     1941        devid => 0xA020, 
     1942        devid_mask => 0xFFF0, 
     1943        logdev => 0x0b, 
     1944      }, 
     1945      { 
    19281946        name => "Winbond W83L517D Super IO", 
    19291947        driver => "not-a-sensor", 
     
    19491967    ], 
    19501968  }, 
    1951   { 
    1952     enter => 
    1953     { 
    1954       0x2e => [0x87, 0x87], 
    1955       0x4e => [0x87, 0x87], 
    1956     }, 
    1957     chips => 
    1958     [ 
    1959       { 
    1960         name => "Winbond W83627EHF/EHG Super IO Sensors", 
    1961         driver => "w83627ehf", 
    1962         # W83627EHF datasheet says 0x886x but 0x8853 was seen, thus the 
    1963         # broader mask. W83627EHG was seen with ID 0x8863. 
    1964         devid => 0x8840, 
    1965         devid_mask => 0xFFC0, 
    1966         logdev => 0x0b, 
    1967       }, 
    1968       { 
    1969         name => "Winbond W83627DHG Super IO Sensors", 
    1970         driver => "w83627ehf", 
    1971         devid => 0xA020, 
    1972         devid_mask => 0xFFF0, 
    1973         logdev => 0x0b, 
    1974       }, 
    1975     ] 
    1976   } 
    19771969); 
    19781970 
     
    29002892} 
    29012893 
     2894use vars qw(%superio); 
     2895 
     2896%superio = ( 
     2897  devidreg => 0x20, 
     2898  logdevreg => 0x07, 
     2899  actreg => 0x30, 
     2900  actmask => 0x01, 
     2901  basereg => 0x60, 
     2902); 
     2903 
    29022904sub exit_superio 
    29032905{ 
    2904   my ($addrreg, $datareg, $family, $success) = @_; 
    2905  
    2906   # If detection succeeded and an exit sequence exists, use it 
    2907   if ($success && defined ($family->{exit})) { 
    2908     foreach my $byte (@{$family->{exit}}) { 
    2909       outb($addrreg, $byte); 
    2910     } 
    2911     return; 
    2912   } 
    2913  
    2914   # Else return to "Wait For Key" state (PNP-ISA spec) 
     2906  my ($addrreg, $datareg) = @_; 
     2907 
     2908  # Some chips (SMSC, Winbond) want this 
     2909  outb($addrreg, 0xaa); 
     2910 
     2911  # Return to "Wait For Key" state (PNP-ISA spec) 
    29152912  outb($addrreg, 0x02); 
    29162913  outb($datareg, 0x02); 
     2914} 
     2915 
     2916sub probe_superio($$$) 
     2917{ 
     2918  my ($addrreg, $datareg, $chip) = @_; 
     2919  my ($val, $addr); 
     2920 
     2921  printf "\%-60s",  "Found `$chip->{name}'"; 
     2922 
     2923  # Does it have hardware monitoring capabilities? 
     2924  if (!exists $chip->{driver}) { 
     2925    print "\n    (no information available)\n"; 
     2926    return; 
     2927  } 
     2928  if ($chip->{driver} eq "not-a-sensor") { 
     2929    print "\n    (no hardware monitoring capabilities)\n"; 
     2930    return; 
     2931  } 
     2932 
     2933  # Switch to the sensor logical device 
     2934  outb($addrreg, $superio{logdevreg}); 
     2935  outb($datareg, $chip->{logdev}); 
     2936 
     2937  # Check the activation register 
     2938  outb($addrreg, $superio{actreg}); 
     2939  $val = inb($datareg); 
     2940  if (!($val & $superio{actmask})) { 
     2941    print "\n    (but not activated)\n"; 
     2942    return; 
     2943  } 
     2944 
     2945  # Get the IO base register 
     2946  outb($addrreg, $superio{basereg}); 
     2947  $addr = inb($datareg); 
     2948  outb($addrreg, $superio{basereg} + 1); 
     2949  $addr = ($addr << 8) | inb($datareg); 
     2950  if ($addr == 0) { 
     2951    print "\n    (but no address specified)\n"; 
     2952    return; 
     2953  } 
     2954  print "Success!\n"; 
     2955  printf "    (address 0x\%x, driver `%s')\n", $addr, $chip->{driver}; 
     2956  my $new_hash = { conf => 9, 
     2957                   isa_addr => $addr, 
     2958                   chipname => $chip->{name} 
     2959                 }; 
     2960  add_isa_to_chips_detected $chip->{alias_detect},$chip->{driver}, 
     2961                                        $new_hash; 
    29172962} 
    29182963 
     
    29272972{ 
    29282973  my ($addrreg, $datareg) = @_; 
    2929   my ($val, $addr, $name); 
    2930  
    2931   my %superio = ( 
    2932     devidreg => 0x20, 
    2933     logdevreg => 0x07, 
    2934     actreg => 0x30, 
    2935     actmask => 0x01, 
    2936     basereg => 0x60, 
    2937   ); 
    2938    
     2974  my ($val, $found); 
     2975 
    29392976  printf("Probing for Super-I/O at 0x\%x/0x\%x\n", $addrreg, $datareg); 
    29402977 
    29412978  FAMILY:  
    29422979  foreach my $family (@superio_ids) { 
     2980    printf("\%-60s", "Trying family `$family->{family}'... "); 
    29432981# write the password 
    29442982    foreach $val (@{$family->{enter}->{$addrreg}}) { 
    29452983      outb($addrreg, $val); 
    29462984    } 
     2985# did it work? 
     2986    outb($addrreg, $superio{devidreg}); 
     2987    $val = inb($datareg); 
     2988    outb($addrreg, $superio{devidreg} + 1); 
     2989    $val = ($val << 8) | inb($datareg); 
     2990    if ($val == 0x0000 || $val == 0xffff) { 
     2991      print "No\n"; 
     2992      next FAMILY; 
     2993    } 
     2994    print "Yes\n"; 
     2995 
     2996    $found = 0; 
    29472997    foreach my $chip (@{$family->{chips}}) { 
    2948       $name = $chip->{name}; 
    2949       $name =~ s/ Super IO//; 
    2950       printf("\%-60s", sprintf("Probing for `\%s'... ", $name)); 
    2951 # check the device ID 
    2952       outb($addrreg, $superio{devidreg}); 
    2953       $val = inb($datareg); 
    2954       if ($val == 0x00 || $val == 0xff) { 
    2955         print "No\n"; 
    2956         exit_superio($addrreg, $datareg, $family, 0); 
    2957         next FAMILY; 
     2998      if (($chip->{devid} > 0xff && ($val & ($chip->{devid_mask} || 0xffff)) == $chip->{devid}) 
     2999       || ($chip->{devid} <= 0xff && ($val >> 8) == $chip->{devid})) { 
     3000        probe_superio($addrreg, $datareg, $chip); 
     3001        $found++; 
    29583002      } 
    2959       if ($chip->{devid}>0xff) { 
    2960         outb($addrreg, $superio{devidreg} + 1); 
    2961         $val = ($val << 8) | inb($datareg); 
    2962       } 
    2963       if (($val & ($chip->{devid_mask} || 0xffff)) != $chip->{devid}) { 
    2964         printf "No (0x%0*x)\n", $chip->{devid}>0xff ? 4 : 2, $val; 
    2965         next; 
    2966       } 
    2967       print "Success!\n"; 
    2968 # does it have hardware monitoring capabilities 
    2969       if (!exists $chip->{driver}) { 
    2970         print "    (no information available)\n"; 
    2971         next; 
    2972       } 
    2973       if($chip->{driver} eq "not-a-sensor") { 
    2974         print "    (no hardware monitoring capabilities)\n"; 
    2975         next; 
    2976       } 
    2977 # switch to the sensor logical device 
    2978       outb($addrreg, $superio{logdevreg}); 
    2979       outb($datareg, $chip->{logdev}); 
    2980 # check the activation register 
    2981       outb($addrreg, $superio{actreg}); 
    2982       $val = inb($datareg); 
    2983       if(!($val & $superio{actmask})) { 
    2984         print "    (but not activated)\n"; 
    2985         next; 
    2986       } 
    2987 # Get the IO base register 
    2988       outb($addrreg, $superio{basereg}); 
    2989       $addr = inb($datareg); 
    2990       outb($addrreg, $superio{basereg} + 1); 
    2991       $addr = ($addr << 8) | inb($datareg); 
    2992       if($addr == 0) { 
    2993         print "    (but no address specified)\n"; 
    2994         next; 
    2995       }          
    2996       printf "    (address 0x\%x, driver `%s')\n", $addr, $chip->{driver}; 
    2997       my $new_hash = { conf => 9, 
    2998                        isa_addr => $addr, 
    2999                        chipname => $chip->{name} 
    3000                      }; 
    3001       add_isa_to_chips_detected $chip->{alias_detect},$chip->{driver}, 
    3002                                             $new_hash; 
    30033003    } 
    3004     exit_superio($addrreg, $datareg, $family, 1); 
     3004 
     3005    printf("  Found unknown chip with ID 0x%04x\n", $val) 
     3006        unless $found; 
     3007    exit_superio($addrreg, $datareg); 
    30053008  } 
    30063009} 
     
    52085211       #check return value from modprobe in case modprobe -l isn't supported 
    52095212       if((($? >> 8) == 0) && ! $modulefound) { 
    5210          $modprobes .= "# Warning: the required module $chip->{driver} is not currently installed on your system.\n"; 
    5211          $modprobes .= "# For status of 2.6 kernel ports see http://www.lm-sensors.org/wiki/SupportedDevices\n"; 
    5212          $modprobes .= "# If driver is built-in to the kernel, or unavailable, comment out the following line.\n"; 
     5213         $modprobes .= "# Warning: the required module $chip->{driver} is not currently installed on\n". 
     5214                       "# your system. For status of 2.6 kernel ports see\n". 
     5215                       "# http://www.lm-sensors.org/wiki/SupportedDevices and\n". 
     5216                       "# http://www.lm-sensors.org/wiki/SupportedDevices. If driver is built\n". 
     5217                       "# into the kernel, or unavailable, comment out the following line.\n"; 
    52135218       } 
    52145219       $modprobes .= "modprobe $chip->{driver}\n";