From 0fb8b6f04b699a2158b8700a8350bf488e2c1d42 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 19 Mar 2004 18:22:30 +0000 Subject: [PATCH] Add support for the PCA9540. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2367 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/detect/sensors-detect | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index c41d8e97..b1aeca04 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -780,7 +780,7 @@ use subs qw(mtp008_detect lm78_detect lm78_isa_detect lm78_alias_detect adm1026_detect w83l785ts_detect lm83_detect lm90_detect saa1064_detect w83l784r_detect mozart_detect max6650_detect fscher_detect adm1029_detect adm1031_detect max6900_detect - m5879_detect); + m5879_detect pca9540_detect); # This is a list of all recognized chips. # Each entry must have the following fields: @@ -1252,6 +1252,12 @@ use subs qw(mtp008_detect lm78_detect lm78_isa_detect lm78_alias_detect i2c_addrs => [0x38..0x3b], i2c_detect => sub { saa1064_detect @_ }, }, + { + name => "Philips Semiconductors PCA9540", + driver => "pca9540", + i2c_addrs => [0x70], + i2c_detect => sub { pca9540_detect @_ }, + }, { name => "Maxim MAX6900", driver => "to-be-written", @@ -3806,6 +3812,25 @@ sub saa1064_detect return 4; } +# $_[0]: A reference to the file descriptor to access this chip. +# We may assume an i2c_set_slave_addr was already done. +# $_[1]: Address +# Returns: undef if not detected, 1 if detected +# Detection is rather difficult, since the PCA9540 has a single register. +# Fortunately, no other device is known to live at this address. +sub pca9540_detect +{ + my ($file, $addr) = @_; + my $reg = i2c_smbus_read_byte($file); + + return if ($reg & 0xf7); + return if $reg != i2c_smbus_read_byte($file); + return if $reg != i2c_smbus_read_byte($file); + return if $reg != i2c_smbus_read_byte($file); + + return 1; +} + # $_[0]: A reference to the file descriptor to access this chip. # We may assume an i2c_set_slave_addr was already done. # $_[1]: Address