~mfisch/ubuntu/trusty/lm-sensors/merge-to-3.3.4

« back to all changes in this revision

Viewing changes to .pc/14-2-digits-kernel.patch/prog/detect/sensors-detect

  • Committer: Matthew Fischer
  • Date: 2013-12-04 02:20:46 UTC
  • mfrom: (2.1.12 sid)
  • Revision ID: matthew.fischer@canonical.com-20131204022046-eeorueauw00r3m84
* Merge from Debian unstable (LP: #1256671). Remaining changes:
  - Add 100_recommend_using_upstart.patch: Recommend use of upstart rather
    than init-script.
* debian/fancontrol.init: pass the config file location as argument of
  the fancontrol daemon (closes: #720213).
* New upstream version.
* Use dh-systemd to get proper systemd related maintainer scripts,
  based on a patch from Michael Stapelberg (closes: #714190).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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);
43
43
 
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/ \([^()]*\)//;
47
47
 
637
637
                i2c_addrs => [0x2c..0x2e],
638
638
                i2c_detect => sub { adt7490_detect(@_); },
639
639
        }, {
640
 
                name => "Analog Devices ADT7410",
641
 
                driver => "to-be-written",
 
640
                name => "Analog Devices ADT7410/ADT7420",
 
641
                driver => "adt7410",
642
642
                i2c_addrs => [0x48..0x4b],
643
643
                i2c_detect => sub { adt7410_detect(@_); },
644
644
        }, {
803
803
                i2c_addrs => [0x2c..0x2f],
804
804
                i2c_detect => sub { adm9240_detect(@_, 0); },
805
805
        }, {
806
 
                name => "Dallas Semiconductor DS1621/DS1631",
807
 
                driver => "ds1621",
808
 
                i2c_addrs => [0x48..0x4f],
809
 
                i2c_detect => sub { ds1621_detect(@_); },
810
 
        }, {
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); },
1025
1020
        }, {
 
1021
                name => "Texas Instruments TMP431",
 
1022
                driver => "to-be-written",              # tmp401
 
1023
                i2c_addrs => [0x4c, 0x4d],
 
1024
                i2c_detect => sub { lm90_detect(@_, 16); },
 
1025
        }, {
 
1026
                name => "Texas Instruments TMP432",
 
1027
                driver => "to-be-written",              # tmp401
 
1028
                i2c_addrs => [0x4c, 0x4d],
 
1029
                i2c_detect => sub { lm90_detect(@_, 17); },
 
1030
        }, {
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); },
1035
1040
        }, {
 
1041
                name => "National Semiconductor LM95234",
 
1042
                driver => "to-be-written",              # lm95234
 
1043
                i2c_addrs => [0x18, 0x4d, 0x4e],
 
1044
                i2c_detect => sub { lm95231_detect(@_, 3); },
 
1045
        }, {
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); },
1402
1412
        }, {
 
1413
                name => "Microchip MCP98244",
 
1414
                driver => "jc42",
 
1415
                i2c_addrs => [0x18..0x1f],
 
1416
                i2c_detect => sub { jedec_JC42_4_detect(@_, 15); },
 
1417
        }, {
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,
1952
1967
        }, {
 
1968
                name => "Winbond W83627SF/GF Super IO",
 
1969
                driver => "not-a-sensor",
 
1970
                devid => 0x59,
 
1971
        }, {
1953
1972
                name => "Winbond W83627THF/THG Super IO Sensors",
1954
1973
                driver => "w83627hf",
1955
1974
                devid => 0x82,
2024
2043
                logdev => 0x0b,
2025
2044
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2026
2045
        }, {
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",
2036
2055
                devid => 0x61,
2037
2056
        }, {
2038
 
                name => "Nuvoton NCT5577D Super IO Sensors",
2039
 
                driver => "to-be-written",
2040
 
                devid => 0xC331,
2041
 
                logdev => 0x0b,
2042
 
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2043
 
        }, {
2044
 
                name => "Nuvoton NCT6776F Super IO Sensors",
2045
 
                driver => "w83627ehf",
2046
 
                devid => 0xC333,
2047
 
                logdev => 0x0b,
2048
 
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2049
 
        }, {
2050
 
                name => "Nuvoton NCT6779D Super IO Sensors",
2051
 
                driver => "to-be-written",      # nct6775, new driver
2052
 
                devid => 0xC562,
2053
 
                logdev => 0x0b,
2054
 
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2055
 
        }, {
2056
 
                name => "Nuvoton NCT6102D/NCT6106D Super IO Sensors",
2057
 
                driver => "to-be-written",      # nct6775, new driver
2058
 
                devid => 0x1061,
 
2057
                name => "Nuvoton NCT5577D/NCT6776F Super IO Sensors",
 
2058
                driver => "nct6775",
 
2059
                devid => 0xC330,
 
2060
                devid_mask => 0xFFF0,
 
2061
                logdev => 0x0b,
 
2062
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
 
2063
        }, {
 
2064
                name => "Nuvoton NCT5532D/NCT6779D Super IO Sensors",
 
2065
                driver => "nct6775",
 
2066
                devid => 0xC560,
 
2067
                devid_mask => 0xFFF0,
 
2068
                logdev => 0x0b,
 
2069
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
 
2070
        }, {
 
2071
                name => "Nuvoton NCT6102D/NCT6104D/NCT6106D Super IO Sensors",
 
2072
                driver => "to-be-written",      # nct6775
 
2073
                devid => 0xC450,
 
2074
                devid_mask => 0xFFF0,
2059
2075
                logdev => 0x0b,
2060
2076
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2061
2077
        }, {
2225
2241
                logdev => 0x04,
2226
2242
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2227
2243
        }, {
 
2244
                name => "ITE IT8752F Super IO Sensors",
 
2245
                driver => "to-be-written",      # it87
 
2246
                devid => 0x8752,
 
2247
                logdev => 0x04,
 
2248
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
 
2249
        }, {
2228
2250
                name => "ITE IT8771E Super IO Sensors",
2229
 
                driver => "to-be-written",      # it87
 
2251
                driver => "it87",
2230
2252
                devid => 0x8771,
2231
2253
                logdev => 0x04,
2232
2254
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2233
2255
        }, {
2234
2256
                name => "ITE IT8772E Super IO Sensors",
2235
 
                driver => "to-be-written",      # it87
 
2257
                driver => "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,
2245
2267
        }, {
2246
2268
                name => "ITE IT8782F Super IO Sensors",
2247
 
                driver => "to-be-written",      # it87
 
2269
                driver => "it87",
2248
2270
                devid => 0x8782,
2249
2271
                logdev => 0x04,
2250
2272
                features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
2251
2273
        }, {
2252
2274
                name => "ITE IT8783F Super IO Sensors",
2253
 
                driver => "to-be-written",      # it87
 
2275
                driver => "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') },
2356
2378
        }, {
 
2379
                name => "AMD Family 16h power sensors",
 
2380
                driver => "fam15h_power",
 
2381
                detect => sub { amd_pci_detect('1534') },
 
2382
        }, {
2357
2383
                name => "Intel digital thermal sensor",
2358
2384
                driver => "coretemp",
2359
2385
                detect => \&coretemp_detect,
2468
2494
 
2469
2495
sub initialize_ioports
2470
2496
{
2471
 
        sysopen(IOPORTS, "/dev/port", O_RDWR)
2472
 
                or die "/dev/port: $!\n";
2473
 
        binmode(IOPORTS);
 
2497
        if (sysopen(IOPORTS, "/dev/port", O_RDWR)) {
 
2498
                binmode(IOPORTS);
 
2499
                return 1;
 
2500
        }
 
2501
        print STDERR "/dev/port: $!\n";
 
2502
        return 0;
2474
2503
}
2475
2504
 
2476
2505
sub close_ioports
2770
2799
{
2771
2800
        local $_;
2772
2801
 
 
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))) {
 
2806
                        next if m/^\./;
 
2807
                        $modules_list{$1} = 1 if m/^(\S*)/;
 
2808
                }
 
2809
                return;
 
2810
        }
 
2811
 
 
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*)/;
2777
2816
        }
2778
2817
}
3498
3537
                                print("Can't set I2C address for $dev\n"),
3499
3538
                                next;
3500
3539
 
3501
 
                        initialize_ioports();
3502
 
                        $alias_detect = $detected->[$isa]->{alias_detect};
3503
 
                        $is_alias = &$alias_detect($detected->[$isa]->{isa_addr},
3504
 
                                                   \*FILE,
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},
 
3543
                                                           \*FILE,
 
3544
                                                           $detected->[$i2c]->{i2c_addr});
 
3545
                                close_ioports();
 
3546
                        }
3506
3547
                        close(FILE);
3507
 
                        close_ioports();
3508
3548
 
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;
4318
4358
}
4319
4359
 
4320
 
# Registers used:
4321
 
#   0xAA: Temperature
4322
 
#   0xA1: High limit
4323
 
#   0xA2: Low limit
4324
 
#   0xA8: Counter
4325
 
#   0xA9: Slope
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.
4335
 
sub ds1621_detect
4336
 
{
4337
 
        my ($file, $addr) = @_;
4338
 
 
4339
 
        my $conf = i2c_smbus_read_byte_data($file, 0xAC);
4340
 
        return if ($conf & 0x10);
4341
 
 
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);
4351
 
 
4352
 
        return if ($temp == 0 && $high == 0 && $low == 0 && $conf == 0);
4353
 
 
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;
4359
 
}
4360
 
 
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,
4507
 
#                 15 = G781
 
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
4624
4623
        }
 
4624
        if ($chip == 16) {
 
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
 
4629
        }
 
4630
        if ($chip == 17) {
 
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
 
4635
        }
4625
4636
        return;
4626
4637
}
4627
4638
 
4693
4704
        return 5;
4694
4705
}
4695
4706
 
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;
4727
4748
        }
4728
4749
 
4729
4750
        return 6;
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
6107
6131
        }
6108
6132
 
6109
6133
        # Now, do it all again with words. Note that we get
6161
6185
        } elsif ($chip == 14) {
6162
6186
                return unless $manid == 0x1f00;         # Atmel
6163
6187
                return unless ($devid & 0xfeff) == 0x0082; # AT30TS00
 
6188
        } elsif ($chip == 15) {
 
6189
                return unless $manid == 0x5400;         # MCP
 
6190
                return unless ($devid & 0xfcff) == 0x0022; # MCP98244
6164
6191
        }
6165
6192
 
6166
6193
        return 5;
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);
6765
 
                        close_ioports();
 
6789
                        if (initialize_ioports()) {
 
6790
                                $superio_features |= scan_superio(0x2e, 0x2f);
 
6791
                                $superio_features |= scan_superio(0x4e, 0x4f);
 
6792
                                close_ioports();
 
6793
                        }
6766
6794
                }
6767
6795
                print "\n";
6768
6796
 
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);
6780
 
                                        close_ioports();
 
6806
                                        if (initialize_ioports()) {
 
6807
                                                scan_isa_bus(\@ipmi_ifs);
 
6808
                                                close_ioports();
 
6809
                                        }
6781
6810
                                }
6782
6811
                        }
6783
6812
                        print "\n";
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);
6796
 
                        close_ioports();
 
6823
                        if (initialize_ioports()) {
 
6824
                                scan_isa_bus(\@chip_ids);
 
6825
                                close_ioports();
 
6826
                        }
6797
6827
                }
6798
6828
                print "\n";
6799
6829
        }