From 70587e77511449905643df4c32a4eb9f5d9bab99 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 5 Sep 2006 12:09:30 +0000 Subject: [PATCH] sensors-detect: Add generic Super-I/O logical device detection. For families where it makes sense (ITE, Winbond, Fintek), when we have an unknown Super-I/O, we scan all logical devices in search of one with the typical address for hardware monitoring (0x290). If we find it, we let the user know there are probably sensors in the chip. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4144 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/detect/sensors-detect | 52 ++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 5a24248d..d30121c1 100644 --- a/CHANGES +++ b/CHANGES @@ -83,6 +83,7 @@ lm_sensors CHANGES file Remove detection of nVidia graphics adapters Use sysfs for PCI device enumeration Add generic PCI SMBus adapter detection + Add generic Super-I/O logical device detection 2.10.0 (20060214) diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 4027b05c..dd94201b 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -1471,19 +1471,23 @@ $chip_kern26_w83791d = { # Put in "not-a-sensor" if the chip doesn't have hardware monitoring # capabilities (listing such chips here removes the need of manual # lookup when people report them). -# enter: The password sequence to write to the address register # devid: The device ID(s) we have to match (base device) # devid_mask (optional): Bitmask to apply before checking the device ID # logdev: The logical device containing the sensors -# exit (optional): Sequence to write to the address register to exit config -# mode. If not provided, a default reset operation is performed. # alias_detect (optional): For chips which can be both on the ISA and the # I2C bus, a function which detectes whether two entries are the same. # The function should take three parameters: The ISA address, the # I2C bus number, and the I2C address. +# Entries are grouped by family. Each family entry has the following fields: +# family: The family name +# guess (optional): Typical logical device address. This lets us do +# generic probing if we fail to recognize the chip. +# enter: The password sequence to write to the address register +# chips: Array of chips @superio_ids = ( { family => "ITE", + guess => 0x290, enter => { 0x2e => [0x87, 0x01, 0x55, 0x55], @@ -1716,6 +1720,7 @@ $chip_kern26_w83791d = { }, { family => "VIA/Winbond/Fintek", + guess => 0x290, enter => { 0x2e => [0x87, 0x87], @@ -2831,6 +2836,38 @@ sub exit_superio outb($datareg, 0x02); } +# Guess if an unknown Super-I/O chip has sensors +sub guess_superio_ld($$$) +{ + my ($addrreg, $datareg, $typical_addr) = @_; + my ($oldldn, $ldn, $addr); + + # Save logical device number + outb($addrreg, $superio{logdevreg}); + $oldldn = inb($datareg); + + for ($ldn = 0; $ldn < 16; $ldn++) { + # Select logical device + outb($addrreg, $superio{logdevreg}); + outb($datareg, $ldn); + + # Read base I/O address + outb($addrreg, $superio{basereg}); + $addr = inb($datareg) << 8; + outb($addrreg, $superio{basereg} + 1); + $addr |= inb($datareg); + next unless ($addr & 0xfff8) == $typical_addr; + + printf " (logical device \%X has address 0x\%x, could be sensors)\n", + $ldn, $addr; + last; + } + + # Be nice, restore original logical device + outb($addrreg, $superio{logdevreg}); + outb($datareg, $oldldn); +} + sub probe_superio($$$) { my ($addrreg, $datareg, $chip) = @_; @@ -2920,8 +2957,13 @@ sub scan_superio } } - printf(" Found unknown chip with ID 0x%04x\n", $val) - unless $found; + if (!$found) { + printf("Found unknown chip with ID 0x%04x\n", $val); + # Guess if a logical device could correspond to sensors + guess_superio_ld($addrreg, $datareg, $family->{guess}) + if defined $family->{guess}; + } + exit_superio($addrreg, $datareg); } }