3
# sensors-detect - Detect hardware monitoring chips
4
# Copyright (C) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>
5
# Copyright (C) 2004 - 2009 Jean Delvare <khali@linux-fr.org>
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
29
# We will call modprobe, which typically lives in either /sbin,
30
# /usr/sbin or /usr/local/bin. So make sure these are all in the PATH.
31
foreach ('/usr/sbin', '/usr/local/sbin', '/sbin') {
32
$ENV{PATH} = "$_:".$ENV{PATH}
33
unless $ENV{PATH} =~ m/(^|:)$_\/?(:|$)/;
36
#########################
37
# CONSTANT DECLARATIONS #
38
#########################
40
use constant NO_CACHE => 1;
41
use vars qw(@pci_adapters @chip_ids @ipmi_ifs @non_hwmon_chip_ids
42
$i2c_addresses_to_scan $revision @i2c_byte_cache);
44
$revision = '$Revision: 5861 $ ($Date: 2010-09-21 17:21:05 +0200 (mar. 21 sept. 2010) $)';
45
$revision =~ s/\$\w+: (.*?) \$/$1/g;
46
$revision =~ s/ \([^()]*\)//;
48
# This is the list of SMBus or I2C adapters we recognize by their PCI
49
# signature. This is an easy and fast way to determine which SMBus or I2C
50
# adapters should be present.
51
# Each entry must have a vendid (Vendor ID), devid (Device ID) and
52
# procid (Device name) and driver (Device driver).
57
procid => "Intel 82371AB PIIX4 ACPI",
58
driver => "i2c-piix4",
62
procid => "Intel 82372FB PIIX5 ACPI",
63
driver => "to-be-tested",
67
procid => "Intel 82443MX Mobile",
68
driver => "i2c-piix4",
72
procid => "Intel 82801AA ICH",
77
procid => "Intel 82801AB ICH0",
82
procid => "Intel 82801BA ICH2",
87
procid => "Intel 82801CA/CAM ICH3",
92
procid => "Intel 82801DB ICH4",
97
procid => "Intel 82801EB ICH5",
102
procid => "Intel 6300ESB",
103
driver => "i2c-i801",
107
procid => "Intel Enterprise Southbridge - ESB2",
108
driver => "i2c-i801",
112
procid => "Intel 82801FB ICH6",
113
driver => "i2c-i801",
117
procid => "Intel 82801G ICH7",
118
driver => "i2c-i801",
122
procid => "Intel 82801H ICH8",
123
driver => "i2c-i801",
127
procid => "Intel ICH9",
128
driver => "i2c-i801",
132
procid => "Intel Tolapai",
133
driver => "i2c-i801",
137
procid => "Intel ICH10",
138
driver => "i2c-i801",
142
procid => "Intel ICH10",
143
driver => "i2c-i801",
147
procid => "Intel 3400/5 Series (PCH)",
148
driver => "i2c-i801",
152
procid => "Intel Cougar Point (PCH)",
153
driver => "i2c-i801",
157
procid => "Intel SCH",
158
driver => "i2c-isch",
162
procid => "VIA Technologies VT82C586B Apollo ACPI",
167
procid => "VIA Technologies VT82C596 Apollo ACPI",
168
driver => "i2c-viapro",
172
procid => "VIA Technologies VT82C596B ACPI",
173
driver => "i2c-viapro",
177
procid => "VIA Technologies VT82C686 Apollo ACPI",
178
driver => "i2c-viapro",
182
procid => "VIA Technologies VT8233 VLink South Bridge",
183
driver => "i2c-viapro",
187
procid => "VIA Technologies VT8233A South Bridge",
188
driver => "i2c-viapro",
192
procid => "VIA Technologies VT8233A/8235 South Bridge",
193
driver => "i2c-viapro",
197
procid => "VIA Technologies VT8237 South Bridge",
198
driver => "i2c-viapro",
202
procid => "VIA Technologies VT8237A South Bridge",
203
driver => "i2c-viapro",
207
procid => "VIA Technologies VT8231 South Bridge",
208
driver => "i2c-viapro",
212
procid => "VIA Technologies VT8251 South Bridge",
213
driver => "i2c-viapro",
217
procid => "VIA Technologies CX700 South Bridge",
218
driver => "i2c-viapro",
222
procid => "VIA Technologies VX800/VX820 South Bridge",
223
driver => "i2c-viapro",
227
procid => "Silicon Integrated Systems SIS5595",
228
driver => "i2c-sis5595",
232
procid => "Silicon Integrated Systems SIS630",
233
driver => "i2c-sis630",
237
procid => "Silicon Integrated Systems SIS730",
238
driver => "i2c-sis630",
242
procid => "Silicon Integrated Systems SMBus Controller",
243
driver => "i2c-sis96x",
245
# Both Ali chips below have same PCI ID. Can't be helped. Only one should load.
248
procid => "Acer Labs 1533/1543",
249
driver => "i2c-ali15x3",
253
procid => "Acer Labs 1535",
254
driver => "i2c-ali1535",
258
procid => "Acer Labs 1563",
259
driver => "i2c-ali1563",
263
procid => "AMD-756 Athlon ACPI",
264
driver => "i2c-amd756",
268
procid => "AMD-766 Athlon ACPI",
269
driver => "i2c-amd756",
273
procid => "AMD-768 System Management",
274
driver => "i2c-amd756",
278
procid => "AMD-8111 ACPI",
279
driver => "i2c-amd756",
283
procid => "AMD-8111 SMBus 2.0",
284
driver => "i2c-amd8111",
288
procid => "nVidia nForce SMBus",
289
driver => "i2c-amd756",
293
procid => "nVidia Corporation nForce2 SMBus (MCP)",
294
driver => "i2c-nforce2",
298
procid => "nVidia Corporation nForce2 Ultra 400 SMBus (MCP)",
299
driver => "i2c-nforce2",
303
procid => "nVidia Corporation nForce3 Pro150 SMBus (MCP)",
304
driver => "i2c-nforce2",
308
procid => "nVidia Corporation nForce3 250Gb SMBus (MCP)",
309
driver => "i2c-nforce2",
313
procid => "nVidia Corporation nForce4 SMBus (MCP)",
314
driver => "i2c-nforce2",
318
procid => "nVidia Corporation nForce4 SMBus (MCP-04)",
319
driver => "i2c-nforce2",
323
procid => "nVidia Corporation nForce SMBus (MCP51)",
324
driver => "i2c-nforce2",
328
procid => "nVidia Corporation nForce SMBus (MCP55)",
329
driver => "i2c-nforce2",
333
procid => "nVidia Corporation nForce SMBus (MCP61)",
334
driver => "i2c-nforce2",
338
procid => "nVidia Corporation nForce SMBus (MCP65)",
339
driver => "i2c-nforce2",
343
procid => "nVidia Corporation nForce SMBus (MCP67)",
344
driver => "i2c-nforce2",
348
procid => "nVidia Corporation nForce SMBus (MCP73)",
349
driver => "i2c-nforce2",
353
procid => "nVidia Corporation nForce SMBus (MCP78S)",
354
driver => "i2c-nforce2",
358
procid => "nVidia Corporation nForce SMBus (MCP79)",
359
driver => "i2c-nforce2",
363
procid => "ServerWorks OSB4 South Bridge",
364
driver => "i2c-piix4",
368
procid => "SMSC Victory66 South Bridge",
369
driver => "i2c-piix4",
373
procid => "ServerWorks CSB5 South Bridge",
374
driver => "i2c-piix4",
378
procid => "ServerWorks CSB6 South Bridge",
379
driver => "i2c-piix4",
383
procid => "ServerWorks HT-1000 South Bridge",
384
driver => "i2c-piix4",
388
procid => "ATI Technologies Inc ATI SMBus",
389
driver => "i2c-piix4",
393
procid => "ATI Technologies Inc ATI SMBus",
394
driver => "i2c-piix4",
398
procid => "ATI Technologies Inc IXP SB400 SMBus Controller",
399
driver => "i2c-piix4",
403
procid => "ATI Technologies Inc SB600/SB700/SB800 SMBus",
404
driver => "i2c-piix4",
408
procid => "AMD Hudson-2 SMBus",
409
driver => "i2c-piix4",
413
procid => "SCx200 Bridge",
414
driver => "scx200_acb",
418
procid => "SC1100 Bridge",
419
driver => "scx200_acb",
423
procid => "CS5535 ISA bridge",
424
driver => "scx200_acb",
428
procid => "CS5536 [Geode companion] ISA",
429
driver => "scx200_acb",
433
# Look-up table to find out an I2C bus' driver based on the bus name.
434
# The match field should contain a regular expression matching the I2C
435
# bus name as it would appear in sysfs.
436
# Note that new drivers probably don't need to be added to this table
437
# if they bind to their device, as we will be able to get the driver name
438
# from sysfs directly.
439
use vars qw(@i2c_adapter_names);
440
@i2c_adapter_names = (
441
{ driver => "i2c-piix4", match => qr/^SMBus PIIX4 adapter at / },
442
{ driver => "i2c-i801", match => qr/^SMBus I801 adapter at / },
443
{ driver => "i2c-via", match => qr/^VIA i2c/ },
444
{ driver => "i2c-viapro", match => qr/^SMBus V(IA|ia) Pro adapter at / },
445
{ driver => "i2c-sis5595", match => qr/^SMBus SIS5595 adapter at / },
446
{ driver => "i2c-sis630", match => qr/^SMBus SIS630 adapter at / },
447
{ driver => "i2c-sis96x", match => qr/^SiS96x SMBus adapter at / },
448
{ driver => "i2c-ali15x3", match => qr/^SMBus ALI15X3 adapter at / },
449
{ driver => "i2c-ali1535", match => qr/^SMBus ALI1535 adapter at/ },
450
{ driver => "i2c-ali1563", match => qr/^SMBus ALi 1563 Adapter @ / },
451
{ driver => "i2c-amd756", match => qr/^SMBus (AMD756|AMD766|AMD768|AMD8111|nVidia nForce) adapter at / },
452
{ driver => "i2c-amd8111", match => qr/^SMBus2 AMD8111 adapter at / },
453
{ driver => "i2c-nforce2", match => qr/^SMBus nForce2 adapter at / },
454
{ driver => "scx200_acb", match => qr/^(NatSemi SCx200 ACCESS\.bus|SCx200 ACB\d+|CS553[56] ACB\d+)/ },
457
# This is a list of all recognized I2C and ISA chips.
458
# Each entry must have the following fields:
459
# name: The full chip name
460
# driver: The driver name. Put in exactly:
461
# * "to-be-written" if it is not yet available
462
# * "use-isa-instead" if no i2c driver will be written
463
# i2c_addrs (optional): For I2C chips, the list of I2C addresses to
465
# i2c_detect (optional): For I2C chips, the function to call to detect
466
# this chip. The function will be passed two parameters: an open file
467
# descriptor to access the bus, and the I2C address to probe.
468
# isa_addrs (optional): For ISA chips, the list of port addresses to
470
# isa_detect (optional): For ISA chips, the function to call to detect
471
# this chip. The function will be passed one parameter: the ISA address
473
# alias_detect (optional): For chips which can be both on the ISA and the
474
# I2C bus, a function which detects whether two entries are the same.
475
# The function will be passed three parameters: the ISA address, an
476
# open file descriptor to access the I2C bus, and the I2C address.
479
name => "Myson MTP008",
481
i2c_addrs => [0x2c..0x2e],
482
i2c_detect => sub { mtp008_detect(@_); },
484
name => "National Semiconductor LM78",
486
i2c_addrs => [0x28..0x2f],
487
i2c_detect => sub { lm78_detect(@_, 0); },
488
isa_addrs => [0x290],
489
isa_detect => sub { lm78_isa_detect(@_, 0); },
490
alias_detect => sub { winbond_alias_detect(@_, 0x2b, 0x3d); },
492
name => "National Semiconductor LM79",
494
i2c_addrs => [0x28..0x2f],
495
i2c_detect => sub { lm78_detect(@_, 2); },
496
isa_addrs => [0x290],
497
isa_detect => sub { lm78_isa_detect(@_, 2); },
498
alias_detect => sub { winbond_alias_detect(@_, 0x2b, 0x3d); },
500
name => "National Semiconductor LM75",
502
i2c_addrs => [0x48..0x4f],
503
i2c_detect => sub { lm75_detect(@_, 0); },
505
name => "Dallas Semiconductor DS75",
507
i2c_addrs => [0x48..0x4f],
508
i2c_detect => sub { lm75_detect(@_, 1); },
510
name => "National Semiconductor LM77",
512
i2c_addrs => [0x48..0x4b],
513
i2c_detect => sub { lm77_detect(@_); },
515
name => "National Semiconductor LM80",
517
i2c_addrs => [0x28..0x2f],
518
i2c_detect => sub { lm80_detect(@_); },
520
name => "National Semiconductor LM85",
522
i2c_addrs => [0x2c..0x2e],
523
i2c_detect => sub { lm85_detect(@_, 0); },
525
name => "National Semiconductor LM96000 or PC8374L",
527
i2c_addrs => [0x2c..0x2e],
528
i2c_detect => sub { lm85_detect(@_, 1); },
530
name => "Analog Devices ADM1027",
532
i2c_addrs => [0x2c..0x2e],
533
i2c_detect => sub { lm85_detect(@_, 2); },
535
name => "Analog Devices ADT7460 or ADT7463",
537
i2c_addrs => [0x2c..0x2e],
538
i2c_detect => sub { lm85_detect(@_, 3); },
540
name => "SMSC EMC6D100 or EMC6D101",
542
i2c_addrs => [0x2c..0x2e],
543
i2c_detect => sub { lm85_detect(@_, 4); },
545
name => "SMSC EMC6D102",
547
i2c_addrs => [0x2c..0x2e],
548
i2c_detect => sub { lm85_detect(@_, 5); },
550
name => "SMSC EMC6D103",
552
i2c_addrs => [0x2c..0x2e],
553
i2c_detect => sub { lm85_detect(@_, 6); },
555
name => "Winbond WPCD377I",
556
driver => "not-a-sensor",
557
i2c_addrs => [0x2c..0x2e],
558
i2c_detect => sub { lm85_detect(@_, 7); },
560
name => "Analog Devices ADT7462",
562
i2c_addrs => [0x5c, 0x58],
563
i2c_detect => sub { adt7467_detect(@_, 2); },
565
name => "Analog Devices ADT7466",
568
i2c_detect => sub { adt7467_detect(@_, 3); },
570
name => "Analog Devices ADT7467 or ADT7468",
573
i2c_detect => sub { adt7467_detect(@_, 0); },
575
name => "Analog Devices ADT7470",
577
i2c_addrs => [0x2c, 0x2e, 0x2f],
578
i2c_detect => sub { adt7467_detect(@_, 4); },
580
name => "Analog Devices ADT7473",
581
driver => sub { kernel_version_at_least(2, 6, 33) ? "adt7475" : "adt7473" },
582
i2c_addrs => [0x2c..0x2e],
583
i2c_detect => sub { adt7473_detect(@_, 0); },
585
name => "Analog Devices ADT7475",
588
i2c_detect => sub { adt7473_detect(@_, 1); },
590
name => "Analog Devices ADT7476",
592
i2c_addrs => [0x2c..0x2e],
593
i2c_detect => sub { adt7467_detect(@_, 1); },
595
name => "Analog Devices ADT7490",
597
i2c_addrs => [0x2c..0x2e],
598
i2c_detect => sub { adt7490_detect(@_); },
600
name => "Analog Devices ADT7411",
601
driver => "to-be-written",
602
i2c_addrs => [0x48, 0x4a, 0x4b],
603
i2c_detect => sub { adt7411_detect(@_); },
605
name => "Andigilog aSC7511",
606
driver => "to-be-written",
608
i2c_detect => sub { andigilog_aSC7511_detect(@_); },
610
name => "Andigilog aSC7512",
611
driver => "to-be-written",
613
i2c_detect => sub { andigilog_detect(@_, 0); },
615
name => "Andigilog aSC7611",
616
driver => "to-be-written",
617
i2c_addrs => [0x2c..0x2e],
618
i2c_detect => sub { andigilog_detect(@_, 1); },
620
name => "Andigilog aSC7621",
622
i2c_addrs => [0x2c..0x2e],
623
i2c_detect => sub { andigilog_detect(@_, 2); },
625
name => "National Semiconductor LM87",
627
i2c_addrs => [0x2c..0x2e],
628
i2c_detect => sub { lm87_detect(@_, 0); },
630
name => "Analog Devices ADM1024",
632
i2c_addrs => [0x2c..0x2e],
633
i2c_detect => sub { lm87_detect(@_, 1); },
635
name => "National Semiconductor LM93",
637
i2c_addrs => [0x2c..0x2e],
638
i2c_detect => sub { lm93_detect(@_); },
640
name => "Winbond W83781D",
642
i2c_addrs => [0x28..0x2f],
643
i2c_detect => sub { w83781d_detect(@_, 0); },
644
isa_addrs => [0x290],
645
isa_detect => sub { w83781d_isa_detect(@_, 0); },
646
alias_detect => sub { winbond_alias_detect(@_, 0x2b, 0x3d); },
648
name => "Winbond W83782D",
650
i2c_addrs => [0x28..0x2f],
651
i2c_detect => sub { w83781d_detect(@_, 1); },
652
isa_addrs => [0x290],
653
isa_detect => sub { w83781d_isa_detect(@_, 1); },
654
alias_detect => sub { winbond_alias_detect(@_, 0x2b, 0x3d); },
656
name => "Winbond W83783S",
659
i2c_detect => sub { w83781d_detect(@_, 2); },
661
name => "Winbond W83791D",
663
i2c_addrs => [0x2c..0x2f],
664
i2c_detect => sub { w83781d_detect(@_, 7); },
666
name => "Winbond W83792D",
668
i2c_addrs => [0x2c..0x2f],
669
i2c_detect => sub { w83781d_detect(@_, 8); },
671
name => "Winbond W83793R/G",
673
i2c_addrs => [0x2c..0x2f],
674
i2c_detect => sub { w83793_detect(@_); },
676
name => "Nuvoton W83795G/ADG",
678
i2c_addrs => [0x2c..0x2f],
679
i2c_detect => sub { w83795_detect(@_); },
681
name => "Winbond W83627HF",
682
driver => "use-isa-instead",
683
i2c_addrs => [0x28..0x2f],
684
i2c_detect => sub { w83781d_detect(@_, 3); },
686
name => "Winbond W83627EHF",
687
driver => "use-isa-instead",
688
i2c_addrs => [0x28..0x2f],
689
i2c_detect => sub { w83781d_detect(@_, 9); },
691
name => "Winbond W83627DHG/W83667HG/W83677HG",
692
driver => "use-isa-instead",
693
i2c_addrs => [0x28..0x2f],
694
i2c_detect => sub { w83781d_detect(@_, 10); },
696
name => "Asus AS99127F (rev.1)",
698
i2c_addrs => [0x28..0x2f],
699
i2c_detect => sub { w83781d_detect(@_, 4); },
701
name => "Asus AS99127F (rev.2)",
703
i2c_addrs => [0x28..0x2f],
704
i2c_detect => sub { w83781d_detect(@_, 5); },
706
name => "Asus ASB100 Bach",
708
i2c_addrs => [0x28..0x2f],
709
i2c_detect => sub { w83781d_detect(@_, 6); },
711
name => "Asus Mozart-2",
712
driver => "to-be-written",
714
i2c_detect => sub { mozart_detect(@_); },
716
name => "Winbond W83L784R/AR/G",
717
driver => "to-be-written",
719
i2c_detect => sub { w83l784r_detect(@_, 0); },
721
name => "Winbond W83L785R/G",
722
driver => "to-be-written",
724
i2c_detect => sub { w83l784r_detect(@_, 1); },
726
name => "Winbond W83L786NR/NG/R/G",
727
driver => "w83l786ng",
728
i2c_addrs => [0x2e, 0x2f],
729
i2c_detect => sub { w83l784r_detect(@_, 2); },
731
name => "Winbond W83L785TS-S",
732
driver => "w83l785ts",
734
i2c_detect => sub { w83l784r_detect(@_, 3); },
736
name => "Genesys Logic GL518SM",
738
i2c_addrs => [0x2c, 0x2d],
739
i2c_detect => sub { gl518sm_detect(@_, 0); },
741
name => "Genesys Logic GL520SM",
743
i2c_addrs => [0x2c, 0x2d],
744
i2c_detect => sub { gl518sm_detect(@_, 1); },
746
name => "Genesys Logic GL525SM",
747
driver => "to-be-written",
749
i2c_detect => sub { gl525sm_detect(@_); },
751
name => "Analog Devices ADM9240",
753
i2c_addrs => [0x2c..0x2f],
754
i2c_detect => sub { adm9240_detect(@_, 0); },
756
name => "Dallas Semiconductor DS1621/DS1631",
758
i2c_addrs => [0x48..0x4f],
759
i2c_detect => sub { ds1621_detect(@_); },
761
name => "Dallas Semiconductor DS1780",
763
i2c_addrs => [0x2c..0x2f],
764
i2c_detect => sub { adm9240_detect(@_, 1); },
766
name => "National Semiconductor LM81",
768
i2c_addrs => [0x2c..0x2f],
769
i2c_detect => sub { adm9240_detect(@_, 2); },
771
name => "Analog Devices ADM1026",
773
i2c_addrs => [0x2c..0x2e],
774
i2c_detect => sub { adm1026_detect(@_); },
776
name => "Analog Devices ADM1025",
778
i2c_addrs => [0x2c..0x2e],
779
i2c_detect => sub { adm1025_detect(@_, 0); },
781
name => "Philips NE1619",
783
i2c_addrs => [0x2c..0x2d],
784
i2c_detect => sub { adm1025_detect(@_, 1); },
786
name => "Analog Devices ADM1021",
788
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
789
i2c_detect => sub { adm1021_detect(@_, 0); },
791
name => "Analog Devices ADM1021A/ADM1023",
793
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
794
i2c_detect => sub { adm1021_detect(@_, 1); },
796
name => "Maxim MAX1617",
798
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
799
i2c_detect => sub { adm1021_detect(@_, 2); },
801
name => "Maxim MAX1617A",
803
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
804
i2c_detect => sub { adm1021_detect(@_, 3); },
806
name => "Maxim MAX1668",
808
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
809
i2c_detect => sub { max1668_detect(@_, 0); },
811
name => "Maxim MAX1805",
813
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
814
i2c_detect => sub { max1668_detect(@_, 1); },
816
name => "Maxim MAX1989",
818
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
819
i2c_detect => sub { max1668_detect(@_, 2); },
821
name => "Maxim MAX6650/MAX6651",
823
i2c_addrs => [0x1b, 0x1f, 0x48, 0x4b],
824
i2c_detect => sub { max6650_detect(@_); },
826
name => "Maxim MAX6655/MAX6656",
828
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
829
i2c_detect => sub { max6655_detect(@_); },
833
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
834
i2c_detect => sub { adm1021_detect(@_, 4); },
836
name => "National Semiconductor LM84",
838
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
839
i2c_detect => sub { adm1021_detect(@_, 5); },
841
name => "Genesys Logic GL523SM",
843
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
844
i2c_detect => sub { adm1021_detect(@_, 6); },
846
name => "Onsemi MC1066",
848
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
849
i2c_detect => sub { adm1021_detect(@_, 7); },
851
name => "Maxim MAX1618",
853
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
854
i2c_detect => sub { max1619_detect(@_, 1); },
856
name => "Maxim MAX1619",
858
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
859
i2c_detect => sub { max1619_detect(@_, 0); },
861
name => "National Semiconductor LM82/LM83",
863
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
864
i2c_detect => sub { lm83_detect(@_); },
866
name => "National Semiconductor LM90",
869
i2c_detect => sub { lm90_detect(@_, 0); },
871
name => "National Semiconductor LM89/LM99",
873
i2c_addrs => [0x4c..0x4d],
874
i2c_detect => sub { lm90_detect(@_, 1); },
876
name => "National Semiconductor LM86",
879
i2c_detect => sub { lm90_detect(@_, 2); },
881
name => "Analog Devices ADM1032",
883
i2c_addrs => [0x4c..0x4d],
884
i2c_detect => sub { lm90_detect(@_, 3); },
886
name => "Maxim MAX6654",
887
driver => "to-be-written", # probably lm90
888
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
889
i2c_detect => sub { lm90_detect(@_, 4); },
891
name => "Maxim MAX6690",
892
driver => "to-be-written", # probably lm90
893
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
894
i2c_detect => sub { lm90_detect(@_, 12); },
896
name => "Maxim MAX6657/MAX6658/MAX6659",
899
i2c_detect => sub { max6657_detect(@_); },
901
name => "Maxim MAX6659",
903
i2c_addrs => [0x4d..0x4e], # 0x4c is handled above
904
i2c_detect => sub { max6657_detect(@_); },
906
name => "Maxim MAX6646",
909
i2c_detect => sub { lm90_detect(@_, 6); },
911
name => "Maxim MAX6647",
914
i2c_detect => sub { lm90_detect(@_, 6); },
916
name => "Maxim MAX6648/MAX6649/MAX6692",
919
i2c_detect => sub { lm90_detect(@_, 6); },
921
name => "Maxim MAX6680/MAX6681",
923
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
924
i2c_detect => sub { max6680_95_detect(@_, 0); },
926
name => "Maxim MAX6695/MAX6696",
928
i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
929
i2c_detect => sub { max6680_95_detect(@_, 1); },
931
name => "Winbond W83L771W/G",
932
driver => "to-be-written",
934
i2c_detect => sub { lm90_detect(@_, 8); },
936
name => "Winbond W83L771AWG/ASG",
939
i2c_detect => sub { lm90_detect(@_, 11); },
941
name => "Texas Instruments TMP401",
944
i2c_detect => sub { lm90_detect(@_, 9); },
946
name => "Texas Instruments TMP411",
948
i2c_addrs => [0x4c..0x4e],
949
i2c_detect => sub { lm90_detect(@_, 10); },
951
name => "Texas Instruments TMP421",
953
i2c_addrs => [0x2a, 0x4c..0x4f], # 0x1c-0x1f not probed.
954
i2c_detect => sub { tmp42x_detect(@_, 0); },
956
name => "Texas Instruments TMP422",
958
i2c_addrs => [0x4c..0x4f],
959
i2c_detect => sub { tmp42x_detect(@_, 1); },
961
name => "Texas Instruments TMP423",
963
i2c_addrs => [0x4c, 0x4d],
964
i2c_detect => sub { tmp42x_detect(@_, 2); },
966
name => "Texas Instruments AMC6821",
968
i2c_addrs => [0x18..0x1a, 0x2c..0x2e, 0x4c..0x4e],
969
i2c_detect => sub { amc6821_detect(@_); },
971
name => "National Semiconductor LM95231",
972
driver => "to-be-written",
973
i2c_addrs => [0x2b, 0x19, 0x2a],
974
i2c_detect => sub { lm95231_detect(@_, 0); },
976
name => "National Semiconductor LM95241",
978
i2c_addrs => [0x2b, 0x19, 0x2a],
979
i2c_detect => sub { lm95231_detect(@_, 1); },
981
name => "National Semiconductor LM63",
984
i2c_detect => sub { lm63_detect(@_, 1); },
986
name => "National Semiconductor LM64",
988
i2c_addrs => [0x18, 0x4e],
989
i2c_detect => sub { lm63_detect(@_, 3); },
991
name => "Fintek F75363SG",
992
driver => "lm63", # Not yet
994
i2c_detect => sub { lm63_detect(@_, 2); },
996
name => "National Semiconductor LM73",
998
i2c_addrs => [0x48..0x4a, 0x4c..0x4e],
999
i2c_detect => sub { lm73_detect(@_); },
1001
name => "National Semiconductor LM92",
1003
i2c_addrs => [0x48..0x4b],
1004
i2c_detect => sub { lm92_detect(@_, 0); },
1006
name => "National Semiconductor LM76",
1008
i2c_addrs => [0x48..0x4b],
1009
i2c_detect => sub { lm92_detect(@_, 1); },
1011
name => "Maxim MAX6633/MAX6634/MAX6635",
1013
i2c_addrs => [0x48..0x4f], # The MAX6633 can also use 0x40-0x47 but we
1014
# don't want to probe these addresses, it's
1016
i2c_detect => sub { lm92_detect(@_, 2); },
1018
name => "Analog Devices ADT7461",
1020
i2c_addrs => [0x4c..0x4d],
1021
i2c_detect => sub { lm90_detect(@_, 5); },
1023
name => "Analog Devices ADT7481",
1024
driver => "to-be-written",
1025
i2c_addrs => [0x4c, 0x4b],
1026
i2c_detect => sub { adt7481_detect(@_); },
1028
name => "Analog Devices ADM1029",
1029
driver => "adm1029",
1030
i2c_addrs => [0x28..0x2f],
1031
i2c_detect => sub { adm1029_detect(@_); },
1033
name => "Analog Devices ADM1030",
1034
driver => "adm1031",
1035
i2c_addrs => [0x2c..0x2e],
1036
i2c_detect => sub { adm1031_detect(@_, 0); },
1038
name => "Analog Devices ADM1031",
1039
driver => "adm1031",
1040
i2c_addrs => [0x2c..0x2e],
1041
i2c_detect => sub { adm1031_detect(@_, 1); },
1043
name => "Analog Devices ADM1033",
1044
driver => "to-be-written",
1045
i2c_addrs => [0x50..0x53],
1046
i2c_detect => sub { adm1034_detect(@_, 0); },
1048
name => "Analog Devices ADM1034",
1049
driver => "to-be-written",
1050
i2c_addrs => [0x50..0x53],
1051
i2c_detect => sub { adm1034_detect(@_, 1); },
1053
name => "Analog Devices ADM1022",
1055
i2c_addrs => [0x2c..0x2e],
1056
i2c_detect => sub { adm1022_detect(@_, 0); },
1058
name => "Texas Instruments THMC50",
1060
i2c_addrs => [0x2c..0x2e],
1061
i2c_detect => sub { adm1022_detect(@_, 1); },
1063
name => "Analog Devices ADM1028",
1065
i2c_addrs => [0x2e],
1066
i2c_detect => sub { adm1022_detect(@_, 2); },
1068
name => "Texas Instruments THMC51",
1069
driver => "to-be-written", # thmc50
1070
i2c_addrs => [0x2e], # At least (no datasheet)
1071
i2c_detect => sub { adm1022_detect(@_, 3); },
1073
name => "VIA VT1211 (I2C)",
1074
driver => "use-isa-instead",
1075
i2c_addrs => [0x2d],
1076
i2c_detect => sub { vt1211_i2c_detect(@_); },
1078
name => "ITE IT8712F",
1080
i2c_addrs => [0x28..0x2f],
1081
i2c_detect => sub { it8712_i2c_detect(@_); },
1083
name => "FSC Poseidon I",
1084
driver => sub { kernel_version_at_least(2, 6, 24) ? "fschmd" : "fscpos" },
1085
i2c_addrs => [0x73],
1086
i2c_detect => sub { fsc_detect(@_, 0); },
1088
name => "FSC Poseidon II",
1089
driver => "to-be-written",
1090
i2c_addrs => [0x73],
1091
i2c_detect => sub { fsc_detect(@_, 1); },
1093
name => "FSC Scylla",
1095
i2c_addrs => [0x73],
1096
i2c_detect => sub { fsc_detect(@_, 2); },
1098
name => "FSC Hermes",
1099
driver => sub { kernel_version_at_least(2, 6, 24) ? "fschmd" : "fscher" },
1100
i2c_addrs => [0x73],
1101
i2c_detect => sub { fsc_detect(@_, 3); },
1103
name => "FSC Heimdal",
1105
i2c_addrs => [0x73],
1106
i2c_detect => sub { fsc_detect(@_, 4); },
1108
name => "FSC Heracles",
1110
i2c_addrs => [0x73],
1111
i2c_detect => sub { fsc_detect(@_, 5); },
1113
name => "FSC Hades",
1115
i2c_addrs => [0x73],
1116
i2c_detect => sub { fsc_detect(@_, 6); },
1118
name => "FSC Syleus",
1120
i2c_addrs => [0x73],
1121
i2c_detect => sub { fsc_detect(@_, 7); },
1123
name => "ALi M5879",
1124
driver => "to-be-written",
1125
i2c_addrs => [0x2c..0x2d],
1126
i2c_detect => sub { m5879_detect(@_); },
1128
name => "SMSC LPC47M15x/192/292/997",
1129
driver => "smsc47m192",
1130
i2c_addrs => [0x2c..0x2d],
1131
i2c_detect => sub { smsc47m192_detect(@_); },
1133
name => "SMSC DME1737",
1134
driver => "dme1737",
1135
i2c_addrs => [0x2c..0x2e],
1136
i2c_detect => sub { dme1737_detect(@_, 1); },
1138
name => "SMSC SCH5027D-NW",
1139
driver => "dme1737",
1140
i2c_addrs => [0x2c..0x2e],
1141
i2c_detect => sub { dme1737_detect(@_, 2); },
1143
name => "SMSC EMC2103",
1144
driver => "emc2103",
1145
i2c_addrs => [0x2e],
1146
i2c_detect => sub { emc1403_detect(@_, 2); },
1148
name => "Fintek F75121R/F75122R/RG (VID+GPIO)",
1149
driver => "to-be-written",
1150
i2c_addrs => [0x4e], # 0x37 not probed
1151
i2c_detect => sub { fintek_detect(@_, 2); },
1153
name => "Fintek F75373S/SG",
1154
driver => "f75375s",
1155
i2c_addrs => [0x2d..0x2e],
1156
i2c_detect => sub { fintek_detect(@_, 3); },
1158
name => "Fintek F75375S/SP",
1159
driver => "f75375s",
1160
i2c_addrs => [0x2d..0x2e],
1161
i2c_detect => sub { fintek_detect(@_, 4); },
1163
name => "Fintek F75387SG/RG",
1164
driver => "to-be-written",
1165
i2c_addrs => [0x2d..0x2e],
1166
i2c_detect => sub { fintek_detect(@_, 5); },
1168
name => "Fintek F75383S/M",
1169
driver => "to-be-written",
1170
i2c_addrs => [0x4c],
1171
i2c_detect => sub { fintek_detect(@_, 6); },
1173
name => "Fintek F75384S/M",
1174
driver => "to-be-written",
1175
i2c_addrs => [0x4d],
1176
i2c_detect => sub { fintek_detect(@_, 6); },
1178
name => "Fintek custom power control IC",
1179
driver => "to-be-written",
1180
i2c_addrs => [0x2f],
1181
i2c_detect => sub { fintek_detect(@_, 7); },
1183
name => "SMSC EMC1403",
1184
driver => "emc1403",
1185
i2c_addrs => [0x18, 0x2a, 0x4c, 0x4d],
1186
i2c_detect => sub { emc1403_detect(@_, 0); },
1188
name => "SMSC EMC1404",
1189
driver => "to-be-written", # emc1403
1190
i2c_addrs => [0x18, 0x2a, 0x4c, 0x4d],
1191
i2c_detect => sub { emc1403_detect(@_, 1); },
1193
name => "ST STTS424",
1195
i2c_addrs => [0x18..0x1f],
1196
i2c_detect => sub { jedec_JC42_4_detect(@_, 0); },
1198
name => "ST STTS424E",
1200
i2c_addrs => [0x18..0x1f],
1201
i2c_detect => sub { jedec_JC42_4_detect(@_, 10); },
1203
name => "NXP SE97/SE97B",
1205
i2c_addrs => [0x18..0x1f],
1206
i2c_detect => sub { jedec_JC42_4_detect(@_, 1); },
1210
i2c_addrs => [0x18..0x1f],
1211
i2c_detect => sub { jedec_JC42_4_detect(@_, 2); },
1213
name => "Analog Devices ADT7408",
1215
i2c_addrs => [0x18..0x1f],
1216
i2c_detect => sub { jedec_JC42_4_detect(@_, 3); },
1218
name => "IDT TS3000/TSE2002",
1220
i2c_addrs => [0x18..0x1f],
1221
i2c_detect => sub { jedec_JC42_4_detect(@_, 4); },
1223
name => "Maxim MAX6604",
1225
i2c_addrs => [0x18..0x1f],
1226
i2c_detect => sub { jedec_JC42_4_detect(@_, 5); },
1228
name => "Microchip MCP98242",
1230
i2c_addrs => [0x18..0x1f],
1231
i2c_detect => sub { jedec_JC42_4_detect(@_, 6); },
1233
name => "Microchip MCP98243",
1235
i2c_addrs => [0x18..0x1f],
1236
i2c_detect => sub { jedec_JC42_4_detect(@_, 7); },
1238
name => "Microchip MCP9843",
1240
i2c_addrs => [0x18..0x1f],
1241
i2c_detect => sub { jedec_JC42_4_detect(@_, 8); },
1243
name => "ON CAT6095/CAT34TS02",
1245
i2c_addrs => [0x18..0x1f],
1246
i2c_detect => sub { jedec_JC42_4_detect(@_, 9); },
1248
name => "Smart Battery",
1249
driver => "sbs", # ACPI driver, not sure if it always works
1250
i2c_addrs => [0x0b],
1251
i2c_detect => sub { smartbatt_detect(@_); },
1255
# IPMI interfaces have their own array now
1258
name => "IPMI BMC KCS",
1259
driver => "ipmisensors",
1260
isa_addrs => [0x0ca0],
1261
isa_detect => sub { ipmi_detect(@_); },
1263
name => "IPMI BMC SMIC",
1264
driver => "ipmisensors",
1265
isa_addrs => [0x0ca8],
1266
isa_detect => sub { ipmi_detect(@_); },
1270
# Here is a similar list, but for devices which are not hardware monitoring
1271
# chips. We only list popular devices which happen to live at the same I2C
1272
# address as recognized hardware monitoring chips. The idea is to make it
1273
# clear that the chip in question is of no interest for lm-sensors.
1274
@non_hwmon_chip_ids = (
1276
name => "Winbond W83791SD",
1277
i2c_addrs => [0x2c..0x2f],
1278
i2c_detect => sub { w83791sd_detect(@_); },
1280
name => "Fintek F75111R/RG/N (GPIO)",
1281
i2c_addrs => [0x37, 0x4e],
1282
i2c_detect => sub { fintek_detect(@_, 1); },
1284
name => "ITE IT8201R/IT8203R/IT8206R/IT8266R",
1285
i2c_addrs => [0x4e],
1286
i2c_detect => sub { ite_overclock_detect(@_); },
1288
name => "SPD EEPROM",
1289
i2c_addrs => [0x50..0x57],
1290
i2c_detect => sub { eeprom_detect(@_); },
1292
name => "EDID EEPROM",
1293
i2c_addrs => [0x50],
1294
i2c_detect => sub { ddcmonitor_detect(@_); },
1298
# This is a list of all recognized superio chips.
1299
# Each entry must have the following fields:
1300
# name: The full chip name
1301
# driver: The driver name. Put in exactly:
1302
# * "to-be-written" if it is not yet available
1303
# * "not-a-sensor" if the chip doesn't have hardware monitoring
1304
# capabilities (listing such chips here removes the need of manual
1305
# lookup when people report them)
1306
# * "via-smbus-only" if this is a Super-I/O chip whose hardware
1307
# monitoring registers can only be accessed via the SMBus
1308
# devid: The device ID we have to match (base device)
1309
# devid_mask (optional): Bitmask to apply before checking the device ID
1310
# logdev: The logical device containing the sensors
1311
# check (optional): A function to refine the detection. Will be passed
1312
# the index and data ports as parameters. Must return 1 for a matching
1313
# device, 0 otherwise.
1314
# features (optional): Features supported by this device, amongst:
1318
use vars qw(@superio_ids_natsemi @superio_ids_smsc @superio_ids_smsc_ns
1319
@superio_ids_winbond @superio_ids_ite @superio_ids);
1321
use constant FEAT_IN => (1 << 0);
1322
use constant FEAT_FAN => (1 << 1);
1323
use constant FEAT_TEMP => (1 << 2);
1324
use constant FEAT_SMBUS => (1 << 7);
1326
@superio_ids_natsemi = (
1328
name => "Nat. Semi. PC8374L Super IO Sensors", # Also Nuvoton WPCD374L
1329
driver => "to-be-written",
1333
# Guess work; seen so far: 0x11
1334
return (inb($_[1]) < 0x80);
1337
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1339
name => "Nuvoton WPCD377I Super IO", # Also WPCD376I
1340
driver => "not-a-sensor",
1344
# Guess work; seen so far: 0x91 (twice)
1345
return (inb($_[1]) >= 0x80);
1348
name => "Nat. Semi. PC87351 Super IO Fan Sensors",
1349
driver => "to-be-written",
1353
name => "Nat. Semi. PC87360 Super IO Fan Sensors",
1354
driver => "pc87360",
1357
features => FEAT_FAN,
1359
name => "Nat. Semi. PC87363 Super IO Fan Sensors",
1360
driver => "pc87360",
1363
features => FEAT_FAN,
1365
name => "Nat. Semi. PC87364 Super IO Fan Sensors",
1366
driver => "pc87360",
1369
features => FEAT_FAN,
1371
name => "Nat. Semi. PC87365 Super IO Fan Sensors",
1372
driver => "pc87360",
1375
features => FEAT_FAN,
1377
name => "Nat. Semi. PC87365 Super IO Voltage Sensors",
1378
driver => "pc87360",
1381
features => FEAT_IN,
1383
name => "Nat. Semi. PC87365 Super IO Thermal Sensors",
1384
driver => "pc87360",
1387
features => FEAT_TEMP,
1389
name => "Nat. Semi. PC87366 Super IO Fan Sensors",
1390
driver => "pc87360",
1393
features => FEAT_FAN,
1395
name => "Nat. Semi. PC87366 Super IO Voltage Sensors",
1396
driver => "pc87360",
1399
features => FEAT_IN,
1401
name => "Nat. Semi. PC87366 Super IO Thermal Sensors",
1402
driver => "pc87360",
1405
features => FEAT_TEMP,
1407
name => "Nat. Semi. PC87372 Super IO Fan Sensors",
1408
driver => "to-be-written",
1411
features => FEAT_FAN,
1413
name => "Nat. Semi. PC87373 Super IO Fan Sensors",
1414
driver => "to-be-written",
1417
features => FEAT_FAN,
1419
name => "Nat. Semi. PC87591 Super IO",
1420
driver => "to-be-written",
1424
name => "Nat. Semi. PC87317 Super IO",
1425
driver => "not-a-sensor",
1428
name => "Nat. Semi. PC97317 Super IO",
1429
driver => "not-a-sensor",
1432
name => "Nat. Semi. PC8739x Super IO",
1433
driver => "not-a-sensor",
1436
name => "Nat. Semi. PC8741x Super IO",
1437
driver => "not-a-sensor",
1440
name => "Nat. Semi. PC87427 Super IO Fan Sensors",
1441
driver => "pc87427",
1444
features => FEAT_FAN,
1446
name => "Nat. Semi. PC87427 Super IO Health Sensors",
1447
driver => "to-be-written",
1450
features => FEAT_IN | FEAT_TEMP,
1452
# Shouldn't be in this family, but there it is
1453
name => "ITE IT8512E/F Super IO",
1454
driver => "not-a-sensor",
1459
@superio_ids_smsc = (
1461
name => "SMSC DME1737 Super IO",
1462
# Hardware monitoring features are accessed on the SMBus
1463
driver => "via-smbus-only",
1466
name => "SMSC DME1737 Super IO",
1467
# The DME1737 shows up twice in this list because it can return either
1468
# 0x78 or 0x77 as its device ID.
1469
# Hardware monitoring features are accessed on the SMBus
1470
driver => "via-smbus-only",
1473
name => "SMSC EMC2700LPC Super IO",
1477
name => "SMSC FDC37B72x Super IO",
1478
driver => "not-a-sensor",
1481
name => "SMSC FDC37B78x Super IO",
1482
driver => "not-a-sensor",
1485
name => "SMSC FDC37C672 Super IO",
1486
driver => "not-a-sensor",
1489
name => "SMSC FDC37M707 Super IO",
1490
driver => "not-a-sensor",
1493
name => "SMSC FDC37M81x Super IO",
1494
driver => "not-a-sensor",
1497
name => "SMSC LPC47B27x Super IO Fan Sensors",
1498
driver => "smsc47m1",
1501
features => FEAT_FAN,
1503
name => "SMSC LPC47B34x Super IO",
1504
driver => "not-a-sensor",
1507
name => "SMSC LPC47B357/M967 Super IO",
1508
driver => "not-a-sensor",
1511
name => "SMSC LPC47B367-NC Super IO",
1512
driver => "not-a-sensor",
1515
name => "SMSC LPC47B37x Super IO Fan Sensors",
1516
driver => "to-be-written",
1519
features => FEAT_FAN,
1521
name => "SMSC LPC47B397-NC Super IO",
1522
driver => "smsc47b397",
1525
features => FEAT_FAN | FEAT_TEMP,
1527
name => "SMSC LPC47M10x/112/13x Super IO Fan Sensors",
1528
driver => "smsc47m1",
1531
features => FEAT_FAN,
1533
name => "SMSC LPC47M14x Super IO Fan Sensors",
1534
driver => "smsc47m1",
1537
features => FEAT_FAN,
1539
name => "SMSC LPC47M15x/192/997 Super IO Fan Sensors",
1540
driver => "smsc47m1",
1543
features => FEAT_FAN,
1545
name => "SMSC LPC47M172 Super IO Fan Sensors",
1546
driver => "to-be-written",
1549
features => FEAT_FAN,
1551
name => "SMSC LPC47M182 Super IO Fan Sensors",
1552
driver => "to-be-written",
1555
features => FEAT_FAN,
1557
name => "SMSC LPC47M233 Super IO Sensors",
1558
driver => "to-be-written",
1560
devid_mask => 0xff80,
1562
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1564
name => "SMSC LPC47M292 Super IO Fan Sensors",
1565
driver => "smsc47m1",
1567
devid_mask => 0xff80,
1569
features => FEAT_FAN,
1571
name => "SMSC LPC47M584-NC Super IO",
1575
name => "SMSC LPC47N252 Super IO Fan Sensors",
1576
driver => "to-be-written",
1579
features => FEAT_FAN,
1581
name => "SMSC LPC47S42x Super IO Fan Sensors",
1582
driver => "to-be-written",
1585
features => FEAT_FAN,
1587
name => "SMSC LPC47S45x Super IO Fan Sensors",
1588
driver => "to-be-written",
1591
features => FEAT_FAN,
1593
name => "SMSC LPC47U32x Super IO Fan Sensors",
1594
driver => "to-be-written",
1597
features => FEAT_FAN,
1599
name => "SMSC LPC47U33x Super IO Fan Sensors",
1600
driver => "to-be-written",
1603
features => FEAT_FAN,
1605
name => "SMSC SCH3112 Super IO",
1606
driver => "dme1737",
1609
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1611
name => "SMSC SCH3114 Super IO",
1612
driver => "dme1737",
1615
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1617
name => "SMSC SCH3116 Super IO",
1618
driver => "dme1737",
1621
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1623
name => "SMSC SCH4307 Super IO Fan Sensors",
1624
driver => "to-be-written",
1627
features => FEAT_FAN,
1629
name => "SMSC SCH5027D-NW Super IO",
1630
# Hardware monitoring features are accessed on the SMBus
1631
driver => "via-smbus-only",
1634
name => "SMSC SCH5127 Super IO",
1635
driver => "dme1737",
1638
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1640
name => "SMSC SCH5307-NS Super IO",
1641
driver => "smsc47b397",
1644
features => FEAT_FAN | FEAT_TEMP,
1646
name => "SMSC SCH5317 Super IO",
1647
driver => "smsc47b397",
1650
features => FEAT_FAN | FEAT_TEMP,
1652
name => "SMSC SCH5317 Super IO",
1653
# The SCH5317 shows up twice in this list because it can return either
1654
# 0x85 or 0x8c as its device ID.
1655
driver => "smsc47b397",
1658
features => FEAT_FAN | FEAT_TEMP,
1660
name => "SMSC SCH5504-NS Super IO",
1662
driver => "not-a-sensor",
1665
name => "SMSC SCH5514D-NS Super IO",
1667
driver => "not-a-sensor",
1672
# Non-standard SMSC chip list. These chips differ from the standard ones
1673
# listed above in that the device ID register address is 0x0d instead of
1674
# 0x20 (as specified by the ISA PNP spec).
1675
@superio_ids_smsc_ns = (
1677
name => "SMSC FDC37C665 Super IO",
1678
driver => "not-a-sensor",
1681
name => "SMSC FDC37C666 Super IO",
1682
driver => "not-a-sensor",
1685
name => "SMSC FDC37C669 Super IO",
1686
driver => "not-a-sensor",
1689
name => "SMSC FDC37N769 Super IO",
1690
driver => "not-a-sensor",
1693
name => "SMSC LPC47N227 Super IO",
1694
driver => "not-a-sensor",
1697
name => "SMSC LPC47N237 Super IO",
1698
driver => "not-a-sensor",
1703
@superio_ids_winbond = (
1705
name => "VIA VT1211 Super IO Sensors",
1709
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1711
name => "VIA VT1212 Super IO Lite", # in 100 pin TQFP package
1712
driver => "not-a-sensor",
1715
name => "VIA VT1212 Super IO Lite", # in 48 pin LQFP package
1716
driver => "not-a-sensor",
1719
name => "Winbond W83627HF/F/HG/G Super IO Sensors",
1720
# Also SMSC LPC61W492
1721
driver => "w83627hf",
1724
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1726
name => "Winbond W83627THF/THG Super IO Sensors",
1727
driver => "w83627hf",
1730
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1732
name => "Winbond W83637HF/HG Super IO Sensors",
1733
driver => "w83627hf",
1736
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1738
name => "Winbond W83687THF Super IO Sensors",
1739
driver => "w83627hf",
1742
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1744
name => "Winbond W83697HF/F/HG Super IO Sensors",
1745
driver => "w83627hf",
1748
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1750
name => "Winbond W83697SF/UF/UG Super IO PWM",
1751
driver => "to-be-written",
1754
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1756
name => "Winbond W83627EHF/EF/EHG/EG Super IO Sensors",
1757
driver => "w83627ehf",
1758
# W83627EHF datasheet says 0x886x but 0x8853 was seen, thus the
1759
# broader mask. W83627EHG was seen with ID 0x8863.
1761
devid_mask => 0xFFC0,
1763
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1765
name => "Winbond W83627DHG Super IO Sensors",
1766
driver => "w83627ehf",
1768
devid_mask => 0xFFF0,
1770
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1772
name => "Winbond W83627DHG-P Super IO Sensors",
1773
driver => "w83627ehf",
1775
devid_mask => 0xFFF0,
1777
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1779
name => "Winbond W83627UHG Super IO Sensors",
1780
driver => "to-be-written",
1782
devid_mask => 0xFFF0,
1784
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1786
name => "Winbond W83667HG Super IO Sensors",
1787
driver => "w83627ehf",
1789
devid_mask => 0xFFF0,
1791
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1793
name => "Nuvoton W83667HG-B Super IO Sensors",
1794
driver => "to-be-written", # Probably w83627ehf
1796
devid_mask => 0xFFF0,
1798
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1800
name => "Nuvoton W83677HG-I (NCT6771F/NCT6772F/NCT6775F) Super IO Sensors",
1801
driver => "to-be-written", # Probably w83627ehf
1803
devid_mask => 0xFFF0,
1805
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1807
name => "Winbond W83L517D Super IO",
1808
driver => "not-a-sensor",
1811
name => "Fintek F71805F/FG Super IO Sensors",
1812
driver => "f71805f",
1815
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1817
name => "Fintek F71808E Super IO Sensors",
1818
driver => "f71882fg",
1821
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1823
name => "Fintek F71862FG Super IO Sensors",
1824
driver => "f71882fg",
1827
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1829
name => "Fintek F71869FG Super IO Sensors",
1830
driver => "to-be-written",
1833
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1835
name => "Fintek F71806FG/F71872FG Super IO Sensors",
1836
driver => "f71805f",
1839
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1841
name => "Fintek F71858DG Super IO Sensors",
1842
driver => "f71882fg",
1845
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1847
name => "Fintek F71882FG/F71883FG Super IO Sensors",
1848
driver => "f71882fg",
1851
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1853
name => "Fintek F71889FG Super IO Sensors",
1854
driver => "f71882fg",
1857
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1859
name => "Fintek F71889E Super IO Sensors",
1860
driver => "to-be-written",
1863
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1865
name => "Fintek F81216D Super IO",
1866
driver => "not-a-sensor",
1869
name => "Fintek F81218D Super IO",
1870
driver => "not-a-sensor",
1873
name => "Asus F8000 Super IO",
1874
driver => "f71882fg",
1877
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1879
# Shouldn't be in this family, but seems to be still.
1880
name => "ITE IT8708F Super IO",
1881
driver => "not-a-sensor",
1884
# Shouldn't be in this family, but seems to be still.
1885
name => "ITE IT8710F Super IO",
1886
driver => "not-a-sensor",
1891
@superio_ids_ite = (
1893
name => "ITE IT8702F Super IO Fan Sensors",
1894
driver => "to-be-written",
1897
features => FEAT_FAN,
1899
name => "ITE IT8705F Super IO Sensors",
1903
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1905
name => "ITE IT8712F Super IO Sensors",
1909
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1911
name => "ITE IT8716F Super IO Sensors",
1915
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1917
name => "ITE IT8718F Super IO Sensors",
1921
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1923
name => "ITE IT8720F Super IO Sensors",
1927
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1929
name => "ITE IT8721F/IT8758E Super IO Sensors",
1930
driver => "to-be-written", # it87
1933
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1935
name => "ITE IT8726F Super IO Sensors",
1939
features => FEAT_IN | FEAT_FAN | FEAT_TEMP,
1943
# Entries are grouped by family. Each family entry has the following fields:
1944
# family: The family name
1945
# guess (optional): Typical logical device address. This lets us do
1946
# generic probing if we fail to recognize the chip.
1947
# enter: The password sequence to write to the address register
1948
# chips: Array of chips
1949
# The order of families matters, because we stop as soon as one family
1950
# succeeds. So we have to list families with shorter password sequences
1954
family => "National Semiconductor",
1960
chips => \@superio_ids_natsemi,
1968
chips => \@superio_ids_smsc,
1969
ns_detect => \&smsc_ns_detect_superio,
1970
ns_chips => \@superio_ids_smsc_ns,
1972
family => "VIA/Winbond/Nuvoton/Fintek",
1976
0x2e => [0x87, 0x87],
1977
0x4e => [0x87, 0x87],
1979
chips => \@superio_ids_winbond,
1985
0x2e => [0x87, 0x01, 0x55, 0x55],
1986
0x4e => [0x87, 0x01, 0x55, 0xaa],
1988
chips => \@superio_ids_ite,
1992
# Drivers for bridge, CPU and memory embedded sensors
1993
# Each entry must have the following fields:
1994
# name: The device name
1995
# driver: The driver name. Put "to-be-written" if no driver is available.
1996
# detect: Detection callback function. No parameter will be passed to
1997
# this function, it must use global lists of PCI devices, CPU,
1998
# etc. It must return a confidence value, undef if no supported
2000
use vars qw(@cpu_ids);
2004
name => "Silicon Integrated Systems SIS5595",
2005
driver => "sis5595",
2006
detect => \&sis5595_pci_detect,
2008
name => "VIA VT82C686 Integrated Sensors",
2009
driver => "via686a",
2010
detect => \&via686a_pci_detect,
2012
name => "VIA VT8231 Integrated Sensors",
2014
detect => \&via8231_pci_detect,
2016
name => "AMD K8 thermal sensors",
2018
detect => \&k8temp_pci_detect,
2020
name => "AMD Family 10h thermal sensors",
2021
driver => "k10temp",
2022
detect => \&fam10h_pci_detect,
2024
name => "AMD Family 11h thermal sensors",
2025
driver => "k10temp",
2026
detect => \&fam11h_pci_detect,
2028
name => "Intel Core family thermal sensor",
2029
driver => "coretemp",
2030
detect => sub { coretemp_detect(0); },
2032
name => "Intel Atom thermal sensor",
2033
driver => "coretemp",
2034
detect => sub { coretemp_detect(1); },
2036
name => "Intel AMB FB-DIMM thermal sensor",
2037
driver => "i5k_amb",
2038
detect => \&intel_amb_detect,
2040
name => "VIA C7 thermal sensor",
2041
driver => "via-cputemp",
2042
detect => \&via_c7_detect,
2044
name => "VIA Nano thermal sensor",
2045
driver => "via-cputemp",
2046
detect => \&via_nano_detect,
2050
#######################
2051
# AUXILIARY FUNCTIONS #
2052
#######################
2054
# $_[0] is the sought value
2055
# $_[1..] is the list to seek in
2056
# Returns: 1 if found, 0 if not.
2063
return 1 if $sought eq $_;
2068
# Address can be decimal or hexadecimal
2073
if ($value !~ m/^(0x[0-9a-f]+|[0-9]+)$/i) {
2074
print "$value is not a valid address, sorry.\n";
2077
$value = oct($value) if $value =~ m/^0x/i;
2082
sub parse_not_to_scan
2084
my ($min, $max, $to_parse) = @_;
2085
my @ranges = split /\s*, \s*/, $to_parse;
2089
foreach $range (@ranges) {
2090
my ($start, $end) = split /\s*-\s*/, $range;
2091
$start = valid_address($start);
2093
$end = valid_address($end);
2094
if ($end <= $start) {
2095
print "$start-$end is not a valid range, sorry.\n";
2098
$start = $min if $start < $min;
2099
$end = $max if $end > $max;
2100
push @res, ($start..$end);
2102
push @res, $start if $start >= $min and $start <= $max;
2106
return sort { $a <=> $b } @res;
2109
# $_[0]: Reference to list 1
2110
# $_[1]: Reference to list 2
2111
# Result: 0 if they have no elements in common, 1 if they have
2112
# Elements must be numeric.
2115
my ($list1, $list2) = @_;
2118
foreach $el1 (@$list1) {
2119
foreach $el2 (@$list2) {
2120
return 1 if $el1 == $el2;
2130
sub initialize_ioports
2132
sysopen(IOPORTS, "/dev/port", O_RDWR)
2133
or die "/dev/port: $!\n";
2142
# $_[0]: port to read
2143
# Returns: -1 on failure, read value on success.
2146
my ($res, $nrchars);
2147
sysseek(IOPORTS, $_[0], 0) or return -1;
2148
$nrchars = sysread(IOPORTS, $res, 1);
2149
return -1 if not defined $nrchars or $nrchars != 1;
2150
$res = unpack("C", $res);
2154
# $_[0]: port to write
2155
# $_[1]: value to write
2156
# We assume this can't fail.
2159
sysseek(IOPORTS, $_[0], 0);
2160
syswrite(IOPORTS, pack("C", $_[1]), 1);
2163
# $_[0]: Address register
2164
# $_[1]: Data register
2165
# $_[2]: Register to read
2166
# Returns: read value
2173
# $_[0]: Base address
2174
# $_[1]: Register to read
2175
# Returns: read value
2176
# This one can be used for any ISA chip with index register at
2177
# offset 5 and data register at offset 6.
2180
my ($addr, $reg) = @_;
2181
return isa_read_byte($addr + 5, $addr + 6, $reg);
2188
use vars qw($dev_i2c $sysfs_root);
2193
open(local *INPUTFILE, "/proc/mounts") or die "Can't access /proc/mounts!";
2195
while (<INPUTFILE>) {
2196
if (m@^\w+ /dev devfs @) {
2198
$dev_i2c = '/dev/i2c/';
2200
if (m@^\S+ (/\w+) sysfs @) {
2206
# We need sysfs for many things
2207
if (!defined $sysfs_root) {
2208
print "Sysfs not mounted?\n";
2213
if (open(*INPUTFILE, '/etc/udev/udev.conf')) {
2214
while (<INPUTFILE>) {
2215
next unless m/^\s*udev_db\s*=\s*\"([^"]*)\"/
2216
|| m/^\s*udev_db\s*=\s*(\S+)/;
2219
$dev_i2c = '/dev/i2c-';
2227
# Try some known default udev db locations, just in case
2228
if (-e '/dev/.udev.tdb' || -e '/dev/.udev'
2229
|| -e '/dev/.udevdb') {
2231
$dev_i2c = '/dev/i2c-';
2235
if (!($use_devfs || $use_udev)) {
2236
if (! -c '/dev/i2c-0' && -x '/sbin/MAKEDEV') {
2237
system("/sbin/MAKEDEV i2c");
2239
if (! -c '/dev/i2c-0' && -x '/dev/MAKEDEV') {
2240
system("/dev/MAKEDEV i2c");
2242
if (-c '/dev/i2c-0') {
2243
$dev_i2c = '/dev/i2c-';
2245
print "No i2c device files found.\n";
2254
# [3] -> EXTRAVERSION
2256
use vars qw(@kernel_version $kernel_arch);
2258
sub initialize_kernel_version
2260
`uname -r` =~ /(\d+)\.(\d+)\.(\d+)(.*)/;
2261
@kernel_version = ($1, $2, $3, $4);
2262
chomp($kernel_arch = `uname -m`);
2264
# We only support kernels >= 2.6.5
2265
if (!kernel_version_at_least(2, 6, 5)) {
2266
print "Kernel version is unsupported (too old, >= 2.6.5 needed)\n";
2271
sub kernel_version_at_least
2273
my ($vers, $plvl, $slvl) = @_;
2274
return 1 if ($kernel_version[0] > $vers ||
2275
($kernel_version[0] == $vers &&
2276
($kernel_version[1] > $plvl ||
2277
($kernel_version[1] == $plvl &&
2278
($kernel_version[2] >= $slvl)))));
2282
# @cpu is a list of reference to hashes, one hash per CPU.
2283
# Each entry has the following keys: vendor_id, cpu family, model,
2284
# model name and stepping, directly taken from /proc/cpuinfo.
2287
sub initialize_cpu_list
2292
open(local *INPUTFILE, "/proc/cpuinfo") or die "Can't access /proc/cpuinfo!";
2293
while (<INPUTFILE>) {
2294
if (m/^processor\s*:\s*(\d+)/) {
2295
push @cpu, $entry if scalar keys(%{$entry}); # Previous entry
2296
$entry = {}; # New entry
2299
if (m/^(vendor_id|cpu family|model|model name|stepping)\s*:\s*(.+)$/) {
2302
$v =~ s/\s+/ /g; # Merge multiple spaces
2303
$v =~ s/ $//; # Trim trailing space
2309
push @cpu, $entry if scalar keys(%{$entry}); # Last entry
2312
# @i2c_adapters is a list of references to hashes, one hash per I2C/SMBus
2313
# adapter present on the system. Each entry has the following keys: path,
2314
# parent, name (directly taken from sysfs), driver and autoload.
2315
use vars qw(@i2c_adapters);
2317
# Find out whether the driver would be automatically loaded by the modalias
2319
sub device_driver_autoloads
2323
my $modalias = sysfs_device_attribute($device, "modalias");
2324
return 0 unless defined($modalias);
2326
# At the moment we only handle PCI and USB drivers. Other driver
2327
# types, most notably platform and i2c drivers, do not follow the
2328
# device driver model to the letter, and often create their own
2329
# devices. Such drivers appear to be autoloaded when they are not.
2330
return 0 unless $modalias =~ m/^(pci|usb):/;
2332
my $result = `modprobe -n -v --first-time $modalias 2>&1`;
2333
return ($result =~ m/^insmod/ ||
2334
$result =~ m/\balready in kernel\b/);
2337
sub initialize_i2c_adapters_list
2339
my ($entry, $base_dir, $have_i2c_adapter_class);
2342
if (-d "${sysfs_root}/class/i2c-adapter") {
2343
$base_dir = "${sysfs_root}/class/i2c-adapter";
2344
$have_i2c_adapter_class = 1;
2346
$base_dir = "${sysfs_root}/bus/i2c/devices";
2347
$have_i2c_adapter_class = 0;
2349
opendir(local *ADAPTERS, $base_dir) or return;
2351
while (defined($_ = readdir(ADAPTERS))) {
2352
next unless m/^i2c-(\d+)$/;
2354
$entry = {}; # New entry
2356
# The layout in sysfs has changed over the years
2357
if ($have_i2c_adapter_class) {
2358
my $link = readlink("${base_dir}/i2c-$nr/device");
2359
if (!defined $link) {
2360
$entry->{path} = "${base_dir}/i2c-$nr";
2361
$entry->{parent} = "${base_dir}/i2c-$nr";
2362
} elsif ($link =~ m/^(.*)\/i2c-$nr$/) {
2363
$entry->{path} = "${base_dir}/i2c-$nr/device";
2364
$entry->{parent} = "${base_dir}/i2c-$nr/$1";
2366
$entry->{path} = "${base_dir}/i2c-$nr";
2367
$entry->{parent} = "$entry->{path}/device";
2370
my $link = readlink("${base_dir}/i2c-$nr");
2371
$link =~ s/\/i2c-$nr$//;
2372
$entry->{path} = "${base_dir}/i2c-$nr";
2373
$entry->{parent} = "${base_dir}/$link";
2376
$entry->{name} = sysfs_device_attribute($entry->{path}, "name");
2377
next if $entry->{name} eq "ISA main adapter";
2379
# First try to get the I2C adapter driver name from sysfs,
2380
# and if it fails, fall back to searching our list of known
2382
$entry->{driver} = sysfs_device_driver($entry->{parent})
2383
|| find_i2c_adapter_driver($entry->{name})
2386
$entry->{autoload} = device_driver_autoloads($entry->{parent});
2387
$i2c_adapters[$nr] = $entry;
2392
# %hwmon_autoloaded is a list of hwmon drivers which are autoloaded
2393
# (typically by udev.) We don't need to load these drivers ourselves.
2394
use vars qw(%hwmon_autoloaded);
2396
sub initialize_hwmon_autoloaded
2398
my $class_dir = "${sysfs_root}/class/hwmon";
2399
opendir(local *HWMON, $class_dir) or return;
2401
my ($hwmon, $driver);
2402
while (defined($hwmon = readdir(HWMON))) {
2403
next unless $hwmon =~ m/^hwmon\d+$/;
2405
$driver = sysfs_device_driver("${class_dir}/$hwmon/device");
2406
next unless defined($driver);
2408
if (device_driver_autoloads("${class_dir}/$hwmon/device")) {
2410
$hwmon_autoloaded{$driver}++
2416
sub hwmon_is_autoloaded
2420
return exists($hwmon_autoloaded{$driver});
2427
use vars qw(%modules_list %modules_supported @modules_we_loaded);
2429
sub initialize_modules_list
2433
open(local *INPUTFILE, "/proc/modules") or return;
2434
while (<INPUTFILE>) {
2435
tr/-/_/; # Probably not needed
2436
$modules_list{$1} = 1 if m/^(\S*)/;
2440
sub is_module_loaded
2444
return exists $modules_list{$module}
2451
return if is_module_loaded($module);
2453
system("modprobe", $module);
2454
if (($? >> 8) != 0) {
2455
print "Failed to load module $module.\n";
2459
print "Module $module loaded successfully.\n";
2460
push @modules_we_loaded, $module;
2462
# Update the list of loaded modules
2463
my $normalized = $module;
2464
$normalized =~ tr/-/_/;
2465
$modules_list{$normalized} = 1;
2468
sub initialize_modules_supported
2470
foreach my $chip (@chip_ids) {
2471
next if $chip->{driver} eq "to-be-written";
2472
next if $chip->{driver} eq "use-isa-instead";
2474
my $normalized = $chip->{driver};
2475
$normalized =~ tr/-/_/;
2476
$modules_supported{$normalized}++;
2482
return unless @modules_we_loaded;
2484
# Attempt to unload all kernel drivers we loaded ourselves
2485
while (my $module = pop @modules_we_loaded) {
2486
print "Unloading $module... ";
2487
system("modprobe -r $module 2> /dev/null");
2488
if (($? >> 8) == 0) {
2501
use vars qw(%dmi $dmidecode_ok);
2503
# Returns: 1 if dmidecode is recent enough, 0 if not
2504
# Cache the result in case it is needed again later.
2505
sub check_dmidecode_version
2507
return $dmidecode_ok if defined $dmidecode_ok;
2510
if (open(local *DMIDECODE, "dmidecode --version 2>/dev/null |")) {
2511
$version = <DMIDECODE>;
2513
chomp $version if defined $version;
2516
if (!defined $version
2517
|| !($version =~ m/^(\d+).(\d+)$/)
2518
|| !(($1 == 2 && $2 >= 7) || $1 > 2)) {
2519
print "# DMI data unavailable, please consider installing dmidecode 2.7\n".
2520
"# or later for better results.\n";
2526
return $dmidecode_ok;
2529
sub initialize_dmi_data
2532
# sysfs file name => dmidecode string name
2533
sys_vendor => 'system-manufacturer',
2534
product_name => 'system-product-name',
2535
product_version => 'system-version',
2536
board_vendor => 'baseboard-manufacturer',
2537
board_name => 'baseboard-product-name',
2538
board_version => 'baseboard-product-name',
2539
chassis_type => 'chassis-type',
2541
# Many BIOS have broken DMI data, filter it out
2543
'System Manufacturer' => 1,
2548
# First try reading the strings from sysfs if available
2549
if (-d ($dmi_id_dir = "$sysfs_root/devices/virtual/dmi/id") # kernel >= 2.6.28
2550
|| -d ($dmi_id_dir = "$sysfs_root/class/dmi/id")) {
2551
foreach my $k (keys %items) {
2552
$dmi{$k} = sysfs_device_attribute($dmi_id_dir, $k);
2555
# Else fallback on calling dmidecode
2556
return unless check_dmidecode_version();
2558
foreach my $k (keys %items) {
2559
next unless open(local *DMIDECODE,
2560
"dmidecode -s $items{$k} 2>/dev/null |");
2561
$dmi{$k} = <DMIDECODE>;
2566
# Strip trailing white-space, discard empty field
2567
foreach my $k (keys %dmi) {
2568
if (!defined $dmi{$k}) {
2572
$dmi{$k} =~ s/\s*$//;
2573
delete $dmi{$k} if $dmi{$k} eq '' || exists $fake{$dmi{$k}};
2577
sub print_dmi_summary
2579
my ($system, $board);
2580
if (defined $dmi{sys_vendor} && defined $dmi{product_name}) {
2581
$system = "$dmi{sys_vendor} $dmi{product_name}";
2583
if (defined $dmi{board_vendor} && defined $dmi{board_name}) {
2584
$board = "$dmi{board_vendor} $dmi{board_name}";
2587
if (defined $system) {
2588
print "# System: $system";
2589
print " (laptop)" if (is_laptop());
2592
print "# Board: $board\n" if defined $board
2593
&& (!defined $system || $system ne $board);
2601
return unless defined $dmi{$key};
2602
while (defined ($value = shift)) {
2603
return 1 if $dmi{$key} =~ m/\b$value\b/i;
2610
return 0 unless $dmi{chassis_type};
2611
return 1 if $dmi{chassis_type} =~ m/(Laptop|Notebook|Hand Held)/i;
2612
return 1 if $dmi{chassis_type} =~ m/^(9|10|11|14)$/;
2620
# From a sysfs device path, return the driver (module) name, or undef
2621
sub sysfs_device_driver
2625
my $link = readlink("$device/driver/module");
2626
return unless defined $link;
2627
return basename($link);
2630
# From a sysfs device path, return the subsystem name, or undef
2631
sub sysfs_device_subsystem
2635
my $link = readlink("$device/subsystem");
2636
return unless defined $link;
2637
return basename($link);
2640
# From a sysfs device path and an attribute name, return the attribute
2642
sub sysfs_device_attribute
2644
my ($device, $attr) = @_;
2647
open(local *FILE, "$device/$attr") or return;
2650
return unless defined $value;
2660
use vars qw(%pci_list);
2662
# This function returns a list of hashes. Each hash has some PCI information:
2663
# 'domain', 'bus', 'slot' and 'func' uniquely identify a PCI device in a
2664
# computer; 'vendid' and 'devid' uniquely identify a type of device.
2665
# 'class' lets us spot unknown SMBus adapters.
2666
sub read_sys_dev_pci
2668
my $devices = shift;
2669
my ($dev, @pci_list);
2671
opendir(local *DEVICES, "$devices")
2672
or die "$devices: $!";
2674
while (defined($dev = readdir(DEVICES))) {
2677
m/^(?:([\da-f]+):)?([\da-f]+):([\da-f]+)\.([\da-f]+)$/;
2679
$record{domain} = hex $1;
2680
$record{bus} = hex $2;
2681
$record{slot} = hex $3;
2682
$record{func} = hex $4;
2684
$record{vendid} = oct sysfs_device_attribute("$devices/$dev",
2686
$record{devid} = oct sysfs_device_attribute("$devices/$dev",
2688
$record{class} = (oct sysfs_device_attribute("$devices/$dev",
2691
push @pci_list, \%record;
2702
$pci_list = read_sys_dev_pci("$sysfs_root/bus/pci/devices");
2704
# Note that we lose duplicate devices at this point, but we don't
2705
# really care. What matters to us is which unique devices are present,
2706
# not how many of each.
2708
sprintf("%04x:%04x", $_->{vendid}, $_->{devid}) => $_
2712
#####################
2713
# ADAPTER DETECTION #
2714
#####################
2716
# Build and return a PCI device's bus ID
2722
$busid = sprintf("\%02x:\%02x.\%x",
2723
$device->{bus}, $device->{slot}, $device->{func});
2724
$busid = sprintf("\%04x:", $device->{domain}) . $busid
2725
if defined $device->{domain};
2730
sub adapter_pci_detection
2732
my ($key, $device, $try, %smbus, $count);
2734
# Build a list of detected SMBus devices
2735
foreach $key (keys %pci_list) {
2736
$device = $pci_list{$key};
2738
if exists $device->{class} &&
2739
($device->{class} == 0x0c01 || # Access Bus
2740
$device->{class} == 0x0c05); # SMBus
2743
# Loop over the known I2C/SMBus adapters
2744
foreach $try (@pci_adapters) {
2745
$key = sprintf("%04x:%04x", $try->{vendid}, $try->{devid});
2746
next unless exists $pci_list{$key};
2748
$device = $pci_list{$key};
2749
if ($try->{driver} eq "to-be-tested") {
2750
print "\nWe are currently looking for testers for this adapter!\n".
2751
"Please check http://www.lm-sensors.org/wiki/Devices\n".
2752
"and/or contact us if you want to help.\n\n".
2758
if ($try->{driver} =~ m/^to-be-/) {
2759
printf "No known driver for device \%s: \%s\n",
2760
pci_busid($device), $try->{procid};
2762
printf "Using driver `\%s' for device \%s: \%s\n",
2763
$try->{driver}, pci_busid($device),
2766
load_module($try->{driver});
2769
# Delete from detected SMBus device list
2770
delete $smbus{$key};
2773
# Now see if there are unknown SMBus devices left
2774
foreach $key (keys %smbus) {
2775
$device = $pci_list{$key};
2776
printf "Found unknown SMBus adapter \%04x:\%04x at \%s.\n",
2777
$device->{vendid}, $device->{devid}, pci_busid($device);
2780
print "Sorry, no supported PCI bus adapters found.\n"
2784
# $_[0]: Adapter description as found in sysfs
2785
sub find_i2c_adapter_driver
2790
foreach $entry (@i2c_adapter_names) {
2791
return $entry->{driver}
2792
if $name =~ $entry->{match};
2796
#############################
2797
# I2C AND SMBUS /DEV ACCESS #
2798
#############################
2800
# This should really go into a separate module/package.
2802
# These are copied from <linux/i2c-dev.h>
2804
use constant IOCTL_I2C_SLAVE => 0x0703;
2805
use constant IOCTL_I2C_FUNCS => 0x0705;
2806
use constant IOCTL_I2C_SMBUS => 0x0720;
2808
use constant SMBUS_READ => 1;
2809
use constant SMBUS_WRITE => 0;
2811
use constant SMBUS_QUICK => 0;
2812
use constant SMBUS_BYTE => 1;
2813
use constant SMBUS_BYTE_DATA => 2;
2814
use constant SMBUS_WORD_DATA => 3;
2816
use constant I2C_FUNC_SMBUS_QUICK => 0x00010000;
2817
use constant I2C_FUNC_SMBUS_READ_BYTE => 0x00020000;
2818
use constant I2C_FUNC_SMBUS_READ_BYTE_DATA => 0x00080000;
2820
# Get the i2c adapter's functionalities
2821
# $_[0]: Reference to an opened filehandle
2822
# Returns: -1 on failure, functionality bitfield on success.
2826
my $funcs = pack("L", 0); # Allocate space
2828
ioctl($file, IOCTL_I2C_FUNCS, $funcs) or return -1;
2829
$funcs = unpack("L", $funcs);
2834
# Select the device to communicate with through its address.
2835
# $_[0]: Reference to an opened filehandle
2836
# $_[1]: Address to select
2837
# Returns: 0 on failure, 1 on success.
2838
sub i2c_set_slave_addr
2840
my ($file, $addr) = @_;
2842
# Reset register data cache
2843
@i2c_byte_cache = ();
2845
$addr += 0; # Make sure it's a number not a string
2846
ioctl($file, IOCTL_I2C_SLAVE, $addr) or return 0;
2850
# i2c_smbus_access is based upon the corresponding C function (see
2851
# <linux/i2c-dev.h>). You should not need to call this directly.
2852
# $_[0]: Reference to an opened filehandle
2853
# $_[1]: SMBUS_READ for reading, SMBUS_WRITE for writing
2854
# $_[2]: Command (usually register number)
2855
# $_[3]: Transaction kind (SMBUS_BYTE, SMBUS_BYTE_DATA, etc.)
2856
# $_[4]: Reference to an array used for input/output of data
2857
# Returns: 0 on failure, 1 on success.
2858
# Note that we need to get back to Integer boundaries through the 'x2'
2859
# in the pack. This is very compiler-dependent; I wish there was some other
2861
sub i2c_smbus_access
2863
my ($file, $read_write, $command, $size, $data) = @_;
2864
my $data_array = pack("C32", @$data);
2865
my $ioctl_data = pack("C2x2Ip", $read_write, $command, $size,
2868
ioctl($file, IOCTL_I2C_SMBUS, $ioctl_data) or return 0;
2869
@{$_[4]} = unpack("C32", $data_array);
2873
# $_[0]: Reference to an opened filehandle
2874
# Returns: -1 on failure, the read byte on success.
2875
sub i2c_smbus_read_byte
2880
i2c_smbus_access($file, SMBUS_READ, 0, SMBUS_BYTE, \@data)
2885
# $_[0]: Reference to an opened filehandle
2886
# $_[1]: Command byte (usually register number)
2887
# Returns: -1 on failure, the read byte on success.
2888
# Read byte data values are cached by default. As we keep reading the
2889
# same registers over and over again in the detection functions, and
2890
# SMBus can be slow, caching results in a big performance boost.
2891
sub i2c_smbus_read_byte_data
2893
my ($file, $command, $nocache) = @_;
2896
return $i2c_byte_cache[$command]
2897
if !$nocache && exists $i2c_byte_cache[$command];
2899
i2c_smbus_access($file, SMBUS_READ, $command, SMBUS_BYTE_DATA, \@data)
2901
return ($i2c_byte_cache[$command] = $data[0]);
2904
# $_[0]: Reference to an opened filehandle
2905
# $_[1]: Command byte (usually register number)
2906
# Returns: -1 on failure, the read word on success.
2907
# Use this function with care, some devices don't like word reads,
2908
# so you should do as much of the detection as possible using byte reads,
2909
# and only start using word reads when there is a good chance that
2910
# the detection will succeed.
2911
# Note: some devices use the wrong endianness.
2912
sub i2c_smbus_read_word_data
2914
my ($file, $command) = @_;
2916
i2c_smbus_access($file, SMBUS_READ, $command, SMBUS_WORD_DATA, \@data)
2918
return $data[0] + 256 * $data[1];
2921
# $_[0]: Reference to an opened filehandle
2923
# $_[2]: Functionalities of this i2c adapter
2924
# Returns: 1 on successful probing, 0 else.
2925
# This function is meant to prevent AT24RF08 corruption and write-only
2926
# chips locks. This is done by choosing the best probing method depending
2927
# on the address range.
2930
my ($file, $addr, $funcs) = @_;
2932
if (($addr >= 0x50 && $addr <= 0x5F)
2933
|| ($addr >= 0x30 && $addr <= 0x37)) {
2934
# This covers all EEPROMs we know of, including page protection
2935
# addresses. Note that some page protection addresses will not
2936
# reveal themselves with this, because they ack on write only,
2937
# but this is probably better since some EEPROMs write-protect
2938
# themselves permanently on almost any write to their page
2939
# protection address.
2940
return 0 unless ($funcs & I2C_FUNC_SMBUS_READ_BYTE);
2941
return i2c_smbus_access($file, SMBUS_READ, 0, SMBUS_BYTE, []);
2942
} elsif ($addr == 0x73) {
2943
# Special case for FSC chips, as at least the Syleus locks
2944
# up with our regular probe code. Note that to our current
2945
# knowledge only FSC chips live on this address, and for them
2946
# this probe method is safe.
2947
return 0 unless ($funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA);
2948
return i2c_smbus_access($file, SMBUS_READ, 0, SMBUS_BYTE_DATA, []);
2950
return 0 unless ($funcs & I2C_FUNC_SMBUS_QUICK);
2951
return i2c_smbus_access($file, SMBUS_WRITE, 0, SMBUS_QUICK, []);
2955
# $_[0]: Reference to an opened file handle
2956
# Returns: 1 if the device is safe to access, 0 else.
2957
# This function is meant to prevent access to 1-register-only devices,
2958
# which are designed to be accessed with SMBus receive byte and SMBus send
2959
# byte transactions (i.e. short reads and short writes) and treat SMBus
2960
# read byte as a real write followed by a read. The device detection
2961
# routines would write random values to the chip with possibly very nasty
2962
# results for the hardware. Note that this function won't catch all such
2963
# chips, as it assumes that reads and writes relate to the same register,
2964
# but that's the best we can do.
2965
sub i2c_safety_check
2970
# First we receive a byte from the chip, and remember it.
2971
$data = i2c_smbus_read_byte($file);
2972
return 1 if ($data < 0);
2974
# We receive a byte again; very likely to be the same for
2975
# 1-register-only devices.
2976
return 1 if (i2c_smbus_read_byte($file) != $data);
2978
# Then we try a standard byte read, with a register offset equal to
2979
# the byte we received; we should receive the same byte value in return.
2980
return 1 if (i2c_smbus_read_byte_data($file, $data) != $data);
2982
# Then we try a standard byte read, with a slightly different register
2983
# offset; we should again receive the same byte value in return.
2984
return 1 if (i2c_smbus_read_byte_data($file, $data ^ 1) != ($data ^ 1));
2986
# Apprently this is a 1-register-only device, restore the original
2987
# register value and leave it alone.
2988
i2c_smbus_read_byte_data($file, $data);
2992
####################
2993
# ADAPTER SCANNING #
2994
####################
2996
use vars qw(%chips_detected);
2998
# We will build a complicated structure %chips_detected here, being a hash
2999
# where keys are driver names and values are detected chip information in
3000
# the form of a list of hashes of type 'detect_data'.
3004
# with field 'i2c_devnr', contianing the /dev/i2c-* number of this
3005
# adapter (if this is an I2C detection)
3006
# with field 'i2c_addr', containing the I2C address of the detection;
3007
# (if this is an I2C detection)
3008
# with field 'i2c_sub_addrs', containing a reference to a list of
3009
# other I2C addresses (if this is an I2C detection)
3010
# with field 'isa_addr' containing the ISA address this chip is on
3011
# (if this is an ISA detection)
3012
# with field 'conf', containing the confidence level of this detection
3013
# with field 'chipname', containing the chip name
3014
# with optional field 'alias_detect', containing a reference to an alias
3015
# detection function for this chip
3017
# This adds a detection to the above structure.
3018
# Not all possibilities of i2c_addr and i2c_sub_addrs are exhausted.
3019
# In all normal cases, it should be all right.
3020
# $_[0]: chip driver
3021
# $_[1]: reference to data hash
3023
sub add_i2c_to_chips_detected
3025
my ($chipdriver, $datahash) = @_;
3026
my ($i, $detected_ref, $detected_entry, $driver,
3027
$put_in_detected, @hash_addrs, @entry_addrs);
3029
# Find out whether our new entry should go into the detected list
3030
# or not. We compare all i2c addresses; if at least one matches,
3031
# but our confidence value is lower, we assume this is a misdetection,
3032
# in which case we simply discard our new entry.
3033
@hash_addrs = ($datahash->{i2c_addr});
3034
push @hash_addrs, @{$datahash->{i2c_sub_addrs}}
3035
if exists $datahash->{i2c_sub_addrs};
3036
$put_in_detected = 1;
3038
foreach $detected_ref (values %chips_detected) {
3039
foreach $detected_entry (@{$detected_ref}) {
3040
next unless defined $detected_entry->{i2c_addr};
3041
@entry_addrs = ($detected_entry->{i2c_addr});
3042
push @entry_addrs, @{$detected_entry->{i2c_sub_addrs}}
3043
if exists $detected_entry->{i2c_sub_addrs};
3044
if ($detected_entry->{i2c_devnr} == $datahash->{i2c_devnr} &&
3045
any_list_match(\@entry_addrs, \@hash_addrs)) {
3046
if ($detected_entry->{conf} >= $datahash->{conf}) {
3047
$put_in_detected = 0;
3054
return unless $put_in_detected;
3056
# Here, we discard all entries which match at least in one main or
3057
# sub address. This may not be the best idea to do, as it may remove
3058
# detections without replacing them with second-best ones. Too bad.
3059
foreach $driver (keys %chips_detected) {
3060
$detected_ref = $chips_detected{$driver};
3061
for ($i = @$detected_ref-1; $i >=0; $i--) {
3062
next unless defined $detected_ref->[$i]->{i2c_addr};
3063
@entry_addrs = ($detected_ref->[$i]->{i2c_addr});
3064
push @entry_addrs, @{$detected_ref->[$i]->{i2c_sub_addrs}}
3065
if exists $detected_ref->[$i]->{i2c_sub_addrs};
3066
if ($detected_ref->[$i]->{i2c_devnr} == $datahash->{i2c_devnr} &&
3067
any_list_match(\@entry_addrs, \@hash_addrs)) {
3068
splice @$detected_ref, $i, 1;
3069
delete $chips_detected{$driver}
3070
if (!@$detected_ref);
3075
# Now add the new entry to detected
3076
$chips_detected{$chipdriver} = []
3077
unless exists $chips_detected{$chipdriver};
3078
push @{$chips_detected{$chipdriver}}, $datahash;
3081
# Fake i2c drivers such as "not-a-sensor" or "use-isa-instead" have to be
3082
# inserted so that confidence comparison can be performed. But then we have
3083
# to filter them out so that the user doesn't get confused.
3084
sub filter_out_fake_i2c_drivers
3086
delete $chips_detected{"not-a-sensor"};
3087
delete $chips_detected{"use-isa-instead"};
3090
# This adds a detection to the above structure.
3091
# $_[0]: chip driver
3092
# $_[1]: reference to data hash
3093
sub add_isa_to_chips_detected
3095
my ($chipdriver, $datahash) = @_;
3096
my ($i, $new_detected_ref, $detected_ref);
3098
# First determine where the hash has to be added.
3099
$chips_detected{$chipdriver} = []
3100
unless exists $chips_detected{$chipdriver};
3101
$new_detected_ref = $chips_detected{$chipdriver};
3103
# Find out whether our new entry should go into the detected list
3104
# or not. We only compare main isa_addr here, of course.
3105
foreach $detected_ref (values %chips_detected) {
3106
for ($i = 0; $i < @{$detected_ref}; $i++) {
3107
if (exists $detected_ref->[$i]->{isa_addr} and
3108
exists $datahash->{isa_addr} and
3109
$detected_ref->[$i]->{isa_addr} == $datahash->{isa_addr}) {
3110
if ($detected_ref->[$i]->{conf} < $datahash->{conf}) {
3111
splice @$detected_ref, $i, 1;
3112
push @$new_detected_ref, $datahash;
3119
# Not found? OK, put it in the detected list
3120
push @$new_detected_ref, $datahash;
3123
# $_[0]: reference to an array of chips which may be aliases of each other
3126
my $detected = shift;
3127
my ($isa, $i2c, $dev, $alias_detect, $is_alias);
3129
for ($isa = 0; $isa < @{$detected}; $isa++) {
3130
# Look for chips with an ISA address but no I2C address
3131
next unless defined $detected->[$isa];
3132
next unless $detected->[$isa]->{isa_addr};
3133
next if defined $detected->[$isa]->{i2c_addr};
3134
# Additionally, the chip must possibly have I2C aliases
3135
next unless defined $detected->[$isa]->{alias_detect};
3137
for ($i2c = 0; $i2c < @{$detected}; $i2c++) {
3138
# Look for chips with an I2C address but no ISA address
3139
next unless defined $detected->[$i2c];
3140
next unless defined $detected->[$i2c]->{i2c_addr};
3141
next if $detected->[$i2c]->{isa_addr};
3142
# Additionally, it must have the same chip name
3143
next unless $detected->[$i2c]->{chipname} eq
3144
$detected->[$isa]->{chipname};
3146
# We have potential aliases, check if they actually are
3147
$dev = $dev_i2c.$detected->[$i2c]->{i2c_devnr};
3148
open(local *FILE, $dev) or
3149
print("Can't open $dev\n"),
3152
i2c_set_slave_addr(\*FILE, $detected->[$i2c]->{i2c_addr}) or
3153
print("Can't set I2C address for $dev\n"),
3156
initialize_ioports();
3157
$alias_detect = $detected->[$isa]->{alias_detect};
3158
$is_alias = &$alias_detect($detected->[$isa]->{isa_addr},
3160
$detected->[$i2c]->{i2c_addr});
3164
next unless $is_alias;
3165
# This is an alias: copy the I2C data into the ISA
3166
# entry, then discard the I2C entry
3167
$detected->[$isa]->{i2c_devnr} = $detected->[$i2c]->{i2c_devnr};
3168
$detected->[$isa]->{i2c_addr} = $detected->[$i2c]->{i2c_addr};
3169
$detected->[$isa]->{i2c_sub_addr} = $detected->[$i2c]->{i2c_sub_addr};
3170
undef $detected->[$i2c];
3175
# The loops above may have made the chip list sparse, make it
3177
for ($isa = 0; $isa < @{$detected}; ) {
3178
if (defined($detected->[$isa])) {
3181
splice @{$detected}, $isa, 1;
3186
# From the list of known I2C/SMBus devices, build a list of I2C addresses
3187
# which are worth probing. There's no point in probing an address for which
3188
# we don't know a single device, and probing some addresses has caused
3189
# random trouble in the past.
3190
sub i2c_addresses_to_scan
3196
foreach my $chip (@chip_ids) {
3197
next unless defined $chip->{i2c_addrs};
3198
foreach $addr (@{$chip->{i2c_addrs}}) {
3203
for ($addr = 0x03; $addr <= 0x77; $addr++) {
3204
push @addresses, $addr if $used[$addr];
3209
# $_[0]: The number of the adapter to scan
3211
sub add_busy_i2c_address
3213
my ($adapter_nr, $addr) = @_;
3214
# If the address is busy, we can normally find out which driver
3215
# requested it (if the kernel is recent enough, at least 2.6.16 and
3216
# later are known to work), and we assume it is the right one.
3217
my ($device, $driver, $new_hash);
3219
$device = sprintf("$sysfs_root/bus/i2c/devices/\%d-\%04x",
3220
$adapter_nr, $addr);
3221
$driver = sysfs_device_driver($device);
3223
if (!defined($driver)) {
3224
printf("Client at address 0x%02x can not be probed - ".
3225
"unload all client drivers first!\n", $addr);
3230
conf => 6, # Arbitrary confidence
3232
chipname => sysfs_device_attribute($device, "name")
3234
i2c_devnr => $adapter_nr,
3237
printf "Client found at address 0x\%02x\n", $addr;
3238
printf "Handled by driver `\%s' (already loaded), chip type `\%s'\n",
3239
$driver, $new_hash->{chipname};
3241
# Only add it to the list if this is something we would have detected,
3242
# else we end up with random i2c chip drivers listed (for example
3243
# media/video drivers.)
3244
if (exists $modules_supported{$driver}) {
3245
add_i2c_to_chips_detected($driver, $new_hash);
3247
print " (note: this is probably NOT a sensor chip!)\n";
3251
# $_[0]: The number of the adapter to scan
3253
# $_[2]: Chip being probed
3254
sub probe_free_i2c_address
3256
my ($adapter_nr, $addr, $chip) = @_;
3257
my ($conf, @other_addr, $new_hash);
3259
printf("\%-60s", sprintf("Probing for `\%s'... ", $chip->{name}));
3260
if (($conf, @other_addr) = &{$chip->{i2c_detect}} (\*FILE, $addr)) {
3261
if ($chip->{driver} eq "not-a-sensor") {
3263
" (confidence $conf, not a hardware monitoring chip";
3266
" (confidence $conf, driver `$chip->{driver}'";
3269
print ", other addresses:";
3270
@other_addr = sort @other_addr;
3271
foreach my $other_addr (@other_addr) {
3272
printf(" 0x%02x", $other_addr);
3280
chipname => $chip->{name},
3281
i2c_devnr => $adapter_nr,
3284
my @other_addr_copy = @other_addr;
3285
$new_hash->{i2c_sub_addrs} = \@other_addr_copy;
3287
add_i2c_to_chips_detected($chip->{driver}, $new_hash);
3293
# $_[0]: The device to check (PCI or not)
3294
# Returns: PCI class of the adapter if available, 0 if not
3298
my ($subsystem, $class);
3300
$subsystem = sysfs_device_subsystem($device);
3301
return 0 unless defined $subsystem && $subsystem eq "pci";
3303
$class = sysfs_device_attribute($device, "class");
3304
return 0 unless defined $class;
3305
$class = oct($class) if $class =~ /^0/;
3309
# $_[0]: The number of the adapter to scan
3310
sub scan_i2c_adapter
3312
my ($adapter_nr, $smbus_default) = @_;
3313
my ($funcs, $chip, $addr, $class, $default, $input, @not_to_scan);
3315
$class = get_pci_class($i2c_adapters[$adapter_nr]->{parent});
3316
if (($class & 0xff00) == 0x0400) {
3317
# Do not probe adapters on PCI multimedia cards by default
3319
} elsif ($class == 0x0c01 || $class == 0x0c05
3320
|| find_i2c_adapter_driver($i2c_adapters[$adapter_nr]->{name})) {
3321
$default = $smbus_default;
3326
printf "Next adapter: $i2c_adapters[$adapter_nr]->{name} (i2c-$adapter_nr)\n".
3327
"Do you want to scan it? (\%s/selectively): ",
3328
$default ? "YES/no" : "yes/NO";
3331
if ($input =~ /^\s*n/i
3332
|| (!$default && $input !~ /^\s*[ys]/i)) {
3337
if ($input =~ /^\s*s/i) {
3338
print "Please enter one or more addresses not to scan. Separate them with commas.\n",
3339
"You can specify a range by using dashes. Example: 0x58-0x5f,0x69.\n",
3343
@not_to_scan = parse_not_to_scan(0x03, 0x77, $input);
3346
open(local *FILE, "$dev_i2c$adapter_nr") or
3347
(print "Can't open $dev_i2c$adapter_nr\n"), return;
3350
# Can we probe this adapter?
3351
$funcs = i2c_get_funcs(\*FILE);
3353
print "Adapter failed to provide its functionalities, skipping.\n";
3356
if (!($funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_READ_BYTE_DATA))) {
3357
print "Adapter cannot be probed, skipping.\n";
3360
if (~$funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
3361
print "Adapter doesn't support all probing functions.\n",
3362
"Some addresses won't be probed.\n";
3365
# Now scan each address in turn
3366
foreach $addr (@{$i2c_addresses_to_scan}) {
3367
# As the not_to_scan list is sorted, we can check it fast
3368
shift @not_to_scan # User skipped an address which we didn't intend to probe anyway
3369
while (@not_to_scan and $not_to_scan[0] < $addr);
3370
if (@not_to_scan and $not_to_scan[0] == $addr) {
3375
if (!i2c_set_slave_addr(\*FILE, $addr)) {
3376
add_busy_i2c_address($adapter_nr, $addr);
3380
next unless i2c_probe(\*FILE, $addr, $funcs);
3381
printf "Client found at address 0x%02x\n", $addr;
3382
if (!i2c_safety_check(\*FILE)) {
3383
print "Seems to be a 1-register-only device, skipping.\n";
3388
foreach $chip (@chip_ids, @non_hwmon_chip_ids) {
3389
next unless exists $chip->{i2c_addrs}
3390
&& contains($addr, @{$chip->{i2c_addrs}});
3391
probe_free_i2c_address($adapter_nr, $addr, $chip);
3400
my $chip_list_ref = shift;
3401
my ($chip, $addr, $conf);
3404
foreach $chip (@{$chip_list_ref}) {
3405
next if not exists $chip->{isa_addrs} or not exists $chip->{isa_detect};
3406
foreach $addr (@{$chip->{isa_addrs}}) {
3407
printf("\%-60s", sprintf("Probing for `\%s' at 0x\%x... ",
3408
$chip->{name}, $addr));
3409
$conf = &{$chip->{isa_detect}} ($addr);
3410
print("No\n"), next if not defined $conf;
3412
printf " (confidence %d, driver `%s')\n", $conf, $chip->{driver};
3416
chipname => $chip->{name},
3417
alias_detect => $chip->{alias_detect},
3419
add_isa_to_chips_detected($chip->{driver}, $new_hash);
3425
use vars qw(%superio);
3427
# The following are taken from the PNP ISA spec (so it's supposed
3428
# to be common to all Super I/O chips):
3429
# devidreg: The device ID register(s)
3430
# logdevreg: The logical device register
3431
# actreg: The activation register within the logical device
3432
# actmask: The activation bit in the activation register
3433
# basereg: The I/O base register within the logical device
3444
my ($addrreg, $datareg) = @_;
3446
# Some chips (SMSC, Winbond) want this
3447
outb($addrreg, 0xaa);
3449
# Return to "Wait For Key" state (PNP-ISA spec)
3450
outb($addrreg, 0x02);
3451
outb($datareg, 0x02);
3454
# Guess if an unknown Super-I/O chip has sensors
3455
sub guess_superio_ld
3457
my ($addrreg, $datareg, $typical_addr) = @_;
3458
my ($oldldn, $ldn, $addr);
3460
# Save logical device number
3461
outb($addrreg, $superio{logdevreg});
3462
$oldldn = inb($datareg);
3464
for ($ldn = 0; $ldn < 16; $ldn++) {
3465
# Select logical device
3466
outb($addrreg, $superio{logdevreg});
3467
outb($datareg, $ldn);
3469
# Read base I/O address
3470
outb($addrreg, $superio{basereg});
3471
$addr = inb($datareg) << 8;
3472
outb($addrreg, $superio{basereg} + 1);
3473
$addr |= inb($datareg);
3474
next unless ($addr & 0xfff8) == $typical_addr;
3476
printf " (logical device \%X has address 0x\%x, could be sensors)\n",
3481
# Be nice, restore original logical device
3482
outb($addrreg, $superio{logdevreg});
3483
outb($datareg, $oldldn);
3486
# Returns: features bitmask if device added to chips_detected, 0 if not
3489
my ($addrreg, $datareg, $chip) = @_;
3492
if (exists $chip->{check}) {
3493
return 0 unless $chip->{check}($addrreg, $datareg);
3496
printf "\%-60s", "Found `$chip->{name}'";
3498
# Does it have hardware monitoring capabilities?
3499
if (!exists $chip->{driver}) {
3500
print "\n (no information available)\n";
3503
if ($chip->{driver} eq "not-a-sensor") {
3504
print "\n (no hardware monitoring capabilities)\n";
3507
if ($chip->{driver} eq "via-smbus-only") {
3508
print "\n (hardware monitoring capabilities accessible via SMBus only)\n";
3512
# Switch to the sensor logical device
3513
outb($addrreg, $superio{logdevreg});
3514
outb($datareg, $chip->{logdev});
3516
# Get the IO base address
3517
outb($addrreg, $superio{basereg});
3518
$addr = inb($datareg);
3519
outb($addrreg, $superio{basereg} + 1);
3520
$addr = ($addr << 8) | inb($datareg);
3522
# Check the activation register and base address
3523
outb($addrreg, $superio{actreg});
3524
$val = inb($datareg);
3525
if (!($val & $superio{actmask})) {
3527
printf "\n (address 0x\%x, but not activated)\n", $addr;
3529
print "\n (but not activated)\n";
3534
print "\n (but no address specified)\n";
3539
printf " (address 0x\%x, driver `%s')\n", $addr, $chip->{driver};
3543
chipname => $chip->{name}
3545
add_isa_to_chips_detected($chip->{driver}, $new_hash);
3546
return $chip->{features};
3549
# Detection routine for non-standard SMSC Super I/O chips
3550
# $_[0]: Super I/O LPC config/index port
3551
# $_[1]: Super I/O LPC data port
3552
# $_[2]: Reference to array of non-standard chips
3553
# Return values: 1 if non-standard chip found, 0 otherwise
3554
sub smsc_ns_detect_superio
3556
my ($addrreg, $datareg, $ns_chips) = @_;
3559
# read alternate device ID register
3560
outb($addrreg, 0x0d);
3561
$val = inb($datareg);
3562
return 0 if $val == 0x00 || $val == 0xff;
3566
foreach $chip (@{$ns_chips}) {
3567
if ($chip->{devid} == $val) {
3568
probe_superio($addrreg, $datareg, $chip);
3573
printf("Found unknown non-standard chip with ID 0x%02x\n", $val);
3577
# Returns: features supported by the device added, if any
3580
my ($addrreg, $datareg) = @_;
3584
printf("Probing for Super-I/O at 0x\%x/0x\%x\n", $addrreg, $datareg);
3587
# reset state to avoid false positives
3588
exit_superio($addrreg, $datareg);
3589
foreach my $family (@superio_ids) {
3590
printf("\%-60s", "Trying family `$family->{family}'... ");
3591
# write the password
3592
foreach $val (@{$family->{enter}->{$addrreg}}) {
3593
outb($addrreg, $val);
3595
# call the non-standard detection routine first if it exists
3596
if (defined($family->{ns_detect}) &&
3597
&{$family->{ns_detect}}($addrreg, $datareg, $family->{ns_chips})) {
3602
outb($addrreg, $superio{devidreg});
3603
$val = inb($datareg);
3604
outb($addrreg, $superio{devidreg} + 1);
3605
$val = ($val << 8) | inb($datareg);
3606
if ($val == 0x0000 || $val == 0xffff) {
3613
foreach my $chip (@{$family->{chips}}) {
3614
if (($chip->{devid} > 0xff &&
3615
($val & ($chip->{devid_mask} || 0xffff)) == $chip->{devid})
3616
|| ($chip->{devid} <= 0xff &&
3617
($val >> 8) == $chip->{devid})) {
3618
$features |= probe_superio($addrreg, $datareg, $chip);
3624
printf("Found unknown chip with ID 0x%04x\n", $val);
3625
# Guess if a logical device could correspond to sensors
3626
guess_superio_ld($addrreg, $datareg, $family->{guess})
3627
if defined $family->{guess};
3631
exit_superio($addrreg, $datareg);
3641
printf("\%-60s", "$entry->{name}... ");
3642
if (defined ($confidence = $entry->{detect}())) {
3644
printf " (driver `%s')\n", $entry->{driver};
3646
conf => $confidence,
3647
chipname => $entry->{name},
3649
add_isa_to_chips_detected($entry->{driver}, $new_hash);
3659
# This routine allows you to dynamically update the chip detection list.
3660
# The most common use is to allow for different chip to driver mappings
3661
# based on different linux kernels
3662
sub chip_special_cases
3664
# Some chip to driver mappings depend on the environment
3665
foreach my $chip (@chip_ids) {
3666
if (ref($chip->{driver}) eq 'CODE') {
3667
$chip->{driver} = $chip->{driver}->();
3671
# Also fill the fake driver name of non-hwmon chips
3672
foreach my $chip (@non_hwmon_chip_ids) {
3673
$chip->{driver} = "not-a-sensor";
3677
# Each function returns a confidence value. The higher this value, the more
3678
# sure we are about this chip. This may help overrule false positives,
3679
# although we also attempt to prevent false positives in the first place.
3681
# Each function returns a list. The first element is the confidence value;
3682
# Each element after it is an SMBus address. In this way, we can detect
3683
# chips with several SMBus addresses. The SMBus address for which the
3684
# function was called is never returned.
3686
# All I2C detection functions below take at least 2 parameters:
3687
# $_[0]: Reference to the file descriptor to access the chip
3689
# Some of these functions which can detect more than one type of device,
3690
# take a third parameter:
3691
# $_[2]: Chip to detect
3693
# Registers used: 0x58
3696
my ($file, $addr) = @_;
3697
return if i2c_smbus_read_byte_data($file, 0x58) != 0xac;
3701
# Chip to detect: 0 = LM78, 2 = LM79
3703
# 0x40: Configuration
3704
# 0x48: Full I2C Address
3708
my ($file, $addr, $chip) = @_;
3711
return unless i2c_smbus_read_byte_data($file, 0x48) == $addr;
3712
return unless (i2c_smbus_read_byte_data($file, 0x40) & 0x80) == 0x00;
3714
$reg = i2c_smbus_read_byte_data($file, 0x49);
3715
return if $chip == 0 && ($reg != 0x00 && $reg != 0x20 && $reg != 0x40);
3716
return if $chip == 2 && ($reg & 0xfe) != 0xc0;
3718
# Explicitly prevent misdetection of Winbond chips
3719
$reg = i2c_smbus_read_byte_data($file, 0x4f);
3720
return if $reg == 0xa3 || $reg == 0x5c;
3725
# Chip to detect: 0 = LM75, 1 = DS75
3728
# 0x01: Configuration
3730
# 0x03: Overtemperature Shutdown
3731
# 0x04-0x07: No registers
3732
# The first detection step is based on the fact that the LM75 has only
3733
# four registers, and cycles addresses over 8-byte boundaries. We use the
3734
# 0x04-0x07 addresses (unused) to improve the reliability. These are not
3735
# real registers and will always return the last returned value. This isn't
3737
# Note that register 0x00 may change, so we can't use the modulo trick on it.
3738
# The DS75 is a bit different, it doesn't cycle over 8-byte boundaries, and
3739
# all register addresses from 0x04 to 0x0f behave like 0x04-0x07 do for
3741
# Not all devices enjoy SMBus read word transactions, so we use read byte
3742
# transactions even for the 16-bit registers. The low bits aren't very
3743
# useful for detection anyway.
3746
my ($file, $addr, $chip) = @_;
3748
my $cur = i2c_smbus_read_byte_data($file, 0x00);
3749
my $conf = i2c_smbus_read_byte_data($file, 0x01);
3751
my $hyst = i2c_smbus_read_byte_data($file, 0x02, NO_CACHE);
3752
my $maxreg = $chip == 1 ? 0x0f : 0x07;
3753
for $i (0x04 .. $maxreg) {
3754
return if i2c_smbus_read_byte_data($file, $i, NO_CACHE) != $hyst;
3757
my $os = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);
3758
for $i (0x04 .. $maxreg) {
3759
return if i2c_smbus_read_byte_data($file, $i, NO_CACHE) != $os;
3763
for ($i = 8; $i <= 248; $i += 40) {
3764
return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf
3765
or i2c_smbus_read_byte_data($file, $i + 0x02) != $hyst
3766
or i2c_smbus_read_byte_data($file, $i + 0x03) != $os;
3770
# All registers hold the same value, obviously a misdetection
3771
return if $conf == $cur and $cur == $hyst and $cur == $os;
3774
return if $chip == 0 and ($conf & 0xe0);
3775
return if $chip == 1 and ($conf & 0x80);
3777
# Most probable value ranges
3778
return 6 if $cur <= 100 and ($hyst >= 10 && $hyst <= 125)
3779
and ($os >= 20 && $os <= 127) and $hyst < $os;
3785
# 0x01: Configuration
3789
# 0x07: Manufacturer ID and Product ID
3792
my ($file, $addr) = @_;
3794
my $conf = i2c_smbus_read_byte_data($file, 0x01);
3795
my $status = i2c_smbus_read_byte_data($file, 0x04);
3797
# Bits that always return 0
3798
return if ($conf & 0x0c) or ($status & 0x10);
3800
return if i2c_smbus_read_word_data($file, 0x07) != 0x9001;
3802
# Make sure the chip supports SMBus read word transactions
3803
my $cur = i2c_smbus_read_word_data($file, 0x00);
3805
my $high = i2c_smbus_read_word_data($file, 0x02);
3806
return if $high < 0;
3807
my $low = i2c_smbus_read_word_data($file, 0x03);
3809
return if ($cur & 0x0300) or (($high | $low) & 0x1f00);
3816
# 0x01: Configuration
3818
# 0x03: Overtemperature Shutdown
3821
# 0x06-0x07: No registers
3822
# The first detection step is based on the fact that the LM77 has only
3823
# six registers, and cycles addresses over 8-byte boundaries. We use the
3824
# 0x06-0x07 addresses (unused) to improve the reliability. These are not
3825
# real registers and will always return the last returned value. This isn't
3827
# Note that register 0x00 may change, so we can't use the modulo trick on it.
3828
# Not all devices enjoy SMBus read word transactions, so we use read byte
3829
# transactions even for the 16-bit registers at first. We only use read word
3830
# transactions in the end when we are already almost certain that we have an
3834
my ($file, $addr) = @_;
3836
my $cur = i2c_smbus_read_byte_data($file, 0x00);
3837
my $conf = i2c_smbus_read_byte_data($file, 0x01);
3838
my $hyst = i2c_smbus_read_byte_data($file, 0x02);
3839
my $os = i2c_smbus_read_byte_data($file, 0x03);
3841
my $low = i2c_smbus_read_byte_data($file, 0x04, NO_CACHE);
3842
return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $low;
3843
return if i2c_smbus_read_byte_data($file, 0x07, NO_CACHE) != $low;
3845
my $high = i2c_smbus_read_byte_data($file, 0x05, NO_CACHE);
3846
return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $high;
3847
return if i2c_smbus_read_byte_data($file, 0x07, NO_CACHE) != $high;
3849
for ($i = 8; $i <= 248; $i += 40) {
3850
return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf;
3851
return if i2c_smbus_read_byte_data($file, $i + 0x02) != $hyst;
3852
return if i2c_smbus_read_byte_data($file, $i + 0x03) != $os;
3853
return if i2c_smbus_read_byte_data($file, $i + 0x04) != $low;
3854
return if i2c_smbus_read_byte_data($file, $i + 0x05) != $high;
3857
# All registers hold the same value, obviously a misdetection
3858
return if $conf == $cur and $cur == $hyst
3859
and $cur == $os and $cur == $low and $cur == $high;
3862
return if ($conf & 0xe0)
3863
or (($cur >> 4) != 0 && ($cur >> 4) != 0xf)
3864
or (($hyst >> 4) != 0 && ($hyst >> 4) != 0xf)
3865
or (($os >> 4) != 0 && ($os >> 4) != 0xf)
3866
or (($low >> 4) != 0 && ($low >> 4) != 0xf)
3867
or (($high >> 4) != 0 && ($high >> 4) != 0xf);
3869
# Make sure the chip supports SMBus read word transactions
3870
foreach $i (0x00, 0x02, 0x03, 0x04, 0x05) {
3871
return if i2c_smbus_read_word_data($file, $i) < 0;
3877
# Chip to detect: 0 = LM92, 1 = LM76, 2 = MAX6633/MAX6634/MAX6635
3879
# 0x01: Configuration (National Semiconductor only)
3881
# 0x03: Critical Temp
3884
# 0x07: Manufacturer ID (LM92 only)
3885
# One detection step is based on the fact that the LM92 and clones have a
3886
# limited number of registers, which cycle modulo 16 address values.
3887
# Note that register 0x00 may change, so we can't use the modulo trick on it.
3888
# Not all devices enjoy SMBus read word transactions, so we use read byte
3889
# transactions even for the 16-bit registers at first. We only use read
3890
# word transactions in the end when we are already almost certain that we
3891
# have an LM92 chip or compatible.
3894
my ($file, $addr, $chip) = @_;
3896
my $conf = i2c_smbus_read_byte_data($file, 0x01);
3897
my $hyst = i2c_smbus_read_byte_data($file, 0x02);
3898
my $crit = i2c_smbus_read_byte_data($file, 0x03);
3899
my $low = i2c_smbus_read_byte_data($file, 0x04);
3900
my $high = i2c_smbus_read_byte_data($file, 0x05);
3902
return if $conf == 0 and $hyst == 0 and $crit == 0
3903
and $low == 0 and $high == 0;
3906
return if ($chip == 0 || $chip == 1)
3909
for (my $i = 0; $i <= 240; $i += 16) {
3910
return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf;
3911
return if i2c_smbus_read_byte_data($file, $i + 0x02) != $hyst;
3912
return if i2c_smbus_read_byte_data($file, $i + 0x03) != $crit;
3913
return if i2c_smbus_read_byte_data($file, $i + 0x04) != $low;
3914
return if i2c_smbus_read_byte_data($file, $i + 0x05) != $high;
3917
return if $chip == 0
3918
and i2c_smbus_read_word_data($file, 0x07) != 0x0180;
3920
# Make sure the chip supports SMBus read word transactions
3921
$hyst = i2c_smbus_read_word_data($file, 0x02);
3922
return if $hyst < 0;
3923
$crit = i2c_smbus_read_word_data($file, 0x03);
3924
return if $crit < 0;
3925
$low = i2c_smbus_read_word_data($file, 0x04);
3927
$high = i2c_smbus_read_word_data($file, 0x05);
3928
return if $high < 0;
3930
foreach my $temp ($hyst, $crit, $low, $high) {
3931
return if $chip == 2 and ($temp & 0x7F00);
3932
return if $chip != 2 and ($temp & 0x0700);
3935
return ($chip == 0) ? 4 : 2;
3944
# 0xAC: Configuration
3945
# Detection is weak. We check if bit 4 (NVB) is clear, because it is
3946
# unlikely to be set (would mean that EEPROM is currently being accessed).
3947
# We also check the value of the counter and slope registers, the datasheet
3948
# doesn't mention the possible values but the conversion formula together
3949
# with experimental evidence suggest possible sanity checks.
3950
# Not all devices enjoy SMBus read word transactions, so we do as much as
3951
# possible with read byte transactions first, and only use read word
3952
# transactions second.
3955
my ($file, $addr) = @_;
3957
my $conf = i2c_smbus_read_byte_data($file, 0xAC);
3958
return if ($conf & 0x10);
3960
my $temp = i2c_smbus_read_word_data($file, 0xAA);
3961
return if $temp < 0 || ($temp & 0x0f00);
3962
# On the DS1631, the following two checks are too strict in theory,
3963
# but in practice I very much doubt that anyone will set temperature
3964
# limits not a multiple of 0.5 degrees C.
3965
my $high = i2c_smbus_read_word_data($file, 0xA1);
3966
return if $high < 0 || ($high & 0x7f00);
3967
my $low = i2c_smbus_read_word_data($file, 0xA2);
3968
return if $low < 0 || ($low & 0x7f00);
3970
return if ($temp == 0 && $high == 0 && $low == 0 && $conf == 0);
3972
# Old versions of the DS1621 apparently don't have the counter and
3973
# slope registers (or they return crap)
3974
my $counter = i2c_smbus_read_byte_data($file, 0xA8);
3975
my $slope = i2c_smbus_read_byte_data($file, 0xA9);
3976
return ($slope == 0x10 && $counter <= $slope) ? 3 : 2;
3980
# 0x00: Configuration register
3981
# 0x02: Interrupt state register
3982
# 0x2a-0x3d: Limits registers
3983
# This one is easily misdetected since it doesn't provide identification
3984
# registers. So we have to use some tricks:
3985
# - 6-bit addressing, so limits readings modulo 0x40 should be unchanged
3986
# - positive temperature limits
3987
# - limits order correctness
3988
# Hopefully this should limit the rate of false positives, without increasing
3989
# the rate of false negatives.
3990
# Thanks to Lennard Klein for testing on a non-LM80 chip, which was
3991
# previously misdetected, and isn't anymore. For reference, it scored
3992
# a final confidence of 0, and changing from strict limit comparisons
3993
# to loose comparisons did not change the score.
3996
my ($file, $addr) = @_;
3999
return if (i2c_smbus_read_byte_data($file, 0x00) & 0x80) != 0;
4000
return if (i2c_smbus_read_byte_data($file, 0x02) & 0xc0) != 0;
4002
for ($i = 0x2a; $i <= 0x3d; $i++) {
4003
$reg = i2c_smbus_read_byte_data($file, $i);
4004
return if i2c_smbus_read_byte_data($file, $i+0x40) != $reg;
4005
return if i2c_smbus_read_byte_data($file, $i+0x80) != $reg;
4006
return if i2c_smbus_read_byte_data($file, $i+0xc0) != $reg;
4009
# Refine a bit by checking whether limits are in the correct order
4010
# (min<max for voltages, hyst<max for temperature). Since it is still
4011
# possible that the chip is an LM80 with limits not properly set,
4012
# a few "errors" are tolerated.
4014
for ($i = 0x2a; $i <= 0x3a; $i++) {
4016
if i2c_smbus_read_byte_data($file, $i) < i2c_smbus_read_byte_data($file, $i+1);
4020
if i2c_smbus_read_byte_data($file, 0x38) < i2c_smbus_read_byte_data($file, 0x3a);
4022
# Negative temperature limits are unlikely.
4023
for ($i = 0x3a; $i <= 0x3d; $i++) {
4024
$confidence++ if (i2c_smbus_read_byte_data($file, $i) & 0x80) == 0;
4027
# $confidence is between 0 and 14
4028
$confidence = ($confidence >> 1) - 4;
4029
# $confidence is now between -4 and 3
4031
return unless $confidence > 0;
4038
# 0x03: Configuration
4039
# 0x04: Company ID of LM84
4041
# 0xfe: Manufacturer ID
4042
# 0xff: Chip ID / die revision
4043
# We can use the LM84 Company ID register because the LM83 and the LM82 are
4044
# compatible with the LM84.
4045
# The LM83 chip ID is missing from the datasheet and was contributed by
4046
# Magnus Forsstrom: 0x03.
4047
# At least some revisions of the LM82 seem to be repackaged LM83, so they
4048
# have the same chip ID, and temp2/temp4 will be stuck in "OPEN" state.
4049
# For this reason, we don't even try to distinguish between both chips.
4050
# Thanks to Ben Gardner for reporting.
4053
my ($file, $addr) = @_;
4054
return if i2c_smbus_read_byte_data($file, 0xfe) != 0x01;
4055
my $chipid = i2c_smbus_read_byte_data($file, 0xff);
4056
return if $chipid != 0x01 && $chipid != 0x03;
4060
if (i2c_smbus_read_byte_data($file, 0x02) & 0xa8) == 0x00;
4062
if (i2c_smbus_read_byte_data($file, 0x03) & 0x41) == 0x00;
4064
if i2c_smbus_read_byte_data($file, 0x04) == 0x00;
4066
if (i2c_smbus_read_byte_data($file, 0x35) & 0x48) == 0x00;
4071
# Chip to detect: 0 = MAX6680/81, 1 = MAX6695/96
4073
# 0x03: Configuration
4074
# 0x04: Conversion rate
4076
# 0x16: Overtemperature 2
4077
# 0xfe: Manufacturer ID
4078
# 0xff: Chip ID / die revision
4079
sub max6680_95_detect
4081
my ($file, $addr, $chip) = @_;
4082
my $cid = i2c_smbus_read_byte_data($file, 0xff);
4083
my $conf = i2c_smbus_read_byte_data($file, 0x03);
4084
my $mid = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);
4085
my $emerg = i2c_smbus_read_byte_data($file, 0x16, NO_CACHE);
4086
my $rate = i2c_smbus_read_byte_data($file, 0x04, NO_CACHE);
4087
my $emerg2 = i2c_smbus_read_byte_data($file, 0x16, NO_CACHE);
4089
# Check common conditions
4090
return if $rate > 0x07;
4091
return if $mid != 0x4d; # Not Maxim
4092
return if $cid != 0x01; # None of the chips we are looking for
4095
return if ($conf & 0x03) != 0;
4096
return 8 if $emerg != $emerg2; # MAX6680/MAX6681
4099
my $status2 = i2c_smbus_read_byte_data($file, 0x12);
4101
return if ($conf & 0x10) != 0;
4102
return if ($status2 & 0x01) != 0;
4103
return 8 if $emerg == $emerg2; # MAX6695/MAX6696
4108
# Chip to detect: 0 = LM90, 1 = LM89/LM99, 2 = LM86, 3 = ADM1032,
4109
# 4 = MAX6654, 5 = ADT7461,
4110
# 6 = MAX6646/MAX6647/MAX6648/MAX6649/MAX6692,
4111
# 8 = W83L771W/G, 9 = TMP401, 10 = TMP411,
4112
# 11 = W83L771AWG/ASG, 12 = MAX6690
4114
# 0x03: Configuration
4115
# 0x04: Conversion rate
4116
# 0xfe: Manufacturer ID
4117
# 0xff: Chip ID / die revision
4120
my ($file, $addr, $chip) = @_;
4121
my $mid = i2c_smbus_read_byte_data($file, 0xfe);
4122
my $cid = i2c_smbus_read_byte_data($file, 0xff);
4123
my $conf = i2c_smbus_read_byte_data($file, 0x03);
4124
my $rate = i2c_smbus_read_byte_data($file, 0x04);
4127
return if ($conf & 0x2a) != 0;
4128
return if $rate > 0x09;
4129
return if $mid != 0x01; # National Semiconductor
4130
return 8 if $cid == 0x21; # LM90
4131
return 6 if ($cid & 0x0f) == 0x20;
4134
return if ($conf & 0x2a) != 0;
4135
return if $rate > 0x09;
4136
return if $mid != 0x01; # National Semiconductor
4137
return 8 if $addr == 0x4c and $cid == 0x31; # LM89/LM99
4138
return 8 if $addr == 0x4d and $cid == 0x34; # LM89-1/LM99-1
4139
return 6 if ($cid & 0x0f) == 0x30;
4142
return if ($conf & 0x2a) != 0;
4143
return if $rate > 0x09;
4144
return if $mid != 0x01; # National Semiconductor
4145
return 8 if $cid == 0x11; # LM86
4146
return 6 if ($cid & 0xf0) == 0x10;
4149
return if ($conf & 0x3f) != 0;
4150
return if $rate > 0x0a;
4151
return if $mid != 0x41; # Analog Devices
4152
return 6 if ($cid & 0xf0) == 0x40; # ADM1032
4155
return if ($conf & 0x07) != 0;
4156
return if $rate > 0x07;
4157
return if $mid != 0x4d; # Maxim
4158
return 8 if $cid == 0x08; # MAX6654
4161
return if ($conf & 0x1b) != 0;
4162
return if $rate > 0x0a;
4163
return if $mid != 0x41; # Analog Devices
4164
return 8 if $cid == 0x51; # ADT7461
4167
return if ($conf & 0x3f) != 0;
4168
return if $rate > 0x07;
4169
return if $mid != 0x4d; # Maxim
4170
return 8 if $cid == 0x59; # MAX6648/MAX6692
4173
return if ($conf & 0x2a) != 0;
4174
return if $rate > 0x09;
4175
return if $mid != 0x5c; # Winbond
4176
return 6 if ($cid & 0xfe) == 0x00; # W83L771W/G
4179
return if ($conf & 0x1B) != 0;
4180
return if $rate > 0x0F;
4181
return if $mid != 0x55; # Texas Instruments
4182
return 8 if $cid == 0x11; # TMP401
4185
return if ($conf & 0x1B) != 0;
4186
return if $rate > 0x0F;
4187
return if $mid != 0x55; # Texas Instruments
4188
return 6 if ($addr == 0x4c && $cid == 0x12); # TMP411A
4189
return 6 if ($addr == 0x4d && $cid == 0x13); # TMP411B
4190
return 6 if ($addr == 0x4e && $cid == 0x10); # TMP411C
4193
return if ($conf & 0x2a) != 0;
4194
return if $rate > 0x08;
4195
return if $mid != 0x5c; # Winbond
4196
return 6 if ($cid & 0xfe) == 0x10; # W83L771AWG/ASG
4199
return if ($conf & 0x07) != 0;
4200
return if $rate > 0x07;
4201
return if $mid != 0x4d; # Maxim
4202
return 8 if $cid == 0x09; # MAX6690
4207
# Chip to detect: 0 = TMP421, 1 = TMP422, 2 = TMP423
4209
# 0xfe: Manufactorer ID
4213
my ($file, $addr, $chip) = @_;
4215
my $mid = i2c_smbus_read_byte_data($file, 0xfe);
4216
my $cid = i2c_smbus_read_byte_data($file, 0xff);
4218
return if ($mid != 0x55);
4220
return 6 if ($chip == 0 && $cid == 0x21); # TMP421
4221
return 6 if ($chip == 1 && $cid == 0x22); # TMP422
4222
return 6 if ($chip == 2 && $cid == 0x23); # TMP423
4230
sub amc6821_detect()
4232
my ($file, $addr) = @_;
4234
my $dev_id = i2c_smbus_read_byte_data($file, 0x3d);
4235
my $comp_id = i2c_smbus_read_byte_data($file, 0x3e);
4237
return if ($comp_id != 0x49); # Texas Instruments
4239
# Bit 7 of register address is ignored
4240
return if i2c_smbus_read_byte_data($file, 0x80 | 0x3d) != $dev_id;
4241
return if i2c_smbus_read_byte_data($file, 0x80 | 0x3e) != $comp_id;
4243
return 6 if ($dev_id == 0x21); # AMC6821
4249
# 0x03: Configuration (no low nibble, returns the previous low nibble)
4250
# 0x04: Conversion rate
4251
# 0xfe: Manufacturer ID
4255
my ($file, $addr) = @_;
4256
my $mid = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);
4257
my $cid = i2c_smbus_read_byte_data($file, 0xff, NO_CACHE);
4258
my $conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);
4260
return if $mid != 0x4d; # Maxim
4261
return if ($conf & 0x1f) != 0x0d;
4262
return if $cid != 0x4d; # No register, returns previous value
4264
my $rate = i2c_smbus_read_byte_data($file, 0x04, NO_CACHE);
4265
return if $rate > 0x09;
4267
$cid = i2c_smbus_read_byte_data($file, 0xff, NO_CACHE);
4268
$conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);
4269
return if ($conf & 0x0f) != $rate;
4270
return if $cid != $rate; # No register, returns previous value
4275
# Chip to detect: 0 = LM95231, 1 = LM95241
4277
# 0x02: Status (3 unused bits)
4278
# 0x03: Configuration (3 unused bits)
4279
# 0x06: Remote diode filter control (6 unused bits)
4280
# 0x30: Remote diode model type select (6 unused bits)
4281
# 0xfe: Manufacturer ID
4285
my ($file, $addr, $chip) = @_;
4286
my $mid = i2c_smbus_read_byte_data($file, 0xfe);
4287
my $cid = i2c_smbus_read_byte_data($file, 0xff);
4289
return if $mid != 0x01; # National Semiconductor
4290
return if $chip == 0 && $cid != 0xa1; # LM95231
4291
return if $chip == 1 && $cid != 0xa4; # LM95231
4293
return if i2c_smbus_read_byte_data($file, 0x02) & 0x70;
4294
return if i2c_smbus_read_byte_data($file, 0x03) & 0x89;
4295
return if i2c_smbus_read_byte_data($file, 0x06) & 0xfa;
4296
return if i2c_smbus_read_byte_data($file, 0x30) & 0xfa;
4302
# 0x03: Configuration 1
4303
# 0x24: Configuration 2
4304
# 0x3d: Manufacturer ID
4308
my ($file, $addr) = @_;
4309
my $mid = i2c_smbus_read_byte_data($file, 0x3d);
4310
my $cid = i2c_smbus_read_byte_data($file, 0x3e);
4311
my $conf1 = i2c_smbus_read_byte_data($file, 0x03);
4312
my $conf2 = i2c_smbus_read_byte_data($file, 0x24);
4314
return if ($conf1 & 0x10) != 0;
4315
return if ($conf2 & 0x7f) != 0;
4316
return if $mid != 0x41; # Analog Devices
4317
return if $cid != 0x81; # ADT7481
4322
# Chip to detect: 1 = LM63, 2 = F75363SG, 3 = LM64
4324
# 0xfe: Manufacturer ID
4325
# 0xff: Chip ID / die revision
4326
# 0x03: Configuration (two or three unused bits)
4327
# 0x16: Alert mask (two or three unused bits)
4330
my ($file, $addr, $chip) = @_;
4332
my $mid = i2c_smbus_read_byte_data($file, 0xfe);
4333
my $cid = i2c_smbus_read_byte_data($file, 0xff);
4334
my $conf = i2c_smbus_read_byte_data($file, 0x03);
4335
my $mask = i2c_smbus_read_byte_data($file, 0x16);
4338
return if $mid != 0x01 # National Semiconductor
4339
|| $cid != 0x41; # LM63
4340
return if ($conf & 0x18) != 0x00
4341
|| ($mask & 0xa4) != 0xa4;
4342
} elsif ($chip == 2) {
4343
return if $mid != 0x23 # Fintek
4344
|| $cid != 0x20; # F75363SG
4345
return if ($conf & 0x1a) != 0x00
4346
|| ($mask & 0x84) != 0x00;
4347
} elsif ($chip == 3) {
4348
return if $mid != 0x01 # National Semiconductor
4349
|| $cid != 0x51; # LM64
4350
return if ($conf & 0x18) != 0x00
4351
|| ($mask & 0xa4) != 0xa4;
4358
# 0x02, 0x03: Fan support
4359
# 0x06: Temperature support
4360
# 0x07, 0x08, 0x09: Fan config
4361
# 0x0d: Manufacturer ID
4362
# 0x0e: Chip ID / die revision
4365
my ($file, $addr) = @_;
4366
my $mid = i2c_smbus_read_byte_data($file, 0x0d);
4367
my $cid = i2c_smbus_read_byte_data($file, 0x0e);
4370
return unless $mid == 0x41; # Analog Devices
4371
return unless ($cid & 0xF0) == 0x00; # ADM1029
4373
# Extra check on unused bits
4374
$cfg = i2c_smbus_read_byte_data($file, 0x02);
4375
return unless $cfg == 0x03;
4376
$cfg = i2c_smbus_read_byte_data($file, 0x06);
4377
return unless ($cfg & 0xF9) == 0x01;
4378
foreach my $reg (0x03, 0x07, 0x08, 0x09) {
4379
$cfg = i2c_smbus_read_byte_data($file, $reg);
4380
return unless ($cfg & 0xFC) == 0x00;
4386
# Chip to detect: 0 = ADM1030, 1 = ADM1031
4390
# 0x0d, 0x0e, 0x0f: Temperature offsets
4391
# 0x22: Fan speed config
4393
# 0x3e: Manufacturer ID
4394
# 0x3f: Die revision
4397
my ($file, $addr, $chip) = @_;
4398
my $mid = i2c_smbus_read_byte_data($file, 0x3e);
4399
my $cid = i2c_smbus_read_byte_data($file, 0x3d);
4400
my $drev = i2c_smbus_read_byte_data($file, 0x3f);
4401
my $conf2 = i2c_smbus_read_byte_data($file, 0x01);
4402
my $stat2 = i2c_smbus_read_byte_data($file, 0x03);
4403
my $fsc = i2c_smbus_read_byte_data($file, 0x22);
4404
my $lto = i2c_smbus_read_byte_data($file, 0x0d);
4405
my $r1to = i2c_smbus_read_byte_data($file, 0x0e);
4406
my $r2to = i2c_smbus_read_byte_data($file, 0x0f);
4410
return if $mid != 0x41; # Analog Devices
4411
return if $cid != 0x30; # ADM1030
4412
$confidence++ if ($drev & 0x70) == 0x00;
4413
$confidence++ if ($conf2 & 0x4A) == 0x00;
4414
$confidence++ if ($stat2 & 0x3F) == 0x00;
4415
$confidence++ if ($fsc & 0xF0) == 0x00;
4416
$confidence++ if ($lto & 0x70) == 0x00;
4417
$confidence++ if ($r1to & 0x70) == 0x00;
4421
return if $mid != 0x41; # Analog Devices
4422
return if $cid != 0x31; # ADM1031
4423
$confidence++ if ($drev & 0x70) == 0x00;
4424
$confidence++ if ($lto & 0x70) == 0x00;
4425
$confidence++ if ($r1to & 0x70) == 0x00;
4426
$confidence++ if ($r2to & 0x70) == 0x00;
4431
# Chip to detect: 0 = ADM1033, 1 = ADM1034
4434
# 0x3e: Manufacturer ID
4435
# 0x3f: Die revision
4438
my ($file, $addr, $chip) = @_;
4439
my $mid = i2c_smbus_read_byte_data($file, 0x3e);
4440
my $cid = i2c_smbus_read_byte_data($file, 0x3d);
4441
my $drev = i2c_smbus_read_byte_data($file, 0x3f);
4444
return if $mid != 0x41; # Analog Devices
4445
return if $cid != 0x33; # ADM1033
4446
return if ($drev & 0xf8) != 0x00;
4447
return 6 if $drev == 0x02;
4451
return if $mid != 0x41; # Analog Devices
4452
return if $cid != 0x34; # ADM1034
4453
return if ($drev & 0xf8) != 0x00;
4454
return 6 if $drev == 0x02;
4459
# Chip to detect: 0 = ADT7467/ADT7468, 1 = ADT7476, 2 = ADT7462, 3 = ADT7466,
4463
# 0x3e: Manufacturer ID
4464
# 0x3f: Die revision
4467
my ($file, $addr, $chip) = @_;
4468
my $mid = i2c_smbus_read_byte_data($file, 0x3e);
4469
my $cid = i2c_smbus_read_byte_data($file, 0x3d);
4470
my $drev = i2c_smbus_read_byte_data($file, 0x3f);
4472
return if $mid != 0x41; # Analog Devices
4475
return if $cid != 0x68; # ADT7467/ADT7468
4476
return if ($drev & 0xf0) != 0x70;
4477
return 7 if $drev == 0x71 || $drev == 0x72;
4481
return if $cid != 0x76; # ADT7476
4482
return if ($drev & 0xf0) != 0x60;
4483
return 7 if $drev >= 0x69 && $drev <= 0x6b;
4487
return if $cid != 0x62; # ADT7462
4488
return if ($drev & 0xf0) != 0x00;
4489
return 7 if $drev == 0x04;
4493
return if $cid != 0x66; # ADT7466
4494
return if ($drev & 0xf0) != 0x00;
4495
return 7 if $drev == 0x02;
4499
return if $cid != 0x70; # ADT7470
4500
return if ($drev & 0xf0) != 0x00;
4501
return 7 if $drev == 0x00;
4506
# Chip to detect: 0 = ADT7473, 1 = ADT7475
4509
# 0x3e: Manufacturer ID
4512
my ($file, $addr, $chip) = @_;
4513
my $mid = i2c_smbus_read_byte_data($file, 0x3e);
4514
my $cid = i2c_smbus_read_byte_data($file, 0x3d);
4516
return if $mid != 0x41; # Analog Devices
4518
return if $chip == 0 && $cid != 0x73; # ADT7473
4519
return if $chip == 1 && $cid != 0x75; # ADT7475
4524
# 0x3e: Manufacturer ID
4528
my ($file, $addr) = @_;
4529
my $mid = i2c_smbus_read_byte_data($file, 0x3e);
4530
my $cid = i2c_smbus_read_byte_data($file, 0x3f);
4532
return if $mid != 0x41; # Analog Devices
4533
return if ($cid & 0xfc) != 0x6c; # ADT7490
4539
# 0x4e: Manufacturer ID
4540
# 0x4e: Silicon revision
4543
my ($file, $addr) = @_;
4544
my $dev_id = i2c_smbus_read_byte_data($file, 0x4d);
4545
my $man_id = i2c_smbus_read_byte_data($file, 0x4e);
4546
my $revision = i2c_smbus_read_byte_data($file, 0x4f);
4548
return if $man_id != 0x41; # Analog Devices
4549
return if $dev_id != 0x02; # ADT7411
4550
# The datasheet suggests that the version is in the high nibble, but
4551
# a dump from a real ADT7411 chip shows that it is in the low nibble.
4552
return if ($revision & 0x0f) != 0x04; # ADT7411
4556
# Chip to detect: 0 = aSC7512, 1 = aSC7611, 2 = aSC7621
4558
# 0x3e: Manufacturer ID
4560
sub andigilog_detect
4562
my ($file, $addr, $chip) = @_;
4563
my $mid = i2c_smbus_read_byte_data($file, 0x3e);
4564
my $cid = i2c_smbus_read_byte_data($file, 0x3f);
4566
return if $mid != 0x61; # Andigilog
4568
return if $chip == 0 && $cid != 0x62;
4569
return if $chip == 1 && $cid != 0x69;
4570
return if $chip == 2 && ($cid != 0x6C && $cid != 0x6D);
4575
# 0xfe: Manufacturer ID
4577
sub andigilog_aSC7511_detect
4579
my ($file, $addr) = @_;
4580
my $mid = i2c_smbus_read_byte_data($file, 0xfe);
4581
my $die = i2c_smbus_read_byte_data($file, 0xff);
4583
return if $mid != 0x61; # Andigilog
4584
return if $die != 0x00;
4588
# Chip to detect: 0 = LM85, 1 = LM96000, 2 = ADM1027, 3 = ADT7463,
4589
# 4 = EMC6D100/101, 5 = EMC6D102, 6 = EMC6D103,
4590
# 7 = WPCD377I (no sensors)
4592
# 0x3e: Vendor register
4593
# 0x3d: Device ID register (Analog Devices only)
4594
# 0x3f: Version/Stepping register
4597
my ($file, $addr, $chip) = @_;
4598
my $vendor = i2c_smbus_read_byte_data($file, 0x3e);
4599
my $verstep = i2c_smbus_read_byte_data($file, 0x3f);
4602
return if $vendor != 0x01; # National Semiconductor
4603
return if $verstep != 0x60 # LM85 C
4604
&& $verstep != 0x62; # LM85 B
4605
} elsif ($chip == 1 || $chip == 7) {
4606
return if $vendor != 0x01; # National Semiconductor
4607
return if $verstep != 0x68 # LM96000
4608
&& $verstep != 0x69; # LM96000
4609
} elsif ($chip == 2) {
4610
return if $vendor != 0x41; # Analog Devices
4611
return if $verstep != 0x60; # ADM1027
4612
} elsif ($chip == 3) {
4613
return if $vendor != 0x41; # Analog Devices
4614
return if $verstep != 0x62 # ADT7463
4615
&& $verstep != 0x6a; # ADT7463 C
4616
} elsif ($chip == 4) {
4617
return if $vendor != 0x5c; # SMSC
4618
return if $verstep != 0x60 # EMC6D100/101 A0
4619
&& $verstep != 0x61; # EMC6D100/101 A1
4620
} elsif ($chip == 5) {
4621
return if $vendor != 0x5c; # SMSC
4622
return if $verstep != 0x65; # EMC6D102
4623
} elsif ($chip == 6) {
4624
return if $vendor != 0x5c; # SMSC
4625
return if $verstep != 0x68; # EMC6D103
4628
if ($vendor == 0x41) { # Analog Devices
4629
return if i2c_smbus_read_byte_data($file, 0x3d) != 0x27;
4633
if ($chip == 1 || $chip == 7) {
4634
# Differenciate between real LM96000 and Winbond WPCD377I.
4635
# The latter emulate the former except that it has no
4636
# hardware monitoring function so the readings are always
4638
my ($in_temp, $fan, $i);
4640
for ($i = 0; $i < 8; $i++) {
4641
$in_temp = i2c_smbus_read_byte_data($file, 0x20 + $i);
4642
$fan = i2c_smbus_read_byte_data($file, 0x28 + $i);
4643
if ($in_temp != 0x00 or $fan != 0xff) {
4644
return 7 if $chip == 1;
4648
return 7 if $chip == 7;
4655
# Chip to detect: 0 = LM87, 1 = ADM1024
4659
# 0x40: Configuration
4662
my ($file, $addr, $chip) = @_;
4663
my $cid = i2c_smbus_read_byte_data($file, 0x3e);
4664
my $rev = i2c_smbus_read_byte_data($file, 0x3f);
4667
return if $cid != 0x02; # National Semiconductor
4668
return if ($rev & 0xfc) != 0x04; # LM87
4671
return if $cid != 0x41; # Analog Devices
4672
return if ($rev & 0xf0) != 0x10; # ADM1024
4675
my $cfg = i2c_smbus_read_byte_data($file, 0x40);
4676
return if ($cfg & 0x80) != 0x00;
4681
# Chip to detect: 0 = W83781D, 1 = W83782D, 2 = W83783S, 3 = W83627HF,
4682
# 4 = AS99127F (rev.1), 5 = AS99127F (rev.2), 6 = ASB100,
4683
# 7 = W83791D, 8 = W83792D, 9 = W83627EHF,
4684
# 10 = W83627DHG/W83667HG/W83677HG
4686
# 0x48: Full I2C Address
4687
# 0x4a: I2C addresses of emulated LM75 chips
4688
# 0x4e: Vendor ID byte selection, and bank selection
4690
# 0x58: Device ID (only when in bank 0)
4691
# Note: Fails if the W8378xD is not in bank 0!
4692
# Note: Asus chips do not have their I2C address at register 0x48?
4693
# AS99127F rev.1 and ASB100 have 0x00, confirmation wanted for
4697
my ($file, $addr, $chip) = @_;
4698
my ($reg1, $reg2, @res);
4700
return unless (i2c_smbus_read_byte_data($file, 0x48) == $addr)
4701
or ($chip >= 4 && $chip <= 6);
4703
$reg1 = i2c_smbus_read_byte_data($file, 0x4e);
4704
$reg2 = i2c_smbus_read_byte_data($file, 0x4f);
4705
if ($chip == 4) { # Asus AS99127F (rev.1)
4706
return unless (($reg1 & 0x80) == 0x00 and $reg2 == 0xc3) or
4707
(($reg1 & 0x80) == 0x80 and $reg2 == 0x12);
4708
} elsif ($chip == 6) { # Asus ASB100
4709
return unless (($reg1 & 0x80) == 0x00 and $reg2 == 0x94) or
4710
(($reg1 & 0x80) == 0x80 and $reg2 == 0x06);
4711
} else { # Winbond and Asus AS99127F (rev.2)
4712
return unless (($reg1 & 0x80) == 0x00 and $reg2 == 0xa3) or
4713
(($reg1 & 0x80) == 0x80 and $reg2 == 0x5c);
4716
return unless ($reg1 & 0x07) == 0x00;
4718
$reg1 = i2c_smbus_read_byte_data($file, 0x58);
4719
return if $chip == 0 and ($reg1 != 0x10 && $reg1 != 0x11);
4720
return if $chip == 1 and $reg1 != 0x30;
4721
return if $chip == 2 and $reg1 != 0x40;
4722
return if $chip == 3 and $reg1 != 0x21;
4723
return if $chip == 4 and $reg1 != 0x31;
4724
return if $chip == 5 and $reg1 != 0x31;
4725
return if $chip == 6 and $reg1 != 0x31;
4726
return if $chip == 7 and $reg1 != 0x71;
4727
return if $chip == 8 and $reg1 != 0x7a;
4728
return if $chip == 9 and ($reg1 != 0x88 && $reg1 != 0xa1);
4729
return if $chip == 10 and $reg1 != 0xc1;
4730
# Default address is 0x2d
4731
@res = ($addr != 0x2d) ? (7) : (8);
4732
return @res if $chip >= 9; # No subclients
4734
$reg1 = i2c_smbus_read_byte_data($file, 0x4a);
4735
push @res, ($reg1 & 0x07) + 0x48 unless $reg1 & 0x08;
4736
push @res, (($reg1 & 0x70) >> 4) + 0x48
4737
unless ($reg1 & 0x80 or $chip == 2);
4742
# 0x0b: Full I2C Address
4743
# 0x0c: I2C addresses of emulated LM75 chips
4744
# 0x00: Vendor ID byte selection, and bank selection(Bank 0, 1, 2)
4745
# 0x0d: Vendor ID(Bank 0, 1, 2)
4746
# 0x0e: Device ID(Bank 0, 1, 2)
4749
my ($file, $addr) = @_;
4750
my ($bank, $reg, @res);
4752
$bank = i2c_smbus_read_byte_data($file, 0x00);
4753
$reg = i2c_smbus_read_byte_data($file, 0x0d);
4755
return unless (($bank & 0x80) == 0x00 and $reg == 0xa3) or
4756
(($bank & 0x80) == 0x80 and $reg == 0x5c);
4758
$reg = i2c_smbus_read_byte_data($file, 0x0e);
4759
return if $reg != 0x7b;
4761
# If bank 0 is selected, we can do more checks
4762
return 6 unless ($bank & 0x07) == 0;
4763
$reg = i2c_smbus_read_byte_data($file, 0x0b);
4764
return unless ($reg == ($addr << 1));
4766
$reg = i2c_smbus_read_byte_data($file, 0x0c);
4768
push @res, ($reg & 0x07) + 0x48 unless $reg & 0x08;
4769
push @res, (($reg & 0x70) >> 4) + 0x48 unless $reg & 0x80;
4774
# 0xfc: Full I2C Address
4775
# 0x00: Vendor ID byte selection, and bank selection(Bank 0, 1, 2)
4776
# 0xfd: Vendor ID(Bank 0, 1, 2)
4777
# 0xfe: Device ID(Bank 0, 1, 2)
4781
my ($file, $addr) = @_;
4783
$bank = i2c_smbus_read_byte_data($file, 0x00);
4784
$reg = i2c_smbus_read_byte_data($file, 0xfd);
4786
return unless (($bank & 0x80) == 0x00 and $reg == 0xa3) or
4787
(($bank & 0x80) == 0x80 and $reg == 0x5c);
4789
$reg = i2c_smbus_read_byte_data($file, 0xfe);
4790
return if $reg != 0x79;
4792
# If bank 0 is selected, we can do more checks
4793
return 6 unless ($bank & 0x07) == 0;
4794
$reg = i2c_smbus_read_byte_data($file, 0xfc) & 0x7f;
4795
return unless ($reg == $addr);
4801
# 0x48: Full I2C Address
4802
# 0x4e: Vendor ID byte selection
4805
# Note that the datasheet was useless and this detection routine
4806
# is based on dumps we received from users. Also, the W83781SD is *NOT*
4807
# a hardware monitoring chip as far as we know, but we still want to
4808
# detect it so that people won't keep reporting it as an unknown chip
4809
# we should investigate about.
4812
my ($file, $addr) = @_;
4815
return unless (i2c_smbus_read_byte_data($file, 0x48) == $addr);
4817
$reg1 = i2c_smbus_read_byte_data($file, 0x4e);
4818
$reg2 = i2c_smbus_read_byte_data($file, 0x4f);
4819
return unless (!($reg1 & 0x80) && $reg2 == 0xa3)
4820
|| (($reg1 & 0x80) && $reg2 == 0x5c);
4822
$reg1 = i2c_smbus_read_byte_data($file, 0x58);
4823
return unless $reg1 == 0x72;
4829
# 0x4e: Vendor ID high byte
4830
# 0x4f: Vendor ID low byte
4832
# Note: The values were given by Alex van Kaam, we don't have datasheets
4836
my ($file, $addr) = @_;
4839
$vid = (i2c_smbus_read_byte_data($file, 0x4e) << 8)
4840
+ i2c_smbus_read_byte_data($file, 0x4f);
4841
$dev = i2c_smbus_read_byte_data($file, 0x58);
4843
return unless ($dev == 0x56 && $vid == 0x9436) # ASM58
4844
|| ($dev == 0x56 && $vid == 0x9406) # AS2K129R
4845
|| ($dev == 0x10 && $vid == 0x5ca3);
4850
# Chip to detect: 0 = GL518SM, 1 = GL520SM
4854
# 0x03: Configuration
4857
my ($file, $addr, $chip) = @_;
4860
$reg = i2c_smbus_read_byte_data($file, 0x00);
4861
return if $chip == 0 && $reg != 0x80;
4862
return if $chip == 1 && $reg != 0x20;
4864
return unless (i2c_smbus_read_byte_data($file, 0x03) & 0x80) == 0x00;
4865
$reg = i2c_smbus_read_byte_data($file, 0x01);
4866
return unless $reg == 0x00 or $reg == 0x80;
4872
# 0x03: Configuration
4873
# Mediocre detection
4876
my ($file, $addr) = @_;
4877
return unless i2c_smbus_read_byte_data($file, 0x00) == 0x25;
4878
return unless (i2c_smbus_read_byte_data($file, 0x03) & 0x80) == 0x00;
4882
# Chip to detect: 0 = ADM9240, 1 = DS1780, 2 = LM81
4885
# 0x40: Configuration
4886
# 0x48: Full I2C Address
4889
my ($file, $addr, $chip) = @_;
4891
$reg = i2c_smbus_read_byte_data($file, 0x3e);
4892
return unless ($chip == 0 and $reg == 0x23) or
4893
($chip == 1 and $reg == 0xda) or
4894
($chip == 2 and $reg == 0x01);
4895
return unless (i2c_smbus_read_byte_data($file, 0x40) & 0x80) == 0x00;
4896
return unless i2c_smbus_read_byte_data($file, 0x48) == $addr;
4901
# Chip to detect: 0 = ADM1022, 1 = THMC50, 2 = ADM1028, 3 = THMC51
4905
# 0x40: Configuration
4908
my ($file, $addr, $chip) = @_;
4910
$reg = i2c_smbus_read_byte_data($file, 0x3e);
4911
return unless ($chip == 0 and $reg == 0x41) or
4912
($chip == 1 and $reg == 0x49) or
4913
($chip == 2 and $reg == 0x41) or
4914
($chip == 3 and $reg == 0x49);
4915
$reg = i2c_smbus_read_byte_data($file, 0x40);
4916
return if ($reg & 0x10); # Soft Reset always reads 0
4917
return if ($chip != 0 and ($reg & 0x80)); # Reserved on THMC50 and ADM1028
4918
$reg = i2c_smbus_read_byte_data($file, 0x3f) & 0xf0;
4919
return unless ($chip == 0 and $reg == 0xc0) or
4920
($chip == 1 and $reg == 0xc0) or
4921
($chip == 2 and $reg == 0xd0) or
4922
($chip == 3 and $reg == 0xd0);
4926
# Chip to detect: 0 = ADM1025, 1 = NE1619
4930
# 0x40: Configuration
4935
my ($file, $addr, $chip) = @_;
4938
$reg = i2c_smbus_read_byte_data($file, 0x3e);
4939
return if ($chip == 0) and ($reg != 0x41);
4940
return if ($chip == 1) and ($reg != 0xA1);
4942
return unless (i2c_smbus_read_byte_data($file, 0x40) & 0x80) == 0x00;
4943
return unless (i2c_smbus_read_byte_data($file, 0x41) & 0xC0) == 0x00;
4944
return unless (i2c_smbus_read_byte_data($file, 0x42) & 0xBC) == 0x00;
4945
return unless (i2c_smbus_read_byte_data($file, 0x3f) & 0xf0) == 0x20;
4955
my ($file, $addr) = @_;
4957
$reg = i2c_smbus_read_byte_data($file, 0x16);
4958
return unless ($reg == 0x41);
4959
return unless (i2c_smbus_read_byte_data($file, 0x17) & 0xf0) == 0x40;
4963
# Chip to detect: 0 = ADM1021, 1 = ADM1021A/ADM1023, 2 = MAX1617, 3 = MAX1617A,
4964
# 4 = THMC10, 5 = LM84, 6 = GL523, 7 = MC1066
4966
# 0x04: Company ID (LM84 only)
4967
# 0xfe: Company ID (all but LM84 and MAX1617)
4968
# 0xff: Revision (ADM1021, ADM1021A/ADM1023 and MAX1617A)
4970
# 0x03: Configuration
4971
# 0x04: Conversion rate
4972
# 0x00-0x01, 0x05-0x08: Temperatures (MAX1617 and LM84)
4973
# Note: Especially the MAX1617 has very bad detection; we give it a low
4977
my ($file, $addr, $chip) = @_;
4978
my $man_id = i2c_smbus_read_byte_data($file, 0xfe);
4979
my $rev = i2c_smbus_read_byte_data($file, 0xff);
4980
my $conf = i2c_smbus_read_byte_data($file, 0x03);
4981
my $status = i2c_smbus_read_byte_data($file, 0x02);
4982
my $convrate = i2c_smbus_read_byte_data($file, 0x04);
4984
# Check manufacturer IDs and product revisions when available
4985
return if $chip == 0 and $man_id != 0x41 || ($rev & 0xf0) != 0x00;
4986
return if $chip == 1 and $man_id != 0x41 || ($rev & 0xf0) != 0x30;
4987
return if $chip == 3 and $man_id != 0x4d || $rev != 0x01;
4988
return if $chip == 4 and $man_id != 0x49;
4989
return if $chip == 5 and $convrate != 0x00;
4990
return if $chip == 6 and $man_id != 0x23;
4991
return if $chip == 7 and $man_id != 0x54;
4994
if ($chip == 5) { # LM84
4995
return if ($status & 0xab) != 0;
4996
return if ($conf & 0x7f) != 0;
4998
return if ($status & 0x03) != 0;
4999
return if ($conf & 0x3f) != 0;
5000
return if ($convrate & 0xf8) != 0;
5003
# Extra checks for MAX1617 and LM84, since those are often misdetected.
5004
# We verify several assertions (6 for the MAX1617, 4 for the LM84) and
5005
# discard the chip if any fail. Note that these checks are not done
5006
# by the adm1021 driver.
5007
if ($chip == 2 || $chip == 5) {
5008
my $lte = i2c_smbus_read_byte_data($file, 0x00);
5009
my $rte = i2c_smbus_read_byte_data($file, 0x01);
5010
my $lhi = i2c_smbus_read_byte_data($file, 0x05);
5011
my $rhi = i2c_smbus_read_byte_data($file, 0x07);
5012
my $llo = i2c_smbus_read_byte_data($file, 0x06);
5013
my $rlo = i2c_smbus_read_byte_data($file, 0x08);
5015
# If all registers hold the same value, it has to be a misdetection
5016
return if $lte == $rte and $lte == $lhi and $lte == $rhi
5017
and $lte == $llo and $lte == $rlo;
5019
# Negative temperatures
5020
return if ($lte & 0x80) or ($rte & 0x80);
5021
# Negative high limits
5022
return if ($lhi & 0x80) or ($rhi & 0x80);
5023
# Low limits over high limits
5025
$llo -= 256 if ($llo & 0x80);
5026
$rlo -= 256 if ($rlo & 0x80);
5027
return if ($llo > $lhi) or ($rlo > $rhi);
5032
return ($chip <= 3) ? 7 : 5;
5035
# Chip to detect: 0 = MAX1668, 1 = MAX1805, 2 = MAX1989
5041
my ($file, $addr, $chip) = @_;
5042
my $man_id = i2c_smbus_read_byte_data($file, 0xfe);
5043
my $dev_id = i2c_smbus_read_byte_data($file, 0xff);
5045
return if $man_id != 0x4d;
5046
return if $chip == 0 and $dev_id != 0x03;
5047
return if $chip == 1 and $dev_id != 0x05;
5048
return if $chip == 2 and $dev_id != 0x0b;
5053
# Chip to detect: 0 = MAX1619, 1 = MAX1618
5058
# 0x03: Configuration
5059
# 0x04: Conversion rate
5062
my ($file, $addr, $chip) = @_;
5063
my $man_id = i2c_smbus_read_byte_data($file, 0xfe);
5064
my $dev_id = i2c_smbus_read_byte_data($file, 0xff);
5065
my $conf = i2c_smbus_read_byte_data($file, 0x03);
5066
my $status = i2c_smbus_read_byte_data($file, 0x02);
5067
my $convrate = i2c_smbus_read_byte_data($file, 0x04);
5069
return if $man_id != 0x4D; # Maxim
5071
if ($chip == 0) { # MAX1619
5072
return if $dev_id != 0x04
5077
if ($chip == 1) { # MAX1618
5078
return if $dev_id != 0x02
5080
or ($status & 0x63);
5089
sub ite_overclock_detect
5091
my ($file, $addr) = @_;
5093
my $uid1 = i2c_smbus_read_byte_data($file, 0x28);
5094
my $uid2 = i2c_smbus_read_byte_data($file, 0x29);
5095
return if $uid1 != 0x83 || $uid2 != 0x12;
5101
# 0x00: Configuration
5102
# 0x48: Full I2C Address
5105
sub it8712_i2c_detect
5107
my ($file, $addr) = @_;
5109
return unless i2c_smbus_read_byte_data($file, 0x48) == $addr;
5110
return unless (i2c_smbus_read_byte_data($file, 0x00) & 0x90) == 0x10;
5111
return unless i2c_smbus_read_byte_data($file, 0x58) == 0x90;
5112
return if i2c_smbus_read_byte_data($file, 0x5b) != 0x12;
5113
return 7 + ($addr == 0x2d);
5117
# 0-63: SPD Data and Checksum
5120
my ($file, $addr) = @_;
5123
# Check the checksum for validity (works for most DIMMs and RIMMs)
5124
for (my $i = 0; $i <= 62; $i++) {
5125
$checksum += i2c_smbus_read_byte_data($file, $i);
5129
return 8 if $checksum == i2c_smbus_read_byte_data($file, 63);
5134
# 0x00..0x07: DDC signature
5135
sub ddcmonitor_detect
5137
my ($file, $addr) = @_;
5140
i2c_smbus_read_byte_data($file, 0x00) == 0x00 and
5141
i2c_smbus_read_byte_data($file, 0x01) == 0xFF and
5142
i2c_smbus_read_byte_data($file, 0x02) == 0xFF and
5143
i2c_smbus_read_byte_data($file, 0x03) == 0xFF and
5144
i2c_smbus_read_byte_data($file, 0x04) == 0xFF and
5145
i2c_smbus_read_byte_data($file, 0x05) == 0xFF and
5146
i2c_smbus_read_byte_data($file, 0x06) == 0xFF and
5147
i2c_smbus_read_byte_data($file, 0x07) == 0x00;
5152
# Chip to detect: 0 = Poseidon I, 1 = Poseidon II, 2 = Scylla,
5153
# 3 = Hermes, 4 = Heimdal, 5 = Heracles
5155
# 0x00-0x02: Identification (3 capital ASCII letters)
5158
my ($file, $addr, $chip) = @_;
5161
$id = chr(i2c_smbus_read_byte_data($file, 0x00))
5162
. chr(i2c_smbus_read_byte_data($file, 0x01))
5163
. chr(i2c_smbus_read_byte_data($file, 0x02));
5165
return if $chip == 0 and $id ne 'PEG'; # Pegasus? aka Poseidon I
5166
return if $chip == 1 and $id ne 'POS'; # Poseidon II
5167
return if $chip == 2 and $id ne 'SCY'; # Scylla
5168
return if $chip == 3 and $id ne 'HER'; # Hermes
5169
return if $chip == 4 and $id ne 'HMD'; # Heimdal
5170
return if $chip == 5 and $id ne 'HRC'; # Heracles
5171
return if $chip == 6 and $id ne 'HDS'; # Hades
5172
return if $chip == 7 and $id ne 'SYL'; # Syleus
5178
# 0x3E: Manufacturer ID
5179
# 0x3F: Version/Stepping
5182
my ($file, $addr) = @_;
5183
return unless i2c_smbus_read_byte_data($file, 0x3E) == 0x01
5184
and i2c_smbus_read_byte_data($file, 0x3F) == 0x73;
5191
# 0x4A, 0x4B, 0x4F, 0x57, 0x58: Reserved bits.
5192
# We do not use 0x49's reserved bits on purpose. The register is named
5193
# "VID4/Device ID" so it is doubtful bits 7-1 are really unused.
5196
my ($file, $addr) = @_;
5198
return unless i2c_smbus_read_byte_data($file, 0x3F) == 0x01;
5199
return unless i2c_smbus_read_byte_data($file, 0x48) == $addr;
5201
return unless (i2c_smbus_read_byte_data($file, 0x4A) & 0x06) == 0
5202
and (i2c_smbus_read_byte_data($file, 0x4B) & 0xFC) == 0
5203
and (i2c_smbus_read_byte_data($file, 0x4F) & 0xFC) == 0
5204
and (i2c_smbus_read_byte_data($file, 0x57) & 0xFE) == 0
5205
and (i2c_smbus_read_byte_data($file, 0x58) & 0xEF) == 0;
5211
# 0x3E: Manufacturer ID
5212
# 0x3F: Version/Stepping
5213
# 0x47: VID (3 reserved bits)
5214
# 0x49: VID4 (7 reserved bits)
5215
sub smsc47m192_detect
5217
my ($file, $addr) = @_;
5218
return unless i2c_smbus_read_byte_data($file, 0x3E) == 0x55
5219
and (i2c_smbus_read_byte_data($file, 0x3F) & 0xF0) == 0x20
5220
and (i2c_smbus_read_byte_data($file, 0x47) & 0x70) == 0x00
5221
and (i2c_smbus_read_byte_data($file, 0x49) & 0xFE) == 0x80;
5222
return ($addr == 0x2d ? 6 : 5);
5225
# Chip to detect: 1 = DME1737, 2 = SCH5027
5227
# 0x3E: Manufacturer ID
5228
# 0x3F: Version/Stepping
5229
# 0x73: Read-only test register (4 test bits)
5230
# 0x8A: Read-only test register (7 test bits)
5231
# 0xBA: Read-only test register (8 test bits)
5234
my ($file, $addr, $chip) = @_;
5235
my $vendor = i2c_smbus_read_byte_data($file, 0x3E);
5236
my $verstep = i2c_smbus_read_byte_data($file, 0x3F);
5238
return unless $vendor == 0x5C; # SMSC
5240
if ($chip == 1) { # DME1737
5241
return unless ($verstep & 0xF8) == 0x88 and
5242
(i2c_smbus_read_byte_data($file, 0x73) & 0x0F) == 0x09 and
5243
(i2c_smbus_read_byte_data($file, 0x8A) & 0x7F) == 0x4D;
5244
} elsif ($chip == 2) { # SCH5027
5245
return unless $verstep >= 0x69 and $verstep <= 0x6F and
5246
i2c_smbus_read_byte_data($file, 0xBA) == 0x0F;
5249
return ($addr == 0x2e ? 6 : 5);
5252
# Chip to detect: 1 = F75111R/RG/N, 2 = F75121R/F75122R/RG, 3 = F75373S/SG,
5253
# 4 = F75375S/SP, 5 = F75387SG/RG, 6 = F75383M/S/F75384M/S,
5254
# 7 = custom power control IC
5256
# 0x5A-0x5B: Chip ID
5257
# 0x5D-0x5E: Vendor ID
5260
my ($file, $addr, $chip) = @_;
5261
my $chipid = (i2c_smbus_read_byte_data($file, 0x5A) << 8)
5262
| i2c_smbus_read_byte_data($file, 0x5B);
5263
my $vendid = (i2c_smbus_read_byte_data($file, 0x5D) << 8)
5264
| i2c_smbus_read_byte_data($file, 0x5E);
5266
return unless $vendid == 0x1934; # Fintek ID
5268
if ($chip == 1) { # F75111R/RG/N
5269
return unless $chipid == 0x0300;
5270
} elsif ($chip == 2) { # F75121R/F75122R/RG
5271
return unless $chipid == 0x0301;
5272
} elsif ($chip == 3) { # F75373S/SG
5273
return unless $chipid == 0x0204;
5274
} elsif ($chip == 4) { # F75375S/SP
5275
return unless $chipid == 0x0306;
5276
} elsif ($chip == 5) { # F75387SG/RG
5277
return unless $chipid == 0x0410;
5278
} elsif ($chip == 6) { # F75383M/S/F75384M/S
5279
# The datasheet has 0x0303, but Fintek say 0x0413 is also
5281
return unless $chipid == 0x0303 || $chipid == 0x0413;
5282
} elsif ($chip == 7) { # custom power control IC
5283
return unless $chipid == 0x0302;
5289
# Chip to detect: 0 = EMC1403, 1 = EMC1404, 2 = EMC2103
5291
# 0xfd: Device ID register
5292
# 0xfe: Vendor ID register
5293
# 0xff: Revision register
5296
my ($file, $addr, $chip) = @_;
5297
my $dev_id = i2c_smbus_read_byte_data($file, 0xfd);
5298
my $man_id = i2c_smbus_read_byte_data($file, 0xfe);
5299
my $rev = i2c_smbus_read_byte_data($file, 0xff);
5301
return unless $man_id == 0x5d; # SMSC
5304
return unless $dev_id == 0x21;
5305
return unless $rev == 0x01;
5306
} elsif ($chip == 1) {
5307
return unless $dev_id == 0x25;
5308
return unless $rev == 0x01;
5309
} elsif ($chip == 2) {
5310
return unless ($dev_id == 0x24) || ($dev_id == 0x26);
5311
return unless $rev == 0x01;
5317
# This checks for non-FFFF values for temperature, voltage, and current.
5318
# The address (0x0b) is specified by the SMBus standard so it's likely
5319
# that this really is a smart battery.
5320
sub smartbatt_detect
5322
my ($file, $addr) = @_;
5324
return if i2c_smbus_read_word_data($file, 0x08) == 0xffff
5325
|| i2c_smbus_read_word_data($file, 0x09) == 0xffff
5326
|| i2c_smbus_read_word_data($file, 0x0a) == 0xffff;
5330
# Chip to detect: 0 = W83L784R/AR/G, 1 = W83L785R/G, 2 = W83L786NR/NG/R/G,
5333
# 0x40: Configuration
5334
# 0x4a: Full I2C Address (W83L784R only)
5335
# 0x4b: I2C addresses of emulated LM75 chips (W83L784R only)
5336
# 0x4c: Winbond Vendor ID (Low Byte)
5337
# 0x4d: Winbond Vendor ID (High Byte)
5341
my ($file, $addr, $chip) = @_;
5344
return unless (i2c_smbus_read_byte_data($file, 0x40) & 0x80) == 0x00;
5345
return if $chip == 0
5346
and i2c_smbus_read_byte_data($file, 0x4a) != $addr;
5347
return unless i2c_smbus_read_byte_data($file, 0x4c) == 0xa3;
5348
return unless i2c_smbus_read_byte_data($file, 0x4d) == 0x5c;
5350
$reg = i2c_smbus_read_byte_data($file, 0x4e);
5351
return if $chip == 0 and $reg != 0x50;
5352
return if $chip == 1 and $reg != 0x60;
5353
return if $chip == 2 and $reg != 0x80;
5354
return if $chip == 3 and $reg != 0x70;
5356
return 8 if $chip != 0; # No subclients
5359
$reg = i2c_smbus_read_byte_data($file, 0x4b);
5360
push @res, ($reg & 0x07) + 0x48 unless $reg & 0x08;
5361
push @res, (($reg & 0x70) >> 4) + 0x48 unless $reg & 0x80;
5365
# The max6650 has no device ID register. However, a few registers have
5366
# spare bits, which are documented as being always zero on read. We read
5367
# all of these registers check the spare bits. Any non-zero means this
5368
# is not a max6650/1.
5370
# The always zero bits are:
5371
# configuration byte register (0x02) - top 2 bits
5372
# gpio status register (0x14) - top 3 bits
5373
# alarm enable register (0x08) - top 3 bits
5374
# alarm status register (0x0A) - top 3 bits
5375
# tachometer count time register (0x16) - top 6 bits
5376
# Additionally, not all values are possible for lower 3 bits of
5377
# the configuration register.
5380
my ($file, $addr) = @_;
5382
my $conf = i2c_smbus_read_byte_data($file, 0x02);
5384
return if i2c_smbus_read_byte_data($file, 0x16) & 0xFC;
5385
return if i2c_smbus_read_byte_data($file, 0x0A) & 0xE0;
5386
return if i2c_smbus_read_byte_data($file, 0x08) & 0xE0;
5387
return if i2c_smbus_read_byte_data($file, 0x14) & 0xE0;
5388
return if ($conf & 0xC0) or ($conf & 0x07) > 4;
5395
my ($file, $addr) = @_;
5397
# checking RDID (Device ID)
5398
return unless i2c_smbus_read_byte_data($file, 0xfe) == 0x0a;
5399
# checking RDRV (Manufacturer ID)
5400
return unless i2c_smbus_read_byte_data($file, 0xff) == 0x4d;
5401
# checking unused bits (conversion rate, extended temperature)
5402
return unless i2c_smbus_read_byte_data($file, 0x04) & 0xf8;
5403
return unless i2c_smbus_read_byte_data($file, 0x10) & 0x1f;
5404
return unless i2c_smbus_read_byte_data($file, 0x11) & 0x1f;
5405
return unless i2c_smbus_read_byte_data($file, 0x12) & 0x1f;
5410
# Chip to detect: 0 = STTS424, 1 = SE97/SE97B, 2 = SE98, 3 = ADT7408,
5411
# 4 = TS3000/TSE2002, 5 = MAX6604, 6 = MCP98242,
5412
# 7 = MCP98243, 8 = MCP9843, 9 = CAT6095 / CAT34TS02,
5415
# 0x00: Capabilities
5416
# 0x01: Configuration
5417
# 0x06: Manufacturer ID
5419
sub jedec_JC42_4_detect
5421
my ($file, $addr, $chip) = @_;
5422
my ($reg, $manid, $devid);
5424
# We test the MSB only at first, because not all chips enjoy
5427
# Check for unused bits
5428
$reg = i2c_smbus_read_byte_data($file, 0x00);
5429
return if $reg & 0xff;
5430
$reg = i2c_smbus_read_byte_data($file, 0x01);
5431
return if $reg & 0xf8;
5433
# Check for manufacturer and device ID
5434
$manid = i2c_smbus_read_byte_data($file, 0x06);
5435
$devid = i2c_smbus_read_byte_data($file, 0x07);
5438
return unless $manid == 0x10; # STMicrolectronics
5439
return unless $devid == 0x01; # STTS424
5440
} elsif ($chip == 1) {
5441
return unless $manid == 0x11; # NXP
5442
return unless $devid == 0xa2; # SE97
5443
} elsif ($chip == 2) {
5444
return unless $manid == 0x11; # NXP
5445
return unless $devid == 0xa1; # SE98
5446
} elsif ($chip == 3) {
5447
return unless $manid == 0x11; # ADT
5448
return unless $devid == 0x08; # ADT7408
5449
} elsif ($chip == 4) {
5450
return unless $manid == 0x00; # IDT
5451
return unless $devid == 0x29; # TS3000/TSE2002
5452
} elsif ($chip == 5) {
5453
return unless $manid == 0x00; # MAXIM
5454
return unless $devid == 0x3e; # MAX6604
5455
} elsif ($chip == 6) {
5456
return unless $manid == 0x00; # MCP
5457
return unless $devid == 0x20; # MCP98242
5458
} elsif ($chip == 7) {
5459
return unless $manid == 0x00; # MCP
5460
return unless $devid == 0x21; # MCP98243
5461
} elsif ($chip == 8) {
5462
return unless $manid == 0x00; # MCP
5463
return unless $devid == 0x00; # MCP9843
5464
} elsif ($chip == 9) {
5465
return unless $manid == 0x1b; # ONS
5466
return unless $devid == 0x08; # CAT6095 / CAT34TS02
5467
} elsif ($chip == 10) {
5468
return unless $manid == 0x10; # STMicrolectronics
5469
return unless $devid == 0x00; # STTS424E02
5472
# Now, do it all again with words. Note that we get
5473
# the MSB first, so all value checks are byte-swapped.
5475
# Check for unused bits
5476
$reg = i2c_smbus_read_word_data($file, 0x00);
5477
return if $reg < 0 || $reg & 0x00ff;
5479
$manid = i2c_smbus_read_word_data($file, 0x06);
5480
$devid = i2c_smbus_read_word_data($file, 0x07);
5481
return if $manid < 0 || $devid < 0;
5483
return unless $manid == 0x4a10; # STMicrolectronics
5484
return unless ($devid & 0xfeff) == 0x0001; # STTS424
5485
} elsif ($chip == 1) {
5486
return unless $manid == 0x3111; # NXP
5487
return unless ($devid & 0xfcff) == 0x00a2; # SE97
5488
} elsif ($chip == 2) {
5489
return unless $manid == 0x3111; # NXP
5490
return unless ($devid & 0xfcff) == 0x00a1; # SE98
5491
} elsif ($chip == 3) {
5492
return unless $manid == 0xd411; # ADT
5493
return unless $devid == 0x0108; # ADT7408
5494
} elsif ($chip == 4) {
5495
return unless $manid == 0xb300; # IDT
5496
return unless $devid == 0x0329; # TS3000/TSE2002
5497
} elsif ($chip == 5) {
5498
return unless $manid == 0x4d00; # MAXIM
5499
return unless $devid == 0x003e; # MAX6604
5500
} elsif ($chip == 6) {
5501
return unless $manid == 0x5400; # MCP
5502
return unless ($devid & 0xfcff) == 0x0020; # MCP98242
5503
} elsif ($chip == 7) {
5504
return unless $manid == 0x5400; # MCP
5505
return unless ($devid & 0xfcff) == 0x0021; # MCP98243
5506
} elsif ($chip == 8) {
5507
return unless $manid == 0x5400; # MCP
5508
return unless ($devid & 0xfcff) == 0x0000; # MCP9843
5509
} elsif ($chip == 9) {
5510
return unless $manid == 0x091b; # ONS
5511
return unless ($devid & 0xe0ff) == 0x0008; # CAT6095 / CAT34TS02
5512
} elsif ($chip == 10) {
5513
return unless $manid == 0x4a10; # STMicrolectronics
5514
return unless ($devid & 0xfeff) == 0x0000; # STTS424E02
5520
# This isn't very good detection.
5521
# Verify the i2c address, and the stepping ID (which is 0xb0 on
5522
# my chip but could be different for others...
5523
sub vt1211_i2c_detect
5525
my ($file, $addr) = @_;
5526
return unless (i2c_smbus_read_byte_data($file, 0x48) & 0x7f) == $addr;
5527
return unless i2c_smbus_read_byte_data($file, 0x3f) == 0xb0;
5531
# All ISA detection functions below take at least 1 parameter:
5533
# Some of these functions which can detect more than one type of device,
5534
# take a second parameter:
5535
# $_[1]: Chip to detect
5537
# Chip to detect: 0 = LM78, 2 = LM79
5540
my ($addr, $chip) = @_;
5541
my $val = inb($addr + 1);
5542
return if inb($addr + 2) != $val or inb($addr + 3) != $val or
5543
inb($addr + 7) != $val;
5545
$val = inb($addr + 5);
5546
outb($addr + 5, ~$val & 0x7f);
5547
if ((inb($addr+5) & 0x7f) != (~ $val & 0x7f)) {
5548
outb($addr+5, $val);
5552
return unless (isa_read_i5d6($addr, 0x40) & 0x80) == 0x00;
5553
my $reg = isa_read_i5d6($addr, 0x49);
5554
return if $chip == 0 && ($reg != 0x00 && $reg != 0x20 && $reg != 0x40);
5555
return if $chip == 2 && ($reg & 0xfe) != 0xc0;
5557
# Explicitly prevent misdetection of Winbond chips
5558
$reg = isa_read_i5d6($addr, 0x4f);
5559
return if $reg == 0xa3 || $reg == 0x5c;
5561
# Explicitly prevent misdetection of ITE chips
5562
$reg = isa_read_i5d6($addr, 0x58);
5563
return if $reg == 0x90;
5568
# Chip to detect: 0 = W83781D, 1 = W83782D
5569
sub w83781d_isa_detect
5571
my ($addr, $chip) = @_;
5573
my $val = inb($addr + 1);
5574
return if inb($addr + 2) != $val or inb($addr + 3) != $val or
5575
inb($addr + 7) != $val;
5577
$val = inb($addr + 5);
5578
outb($addr+5, ~$val & 0x7f);
5579
if ((inb($addr+5) & 0x7f) != (~ $val & 0x7f)) {
5580
outb($addr+5, $val);
5584
$reg1 = isa_read_i5d6($addr, 0x4e);
5585
$reg2 = isa_read_i5d6($addr, 0x4f);
5586
return unless (($reg1 & 0x80) == 0x00 and $reg2 == 0xa3) or
5587
(($reg1 & 0x80) == 0x80 and $reg2 == 0x5c);
5588
return unless ($reg1 & 0x07) == 0x00;
5589
$reg1 = isa_read_i5d6($addr, 0x58);
5590
return if $chip == 0 && ($reg1 & 0xfe) != 0x10;
5591
return if $chip == 1 && ($reg1 & 0xfe) != 0x30;
5600
# Returns: number of IPMI interfaces found
5601
sub ipmi_from_smbios
5603
my ($version, $if, @ipmi_if);
5605
return 0 unless check_dmidecode_version();
5607
# Parse the output of dmidecode into an array of IPMI interfaces.
5608
# Each entry is a hash with the following keys: type and addr.
5610
open(local *DMIDECODE, "dmidecode -t 38 2>/dev/null |") or return 0;
5611
while (<DMIDECODE>) {
5612
if (m/^IPMI Device Information/) {
5616
next unless $if >= 0;
5618
if (m/^\tInterface Type: (.*)$/) {
5619
$ipmi_if[$if]->{type} = "IPMI BMC $1";
5620
$ipmi_if[$if]->{type} =~ s/ \(.*//;
5623
if (m/^\tBase Address: (0x[0-9A-Fa-f]+) \(I\/O\)$/) {
5624
$ipmi_if[$if]->{addr} = oct($1);
5630
foreach $if (@ipmi_if) {
5631
if (exists $if->{addr}) {
5632
printf("\%-60s", sprintf("Found `\%s' at 0x\%x... ",
5633
$if->{type}, $if->{addr}));
5635
printf("\%-60s", sprintf("Found `\%s'... ",
5639
" (confidence 8, driver `ipmisensors')\n";
5642
isa_addr => $if->{addr} || 0,
5643
chipname => $if->{type},
5645
add_isa_to_chips_detected("ipmisensors", $new_hash);
5648
return scalar @ipmi_if;
5651
# We simply look for a register at standard locations.
5652
# For KCS, use the STATUS register. For SMIC, use the FLAGS register.
5653
# Incidentally they live at the same offset.
5657
return if inb($addr + 3) == 0xff;
5665
# These functions take at least 3 parameters:
5666
# $_[0]: ISA/LPC address
5667
# $_[1]: I2C file handle
5668
# $_[2]: I2C address
5669
# Some of these functions may take extra parameters.
5670
# They return 1 if both devices are the same, 0 if not.
5673
# $_[3]: First limit register to compare
5674
# $_[4]: Last limit register to compare
5675
sub winbond_alias_detect
5677
my ($isa_addr, $file, $i2c_addr, $first, $last) = @_;
5680
return 0 unless isa_read_i5d6($isa_addr, 0x48) == $i2c_addr;
5681
for ($i = $first; $i <= $last; $i++) {
5682
return 0 unless isa_read_i5d6($isa_addr, $i) ==
5683
i2c_smbus_read_byte_data($file, $i);
5688
############################
5689
# PCI CHIP / CPU DETECTION #
5690
############################
5692
sub sis5595_pci_detect
5694
return unless exists $pci_list{'1039:0008'};
5698
sub via686a_pci_detect
5700
return unless exists $pci_list{'1106:3057'};
5704
sub via8231_pci_detect
5706
return unless exists $pci_list{'1106:8235'};
5710
sub k8temp_pci_detect
5712
return unless exists $pci_list{'1022:1103'};
5716
sub fam10h_pci_detect
5718
return unless exists $pci_list{'1022:1203'};
5720
# Errata 319 (Inaccurate Temperature Measurement) affects
5721
# revisions DR-BA, DR-B2 and DR-B3, all have model number = 2.
5722
# Revisions RB-C2 and HY-D0 are also affected.
5724
foreach $probecpu (@cpu) {
5725
next unless $probecpu->{vendor_id} eq 'AuthenticAMD' &&
5726
$probecpu->{'cpu family'} == 0x10;
5728
next if $probecpu->{model} < 4; # DR-B*
5729
next if $probecpu->{model} == 8; # HY-D0
5730
if ($probecpu->{model} == 4 && $probecpu->{stepping} <= 2) { # RB-C2
5731
my @dram_cfg = split /\n/, `setpci -d 1022:1202 94.L 2>/dev/null`;
5732
next unless @dram_cfg >= 1;
5733
next unless hex($dram_cfg[0]) & 0x00000100; # DDR3
5742
sub fam11h_pci_detect
5744
return unless exists $pci_list{'1022:1303'};
5748
sub intel_amb_detect
5750
if ((exists $pci_list{'8086:25f0'}) || # Intel 5000
5751
(exists $pci_list{'8086:4030'})) { # Intel 5400
5762
foreach $probecpu (@cpu) {
5763
next unless $probecpu->{vendor_id} eq 'GenuineIntel' &&
5764
$probecpu->{'cpu family'} == 6;
5765
return 9 if $chip == 0 &&
5766
($probecpu->{model} == 14 || # Pentium M DC
5767
$probecpu->{model} == 15 || # Core 2 DC 65nm
5768
$probecpu->{model} == 0x16 || # Core 2 SC 65nm
5769
$probecpu->{model} == 0x17 || # Penryn 45nm
5770
$probecpu->{model} == 0x1a || # Nehalem
5771
$probecpu->{model} == 0x1e); # Lynnfield
5772
return 9 if $chip == 1 &&
5773
($probecpu->{model} == 0x1c); # Atom
5781
foreach $probecpu (@cpu) {
5782
if ($probecpu->{vendor_id} eq 'CentaurHauls' &&
5783
$probecpu->{'cpu family'} == 6 &&
5784
($probecpu->{model} == 0xa ||
5785
$probecpu->{model} == 0xd)) {
5795
foreach $probecpu (@cpu) {
5796
if ($probecpu->{vendor_id} eq 'CentaurHauls' &&
5797
$probecpu->{'cpu family'} == 6 &&
5798
$probecpu->{model} == 0xf) {
5811
my ($chip, $addr, %histo, $chips);
5814
foreach $chip (@chip_ids) {
5815
next unless defined $chip->{i2c_addrs};
5817
foreach my $addr (@{$chip->{i2c_addrs}}) {
5823
printf "\%d I2C chips known, \%d I2C addresses probed\n\n",
5824
$chips, scalar keys %histo;
5825
print " 0 1 2 3 4 5 6 7 8 9 a b c d e f\n".
5827
for (my $addr = 0x03; $addr <= 0x77; $addr++) {
5828
printf("\n\%02x:", $addr) if ($addr % 16) == 0;
5829
if (defined $histo{$addr}) {
5830
printf ' %02d', $histo{$addr};
5842
# $_[0]: reference to a list of chip hashes
5843
sub print_chips_report
5848
foreach $data (@$listref) {
5849
my $is_i2c = exists $data->{i2c_addr};
5850
my $is_isa = exists $data->{isa_addr};
5853
printf "Bus `%s'\n", $i2c_adapters[$data->{i2c_devnr}]->{name};
5854
printf " Busdriver `%s', I2C address 0x%02x",
5855
$i2c_adapters[$data->{i2c_devnr}]->{driver}, $data->{i2c_addr};
5856
if (exists $data->{i2c_sub_addrs}) {
5859
foreach $sub_addr (@{$data->{i2c_sub_addrs}}) {
5860
printf " 0x%02x", $sub_addr;
5868
if ($data->{isa_addr}) {
5869
printf ", address 0x%x", $data->{isa_addr};
5871
print " (Busdriver `i2c-isa')"
5872
unless kernel_version_at_least(2, 6, 18);
5875
printf "Chip `%s' (confidence: %d)\n",
5876
$data->{chipname}, $data->{conf};
5880
sub generate_modprobes
5882
my ($driver, $detection, $adap);
5883
my ($configfile, %bus_modules, %hwmon_modules);
5885
foreach $driver (keys %chips_detected) {
5886
foreach $detection (@{$chips_detected{$driver}}) {
5887
# Tag adapters which host hardware monitoring chips we want to access
5888
if (exists $detection->{i2c_devnr}
5889
&& !exists $detection->{isa_addr}) {
5890
$i2c_adapters[$detection->{i2c_devnr}]->{used}++;
5893
# i2c-isa is loaded automatically (as a dependency)
5894
# since 2.6.14, and will soon be gone.
5895
if (exists $detection->{isa_addr}
5896
&& !kernel_version_at_least(2, 6, 18)) {
5897
$bus_modules{"i2c-isa"}++
5900
if ($driver eq "ipmisensors") {
5901
$bus_modules{"ipmi-si"}++;
5906
# As of kernel 2.6.28, alias detection is handled by kernel drivers
5907
# directly, so module options are no longer needed.
5908
unless (kernel_version_at_least(2, 6, 28)) {
5909
foreach $driver (keys %chips_detected) {
5910
my @optionlist = ();
5911
foreach $detection (@{$chips_detected{$driver}}) {
5912
next unless exists $detection->{i2c_addr}
5913
&& exists $detection->{isa_addr}
5914
&& $i2c_adapters[$detection->{i2c_devnr}]->{used};
5916
push @optionlist, sprintf("%d,0x%02x",
5917
$detection->{i2c_devnr},
5918
$detection->{i2c_addr});
5921
next if not @optionlist;
5922
$configfile = "# hwmon module options\n"
5923
unless defined $configfile;
5924
$configfile .= "options $driver ignore=".
5925
(join ",", @optionlist)."\n";
5929
# If we added any module option to handle aliases, we need to load all
5930
# the adapter drivers so that the numbers will be the same. If not, then
5931
# we only load the adapter drivers which are useful.
5932
foreach $adap (@i2c_adapters) {
5933
next if $adap->{autoload};
5934
next if $adap->{driver} eq 'UNKNOWN';
5935
next if not defined $configfile and not $adap->{used};
5936
$bus_modules{$adap->{driver}}++;
5939
# Now determine the chip probe lines
5940
foreach $driver (keys %chips_detected) {
5941
next if not @{$chips_detected{$driver}};
5942
if ($driver eq "to-be-written") {
5943
print "Note: there is no driver for ${$chips_detected{$driver}}[0]{chipname} yet.\n".
5944
"Check http://www.lm-sensors.org/wiki/Devices for updates.\n\n";
5946
open(local *INPUTFILE, "modprobe -l $driver 2>/dev/null |");
5948
my $modulefound = 0;
5949
while (<INPUTFILE>) {
5956
# Check return value from modprobe in case modprobe -l
5958
if ((($? >> 8) == 0) && ! $modulefound) {
5959
print "Warning: the required module $driver is not currently installed\n".
5960
"on your system. If it is built into the kernel then it's OK.\n".
5961
"Otherwise, check http://www.lm-sensors.org/wiki/Devices for\n".
5962
"driver availability.\n\n";
5964
$hwmon_modules{$driver}++
5965
unless hwmon_is_autoloaded($driver);
5970
my @bus_modules = sort keys %bus_modules;
5971
my @hwmon_modules = sort keys %hwmon_modules;
5972
return ($configfile, \@bus_modules, \@hwmon_modules);
5977
my ($configfile, $bus_modules, $hwmon_modules) = @_;
5979
if (defined $configfile) {
5980
my $have_modprobe_d = -d '/etc/modprobe.d';
5981
printf "Do you want to \%s /etc/modprobe.d/lm_sensors.conf? (\%s): ",
5982
(-e '/etc/modprobe.d/lm_sensors.conf' ? 'overwrite' : 'generate'),
5983
($have_modprobe_d ? 'YES/no' : 'yes/NO');
5985
if (($have_modprobe_d and not m/^\s*n/i) or m/^\s*y/i) {
5986
unless ($have_modprobe_d) {
5987
mkdir('/etc/modprobe.d', 0777)
5988
or die "Sorry, can't create /etc/modprobe.d ($!)";
5990
open(local *MODPROBE_D, ">/etc/modprobe.d/lm_sensors.conf")
5991
or die "Sorry, can't create /etc/modprobe.d/lm_sensors.conf ($!)";
5992
print MODPROBE_D "# Generated by sensors-detect on " . scalar localtime() . "\n";
5993
print MODPROBE_D $configfile;
5996
print "To make the sensors modules behave correctly, add these lines to\n".
5997
"/etc/modprobe.conf:\n\n";
5998
print "#----cut here----\n".
6000
"#----cut here----\n\n";
6004
print "To load everything that is needed, add this to /etc/modules:\n";
6005
print "#----cut here----\n";
6006
if (@{$bus_modules}) {
6007
print "# Adapter drivers\n";
6008
print "$_\n" foreach (@{$bus_modules});
6010
print "# Chip drivers\n";
6011
print "$_\n" foreach (@{$hwmon_modules});
6012
print "#----cut here----\n";
6014
print "If you have some drivers built into your kernel, the list above will\n".
6015
"contain too many modules. Skip the appropriate ones!\n";
6017
print "\nDo you want to add these lines automatically to /etc/modules? (yes/NO)";
6020
open(MODULES, ">>/etc/modules")
6021
or die "Sorry, can't create /etc/modules ($!)?!?";
6022
print MODULES "\n# Generated by sensors-detect on " . scalar localtime() . "\n";
6023
if (@{$bus_modules}) {
6024
print MODULES "# Adapter drivers\n";
6025
print MODULES "$_\n" foreach (@{$bus_modules});
6027
print MODULES "# Chip drivers\n";
6028
print MODULES "$_\n" foreach (@{$hwmon_modules});
6031
print "Successful!\n\n";
6032
print "Monitoring programs won't work until the needed modules are\n".
6033
"loaded. You may want to run '/etc/init.d/module-init-tools start'\n".
6041
my ($input, $superio_features);
6043
# Handle special command line cases first
6044
if (defined $ARGV[0] && $ARGV[0] eq "--stat") {
6049
# We won't go very far if not root
6051
print "You need to be root to run this script.\n";
6055
if (-x "/sbin/service" && -f "/etc/init.d/lm_sensors" &&
6056
-f "/var/lock/subsys/lm_sensors") {
6057
system("/sbin/service", "lm_sensors", "stop");
6060
initialize_kernel_version();
6063
initialize_modules_list();
6064
# Make sure any special case chips are added to the chip_ids list
6065
# before making the support modules list
6066
chip_special_cases();
6067
initialize_modules_supported();
6068
initialize_cpu_list();
6070
print "# sensors-detect revision $revision\n";
6071
initialize_dmi_data();
6072
print_dmi_summary();
6074
print "This program will help you determine which kernel modules you need\n",
6075
"to load to use lm_sensors most effectively. It is generally safe\n",
6076
"and recommended to accept the default answers to all questions,\n",
6077
"unless you know what you're doing.\n\n";
6079
print "Some south bridges, CPUs or memory controllers contain embedded sensors.\n".
6080
"Do you want to scan for them? This is totally safe. (YES/no): ";
6081
unless (<STDIN> =~ /^\s*n/i) {
6083
foreach my $entry (@cpu_ids) {
6090
$superio_features = 0;
6091
# Skip "random" I/O port probing on PPC
6092
if ($kernel_arch ne 'ppc'
6093
&& $kernel_arch ne 'ppc64') {
6094
print "Some Super I/O chips contain embedded sensors. We have to write to\n".
6095
"standard I/O ports to probe them. This is usually safe.\n";
6096
print "Do you want to scan for Super I/O sensors? (YES/no): ";
6097
unless (<STDIN> =~ /^\s*n/i) {
6098
initialize_ioports();
6099
$superio_features |= scan_superio(0x2e, 0x2f);
6100
$superio_features |= scan_superio(0x4e, 0x4f);
6105
unless (is_laptop()) {
6106
print "Some systems (mainly servers) implement IPMI, a set of common interfaces\n".
6107
"through which system health data may be retrieved, amongst other things.\n".
6108
"We first try to get the information from SMBIOS. If we don't find it\n".
6109
"there, we have to read from arbitrary I/O ports to probe for such\n".
6110
"interfaces. This is normally safe. Do you want to scan for IPMI\n".
6111
"interfaces? (YES/no): ";
6112
unless (<STDIN> =~ /^\s*n/i) {
6113
if (!ipmi_from_smbios()) {
6114
initialize_ioports();
6115
scan_isa_bus(\@ipmi_ifs);
6122
printf "Some hardware monitoring chips are accessible through the ISA I/O ports.\n".
6123
"We have to write to arbitrary I/O ports to probe them. This is usually\n".
6124
"safe though. Yes, you do have ISA I/O ports even if you do not have any\n".
6125
"ISA slots! Do you want to scan the ISA I/O ports? (\%s): ",
6126
$superio_features ? "yes/NO" : "YES/no";
6128
unless ($input =~ /^\s*n/i
6129
|| ($superio_features && $input !~ /^\s*y/i)) {
6130
initialize_ioports();
6131
scan_isa_bus(\@chip_ids);
6137
print "Lastly, we can probe the I2C/SMBus adapters for connected hardware\n".
6138
"monitoring devices. This is the most risky part, and while it works\n".
6139
"reasonably well on most systems, it has been reported to cause trouble\n".
6140
"on some systems.\n".
6141
"Do you want to probe the I2C/SMBus adapters now? (YES/no): ";
6143
unless (<STDIN> =~ /^\s*n/i) {
6144
adapter_pci_detection();
6145
load_module("i2c-dev") unless -e "$sysfs_root/class/i2c-dev";
6146
initialize_i2c_adapters_list();
6147
$i2c_addresses_to_scan = i2c_addresses_to_scan();
6150
# Skip SMBus probing by default if Super-I/O has all the features
6151
my $by_default = ~$superio_features & (FEAT_IN | FEAT_FAN | FEAT_TEMP);
6152
# Except on Asus and Tyan boards which often have more than
6153
# one hardware monitoring chip
6154
$by_default = 1 if dmi_match('board_vendor', 'asustek', 'tyan',
6157
# udev may take some time to create the device node
6158
if (!(-x "/sbin/udevadm" && system("/sbin/udevadm settle") == 0)
6159
&& !(-x "/sbin/udevsettle" && system("/sbin/udevsettle") == 0)) {
6163
for (my $dev_nr = 0; $dev_nr < @i2c_adapters; $dev_nr++) {
6164
next unless exists $i2c_adapters[$dev_nr];
6165
scan_i2c_adapter($dev_nr, $by_default);
6167
filter_out_fake_i2c_drivers();
6170
if (!keys %chips_detected) {
6171
print "Sorry, no sensors were detected.\n";
6172
if (is_laptop() && -d "$sysfs_root/firmware/acpi") {
6173
print "This is relatively common on laptops, where thermal management is\n".
6174
"handled by ACPI rather than the OS.\n";
6176
print "Either your system has no sensors, or they are not supported, or\n".
6177
"they are connected to an I2C or SMBus adapter that is not\n".
6178
"supported. If you find out what chips are on your board, check\n".
6179
"http://www.lm-sensors.org/wiki/Devices for driver status.\n";
6184
print "Now follows a summary of the probes I have just done.\n".
6185
"Just press ENTER to continue: ";
6188
initialize_hwmon_autoloaded();
6189
foreach my $driver (keys %chips_detected) {
6190
next unless @{$chips_detected{$driver}};
6191
find_aliases($chips_detected{$driver});
6192
print "\nDriver `$driver'";
6193
print " (autoloaded)" if hwmon_is_autoloaded($driver);
6195
print_chips_report($chips_detected{$driver});
6199
my ($configfile, $bus_modules, $hwmon_modules) = generate_modprobes();
6201
if (@{$hwmon_modules}) {
6202
write_config($configfile, $bus_modules, $hwmon_modules);
6204
print "No modules to load, skipping modules configuration.\n\n";
6217
$SIG{INT} = \&cleanup_on_int;