Subject: ADB setup
To: port-macppc mailing-list <port-macppc@netbsd.org>
From: Michael Lorenz <macallan@netbsd.org>
List: port-macppc
Date: 10/01/2007 21:46:48
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--Apple-Mail-3-381527345
Content-Type: multipart/mixed; boundary=Apple-Mail-2-381526975


--Apple-Mail-2-381526975
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed

Hello,

I thought I fixed this in 4.0 but I guess I was wrong.
On some newer *Books we accidentally power down when the adb driver  
attaches. As far as I know this happens on machines which don't have  
an ADB bus, so the PMU regards ADB commands as error and powers down.  
The attached patch will prevent the adb driver from issuing any ADB  
commands when the pmu node doesn't have an adb child. I've tested it  
on a PowerMac G4 which doesn't have ADB but the PMU is similar enough  
to the one used in newer PowerBooks although it doesn't power down on  
every error and a PowerBook 3400c which does have ADB. On the G4 no  
ADB commands are issued ( usually there would be a timeout message )  
and on the PowerBook the normal ADB devices attach.

Please test this on machines with or without ADB, if it fixes the  
power down problem and doesn't have any funny side effects I'll  
request pullup into 4.0

have fun
Michael

--Apple-Mail-2-381526975
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name=adb.patch
Content-Disposition: attachment;
	filename=adb.patch

Index: adb.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/dev/adb.c,v
retrieving revision 1.20
diff -u -w -r1.20 adb.c
--- adb.c	13 Sep 2006 03:37:20 -0000	1.20
+++ adb.c	2 Oct 2007 01:40:05 -0000
@@ -108,12 +108,13 @@
 {
 	struct adb_softc *sc = (struct adb_softc *)self;
 	struct confargs *ca = aux;
+	char name[64];
 	int irq = ca->ca_intr[0];
 	int node;
 	ADBDataBlock adbdata;
 	struct adb_attach_args aa_args;
 	int totaladbs;
-	int adbindex, adbaddr;
+	int have_adb, adbindex, adbaddr;
 
 	extern volatile u_char *Via1Base;
 
@@ -133,7 +134,17 @@
 
 	printf(" irq %d: ", irq);
 
+	have_adb = 0;
+	node = OF_child(ca->ca_node);
+	while (!have_adb && (node != 0) && (node != -1)) {
+		if (OF_getprop(node, "name", name, sizeof(name)) > 0) {
+			have_adb = (strcmp(name, "adb") == 0);
+		}
+		node = OF_peer(node);
+	}
+	
 	adb_polling = 1;
+	if (have_adb)
 	ADBReInit();
 
 	switch (adbHardware) {
@@ -146,6 +157,7 @@
 		break;
 	}
 
+	if (have_adb) {
 #ifdef ADB_DEBUG
 	if (adb_debug)
 		printf("adb: done with ADBReInit\n");
@@ -185,6 +197,8 @@
 
 	if (adbHardware == ADB_HW_CUDA)
 		adb_cuda_autopoll();
+	}
+
 	adb_polling = 0;
 
 	adb_todr_init();

--Apple-Mail-2-381526975--

--Apple-Mail-3-381527345
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQEVAwUBRwGjCMpnzkX8Yg2nAQIuxggAtqnJsv/rh6TFcLAvTbsbhHkvP9JK4adI
ucWHKgzTsxtdcSNp5drwt0nBJmzgvsrZO6jHtx/REtArN30QxdY4cwPCtP4RtjtD
cNuxTjS9v8jEyX73ykGCFVocVBLYlgPKqt/qxrcFftHXu1zIBNLyIeF3uI4jhlVT
7AfHi5Hjakyi5WVzOhnnStVMgHlJG4o5nAYPMOp4z8nH3KgzxBj0Lu14zWud8kDP
7pHOiH2q6I1VJTPOORWgCxwj1pXdrw/OzPW/xHuJHiZI5/Q2etpK1wPZPjY6M1V4
n92/lfiX5PJfsFrFlHVmPJYIkdfhGPjvvMrlY6NPn/d05J2gWHtwgQ==
=JvSj
-----END PGP SIGNATURE-----

--Apple-Mail-3-381527345--