Skip to contentSkip to conversation

lm-sensors: add detection for non-standard

PATCH Superseded Juerg Haefliger 2 participants 3 messages Jun 20, 2007 – Jun 25, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lm-sensors: add detection for non-standard

This patch adds detection logic for non-standard SMSC Super I/Os. These chips have their device ID register at address 0x0d rather than 0x20.

Signed-off-by Juerg Haefliger <juergh at gmail.com>
prog/detect/sensors-detect +70 -0
@@ -1832,6 +1832,38 @@ use vars qw(@chip_kern24_ids @chip_kern2
 	devid => 0x77,
       },
     ],
+    # Non-standard SMSC detection callback and chip list. These chips differ
+    # from the standard ones listed above in that the device ID register 
+    # address is 0x0d instead of 0x20 (as specified by the ISA PNP spec).
+    ns_detect => \&smsc_ns_detect_superio,
+    ns_chips =>
+    [
+      {
+	name => "SMSC FDC37C665 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x65,
+      },
+      {
+	name => "SMSC FDC37C666 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x66,
+      },
+      {
+	name => "SMSC FDC37C669 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x03,
+      },
+      {
+	name => "SMSC FDC37N769 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x28,
+      },
+      {
+	name => "SMSC LPC47N227 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x5a,
+      },
+    ],
   },
   {
     family => "VIA/Winbond/Fintek",
@@ -3189,6 +3221,38 @@ sub probe_superio($$$)
                                         $new_hash;
 }
 
+# Detection routine for non-standard SMSC Super I/O chips
+# $_[0]: Super I/O LPC address port
+# $_[1]: Super I/O LPC data port
+# $_[2]: Reference to chip family hash
+sub smsc_ns_detect_superio
+{
+    my ($addrreg, $datareg, $family) = @_;
+    my ($val, $found);
+
+    # read alternate device ID register
+    outb($addrreg, 0x0d);
+    $val = inb($datareg);
+    if ($val == 0x00 || $val == 0xff) {
+	return 0;
+    }
+    # read revision   
+    outb($addrreg, 0x0e);
+    $val = ($val << 8) | inb($datareg);
+
+    print "Yes\n";
+
+    foreach my $chip (@{$family->{ns_chips}}) {
+	if ($chip->{devid} == ($val >> 8)) {
+	    probe_superio($addrreg, $datareg, $chip);
+	    return 1;
+	}
+    }
+
+    printf("Found unknown non-standard chip with ID 0x%04x\n", $val);
+    return 1;
+}
+
 sub scan_superio
 {
   my ($addrreg, $datareg) = @_;
@@ -3206,6 +3270,12 @@ sub scan_superio
     foreach $val (@{$family->{enter}->{$addrreg}}) {
       outb($addrreg, $val);
     }
+# call the non-standard detection routine first if it exists
+    if (defined($family->{ns_detect}) && 
+	&{$family->{ns_detect}}($addrreg, $datareg, $family)) {
+	exit_superio($addrreg, $datareg);
+	last FAMILY;
+    }
 # did it work?
     outb($addrreg, $superio{devidreg});
     $val = inb($datareg);

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

#1 lore raw

Hi Juerg,

Quoted 5 lines · Juerg Haefliger

This patch adds detection logic for non-standard SMSC Super I/Os. These chips have their device ID register at address 0x0d rather than 0x20.

Signed-off-by Juerg Haefliger <juergh at gmail.com>

I don't know what you and others think, but personally I prefer this version over the previous one.

Comments:

Quoted 31 lines
prog/detect/sensors-detect +25 -0
@@ -1832,6 +1832,38 @@ use vars qw(@chip_kern24_ids @chip_kern2
 	devid => 0x77,
       },
     ],
+    # Non-standard SMSC detection callback and chip list. These chips differ
+    # from the standard ones listed above in that the device ID register 
+    # address is 0x0d instead of 0x20 (as specified by the ISA PNP spec).
+    ns_detect => \&smsc_ns_detect_superio,
+    ns_chips =>
+    [
+      {
+	name => "SMSC FDC37C665 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x65,
+      },
+      {
+	name => "SMSC FDC37C666 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x66,
+      },
+      {
+	name => "SMSC FDC37C669 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x03,
+      },
+      {
+	name => "SMSC FDC37N769 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x28,

prog/detect/sensors-detect use vars qw(@chip_kern24_ids @chip_kern2 · line 1869

Quoted 10 lines
prog/detect/sensors-detect +7 -0
+      },
+      {
+	name => "SMSC LPC47N227 Super IO",
+	driver => "not-a-sensor",
+	devid => 0x5a,
+      },
+    ],
   },
   {
     family => "VIA/Winbond/Fintek",

Originally I didn't expect this non-standard list to be embedded in the main list, but after all, maybe it's a good idea to have all the declarations in the same place.

prog/detect/sensors-detect sub probe_superio($$$) · line 3227

Quoted 8 lines
prog/detect/sensors-detect +4 -0
@@ -3189,6 +3221,38 @@ sub probe_superio($$$)
                                         $new_hash;
 }
 
+# Detection routine for non-standard SMSC Super I/O chips
+# $_[0]: Super I/O LPC address port
+# $_[1]: Super I/O LPC data port
+# $_[2]: Reference to chip family hash

Maybe explain the return value convention too.

prog/detect/sensors-detect sub probe_superio($$$) · line 3231

Quoted 4 lines
prog/detect/sensors-detect +4 -0
+sub smsc_ns_detect_superio
+{
+    my ($addrreg, $datareg, $family) = @_;
+    my ($val, $found);

Unused variable $found.

prog/detect/sensors-detect sub probe_superio($$$) · line 3241

Quoted 10 lines
prog/detect/sensors-detect +10 -0
+
+    # read alternate device ID register
+    outb($addrreg, 0x0d);
+    $val = inb($datareg);
+    if ($val = 0x00 || $val = 0xff) {
+	return 0;
+    }
+    # read revision   
+    outb($addrreg, 0x0e);
+    $val = ($val << 8) | inb($datareg);

Why do you bother with the revision? You don't even use it for identification. Remember, we want this non-standard stuff to be as simple as possible.

Quoted 18 lines
prog/detect/sensors-detect +14 -0
+
+    print "Yes\n";
+
+    foreach my $chip (@{$family->{ns_chips}}) {
+	if ($chip->{devid} = ($val >> 8)) {
+	    probe_superio($addrreg, $datareg, $chip);
+	    return 1;
+	}
+    }
+
+    printf("Found unknown non-standard chip with ID 0x%04x\n", $val);
+    return 1;
+}
+
 sub scan_superio
 {
   my ($addrreg, $datareg) = @_;

prog/detect/sensors-detect sub scan_superio · line 3275

Quoted 6 lines
prog/detect/sensors-detect +3 -0
@@ -3206,6 +3270,12 @@ sub scan_superio
     foreach $val (@{$family->{enter}->{$addrreg}}) {
       outb($addrreg, $val);
     }
+# call the non-standard detection routine first if it exists
+    if (defined($family->{ns_detect}) && 
+	&{$family->{ns_detect}}($addrreg, $datareg, $family)) {

I'd suggest passing $family->{ns_chips} directly as the 3rd parameter. I can't think of a valid reason why you'd need access to the full family hash in the ns_detect callback.

prog/detect/sensors-detect sub scan_superio · line 3281

Quoted 6 lines
prog/detect/sensors-detect +3 -0
+	exit_superio($addrreg, $datareg);
+	last FAMILY;
+    }
 # did it work?
     outb($addrreg, $superio{devidreg});
     $val = inb($datareg);

Thanks,

Signature · 6 lines
Jean Delvare

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

Hi Jean,

Quoted 11 lines · Jean Delvare

Hi Juerg,

Quoted 5 lines · Juerg Haefliger

This patch adds detection logic for non-standard SMSC Super I/Os. These chips have their device ID register at address 0x0d rather than 0x20.

Signed-off-by Juerg Haefliger <juergh at gmail.com>

I don't know what you and others think, but personally I prefer this version over the previous one.

Yeah, looks kind of cleaner.

Quoted 52 lines

Comments:

Quoted 31 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +25 -0
@@ -1832,6 +1832,38 @@ use vars qw(@chip_kern24_ids @chip_kern2
      devid => 0x77,
       },
     ],
+    # Non-standard SMSC detection callback and chip list. These chips differ
+    # from the standard ones listed above in that the device ID register
+    # address is 0x0d instead of 0x20 (as specified by the ISA PNP spec).
+    ns_detect => \&smsc_ns_detect_superio,
+    ns_chips =>
+    [
+      {
+     name => "SMSC FDC37C665 Super IO",
+     driver => "not-a-sensor",
+     devid => 0x65,
+      },
+      {
+     name => "SMSC FDC37C666 Super IO",
+     driver => "not-a-sensor",
+     devid => 0x66,
+      },
+      {
+     name => "SMSC FDC37C669 Super IO",
+     driver => "not-a-sensor",
+     devid => 0x03,
+      },
+      {
+     name => "SMSC FDC37N769 Super IO",
+     driver => "not-a-sensor",
+     devid => 0x28,

prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 use vars qw(@chip_kern24_ids @chip_kern2 · line 1869

Quoted 10 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +7 -0
+      },
+      {
+     name => "SMSC LPC47N227 Super IO",
+     driver => "not-a-sensor",
+     devid => 0x5a,
+      },
+    ],
   },
   {
     family => "VIA/Winbond/Fintek",

Originally I didn't expect this non-standard list to be embedded in the main list, but after all, maybe it's a good idea to have all the declarations in the same place.

Quoted 4 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +0 -0
@@ -3189,6 +3221,38 @@ sub probe_superio($$$)
                                         $new_hash;
 }
 
Quoted 6 lines

prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 sub probe_superio($$$) · line 3227

Quoted 4 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +4 -0
+# Detection routine for non-standard SMSC Super I/O chips
+# $_[0]: Super I/O LPC address port
+# $_[1]: Super I/O LPC data port
+# $_[2]: Reference to chip family hash

Maybe explain the return value convention too.

OK.

Quoted 6 lines

prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 sub probe_superio($$$) · line 3231

Quoted 4 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +4 -0
+sub smsc_ns_detect_superio
+{
+    my ($addrreg, $datareg, $family) = @_;
+    my ($val, $found);

Unused variable $found.

Good catch.

Quoted 11 lines

prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 sub probe_superio($$$) · line 3241

Quoted 10 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +10 -0
+
+    # read alternate device ID register
+    outb($addrreg, 0x0d);
+    $val = inb($datareg);
+    if ($val = 0x00 || $val = 0xff) {
+     return 0;
+    }
+    # read revision
+    outb($addrreg, 0x0e);
+    $val = ($val << 8) | inb($datareg);
Quoted 3 lines

Why do you bother with the revision? You don't even use it for identification. Remember, we want this non-standard stuff to be as simple as possible.

OK, will drop it.

Quoted 20 lines
Quoted 20 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +14 -0
+
+    print "Yes\n";
+
+    foreach my $chip (@{$family->{ns_chips}}) {
+     if ($chip->{devid} = ($val >> 8)) {
+         probe_superio($addrreg, $datareg, $chip);
+         return 1;
+     }
+    }
+
+    printf("Found unknown non-standard chip with ID 0x%04x\n", $val);
+    return 1;
+}
+
 sub scan_superio
 {
   my ($addrreg, $datareg) = @_;
@@ -3206,6 +3270,12 @@ sub scan_superio
     foreach $val (@{$family->{enter}->{$addrreg}}) {
       outb($addrreg, $val);
Quoted 8 lines

prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 sub scan_superio · line 3275

Quoted 4 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +3 -0
     }
+# call the non-standard detection routine first if it exists
+    if (defined($family->{ns_detect}) &&
+     &{$family->{ns_detect}}($addrreg, $datareg, $family)) {

I'd suggest passing $family->{ns_chips} directly as the 3rd parameter. I can't think of a valid reason why you'd need access to the full family hash in the ns_detect callback.

OK.

Quoted 11 lines

prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 sub scan_superio · line 3281

Quoted 6 lines
prog/detect/sensors-detect 2007-06-20 08:17:26.201043000 -0700 renamed from prog/detect/sensors-detect 2007-06-13 08:18:39.981298000 -0700 +3 -0
+     exit_superio($addrreg, $datareg);
+     last FAMILY;
+    }
 # did it work?
     outb($addrreg, $superio{devidreg});
     $val = inb($datareg);

Thanks,
--
Jean Delvare

Thanks for the review. I will spin and resubmit the patch.

...juerg

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