mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-03 15:55:15 +00:00
Several detect things:
* W83782D and W83783S detection added; * Adrian's latest Winbond detection problem solved; * inb/outb added (not used yet) git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@262 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -128,6 +128,20 @@ use subs qw(lm78_detect lm75_detect lm80_detect w83781d_detect
|
|||||||
i2c_detect => sub { w83781d_detect 0, @_},
|
i2c_detect => sub { w83781d_detect 0, @_},
|
||||||
isa_addrs => [0x290], # Theoretically anyway, but this will do
|
isa_addrs => [0x290], # Theoretically anyway, but this will do
|
||||||
} ,
|
} ,
|
||||||
|
{
|
||||||
|
name => "Winbond W83782D",
|
||||||
|
driver => "w83781d",
|
||||||
|
i2c_addrs => [0x00..0x7f],
|
||||||
|
i2c_detect => sub { w83781d_detect 1, @_},
|
||||||
|
isa_addrs => [0x290], # Theoretically anyway, but this will do
|
||||||
|
} ,
|
||||||
|
{
|
||||||
|
name => "Winbond W83783S",
|
||||||
|
driver => "w83781d",
|
||||||
|
i2c_addrs => [0x00..0x7f],
|
||||||
|
i2c_detect => sub { w83781d_detect 2, @_},
|
||||||
|
isa_addrs => [0x290], # Theoretically anyway, but this will do
|
||||||
|
} ,
|
||||||
{
|
{
|
||||||
name => "Genesys Logic GL518SM Revision 0x00",
|
name => "Genesys Logic GL518SM Revision 0x00",
|
||||||
driver => "gl518sm",
|
driver => "gl518sm",
|
||||||
@@ -188,6 +202,39 @@ sub contains
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###################
|
||||||
|
# I/O port access #
|
||||||
|
###################
|
||||||
|
|
||||||
|
sub initialize_io
|
||||||
|
{
|
||||||
|
sysopen IOPORTS, "/dev/port", 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
# $_[0]: port to read
|
||||||
|
# Returns: -1 on failure, read value on success.
|
||||||
|
sub inb
|
||||||
|
{
|
||||||
|
my ($res,$nrchars);
|
||||||
|
sysseek IOPORTS, $_[0], 0 or return -1;
|
||||||
|
$nrchars = sysread IOPORTS, $res, 1;
|
||||||
|
return -1 if not defined $nrchars or $nrchars != 1;
|
||||||
|
$res = unpack "C",$res ;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
# $_[0]: port to write
|
||||||
|
# $_[1]: value to write
|
||||||
|
# Returns: -1 on failure, 0 on success.
|
||||||
|
sub outb
|
||||||
|
{
|
||||||
|
my $towrite = pack "C", $_[1];
|
||||||
|
sysseek IOPORTS, $_[0], 0 or return -1;
|
||||||
|
my $nrchars = syswrite IOPORTS, $towrite, 1;
|
||||||
|
return -1 if not defined $nrchars or $nrchars != 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# MODULES #
|
# MODULES #
|
||||||
###########
|
###########
|
||||||
@@ -657,7 +704,7 @@ sub scan_adapter
|
|||||||
foreach $add_addr(@chips) {
|
foreach $add_addr(@chips) {
|
||||||
add_to_chips_detected $$chip{driver},
|
add_to_chips_detected $$chip{driver},
|
||||||
{ confidence => $conf,
|
{ confidence => $conf,
|
||||||
address => add_$addr,
|
address => $addr,
|
||||||
chipname => $$chip{name},
|
chipname => $$chip{name},
|
||||||
description => $adapter_name,
|
description => $adapter_name,
|
||||||
driver => $adapter_driver,
|
driver => $adapter_driver,
|
||||||
@@ -765,9 +812,10 @@ sub lm80_detect
|
|||||||
return (3);
|
return (3);
|
||||||
}
|
}
|
||||||
|
|
||||||
# $_[0]: A reference to the file descriptor to access this chip.
|
# $_[0]: Chip to detect (0 = W83781D, 1 = W83782D, 3 = W83783S)
|
||||||
|
# $_[1]: A reference to the file descriptor to access this chip.
|
||||||
# We may assume an i2c_set_slave_addr was already done.
|
# We may assume an i2c_set_slave_addr was already done.
|
||||||
# $_[1]: Address
|
# $_[2]: Address
|
||||||
# Returns: undef if not detected, (8,addr1,addr2) if detected, but only
|
# Returns: undef if not detected, (8,addr1,addr2) if detected, but only
|
||||||
# if the LM75 chip emulation is enabled.
|
# if the LM75 chip emulation is enabled.
|
||||||
# Registers used:
|
# Registers used:
|
||||||
@@ -775,10 +823,9 @@ sub lm80_detect
|
|||||||
# 0x4a: I2C addresses of emulated LM75 chips
|
# 0x4a: I2C addresses of emulated LM75 chips
|
||||||
# 0x4e: Vendor ID byte selection, and bank selection
|
# 0x4e: Vendor ID byte selection, and bank selection
|
||||||
# 0x4f: Vendor ID
|
# 0x4f: Vendor ID
|
||||||
# 0x58: Device ID (only when in bank 0); both 0x10 and 0x11 is seen
|
# 0x58: Device ID (only when in bank 0); both 0x10 and 0x11 is seen for
|
||||||
# though Winbond documents 0x10 only.
|
# W83781D though Winbond documents 0x10 only.
|
||||||
# Note: Fails if the W83781D is not in bank 0 (may succeed for bank 2; bank 1
|
# Note: Fails if the W8378xD is not in bank 0!
|
||||||
# leaves almost all registers in an undefined state, too bad).
|
|
||||||
# Note: Detection overrules a previous LM78 detection
|
# Note: Detection overrules a previous LM78 detection
|
||||||
sub w83781d_detect
|
sub w83781d_detect
|
||||||
{
|
{
|
||||||
@@ -789,8 +836,11 @@ sub w83781d_detect
|
|||||||
$reg2 = i2c_smbus_read_byte_data($file,0x4f);
|
$reg2 = i2c_smbus_read_byte_data($file,0x4f);
|
||||||
return unless (($reg1 & 0x80) == 0x00 and $reg2 == 0xa3) or
|
return unless (($reg1 & 0x80) == 0x00 and $reg2 == 0xa3) or
|
||||||
(($reg1 & 0x80) == 0x80 and $reg2 == 0x5c);
|
(($reg1 & 0x80) == 0x80 and $reg2 == 0x5c);
|
||||||
return if ($reg1 & 0x07) == 0x00 and
|
return if ($reg1 & 0x07) == 0x00;
|
||||||
(i2c_smbus_read_byte_data($file,0x58) & 0xfe) != 0x10;
|
$reg1 = i2c_smbus_read_byte_data($file,0x58);
|
||||||
|
return if $chip == 0 and ($reg1 & 0xfe) != 0x10;
|
||||||
|
return if $chip == 1 and $reg1 != 0x30;
|
||||||
|
return if $chip == 2 and $reg1 != 0x40;
|
||||||
$reg1 = i2c_smbus_read_byte_data($file,0x4a);
|
$reg1 = i2c_smbus_read_byte_data($file,0x4a);
|
||||||
@res = (8);
|
@res = (8);
|
||||||
push @res, ($reg1 & 0x07) + 0x48 unless $reg1 & 0x08;
|
push @res, ($reg1 & 0x07) + 0x48 unless $reg1 & 0x08;
|
||||||
|
@@ -128,6 +128,20 @@ use subs qw(lm78_detect lm75_detect lm80_detect w83781d_detect
|
|||||||
i2c_detect => sub { w83781d_detect 0, @_},
|
i2c_detect => sub { w83781d_detect 0, @_},
|
||||||
isa_addrs => [0x290], # Theoretically anyway, but this will do
|
isa_addrs => [0x290], # Theoretically anyway, but this will do
|
||||||
} ,
|
} ,
|
||||||
|
{
|
||||||
|
name => "Winbond W83782D",
|
||||||
|
driver => "w83781d",
|
||||||
|
i2c_addrs => [0x00..0x7f],
|
||||||
|
i2c_detect => sub { w83781d_detect 1, @_},
|
||||||
|
isa_addrs => [0x290], # Theoretically anyway, but this will do
|
||||||
|
} ,
|
||||||
|
{
|
||||||
|
name => "Winbond W83783S",
|
||||||
|
driver => "w83781d",
|
||||||
|
i2c_addrs => [0x00..0x7f],
|
||||||
|
i2c_detect => sub { w83781d_detect 2, @_},
|
||||||
|
isa_addrs => [0x290], # Theoretically anyway, but this will do
|
||||||
|
} ,
|
||||||
{
|
{
|
||||||
name => "Genesys Logic GL518SM Revision 0x00",
|
name => "Genesys Logic GL518SM Revision 0x00",
|
||||||
driver => "gl518sm",
|
driver => "gl518sm",
|
||||||
@@ -188,6 +202,39 @@ sub contains
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###################
|
||||||
|
# I/O port access #
|
||||||
|
###################
|
||||||
|
|
||||||
|
sub initialize_io
|
||||||
|
{
|
||||||
|
sysopen IOPORTS, "/dev/port", 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
# $_[0]: port to read
|
||||||
|
# Returns: -1 on failure, read value on success.
|
||||||
|
sub inb
|
||||||
|
{
|
||||||
|
my ($res,$nrchars);
|
||||||
|
sysseek IOPORTS, $_[0], 0 or return -1;
|
||||||
|
$nrchars = sysread IOPORTS, $res, 1;
|
||||||
|
return -1 if not defined $nrchars or $nrchars != 1;
|
||||||
|
$res = unpack "C",$res ;
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
# $_[0]: port to write
|
||||||
|
# $_[1]: value to write
|
||||||
|
# Returns: -1 on failure, 0 on success.
|
||||||
|
sub outb
|
||||||
|
{
|
||||||
|
my $towrite = pack "C", $_[1];
|
||||||
|
sysseek IOPORTS, $_[0], 0 or return -1;
|
||||||
|
my $nrchars = syswrite IOPORTS, $towrite, 1;
|
||||||
|
return -1 if not defined $nrchars or $nrchars != 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# MODULES #
|
# MODULES #
|
||||||
###########
|
###########
|
||||||
@@ -657,7 +704,7 @@ sub scan_adapter
|
|||||||
foreach $add_addr(@chips) {
|
foreach $add_addr(@chips) {
|
||||||
add_to_chips_detected $$chip{driver},
|
add_to_chips_detected $$chip{driver},
|
||||||
{ confidence => $conf,
|
{ confidence => $conf,
|
||||||
address => add_$addr,
|
address => $addr,
|
||||||
chipname => $$chip{name},
|
chipname => $$chip{name},
|
||||||
description => $adapter_name,
|
description => $adapter_name,
|
||||||
driver => $adapter_driver,
|
driver => $adapter_driver,
|
||||||
@@ -765,9 +812,10 @@ sub lm80_detect
|
|||||||
return (3);
|
return (3);
|
||||||
}
|
}
|
||||||
|
|
||||||
# $_[0]: A reference to the file descriptor to access this chip.
|
# $_[0]: Chip to detect (0 = W83781D, 1 = W83782D, 3 = W83783S)
|
||||||
|
# $_[1]: A reference to the file descriptor to access this chip.
|
||||||
# We may assume an i2c_set_slave_addr was already done.
|
# We may assume an i2c_set_slave_addr was already done.
|
||||||
# $_[1]: Address
|
# $_[2]: Address
|
||||||
# Returns: undef if not detected, (8,addr1,addr2) if detected, but only
|
# Returns: undef if not detected, (8,addr1,addr2) if detected, but only
|
||||||
# if the LM75 chip emulation is enabled.
|
# if the LM75 chip emulation is enabled.
|
||||||
# Registers used:
|
# Registers used:
|
||||||
@@ -775,10 +823,9 @@ sub lm80_detect
|
|||||||
# 0x4a: I2C addresses of emulated LM75 chips
|
# 0x4a: I2C addresses of emulated LM75 chips
|
||||||
# 0x4e: Vendor ID byte selection, and bank selection
|
# 0x4e: Vendor ID byte selection, and bank selection
|
||||||
# 0x4f: Vendor ID
|
# 0x4f: Vendor ID
|
||||||
# 0x58: Device ID (only when in bank 0); both 0x10 and 0x11 is seen
|
# 0x58: Device ID (only when in bank 0); both 0x10 and 0x11 is seen for
|
||||||
# though Winbond documents 0x10 only.
|
# W83781D though Winbond documents 0x10 only.
|
||||||
# Note: Fails if the W83781D is not in bank 0 (may succeed for bank 2; bank 1
|
# Note: Fails if the W8378xD is not in bank 0!
|
||||||
# leaves almost all registers in an undefined state, too bad).
|
|
||||||
# Note: Detection overrules a previous LM78 detection
|
# Note: Detection overrules a previous LM78 detection
|
||||||
sub w83781d_detect
|
sub w83781d_detect
|
||||||
{
|
{
|
||||||
@@ -789,8 +836,11 @@ sub w83781d_detect
|
|||||||
$reg2 = i2c_smbus_read_byte_data($file,0x4f);
|
$reg2 = i2c_smbus_read_byte_data($file,0x4f);
|
||||||
return unless (($reg1 & 0x80) == 0x00 and $reg2 == 0xa3) or
|
return unless (($reg1 & 0x80) == 0x00 and $reg2 == 0xa3) or
|
||||||
(($reg1 & 0x80) == 0x80 and $reg2 == 0x5c);
|
(($reg1 & 0x80) == 0x80 and $reg2 == 0x5c);
|
||||||
return if ($reg1 & 0x07) == 0x00 and
|
return if ($reg1 & 0x07) == 0x00;
|
||||||
(i2c_smbus_read_byte_data($file,0x58) & 0xfe) != 0x10;
|
$reg1 = i2c_smbus_read_byte_data($file,0x58);
|
||||||
|
return if $chip == 0 and ($reg1 & 0xfe) != 0x10;
|
||||||
|
return if $chip == 1 and $reg1 != 0x30;
|
||||||
|
return if $chip == 2 and $reg1 != 0x40;
|
||||||
$reg1 = i2c_smbus_read_byte_data($file,0x4a);
|
$reg1 = i2c_smbus_read_byte_data($file,0x4a);
|
||||||
@res = (8);
|
@res = (8);
|
||||||
push @res, ($reg1 & 0x07) + 0x48 unless $reg1 & 0x08;
|
push @res, ($reg1 & 0x07) + 0x48 unless $reg1 & 0x08;
|
||||||
|
Reference in New Issue
Block a user