Changeset 255
- Timestamp:
- 02/19/99 19:11:03 (10 years ago)
- Files:
-
- lm-sensors/trunk/TODO (modified) (1 diff)
- lm-sensors/trunk/prog/detect/detect.pl (modified) (12 diffs)
- lm-sensors/trunk/prog/detect/sensors-detect (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/trunk/TODO
r219 r255 1 1 Many, many things. Most notably: 2 2 3 * Check CDROM insert-remove error of Matt Mueller 3 * bit-lp increases module count stupidly 4 * Library: reload does not work (Bison/Flex problem?) 4 5 * Create wait-queues for bus locking instead of pure semaphores, to make 5 6 it more interactive lm-sensors/trunk/prog/detect/detect.pl
r254 r255 41 41 # Function) and procid (string as appears in /proc/pci; see linux/driver/pci, 42 42 # either pci.c or oldproc.c). If no driver is written yet, omit the 43 # driver (Driver Name) field. 43 # driver (Driver Name) field. The match (Match Description) field should 44 # contain a function which returns zero if its first parameter matches 45 # the text as it would appear in /proc/bus/i2c. 44 46 @pci_adapters = ( 45 47 { … … 48 50 func => 3, 49 51 procid => "Intel 82371AB PIIX4 ACPI", 50 driver => "i2c-piix4" 52 driver => "i2c-piix4", 53 match => sub { $_[0] =~ /^SMBus PIIX4 adapter at [0-9,a-f]{4}/ }, 51 54 } , 52 55 { … … 55 58 func => 3, 56 59 procid => "VIA Technologies VT 82C586B Apollo ACPI", 57 driver => "i2c-via" 60 driver => "i2c-via", 61 match => sub { $_[0] =~ /^VIA i2c/ }, 58 62 } , 59 63 { … … 62 66 func => 0, 63 67 procid => "Silicon Integrated Systems 85C503", 68 match => sub { 0 }, 64 69 } , 65 70 { … … 68 73 funcid => 0, 69 74 procid => "Acer Labs M7101", 70 driver => "i2c-ali15x3" 75 driver => "i2c-ali15x3", 76 match => sub { $_[0] =~ /^SMBus ALI15X3 adapter at [0-9,a-f]{4}/ }, 71 77 } 72 78 ); … … 138 144 name => "Genesys Logic GL520SM", 139 145 i2c_addrs => [0x4c, 0x4d], 140 i2c_detect => sub { gl520sm_detect 1,@_} ,146 i2c_detect => sub { gl520sm_detect @_} , 141 147 }, 142 148 { … … 313 319 } 314 320 321 # $_[0]: Description as found in /proc/bus/i2c 322 sub find_adapter_driver 323 { 324 my $adapter; 325 for $adapter (@pci_adapters) { 326 return $adapter->{driver} if &{$adapter->{match}} ($_[0]); 327 } 328 return "?????"; 329 } 330 315 331 ############################# 316 332 # I2C AND SMBUS /DEV ACCESS # … … 526 542 #################### 527 543 544 use vars qw(@chips_detected); 545 546 # We will build a complicated structure @chips_detected here, being: 547 # A list of 548 # references to hashes 549 # with field 'driver', being a string with the driver name for this chip; 550 # with field 'detected' 551 # being a reference to a list of 552 # references to hashes 553 # with field 'description' containing an adapter string as appearing 554 # in /proc/bus/i2c 555 # with field 'driver', containing the driver name for this adapter; 556 # with field 'address', containing the I2C address of the detection; 557 # with field 'confidence', containing the confidence level of this 558 # detection 559 # with field 'chipname", containing the chip name 560 # 561 # with field 'misdetected' 562 # being a reference to a list of 563 # references to hashes 564 # with field 'description' containing an adapter string as appearing 565 # in /proc/bus/i2c 566 # with field 'driver', containing the driver name for this adapter; 567 # with field 'address', containing the I2C address of the detection; 568 # with field 'confidence', containing the confidence level of this 569 # detection 570 # with field 'chipname", containing the chip name 571 572 # $_[0]: chip driver 573 # $_[1]: reference to data hash 574 sub add_to_chips_detected 575 { 576 my ($chipdriver,$datahash,$detected_ref,$misdetected_ref, 577 $new_detected_ref,$new_misdetected_ref) = @_; 578 my ($i,$j,$found_it); 579 for ($i = 0; $i < @chips_detected; $i++) { 580 last if ($chips_detected[$i]->{driver} eq $chipdriver); 581 } 582 if ($i == @chips_detected) { 583 push @chips_detected, { driver => $chipdriver, 584 detected => [], 585 misdetected => [] }; 586 } 587 588 $new_detected_ref = $chips_detected[$i]->{detected}; 589 $new_misdetected_ref = $chips_detected[$i]->{misdetected}; 590 591 # This is tricky, mostly because of the datastructures involved. We walk 592 # through all previous detections for this address. If the to-be-inserted 593 # detection matches an item in it, we look at the confidence values. 594 # If the to-be-inserted detections's confidence is greater, we delegate 595 # the previous detection to the misdetections, and replace it with this 596 # detection. If it is equal or less, we add the to-be-inserted detection 597 # to the misdetections. As soon as a match is found, we break. If no 598 # matches are found at all, add the to-be-inserted detection with the 599 # detections. 600 $found_it = 0; 601 LOOP: for ($i = 0; $i < @chips_detected; $i++) { 602 $detected_ref = $chips_detected[$i]->{detected}; 603 $misdetected_ref = $chips_detected[$i]->{misdetected}; 604 for ($j = 0; $j < @$detected_ref ; $j++) { 605 if ($detected_ref->[$j]->{driver} eq $datahash->{driver} and 606 $detected_ref->[$j]->{description} eq $datahash->{description} and 607 $detected_ref->[$j]->{address} eq $datahash->{address}) { 608 if ($detected_ref->[$j]->{confidence} > $datahash->{confidence}) { 609 push @$misdetected_ref, $detected_ref->[$j]; 610 splice @$detected_ref, $j, 1; 611 push @$new_detected_ref, $datahash; 612 $found_it = 1; 613 last LOOP; 614 } else { 615 push @$new_misdetected_ref, $datahash; 616 $found_it = 1; 617 last LOOP; 618 } 619 } 620 } 621 } 622 push @$new_detected_ref, $datahash if not $found_it 623 } 624 528 625 # $_[0]: The number of the adapter to scan 626 # $_[1]: The name of the adapter, as appearing in /proc/bus/i2c 627 # $_[2]: The driver of the adapter 529 628 sub scan_adapter 530 629 { 630 my ( $adapter_nr,$adapter_name,$adapter_driver) = @_; 531 631 my ($chip, $addr, $conf,@chips); 532 open FILE,"/dev/i2c-$ _[0]" or print ("Can't open /dev/i2c-$_[0] ($!)\n"),533 return;632 open FILE,"/dev/i2c-$adapter_nr" or 633 print ("Can't open /dev/i2c-$adapter_nr ($!)\n"), return; 534 634 foreach $addr (0..0x7f) { 535 635 i2c_set_slave_addr(\*FILE,$addr) or print("Can't set address to $_?!?\n"), … … 537 637 next unless i2c_smbus_read_byte(\*FILE) >= 0; 538 638 printf "Client found at address 0x%02x\n",$addr; 639 my @detection_list = (); 640 my $highest_conf = 0; 641 my $double_conf = 0; 539 642 foreach $chip (@chip_ids) { 540 643 if (contains $addr, @{$$chip{i2c_addrs}}) { … … 548 651 print ")\n"; 549 652 } 653 add_to_chips_detected $$chip{driver}, 654 { confidence => $conf, 655 address => $addr, 656 chipname => $$chip{name}, 657 description => $adapter_name, 658 driver => $adapter_driver, 659 }; 550 660 } else { 551 print "Failed!\n" 661 print "Failed!\n"; 552 662 } 553 663 } … … 887 997 "module. If not,", 888 998 " you won't be able to open any /dev/i2c-* file.\n"; 889 } elsif (system "modprobe","i2c- proc") {999 } elsif (system "modprobe","i2c-dev") { 890 1000 print " Loading failed ($!), aborting.\n"; 891 1001 exit; … … 906 1016 print "\n"; 907 1017 my ($dev_nr,$description) = /^i2c-(\S+)\s+\S+\s+(.*)$/; 1018 $description =~ s/\t/ /; 908 1019 print "Next adapter: $description\n"; 909 print "Do you want to scan it? (YES/no):"; 910 scan_adapter $dev_nr unless <STDIN> =~ /^\s*[Nn]/; 1020 print "Do you want to scan it? (YES/no): "; 1021 scan_adapter $dev_nr, $description, find_adapter_driver($description) 1022 unless <STDIN> =~ /^\s*[Nn]/; 1023 } 1024 1025 print "\n Now follows a summary of the probes I have just done.\n"; 1026 my ($chip,$data); 1027 foreach $chip (@chips_detected) { 1028 print "\nDriver `$$chip{driver}' "; 1029 if (@{$$chip{detected}}) { 1030 if (@{$$chip{misdetected}}) { 1031 print "(should be inserted but causes problems):\n"; 1032 } else { 1033 print "(should be inserted):\n"; 1034 } 1035 } else { 1036 if (@{$$chip{misdetected}}) { 1037 print "(may not be inserted):\n"; 1038 } else { 1039 print "(should not be inserted, but is harmless):\n"; 1040 } 1041 } 1042 if (@{$$chip{detected}}) { 1043 print " Detects correctly:\n"; 1044 foreach $data (@{$$chip{detected}}) { 1045 printf " * Bus `%s'\n". 1046 " Busdriver `%s', I2C address 0x%02x\n". 1047 " Chip `%s' (confidence: %d)\n", 1048 $data->{description}, $data->{driver}, $data->{address}, 1049 $data->{chipname}, $data->{address}, $data->{confidence}; 1050 } 1051 } 1052 if (@{$$chip{misdetected}}) { 1053 print " Misdetects:\n"; 1054 foreach $data (@{$$chip{misdetected}}) { 1055 printf " * Bus: %s\n". 1056 " Busdriver `%s', I2C address 0x%02x\n". 1057 " Chip `%s' (confidence: %d)\n", 1058 $data->{description}, $data->{driver}, $data->{address}, 1059 $data->{chipname}, $data->{address}, $data->{confidence}; 1060 } 1061 } 911 1062 } 912 1063 } 913 1064 914 1065 main; 915 916 917 918 919 920 # TEST!921 # scan_adapter 0;922 #}923 924 #lm-sensors/trunk/prog/detect/sensors-detect
r254 r255 41 41 # Function) and procid (string as appears in /proc/pci; see linux/driver/pci, 42 42 # either pci.c or oldproc.c). If no driver is written yet, omit the 43 # driver (Driver Name) field. 43 # driver (Driver Name) field. The match (Match Description) field should 44 # contain a function which returns zero if its first parameter matches 45 # the text as it would appear in /proc/bus/i2c. 44 46 @pci_adapters = ( 45 47 { … … 48 50 func => 3, 49 51 procid => "Intel 82371AB PIIX4 ACPI", 50 driver => "i2c-piix4" 52 driver => "i2c-piix4", 53 match => sub { $_[0] =~ /^SMBus PIIX4 adapter at [0-9,a-f]{4}/ }, 51 54 } , 52 55 { … … 55 58 func => 3, 56 59 procid => "VIA Technologies VT 82C586B Apollo ACPI", 57 driver => "i2c-via" 60 driver => "i2c-via", 61 match => sub { $_[0] =~ /^VIA i2c/ }, 58 62 } , 59 63 { … … 62 66 func => 0, 63 67 procid => "Silicon Integrated Systems 85C503", 68 match => sub { 0 }, 64 69 } , 65 70 { … … 68 73 funcid => 0, 69 74 procid => "Acer Labs M7101", 70 driver => "i2c-ali15x3" 75 driver => "i2c-ali15x3", 76 match => sub { $_[0] =~ /^SMBus ALI15X3 adapter at [0-9,a-f]{4}/ }, 71 77 } 72 78 ); … … 138 144 name => "Genesys Logic GL520SM", 139 145 i2c_addrs => [0x4c, 0x4d], 140 i2c_detect => sub { gl520sm_detect 1,@_} ,146 i2c_detect => sub { gl520sm_detect @_} , 141 147 }, 142 148 { … … 313 319 } 314 320 321 # $_[0]: Description as found in /proc/bus/i2c 322 sub find_adapter_driver 323 { 324 my $adapter; 325 for $adapter (@pci_adapters) { 326 return $adapter->{driver} if &{$adapter->{match}} ($_[0]); 327 } 328 return "?????"; 329 } 330 315 331 ############################# 316 332 # I2C AND SMBUS /DEV ACCESS # … … 526 542 #################### 527 543 544 use vars qw(@chips_detected); 545 546 # We will build a complicated structure @chips_detected here, being: 547 # A list of 548 # references to hashes 549 # with field 'driver', being a string with the driver name for this chip; 550 # with field 'detected' 551 # being a reference to a list of 552 # references to hashes 553 # with field 'description' containing an adapter string as appearing 554 # in /proc/bus/i2c 555 # with field 'driver', containing the driver name for this adapter; 556 # with field 'address', containing the I2C address of the detection; 557 # with field 'confidence', containing the confidence level of this 558 # detection 559 # with field 'chipname", containing the chip name 560 # 561 # with field 'misdetected' 562 # being a reference to a list of 563 # references to hashes 564 # with field 'description' containing an adapter string as appearing 565 # in /proc/bus/i2c 566 # with field 'driver', containing the driver name for this adapter; 567 # with field 'address', containing the I2C address of the detection; 568 # with field 'confidence', containing the confidence level of this 569 # detection 570 # with field 'chipname", containing the chip name 571 572 # $_[0]: chip driver 573 # $_[1]: reference to data hash 574 sub add_to_chips_detected 575 { 576 my ($chipdriver,$datahash,$detected_ref,$misdetected_ref, 577 $new_detected_ref,$new_misdetected_ref) = @_; 578 my ($i,$j,$found_it); 579 for ($i = 0; $i < @chips_detected; $i++) { 580 last if ($chips_detected[$i]->{driver} eq $chipdriver); 581 } 582 if ($i == @chips_detected) { 583 push @chips_detected, { driver => $chipdriver, 584 detected => [], 585 misdetected => [] }; 586 } 587 588 $new_detected_ref = $chips_detected[$i]->{detected}; 589 $new_misdetected_ref = $chips_detected[$i]->{misdetected}; 590 591 # This is tricky, mostly because of the datastructures involved. We walk 592 # through all previous detections for this address. If the to-be-inserted 593 # detection matches an item in it, we look at the confidence values. 594 # If the to-be-inserted detections's confidence is greater, we delegate 595 # the previous detection to the misdetections, and replace it with this 596 # detection. If it is equal or less, we add the to-be-inserted detection 597 # to the misdetections. As soon as a match is found, we break. If no 598 # matches are found at all, add the to-be-inserted detection with the 599 # detections. 600 $found_it = 0; 601 LOOP: for ($i = 0; $i < @chips_detected; $i++) { 602 $detected_ref = $chips_detected[$i]->{detected}; 603 $misdetected_ref = $chips_detected[$i]->{misdetected}; 604 for ($j = 0; $j < @$detected_ref ; $j++) { 605 if ($detected_ref->[$j]->{driver} eq $datahash->{driver} and 606 $detected_ref->[$j]->{description} eq $datahash->{description} and 607 $detected_ref->[$j]->{address} eq $datahash->{address}) { 608 if ($detected_ref->[$j]->{confidence} > $datahash->{confidence}) { 609 push @$misdetected_ref, $detected_ref->[$j]; 610 splice @$detected_ref, $j, 1; 611 push @$new_detected_ref, $datahash; 612 $found_it = 1; 613 last LOOP; 614 } else { 615 push @$new_misdetected_ref, $datahash; 616 $found_it = 1; 617 last LOOP; 618 } 619 } 620 } 621 } 622 push @$new_detected_ref, $datahash if not $found_it 623 } 624 528 625 # $_[0]: The number of the adapter to scan 626 # $_[1]: The name of the adapter, as appearing in /proc/bus/i2c 627 # $_[2]: The driver of the adapter 529 628 sub scan_adapter 530 629 { 630 my ( $adapter_nr,$adapter_name,$adapter_driver) = @_; 531 631 my ($chip, $addr, $conf,@chips); 532 open FILE,"/dev/i2c-$ _[0]" or print ("Can't open /dev/i2c-$_[0] ($!)\n"),533 return;632 open FILE,"/dev/i2c-$adapter_nr" or 633 print ("Can't open /dev/i2c-$adapter_nr ($!)\n"), return; 534 634 foreach $addr (0..0x7f) { 535 635 i2c_set_slave_addr(\*FILE,$addr) or print("Can't set address to $_?!?\n"), … … 537 637 next unless i2c_smbus_read_byte(\*FILE) >= 0; 538 638 printf "Client found at address 0x%02x\n",$addr; 639 my @detection_list = (); 640 my $highest_conf = 0; 641 my $double_conf = 0; 539 642 foreach $chip (@chip_ids) { 540 643 if (contains $addr, @{$$chip{i2c_addrs}}) { … … 548 651 print ")\n"; 549 652 } 653 add_to_chips_detected $$chip{driver}, 654 { confidence => $conf, 655 address => $addr, 656 chipname => $$chip{name}, 657 description => $adapter_name, 658 driver => $adapter_driver, 659 }; 550 660 } else { 551 print "Failed!\n" 661 print "Failed!\n"; 552 662 } 553 663 } … … 887 997 "module. If not,", 888 998 " you won't be able to open any /dev/i2c-* file.\n"; 889 } elsif (system "modprobe","i2c- proc") {999 } elsif (system "modprobe","i2c-dev") { 890 1000 print " Loading failed ($!), aborting.\n"; 891 1001 exit; … … 906 1016 print "\n"; 907 1017 my ($dev_nr,$description) = /^i2c-(\S+)\s+\S+\s+(.*)$/; 1018 $description =~ s/\t/ /; 908 1019 print "Next adapter: $description\n"; 909 print "Do you want to scan it? (YES/no):"; 910 scan_adapter $dev_nr unless <STDIN> =~ /^\s*[Nn]/; 1020 print "Do you want to scan it? (YES/no): "; 1021 scan_adapter $dev_nr, $description, find_adapter_driver($description) 1022 unless <STDIN> =~ /^\s*[Nn]/; 1023 } 1024 1025 print "\n Now follows a summary of the probes I have just done.\n"; 1026 my ($chip,$data); 1027 foreach $chip (@chips_detected) { 1028 print "\nDriver `$$chip{driver}' "; 1029 if (@{$$chip{detected}}) { 1030 if (@{$$chip{misdetected}}) { 1031 print "(should be inserted but causes problems):\n"; 1032 } else { 1033 print "(should be inserted):\n"; 1034 } 1035 } else { 1036 if (@{$$chip{misdetected}}) { 1037 print "(may not be inserted):\n"; 1038 } else { 1039 print "(should not be inserted, but is harmless):\n"; 1040 } 1041 } 1042 if (@{$$chip{detected}}) { 1043 print " Detects correctly:\n"; 1044 foreach $data (@{$$chip{detected}}) { 1045 printf " * Bus `%s'\n". 1046 " Busdriver `%s', I2C address 0x%02x\n". 1047 " Chip `%s' (confidence: %d)\n", 1048 $data->{description}, $data->{driver}, $data->{address}, 1049 $data->{chipname}, $data->{address}, $data->{confidence}; 1050 } 1051 } 1052 if (@{$$chip{misdetected}}) { 1053 print " Misdetects:\n"; 1054 foreach $data (@{$$chip{misdetected}}) { 1055 printf " * Bus: %s\n". 1056 " Busdriver `%s', I2C address 0x%02x\n". 1057 " Chip `%s' (confidence: %d)\n", 1058 $data->{description}, $data->{driver}, $data->{address}, 1059 $data->{chipname}, $data->{address}, $data->{confidence}; 1060 } 1061 } 911 1062 } 912 1063 } 913 1064 914 1065 main; 915 916 917 918 919 920 # TEST!921 # scan_adapter 0;922 #}923 924 #
