Skip to contentSkip to conversation

sensors-detect: Add detection of MAX6642

PATCH Applied Per Dalén 5 participants 13 messages May 26, 2011 – Jun 26, 2014

lore
Share & tools
lore

Per Dalén

author
#0 lore raw

PATCH v2 1/1 sensors-detect: Add detection of MAX6642

Changed according to the suggestions from Guenter Roeck:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.

---

This patch adds detection of MAX6642 to sensors-detect.

---

detect/sensors-detect +12 -0
@@ -848,6 +848,11 @@
 		i2c_addrs => [0x2c, 0x2e, 0x2f],
 		i2c_detect => sub { max6639_detect(@_); },
 	}, {
+		name => "Maxim MAX6642",
+		driver => "max6642",
+		i2c_addrs => [0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f],
+		i2c_detect => sub { max6642_detect(@_); },
+	}, {
 		name => "Maxim MAX6655/MAX6656",
 		driver => "max6655",
 		i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
@@ -5779,6 +5784,36 @@
 	return 6;
 }
 
+# Chip to detect: MAX6642
+# Registers used:
+#   0x02: Status register
+#   0x03: Configuration register
+#   0xfe: Manufacturer ID
+#   0x04,0x06,0xff: No registers
+# We use the 0x04,0x06 and 0xff addresses (unused) to improve the

reliability.
+# These are not real registers and will always return the last returned value.
+# This isn't documented.
+sub max6642_detect
+{
+ my ($file, $addr) = @_;
+ my ($man_id, $conf, $status);
+
+ $man_id = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);
+ return unless $man_id = 0x4d; # Maxim
+ return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) != $man_id;
+ return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $man_id;
+ return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $man_id;
+ $status = i2c_smbus_read_byte_data($file, 0x02, NO_CACHE);
+ $conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);
+
+ # Bit 5, 3, 1 and 0 should be zero
+ return unless ($status & 0x2b) = 0x00;
+ # The 4 lower bits should be zero
+ return unless ($conf & 0x0f) = 0x00;
+
+ return 6;
+}
+
sub max6655_detect
{
my ($file, $addr) = @_;

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

#1 lore raw
Quoted 11 lines · Per Dalén

Changed according to the suggestions from Guenter Roeck:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.

---

This patch adds detection of MAX6642 to sensors-detect.

Looks good to me. Jean, any comments, especially regarding the detection strength ? If not I'll apply it.

Thanks,
Guenter

Quoted 45 lines

---

detect/sensors-detect +12 -0
@@ -848,6 +848,11 @@
 		i2c_addrs => [0x2c, 0x2e, 0x2f],
 		i2c_detect => sub { max6639_detect(@_); },
 	}, {
+		name => "Maxim MAX6642",
+		driver => "max6642",
+		i2c_addrs => [0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f],
+		i2c_detect => sub { max6642_detect(@_); },
+	}, {
 		name => "Maxim MAX6655/MAX6656",
 		driver => "max6655",
 		i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
@@ -5779,6 +5784,36 @@
 	return 6;
 }
 
+# Chip to detect: MAX6642
+# Registers used:
+#   0x02: Status register
+#   0x03: Configuration register
+#   0xfe: Manufacturer ID
+#   0x04,0x06,0xff: No registers
+# We use the 0x04,0x06 and 0xff addresses (unused) to improve the

reliability.
+# These are not real registers and will always return the last returned value.

detect/sensors-detect +15 -0
+# This isn't documented.
+sub max6642_detect
+{
+	my ($file, $addr) = @_;
+	my ($man_id, $conf, $status);
+
+	$man_id = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);
+	return unless $man_id = 0x4d;	# Maxim
+	return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $man_id;
+	$status = i2c_smbus_read_byte_data($file, 0x02, NO_CACHE);
+	$conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);
+
+	# Bit 5, 3, 1 and 0 should be zero

detect/sensors-detect

Quoted 10 lines
detect/sensors-detect +7 -0
+	return unless ($status & 0x2b) = 0x00;
+	# The 4 lower bits should be zero
+	return unless ($conf & 0x0f) = 0x00;
+
+	return 6;
+}
+
 sub max6655_detect
 {
 	my ($file, $addr) = @_;

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

#2 lore raw
In reply to Per Dalén
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Per Dalén

Changed according to the suggestions from Guenter Roeck:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.

Quoted 8 lines
Quoted 5 lines

---

This patch adds detection of MAX6642 to sensors-detect.

Looks good to me. Jean, any comments, especially regarding the detection strength ? If not I'll apply it.

Busy at work right now, will take a look in the evening.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#3 lore raw
In reply to Per Dalén

Hi Per,

Quoted 5 lines · Per Dalén

Changed according to the suggestions from Guenter Roeck:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.

THis is better but I'm not completely happy yet.

Quoted 8 lines

This patch adds detection of MAX6642 to sensors-detect.

---

detect/sensors-detect line 853

Quoted 6 lines
detect/sensors-detect +3 -0
@@ -848,6 +848,11 @@
 		i2c_addrs => [0x2c, 0x2e, 0x2f],
 		i2c_detect => sub { max6639_detect(@_); },
 	}, {
+		name => "Maxim MAX6642",
+		driver => "max6642",
+		i2c_addrs => [0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f],

Better written: [0x48..0x4f]

Quoted 6 lines
detect/sensors-detect +2 -0
+		i2c_detect => sub { max6642_detect(@_); },
+	}, {
 		name => "Maxim MAX6655/MAX6656",
 		driver => "max6655",
 		i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],

detect/sensors-detect line 5793

Quoted 10 lines
detect/sensors-detect +7 -0
@@ -5779,6 +5784,36 @@
 	return 6;
 }
 
+# Chip to detect: MAX6642
+# Registers used:
+#   0x02: Status register
+#   0x03: Configuration register
+#   0xfe: Manufacturer ID
+#   0x04,0x06,0xff: No registers
+# We use the 0x04,0x06 and 0xff addresses (unused) to improve the

Space after comma please.

Quoted 1 line

reliability.

Please disable line wrapping in your e-mail client before sending patches.

Quoted 4 lines

+# These are not real registers and will always return the last returned value.

detect/sensors-detect +2 -0
+# This isn't documented.
+sub max6642_detect

detect/sensors-detect

Quoted 10 lines
detect/sensors-detect +10 -0
+{
+	my ($file, $addr) = @_;
+	my ($man_id, $conf, $status);
+
+	$man_id = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);
+	return unless $man_id = 0x4d;	# Maxim
+	return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $man_id;
+	$status = i2c_smbus_read_byte_data($file, 0x02, NO_CACHE);

At this point you should check the unused status bits immediately (so that you can exit if they don't meet the expectations.) Then you should read non-registers 0x04, 0x06 and 0xff again. This is the only reliable way to make sure that there are no registers at these addresses. It is perfectly possible (though unlikely) that a given chip does have values 0x4d for all of registers 0x04, 0x06, 0xfe and 0xff.

See max6657_detect() for an example.

detect/sensors-detect

Quoted 1 line
detect/sensors-detect +1 -0
+	$conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);

NO_CACHE is not needed here, as this register 0x03 does exist. Only use NO_CACHE when you really need it, it's expensive!

Quoted 12 lines
detect/sensors-detect +9 -0
+
+	# Bit 5, 3, 1 and 0 should be zero
+	return unless ($status & 0x2b) = 0x00;
+	# The 4 lower bits should be zero
+	return unless ($conf & 0x0f) = 0x00;
+
+	return 6;
+}
+
 sub max6655_detect
 {
 	my ($file, $addr) = @_;
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author
#4 lore raw
In reply to Per Dalén
Quoted 1 line · Jean Delvare

Hi Per,

Hi Jean,

I'll fix the sensors-detect and MAX6642 driver during (or right after) the weekend in the way you suggest. Thanks for the tips.

Quoted 79 lines · Per Dalén
Quoted 5 lines

Changed according to the suggestions from Guenter Roeck:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.

THis is better but I'm not completely happy yet.

Quoted 8 lines

This patch adds detection of MAX6642 to sensors-detect.

---

detect/sensors-detect line 853

Quoted 6 lines
detect/sensors-detect +3 -0
@@ -848,6 +848,11 @@
 		i2c_addrs => [0x2c, 0x2e, 0x2f],
 		i2c_detect => sub { max6639_detect(@_); },
 	}, {
+		name => "Maxim MAX6642",
+		driver => "max6642",
+		i2c_addrs => [0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f],

Better written: [0x48..0x4f]

Quoted 6 lines
detect/sensors-detect +2 -0
+		i2c_detect => sub { max6642_detect(@_); },
+	}, {
 		name => "Maxim MAX6655/MAX6656",
 		driver => "max6655",
 		i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],

detect/sensors-detect line 5793

Quoted 10 lines
detect/sensors-detect +7 -0
@@ -5779,6 +5784,36 @@
 	return 6;
 }
 
+# Chip to detect: MAX6642
+# Registers used:
+#   0x02: Status register
+#   0x03: Configuration register
+#   0xfe: Manufacturer ID
+#   0x04,0x06,0xff: No registers
+# We use the 0x04,0x06 and 0xff addresses (unused) to improve the

Space after comma please.

Quoted 1 line

reliability.

Please disable line wrapping in your e-mail client before sending patches.

Quoted 4 lines

+# These are not real registers and will always return the last returned value.

detect/sensors-detect +2 -0
+# This isn't documented.
+sub max6642_detect

detect/sensors-detect

Quoted 10 lines
detect/sensors-detect +10 -0
+{
+	my ($file, $addr) = @_;
+	my ($man_id, $conf, $status);
+
+	$man_id = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);
+	return unless $man_id = 0x4d;	# Maxim
+	return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $man_id;
+	$status = i2c_smbus_read_byte_data($file, 0x02, NO_CACHE);

At this point you should check the unused status bits immediately (so that you can exit if they don't meet the expectations.) Then you should read non-registers 0x04, 0x06 and 0xff again. This is the only reliable way to make sure that there are no registers at these addresses. It is perfectly possible (though unlikely) that a given chip does have values 0x4d for all of registers 0x04, 0x06, 0xfe and 0xff.

See max6657_detect() for an example.

detect/sensors-detect

Quoted 1 line
detect/sensors-detect +1 -0
+	$conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);

NO_CACHE is not needed here, as this register 0x03 does exist. Only use NO_CACHE when you really need it, it's expensive!

Quoted 14 lines

detect/sensors-detect

Quoted 12 lines
detect/sensors-detect +9 -0
+
+	# Bit 5, 3, 1 and 0 should be zero
+	return unless ($status & 0x2b) = 0x00;
+	# The 4 lower bits should be zero
+	return unless ($conf & 0x0f) = 0x00;
+
+	return 6;
+}
+
 sub max6655_detect
 {
 	my ($file, $addr) = @_;

BR
Per

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

author
#5 lore raw
In reply to Per Dalén

Hi,

Here's the new patch for sensors-detect.

Changed according to the suggestions from Jean Delvare:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.
* Read the other non-existing registers after the status.
* Removed NO_CACHE from manufacturer ID, Status and Configuration registers.

BR
Per

Quoted 80 lines · Jean Delvare

Hi Per,

Quoted 5 lines · Per Dalén

Changed according to the suggestions from Guenter Roeck:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.

THis is better but I'm not completely happy yet.

Quoted 8 lines

This patch adds detection of MAX6642 to sensors-detect.

---

detect/sensors-detect line 853

Quoted 6 lines
detect/sensors-detect +3 -0
@@ -848,6 +848,11 @@
 		i2c_addrs => [0x2c, 0x2e, 0x2f],
 		i2c_detect => sub { max6639_detect(@_); },
 	}, {
+		name => "Maxim MAX6642",
+		driver => "max6642",
+		i2c_addrs => [0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f],

Better written: [0x48..0x4f]

Quoted 6 lines
detect/sensors-detect +2 -0
+		i2c_detect => sub { max6642_detect(@_); },
+	}, {
 		name => "Maxim MAX6655/MAX6656",
 		driver => "max6655",
 		i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],

detect/sensors-detect line 5793

Quoted 10 lines
detect/sensors-detect +7 -0
@@ -5779,6 +5784,36 @@
 	return 6;
 }
 
+# Chip to detect: MAX6642
+# Registers used:
+#   0x02: Status register
+#   0x03: Configuration register
+#   0xfe: Manufacturer ID
+#   0x04,0x06,0xff: No registers
+# We use the 0x04,0x06 and 0xff addresses (unused) to improve the

Space after comma please.

Quoted 1 line

reliability.

Please disable line wrapping in your e-mail client before sending patches.

Quoted 4 lines

+# These are not real registers and will always return the last returned value.

detect/sensors-detect +2 -0
+# This isn't documented.
+sub max6642_detect

detect/sensors-detect

Quoted 10 lines
detect/sensors-detect +10 -0
+{
+	my ($file, $addr) = @_;
+	my ($man_id, $conf, $status);
+
+	$man_id = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE);
+	return unless $man_id == 0x4d;	# Maxim
+	return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $man_id;
+	$status = i2c_smbus_read_byte_data($file, 0x02, NO_CACHE);

At this point you should check the unused status bits immediately (so that you can exit if they don't meet the expectations.) Then you should read non-registers 0x04, 0x06 and 0xff again. This is the only reliable way to make sure that there are no registers at these addresses. It is perfectly possible (though unlikely) that a given chip does have values 0x4d for all of registers 0x04, 0x06, 0xfe and 0xff.

See max6657_detect() for an example.

detect/sensors-detect

Quoted 1 line
detect/sensors-detect +1 -0
+	$conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE);

NO_CACHE is not needed here, as this register 0x03 does exist. Only use NO_CACHE when you really need it, it's expensive!

Quoted 14 lines

detect/sensors-detect

Quoted 12 lines
detect/sensors-detect +9 -0
+
+	# Bit 5, 3, 1 and 0 should be zero
+	return unless ($status & 0x2b) == 0x00;
+	# The 4 lower bits should be zero
+	return unless ($conf & 0x0f) == 0x00;
+
+	return 6;
+}
+
 sub max6655_detect
 {
 	my ($file, $addr) = @_;

This patch adds detection of MAX6642 to sensors-detect.

---

detect/sensors-detect +39 -0
Index: prog/detect/sensors-detect
===================================================================
@@ -848,6 +848,11 @@
 		i2c_addrs => [0x2c, 0x2e, 0x2f],
 		i2c_detect => sub { max6639_detect(@_); },
 	}, {
+		name => "Maxim MAX6642",
+		driver => "max6642",
+		i2c_addrs => [0x48..0x4f],
+		i2c_detect => sub { max6642_detect(@_); },
+	}, {
 		name => "Maxim MAX6655/MAX6656",
 		driver => "max6655",
 		i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e],
@@ -5789,6 +5794,40 @@
 	return 6;
 }
 
+# Chip to detect: MAX6642
+# Registers used:
+#   0x02: Status register
+#   0x03: Configuration register
+#   0xfe: Manufacturer ID
+#   0x04, 0x06, 0xff: No registers
+# We use the 0x04,0x06 and 0xff addresses (unused) to improve the reliability.
+# These are not real registers and will always return the last returned value.
+# This isn't documented.
+sub max6642_detect
+{
+	my ($file, $addr) = @_;
+	my ($man_id, $conf, $status);
+
+	$man_id = i2c_smbus_read_byte_data($file, 0xfe);
+	return unless $man_id == 0x4d;	# Maxim
+	return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $man_id;
+	return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $man_id;
+
+	$status = i2c_smbus_read_byte_data($file, 0x02);
+	# Bit 5, 3, 1 and 0 should be zero
+	return unless ($status & 0x2b) == 0x00;
+	return if i2c_smbus_read_byte_data($file, 0x04, NO_CACHE) != $status;
+	return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $status;
+	return if i2c_smbus_read_byte_data($file, 0xff, NO_CACHE) != $status;
+
+	$conf = i2c_smbus_read_byte_data($file, 0x03);
+	# The 4 lower bits should be zero
+	return unless ($conf & 0x0f) == 0x00;
+
+	return 6;
+}
+
 sub max6655_detect
 {
 	my ($file, $addr) = @_;

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

#6 lore raw
In reply to Per Dalén
Quoted 11 lines · Per Dalén

Hi,

Here's the new patch for sensors-detect.

Changed according to the suggestions from Jean Delvare:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.
* Read the other non-existing registers after the status.
* Removed NO_CACHE from manufacturer ID, Status and Configuration registers.

Looks good, except that maybe I'd go for a confidence value of only 5, not 6, due to the lack of proper device ID register.

Guenter, please apply.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#7 lore raw
In reply to Per Dalén
Quoted 13 lines · Jean Delvare
Quoted 11 lines · Per Dalén

Hi,

Here's the new patch for sensors-detect.

Changed according to the suggestions from Jean Delvare:

* Check the manufacturer ID directly. Fastens the test if it's not a Maxim chip.
* Read the other non-existing registers after the manufacturer ID.
* Read the other non-existing registers after the status.
* Removed NO_CACHE from manufacturer ID, Status and Configuration registers.

Quoted 5 lines

Looks good, except that maybe I'd go for a confidence value of only 5, not 6, due to the lack of proper device ID register.

Guenter, please apply.

Applied.

Thanks,
Guenter

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

#8 lore raw

PATCH v2 1/1 sensors-detect: Add detection of TI ADC128D818

In reply to Per Dalén

---
v2: Use separate function to detect ADC128D818.
Fix register addresses
Check additional registers
Fix typo in lm80 detection (ok, I am lazy ;-)

 CHANGES                    |    3 +++
 prog/detect/sensors-detect |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)
CHANGES +3 -0
index e1347a6..970dd67 100644
@@ -1,6 +1,9 @@
 lm-sensors CHANGES file
 -----------------------
 
+SVN HEAD
+  sensors-detect: Add detection of ADC128D818
+
 3.3.5 "Happy Birthday Beddy" (2014-01-22)
   libsensors: Improve documentation of two functions
               Increase MAX_SENSORS_PER_TYPE to 33
prog/detect/sensors-detect +32 -1
index a2093f3..cfab2df 100755
@@ -547,6 +547,11 @@ use vars qw(@i2c_adapter_names);
 		i2c_addrs => [0x28..0x2f],
 		i2c_detect => sub { lm80_detect(@_, 1); },
 	}, {
+		name => "TI / National Semiconductor ADC128D818",
+		driver => "adc128d818",
+		i2c_addrs => [0x1d, 0x1e, 0x1f, 0x2d, 0x2e, 0x2f],
+		i2c_detect => sub { adc128d818_detect(@_); },
+	}, {
 		name => "National Semiconductor LM85",
 		driver => "lm85",
 		i2c_addrs => [0x2c..0x2e],
@@ -4437,7 +4442,7 @@ sub lm92_detect
 # Registers used:
 #   0x00: Configuration register
 #   0x02: Interrupt state register
-#   0x07: Converstion rate register (LM96080 only)
+#   0x07: Conversion rate register (LM96080 only)
 #   0x2a-0x3d: Limits registers (LM80 only)
 #   0x3e: Manufacturer's ID register (LM96080 only)
 #   0x3f: Stepping/die revision ID register (LM96080 only)
@@ -4502,6 +4507,32 @@ sub lm80_detect
 }
 
 # Registers used:
+#   0x00: Configuration register
+#   0x07: Conversion rate register
+#   0x09: Oneshot register
+#   0x0a: Shutdown register
+#   0x0b: Advanced Configuration register
+#   0x0c: Busy Status register
+#   0x3e: Manufacturer's ID register
+#   0x3f: Stepping/die revision ID register
+sub adc128d818_detect
+{
+	my ($file, $addr) = @_;
+
+	return if i2c_smbus_read_byte_data($file, 0x3e) != 0x01;
+	return if i2c_smbus_read_byte_data($file, 0x3f) != 0x09;
+
+	return if (i2c_smbus_read_byte_data($file, 0x00) & 0xf4) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x07) & 0xfe) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x09) & 0xfe) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x0a) & 0xfe) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x0b) & 0xf8) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x0c) & 0xfc) != 0;
+
+	return 7;
+}
+
+# Registers used:
 #   0x02: Status 1
 #   0x03: Configuration
 #   0x04: Company ID of LM84
Signature · 7 lines
1.7.9.7


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

Re: [lm-sensors] [PATCH v2] sensors-detect: Add detection of TI ADC128D818

In reply to Per Dalén
Quoted 73 lines · Guenter Roeck

---
v2: Use separate function to detect ADC128D818.
Fix register addresses
Check additional registers
Fix typo in lm80 detection (ok, I am lazy ;-)

 CHANGES                    |    3 +++
 prog/detect/sensors-detect |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)
CHANGES +3 -0
index e1347a6..970dd67 100644
@@ -1,6 +1,9 @@
 lm-sensors CHANGES file
 -----------------------
 
+SVN HEAD
+  sensors-detect: Add detection of ADC128D818
+
 3.3.5 "Happy Birthday Beddy" (2014-01-22)
   libsensors: Improve documentation of two functions
               Increase MAX_SENSORS_PER_TYPE to 33
prog/detect/sensors-detect +25 -1
index a2093f3..cfab2df 100755
@@ -547,6 +547,11 @@ use vars qw(@i2c_adapter_names);
 		i2c_addrs => [0x28..0x2f],
 		i2c_detect => sub { lm80_detect(@_, 1); },
 	}, {
+		name => "TI / National Semiconductor ADC128D818",
+		driver => "adc128d818",
+		i2c_addrs => [0x1d, 0x1e, 0x1f, 0x2d, 0x2e, 0x2f],
+		i2c_detect => sub { adc128d818_detect(@_); },
+	}, {
 		name => "National Semiconductor LM85",
 		driver => "lm85",
 		i2c_addrs => [0x2c..0x2e],
@@ -4437,7 +4442,7 @@ sub lm92_detect
 # Registers used:
 #   0x00: Configuration register
 #   0x02: Interrupt state register
-#   0x07: Converstion rate register (LM96080 only)
+#   0x07: Conversion rate register (LM96080 only)
 #   0x2a-0x3d: Limits registers (LM80 only)
 #   0x3e: Manufacturer's ID register (LM96080 only)
 #   0x3f: Stepping/die revision ID register (LM96080 only)
@@ -4502,6 +4507,32 @@ sub lm80_detect
 }
 
 # Registers used:
+#   0x00: Configuration register
+#   0x07: Conversion rate register
+#   0x09: Oneshot register
+#   0x0a: Shutdown register
+#   0x0b: Advanced Configuration register
+#   0x0c: Busy Status register
+#   0x3e: Manufacturer's ID register
+#   0x3f: Stepping/die revision ID register
+sub adc128d818_detect
+{
+	my ($file, $addr) = @_;
+
+	return if i2c_smbus_read_byte_data($file, 0x3e) != 0x01;
+	return if i2c_smbus_read_byte_data($file, 0x3f) != 0x09;
+
+	return if (i2c_smbus_read_byte_data($file, 0x00) & 0xf4) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x07) & 0xfe) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x09) & 0xfe) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x0a) & 0xfe) != 0;

prog/detect/sensors-detect sub lm80_detect · line 4538

Quoted 10 lines
prog/detect/sensors-detect +7 -0
+	return if (i2c_smbus_read_byte_data($file, 0x0b) & 0xf8) != 0;
+	return if (i2c_smbus_read_byte_data($file, 0x0c) & 0xfc) != 0;
+
+	return 7;
+}
+
+# Registers used:
 #   0x02: Status 1
 #   0x03: Configuration
 #   0x04: Company ID of LM84

Looks good to me, please commit.

Signature · 6 lines
Jean Delvare

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

PATCH v2 1/1 sensors-detect: Add detection of NCT7802Y

In reply to Per Dalén

---
v2: Don't attempt to detect chip if register bank 1 is selected.
Document all used registers.

 CHANGES                    |  1 +
 prog/detect/sensors-detect | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
CHANGES +1 -0
index 3390942..a16e7be 100644
@@ -13,6 +13,7 @@ SVN HEAD
                   Add detection of ITE IT8620E and IT8623E
                   Add detection of TMP441, TMP442, LM95233, LM95234,
                   and LM95235
+                  Add detection of NCT7802Y
 
 3.3.5 "Happy Birthday Beddy" (2014-01-22)
   libsensors: Improve documentation of two functions
prog/detect/sensors-detect +46 -0

58 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
#11 lore raw

Re: [lm-sensors] [PATCH v2] sensors-detect: Add detection of NCT7802Y

In reply to Per Dalén
Quoted 38 lines · Guenter Roeck

---
v2: Don't attempt to detect chip if register bank 1 is selected.
Document all used registers.

 CHANGES                    |  1 +
 prog/detect/sensors-detect | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
CHANGES +1 -0
index 3390942..a16e7be 100644
@@ -13,6 +13,7 @@ SVN HEAD
                   Add detection of ITE IT8620E and IT8623E
                   Add detection of TMP441, TMP442, LM95233, LM95234,
                   and LM95235
+                  Add detection of NCT7802Y
 
 3.3.5 "Happy Birthday Beddy" (2014-01-22)
   libsensors: Improve documentation of two functions
prog/detect/sensors-detect +5 -0
index 1208f4d..719c6dc 100755
@@ -733,6 +733,11 @@ use vars qw(@i2c_adapter_names);
 		i2c_addrs => [0x2c..0x2f],
 		i2c_detect => sub { w83795_detect(@_); },
 	}, {
+		name => "Nuvoton NCT7802Y",
+		driver => "to-be-written",
+		i2c_addrs => [0x28..0x2f],
+		i2c_detect => sub { nct7802_detect(@_); },
+	}, {
 		name => "Winbond W83627HF",
 		driver => "use-isa-instead",
 		i2c_addrs => [0x28..0x2f],

prog/detect/sensors-detect sub w83795_detect · line 5491

Quoted 4 lines
prog/detect/sensors-detect +1 -0
@@ -5483,6 +5488,47 @@ sub w83795_detect
 }
 
 # Registers used:
+#   0x00: Bank selection (Bank 0, 1)

Not sure the "(Bank 0, 1)" makes much sense any longer.

Looks good otherwise, feel free to commit.

Quoted 43 lines
prog/detect/sensors-detect +40 -0
+#   0x05: Temperature readout register LSB (Bank 0)
+#   0x08: PECI temperature readout register LSB (Bank 0)
+#   0x0f: Voltage readout register LSB (Bank 0)
+#   0xfd: Vendor ID (Bank 0)
+#   0xfe: Device ID (Bank 0)
+#   0xff: Device Revision (Bank 0)
+#
+# Note that identification registers are not accessible in bank 1,
+# and there is no usable other means to identify the chip if bank 1
+# is selected. Only detect chip if bank 0 is selected.
+sub nct7802_detect
+{
+	my ($bank, $reg);
+	my ($file, $addr) = @_;
+
+	$bank = i2c_smbus_read_byte_data($file, 0x00);
+	return unless $bank = 0x00;
+
+	$reg = i2c_smbus_read_byte_data($file, 0xfd);
+	return unless $reg = 0x50;
+
+	$reg = i2c_smbus_read_byte_data($file, 0xfe);
+	return unless $reg = 0xc3;
+
+	$reg = i2c_smbus_read_byte_data($file, 0xff);
+	return unless ($reg & 0xf0) = 0x20;
+
+	$reg = i2c_smbus_read_byte_data($file, 0x05);
+	return unless ($reg & 0x1f) = 0x00;
+
+	$reg = i2c_smbus_read_byte_data($file, 0x08);
+	return unless ($reg & 0x3f) = 0x00;
+
+	$reg = i2c_smbus_read_byte_data($file, 0x0f);
+	return unless ($reg & 0x3f) = 0x00;
+
+	return 8;
+}
+
+# Registers used:
 #   0x48: Full I2C Address
 #   0x4e: Vendor ID byte selection
 #   0x4f: Vendor ID
Signature · 7 lines
Jean Delvare
SUSE L3 Support

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

Re: [lm-sensors] [PATCH v2] sensors-detect: Add detection of NCT7802Y

In reply to Per Dalén
Quoted 5 lines · Jean Delvare
Quoted 4 lines · Guenter Roeck

---
v2: Don't attempt to detect chip if register bank 1 is selected.
Document all used registers.

...

Quoted 6 lines
Quoted 3 lines

# Registers used:
+# 0x00: Bank selection (Bank 0, 1)

Not sure the "(Bank 0, 1)" makes much sense any longer.

On the other side, it doesn't hurt, so I left it in.

Quoted 2 lines

Looks good otherwise, feel free to commit.

Thanks!

Guenter

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