From owner-p4-projects@FreeBSD.ORG Wed Sep 27 06:24:53 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3997116A47B; Wed, 27 Sep 2006 06:24:53 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1882216A416 for ; Wed, 27 Sep 2006 06:24:53 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D8A6843D5C for ; Wed, 27 Sep 2006 06:24:52 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k8R6OquP044346 for ; Wed, 27 Sep 2006 06:24:52 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k8R6OqrE044343 for perforce@freebsd.org; Wed, 27 Sep 2006 06:24:52 GMT (envelope-from imp@freebsd.org) Date: Wed, 27 Sep 2006 06:24:52 GMT Message-Id: <200609270624.k8R6OqrE044343@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 106762 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Sep 2006 06:24:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=106762 Change 106762 by imp@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[] = {