Skip to contentSkip to conversation

sensors-detect: Add code to detect emc1023,

PATCH In review Guenter Roeck 4 participants 8 messages Jan 22, 2011 – Dec 8, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sensors-detect: Add code to detect emc1023,

This patch adds support for emc1023, emc1043, emc1053, and emc1063 to sensors-detect. It is based on the emc1023 detection code written by Anish Patel, but supports additional chips and is at the same time more restrictive.

v2: Use capitals for device names, simplify revision number validation --
Index: prog/detect/sensors-detect
=================================--- prog/detect/sensors-detect (revision 5907)
+++ prog/detect/sensors-detect (working copy)
@@ -1195,6 +1195,26 @@
i2c_addrs => [0x2f],
i2c_detect => sub { fintek_detect(@_, 7); },
}, {
+ name => "SMSC EMC1023",
+ driver => "to-be-written", # emc1023
+ i2c_addrs => [0x48, 0x49, 0x4c, 0x4d],
+ i2c_detect => sub { emc1023_detect(@_, 0); },
+ }, {
+ name => "SMSC EMC1043",
+ driver => "to-be-written", # emc1023
+ i2c_addrs => [0x48, 0x49, 0x4c, 0x4d],
+ i2c_detect => sub { emc1023_detect(@_, 1); },
+ }, {
+ name => "SMSC EMC1053",
+ driver => "to-be-written", # emc1023
+ i2c_addrs => [0x48, 0x49, 0x4c, 0x4d],
+ i2c_detect => sub { emc1023_detect(@_, 2); },
+ }, {
+ name => "SMSC EMC1063",
+ driver => "to-be-written", # emc1023
+ i2c_addrs => [0x48, 0x49, 0x4c, 0x4d],
+ i2c_detect => sub { emc1023_detect(@_, 3); },
+ }, {
name => "SMSC EMC1403",
driver => "emc1403",
i2c_addrs => [0x18, 0x2a, 0x4c, 0x4d],
@@ -5372,6 +5392,48 @@
return 7;
}

+# Chips to detect: 0 = EMC1023, 1 = EMC1043, 2 = EMC1053, 3 = EMC1063 +# Registers used:

+#   0xed: Device ID register
+#   0xfe: Vendor ID register
+#   0xff: Revision register

+sub emc1023_detect
+{
+ my ($file, $addr, $chip) = @_;
+ my $dev_id = i2c_smbus_read_byte_data($file, 0xed);
+ my $man_id = i2c_smbus_read_byte_data($file, 0xfe);
+ my $rev = i2c_smbus_read_byte_data($file, 0xff);
+
+ return unless $man_id = 0x5d; # SMSC
+ return unless $rev <= 1;
+
+ if ($chip = 0) {
+ return if ($addr = 0x4c) && ($dev_id != 0x04); # EMC1023-1
+ return if ($addr = 0x4d) && ($dev_id != 0x05); # EMC1023-2
+ return if ($addr = 0x48) && ($dev_id != 0x06); # EMC1023-3
+ return if ($addr = 0x49) && ($dev_id != 0x07); # EMC1023-4
+ } elsif ($chip = 1) {
+ if ($addr = 0x4c) { # EMC1043-1, EMC1043-5
+ return unless ($dev_id = 0x0c) || ($dev_id = 0x2c);
+ }
+ return if ($addr = 0x4d) && ($dev_id != 0x0d); # EMC1043-2
+ return if ($addr = 0x48) && ($dev_id != 0x0e); # EMC1043-3
+ return if ($addr = 0x49) && ($dev_id != 0x0f); # EMC1043-4
+ } elsif ($chip = 2) {
+ return if ($addr = 0x4c) && ($dev_id != 0x3c); # EMC1053-1
+ return if ($addr = 0x4d) && ($dev_id != 0x3d); # EMC1053-2
+ return if ($addr = 0x48) && ($dev_id != 0x3e); # EMC1053-3
+ return if ($addr = 0x49) && ($dev_id != 0x3f); # EMC1053-4
+ } elsif ($chip = 3) {
+ return if ($addr = 0x4c) && ($dev_id != 0x30); # EMC1063-1
+ return if ($addr = 0x4d) && ($dev_id != 0x31); # EMC1063-2
+ return if ($addr = 0x48) && ($dev_id != 0x32); # EMC1063-3
+ return if ($addr = 0x49) && ($dev_id != 0x33); # EMC1063-4
+ }
+
+ return 7;
+}
+
# Chip to detect: 0 = EMC1403, 1 = EMC1404, 2 = EMC2103, 3 = EMC1423 # Registers used:
# 0xfd: Device ID register

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw

Re: [lm-sensors] [PATCH v2] sensors-detect: Add code to detect

Quoted 75 lines · Guenter Roeck

This patch adds support for emc1023, emc1043, emc1053, and emc1063 to sensors-detect. It is based on the emc1023 detection code written by Anish Patel, but supports additional chips and is at the same time more restrictive.

v2: Use capitals for device names, simplify revision number validation --
Index: prog/detect/sensors-detect
=================================> --- prog/detect/sensors-detect (revision 5907)
+++ prog/detect/sensors-detect (working copy)

(quoted diff) +55 -0
@@ -1195,6 +1195,26 @@
 		i2c_addrs => [0x2f],
 		i2c_detect => sub { fintek_detect(@_, 7); },
 	}, {
+		name => "SMSC EMC1023",
+		driver => "to-be-written",	# emc1023
+		i2c_addrs => [0x48, 0x49, 0x4c, 0x4d],
+		i2c_detect => sub { emc1023_detect(@_, 0); },
+	}, {
+		name => "SMSC EMC1043",
+		driver => "to-be-written",	# emc1023
+		i2c_addrs => [0x48, 0x49, 0x4c, 0x4d],
+		i2c_detect => sub { emc1023_detect(@_, 1); },
+	}, {
+		name => "SMSC EMC1053",
+		driver => "to-be-written",	# emc1023
+		i2c_addrs => [0x48, 0x49, 0x4c, 0x4d],
+		i2c_detect => sub { emc1023_detect(@_, 2); },
+	}, {
+		name => "SMSC EMC1063",
+		driver => "to-be-written",	# emc1023
+		i2c_addrs => [0x48, 0x49, 0x4c, 0x4d],
+		i2c_detect => sub { emc1023_detect(@_, 3); },
+	}, {
 		name => "SMSC EMC1403",
 		driver => "emc1403",
 		i2c_addrs => [0x18, 0x2a, 0x4c, 0x4d],
@@ -5372,6 +5392,48 @@
 	return 7;
 }
 
+# Chips to detect: 0 = EMC1023, 1 = EMC1043, 2 = EMC1053, 3 = EMC1063
+# Registers used:
+#   0xed: Device ID register
+#   0xfe: Vendor ID register
+#   0xff: Revision register
+sub emc1023_detect
+{
+	my ($file, $addr, $chip) = @_;
+	my $dev_id = i2c_smbus_read_byte_data($file, 0xed);
+	my $man_id = i2c_smbus_read_byte_data($file, 0xfe);
+	my $rev = i2c_smbus_read_byte_data($file, 0xff);
+
+	return unless $man_id = 0x5d;  # SMSC
+	return unless $rev <= 1;
+
+	if ($chip = 0) {
+		return if ($addr = 0x4c) && ($dev_id != 0x04);	# EMC1023-1
+		return if ($addr = 0x4d) && ($dev_id != 0x05);	# EMC1023-2
+		return if ($addr = 0x48) && ($dev_id != 0x06);	# EMC1023-3
+		return if ($addr = 0x49) && ($dev_id != 0x07);	# EMC1023-4
+	} elsif ($chip = 1) {
+		if ($addr = 0x4c) {				# EMC1043-1, EMC1043-5
+			return unless ($dev_id = 0x0c) || ($dev_id = 0x2c);
+		}
+		return if ($addr = 0x4d) && ($dev_id != 0x0d);	# EMC1043-2
+		return if ($addr = 0x48) && ($dev_id != 0x0e);	# EMC1043-3
+		return if ($addr = 0x49) && ($dev_id != 0x0f);	# EMC1043-4
+	} elsif ($chip = 2) {
+		return if ($addr = 0x4c) && ($dev_id != 0x3c);	# EMC1053-1
+		return if ($addr = 0x4d) && ($dev_id != 0x3d);	# EMC1053-2
+		return if ($addr = 0x48) && ($dev_id != 0x3e);	# EMC1053-3
+		return if ($addr = 0x49) && ($dev_id != 0x3f);	# EMC1053-4
+	} elsif ($chip = 3) {
+		return if ($addr = 0x4c) && ($dev_id != 0x30);	# EMC1063-1
+		return if ($addr = 0x4d) && ($dev_id != 0x31);	# EMC1063-2

Review line 5439

Quoted 10 lines
(quoted diff) +7 -0
+		return if ($addr = 0x48) && ($dev_id != 0x32);	# EMC1063-3
+		return if ($addr = 0x49) && ($dev_id != 0x33);	# EMC1063-4
+	}
+
+	return 7;
+}
+
 # Chip to detect: 0 = EMC1403, 1 = EMC1404, 2 = EMC2103, 3 = EMC1423
 # Registers used:
 #   0xfd: Device ID register

Looks good, please apply.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw

PATCH v2 1/1 sensors-detect: Add code to detect LM95245

In reply to Guenter Roeck

v2: Fixed per review feedback. Tested code with LM95231 and LM95245.

---

Index: prog/detect/sensors-detect
=================================--- prog/detect/sensors-detect (revision 5983)
+++ prog/detect/sensors-detect (working copy)
@@ -1008,6 +1008,11 @@
i2c_addrs => [0x2b, 0x19, 0x2a], i2c_detect => sub { lm95231_detect(@_, 1); },
}, {
+ name => "National Semiconductor LM95245",
+ driver => "lm95245",
+ i2c_addrs => [0x18, 0x19, 0x29, 0x4c, 0x4d],
+ i2c_detect => sub { lm95231_detect(@_, 2); },
+ }, {
name => "National Semiconductor LM63", driver => "lm63",
i2c_addrs => [0x4c],
@@ -4540,12 +4545,14 @@
return 5;
}

-# Chip to detect: 0 = LM95231, 1 = LM95241
+# Chip to detect: 0 = LM95231, 1 = LM95241, 2 = LM95245
# Registers used:

 #   0x02: Status (3 unused bits)
 #   0x03: Configuration (3 unused bits)
-#   0x06: Remote diode filter control (6 unused bits)
-#   0x30: Remote diode model type select (6 unused bits)
+#   0x06: Remote diode filter control (6 unused bits, LM95231 and LM95241)
+#   0x30: Remote diode model type select (6 unused bits, LM95231 and LM95241)
+#   0x30: Local Temperature LSB (5 unused bits, LM95245)
+#   0x33: Status register 2 (6 unused bits, LM95245)
 #   0xfe: Manufacturer ID
 #   0xff: Revision ID

sub lm95231_detect
@@ -4555,13 +4562,21 @@
my $cid = i2c_smbus_read_byte_data($file, 0xff);

return if $mid != 0x01; # National Semiconductor
- return if $chip = 0 && $cid != 0xa1; # LM95231
- return if $chip = 1 && $cid != 0xa4; # LM95241

- return if i2c_smbus_read_byte_data($file, 0x02) & 0x70;
- return if i2c_smbus_read_byte_data($file, 0x03) & 0x89;
- return if i2c_smbus_read_byte_data($file, 0x06) & 0xfa;
- return if i2c_smbus_read_byte_data($file, 0x30) & 0xfa;
+ if ($chip = 0 || $chip = 1) {
+ return if $chip = 0 && $cid != 0xa1; # LM95231
+ return if $chip = 1 && $cid != 0xa4; # LM95241
+ return if i2c_smbus_read_byte_data($file, 0x02) & 0x70;
+ return if i2c_smbus_read_byte_data($file, 0x03) & 0x89;
+ return if i2c_smbus_read_byte_data($file, 0x06) & 0xfa;
+ return if i2c_smbus_read_byte_data($file, 0x30) & 0xfa;
+ } elsif ($chip = 2) {
+ return if $cid != 0xb3; # LM95245
+ return if i2c_smbus_read_byte_data($file, 0x02) & 0x68;
+ return if i2c_smbus_read_byte_data($file, 0x03) & 0xa1;
+ return if i2c_smbus_read_byte_data($file, 0x30) & 0x1a;
+ return if i2c_smbus_read_byte_data($file, 0x33) & 0x3f;
+ }

return 6;
}
Index: CHANGES
=================================--- CHANGES (revision 5983)
+++ CHANGES (working copy)
@@ -17,6 +17,7 @@
Add detection of ITE IT8772E Don't advertise the ipmisensors driver Add detection of SA56004
+ Add detection of LM95245

3.3.0 (2011-03-28)
Makefile: Check for bison and flex

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw

Re: [lm-sensors] [PATCH v2] sensors-detect: Add code to detect

In reply to Guenter Roeck
Quoted 50 lines · Guenter Roeck

v2: Fixed per review feedback. Tested code with LM95231 and LM95245.

---

Index: prog/detect/sensors-detect
=================================> --- prog/detect/sensors-detect (revision 5983)
+++ prog/detect/sensors-detect (working copy)

(quoted diff) +12 -9
@@ -1008,6 +1008,11 @@
 		i2c_addrs => [0x2b, 0x19, 0x2a],
 		i2c_detect => sub { lm95231_detect(@_, 1); },
 	}, {
+		name => "National Semiconductor LM95245",
+		driver => "lm95245",
+		i2c_addrs => [0x18, 0x19, 0x29, 0x4c, 0x4d],
+		i2c_detect => sub { lm95231_detect(@_, 2); },
+	}, {
 		name => "National Semiconductor LM63",
 		driver => "lm63",
 		i2c_addrs => [0x4c],
@@ -4540,12 +4545,14 @@
 	return 5;
 }
 
-# Chip to detect: 0 = LM95231, 1 = LM95241
+# Chip to detect: 0 = LM95231, 1 = LM95241, 2 = LM95245
 # Registers used:
 #   0x02: Status (3 unused bits)
 #   0x03: Configuration (3 unused bits)
-#   0x06: Remote diode filter control (6 unused bits)
-#   0x30: Remote diode model type select (6 unused bits)
+#   0x06: Remote diode filter control (6 unused bits, LM95231 and LM95241)
+#   0x30: Remote diode model type select (6 unused bits, LM95231 and LM95241)
+#   0x30: Local Temperature LSB (5 unused bits, LM95245)
+#   0x33: Status register 2 (6 unused bits, LM95245)
 #   0xfe: Manufacturer ID
 #   0xff: Revision ID
 sub lm95231_detect
@@ -4555,13 +4562,21 @@
 	my $cid = i2c_smbus_read_byte_data($file, 0xff);
 
 	return if $mid != 0x01;				# National Semiconductor
-	return if $chip = 0 && $cid != 0xa1;		# LM95231
-	return if $chip = 1 && $cid != 0xa4;		# LM95241
 
-	return if i2c_smbus_read_byte_data($file, 0x02) & 0x70;
-	return if i2c_smbus_read_byte_data($file, 0x03) & 0x89;
-	return if i2c_smbus_read_byte_data($file, 0x06) & 0xfa;
-	return if i2c_smbus_read_byte_data($file, 0x30) & 0xfa;
+	if ($chip = 0 || $chip = 1) {
+		return if $chip = 0 && $cid != 0xa1;	# LM95231

Review line 4577

Quoted 10 lines
(quoted diff) +10 -0
+		return if $chip = 1 && $cid != 0xa4;	# LM95241
+		return if i2c_smbus_read_byte_data($file, 0x02) & 0x70;
+		return if i2c_smbus_read_byte_data($file, 0x03) & 0x89;
+		return if i2c_smbus_read_byte_data($file, 0x06) & 0xfa;
+		return if i2c_smbus_read_byte_data($file, 0x30) & 0xfa;
+	} elsif ($chip = 2) {
+		return if $cid != 0xb3;			# LM95245
+		return if i2c_smbus_read_byte_data($file, 0x02) & 0x68;
+		return if i2c_smbus_read_byte_data($file, 0x03) & 0xa1;
+		return if i2c_smbus_read_byte_data($file, 0x30) & 0x1a;

Rather "& 0x1f", no?

Quoted 9 lines
(quoted diff) +2 -0
+		return if i2c_smbus_read_byte_data($file, 0x33) & 0x3f;
+	}
 
 	return 6;
 }

Index: CHANGES
=================================> --- CHANGES (revision 5983)
+++ CHANGES (working copy)

Review line 23

Quoted 7 lines
(quoted diff) +1 -0
@@ -17,6 +17,7 @@
                   Add detection of ITE IT8772E
                   Don't advertise the ipmisensors driver
                   Add detection of SA56004
+                  Add detection of LM95245
 
 3.3.0 (2011-03-28)
   Makefile: Check for bison and flex

Other that this, the patch looks good, feel free to apply after fixing.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#4 lore raw

Re: [lm-sensors] [PATCH v2] sensors-detect: Add code to detect

In reply to Guenter Roeck
Quoted 55 lines · Jean Delvare
Quoted 54 lines · Guenter Roeck

v2: Fixed per review feedback. Tested code with LM95231 and LM95245.

---

Index: prog/detect/sensors-detect
=================================> > --- prog/detect/sensors-detect (revision 5983)
+++ prog/detect/sensors-detect (working copy)

(quoted diff) +16 -9
@@ -1008,6 +1008,11 @@
 		i2c_addrs => [0x2b, 0x19, 0x2a],
 		i2c_detect => sub { lm95231_detect(@_, 1); },
 	}, {
+		name => "National Semiconductor LM95245",
+		driver => "lm95245",
+		i2c_addrs => [0x18, 0x19, 0x29, 0x4c, 0x4d],
+		i2c_detect => sub { lm95231_detect(@_, 2); },
+	}, {
 		name => "National Semiconductor LM63",
 		driver => "lm63",
 		i2c_addrs => [0x4c],
@@ -4540,12 +4545,14 @@
 	return 5;
 }
 
-# Chip to detect: 0 = LM95231, 1 = LM95241
+# Chip to detect: 0 = LM95231, 1 = LM95241, 2 = LM95245
 # Registers used:
 #   0x02: Status (3 unused bits)
 #   0x03: Configuration (3 unused bits)
-#   0x06: Remote diode filter control (6 unused bits)
-#   0x30: Remote diode model type select (6 unused bits)
+#   0x06: Remote diode filter control (6 unused bits, LM95231 and LM95241)
+#   0x30: Remote diode model type select (6 unused bits, LM95231 and LM95241)
+#   0x30: Local Temperature LSB (5 unused bits, LM95245)
+#   0x33: Status register 2 (6 unused bits, LM95245)
 #   0xfe: Manufacturer ID
 #   0xff: Revision ID
 sub lm95231_detect
@@ -4555,13 +4562,21 @@
 	my $cid = i2c_smbus_read_byte_data($file, 0xff);
 
 	return if $mid != 0x01;				# National Semiconductor
-	return if $chip = 0 && $cid != 0xa1;		# LM95231
-	return if $chip = 1 && $cid != 0xa4;		# LM95241
 
-	return if i2c_smbus_read_byte_data($file, 0x02) & 0x70;
-	return if i2c_smbus_read_byte_data($file, 0x03) & 0x89;
-	return if i2c_smbus_read_byte_data($file, 0x06) & 0xfa;
-	return if i2c_smbus_read_byte_data($file, 0x30) & 0xfa;
+	if ($chip = 0 || $chip = 1) {
+		return if $chip = 0 && $cid != 0xa1;	# LM95231
+		return if $chip = 1 && $cid != 0xa4;	# LM95241
+		return if i2c_smbus_read_byte_data($file, 0x02) & 0x70;
+		return if i2c_smbus_read_byte_data($file, 0x03) & 0x89;
+		return if i2c_smbus_read_byte_data($file, 0x06) & 0xfa;
Quoted 9 lines

Review line 4577

Quoted 6 lines
(quoted diff) +6 -0
+		return if i2c_smbus_read_byte_data($file, 0x30) & 0xfa;
+	} elsif ($chip = 2) {
+		return if $cid != 0xb3;			# LM95245
+		return if i2c_smbus_read_byte_data($file, 0x02) & 0x68;
+		return if i2c_smbus_read_byte_data($file, 0x03) & 0xa1;
+		return if i2c_smbus_read_byte_data($file, 0x30) & 0x1a;

Rather "& 0x1f", no?

Yes ...

Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#5 lore raw

PATCH v2 1/1 sensors-detect: Add code to detect TMP435

In reply to Guenter Roeck

Also strengthen chip detection for other TMP4xx chips, and update driver support status for TMP431 and TMP432.

---
v2: Detect TMP435 on its entire address range
Strengthen detect function for other TMP4xx chips

 CHANGES                    |  1 +
 prog/detect/sensors-detect | 42 +++++++++++++++++++++++++++++++++---------
 2 files changed, 34 insertions(+), 9 deletions(-)
CHANGES +1 -0
index 638a8bf..534b810 100644
@@ -24,6 +24,7 @@ SVN HEAD
                   Document support for EMC1402, EMC1404, and EMC1424
                   Detect new revisions of EMC14xx
                   Add detection of EMC1422
+                  Add detection of TMP435
 
 3.3.5 "Happy Birthday Beddy" (2014-01-22)
   libsensors: Improve documentation of two functions
prog/detect/sensors-detect +33 -9

104 lines not on this page · raw message

Signature · 7 lines
1.9.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#6 lore raw

Re: [lm-sensors] [PATCH v2] sensors-detect: Add code to detect TMP435

In reply to Guenter Roeck

Hi Guenter,

Quoted 68 lines · Guenter Roeck

Also strengthen chip detection for other TMP4xx chips, and update driver support status for TMP431 and TMP432.

---
v2: Detect TMP435 on its entire address range
Strengthen detect function for other TMP4xx chips

 CHANGES                    |  1 +
 prog/detect/sensors-detect | 42 +++++++++++++++++++++++++++++++++---------
 2 files changed, 34 insertions(+), 9 deletions(-)
CHANGES +1 -0
index 638a8bf..534b810 100644
@@ -24,6 +24,7 @@ SVN HEAD
                   Document support for EMC1402, EMC1404, and EMC1424
                   Detect new revisions of EMC14xx
                   Add detection of EMC1422
+                  Add detection of TMP435
 
 3.3.5 "Happy Birthday Beddy" (2014-01-22)
   libsensors: Improve documentation of two functions
prog/detect/sensors-detect +10 -3
index 448cf22..55b3537 100755
@@ -1029,15 +1029,20 @@ use vars qw(@i2c_adapter_names);
 		i2c_detect => sub { tmp42x_detect(@_, 2); },
 	}, {
 		name => "Texas Instruments TMP431",
-		driver => "to-be-written",		# tmp401
+		driver => "tmp401",
 		i2c_addrs => [0x4c, 0x4d],
 		i2c_detect => sub { lm90_detect(@_, 16); },
 	}, {
 		name => "Texas Instruments TMP432",
-		driver => "to-be-written",		# tmp401
+		driver => "tmp401",
 		i2c_addrs => [0x4c, 0x4d],
 		i2c_detect => sub { lm90_detect(@_, 17); },
 	}, {
+		name => "Texas Instruments TMP435",
+		driver => "tmp401",
+		i2c_addrs => [0x37, 0x48..0x4f],
+		i2c_detect => sub { lm90_detect(@_, 19); },
+	}, {
 		name => "Texas Instruments TMP441",
 		driver => "tmp421",
 		i2c_addrs => [0x1c..0x1f, 0x2a, 0x4c..0x4f],
@@ -4674,11 +4679,13 @@ sub max6680_95_detect
 #		  8 = W83L771W/G, 9 = TMP401, 10 = TMP411,
 #		  11 = W83L771AWG/ASG, 12 = MAX6690,
 #		  13 = ADT7461A/NCT1008, 14 = SA56004,
-#		  15 = G781, 16 = TMP431, 17 = TMP432, 18 = TMP451
+#		  15 = G781, 16 = TMP431, 17 = TMP432, 18 = TMP451,
+#		  19 = TMP435
 # Registers used:
 #   0x03: Configuration
 #   0x04: Conversion rate
 #   0xbf: Configuration 2 (National Semiconductor, Winbond, and Philips only)
+#   0x1a: Configuration 2 (TI only)
 #   0xfe: Manufacturer ID
 #   0xff: Chip ID / die revision
 sub lm90_detect
@@ -4688,7 +4695,13 @@ sub lm90_detect
 	my $cid = i2c_smbus_read_byte_data($file, 0xff);

prog/detect/sensors-detect sub lm90_detect · line 4704

Quoted 10 lines
prog/detect/sensors-detect +7 -1
 	my $conf = i2c_smbus_read_byte_data($file, 0x03);
 	my $rate = i2c_smbus_read_byte_data($file, 0x04);
-	my $conf2 = i2c_smbus_read_byte_data($file, 0xbf);
+	my $conf2;
+
+	if ($chip = 9 || $chip = 10 || ($chip >= 16 && $chip <= 19)) {
+		$conf2 = i2c_smbus_read_byte_data($file, 0x1a);
+	} else {
+		$conf2 = i2c_smbus_read_byte_data($file, 0xbf);
+	}

The TMP431/TMP432 datasheet I have claims that Configuration Register 2 is at 0x3f for the TMP432 (surprisingly, I have to say.)

At this point I am wondering if it wouldn't make more sense to split support for the TI chips to a separate function.

Quoted 29 lines
prog/detect/sensors-detect +5 -3
 	if ($chip = 0) {
 		return if ($conf & 0x2a) != 0;
@@ -4748,17 +4761,19 @@ sub lm90_detect
 	}
 	if ($chip = 9) {
 		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xfc) != 0x1c;
 		return if $rate > 0x0F;
 		return if $mid != 0x55;		# Texas Instruments
 		return 8 if $cid = 0x11;	# TMP401
 	}
 	if ($chip = 10) {
 		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xfc) != 0x1c;
 		return if $rate > 0x0F;
 		return if $mid != 0x55;		# Texas Instruments
-		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 8 if ($addr = 0x4c && $cid = 0x12); # TMP411A
+		return 8 if ($addr = 0x4d && $cid = 0x13); # TMP411B
+		return 8 if ($addr = 0x4e && $cid = 0x10); # TMP411C
 	}
 	if ($chip = 11) {
 		return if ($conf & 0x2a) != 0;
@@ -4794,15 +4809,17 @@ sub lm90_detect
 	}
 	if ($chip = 16) {

prog/detect/sensors-detect sub lm90_detect · line 4819

Quoted 10 lines
prog/detect/sensors-detect +3 -1
 		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xe3) != 0;
 		return if $rate > 0x0F;
 		return if $mid != 0x55;		# Texas Instruments
-		return 6 if ($cid = 0x31);	# TMP431A/B/C/D
+		return 8 if ($cid = 0x31);	# TMP431A/B/C/D
 	}
 	if ($chip = 17) {
 		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xe3) != 0;

With the datasheet I have, the mask should be 0xC3 here.

Quoted 21 lines
prog/detect/sensors-detect +8 -1
 		return if $rate > 0x0F;
 		return if $mid != 0x55;		# Texas Instruments
-		return 6 if ($cid = 0x32);	# TMP432A/B
+		return 8 if ($cid = 0x32);	# TMP432A/B
 	}
 	if ($chip = 18) {
 		return if ($conf & 0x1B) != 0;
@@ -4810,6 +4827,13 @@ sub lm90_detect
 		return if $mid != 0x55;		# Texas Instruments
 		return 4 if ($cid = 0x00);	# TMP451
 	}
+	if ($chip = 19) {
+		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xe3) != 0;
+		return if $rate > 0x0F;
+		return if $mid != 0x55;		# Texas Instruments
+		return 8 if ($cid = 0x35);	# TMP435
+	}
 	return;
 }
 
Signature · 7 lines
Jean Delvare
SUSE L3 Support

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#7 lore raw

Re: [lm-sensors] [PATCH v2] sensors-detect: Add code to detect TMP435

In reply to Guenter Roeck
Quoted 76 lines · Jean Delvare

Hi Guenter,

Quoted 73 lines · Guenter Roeck

Also strengthen chip detection for other TMP4xx chips, and update driver support status for TMP431 and TMP432.

---
v2: Detect TMP435 on its entire address range
Strengthen detect function for other TMP4xx chips

  CHANGES                    |  1 +
  prog/detect/sensors-detect | 42 +++++++++++++++++++++++++++++++++---------
  2 files changed, 34 insertions(+), 9 deletions(-)
CHANGES +1 -0
index 638a8bf..534b810 100644
@@ -24,6 +24,7 @@ SVN HEAD
                    Document support for EMC1402, EMC1404, and EMC1424
                    Detect new revisions of EMC14xx
                    Add detection of EMC1422
+                  Add detection of TMP435
 
  3.3.5 "Happy Birthday Beddy" (2014-01-22)
    libsensors: Improve documentation of two functions
prog/detect/sensors-detect +12 -4
index 448cf22..55b3537 100755
@@ -1029,15 +1029,20 @@ use vars qw(@i2c_adapter_names);
  		i2c_detect => sub { tmp42x_detect(@_, 2); },
  	}, {
  		name => "Texas Instruments TMP431",
-		driver => "to-be-written",		# tmp401
+		driver => "tmp401",
  		i2c_addrs => [0x4c, 0x4d],
  		i2c_detect => sub { lm90_detect(@_, 16); },
  	}, {
  		name => "Texas Instruments TMP432",
-		driver => "to-be-written",		# tmp401
+		driver => "tmp401",
  		i2c_addrs => [0x4c, 0x4d],
  		i2c_detect => sub { lm90_detect(@_, 17); },
  	}, {
+		name => "Texas Instruments TMP435",
+		driver => "tmp401",
+		i2c_addrs => [0x37, 0x48..0x4f],
+		i2c_detect => sub { lm90_detect(@_, 19); },
+	}, {
  		name => "Texas Instruments TMP441",
  		driver => "tmp421",
  		i2c_addrs => [0x1c..0x1f, 0x2a, 0x4c..0x4f],
@@ -4674,11 +4679,13 @@ sub max6680_95_detect
  #		  8 = W83L771W/G, 9 = TMP401, 10 = TMP411,
  #		  11 = W83L771AWG/ASG, 12 = MAX6690,
  #		  13 = ADT7461A/NCT1008, 14 = SA56004,
-#		  15 = G781, 16 = TMP431, 17 = TMP432, 18 = TMP451
+#		  15 = G781, 16 = TMP431, 17 = TMP432, 18 = TMP451,
+#		  19 = TMP435
  # Registers used:
  #   0x03: Configuration
  #   0x04: Conversion rate
  #   0xbf: Configuration 2 (National Semiconductor, Winbond, and Philips only)
+#   0x1a: Configuration 2 (TI only)
  #   0xfe: Manufacturer ID
  #   0xff: Chip ID / die revision
  sub lm90_detect
@@ -4688,7 +4695,13 @@ sub lm90_detect
  	my $cid = i2c_smbus_read_byte_data($file, 0xff);
  	my $conf = i2c_smbus_read_byte_data($file, 0x03);
  	my $rate = i2c_smbus_read_byte_data($file, 0x04);
-	my $conf2 = i2c_smbus_read_byte_data($file, 0xbf);
+	my $conf2;
+
Quoted 9 lines

prog/detect/sensors-detect sub lm90_detect · line 4704

Quoted 5 lines
prog/detect/sensors-detect +5 -0
+	if ($chip = 9 || $chip = 10 || ($chip >= 16 && $chip <= 19)) {
+		$conf2 = i2c_smbus_read_byte_data($file, 0x1a);
+	} else {
+		$conf2 = i2c_smbus_read_byte_data($file, 0xbf);
+	}

The TMP431/TMP432 datasheet I have claims that Configuration Register 2 is at 0x3f for the TMP432 (surprisingly, I have to say.)

You are right; I overlooked the second register table in the datasheet. Those chips have weird register addresses.

Quoted 3 lines

At this point I am wondering if it wouldn't make more sense to split support for the TI chips to a separate function.

Agreed, makes sense. I'll do that.

Quoted 33 lines
Quoted 33 lines
prog/detect/sensors-detect +6 -3
  	if ($chip = 0) {
  		return if ($conf & 0x2a) != 0;
@@ -4748,17 +4761,19 @@ sub lm90_detect
  	}
  	if ($chip = 9) {
  		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xfc) != 0x1c;
  		return if $rate > 0x0F;
  		return if $mid != 0x55;		# Texas Instruments
  		return 8 if $cid = 0x11;	# TMP401
  	}
  	if ($chip = 10) {
  		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xfc) != 0x1c;
  		return if $rate > 0x0F;
  		return if $mid != 0x55;		# Texas Instruments
-		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 8 if ($addr = 0x4c && $cid = 0x12); # TMP411A
+		return 8 if ($addr = 0x4d && $cid = 0x13); # TMP411B
+		return 8 if ($addr = 0x4e && $cid = 0x10); # TMP411C
  	}
  	if ($chip = 11) {
  		return if ($conf & 0x2a) != 0;
@@ -4794,15 +4809,17 @@ sub lm90_detect
  	}
  	if ($chip = 16) {
  		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xe3) != 0;
  		return if $rate > 0x0F;
  		return if $mid != 0x55;		# Texas Instruments
Quoted 9 lines

prog/detect/sensors-detect sub lm90_detect · line 4819

Quoted 6 lines
prog/detect/sensors-detect +2 -1
-		return 6 if ($cid = 0x31);	# TMP431A/B/C/D
+		return 8 if ($cid = 0x31);	# TMP431A/B/C/D
  	}
  	if ($chip = 17) {
  		return if ($conf & 0x1B) != 0;
+		return if ($conf2 & 0xe3) != 0;

With the datasheet I have, the mask should be 0xC3 here.

Yes. Again, looked at wrong table.

Thanks,
Guenter

Quoted 13 lines
Quoted 13 lines
prog/detect/sensors-detect +3 -1
  		return if $rate > 0x0F;
  		return if $mid != 0x55;		# Texas Instruments
-		return 6 if ($cid = 0x32);	# TMP432A/B
+		return 8 if ($cid = 0x32);	# TMP432A/B
  	}
  	if ($chip = 18) {
  		return if ($conf & 0x1B) != 0;
@@ -4810,6 +4827,13 @@ sub lm90_detect
  		return if $mid != 0x55;		# Texas Instruments
  		return 4 if ($cid = 0x00);	# TMP451
  	}
+	if ($chip = 19) {
+		return if ($conf & 0x1B) != 0;
Quoted 10 lines

prog/detect/sensors-detect sub lm90_detect · line 4839

Quoted 8 lines
prog/detect/sensors-detect +5 -0
+		return if ($conf2 & 0xe3) != 0;
+		return if $rate > 0x0F;
+		return if $mid != 0x55;		# Texas Instruments
+		return 8 if ($cid = 0x35);	# TMP435
+	}
  	return;
  }
 

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors