Subject: Driver hacks 2: cs4231_sbus.c
To: NetBSD port-sparc mailing list <port-sparc@netbsd.org>
From: Julian Coleman <jdc@coris.demon.co.uk>
List: port-sparc
Date: 10/16/2002 20:25:59
With a Cycle 5 IP (basically a Sparc 5 in an IPC/IPX box), a phantom
audiocs is attached because the PROM has an entry for SUNW,CS4231 but
the audio hardware is actually an AMD 7930.  The SUNW,CS4231 node has
`device_type serial', so checking for that (as in the following patch)
stops the device matching.  However, it gives a "not configured" line
on boot instead.  Would it be better to check for this in the attach
routine instead (and print a suitable message there)?

J

PS.  Not tested on any other machine with SUNW,CS4231, but looking at the
PROM on a real SS5, it has `device_type audio'.

 ---8<---------------------------- Cut here ---------------------------->8---
--- cs4231_sbus.c.dist	Thu Oct  3 11:05:45 2002
+++ cs4231_sbus.c	Tue Oct 15 12:53:49 2002
@@ -50,6 +50,7 @@
 
 #include <machine/bus.h>
 #include <machine/intr.h>
+#include <machine/autoconf.h>
 
 #include <dev/sbus/sbusvar.h>
 
@@ -148,7 +149,9 @@
 {
 	struct sbus_attach_args *sa = aux;
 
-	return (strcmp(sa->sa_name, AUDIOCS_PROM_NAME) == 0);
+	/* Cycle 5 IP has a SUNW,CS4231 in the PROM but no hardware */
+	return (strcmp(sa->sa_name, AUDIOCS_PROM_NAME) == 0 &&
+	strcmp("serial", PROM_getpropstring(sa->sa_node, "device_type")) != 0);
 }
 
 
 ---8<---------------------------- Cut here ---------------------------->8---
-- 
                    My other computer also runs NetBSD
                          http://www.netbsd.org/