PERFORCE change 64005 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sat Oct 30 19:25:53 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=64005
Change 64005 by marcel at 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)
More information about the p4-projects
mailing list