- Timestamp:
- 04/03/07 14:55:30 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect
r4271 r4357 48 48 ######################### 49 49 50 use vars qw(@pci_adapters @chip_ids @superio_ids @cpu_ids $revision); 50 use vars qw(@pci_adapters @chip_ids $i2c_addresses_to_scan @superio_ids 51 @cpu_ids $revision); 51 52 52 53 $revision = '$Revision$ ($Date$)'; … … 247 248 } , 248 249 { 250 vendid => 0x1106, 251 devid => 0x8324, 252 procid => "VIA Technologies CX700 South Bridge", 253 driver => "i2c-viapro", 254 match => qr/^SMBus V(IA|ia) Pro adapter at/, 255 }, 256 { 249 257 vendid => 0x1039, 250 258 devid => 0x5597, … … 530 538 devid => 0x03eb, 531 539 procid => "nVidia Corporation nForce4 SMBus (MCP61)", 532 driver => " to-be-tested",540 driver => "i2c-nforce2", 533 541 match => qr/^SMBus nForce2 adapter at /, 534 542 }, … … 537 545 devid => 0x0446, 538 546 procid => "nVidia Corporation nForce4 SMBus (MCP65)", 539 driver => " to-be-tested",547 driver => "i2c-nforce2", 540 548 match => qr/^SMBus nForce2 adapter at /, 541 549 }, … … 812 820 driver => "lm75", 813 821 i2c_addrs => [0x48..0x4f], 814 i2c_detect => sub { lm75_detect(@_); }, 815 } , 822 i2c_detect => sub { lm75_detect(0, @_); }, 823 }, 824 { 825 name => "Dallas Semiconductor DS75", 826 driver => "lm75", 827 i2c_addrs => [0x48..0x4f], 828 i2c_detect => sub { lm75_detect(1, @_); }, 829 }, 816 830 { 817 831 name => "National Semiconductor LM77", … … 968 982 { 969 983 name => "Winbond W83627HF", 970 driver => " w83781d",971 i2c_addrs => [0x2 0..0x2f],984 driver => "use-isa-instead", 985 i2c_addrs => [0x28..0x2f], 972 986 i2c_detect => sub { w83781d_detect(3, @_); }, 973 isa_addrs => [0x290], 974 isa_detect => sub { w83781d_isa_detect(3, @_); }, 975 alias_detect => sub { w83781d_alias_detect(3, @_); }, 976 } , 987 }, 977 988 { 978 989 name => "Winbond W83627EHF", … … 1138 1149 }, 1139 1150 { 1151 name => "Maxim MAX1668", 1152 driver => "max1668", 1153 i2c_addrs => [0x18..0x1a,0x29..0x2b,0x4c..0x4e], 1154 i2c_detect => sub { max1668_detect(0, @_); }, 1155 }, 1156 { 1157 name => "Maxim MAX1805", 1158 driver => "max1668", 1159 i2c_addrs => [0x18..0x1a,0x29..0x2b,0x4c..0x4e], 1160 i2c_detect => sub { max1668_detect(1, @_); }, 1161 }, 1162 { 1163 name => "Maxim MAX1989", 1164 driver => "max1668", 1165 i2c_addrs => [0x18..0x1a,0x29..0x2b,0x4c..0x4e], 1166 i2c_detect => sub { max1668_detect(2, @_); }, 1167 }, 1168 { 1140 1169 name => "Maxim MAX6650/MAX6651", 1141 1170 driver => "max6650", … … 1144 1173 }, 1145 1174 { 1175 name => "Maxim MAX6655/MAX6656", 1176 driver => "max6655", 1177 i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e], 1178 i2c_detect => sub { max6655_detect(0, @_); }, 1179 }, 1180 { 1146 1181 name => "TI THMC10", 1147 1182 driver => "adm1021", … … 1353 1388 i2c_detect => sub { eeprom_detect(1, @_); }, 1354 1389 }, 1355 # Disabled by default (potentially dangerous)1356 # {1357 # name => "SPD EEPROM with Software Write-Protect",1358 # driver => "eeprom",1359 # i2c_addrs => [0x50..0x57],1360 # i2c_detect => sub { eeprom_detect(2, @_); },1361 # },1362 1390 { 1363 1391 name => "EDID EEPROM", … … 1391 1419 }, 1392 1420 { 1393 name => "SMSC LPC47M15x , LPC47M192 or LPC47M997",1421 name => "SMSC LPC47M15x/192/292/997", 1394 1422 driver => "smsc47m192", 1395 1423 i2c_addrs => [0x2c..0x2d], … … 1398 1426 { 1399 1427 name => "SMSC DME1737", 1400 driver => " to-be-written",1428 driver => "dme1737", 1401 1429 i2c_addrs => [0x2c..0x2e], 1402 1430 i2c_detect => sub { dme1737_detect(@_); }, … … 1470 1498 { 1471 1499 name => "Maxim MAX6900", 1472 driver => " to-be-written",1500 driver => "not-a-sensor", 1473 1501 i2c_addrs => [0x50], 1474 1502 i2c_detect => sub { max6900_detect(@_); }, 1475 },1476 {1477 name => "SMBus 2.0 ARP-Capable Device",1478 driver => "not-a-sensor",1479 i2c_addrs => [0x61],1480 i2c_detect => sub { arp_detect(@_); },1481 1503 }, 1482 1504 { … … 1537 1559 # capabilities (listing such chips here removes the need of manual 1538 1560 # lookup when people report them). 1561 # Put in exactly "via-smbus-only" if this is a Super-I/O chip whose 1562 # hardware monitoring registers can only be accessed via the SMBus. 1539 1563 # devid: The device ID(s) we have to match (base device) 1540 1564 # devid_mask (optional): Bitmask to apply before checking the device ID … … 1550 1574 # enter: The password sequence to write to the address register 1551 1575 # chips: Array of chips 1576 # The order of families matters, because we stop as soon as one family 1577 # succeeds. So we have to list families with shorter password sequences 1578 # first. 1552 1579 @superio_ids = ( 1553 {1554 family => "ITE",1555 guess => 0x290,1556 enter =>1557 {1558 0x2e => [0x87, 0x01, 0x55, 0x55],1559 0x4e => [0x87, 0x01, 0x55, 0xaa],1560 },1561 chips =>1562 [1563 {1564 name => "ITE IT8702F Super IO Sensors",1565 driver => "to-be-written",1566 devid => 0x8702,1567 logdev => 0x04,1568 },1569 {1570 name => "ITE IT8705F Super IO Sensors",1571 driver => "it87",1572 devid => 0x8705,1573 logdev => 0x04,1574 },1575 {1576 name => "ITE IT8712F Super IO Sensors",1577 driver => "it87",1578 devid => 0x8712,1579 logdev => 0x04,1580 alias_detect => sub { ite_alias_detect(0, @_); },1581 },1582 {1583 name => "ITE IT8716F Super IO Sensors",1584 driver => "it87",1585 devid => 0x8716,1586 logdev => 0x04,1587 },1588 {1589 name => "ITE IT8718F Super IO Sensors",1590 driver => "it87",1591 devid => 0x8718,1592 logdev => 0x04,1593 },1594 ],1595 },1596 1580 { 1597 1581 family => "National Semiconductor", … … 1603 1587 chips => 1604 1588 [ 1589 { 1590 name => "Nat. Semi. PC8374L Super IO Sensors", 1591 driver => "to-be-written", 1592 devid => 0xf1, 1593 logdev => 0x08, 1594 }, 1605 1595 { 1606 1596 name => "Nat. Semi. PC87351 Super IO Fan Sensors", … … 1749 1739 }, 1750 1740 { 1741 name => "SMSC LPC47M292 Super IO Fan Sensors", 1742 driver => "smsc47m1", 1743 devid => 0x6b, 1744 logdev => 0x0a, 1745 }, 1746 { 1751 1747 name => "SMSC LPC47S42x Super IO Fan Sensors", 1752 1748 driver => "to-be-written", … … 1785 1781 }, 1786 1782 { 1783 name => "SMSC SCH5504-NS Super IO", 1784 # No datasheet 1785 driver => "not-a-sensor", 1786 devid => 0x79, 1787 }, 1788 { 1787 1789 name => "SMSC LPC47M584-NC Super IO", 1788 1790 # No datasheet … … 1792 1794 name => "SMSC DME1737 Super IO", 1793 1795 # Hardware monitoring features are accessed on the SMBus 1794 driver => " not-a-sensor",1796 driver => "via-smbus-only", 1795 1797 devid => 0x78, 1798 }, 1799 { 1800 name => "SMSC DME1737 Super IO", 1801 # The DME1737 shows up twice in this list because it can return either 1802 # 0x78 or 0x77 as its device ID. 1803 # Hardware monitoring features are accessed on the SMBus 1804 driver => "via-smbus-only", 1805 devid => 0x77, 1796 1806 }, 1797 1807 ], … … 1819 1829 devid => 0x52, 1820 1830 logdev => 0x0b, 1831 alias_detect => sub { w83781d_alias_detect(3, @_); }, 1821 1832 }, 1822 1833 { … … 1904 1915 ], 1905 1916 }, 1917 { 1918 family => "ITE", 1919 guess => 0x290, 1920 enter => 1921 { 1922 0x2e => [0x87, 0x01, 0x55, 0x55], 1923 0x4e => [0x87, 0x01, 0x55, 0xaa], 1924 }, 1925 chips => 1926 [ 1927 { 1928 name => "ITE IT8702F Super IO Sensors", 1929 driver => "to-be-written", 1930 devid => 0x8702, 1931 logdev => 0x04, 1932 }, 1933 { 1934 name => "ITE IT8705F Super IO Sensors", 1935 driver => "it87", 1936 devid => 0x8705, 1937 logdev => 0x04, 1938 }, 1939 { 1940 name => "ITE IT8712F Super IO Sensors", 1941 driver => "it87", 1942 devid => 0x8712, 1943 logdev => 0x04, 1944 alias_detect => sub { ite_alias_detect(0, @_); }, 1945 }, 1946 { 1947 name => "ITE IT8716F Super IO Sensors", 1948 driver => "it87", 1949 devid => 0x8716, 1950 logdev => 0x04, 1951 }, 1952 { 1953 name => "ITE IT8718F Super IO Sensors", 1954 driver => "it87", 1955 devid => 0x8718, 1956 logdev => 0x04, 1957 }, 1958 ], 1959 }, 1906 1960 ); 1907 1961 … … 2478 2532 { 2479 2533 my ($file,$addr) = @_; 2534 $addr += 0; # Make sure it's a number not a string 2480 2535 ioctl $file, IOCTL_I2C_SLAVE, $addr or return 0; 2481 2536 return 1; … … 2820 2875 } 2821 2876 2877 # From the list of known I2C/SMBus devices, build a list of I2C addresses 2878 # which are worth probing. There's no point in probing an address for which 2879 # we don't know a single device, and probing some addresses has caused 2880 # random trouble in the past. 2881 sub i2c_addresses_to_scan() 2882 { 2883 my @used; 2884 my @addresses; 2885 my $addr; 2886 2887 foreach my $chip (@chip_ids) { 2888 next unless defined $chip->{'i2c_addrs'}; 2889 next if $chip->{'driver'} eq 'not-a-sensor'; 2890 foreach $addr (@{$chip->{'i2c_addrs'}}) { 2891 $used[$addr]++; 2892 } 2893 } 2894 2895 for ($addr = 0x03; $addr <= 0x77; $addr++) { 2896 push @addresses, $addr if $used[$addr]; 2897 } 2898 return \@addresses; 2899 } 2900 2822 2901 # $_[0]: The number of the adapter to scan 2823 2902 # $_[1]: The name of the adapter, as appearing in /proc/bus/i2c … … 2852 2931 2853 2932 # Now scan each address in turn 2854 foreach $addr ( 0x03..0x77) {2933 foreach $addr (@{$i2c_addresses_to_scan}) { 2855 2934 # As the not_to_scan list is sorted, we can check it fast 2856 2935 if (@not_to_scan and $not_to_scan[0] == $addr) { … … 2901 2980 printf "Client found at address 0x%02x\n",$addr; 2902 2981 2982 $| = 1; 2903 2983 foreach $chip (@chip_ids) { 2904 2984 if (exists $chip->{i2c_addrs} and contains $addr, @{$chip->{i2c_addrs}}) { … … 2932 3012 } 2933 3013 } 3014 $| = 0; 2934 3015 } 2935 3016 } … … 2938 3019 { 2939 3020 my ($chip,$addr,$conf); 3021 $| = 1; 2940 3022 foreach $chip (@chip_ids) { 2941 3023 next if not exists $chip->{isa_addrs} or not exists $chip->{isa_detect}; … … 2959 3041 } 2960 3042 } 3043 $| = 0; 2961 3044 } 2962 3045 … … 3038 3121 return; 3039 3122 } 3123 if ($chip->{driver} eq "via-smbus-only") { 3124 print "\n (hardware monitoring capabilities accessible via SMBus only)\n"; 3125 return; 3126 } 3040 3127 3041 3128 # Switch to the sensor logical device … … 3077 3164 printf("Probing for Super-I/O at 0x\%x/0x\%x\n", $addrreg, $datareg); 3078 3165 3166 $| = 1; 3167 # reset state to avoid false positives 3168 exit_superio($addrreg, $datareg); 3079 3169 FAMILY: 3080 3170 foreach my $family (@superio_ids) { … … 3100 3190 || ($chip->{devid} <= 0xff && ($val >> 8) == $chip->{devid})) { 3101 3191 probe_superio($addrreg, $datareg, $chip); 3102 $found++;3192 $found++; 3103 3193 } 3104 3194 } … … 3112 3202 3113 3203 exit_superio($addrreg, $datareg); 3114 } 3204 last FAMILY; 3205 } 3206 $| = 0; 3115 3207 } 3116 3208 … … 3171 3263 3172 3264 # $_[0]: A reference to the file descriptor to access this chip. 3173 # We may assume an i2c_set_slave_addr was already done.3174 3265 # $_[1]: Address 3175 3266 # Returns: undef if not detected, (7) if detected. … … 3184 3275 # $_[0]: Chip to detect (0 = LM78, 1 = LM78-J, 2 = LM79) 3185 3276 # $_[1]: A reference to the file descriptor to access this chip. 3186 # We may assume an i2c_set_slave_addr was already done.3187 3277 # $_[2]: Address 3188 3278 # Returns: undef if not detected, (6) if detected. … … 3217 3307 inb ($addr + 7) != $val; 3218 3308 3219 $val = inb($addr + 5) & 0x7f;3220 outb($addr + 5, ~$val & 0x ff);3309 $val = inb($addr + 5); 3310 outb($addr + 5, ~$val & 0x7f); 3221 3311 if ((inb ($addr+5) & 0x7f) != (~ $val & 0x7f)) { 3222 3312 outb($addr+5,$val); … … 3230 3320 ($chip == 2 and ($reg & 0xfe) == 0xc0); 3231 3321 3232 # Explicit ely prevent misdetection of Winbond chips3322 # Explicitly prevent misdetection of Winbond chips 3233 3323 $reg = &$readproc(0x4f); 3234 3324 return if $reg == 0xa3 || $reg == 0x5c; 3235 3325 3236 # Explicit ely prevent misdetection of ITE chips3326 # Explicitly prevent misdetection of ITE chips 3237 3327 $reg = &$readproc(0x58); 3238 3328 return if $reg == 0x90; … … 3258 3348 } 3259 3349 3260 # $_[0]: A reference to the file descriptor to access this chip.3261 # We assume an i2c_set_slave_addr was already done.3262 # $_[ 1]: Address3350 # $_[0]: Chip to detect (0 = LM75, 1 = DS75) 3351 # $_[1]: A reference to the file descriptor to access this chip. 3352 # $_[2]: Address (unused) 3263 3353 # Returns: undef if not detected, 3 or 6 if detected; 3264 3354 # 6 means that the temperatures make sense; … … 3276 3366 # documented. 3277 3367 # Note that register 0x00 may change, so we can't use the modulo trick on it. 3368 # The DS75 is a bit different, it doesn't cycle over 8-byte boundaries, and 3369 # all register addresses from 0x04 to 0x0f behave like 0x04-0x07 do for 3370 # the LM75. 3278 3371 sub lm75_detect 3279 3372 { 3280 3373 my $i; 3281 my ($ file,$addr) = @_;3374 my ($chip, $file, $addr) = @_; 3282 3375 my $cur = i2c_smbus_read_word_data($file,0x00); 3283 my $cur_varies = 0;3284 3376 my $conf = i2c_smbus_read_byte_data($file,0x01); 3285 3377 3286 3378 my $hyst = i2c_smbus_read_word_data($file,0x02); 3287 return if i2c_smbus_read_word_data($file,0x04) != $hyst;3288 return if i2c_smbus_read_word_data($file,0x05) != $hyst;3289 return if i2c_smbus_read_word_data($file,0x06) != $hyst;3290 return if i2c_smbus_read_word_data($file,0x07) != $hyst;3379 my $maxreg = $chip == 1 ? 0x0f : 0x07; 3380 for $i (0x04 .. $maxreg) { 3381 return if i2c_smbus_read_word_data($file, $i) != $hyst; 3382 } 3291 3383 3292 3384 my $os = i2c_smbus_read_word_data($file,0x03); 3293 return if i2c_smbus_read_word_data($file,0x04) != $os; 3294 return if i2c_smbus_read_word_data($file,0x05) != $os; 3295 return if i2c_smbus_read_word_data($file,0x06) != $os; 3296 return if i2c_smbus_read_word_data($file,0x07) != $os; 3297 3298 for ($i = 0x00; $i < 0xff; $i += 8) { 3299 return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf; 3300 return if i2c_smbus_read_word_data($file, $i + 0x02) != $hyst; 3301 return if i2c_smbus_read_word_data($file, $i + 0x04) != $hyst; 3302 return if i2c_smbus_read_word_data($file, $i + 0x05) != $hyst; 3303 return if i2c_smbus_read_word_data($file, $i + 0x06) != $hyst; 3304 return if i2c_smbus_read_word_data($file, $i + 0x07) != $hyst; 3305 return if i2c_smbus_read_word_data($file, $i + 0x03) != $os; 3306 return if i2c_smbus_read_word_data($file, $i + 0x04) != $os; 3307 return if i2c_smbus_read_word_data($file, $i + 0x05) != $os; 3308 return if i2c_smbus_read_word_data($file, $i + 0x06) != $os; 3309 return if i2c_smbus_read_word_data($file, $i + 0x07) != $os; 3310 $cur_varies = 1 3311 if (! $cur_varies) and 3312 i2c_smbus_read_word_data($file, $i) != $cur; 3385 for $i (0x04 .. $maxreg) { 3386 return if i2c_smbus_read_word_data($file, $i) != $os; 3387 } 3388 3389 if ($chip == 0) { 3390 for ($i = 8; $i <= 248; $i += 40) { 3391 return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf 3392 or i2c_smbus_read_word_data($file, $i + 0x02) != $hyst 3393 or i2c_smbus_read_word_data($file, $i + 0x03) != $os; 3394 } 3313 3395 } 3314 3396 3315 3397 # All registers hold the same value, obviously a misdetection 3316 return if (! $cur_varies) and$conf == ($cur & 0xff) and $cur == $hyst3398 return if $conf == ($cur & 0xff) and $cur == $hyst 3317 3399 and $cur == $os; 3318 3400 … … 3321 3403 $os = swap_bytes($os); 3322 3404 # Unused bits 3323 return if ($conf & 0xe0); 3405 return if $chip == 0 and ($conf & 0xe0); 3406 return if $chip == 1 and ($conf & 0x80); 3324 3407 3325 3408 $cur = $cur >> 8; … … 3333 3416 3334 3417 # $_[0]: A reference to the file descriptor to access this chip. 3335 # We assume an i2c_set_slave_addr was already done.3336 3418 # $_[1]: Address 3337 3419 # Returns: undef if not detected, 3 or 6 if detected; … … 3357 3439 my ($file,$addr) = @_; 3358 3440 my $cur = i2c_smbus_read_word_data($file,0x00); 3359 my $cur_varies = 0;3360 3441 my $conf = i2c_smbus_read_byte_data($file,0x01); 3361 3442 my $hyst = i2c_smbus_read_word_data($file,0x02); … … 3370 3451 return if i2c_smbus_read_word_data($file,0x07) != $high; 3371 3452 3372 for ($i = 0x00; $i < 0xff; $i += 8) {3453 for ($i = 8; $i <= 248; $i += 40) { 3373 3454 return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf; 3374 3455 return if i2c_smbus_read_word_data($file, $i + 0x02) != $hyst; 3375 3456 return if i2c_smbus_read_word_data($file, $i + 0x03) != $os; 3376 3457 return if i2c_smbus_read_word_data($file, $i + 0x04) != $low; 3377 return if i2c_smbus_read_word_data($file, $i + 0x06) != $low;3378 return if i2c_smbus_read_word_data($file, $i + 0x07) != $low;3379 3458 return if i2c_smbus_read_word_data($file, $i + 0x05) != $high; 3380 return if i2c_smbus_read_word_data($file, $i + 0x06) != $high;3381 return if i2c_smbus_read_word_data($file, $i + 0x07) != $high;3382 $cur_varies = 13383 if (! $cur_varies) and3384 i2c_smbus_read_word_data($file, $i) != $cur;3385 3459 } 3386 3460 3387 3461 # All registers hold the same value, obviously a misdetection 3388 return if (! $cur_varies) and$conf == ($cur & 0xff) and $cur == $hyst3462 return if $conf == ($cur & 0xff) and $cur == $hyst 3389 3463 and $cur == $os and $cur == $low and $cur == $high; 3390 3464 … … 3416 3490 # $_[0]: Chip to detect (0 = LM92, 1 = LM76, 2 = MAX6633/MAX6634/MAX6635) 3417 3491 # $_[1]: A reference to the file descriptor to access this chip. 3418 # We may assume an i2c_set_slave_addr was already done.3419 3492 # $_[2]: Address 3420 3493 # Returns: undef if not detected, 2 or 4 if detected; … … 3466 3539 3467 3540 # $_[0]: A reference to the file descriptor to access this chip. 3468 # We may assume an i2c_set_slave_addr was already done.3469 3541 # $_[1]: Address 3470 3542 # Returns: undef if not detected, 3 if detected … … 3493 3565 3494 3566 # $_[0]: A reference to the file descriptor to access this chip. 3495 # We may assume an i2c_set_slave_addr was already done.3496 3567 # $_[1]: Address 3497 3568 # Returns: undef if not detected, 1 to 3 if detected. … … 3556 3627 # (0 = LM82/LM83) 3557 3628 # $_[1]: A reference to the file descriptor to access this chip. 3558 # We may assume an i2c_set_slave_addr was already done.3559 3629 # $_[2]: Address 3560 3630 # Returns: undef if not detected, 4 to 8 if detected. … … 3598 3668 # 5 = ADT7461, 6 = MAX6648/MAX6692) 3599 3669 # $_[1]: A reference to the file descriptor to access this chip. 3600 # We may assume an i2c_set_slave_addr was already done.3601 3670 # $_[2]: Address 3602 3671 # Returns: undef if not detected, 4, 6 or 8 if detected. … … 3671 3740 # (1 = LM63, 2 = F75363SG) 3672 3741 # $_[1]: A reference to the file descriptor to access this chip. 3673 # We may assume an i2c_set_slave_addr was already done.3674 3742 # $_[2]: Address (unused) 3675 3743 # Returns: undef if not detected, 8 if detected. … … 3752 3820 # (0 = ADM1030, 1=ADM1031) 3753 3821 # $_[1]: A reference to the file descriptor to access this chip. 3754 # We may assume an i2c_set_slave_addr was already done.3755 3822 # $_[2]: Address 3756 3823 # Returns: undef if not detected, 3 to 7 (ADM1031) or 9 (ADM1030) … … 3838 3905 # 4 = ADT7470) 3839 3906 # $_[1]: A reference to the file descriptor to access this chip. 3840 # We may assume an i2c_set_slave_addr was already done.3841 3907 # $_[2]: Address 3842 3908 # Returns: undef if not detected, 5 or 7 if detected. … … 4006 4072 4007 4073 # $_[0]: A reference to the file descriptor to access this chip. 4008 # We may assume an i2c_set_slave_addr was already done.4009 4074 # $_[1]: Address 4010 4075 # Returns: undef if not detected, (7) if detected. … … 4024 4089 # 8 = W83792D, 9 = W83627EHF 10 = W83627DHG) 4025 4090 # $_[1]: A reference to the file descriptor to access this chip. 4026 # We may assume an i2c_set_slave_addr was already done.4027 4091 # $_[2]: Address 4028 4092 # Returns: undef if not detected, (8,addr1,addr2) if detected, but only … … 4123 4187 4124 4188 # $_[0]: A reference to the file descriptor to access this chip. 4125 # We assume an i2c_set_slave_addr was already done.4126 4189 # $_[1]: Address 4127 4190 # Returns: undef if not detected, 3 if detected … … 4197 4260 } 4198 4261 4199 # $_[0]: Chip to detect (0 = W83781D, 1 = W83782D , 3 = W83627HF)4262 # $_[0]: Chip to detect (0 = W83781D, 1 = W83782D) 4200 4263 # $_[1]: Address 4201 4264 # Returns: undef if not detected, (8) if detected. … … 4208 4271 inb ($addr + 7) != $val; 4209 4272 4210 $val = inb($addr + 5) & 0x7f;4211 outb($addr+5, ~$val & 0x ff);4273 $val = inb($addr + 5); 4274 outb($addr+5, ~$val & 0x7f); 4212 4275 if ((inb ($addr+5) & 0x7f) != (~ $val & 0x7f)) { 4213 4276 outb($addr+5,$val); … … 4224 4287 return if $chip == 0 and ($reg1 & 0xfe) != 0x10; 4225 4288 return if $chip == 1 and ($reg1 & 0xfe) != 0x30; 4226 return if $chip == 3 and ($reg1 & 0xfe) != 0x20;4227 4289 4228 4290 return 8; … … 4231 4293 # $_[0]: Chip to detect (0 = Revision 0x00, 1 = Revision 0x80) 4232 4294 # $_[1]: A reference to the file descriptor to access this chip. 4233 # We may assume an i2c_set_slave_addr was already done.4234 4295 # $_[2]: Address 4235 4296 # Returns: undef if not detected, (6) if detected. … … 4252 4313 4253 4314 # $_[0]: A reference to the file descriptor to access this chip. 4254 # We may assume an i2c_set_slave_addr was already done.4255 4315 # $_[1]: Address 4256 4316 # Returns: undef if not detected, (5) if detected. … … 4271 4331 4272 4332 # $_[0]: A reference to the file descriptor to access this chip. 4273 # We may assume an i2c_set_slave_addr was already done.4274 4333 # $_[1]: Address 4275 4334 # Returns: undef if not detected, (5) if detected. … … 4286 4345 # $_[0]: Chip to detect (0 = ADM9240, 1 = DS1780, 2 = LM81) 4287 4346 # $_[1]: A reference to the file descriptor to access this chip. 4288 # We may assume an i2c_set_slave_addr was already done.4289 4347 # $_[2]: Address 4290 4348 # Returns: undef if not detected, (7) if detected. … … 4310 4368 # $_[0]: Chip to detect (0 = ADM1022, 1 = THMC50, 2 = ADM1028) 4311 4369 # $_[1]: A reference to the file descriptor to access this chip. 4312 # We may assume an i2c_set_slave_addr was already done.4313 4370 # $_[2]: Address 4314 4371 # Returns: undef if not detected, (8) if detected. … … 4327 4384 ($chip == 2 and $reg == 0x41); 4328 4385 return unless (i2c_smbus_read_byte_data($file,0x40) & 0x80) == 0x00; 4329 $reg = i2c_smbus_read_byte_data($file, 0x3f) ;4330 return unless ($ reg & 0xc0) == 0xc0;4331 return if $chip == 0 and ($reg & 0xc0) != 0xc0;4332 return if $chip == 2 and ($reg & 0xc0) == 0xc0;4386 $reg = i2c_smbus_read_byte_data($file, 0x3f) & 0xf0; 4387 return unless ($chip == 0 and $reg == 0xc0) or 4388 ($chip == 1 and $reg == 0xc0) or 4389 ($chip == 2 and $reg == 0xd0); 4333 4390 return (8); 4334 4391 } … … 4336 4393 # $_[0]: Chip to detect (0 = ADM1025, 1 = NE1619) 4337 4394 # $_[1]: A reference to the file descriptor to access this chip. 4338 # We may assume an i2c_set_slave_addr was already done.4339 4395 # $_[2]: Address 4340 4396 # Returns: undef if not detected, (8) if detected. … … 4365 4421 # $_[0]: Chip to detect (0 = ADM1026) 4366 4422 # $_[1]: A reference to the file descriptor to access this chip. 4367 # We may assume an i2c_set_slave_addr was already done.4368 4423 # $_[2]: Address 4369 4424 # Returns: undef if not detected, (8) if detected. … … 4383 4438 # $_[0]: Chip to detect (0 = ADM1024) 4384 4439 # $_[1]: A reference to the file descriptor to access this chip. 4385 # We may assume an i2c_set_slave_addr was already done.4386 4440 # $_[2]: Address 4387 4441 # Returns: undef if not detected, (8) if detected. … … 4405 4459 # 5 = LM84, 6 = GL523, 7 = MC1066) 4406 4460 # $_[1]: A reference to the file descriptor to access this chip. 4407 # We may assume an i2c_set_slave_addr was already done.4408 4461 # $_[2]: Address 4409 4462 # Returns: undef if not detected, 3 if simply detected, 5 if detected and … … 4490 4543 4491 4544 # $_[0]: Chip to detect 4545 # (0 = MAX1668, 1 = MAX1805, 2 = MAX1989) 4546 # $_[1]: A reference to the file descriptor to access this chip. 4547 # We may assume an i2c_set_slave_addr was already done. 4548 # $_[2]: Address 4549 # Returns: undef if not detected, 7 if detected 4550 # Registers used: 4551 # 0xfe: Company ID 4552 # 0xff: Device ID 4553 sub max1668_detect 4554 { 4555 my ($chip, $file, $addr) = @_; 4556 my $man_id = i2c_smbus_read_byte_data($file, 0xfe); 4557 my $dev_id = i2c_smbus_read_byte_data($file, 0xff); 4558 4559 return if $man_id != 0x4d; 4560 return if $chip == 0 and $dev_id != 0x03; 4561 return if $chip == 1 and $dev_id != 0x05; 4562 return if $chip == 2 and $dev_id != 0x0b; 4563 4564 return 7; 4565 } 4566 4567 # $_[0]: Chip to detect 4492 4568 # (0 = MAX1619) 4493 4569 # $_[1]: A reference to the file descriptor to access this chip. 4494 # We may assume an i2c_set_slave_addr was already done.4495 4570 # $_[2]: Address 4496 4571 # Returns: undef if not detected, 7 if detected … … 4541 4616 # $_[0]: Chip to detect (0 = IT8712F) 4542 4617 # $_[1]: A reference to the file descriptor to access this chip. 4543 # We may assume an i2c_set_slave_addr was already done.4544 4618 # $_[2]: Address 4545 4619 # Returns: undef if not detected, 7 or 8 if detected (tops LM78). … … 4579 4653 } 4580 4654 4581 # $_[0]: Chip to detect (0 = SPD EEPROM, 1 = Sony Vaio EEPROM, 4582 # 2 = SPD EEPROM with Software Write Protect) 4655 # $_[0]: Chip to detect (0 = SPD EEPROM, 1 = Sony Vaio EEPROM) 4583 4656 # $_[1]: A reference to the file descriptor to access this chip 4584 4657 # $_[2]: Address 4585 # Returns: 8 for a memory eeprom (9 if write-protect register found), 4586 # 4 to 9 for a Sony Vaio eeprom, 4587 # 1 for an unknown eeprom (2 if write-protect register found) 4658 # Returns: 8 for a memory eeprom 4659 # 4 to 9 for a Sony Vaio eeprom 4588 4660 # Registers used: 4589 4661 # 0-63: SPD Data and Checksum … … 4599 4671 4600 4672 # Check the checksum for validity (works for most DIMMs and RIMMs) 4601 if ($chip != 1) {4602 for (my $i = 0; $i <= 62; $i ++) {4603 $checksum += i2c_smbus_read_byte_data($file,$i);4604 }4605 $checksum &= 255;4606 $checksum -= i2c_smbus_read_byte_data($file,63);4607 }4608 4673 if ($chip == 0) { 4609 if($checksum == 0) { 4610 return 8; 4611 } else { 4612 return 1; 4674 for (my $i = 0; $i <= 62; $i++) { 4675 $checksum += i2c_smbus_read_byte_data($file, $i); 4613 4676 } 4614 } 4615 if ($chip == 2) { 4616 # check for 'shadow' write-protect register at 0x30-0x37 4617 # could be dangerous 4618 i2c_set_slave_addr($file,$addr - 0x20); 4619 if(i2c_smbus_write_quick($file, SMBUS_WRITE) >= 0 && 4620 i2c_smbus_read_byte_data($file,0x80) == -1) { 4621 i2c_set_slave_addr($file,$addr); 4622 if($checksum == 0) { 4623 return (9, $addr - 0x20); 4624 } else { 4625 return (2, $addr - 0x20); 4626 } 4627 } 4628 i2c_set_slave_addr($file,$addr); 4677 $checksum &= 255; 4678 4679 return 8 4680 if $checksum == i2c_smbus_read_byte_data($file, 63); 4629 4681 return; 4630 4682 } … … 4657 4709 4658 4710 # $_[0]: A reference to the file descriptor to access this chip. 4659 # We may assume an i2c_set_slave_addr was already done.4660 4711 # $_[1]: Address 4661 # Returns: undef if not detected, (1)if detected.4712 # Returns: undef if not detected, 8 if detected. 4662 4713 # Registers used: 4663 4714 # 0x00..0x07: DDC signature 4664 # 0x08..0x7E: checksumed area4665 # 0x7F: checksum4666 4715 sub ddcmonitor_detect 4667 4716 { 4668 4717 my ($file,$addr) = @_; 4669 my $i;4670 4718 4671 4719 return unless … … 4679 4727 i2c_smbus_read_byte_data($file,0x07) == 0x00; 4680 4728 4681 # Check the checksum for validity.4682 my $checksum = 0;4683 for ($i = 0; $i <= 127; $i = $i + 1) {4684 $checksum = $checksum + i2c_smbus_read_byte_data($file,$i);4685 }4686 $checksum=$checksum & 255;4687 if ($checksum != 0) {4688 # I have one such monitor...4689 return (2,$addr+1,$addr+2,$addr+3,$addr+4,$addr+5,$addr+6,$addr+7);4690 }4691 4729 return (8,$addr+1,$addr+2,$addr+3,$addr+4,$addr+5,$addr+6,$addr+7); 4692 4730 } 4693 4731 4694 4732 # $_[0]: A reference to the file descriptor to access this chip. 4695 # We may assume an i2c_set_slave_addr was already done.4696 4733 # $_[1]: Address 4697 4734 # Returns: undef if not detected, (8) if detected. … … 4715 4752 4716 4753 # $_[0]: A reference to the file descriptor to access this chip. 4717 # We may assume an i2c_set_slave_addr was already done.4718 4754 # $_[1]: Address 4719 4755 # Returns: undef if not detected, (8) if detected. … … 4737 4773 4738 4774 # $_[0]: A reference to the file descriptor to access this chip. 4739 # We may assume an i2c_set_slave_addr was already done.4740 4775 # $_[1]: Address 4741 4776 # Returns: undef if not detected, (8) if detected. … … 4759 4794 4760 4795 # $_[0]: A reference to the file descriptor to access this chip. 4761 # We assume an i2c_set_slave_addr was already done.4762 4796 # $_[1]: Address (unused) 4763 4797 # Returns: undef if not detected, 5 if detected. … … 4774 4808 4775 4809 # $_[0]: A reference to the file descriptor to access this chip. 4776 # We may assume an i2c_set_slave_addr was already done.4777 4810 # $_[1]: Address 4778 4811 # Returns: undef if not detected, (7) if detected. … … 4804 4837 4805 4838 # $_[0]: A reference to the file descriptor to access this chip. 4806 # We assume an i2c_set_slave_addr was already done.4807 4839 # $_[1]: Address 4808 4840 # Returns: undef if not detected, 5 or 6 if detected. … … 4823 4855 4824 4856 # $_[0]: A reference to the file descriptor to access this chip. 4825 # We assume an i2c_set_slave_addr was already done.4826 4857 # $_[1]: Address 4827 4858 # Returns: undef if not detected, 5 or 6 if detected. … … 4829 4860 # 0x3E: Manufacturer ID 4830 4861 # 0x3F: Version/Stepping 4831 # 0x40: Configuration (2 reserved bits) 4832 # 0x42: Interrupt Status 2 (1 reserved bit) 4833 # 0x43: VID (2 reserved bits) 4862 # 0x73: Read-only test register (4 test bits) 4863 # 0x8A: Read-only test register (7 test bits) 4834 4864 sub dme1737_detect 4835 4865 { 4836 4866 my ($file, $addr) = @_; 4837 return unless i2c_smbus_read_byte_data($file, 0x3E) == 0x5 54867 return unless i2c_smbus_read_byte_data($file, 0x3E) == 0x5c 4838 4868 and (i2c_smbus_read_byte_data($file, 0x3F) & 0xF8) == 0x88 4839 and (i2c_smbus_read_byte_data($file, 0x40) & 0xC4) == 0x04 4840 and (i2c_smbus_read_byte_data($file, 0x42) & 0x02) == 0x00 4841 and (i2c_smbus_read_byte_data($file, 0x43) & 0xC0) == 0x00; 4869 and (i2c_smbus_read_byte_data($file, 0x73) & 0x0F) == 0x09 4870 and (i2c_smbus_read_byte_data($file, 0x8A) & 0x7F) == 0x4D; 4842 4871 return ($addr == 0x2e ? 6 : 5); 4843 4872 } … … 4848 4877 # 7 = custom power control IC) 4849 4878 # $_[1]: A reference to the file descriptor to access this chip. 4850 # We assume an i2c_set_slave_addr was already done.4851 4879 # $_[2]: Address (unused) 4852 4880 # Returns: undef if not detected, 7 if detected. … … 4885 4913 4886 4914 # $_[0]: A reference to the file descriptor to access this chip. 4887 # We may assume an i2c_set_slave_addr was already done.4888 4915 # $_[1]: Address 4889 4916 # Returns: undef if not detected, 4 or 7 if detected … … 4908 4935 4909 4936 # $_[0]: A reference to the file descriptor to access this chip. 4910 # We may assume an i2c_set_slave_addr was already done.4911 4937 # $_[1]: Address 4912 4938 # Returns: undef if not detected, 1 if detected … … 4927 4953 4928 4954 # $_[0]: A reference to the file descriptor to access this chip. 4929 # We assume an i2c_set_slave_addr was already done.4930 4955 # $_[1]: Address (unused) 4931 4956 # Returns: undef if not detected, 1 if detected … … 4956 4981 4957 4982 # $_[0]: A reference to the file descriptor to access this chip. 4958 # We may assume an i2c_set_slave_addr was already done.4959 4983 # $_[1]: Address 4960 4984 # Returns: undef if not detected, 3 if detected … … 5022 5046 } 5023 5047 5024 # $_[0]: A reference to the file descriptor to access this chip.5025 # We may assume an i2c_set_slave_addr was already done.5026 # $_[1]: Address5027 # Returns: 15028 # This is a placeholder so we get a report if any device responds5029 # to the SMBus Device Default Address (0x61), which is used for5030 # ARP in SMBus 2.0.5031 sub arp_detect5032 {5033 return (1);5034 }5035 5036 5048 # This checks for non-FFFF values for SpecInfo and Status. 5037 5049 # The address (0x09) is specified by the SMBus standard so it's likely 5038 5050 # that this really is a smart battery charger. 5039 5051 # $_[0]: A reference to the file descriptor to access this chip. 5040 # We may assume an i2c_set_slave_addr was already done.5041 5052 # $_[1]: Address 5042 5053 # Returns: 5 … … 5058 5069 # that this really is a smart battery manager/selector. 5059 5070 # $_[0]: A reference to the file descriptor to access this chip. 5060 # We may assume an i2c_set_slave_addr was already done.5061 5071 # $_[1]: Address 5062 5072 # Returns: 5 … … 5078 5088 # that this really is a smart battery. 5079 5089 # $_[0]: A reference to the file descriptor to access this chip. 5080 # We may assume an i2c_set_slave_addr was already done.5081 5090 # $_[1]: Address 5082 5091 # Returns: 5 … … 5153 5162 # $_[0]: Chip to detect (0 = W83L785TS-S) 5154 5163 # $_[1]: A reference to the file descriptor to access this chip. 5155 # We may assume an i2c_set_slave_addr was already done.5156 5164 # $_[2]: Address 5157 5165 # Returns: undef if not detected, 8 if detected … … 5172 5180 # if somebody finds a way to distinguish MAX6650 and MAX6651. 5173 5181 # $_[1]: A reference to the file descriptor to access this chip. 5174 # We may assume an i2c_set_slave_addr was already done.5175 5182 # $_[2]: Address 5176 5183 # Returns: undef if not detected, 4 if detected. … … 5204 5211 } 5205 5212 5213 # $_[0]: Chip to detect. Always zero. 5214 # $_[1]: A reference to the file descriptor to access this chip. 5215 # $_[2]: Address. 5216 # 5217 # Returns: undef if not detected, 6 if detected. 5218 sub max6655_detect 5219 { 5220 my ($chip, $file, $addr) = @_; 5221 5222 # checking RDID (Device ID) 5223 return unless i2c_smbus_read_byte_data($file, 0xfe) == 0x0a; 5224 # checking RDRV (Manufacturer ID) 5225 return unless i2c_smbus_read_byte_data($file, 0xff) == 0x4d; 5226 # checking unused bits (conversion rate, extended temperature) 5227 return unless i2c_smbus_read_byte_data($file, 0x04) & 0xf8; 5228 return unless i2c_smbus_read_byte_data($file, 0x10) & 0x1f; 5229 return unless i2c_smbus_read_byte_data($file, 0x11) & 0x1f; 5230 return unless i2c_smbus_read_byte_data($file, 0x12) & 0x1f; 5231 5232 return 6; 5233 } 5234 5206 5235 # $_[0]: Chip to detect (0 = VT1211) 5207 5236 # $_[1]: A reference to the file descriptor to access this chip. 5208 # We may assume an i2c_set_slave_addr was already done.5209 5237 # $_[2]: Address 5210 5238 # … … 5582 5610 # added to the chip_ids list 5583 5611 chip_special_cases(); 5612 $i2c_addresses_to_scan = i2c_addresses_to_scan(); 5584 5613 5585 5614 print "We are now going to do the I2C/SMBus adapter probings. Some chips may\n", … … 5642 5671 print "Do you want to scan for them? (YES/no): "; 5643 5672 unless (<STDIN> =~ /^\s*n/i) { 5673 $| = 1; 5644 5674 foreach my $entry (@cpu_ids) { 5645 5675 scan_cpu($entry); 5646 5676 } 5677 $| = 0; 5647 5678 } 5648 5679 print "\n";
