mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-03 07:45:30 +00:00
Reindent all chip detection functions.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5483 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -3076,11 +3076,13 @@ sub lm78_detect
|
||||
{
|
||||
my ($file, $addr, $chip) = @_;
|
||||
my $reg;
|
||||
|
||||
return unless i2c_smbus_read_byte_data($file, 0x48) == $addr;
|
||||
return unless (i2c_smbus_read_byte_data($file, 0x40) & 0x80) == 0x00;
|
||||
|
||||
$reg = i2c_smbus_read_byte_data($file, 0x49);
|
||||
return unless ($chip == 0 and ($reg == 0x00 or $reg == 0x20 or $reg == 0x40)) or
|
||||
($chip == 2 and ($reg & 0xfe) == 0xc0);
|
||||
return if $chip == 0 && ($reg != 0x00 && $reg != 0x20 && $reg != 0x40);
|
||||
return if $chip == 2 && ($reg & 0xfe) != 0xc0;
|
||||
|
||||
# Explicitly prevent misdetection of Winbond chips
|
||||
$reg = i2c_smbus_read_byte_data($file, 0x4f);
|
||||
@@ -3268,8 +3270,7 @@ sub lm92_detect
|
||||
return if $chip != 2 and ($temp & 0x0700);
|
||||
}
|
||||
|
||||
return 4 if $chip == 0;
|
||||
return 2;
|
||||
return ($chip == 0) ? 4 : 2;
|
||||
}
|
||||
|
||||
# Registers used:
|
||||
@@ -3343,7 +3344,7 @@ sub lm80_detect
|
||||
return if i2c_smbus_read_byte_data($file, $i+0xc0) != $reg;
|
||||
}
|
||||
|
||||
# Refine a bit by checking wether limits are in the correct order
|
||||
# Refine a bit by checking whether limits are in the correct order
|
||||
# (min<max for voltages, hyst<max for temperature). Since it is still
|
||||
# possible that the chip is an LM80 with limits not properly set,
|
||||
# a few "errors" are tolerated.
|
||||
@@ -3498,13 +3499,12 @@ sub lm90_detect
|
||||
return 6 if ($addr == 0x4c && $cid == 0x12); # TMP411A
|
||||
return 6 if ($addr == 0x4d && $cid == 0x13); # TMP411B
|
||||
return 6 if ($addr == 0x4e && $cid == 0x10); # TMP411C
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# Registers used:
|
||||
# 0x03: Configuration (no low nibble)
|
||||
# 0x03: Configuration (no low nibble, returns the previous low nibble)
|
||||
# 0x04: Conversion rate
|
||||
# 0xfe: Manufacturer ID
|
||||
# 0xff: no register
|
||||
@@ -3516,8 +3516,7 @@ sub max6657_detect
|
||||
my $conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);
|
||||
|
||||
return if $mid != 0x4d; # Maxim
|
||||
return if ($conf & 0x1f) != 0x0d; # No low nibble,
|
||||
# returns previous low nibble
|
||||
return if ($conf & 0x1f) != 0x0d;
|
||||
return if $cid != 0x4d; # No register, returns previous value
|
||||
|
||||
my $rate = i2c_smbus_read_byte_data($file, 0x04, NO_CACHE);
|
||||
@@ -3525,8 +3524,7 @@ sub max6657_detect
|
||||
|
||||
$cid = i2c_smbus_read_byte_data($file, 0xff, NO_CACHE);
|
||||
$conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);
|
||||
return if ($conf & 0x0f) != $rate; # No low nibble,
|
||||
# returns previous low nibble
|
||||
return if ($conf & 0x0f) != $rate;
|
||||
return if $cid != $rate; # No register, returns previous value
|
||||
|
||||
return 5;
|
||||
@@ -3678,7 +3676,6 @@ sub adm1031_detect
|
||||
$confidence++ if ($r2to & 0x70) == 0x00;
|
||||
return $confidence;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# Chip to detect: 0 = ADM1033, 1 = ADM1034
|
||||
@@ -3707,7 +3704,6 @@ sub adm1034_detect
|
||||
return 6 if $drev == 0x02;
|
||||
return 4;
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
# Chip to detect: 0 = ADT7467/ADT7468, 1 = ADT7476, 2 = ADT7462, 3 = ADT7466,
|
||||
@@ -3758,7 +3754,6 @@ sub adt7467_detect
|
||||
return 7 if ($drev == 0x00);
|
||||
return 5;
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
# Chip to detect: 0 = ADT7473, 1 = ADT7475
|
||||
@@ -3781,12 +3776,11 @@ sub adt7473_detect
|
||||
return if $cid != 0x75; # ADT7475
|
||||
return 5;
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
# Chip to detect: 0 = aSC7512, 1 = aSC7611, 2 = aSC7621
|
||||
# Registers used:
|
||||
# 0x3e: Manufacturer ID (0x61)
|
||||
# 0x3e: Manufacturer ID
|
||||
# 0x3f: Version
|
||||
sub andigilog_detect
|
||||
{
|
||||
@@ -3794,24 +3788,20 @@ sub andigilog_detect
|
||||
my $mid = i2c_smbus_read_byte_data($file, 0x3e);
|
||||
my $cid = i2c_smbus_read_byte_data($file, 0x3f);
|
||||
|
||||
return if ($mid != 0x61);
|
||||
return if $mid != 0x61; # Andigilog
|
||||
|
||||
if ($chip == 0) {
|
||||
return if $cid != 0x62;
|
||||
return 5;
|
||||
}
|
||||
|
||||
if ($chip == 1) {
|
||||
return if $cid != 0x69;
|
||||
return 5;
|
||||
}
|
||||
|
||||
if ($chip == 2) {
|
||||
return if ($cid != 0x6C && $cid != 0x6D);
|
||||
return if $cid != 0x6C && $cid != 0x6D;
|
||||
return 5;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# Registers used:
|
||||
@@ -3824,18 +3814,16 @@ sub andigilog_aSC7511_detect
|
||||
my $die = i2c_smbus_read_byte_data($file, 0xff);
|
||||
|
||||
return if $mid != 0x61; # Andigilog
|
||||
if ($die == 0x0) {
|
||||
return if $die != 0x00;
|
||||
return 3;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
# Chip to detect: 0 = LM85, 1 = LM96000, 2 = ADM1027, 3 = ADT7463,
|
||||
# 4 = EMC6D100/101, 5 = EMC6D102, 6 = EMC6D103
|
||||
# Registers used: 0x3e == Vendor register.
|
||||
# 0x3d == Device ID register (Analog Devices only).
|
||||
# 0x3f == Version/Stepping register.
|
||||
# Registers used:
|
||||
# 0x3e: Vendor register
|
||||
# 0x3d: Device ID register (Analog Devices only)
|
||||
# 0x3f: Version/Stepping register
|
||||
sub lm85_detect
|
||||
{
|
||||
my ($file, $addr, $chip) = @_;
|
||||
@@ -3873,7 +3861,6 @@ sub lm85_detect
|
||||
return if i2c_smbus_read_byte_data($file, 0x3d) != 0x27;
|
||||
return 8;
|
||||
}
|
||||
|
||||
return 7;
|
||||
}
|
||||
|
||||
@@ -3890,11 +3877,11 @@ sub lm87_detect
|
||||
|
||||
if ($chip == 0) {
|
||||
return if $cid != 0x02; # National Semiconductor
|
||||
return if ($rev & 0xfc) != 0x04;
|
||||
return if ($rev & 0xfc) != 0x04; # LM87
|
||||
}
|
||||
if ($chip == 1) {
|
||||
return if $cid != 0x41; # Analog Devices
|
||||
return if ($rev & 0xf0) != 0x10;
|
||||
return if ($rev & 0xf0) != 0x10; # ADM1024
|
||||
}
|
||||
|
||||
my $cfg = i2c_smbus_read_byte_data($file, 0x40);
|
||||
@@ -3957,7 +3944,8 @@ sub w83781d_detect
|
||||
|
||||
$reg1 = i2c_smbus_read_byte_data($file, 0x4a);
|
||||
push @res, ($reg1 & 0x07) + 0x48 unless $reg1 & 0x08;
|
||||
push @res, (($reg1 & 0x70) >> 4) + 0x48 unless ($reg1 & 0x80 or $chip == 2);
|
||||
push @res, (($reg1 & 0x70) >> 4) + 0x48
|
||||
unless ($reg1 & 0x80 or $chip == 2);
|
||||
return @res;
|
||||
}
|
||||
|
||||
@@ -3981,7 +3969,7 @@ sub w83793_detect
|
||||
$reg = i2c_smbus_read_byte_data($file, 0x0e);
|
||||
return if $reg != 0x7b;
|
||||
|
||||
# If bank 0 is selected, we can do more checks
|
||||
# If bank 0 is selected, we can do more checks
|
||||
return 6 unless ($bank & 0x07) == 0;
|
||||
$reg = i2c_smbus_read_byte_data($file, 0x0b);
|
||||
return unless ($reg == ($addr << 1));
|
||||
@@ -4178,12 +4166,9 @@ sub adm1021_detect
|
||||
my $convrate = i2c_smbus_read_byte_data($file, 0x04);
|
||||
|
||||
# Check manufacturer IDs and product revisions when available
|
||||
return if $chip == 0 and $man_id != 0x41 ||
|
||||
($rev & 0xf0) != 0x00;
|
||||
return if $chip == 1 and $man_id != 0x41 ||
|
||||
($rev & 0xf0) != 0x30;
|
||||
return if $chip == 3 and $man_id != 0x4d ||
|
||||
$rev != 0x01;
|
||||
return if $chip == 0 and $man_id != 0x41 || ($rev & 0xf0) != 0x00;
|
||||
return if $chip == 1 and $man_id != 0x41 || ($rev & 0xf0) != 0x30;
|
||||
return if $chip == 3 and $man_id != 0x4d || $rev != 0x01;
|
||||
return if $chip == 4 and $man_id != 0x49;
|
||||
return if $chip == 5 and $convrate != 0x00;
|
||||
return if $chip == 6 and $man_id != 0x23;
|
||||
@@ -4199,7 +4184,7 @@ sub adm1021_detect
|
||||
return if ($convrate & 0xf8) != 0;
|
||||
}
|
||||
|
||||
# Extra checks for MAX1617 and LM84, since those are often misdetected
|
||||
# Extra checks for MAX1617 and LM84, since those are often misdetected.
|
||||
# We verify several assertions (6 for the MAX1617, 4 for the LM84) and
|
||||
# discard the chip if any fail. Note that these checks are not done
|
||||
# by the adm1021 driver.
|
||||
@@ -4220,16 +4205,15 @@ sub adm1021_detect
|
||||
# Negative high limits
|
||||
return if ($lhi & 0x80) or ($rhi & 0x80);
|
||||
# Low limits over high limits
|
||||
if ($chip != 5) { # LM84 doesn't have low limits
|
||||
if ($chip == 2) {
|
||||
$llo -= 256 if ($llo & 0x80);
|
||||
$rlo -= 256 if ($rlo & 0x80);
|
||||
return if ($llo > $lhi) or ($rlo > $rhi);
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 3 if ($chip == 2) or ($chip == 5);
|
||||
return 7 if $chip <= 3;
|
||||
return 5;
|
||||
return ($chip <= 3) ? 7 : 5;
|
||||
}
|
||||
|
||||
# Chip to detect: 0 = MAX1668, 1 = MAX1805, 2 = MAX1989
|
||||
@@ -4266,16 +4250,16 @@ sub max1619_detect
|
||||
my $status = i2c_smbus_read_byte_data($file, 0x02);
|
||||
my $convrate = i2c_smbus_read_byte_data($file, 0x04);
|
||||
|
||||
return if $man_id != 0x4D; # Maxim
|
||||
|
||||
if ($chip == 0) { # MAX1619
|
||||
return if $man_id != 0x4D
|
||||
or $dev_id != 0x04
|
||||
return if $dev_id != 0x04
|
||||
or ($conf & 0x03)
|
||||
or ($status & 0x61)
|
||||
or $convrate >= 8;
|
||||
}
|
||||
if ($chip == 1) { # MAX1618
|
||||
return if $man_id != 0x4D
|
||||
or $dev_id != 0x02
|
||||
return if $dev_id != 0x02
|
||||
or ($conf & 0x07)
|
||||
or ($status & 0x63);
|
||||
}
|
||||
@@ -4292,8 +4276,7 @@ sub ite_overclock_detect
|
||||
|
||||
my $uid1 = i2c_smbus_read_byte_data($file, 0x28);
|
||||
my $uid2 = i2c_smbus_read_byte_data($file, 0x29);
|
||||
return if $uid1 != 0x83
|
||||
|| $uid2 != 0x12;
|
||||
return if $uid1 != 0x83 || $uid2 != 0x12;
|
||||
|
||||
return 6;
|
||||
}
|
||||
@@ -4327,9 +4310,7 @@ sub eeprom_detect
|
||||
}
|
||||
$checksum &= 255;
|
||||
|
||||
return 8
|
||||
if $checksum == i2c_smbus_read_byte_data($file, 63);
|
||||
|
||||
return 8 if $checksum == i2c_smbus_read_byte_data($file, 63);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4396,14 +4377,10 @@ sub m5879_detect
|
||||
{
|
||||
my ($file, $addr) = @_;
|
||||
|
||||
return
|
||||
unless i2c_smbus_read_byte_data($file, 0x3F) == 0x01;
|
||||
return unless i2c_smbus_read_byte_data($file, 0x3F) == 0x01;
|
||||
return unless i2c_smbus_read_byte_data($file, 0x48) == $addr;
|
||||
|
||||
return
|
||||
unless i2c_smbus_read_byte_data($file, 0x48) == $addr;
|
||||
|
||||
return
|
||||
unless (i2c_smbus_read_byte_data($file, 0x4A) & 0x06) == 0
|
||||
return unless (i2c_smbus_read_byte_data($file, 0x4A) & 0x06) == 0
|
||||
and (i2c_smbus_read_byte_data($file, 0x4B) & 0xFC) == 0
|
||||
and (i2c_smbus_read_byte_data($file, 0x4F) & 0xFC) == 0
|
||||
and (i2c_smbus_read_byte_data($file, 0x57) & 0xFE) == 0
|
||||
@@ -4481,7 +4458,8 @@ sub fintek_detect
|
||||
} elsif ($chip == 5) { # F75387SG/RG
|
||||
return unless $chipid == 0x0410;
|
||||
} elsif ($chip == 6) { # F75383M/S/F75384M/S
|
||||
# The datasheet has 0x0303, but Fintek say 0x0413 is also possible
|
||||
# The datasheet has 0x0303, but Fintek say 0x0413 is also
|
||||
# possible
|
||||
return unless $chipid == 0x0303 || $chipid == 0x0413;
|
||||
} elsif ($chip == 7) { # custom power control IC
|
||||
return unless $chipid == 0x0302;
|
||||
@@ -4617,8 +4595,8 @@ sub lm78_isa_detect
|
||||
|
||||
return unless (isa_read_i5d6($addr, 0x40) & 0x80) == 0x00;
|
||||
my $reg = isa_read_i5d6($addr, 0x49);
|
||||
return unless ($chip == 0 and ($reg == 0x00 or $reg == 0x20 or $reg == 0x40)) or
|
||||
($chip == 2 and ($reg & 0xfe) == 0xc0);
|
||||
return if $chip == 0 && ($reg != 0x00 && $reg != 0x20 && $reg != 0x40);
|
||||
return if $chip == 2 && ($reg & 0xfe) != 0xc0;
|
||||
|
||||
# Explicitly prevent misdetection of Winbond chips
|
||||
$reg = isa_read_i5d6($addr, 0x4f);
|
||||
@@ -4653,8 +4631,8 @@ sub w83781d_isa_detect
|
||||
(($reg1 & 0x80) == 0x80 and $reg2 == 0x5c);
|
||||
return unless ($reg1 & 0x07) == 0x00;
|
||||
$reg1 = isa_read_i5d6($addr, 0x58);
|
||||
return if $chip == 0 and ($reg1 & 0xfe) != 0x10;
|
||||
return if $chip == 1 and ($reg1 & 0xfe) != 0x30;
|
||||
return if $chip == 0 && ($reg1 & 0xfe) != 0x10;
|
||||
return if $chip == 1 && ($reg1 & 0xfe) != 0x30;
|
||||
|
||||
return 8;
|
||||
}
|
||||
@@ -4690,7 +4668,8 @@ sub winbond_alias_detect
|
||||
|
||||
return 0 unless isa_read_i5d6($isa_addr, 0x48) == $i2c_addr;
|
||||
for ($i = $first; $i <= $last; $i++) {
|
||||
return 0 unless isa_read_i5d6($isa_addr, $i) == i2c_smbus_read_byte_data($file, $i);
|
||||
return 0 unless isa_read_i5d6($isa_addr, $i) ==
|
||||
i2c_smbus_read_byte_data($file, $i);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -4702,7 +4681,8 @@ sub vt1211_alias_detect
|
||||
|
||||
return 0 unless (inb($isa_addr + 0x48) & 0x7f) == $i2c_addr;
|
||||
for ($i = 0x2b; $i <= 0x3d; $i++) {
|
||||
return 0 unless inb($isa_addr + $i) == i2c_smbus_read_byte_data($file, $i);
|
||||
return 0 unless inb($isa_addr + $i) ==
|
||||
i2c_smbus_read_byte_data($file, $i);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user