svn commit: r186414 - projects/cambria/sys/arm/xscale/ixp425
Sam Leffler
sam at FreeBSD.org
Mon Dec 22 20:36:12 PST 2008
Author: sam
Date: Tue Dec 23 04:36:11 2008
New Revision: 186414
URL: http://svn.freebsd.org/changeset/base/186414
Log:
allow multiple references; we need this for ancillary drivers
Modified:
projects/cambria/sys/arm/xscale/ixp425/ixp425_npe.c
Modified: projects/cambria/sys/arm/xscale/ixp425/ixp425_npe.c
==============================================================================
--- projects/cambria/sys/arm/xscale/ixp425/ixp425_npe.c Tue Dec 23 04:35:01 2008 (r186413)
+++ projects/cambria/sys/arm/xscale/ixp425/ixp425_npe.c Tue Dec 23 04:36:11 2008 (r186414)
@@ -113,6 +113,7 @@ struct ixpnpe_softc {
uint32_t sc_msg[2]; /* reply msg collected in ixpnpe_intr */
int sc_msgwaiting; /* sc_msg holds valid data */
int sc_npeid;
+ int sc_nrefs; /* # of references */
int validImage; /* valid ucode image loaded */
int started; /* NPE is started */
@@ -122,6 +123,7 @@ struct ixpnpe_softc {
uint32_t savedExecCount;
uint32_t savedEcsDbgCtxtReg2;
};
+static struct ixpnpe_softc *npes[NPE_MAX];
#define IX_NPEDL_NPEIMAGE_FIELD_MASK 0xff
@@ -288,6 +290,11 @@ ixpnpe_attach(device_t dev, int npeid)
device_printf(dev, "%s: bad npeid %d\n", __func__, npeid);
return NULL;
}
+ sc = npes[npeid];
+ if (sc != NULL) {
+ sc->sc_nrefs++;
+ return sc;
+ }
config = &npeconfigs[npeid];
/* XXX M_BUS */
@@ -296,6 +303,7 @@ ixpnpe_attach(device_t dev, int npeid)
sc->sc_iot = sa->sc_iot;
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), "npe driver", MTX_DEF);
sc->sc_npeid = npeid;
+ sc->sc_nrefs = 1;
sc->sc_size = config->size;
sc->insMemSize = config->ins_memsize; /* size of instruction memory */
@@ -322,20 +330,26 @@ ixpnpe_attach(device_t dev, int npeid)
npe_reg_write(sc, IX_NPECTL,
npe_reg_read(sc, IX_NPECTL) | (IX_NPECTL_OFE | IX_NPECTL_OFWE));
+ npes[npeid] = sc;
+
return sc;
}
void
ixpnpe_detach(struct ixpnpe_softc *sc)
{
- /* disable output fifo interrupts */
- npe_reg_write(sc, IX_NPECTL,
- npe_reg_read(sc, IX_NPECTL) &~ (IX_NPECTL_OFE | IX_NPECTL_OFWE));
+ if (--sc->sc_nrefs == 0) {
+ npes[sc->sc_npeid] = NULL;
- bus_teardown_intr(sc->sc_dev, sc->sc_irq, sc->sc_ih);
- bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_size);
- mtx_destroy(&sc->sc_mtx);
- free(sc, M_TEMP);
+ /* disable output fifo interrupts */
+ npe_reg_write(sc, IX_NPECTL,
+ npe_reg_read(sc, IX_NPECTL) &~ (IX_NPECTL_OFE | IX_NPECTL_OFWE));
+
+ bus_teardown_intr(sc->sc_dev, sc->sc_irq, sc->sc_ih);
+ bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_size);
+ mtx_destroy(&sc->sc_mtx);
+ free(sc, M_TEMP);
+ }
}
int
More information about the svn-src-projects
mailing list