41
41
use vars qw(@pci_adapters @chip_ids @ipmi_ifs @non_hwmon_chip_ids
42
42
$i2c_addresses_to_scan $revision @i2c_byte_cache);
44
$revision = '$Revision: 6085 $ ($Date: 2012-10-30 18:18:45 +0100 (mar. 30 oct. 2012) $)';
44
$revision = '$Revision: 6170 $ ($Date: 2013-05-20 21:25:22 +0200 (lun. 20 mai 2013) $)';
45
45
$revision =~ s/\$\w+: (.*?) \$/$1/g;
46
46
$revision =~ s/ \([^()]*\)//;
637
637
i2c_addrs => [0x2c..0x2e],
638
638
i2c_detect => sub { adt7490_detect(@_); },
640
name => "Analog Devices ADT7410",
641
driver => "to-be-written",
640
name => "Analog Devices ADT7410/ADT7420",
642
642
i2c_addrs => [0x48..0x4b],
643
643
i2c_detect => sub { adt7410_detect(@_); },
803
803
i2c_addrs => [0x2c..0x2f],
804
804
i2c_detect => sub { adm9240_detect(@_, 0); },
806
name => "Dallas Semiconductor DS1621/DS1631",
808
i2c_addrs => [0x48..0x4f],
809
i2c_detect => sub { ds1621_detect(@_); },
811
806
name => "Dallas Semiconductor DS1780",
812
807
driver => "adm9240",
813
808
i2c_addrs => [0x2c..0x2f],
1023
1018
i2c_addrs => [0x4c, 0x4d],
1024
1019
i2c_detect => sub { tmp42x_detect(@_, 2); },
1021
name => "Texas Instruments TMP431",
1022
driver => "to-be-written", # tmp401
1023
i2c_addrs => [0x4c, 0x4d],
1024
i2c_detect => sub { lm90_detect(@_, 16); },
1026
name => "Texas Instruments TMP432",
1027
driver => "to-be-written", # tmp401
1028
i2c_addrs => [0x4c, 0x4d],
1029
i2c_detect => sub { lm90_detect(@_, 17); },
1026
1031
name => "Texas Instruments AMC6821",
1027
1032
driver => "amc6821",
1028
1033
i2c_addrs => [0x18..0x1a, 0x2c..0x2e, 0x4c..0x4e],
1033
1038
i2c_addrs => [0x2b, 0x19, 0x2a],
1034
1039
i2c_detect => sub { lm95231_detect(@_, 0); },
1041
name => "National Semiconductor LM95234",
1042
driver => "to-be-written", # lm95234
1043
i2c_addrs => [0x18, 0x4d, 0x4e],
1044
i2c_detect => sub { lm95231_detect(@_, 3); },
1036
1046
name => "National Semiconductor LM95241",
1037
1047
driver => "lm95241",
1038
1048
i2c_addrs => [0x2b, 0x19, 0x2a],
1400
1410
i2c_addrs => [0x18..0x1f],
1401
1411
i2c_detect => sub { jedec_JC42_4_detect(@_, 7); },
1413
name => "Microchip MCP98244",
1415
i2c_addrs => [0x18..0x1f],
1416
i2c_detect => sub { jedec_JC42_4_detect(@_, 15); },
1403
1418
name => "Microchip MCP9843",
1404
1419
driver => "jc42",
1405
1420
i2c_addrs => [0x18..0x1f],
1950
1965
logdev => 0x0b,
1951
1966
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1968
name => "Winbond W83627SF/GF Super IO",
1969
driver => "not-a-sensor",
1953
1972
name => "Winbond W83627THF/THG Super IO Sensors",
1954
1973
driver => "w83627hf",
2024
2043
logdev => 0x0b,
2025
2044
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2027
name => "Nuvoton W83677HG-I (NCT6771F/NCT6772F/NCT6775F) Super IO Sensors",
2046
name => "Nuvoton W83677HG-I (NCT5572D/NCT6771F/NCT6772F/NCT6775F) Super IO Sensors",
2028
2047
driver => "w83627ehf",
2029
2048
devid => 0xB470,
2030
2049
devid_mask => 0xFFF0,
2035
2054
driver => "not-a-sensor",
2038
name => "Nuvoton NCT5577D Super IO Sensors",
2039
driver => "to-be-written",
2042
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2044
name => "Nuvoton NCT6776F Super IO Sensors",
2045
driver => "w83627ehf",
2048
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2050
name => "Nuvoton NCT6779D Super IO Sensors",
2051
driver => "to-be-written", # nct6775, new driver
2054
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2056
name => "Nuvoton NCT6102D/NCT6106D Super IO Sensors",
2057
driver => "to-be-written", # nct6775, new driver
2057
name => "Nuvoton NCT5577D/NCT6776F Super IO Sensors",
2058
driver => "nct6775",
2060
devid_mask => 0xFFF0,
2062
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2064
name => "Nuvoton NCT5532D/NCT6779D Super IO Sensors",
2065
driver => "nct6775",
2067
devid_mask => 0xFFF0,
2069
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2071
name => "Nuvoton NCT6102D/NCT6104D/NCT6106D Super IO Sensors",
2072
driver => "to-be-written", # nct6775
2074
devid_mask => 0xFFF0,
2059
2075
logdev => 0x0b,
2060
2076
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2225
2241
logdev => 0x04,
2226
2242
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2244
name => "ITE IT8752F Super IO Sensors",
2245
driver => "to-be-written", # it87
2248
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2228
2250
name => "ITE IT8771E Super IO Sensors",
2229
driver => "to-be-written", # it87
2230
2252
devid => 0x8771,
2231
2253
logdev => 0x04,
2232
2254
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2234
2256
name => "ITE IT8772E Super IO Sensors",
2235
driver => "to-be-written", # it87
2236
2258
devid => 0x8772,
2237
2259
logdev => 0x04,
2238
2260
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2244
2266
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2246
2268
name => "ITE IT8782F Super IO Sensors",
2247
driver => "to-be-written", # it87
2248
2270
devid => 0x8782,
2249
2271
logdev => 0x04,
2250
2272
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2252
2274
name => "ITE IT8783F Super IO Sensors",
2253
driver => "to-be-written", # it87
2254
2276
devid => 0x8783,
2255
2277
logdev => 0x04,
2256
2278
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2354
2376
driver => "fam15h_power",
2355
2377
detect => sub { amd_pci_detect('1604') },
2379
name => "AMD Family 16h power sensors",
2380
driver => "fam15h_power",
2381
detect => sub { amd_pci_detect('1534') },
2357
2383
name => "Intel digital thermal sensor",
2358
2384
driver => "coretemp",
2359
2385
detect => \&coretemp_detect,
2469
2495
sub initialize_ioports
2471
sysopen(IOPORTS, "/dev/port", O_RDWR)
2472
or die "/dev/port: $!\n";
2497
if (sysopen(IOPORTS, "/dev/port", O_RDWR)) {
2501
print STDERR "/dev/port: $!\n";
2476
2505
sub close_ioports
2802
# /sys/module contains built-in drivers too, but doesn't exist on
2803
# older kernels (added in kernel 2.6.7)
2804
if (opendir(local *MODULES, "$sysfs_root/module")) {
2805
while (defined($_ = readdir(MODULES))) {
2807
$modules_list{$1} = 1 if m/^(\S*)/;
2812
# Fall back to /proc/modules as it is always available
2773
2813
open(local *INPUTFILE, "/proc/modules") or return;
2774
2814
while (<INPUTFILE>) {
2775
tr/-/_/; # Probably not needed
2776
2815
$modules_list{$1} = 1 if m/^(\S*)/;
3498
3537
print("Can't set I2C address for $dev\n"),
3501
initialize_ioports();
3502
$alias_detect = $detected->[$isa]->{alias_detect};
3503
$is_alias = &$alias_detect($detected->[$isa]->{isa_addr},
3505
$detected->[$i2c]->{i2c_addr});
3540
if (initialize_ioports()) {
3541
$alias_detect = $detected->[$isa]->{alias_detect};
3542
$is_alias = &$alias_detect($detected->[$isa]->{isa_addr},
3544
$detected->[$i2c]->{i2c_addr});
3509
3549
next unless $is_alias;
3510
3550
# This is an alias: copy the I2C data into the ISA
4317
4357
return ($chip == 0) ? 4 : 2;
4326
# 0xAC: Configuration
4327
# Detection is weak. We check if bit 4 (NVB) is clear, because it is
4328
# unlikely to be set (would mean that EEPROM is currently being accessed).
4329
# We also check the value of the counter and slope registers, the datasheet
4330
# doesn't mention the possible values but the conversion formula together
4331
# with experimental evidence suggest possible sanity checks.
4332
# Not all devices enjoy SMBus read word transactions, so we do as much as
4333
# possible with read byte transactions first, and only use read word
4334
# transactions second.
4337
my ($file, $addr) = @_;
4339
my $conf = i2c_smbus_read_byte_data($file, 0xAC);
4340
return if ($conf & 0x10);
4342
my $temp = i2c_smbus_read_word_data($file, 0xAA);
4343
return if $temp < 0 || ($temp & 0x0f00);
4344
# On the DS1631, the following two checks are too strict in theory,
4345
# but in practice I very much doubt that anyone will set temperature
4346
# limits not a multiple of 0.5 degrees C.
4347
my $high = i2c_smbus_read_word_data($file, 0xA1);
4348
return if $high < 0 || ($high & 0x7f00);
4349
my $low = i2c_smbus_read_word_data($file, 0xA2);
4350
return if $low < 0 || ($low & 0x7f00);
4352
return if ($temp == 0 && $high == 0 && $low == 0 && $conf == 0);
4354
# Old versions of the DS1621 apparently don't have the counter and
4355
# slope registers (or they return crap)
4356
my $counter = i2c_smbus_read_byte_data($file, 0xA8);
4357
my $slope = i2c_smbus_read_byte_data($file, 0xA9);
4358
return ($slope == 0x10 && $counter <= $slope) ? 3 : 2;
4361
4360
# Chip to detect: 0 = LM80, 1 = LM96080
4362
4361
# Registers used:
4363
4362
# 0x00: Configuration register
4504
4503
# 8 = W83L771W/G, 9 = TMP401, 10 = TMP411,
4505
4504
# 11 = W83L771AWG/ASG, 12 = MAX6690,
4506
4505
# 13 = ADT7461A/NCT1008, 14 = SA56004,
4506
# 15 = G781, 16 = TMP431, 17 = TMP432
4508
4507
# Registers used:
4509
4508
# 0x03: Configuration
4510
4509
# 0x04: Conversion rate
4622
4621
return if $mid != 0x47; # GMT
4623
4622
return 8 if $cid == 0x01; # G781
4625
return if ($conf & 0x1B) != 0;
4626
return if $rate > 0x0F;
4627
return if $mid != 0x55; # Texas Instruments
4628
return 6 if ($cid == 0x31); # TMP431A/B/C/D
4631
return if ($conf & 0x1B) != 0;
4632
return if $rate > 0x0F;
4633
return if $mid != 0x55; # Texas Instruments
4634
return 6 if ($cid == 0x32); # TMP432A/B
4696
# Chip to detect: 0 = LM95231, 1 = LM95241, 2 = LM95245
4707
# Chip to detect: 0 = LM95231, 1 = LM95241, 2 = LM95245, 3 = LM95234
4697
4708
# Registers used:
4698
4709
# 0x02: Status (3 unused bits)
4699
4710
# 0x03: Configuration (3 unused bits)
4711
# 0x04: Conversion rate (6 unused bits, LM95234)
4700
4712
# 0x06: Remote diode filter control (6 unused bits, LM95231 and LM95241)
4701
4713
# 0x30: Remote diode model type select (6 unused bits, LM95231 and LM95241)
4702
4714
# 0x30: Local Temperature LSB (5 unused bits, LM95245)
4715
# 0x30: Diode model (4 unused bits, LM95234)
4703
4716
# 0x33: Status register 2 (6 unused bits, LM95245)
4717
# 0x38: Diode model status (4 unused bits, LM95234)
4704
4718
# 0xfe: Manufacturer ID
4705
4719
# 0xff: Revision ID
4706
4720
sub lm95231_detect
4724
4738
return if i2c_smbus_read_byte_data($file, 0x03) & 0xa1;
4725
4739
return if i2c_smbus_read_byte_data($file, 0x30) & 0x1f;
4726
4740
return if i2c_smbus_read_byte_data($file, 0x33) & 0x3f;
4741
} elsif ($chip == 3) {
4742
return if $cid != 0x79; # LM95234
4743
return if i2c_smbus_read_byte_data($file, 0x02) & 0x30;
4744
return if i2c_smbus_read_byte_data($file, 0x03) & 0xbc;
4745
return if i2c_smbus_read_byte_data($file, 0x04) & 0xfc;
4746
return if i2c_smbus_read_byte_data($file, 0x30) & 0xe1;
4747
return if i2c_smbus_read_byte_data($file, 0x38) & 0xe1;
6035
6056
# 4 = TS3000/TSE2002, 5 = MAX6604, 6 = MCP98242,
6036
6057
# 7 = MCP98243, 8 = MCP9843, 9 = CAT6095 / CAT34TS02,
6037
6058
# 10 = STTS424E, 11 = STTS2002, 12 = STTS3000
6038
# 13 = MCP9804, 14 = AT30TS00
6059
# 13 = MCP9804, 14 = AT30TS00, 15 = MCP98244
6039
6060
# Registers used:
6040
6061
# 0x00: Capabilities
6041
6062
# 0x01: Configuration
6104
6125
} elsif ($chip == 14) {
6105
6126
return unless $manid == 0x00; # Atmel
6106
6127
return unless $devid == 0x82; # AT30TS00
6128
} elsif ($chip == 15) {
6129
return unless $manid == 0x00; # MCP
6130
return unless $devid == 0x22; # MCP98244
6109
6133
# Now, do it all again with words. Note that we get
6759
6786
"standard I/O ports to probe them. This is usually safe.\n";
6760
6787
print "Do you want to scan for Super I/O sensors? (YES/no): ";
6761
6788
unless (<STDIN> =~ /^\s*n/i) {
6762
initialize_ioports();
6763
$superio_features |= scan_superio(0x2e, 0x2f);
6764
$superio_features |= scan_superio(0x4e, 0x4f);
6789
if (initialize_ioports()) {
6790
$superio_features |= scan_superio(0x2e, 0x2f);
6791
$superio_features |= scan_superio(0x4e, 0x4f);
6775
6803
"interfaces? (YES/no): ";
6776
6804
unless (<STDIN> =~ /^\s*n/i) {
6777
6805
if (!ipmi_from_smbios()) {
6778
initialize_ioports();
6779
scan_isa_bus(\@ipmi_ifs);
6806
if (initialize_ioports()) {
6807
scan_isa_bus(\@ipmi_ifs);
6791
6820
$input = <STDIN>;
6792
6821
unless ($input =~ /^\s*n/i
6793
6822
|| ($superio_features && $input !~ /^\s*y/i)) {
6794
initialize_ioports();
6795
scan_isa_bus(\@chip_ids);
6823
if (initialize_ioports()) {
6824
scan_isa_bus(\@chip_ids);