2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-31 06:15:15 +00:00

Add LM90 detection.

Fix binmode call for Perl 5.005.
        Open /dev/i2c* in binary mode.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1865 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2003-07-07 10:31:41 +00:00
parent de809a3502
commit 286c1e8745

View File

@@ -770,7 +770,7 @@ use subs qw(mtp008_detect lm78_detect lm78_isa_detect lm78_alias_detect
ddcmonitor_detect ds1621_detect adm1024_detect fscpos_detect
fscscy_detect pcf8591_detect arp_detect ipmi_kcs_detect
ipmi_smic_detect via8231_isa_detect lm85_detect smartbatt_detect
adm1026_detect w83l785ts_detect lm83_detect);
adm1026_detect w83l785ts_detect lm83_detect lm90_detect);
# This is a list of all recognized chips.
# Each entry must have the following fields:
@@ -1048,6 +1048,12 @@ use subs qw(mtp008_detect lm78_detect lm78_isa_detect lm78_alias_detect
i2c_addrs => [0x18..0x1a,0x29..0x2b,0x4c..0x4e],
i2c_detect => sub { lm83_detect 0, @_ },
},
{
name => "National Semiconductor LM90",
driver => "to-be-written",
i2c_addrs => [0x4c],
i2c_detect => sub { lm83_detect 0, @_ },
},
{
name => "Analog Devices ADM1022",
driver => "thmc50",
@@ -1354,7 +1360,7 @@ sub initialize_ioports
{
sysopen (IOPORTS, "/dev/port", O_RDWR)
or die "/dev/port: $!\n";
binmode (IOPORTS, ':raw');
binmode IOPORTS;
}
sub close_ioports
@@ -1933,6 +1939,7 @@ sub add_isa_to_chips_detected
print("Can't open ",
"/dev/i2c[-/]$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"),
next;
binmode FILE;
i2c_set_slave_addr \*FILE,$new_misdetected_ref->[$i]->{i2c_addr} or
print("Can't set I2C address for ",
"/dev/i2c[-/]$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"),
@@ -1961,6 +1968,7 @@ sub add_isa_to_chips_detected
print("Can't open ",
"/dev/i2c[-/]$new_detected_ref->[$i]->{i2c_devnr}?!?\n"),
next;
binmode FILE;
i2c_set_slave_addr \*FILE,$new_detected_ref->[$i]->{i2c_addr} or
print("Can't set I2C address for ",
"/dev/i2c[-/]$new_detected_ref->[$i]->{i2c_devnr}?!?\n"),
@@ -2031,6 +2039,7 @@ sub scan_adapter
open FILE,"/dev/i2c$adapter_nr" or
open FILE,"/dev/i2c/$adapter_nr" or
(print "Can't open /dev/i2c[-/]$adapter_nr\n"), return;
binmode FILE;
# Now scan each address in turn
foreach $addr (0..0x7f) {
@@ -2378,7 +2387,6 @@ sub lm80_detect
# 0xfe: Manufacturer ID
sub lm83_detect
{
my $reg;
my ($chip, $file,$addr) = @_;
return if $chip == 0 and i2c_smbus_read_byte_data($file,0xfe) != 0x01;
return 8
@@ -2386,6 +2394,29 @@ sub lm83_detect
return 6;
}
# $_[0]: Chip to detect
# (0 = LM90)
# $_[1]: A reference to the file descriptor to access this chip.
# We may assume an i2c_set_slave_addr was already done.
# $_[2]: Address
# Returns: undef if not detected, 6, 7 or 8 if detected.
# Registers used:
# 0x03: Configuration
# 0xfe: Manufacturer ID
# 0xff: Chip ID / die revision
sub lm90_detect
{
my $reg;
my ($chip, $file,$addr) = @_;
return if $chip == 0 and i2c_smbus_read_byte_data($file,0xfe) != 0x01;
return if (i2c_smbus_read_byte_data($file,0x03) & 0x2a) != 0;
return 8
if ($reg = i2c_smbus_read_byte_data($file,0xff)) == 0x21;
return 7
if $reg > 0x21 and $reg < 0x30;
return 6;
}
# $_[0]: Vendor to check for
# (0x01 = National Semi, 0x41 = Analog Dev)
# $_[1]: A reference to the file descriptor to access this chip.