All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of MCP98244
@ 2013-01-29  4:40 Guenter Roeck
  2013-03-16 18:30 ` [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of TMP431 and TMP432 Guenter Roeck
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Guenter Roeck @ 2013-01-29  4:40 UTC (permalink / raw)
  To: lm-sensors

MCP98244 is a JC42 temperature sensor.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 CHANGES                    |    3 ++-
 prog/detect/sensors-detect |   13 ++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/CHANGES b/CHANGES
index 465bd61..90e1e89 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,7 +4,8 @@ lm-sensors CHANGES file
 SVN HEAD
   sensors.conf.5: Mention "sensors -u" to get the raw feature names
   sensors: Clarify what option -u is good for
-  sensors-detect: Add detection of IT8752F
+  sensors-detect: Add detection of MCP98244
+                  Add detection of IT8752F
                   Add detection of AMD family 16h power sensors
                   Map IT8771E, IT8772E, IT8782F and IT8783F to it87
                   Use /sys/module instead of /proc/modules where available
diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
index 59378c2..7db4812 100755
--- a/prog/detect/sensors-detect
+++ b/prog/detect/sensors-detect
@@ -1400,6 +1400,11 @@ use vars qw(@i2c_adapter_names);
 		i2c_addrs => [0x18..0x1f],
 		i2c_detect => sub { jedec_JC42_4_detect(@_, 7); },
 	}, {
+		name => "Microchip MCP98244",
+		driver => "jc42",
+		i2c_addrs => [0x18..0x1f],
+		i2c_detect => sub { jedec_JC42_4_detect(@_, 15); },
+	}, {
 		name => "Microchip MCP9843",
 		driver => "jc42",
 		i2c_addrs => [0x18..0x1f],
@@ -6058,7 +6063,7 @@ sub max6655_detect
 #                 4 = TS3000/TSE2002, 5 = MAX6604, 6 = MCP98242,
 #                 7 = MCP98243, 8 = MCP9843, 9 = CAT6095 / CAT34TS02,
 #                 10 = STTS424E, 11 = STTS2002, 12 = STTS3000
-#                 13 = MCP9804, 14 = AT30TS00
+#                 13 = MCP9804, 14 = AT30TS00, 15 = MCP98244
 # Registers used:
 #   0x00: Capabilities
 #   0x01: Configuration
@@ -6127,6 +6132,9 @@ sub jedec_JC42_4_detect
 	} elsif ($chip = 14) {
 		return unless $manid = 0x00;		# Atmel
 		return unless $devid = 0x82;		# AT30TS00
+	} elsif ($chip = 15) {
+		return unless $manid = 0x00;		# MCP
+		return unless $devid = 0x22;		# MCP98244
 	}
 
 	# Now, do it all again with words. Note that we get
@@ -6184,6 +6192,9 @@ sub jedec_JC42_4_detect
 	} elsif ($chip = 14) {
 		return unless $manid = 0x1f00;		# Atmel
 		return unless ($devid & 0xfeff) = 0x0082; # AT30TS00
+	} elsif ($chip = 15) {
+		return unless $manid = 0x5400;		# MCP
+		return unless ($devid & 0xfcff) = 0x0022; # MCP98244
 	}
 
 	return 5;
-- 
1.7.9.7


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of TMP431 and TMP432
  2013-01-29  4:40 [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of MCP98244 Guenter Roeck
@ 2013-03-16 18:30 ` Guenter Roeck
  2013-03-17 13:12 ` Jean Delvare
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2013-03-16 18:30 UTC (permalink / raw)
  To: lm-sensors

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 CHANGES                    |    1 +
 prog/detect/sensors-detect |   24 +++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/CHANGES b/CHANGES
index 51ac3c8..ba6409f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,7 @@ SVN HEAD
                   Add detection of IT8752F
                   Add detection of MCP98244
                   Add detection of LM95234
+                  Add detection of TMP431/TMP432
 
 3.3.3 "Happy Birthday Sophie" (2012-11-06)
   documentation: Update fan-divisors, fan divisors are optional
diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
index f238802..00e3904 100755
--- a/prog/detect/sensors-detect
+++ b/prog/detect/sensors-detect
@@ -1023,6 +1023,16 @@ use vars qw(@i2c_adapter_names);
 		i2c_addrs => [0x4c, 0x4d],
 		i2c_detect => sub { tmp42x_detect(@_, 2); },
 	}, {
+		name => "Texas Instruments TMP431",
+		driver => "to-be-written",		# tmp401
+		i2c_addrs => [0x4c, 0x4d],
+		i2c_detect => sub { lm90_detect(@_, 16); },
+	}, {
+		name => "Texas Instruments TMP432",
+		driver => "to-be-written",		# tmp401
+		i2c_addrs => [0x4c, 0x4d],
+		i2c_detect => sub { lm90_detect(@_, 17); },
+	}, {
 		name => "Texas Instruments AMC6821",
 		driver => "amc6821",
 		i2c_addrs => [0x18..0x1a, 0x2c..0x2e, 0x4c..0x4e],
@@ -4537,7 +4547,7 @@ sub max6680_95_detect
 #		  8 = W83L771W/G, 9 = TMP401, 10 = TMP411,
 #		  11 = W83L771AWG/ASG, 12 = MAX6690,
 #		  13 = ADT7461A/NCT1008, 14 = SA56004,
-#		  15 = G781
+#		  15 = G781, 16 = TMP431, 17 = TMP432
 # Registers used:
 #   0x03: Configuration
 #   0x04: Conversion rate
@@ -4655,6 +4665,18 @@ sub lm90_detect
 		return if $mid != 0x47;		# GMT
 		return 8 if $cid = 0x01;	# G781
 	}
+	if ($chip = 16) {
+		return if ($conf & 0x1B) != 0;
+		return if $rate > 0x0F;
+		return if $mid != 0x55;		# Texas Instruments
+		return 6 if ($cid = 0x31);	# TMP431A/B/C/D
+	}
+	if ($chip = 17) {
+		return if ($conf & 0x1B) != 0;
+		return if $rate > 0x0F;
+		return if $mid != 0x55;		# Texas Instruments
+		return 6 if ($cid = 0x32);	# TMP432A/B
+	}
 	return;
 }
 
-- 
1.7.9.7


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of TMP431 and TMP432
  2013-01-29  4:40 [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of MCP98244 Guenter Roeck
  2013-03-16 18:30 ` [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of TMP431 and TMP432 Guenter Roeck
@ 2013-03-17 13:12 ` Jean Delvare
  2014-06-25 20:42 ` [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of NCT7802Y Guenter Roeck
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2013-03-17 13:12 UTC (permalink / raw)
  To: lm-sensors

On Sat, 16 Mar 2013 11:30:53 -0700, Guenter Roeck wrote:
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  CHANGES                    |    1 +
>  prog/detect/sensors-detect |   24 +++++++++++++++++++++++-
>  2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/CHANGES b/CHANGES
> index 51ac3c8..ba6409f 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -12,6 +12,7 @@ SVN HEAD
>                    Add detection of IT8752F
>                    Add detection of MCP98244
>                    Add detection of LM95234
> +                  Add detection of TMP431/TMP432
>  
>  3.3.3 "Happy Birthday Sophie" (2012-11-06)
>    documentation: Update fan-divisors, fan divisors are optional
> diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
> index f238802..00e3904 100755
> --- a/prog/detect/sensors-detect
> +++ b/prog/detect/sensors-detect
> @@ -1023,6 +1023,16 @@ use vars qw(@i2c_adapter_names);
>  		i2c_addrs => [0x4c, 0x4d],
>  		i2c_detect => sub { tmp42x_detect(@_, 2); },
>  	}, {
> +		name => "Texas Instruments TMP431",
> +		driver => "to-be-written",		# tmp401
> +		i2c_addrs => [0x4c, 0x4d],
> +		i2c_detect => sub { lm90_detect(@_, 16); },
> +	}, {
> +		name => "Texas Instruments TMP432",
> +		driver => "to-be-written",		# tmp401
> +		i2c_addrs => [0x4c, 0x4d],
> +		i2c_detect => sub { lm90_detect(@_, 17); },
> +	}, {
>  		name => "Texas Instruments AMC6821",
>  		driver => "amc6821",
>  		i2c_addrs => [0x18..0x1a, 0x2c..0x2e, 0x4c..0x4e],
> @@ -4537,7 +4547,7 @@ sub max6680_95_detect
>  #		  8 = W83L771W/G, 9 = TMP401, 10 = TMP411,
>  #		  11 = W83L771AWG/ASG, 12 = MAX6690,
>  #		  13 = ADT7461A/NCT1008, 14 = SA56004,
> -#		  15 = G781
> +#		  15 = G781, 16 = TMP431, 17 = TMP432
>  # Registers used:
>  #   0x03: Configuration
>  #   0x04: Conversion rate
> @@ -4655,6 +4665,18 @@ sub lm90_detect
>  		return if $mid != 0x47;		# GMT
>  		return 8 if $cid = 0x01;	# G781
>  	}
> +	if ($chip = 16) {
> +		return if ($conf & 0x1B) != 0;
> +		return if $rate > 0x0F;
> +		return if $mid != 0x55;		# Texas Instruments
> +		return 6 if ($cid = 0x31);	# TMP431A/B/C/D
> +	}
> +	if ($chip = 17) {
> +		return if ($conf & 0x1B) != 0;
> +		return if $rate > 0x0F;
> +		return if $mid != 0x55;		# Texas Instruments
> +		return 6 if ($cid = 0x32);	# TMP432A/B
> +	}
>  	return;
>  }
>  

Looks good, please commit.

BTW, please use ISO8601 date format in wiki/Devices. MM/DD/YYYY as you
used is potentially ambiguous.

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of NCT7802Y
  2013-01-29  4:40 [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of MCP98244 Guenter Roeck
  2013-03-16 18:30 ` [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of TMP431 and TMP432 Guenter Roeck
  2013-03-17 13:12 ` Jean Delvare
@ 2014-06-25 20:42 ` Guenter Roeck
  2014-06-25 20:45 ` Guenter Roeck
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2014-06-25 20:42 UTC (permalink / raw)
  To: lm-sensors

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 CHANGES                    |  1 +
 prog/detect/sensors-detect | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/CHANGES b/CHANGES
index 3390942..a16e7be 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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
diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
index df9a408..159d2cb 100755
--- a/prog/detect/sensors-detect
+++ b/prog/detect/sensors-detect
@@ -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],
@@ -5483,6 +5488,69 @@ sub w83795_detect
 }
 
 # Registers used:
+#   0x00: bank selection (Bank 0, 1)
+#   0x40, 0x80, 0xc0: bank selection (Bank 1)
+#   0x01, 0x41, 0x81, 0xc1: PECI control register 1 (Bank 1)
+#   0x02, 0x42, 0x82, 0xc2: PECI control register 2 (Bank 1)
+#   0x03, 0x43, 0x83, 0xc3: PECI control register 3 (Bank 1)
+#   0xfd: Vendor ID (Bank 0)
+#   0xfe: Device ID (Bank 0)
+#   0xff: Device Revision (Bank 0)
+sub nct7802_detect
+{
+	my ($bank, $reg, $pc1, $pc2, $pc3);
+	my ($file, $addr) = @_;
+
+	$bank = i2c_smbus_read_byte_data($file, 0x00);
+	return unless ($bank = 0x00 or $bank = 0x01);
+
+	# we can not do much if bank 1 is selected
+	if ($bank = 0x01) {
+		# We can not use bit masks since all bits
+		# (including reserved bits) can be set.
+		$pc1 = i2c_smbus_read_byte_data($file, 0x01);
+		$pc2 = i2c_smbus_read_byte_data($file, 0x02);
+		$pc3 = i2c_smbus_read_byte_data($file, 0x03);
+
+		# Register values repeat every 64 registers on bank 1.
+		# Check the first four registers of each group.
+		for (my $i = 0x40; $i <= 0xc0; $i += 0x40) {
+			$reg = i2c_smbus_read_byte_data($file, $i);
+			return if $reg != 0x01;
+			$reg = i2c_smbus_read_byte_data($file, $i + 1);
+			return if $reg != $pc1;
+			$reg = i2c_smbus_read_byte_data($file, $i + 2);
+			return if $reg != $pc2;
+			$reg = i2c_smbus_read_byte_data($file, $i + 3);
+			return if $reg != $pc3;
+		}
+		return 3;
+	}
+
+	# bank 0, can support real chip detection
+
+	$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
-- 
1.9.1


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of NCT7802Y
  2013-01-29  4:40 [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of MCP98244 Guenter Roeck
                   ` (2 preceding siblings ...)
  2014-06-25 20:42 ` [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of NCT7802Y Guenter Roeck
@ 2014-06-25 20:45 ` Guenter Roeck
  2014-06-26  9:40 ` Jean Delvare
  2014-06-26 13:13 ` Guenter Roeck
  5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2014-06-25 20:45 UTC (permalink / raw)
  To: lm-sensors

On Wed, Jun 25, 2014 at 01:42:26PM -0700, Guenter Roeck wrote:
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  CHANGES                    |  1 +
>  prog/detect/sensors-detect | 68 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 69 insertions(+)
> 

Register maps for NCT7802Y:

Bank 0:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 00 3f 00 00 2d 20 2e 00 00 ce d7 00 83 96 d3 00    .?..- ...??.???.
10: ff ff ff f8 00 64 00 00 00 00 00 00 00 11 00 00    ...?.d.......?..
20: 00 81 7d 03 03 03 03 03 00 04 ee 80 f4 32 40 00    .?}?????.????2@.
30: 55 00 55 00 55 00 55 00 55 00 64 64 64 64 64 ff    U.U.U.U.U.ddddd.
40: 00 ff 00 ff 00 ff 00 cc cc ff ff ff f8 f8 f8 7f    .......??...????
50: 3f 07 8f bf 3f 00 3f 00 00 00 00 00 00 00 00 00    ?????.?.........
60: 00 00 7f 00 21 00 00 00 44 00 00 00 d1 02 01 01    ..?.!...D...????
70: 7f 84 84 84 53 53 53 80 0a 00 80 00 00 ff ff ff    ????SSS??.?.....
80: 3b 3c 4b 5a 5f 00 4c a5 ff ff ff ff ff ff ff ff    ;<KZ_.L?........
90: 3b 3c 4b 5a 5f 00 4c a5 ff ff ff ff ff ff ff ff    ;<KZ_.L?........
a0: 36 37 43 4f 5f 00 b2 d8 ff ff ff ff ff ff ff ff    67CO_.??........
b0: 47 00 00 00 00 00 00 00 00 00 ff ff ff ff 00 0b    G..............?
c0: 00 08 3d 3d 00 00 00 39 33 33 ff 00 00 00 40 00    .?=...933....@.
d0: 00 aa 0a 0a 0a 0a 02 f2 81 1e 00 18 07 41 7f 70    .?????????.??A?p
e0: e4 00 00 00 00 00 00 00 00 00 00 00 00 00 10 f0    ?.............??
f0: 00 30 00 ff 00 05 ff ff 00 08 07 01 ff 50 c3 21    .0...?...???.P?!

Bank 1:
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 01 91 00 30 00 00 00 00 00 64 64 00 00 00 00 00    ??.0.....dd.....
10: 00 00 00 00 00 00 00 f2 92 f8 80 f8 80 f8 80 01    .......?????????
20: 2e 01 06 00 02 09 00 1b 00 f9 00 00 00 00 00 00    .??.??.?.?......
30: 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
40: 01 91 00 30 00 00 00 00 00 64 64 00 00 00 00 00    ??.0.....dd.....
50: 00 00 00 00 00 00 00 f2 ab f8 80 f8 80 f8 80 01    .......?????????
60: 2e 02 06 00 02 09 00 5f 00 f9 00 00 00 00 00 00    .??.??._.?......
70: 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
80: 01 91 00 30 00 00 00 00 00 64 64 00 00 00 00 00    ??.0.....dd.....
90: 00 00 00 00 00 00 00 f2 ab f8 80 f8 80 f8 80 01    .......?????????
a0: 2e 02 06 00 02 09 00 5f 00 f9 00 00 00 00 00 00    .??.??._.?......
b0: 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
c0: 01 91 00 30 00 00 00 00 00 64 64 00 00 00 00 00    ??.0.....dd.....
d0: 00 00 00 00 00 00 00 f2 ab f8 80 f8 80 f8 80 01    .......?????????
e0: 2e 02 06 00 02 09 00 5f 00 f9 00 00 00 00 00 00    .??.??._.?......
f0: 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff    ................

Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of NCT7802Y
  2013-01-29  4:40 [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of MCP98244 Guenter Roeck
                   ` (3 preceding siblings ...)
  2014-06-25 20:45 ` Guenter Roeck
@ 2014-06-26  9:40 ` Jean Delvare
  2014-06-26 13:13 ` Guenter Roeck
  5 siblings, 0 replies; 7+ messages in thread
From: Jean Delvare @ 2014-06-26  9:40 UTC (permalink / raw)
  To: lm-sensors

Hi Guenter,

On Wed, 25 Jun 2014 13:42:26 -0700, Guenter Roeck wrote:
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  CHANGES                    |  1 +
>  prog/detect/sensors-detect | 68 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 69 insertions(+)
> 
> diff --git a/CHANGES b/CHANGES
> index 3390942..a16e7be 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -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
> diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
> index df9a408..159d2cb 100755
> --- a/prog/detect/sensors-detect
> +++ b/prog/detect/sensors-detect
> @@ -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],
> @@ -5483,6 +5488,69 @@ sub w83795_detect
>  }
>  
>  # Registers used:
> +#   0x00: bank selection (Bank 0, 1)
> +#   0x40, 0x80, 0xc0: bank selection (Bank 1)
> +#   0x01, 0x41, 0x81, 0xc1: PECI control register 1 (Bank 1)
> +#   0x02, 0x42, 0x82, 0xc2: PECI control register 2 (Bank 1)
> +#   0x03, 0x43, 0x83, 0xc3: PECI control register 3 (Bank 1)
> +#   0xfd: Vendor ID (Bank 0)
> +#   0xfe: Device ID (Bank 0)
> +#   0xff: Device Revision (Bank 0)
> +sub nct7802_detect
> +{
> +	my ($bank, $reg, $pc1, $pc2, $pc3);
> +	my ($file, $addr) = @_;
> +
> +	$bank = i2c_smbus_read_byte_data($file, 0x00);
> +	return unless ($bank = 0x00 or $bank = 0x01);
> +
> +	# we can not do much if bank 1 is selected
> +	if ($bank = 0x01) {
> +		# We can not use bit masks since all bits
> +		# (including reserved bits) can be set.
> +		$pc1 = i2c_smbus_read_byte_data($file, 0x01);
> +		$pc2 = i2c_smbus_read_byte_data($file, 0x02);
> +		$pc3 = i2c_smbus_read_byte_data($file, 0x03);
> +
> +		# Register values repeat every 64 registers on bank 1.
> +		# Check the first four registers of each group.
> +		for (my $i = 0x40; $i <= 0xc0; $i += 0x40) {
> +			$reg = i2c_smbus_read_byte_data($file, $i);
> +			return if $reg != 0x01;
> +			$reg = i2c_smbus_read_byte_data($file, $i + 1);
> +			return if $reg != $pc1;
> +			$reg = i2c_smbus_read_byte_data($file, $i + 2);
> +			return if $reg != $pc2;
> +			$reg = i2c_smbus_read_byte_data($file, $i + 3);
> +			return if $reg != $pc3;
> +		}
> +		return 3;
> +	}

Bah. I discussed the need to have the identification registers in
non-banked registers with Winbond/Nuvoton engineers years ago, and it
looked like they did listen to me with the W83795G/ADG, but now they
are doing it all wrong again :-(

The above is simply too weak, I'm afraid. Chips cycling over 8, 16, 32
or 64 register addresses are legions. Just from my register dump
collection, the LM80 and the VIA 686A chips would both be detected by
the loop above. There may be more, in particular if Nuvoton keeps using
the same strategy for future chips.

So I would say, just skip the detection if the chip is in bank 1. Let's
hope the BIOS will leave the chip in bank 0. When we have a driver for
that chip, we'll make sure to leave the chip in bank 0 too.

> +
> +	# bank 0, can support real chip detection
> +
> +	$reg = i2c_smbus_read_byte_data($file, 0xfd);
> +	return unless ($reg = 0x50);

Unneeded parentheses.

> +
> +	$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;

You did not say above, what these last 3 registers were. Also I am
surprised because checking these is in contradiction with your statement
above that "we can not use bit masks since all bits (including reserved
bits) can be set."

> +
> +	return 8;
> +}
> +
> +# Registers used:
>  #   0x48: Full I2C Address
>  #   0x4e: Vendor ID byte selection
>  #   0x4f: Vendor ID


-- 
Jean Delvare
SUSE L3 Support

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of NCT7802Y
  2013-01-29  4:40 [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of MCP98244 Guenter Roeck
                   ` (4 preceding siblings ...)
  2014-06-26  9:40 ` Jean Delvare
@ 2014-06-26 13:13 ` Guenter Roeck
  5 siblings, 0 replies; 7+ messages in thread
From: Guenter Roeck @ 2014-06-26 13:13 UTC (permalink / raw)
  To: lm-sensors

On 06/26/2014 02:40 AM, Jean Delvare wrote:
> Hi Guenter,
>
> On Wed, 25 Jun 2014 13:42:26 -0700, Guenter Roeck wrote:
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>   CHANGES                    |  1 +
>>   prog/detect/sensors-detect | 68 ++++++++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 69 insertions(+)
>>
>> diff --git a/CHANGES b/CHANGES
>> index 3390942..a16e7be 100644
>> --- a/CHANGES
>> +++ b/CHANGES
>> @@ -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
>> diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
>> index df9a408..159d2cb 100755
>> --- a/prog/detect/sensors-detect
>> +++ b/prog/detect/sensors-detect
>> @@ -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],
>> @@ -5483,6 +5488,69 @@ sub w83795_detect
>>   }
>>
>>   # Registers used:
>> +#   0x00: bank selection (Bank 0, 1)
>> +#   0x40, 0x80, 0xc0: bank selection (Bank 1)
>> +#   0x01, 0x41, 0x81, 0xc1: PECI control register 1 (Bank 1)
>> +#   0x02, 0x42, 0x82, 0xc2: PECI control register 2 (Bank 1)
>> +#   0x03, 0x43, 0x83, 0xc3: PECI control register 3 (Bank 1)
>> +#   0xfd: Vendor ID (Bank 0)
>> +#   0xfe: Device ID (Bank 0)
>> +#   0xff: Device Revision (Bank 0)
>> +sub nct7802_detect
>> +{
>> +	my ($bank, $reg, $pc1, $pc2, $pc3);
>> +	my ($file, $addr) = @_;
>> +
>> +	$bank = i2c_smbus_read_byte_data($file, 0x00);
>> +	return unless ($bank = 0x00 or $bank = 0x01);
>> +
>> +	# we can not do much if bank 1 is selected
>> +	if ($bank = 0x01) {
>> +		# We can not use bit masks since all bits
>> +		# (including reserved bits) can be set.
>> +		$pc1 = i2c_smbus_read_byte_data($file, 0x01);
>> +		$pc2 = i2c_smbus_read_byte_data($file, 0x02);
>> +		$pc3 = i2c_smbus_read_byte_data($file, 0x03);
>> +
>> +		# Register values repeat every 64 registers on bank 1.
>> +		# Check the first four registers of each group.
>> +		for (my $i = 0x40; $i <= 0xc0; $i += 0x40) {
>> +			$reg = i2c_smbus_read_byte_data($file, $i);
>> +			return if $reg != 0x01;
>> +			$reg = i2c_smbus_read_byte_data($file, $i + 1);
>> +			return if $reg != $pc1;
>> +			$reg = i2c_smbus_read_byte_data($file, $i + 2);
>> +			return if $reg != $pc2;
>> +			$reg = i2c_smbus_read_byte_data($file, $i + 3);
>> +			return if $reg != $pc3;
>> +		}
>> +		return 3;
>> +	}
>
> Bah. I discussed the need to have the identification registers in
> non-banked registers with Winbond/Nuvoton engineers years ago, and it
> looked like they did listen to me with the W83795G/ADG, but now they
> are doing it all wrong again :-(
>
> The above is simply too weak, I'm afraid. Chips cycling over 8, 16, 32
> or 64 register addresses are legions. Just from my register dump
> collection, the LM80 and the VIA 686A chips would both be detected by
> the loop above. There may be more, in particular if Nuvoton keeps using
> the same strategy for future chips.
>
> So I would say, just skip the detection if the chip is in bank 1. Let's
> hope the BIOS will leave the chip in bank 0. When we have a driver for
> that chip, we'll make sure to leave the chip in bank 0 too.
>
Ok with me. I didn't feel comfortable with it either.

>> +
>> +	# bank 0, can support real chip detection
>> +
>> +	$reg = i2c_smbus_read_byte_data($file, 0xfd);
>> +	return unless ($reg = 0x50);
>
> Unneeded parentheses.
>
Ok.

>> +
>> +	$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;
>
> You did not say above, what these last 3 registers were. Also I am
> surprised because checking these is in contradiction with your statement
> above that "we can not use bit masks since all bits (including reserved
> bits) can be set."
>
That only applies to the bank 1 registers. The above registers are read-only.
Or at least I hope so - I'll test with the real chip to make sure.

I'll add the documentation and re-submit.

Thanks,
Guenter


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-26 13:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-29  4:40 [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of MCP98244 Guenter Roeck
2013-03-16 18:30 ` [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of TMP431 and TMP432 Guenter Roeck
2013-03-17 13:12 ` Jean Delvare
2014-06-25 20:42 ` [lm-sensors] [PATCH 2/2] sensors-detect: Add detection of NCT7802Y Guenter Roeck
2014-06-25 20:45 ` Guenter Roeck
2014-06-26  9:40 ` Jean Delvare
2014-06-26 13:13 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.