Module Name:    src
Committed By:   cegger
Date:           Tue Sep  7 07:26:54 UTC 2010

Modified Files:
        src/sys/dev/ieee1394: firewire.c firewirereg.h

Log Message:
do not assume all fw devices speak sbp.
teach the fw attach code to deal with different fw device classes.
this allows other fw drivers than sbp to attach


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ieee1394/firewire.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ieee1394/firewirereg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ieee1394/firewire.c
diff -u src/sys/dev/ieee1394/firewire.c:1.37 src/sys/dev/ieee1394/firewire.c:1.38
--- src/sys/dev/ieee1394/firewire.c:1.37	Thu Aug 26 08:56:15 2010
+++ src/sys/dev/ieee1394/firewire.c	Tue Sep  7 07:26:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: firewire.c,v 1.37 2010/08/26 08:56:15 cegger Exp $	*/
+/*	$NetBSD: firewire.c,v 1.38 2010/09/07 07:26:54 cegger Exp $	*/
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.37 2010/08/26 08:56:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.38 2010/09/07 07:26:54 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -1959,6 +1959,45 @@
 	/* NOTREACHED */
 }
 
+static const char *
+fw_get_devclass(struct fw_device *fwdev)
+{
+	struct crom_context cc;
+	struct csrreg *reg;
+
+	crom_init_context(&cc, fwdev->csrrom);
+	reg = crom_search_key(&cc, CSRKEY_VER);
+	if (reg == NULL)
+		return "null";
+
+	switch (reg->val) {
+	case CSR_PROTAVC:
+		return "av/c";
+	case CSR_PROTCAL:
+		return "cal";
+	case CSR_PROTEHS:
+		return "ehs";
+	case CSR_PROTHAVI:
+		return "havi";
+	case CSR_PROTCAM104:
+		return "cam104";
+	case CSR_PROTCAM120:
+		return "cam120";
+	case CSR_PROTCAM130:
+		return "cam130";
+	case CSR_PROTDPP:
+		return "printer";
+	case CSR_PROTIICP:
+		return "iicp";
+	case CSRVAL_T10SBP2:
+		return "sbp";
+	default:
+		if (firewire_debug)
+			printf("%s: reg->val 0x%x\n",
+				__func__, reg->val);
+		return "sbp";
+	}
+}
 
 /*
  * To attach sub-devices layer onto IEEE1394 bus.
@@ -1973,7 +2012,7 @@
 	struct fw_attach_args fwa;
 	int locs[IEEE1394IFCF_NLOCS];
 
-	fwa.name = "sbp";
+	fwa.name = "null";
 	fwa.fc = fc;
 
 	mutex_enter(&fc->fc_mtx);
@@ -1993,16 +2032,17 @@
 			locs[IEEE1394IFCF_EUIHI] = fwdev->eui.hi;
 			locs[IEEE1394IFCF_EUILO] = fwdev->eui.lo;
 
+			fwa.name = fw_get_devclass(fwdev);
 			fwa.fwdev = fwdev;
-			fwdev->sbp = config_found_sm_loc(sc->dev, "ieee1394if",
+			fwdev->dev = config_found_sm_loc(sc->dev, "ieee1394if",
 			    locs, &fwa, firewire_print, config_stdsubmatch);
-			if (fwdev->sbp == NULL) {
+			if (fwdev->dev == NULL) {
 				free(devlist, M_DEVBUF);
 				break;
 			}
 
 			devlist->fwdev = fwdev;
-			devlist->dev = fwdev->sbp;
+			devlist->dev = fwdev->dev;
 
 			mutex_enter(&fc->fc_mtx);
 			if (SLIST_EMPTY(&sc->devlist))
@@ -2064,7 +2104,7 @@
 			    link);
 			free(devlist, M_DEVBUF);
 
-			if (config_detach(fwdev->sbp, DETACH_FORCE) != 0)
+			if (config_detach(fwdev->dev, DETACH_FORCE) != 0)
 				return;
 
 			STAILQ_REMOVE(&fc->devices, fwdev, fw_device, link);

Index: src/sys/dev/ieee1394/firewirereg.h
diff -u src/sys/dev/ieee1394/firewirereg.h:1.13 src/sys/dev/ieee1394/firewirereg.h:1.14
--- src/sys/dev/ieee1394/firewirereg.h:1.13	Sun May 23 18:56:58 2010
+++ src/sys/dev/ieee1394/firewirereg.h	Tue Sep  7 07:26:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: firewirereg.h,v 1.13 2010/05/23 18:56:58 christos Exp $	*/
+/*	$NetBSD: firewirereg.h,v 1.14 2010/09/07 07:26:54 cegger Exp $	*/
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -63,7 +63,7 @@
 #define FWDEVATTACHED	2
 #define FWDEVINVAL	3
 	STAILQ_ENTRY(fw_device) link;
-	device_t sbp;
+	device_t dev;
 };
 
 struct firewire_softc {

Reply via email to