Changeset 5399
- Timestamp:
- 11/22/08 16:52:52 (5 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0
- Files:
-
- 2 modified
-
CHANGES (modified) (1 diff)
-
prog/detect/sensors-detect (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r5395 r5399 15 15 Fix detection of SMSC LPC47M292 16 16 Add SMSC LPC47M233 support 17 Drop support for Linux 2.4 (#2325) 17 18 18 19 3.0.3 (2008-09-28) -
lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect
r5397 r5399 55 55 # driver (Driver Name) field to "to-be-written". 56 56 # The match (Match Description) field should contain a regular expression 57 # matching the adapter name as it would appear in / proc/bus/i2c or /sys.57 # matching the adapter name as it would appear in /sys/class/i2c-adapter. 58 58 @pci_adapters = ( 59 59 { … … 546 546 # routine before we add them to the @pci_adapters list. 547 547 # 548 use vars qw(@pci_adapters_sis5595 @pci_adapters_sis 645 @pci_adapters_sis96x);548 use vars qw(@pci_adapters_sis5595 @pci_adapters_sis96x); 549 549 @pci_adapters_sis5595 = ( 550 550 { … … 554 554 driver => "i2c-sis5595", 555 555 match => qr/^SMBus SIS5595 adapter at [0-9a-f]{4}/, 556 },557 );558 559 @pci_adapters_sis645 = (560 {561 vendid => 0x1039,562 devid => 0x0008,563 procid => "Silicon Integrated Systems SIS5595",564 driver => "i2c-sis645",565 match => qr/^SiS645 SMBus adapter at [0-9a-f]{4}/,566 },567 {568 vendid => 0x1039,569 devid => 0x0016,570 procid => "Silicon Integrated Systems SMBus Controller",571 driver => "i2c-sis645",572 match => qr/^SiS645 SMBus adapter at 0x[0-9a-f]{4}/,573 },574 {575 vendid => 0x1039,576 devid => 0x0018,577 procid => "Silicon Integrated Systems 85C503/5513 (LPC Bridge)",578 driver => "i2c-sis645",579 match => qr/^SiS645 SMBus adapter at 0x[0-9a-f]{4}/,580 556 }, 581 557 ); … … 785 761 }, 786 762 { 763 name => "Analog Devices ADM1024", 764 driver => "lm87", 765 i2c_addrs => [0x2c..0x2e], 766 i2c_detect => sub { adm1024_detect(0, @_); }, 767 }, 768 { 787 769 name => "National Semiconductor LM93", 788 770 driver => "lm93", … … 815 797 }, 816 798 { 799 name => "Winbond W83791D", 800 driver => "w83791d", 801 i2c_addrs => [0x2c..0x2f], 802 i2c_detect => sub { w83781d_detect(7, @_); }, 803 }, 804 { 817 805 name => "Winbond W83792D", 818 806 driver => "w83792d", … … 1306 1294 }, 1307 1295 { 1296 name => "FSC Scylla", 1297 driver => "fschmd", 1298 i2c_addrs => [0x73], 1299 i2c_detect => sub { fscscy_detect(@_); }, 1300 }, 1301 { 1308 1302 name => "FSC Heimdal", 1309 1303 driver => "fschmd", … … 1395 1389 i2c_detect => sub { smartbatt_detect(@_); }, 1396 1390 }, 1397 );1398 1399 # Special case chip information goes here and would be included in1400 # the chip_special_cases routine below1401 use vars qw(@chip_kern24_ids @chip_kern26_ids1402 @chip_oldfsc_ids @chip_fschmd_ids);1403 @chip_kern24_ids = (1404 {1405 name => "Analog Devices ADM1024",1406 driver => "adm1024",1407 i2c_addrs => [0x2c..0x2e],1408 i2c_detect => sub { adm1024_detect(0, @_); },1409 },1410 {1411 name => "Winbond W83791D",1412 driver => "w83781d",1413 i2c_addrs => [0x2c..0x2f],1414 i2c_detect => sub { w83781d_detect(7, @_); },1415 },1416 {1417 name => "FSC Scylla",1418 driver => "fscscy",1419 i2c_addrs => [0x73],1420 i2c_detect => sub { fscscy_detect(@_); },1421 },1422 {1423 name => "IPMI BMC KCS",1424 driver => "bmcsensors",1425 isa_addrs => [0x0ca0],1426 isa_detect => sub { ipmi_kcs_detect(@_); },1427 },1428 {1429 name => "IPMI BMC SMIC",1430 driver => "bmcsensors",1431 isa_addrs => [0x0ca8],1432 isa_detect => sub { ipmi_smic_detect(@_); },1433 },1434 );1435 1436 @chip_kern26_ids = (1437 {1438 name => "Analog Devices ADM1024",1439 driver => "lm87",1440 i2c_addrs => [0x2c..0x2e],1441 i2c_detect => sub { adm1024_detect(0, @_); },1442 },1443 {1444 name => "Winbond W83791D",1445 driver => "w83791d",1446 i2c_addrs => [0x2c..0x2f],1447 i2c_detect => sub { w83781d_detect(7, @_); },1448 },1449 {1450 name => "FSC Scylla",1451 driver => "fschmd",1452 i2c_addrs => [0x73],1453 i2c_detect => sub { fscscy_detect(@_); },1454 },1455 1391 { 1456 1392 name => "IPMI BMC KCS", … … 1466 1402 }, 1467 1403 ); 1404 1405 # Special case chip information goes here and would be included in 1406 # the chip_special_cases routine below 1407 use vars qw(@chip_oldfsc_ids @chip_fschmd_ids); 1468 1408 1469 1409 # sigh special case for old seperate FSC drivers to new merged one mapping … … 2307 2247 ################# 2308 2248 2309 use vars qw($ modules_conf $dev_i2c $sysfs_root);2249 use vars qw($dev_i2c $sysfs_root); 2310 2250 2311 2251 sub initialize_conf … … 2324 2264 } 2325 2265 close(INPUTFILE); 2266 2267 # We need sysfs for many things 2268 if (!defined $sysfs_root) { 2269 print "Sysfs not mounted?\n"; 2270 exit -1; 2271 } 2326 2272 2327 2273 my $use_udev = 0; … … 2346 2292 $dev_i2c = '/dev/i2c-'; 2347 2293 } 2348 }2349 2350 if (kernel_version_at_least(2, 6, 0)) {2351 $modules_conf = '/etc/modprobe.conf';2352 } else {2353 $modules_conf = '/etc/modules.conf';2354 2294 } 2355 2295 … … 2382 2322 @kernel_version = ($1, $2, $3, $4); 2383 2323 chomp($kernel_arch = `uname -m`); 2324 2325 # We only support kernels >= 2.6.0 2326 if (!kernel_version_at_least(2, 6, 0)) { 2327 print "Kernel version is unsupported (too old, >= 2.6.0 needed)\n"; 2328 exit -1; 2329 } 2384 2330 } 2385 2331 … … 2427 2373 # @i2c_adapters is a list of references to hashes, one hash per I2C/SMBus 2428 2374 # adapter present on the system. Each entry has the following keys: name 2429 # (directly taken from either /proc/bus/i2c or /sys/class/i2c-adapter) and 2430 # driver. 2375 # (directly taken from /sys/class/i2c-adapter) and driver. 2431 2376 use vars qw(@i2c_adapters); 2432 2377 … … 2436 2381 local $_; 2437 2382 2438 if (defined $sysfs_root) { 2439 my $class_dir = "${sysfs_root}/class/i2c-adapter"; 2440 opendir(local *ADAPTERS, $class_dir) or return; 2441 2442 while (defined($_ = readdir(ADAPTERS))) { 2443 next unless m/^i2c-(\d+)$/; 2444 $entry = {}; # New entry 2445 $entry->{'name'} = sysfs_device_attribute("${class_dir}/i2c-$1", "name") 2446 || sysfs_device_attribute("${class_dir}/i2c-$1/device", "name"); 2447 next if $entry->{'name'} eq "ISA main adapter"; 2448 $entry->{'driver'} = find_adapter_driver($entry->{'name'}); 2449 $i2c_adapters[$1] = $entry; 2450 } 2451 closedir(ADAPTERS); 2452 } else { 2453 open(local *INPUTFILE, "/proc/bus/i2c") or return; 2454 2455 while (<INPUTFILE>) { 2456 my ($nr, $type, $name) = /^i2c-(\d+)\s+(\S+)\s+(.*?) *(\t|$)/; 2457 next if ($type eq "dummy" || $type eq "isa"); 2458 $entry = {}; # New entry 2459 $entry->{'name'} = $name; 2460 $entry->{'driver'} = find_adapter_driver($name); 2461 $i2c_adapters[$nr] = $entry; 2462 } 2463 close(INPUTFILE); 2464 } 2383 my $class_dir = "${sysfs_root}/class/i2c-adapter"; 2384 opendir(local *ADAPTERS, $class_dir) or return; 2385 2386 while (defined($_ = readdir(ADAPTERS))) { 2387 next unless m/^i2c-(\d+)$/; 2388 $entry = {}; # New entry 2389 $entry->{'name'} = sysfs_device_attribute("${class_dir}/i2c-$1", "name") 2390 || sysfs_device_attribute("${class_dir}/i2c-$1/device", "name"); 2391 next if $entry->{'name'} eq "ISA main adapter"; 2392 $entry->{'driver'} = find_adapter_driver($entry->{'name'}); 2393 $i2c_adapters[$1] = $entry; 2394 } 2395 closedir(ADAPTERS); 2465 2396 } 2466 2397 … … 2527 2458 # computer; 'vendid' and 'devid' uniquely identify a type of device. 2528 2459 # 'class' lets us spot unknown SMBus adapters. 2529 # This function is used when sysfs is available (Linux 2.6).2530 2460 sub read_sys_dev_pci($) 2531 2461 { … … 2557 2487 } 2558 2488 2559 # This function returns a list of hashes. Each hash has some PCI information: 2560 # 'bus', 'slot' and 'func' uniquely identify a PCI device in a computer; 2561 # 'vendid' and 'devid' uniquely identify a type of device. 2562 # This function is used when sysfs is not available (Linux 2.4). 2563 sub read_proc_dev_pci 2564 { 2565 my ($dfn, $vend, @pci_list); 2566 open(local *INPUTFILE, "/proc/bus/pci/devices") 2567 or die "/proc/bus/pci/devices: $!"; 2568 local $_; 2569 while (<INPUTFILE>) { 2570 my %record; 2571 ($dfn, $vend) = map { hex } (split) [0..1]; 2572 $record{bus} = $dfn >> 8; 2573 $record{slot} = ($dfn & 0xf8) >> 3; 2574 $record{func} = $dfn & 0x07; 2575 $record{vendid} = $vend >> 16; 2576 $record{devid} = $vend & 0xffff; 2577 2578 push @pci_list, \%record; 2579 } 2580 return \@pci_list; 2581 } 2582 2583 sub initialize_proc_pci 2489 sub initialize_pci 2584 2490 { 2585 2491 my $pci_list; 2586 2492 2587 if (defined $sysfs_root) { 2588 $pci_list = read_sys_dev_pci("$sysfs_root/bus/pci/devices"); 2589 } else { 2590 $pci_list = read_proc_dev_pci(); 2591 } 2493 $pci_list = read_sys_dev_pci("$sysfs_root/bus/pci/devices"); 2592 2494 2593 2495 # Note that we lose duplicate devices at this point, but we don't … … 2608 2510 2609 2511 # first, determine which driver if any... 2610 if (kernel_version_at_least(2, 6, 0)) { 2611 if (exists $pci_list{"1039:0016"}) { 2612 $driver = "i2c-sis96x"; 2613 } elsif (exists $pci_list{"1039:0008"}) { 2614 $driver = "i2c-sis5595"; 2615 } 2616 } elsif (kernel_version_at_least(2, 4, 0)) { 2617 if (exists $pci_list{"1039:0008"}) { 2618 if ((exists $pci_list{"1039:0645"}) || 2619 (exists $pci_list{"1039:0646"}) || 2620 (exists $pci_list{"1039:0648"}) || 2621 (exists $pci_list{"1039:0650"}) || 2622 (exists $pci_list{"1039:0651"}) || 2623 (exists $pci_list{"1039:0655"}) || 2624 (exists $pci_list{"1039:0661"}) || 2625 (exists $pci_list{"1039:0735"}) || 2626 (exists $pci_list{"1039:0745"}) || 2627 (exists $pci_list{"1039:0746"})) { 2628 $driver = "i2c-sis645"; 2629 } else { 2630 $driver = "i2c-sis5595"; 2631 } 2632 } elsif ((exists $pci_list{"1039:0016"}) || 2633 (exists $pci_list{"1039:0018"})) { 2634 $driver = "i2c-sis645"; 2635 } 2512 if (exists $pci_list{"1039:0016"}) { 2513 $driver = "i2c-sis96x"; 2514 } elsif (exists $pci_list{"1039:0008"}) { 2515 $driver = "i2c-sis5595"; 2636 2516 } 2637 2517 … … 2639 2519 if ($driver eq "i2c-sis5595") { 2640 2520 push @pci_adapters, @pci_adapters_sis5595; 2641 } elsif ($driver eq "i2c-sis645") {2642 push @pci_adapters, @pci_adapters_sis645;2643 2521 } elsif ($driver eq "i2c-sis96x") { 2644 2522 push @pci_adapters, @pci_adapters_sis96x; … … 2716 2594 } 2717 2595 2718 # $_[0]: Adapter description as found in / proc/bus/i2c or sysfs2596 # $_[0]: Adapter description as found in /sys/class/i2c-adapter 2719 2597 sub find_adapter_driver 2720 2598 { … … 2933 2811 # A hash 2934 2812 # with field 'i2c_adap' containing an adapter string as appearing 2935 # in / proc/bus/i2c(if this is an I2C detection)2813 # in /sys/class/i2c-adapter (if this is an I2C detection) 2936 2814 # with field 'i2c_devnr', contianing the /dev/i2c-* number of this 2937 2815 # adapter (if this is an I2C detection) … … 3178 3056 3179 3057 # $_[0]: The number of the adapter to scan 3180 # $_[1]: The name of the adapter, as appearing in / proc/bus/i2c3058 # $_[1]: The name of the adapter, as appearing in /sys/class/i2c-adapter 3181 3059 # $_[2]: The driver of the adapter 3182 3060 # @_[3]: Addresses not to scan (array reference) … … 3219 3097 3220 3098 if (!i2c_set_slave_addr(\*FILE, $addr)) { 3221 # If the address is busy, in Linux 2.6 we can find out which driver 3222 # is using it, and we assume it is the right one. In Linux 2.4 we 3223 # just give up and warn the user. 3099 # If the address is busy, we can normally find out which driver 3100 # is using it, and we assume it is the right one. 3224 3101 my ($device, $driver); 3225 if (defined($sysfs_root)) { 3226 $device = sprintf("$sysfs_root/bus/i2c/devices/\%d-\%04x",3102 3103 $device = sprintf("$sysfs_root/bus/i2c/devices/\%d-\%04x", 3227 3104 $adapter_nr, $addr); 3228 $driver = sysfs_device_driver($device);3229 } 3105 $driver = sysfs_device_driver($device); 3106 3230 3107 if (defined($driver)) { 3231 3108 $new_hash = { … … 3574 3451 push @chip_ids, @chip_oldfsc_ids; 3575 3452 } 3576 3577 if (kernel_version_at_least(2, 6, 0)) {3578 push @chip_ids, @chip_kern26_ids;3579 } else {3580 push @chip_ids, @chip_kern24_ids;3581 }3582 3453 } 3583 3454 … … 5612 5483 ###################### 5613 5484 5614 # Returns: undef if not detected, ( 7) or (9) if detected.5485 # Returns: undef if not detected, (9) if detected. 5615 5486 # The address is encoded in PCI space. We could decode it and print it. 5616 # For Linux 2.4 we should probably check for invalid matches (SiS645).5617 5487 sub sis5595_pci_detect 5618 5488 { 5619 5489 return unless exists $pci_list{'1039:0008'}; 5620 return (kernel_version_at_least(2, 6, 0) ? 9 : 7);5490 return 9; 5621 5491 } 5622 5492 … … 5793 5663 if ($ipmi) { 5794 5664 $modprobes .= "# You must also install and load the IPMI modules\n"; 5795 if (kernel_version_at_least(2, 6, 0)) { 5796 $modprobes .= "modprobe ipmi-si\n"; 5797 } else { 5798 $modprobes .= "modprobe i2c-ipmi\n"; 5799 } 5665 $modprobes .= "modprobe ipmi-si\n"; 5800 5666 } 5801 5667 … … 5807 5673 $modprobes .= "# no driver for $chip->{detected}[0]{chipname} yet\n"; 5808 5674 } else { 5809 # need the * for 2.4 kernels, won't necessarily be an exact match 5810 open(local *INPUTFILE, "modprobe -l $chip->{driver}\\* 2>/dev/null |"); 5675 open(local *INPUTFILE, "modprobe -l $chip->{driver} 2>/dev/null |"); 5811 5676 local $_; 5812 5677 my $modulefound = 0; … … 5885 5750 initialize_kernel_version(); 5886 5751 initialize_conf(); 5887 initialize_p roc_pci();5752 initialize_pci(); 5888 5753 initialize_modules_list(); 5889 5754 # make sure any special case chips are added to the chip_ids list before … … 5899 5764 "and recommended to accept the default answers to all questions,\n", 5900 5765 "unless you know what you're doing.\n"; 5901 print "You need to have i2c and lm_sensors installed before running this\n",5902 "program.\n"5903 unless kernel_version_at_least(2, 6, 0);5904 5766 print "\n"; 5905 5767 … … 5936 5798 initialize_i2c_adapters_list(); 5937 5799 5938 if (!exists($modules_list{"i2c-dev"}) 5939 && !(defined $sysfs_root && -e "$sysfs_root/class/i2c-dev")) { 5800 if (! -e "$sysfs_root/class/i2c-dev") { 5940 5801 print "To continue, we need module `i2c-dev' to be loaded.\n"; 5941 print "If it is built-in into your kernel, you can safely skip this.\n"5942 unless kernel_version_at_least(2, 6, 0);5943 5802 print "Do you want to load `i2c-dev' now? (YES/no): "; 5944 5803 if (<STDIN> =~ /^\s*n/i) { … … 6084 5943 } else { 6085 5944 print "To make the sensors modules behave correctly, add these lines to\n". 6086 " $modules_conf:\n\n";5945 "/etc/modprobe.conf:\n\n"; 6087 5946 print "#----cut here----\n". 6088 5947 $configfile.
