Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Oct 2004 02:25:52 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 64005 for review
Message-ID:  <200410310225.i9V2Pqj8000234@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=64005

Change 64005 by marcel@marcel_nfs on 2004/10/31 02:25:29

	Have the bus frontends call scc_bfe_probe() for further probe
	related processing.

Affected files ...

.. //depot/projects/uart/dev/scc/scc_bfe.h#4 edit
.. //depot/projects/uart/dev/scc/scc_bfe_ebus.c#2 edit
.. //depot/projects/uart/dev/scc/scc_bfe_sbus.c#2 edit
.. //depot/projects/uart/dev/scc/scc_core.c#2 edit

Differences ...

==== //depot/projects/uart/dev/scc/scc_bfe.h#4 (text+ko) ====

@@ -78,6 +78,7 @@
 
 int scc_bfe_attach(device_t dev);
 int scc_bfe_detach(device_t dev);
+int scc_bfe_probe(device_t dev);
 
 struct resource *scc_bus_alloc_resource(device_t, device_t, int, int *,
     u_long, u_long, u_long, u_int);

==== //depot/projects/uart/dev/scc/scc_bfe_ebus.c#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/*-
+/*
  * Copyright (c) 2004 Marcel Moolenaar
  * All rights reserved.
  *
@@ -53,7 +53,7 @@
 	if (!strcmp(nm, "se")) {
 		device_set_desc(dev, "Siemens SAB 82532 dual channel SCC");
 		sc->sc_class = &scc_sab82532_class;
-		return (0);
+		return (scc_bfe_probe(dev));
 	}
 	return (ENXIO);
 }

==== //depot/projects/uart/dev/scc/scc_bfe_sbus.c#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/*-
+/*
  * Copyright (c) 2004 Marcel Moolenaar
  * All rights reserved.
  *
@@ -53,7 +53,7 @@
 	if (!strcmp(nm, "zs")) {
 		device_set_desc(dev, "Zilog Z8530 dual channel SCC");
 		sc->sc_class = &scc_z8530_class;
-		return (0);
+		return (scc_bfe_probe(dev));
 	}
 	return (ENXIO);
 }

==== //depot/projects/uart/dev/scc/scc_core.c#2 (text+ko) ====

@@ -47,6 +47,13 @@
 int
 scc_bfe_attach(device_t dev)
 {
+	struct scc_softc *sc;
+
+	sc = device_get_softc(dev);
+	sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid,
+	    0, ~0, sc->sc_class->sc_range, RF_ACTIVE);
+	if (sc->sc_rres == NULL)
+		return (ENXIO);
 
 	return (ENXIO);
 }
@@ -58,6 +65,48 @@
 	return (ENXIO);
 }
 
+int
+scc_bfe_probe(device_t dev)
+{
+	struct scc_softc *sc;
+
+	/*
+	 * Initialize the instance. Note that the instance (=softc) does
+	 * not necessarily match the hardware specific softc. We can't do
+	 * anything about it now, because we may not attach to the device.
+	 * Hardware drivers cannot use any of the class specific fields
+	 * while probing.
+	 */
+	sc = device_get_softc(dev);
+	kobj_init((kobj_t)sc, (kobj_class_t)sc->sc_class);
+	sc->sc_dev = dev;
+	if (device_get_desc(dev) == NULL)
+		device_set_desc(dev, sc->sc_class->name);
+
+	/*
+	 * Allocate the register resource. We assume that all SCCs have a
+	 * single register window in either I/O port space or memory mapped
+	 * I/O space. Any SCC that needs multiple windows will consequently
+	 * not be supported by this driver as-is. We try I/O port space
+	 * first to satisfy the EBus code.
+	 */
+	sc->sc_rrid = 0;
+	sc->sc_rtype = SYS_RES_IOPORT;
+	sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid,
+	    0, ~0, sc->sc_class->sc_range, RF_ACTIVE);
+	if (sc->sc_rres == NULL) {
+		sc->sc_rrid = 0;
+		sc->sc_rtype = SYS_RES_MEMORY;
+		sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype,
+		    &sc->sc_rrid, 0, ~0, sc->sc_class->sc_range, RF_ACTIVE);
+		if (sc->sc_rres == NULL)
+			return (ENXIO);
+	}
+
+	bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
+	return (0);
+}
+
 struct resource *
 scc_bus_alloc_resource(device_t dev, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200410310225.i9V2Pqj8000234>