PERFORCE change 95282 for review

Marcel Moolenaar marcel at FreeBSD.org
Fri Apr 14 21:45:55 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=95282

Change 95282 by marcel at marcel_nfs on 2006/04/14 21:45:12

	Add new header <dev/puc/puc_bus.h> for use by subordinate
	drivers. The header only defines what subordinate drivers
	need to know.
	
	Change the bus protocol to avoid that puc(4) has to hardcode
	which driver attaches to what type of port. Each Subordinate
	driver reads the PUC_IVAR_TYPE ivar to obtain the type of
	port it's being probed for and either accept or reject it.
	Which driver actually attaches to a particular port is then
	left to what the respective probe functions return and thus
	allows for vendor specific drivers.

Affected files ...

.. //depot/projects/uart/dev/ppc/ppc_puc.c#3 edit
.. //depot/projects/uart/dev/puc/puc_bus.h#1 add
.. //depot/projects/uart/dev/uart/uart_bus_puc.c#14 edit

Differences ...

==== //depot/projects/uart/dev/ppc/ppc_puc.c#3 (text+ko) ====

@@ -1,4 +1,5 @@
 /*-
+ * Copyright (c) 2006 Marcel Moolenaar
  * Copyright (c) 1997-2000 Nicolas Souchu
  * Copyright (c) 2001 Alcove - Nicolas Souchu
  * All rights reserved.
@@ -23,11 +24,11 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * $FreeBSD: src/sys/dev/ppc/ppc_puc.c,v 1.2 2004/05/30 20:08:37 phk Exp $
- *
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/dev/ppc/ppc_puc.c,v 1.2 2004/05/30 20:08:37 phk Exp $");
+
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
@@ -35,6 +36,8 @@
   
 #include <machine/bus.h>
 
+#include <dev/puc/puc_bus.h>
+
 #include <dev/ppbus/ppbconf.h>
 #include <dev/ppbus/ppb_msq.h>
 #include <dev/ppc/ppcvar.h>
@@ -74,9 +77,17 @@
 };
 
 static int
-ppc_puc_probe(dev)
-	device_t	dev;
+ppc_puc_probe(device_t dev)
 {
+	device_t parent;
+	uintptr_t type;
+
+	parent = device_get_parent(dev);
+	if (BUS_READ_IVAR(parent, dev, PUC_IVAR_TYPE, &type))
+		return (ENXIO);
+	if (type != PUC_TYPE_PARALLEL)
+		return (ENXIO);
+
 	device_set_desc(dev, "Parallel port");
 	return (ppc_probe(dev));
 }

==== //depot/projects/uart/dev/uart/uart_bus_puc.c#14 (text+ko) ====

@@ -33,16 +33,13 @@
 #include <sys/conf.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
+
 #include <machine/bus.h>
 #include <sys/rman.h>
 #include <machine/resource.h>
 
-#include <sys/serial.h>
-#include <serdev_if.h>
+#include <dev/puc/puc_bus.h>
 
-#include <dev/pci/pcivar.h>
-#include <dev/puc/pucvar.h>
-
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_bus.h>
 
@@ -70,14 +67,19 @@
 {
 	device_t parent;
 	struct uart_softc *sc;
-	uintptr_t rclk;
+	uintptr_t rclk, type;
 
 	parent = device_get_parent(dev);
 	sc = device_get_softc(dev);
 
+	if (BUS_READ_IVAR(parent, dev, PUC_IVAR_TYPE, &type))
+		return (ENXIO);
+	if (type != PUC_TYPE_SERIAL)
+		return (ENXIO);
+
 	sc->sc_class = &uart_ns8250_class;
 
-	if (BUS_READ_IVAR(parent, dev, PUC_IVAR_FREQ, &rclk))
+	if (BUS_READ_IVAR(parent, dev, PUC_IVAR_CLOCK, &rclk))
 		rclk = 0;
 	return (uart_bus_probe(dev, 0, rclk, 0, 0));
 }


More information about the p4-projects mailing list