[PATCH] sensors-detect: Add TMP42x chip detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds detection for TI's TMP421, TMP422 and TMP423 chips to
sensors-detect. Only the manufactory ID and the device ID is used for
detection. I hope this is reliable enough.
---

 sensors-detect |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

Index: sensors/prog/detect/sensors-detect
===================================================================
--- sensors.orig/prog/detect/sensors-detect	2009-07-10 22:15:41.000000000 +0200
+++ sensors/prog/detect/sensors-detect	2009-07-12 19:26:14.000000000 +0200
@@ -908,6 +908,21 @@
 		i2c_addrs => [0x4c..0x4e],
 		i2c_detect => sub { lm90_detect(@_, 10); },
 	}, {
+		name => "Texas Instruments TMP421",
+		driver => "tmp421",
+		i2c_addrs => [0x2a, 0x4c..0x4f],
+		i2c_detect => sub { tmp42x_detect(@_, 0); },
+	}, {
+		name => "Texas Instruments TMP422",
+		driver => "tmp421",
+		i2c_addrs => [0x2a, 0x4c..0x4f],
+		i2c_detect => sub { tmp42x_detect(@_, 1); },
+	}, {
+		name => "Texas Instruments TMP423",
+		driver => "tmp421",
+		i2c_addrs => [0x2a, 0x4c..0x4f],
+		i2c_detect => sub { tmp42x_detect(@_, 2); },
+	}, {
 		name => "National Semiconductor LM95231",
 		driver => "to-be-written",
 		i2c_addrs => [0x2b, 0x19, 0x2a],
@@ -3907,6 +3922,25 @@
 }
 
 # Registers used:
+#   0xfe: Manufactorer ID
+#   0xff: Device ID
+sub tmp42x_detect()
+{
+	my ($file, $addr, $chip) = @_;
+
+	my $mid = i2c_smbus_read_byte_data($file, 0xfe);
+	my $cid = i2c_smbus_read_byte_data($file, 0xff);
+
+	return if ($mid != 0x55);
+
+	return 6 if ($chip == 0 && $cid == 0x21); # TMP421
+	return 6 if ($chip == 1 && $cid == 0x22); # TMP422
+	return 6 if ($chip == 2 && $cid == 0x23); # TMP423
+
+	return;
+}
+
+# Registers used:
 #   0x03: Configuration (no low nibble, returns the previous low nibble)
 #   0x04: Conversion rate
 #   0xfe: Manufacturer ID



[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux