PERFORCE change 106762 for review
Warner Losh
imp at FreeBSD.org
Tue Sep 26 23:24:53 PDT 2006
http://perforce.freebsd.org/chv.cgi?CH=106762
Change 106762 by imp at imp_lighthouse on 2006/09/27 06:24:46
implement bus acquisision and release as kind of a poor-man's
semaphore. Might be a good idea to add a device owner to the
mix for sanity checking...
Affected files ...
.. //depot/projects/arm/src/sys/arm/at91/at91_mci.c#7 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/at91/at91_mci.c#7 (text+ko) ====
@@ -68,6 +68,7 @@
bus_dmamap_t map;
struct mmc_host host;
int wire4;
+ int bus_busy;
};
static inline uint32_t
@@ -108,7 +109,7 @@
WR4(sc, MCI_CR, MCI_CR_MCIEN); /* Enable controller */
WR4(sc, MCI_IDR, 0xffffffff); /* Turn off interrupts */
- WR4(sc, MCI_DTOR, MCI_DTOR_DTOMUL_1M | MCI_DTOR_DTOCYC);
+ WR4(sc, MCI_DTOR, MCI_DTOR_DTOMUL_1M | 1);
WR4(sc, MCI_MR, 0x834a); // XXX GROSS HACK FROM LINUX
WR4(sc, MCI_SDCR, 0); /* SLOT A, 1 bit bus */
}
@@ -133,7 +134,6 @@
static int
at91_mci_attach(device_t dev)
{
- /* XXX: asumes MCK = 60MHz */
struct at91_mci_softc *sc = device_get_softc(dev);
int err;
device_t child;
@@ -299,13 +299,27 @@
static int
at91_acquire_host(device_t brdev, device_t reqdev)
{
- return (EIO); // XXX
+ struct at91_mci_softc *sc = device_get_softc(brdev);
+ int err = 0;
+
+ AT91_MCI_LOCK(sc);
+ while (sc->bus_busy)
+ msleep(sc, &sc->sc_mtx, PZERO, "mciah", hz / 5);
+ sc->bus_busy++;
+ AT91_MCI_UNLOCK(sc);
+ return (err);
}
static int
at91_release_host(device_t brdev, device_t reqdev)
{
- return (EIO); // XXX
+ struct at91_mci_softc *sc = device_get_softc(brdev);
+
+ AT91_MCI_LOCK(sc);
+ sc->bus_busy--;
+ wakeup(sc);
+ AT91_MCI_UNLOCK(sc);
+ return (0);
}
static device_method_t at91_mci_methods[] = {
More information about the p4-projects
mailing list