PERFORCE change 106800 for review

Warner Losh imp at FreeBSD.org
Wed Sep 27 15:00:06 PDT 2006


http://perforce.freebsd.org/chv.cgi?CH=106800

Change 106800 by imp at imp_lighthouse on 2006/09/27 21:59:43

	Handle the queueing of commands...

Affected files ...

.. //depot/projects/arm/src/sys/arm/at91/at91_mci.c#8 edit
.. //depot/projects/arm/src/sys/dev/mmc/bridge.h#4 edit
.. //depot/projects/arm/src/sys/dev/mmc/mmcreg.h#9 edit

Differences ...

==== //depot/projects/arm/src/sys/arm/at91/at91_mci.c#8 (text+ko) ====

@@ -29,19 +29,20 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/bio.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
 #include <sys/kernel.h>
+#include <sys/kthread.h>
+#include <sys/lock.h>
 #include <sys/malloc.h>
-#include <sys/lock.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
-#include <sys/time.h>
-#include <sys/bus.h>
+#include <sys/queue.h>
 #include <sys/resource.h>
 #include <sys/rman.h>
+#include <sys/time.h>
 #include <sys/timetc.h>
 #include <sys/watchdog.h>
-#include <sys/conf.h>
-#include <sys/kthread.h>
 
 #include <machine/bus.h>
 #include <machine/cpu.h>
@@ -61,6 +62,9 @@
 struct at91_mci_softc {
 	void *intrhand;			/* Interrupt handle */
 	device_t dev;
+	int flags;
+#define CMD_STARTED	1
+#define STOP_STARTED	2
 	struct resource *irq_res;	/* IRQ resource */
 	struct resource	*mem_res;	/* Memory resource */
 	struct mtx sc_mtx;
@@ -69,6 +73,7 @@
 	struct mmc_host host;
 	int wire4;
 	int bus_busy;
+	struct mmc_request *req;
 };
 
 static inline uint32_t
@@ -237,7 +242,7 @@
 
 #if 0
 static void
-at91_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
+at91_mci_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
 {
 	if (error != 0)
 		return;
@@ -246,7 +251,7 @@
 #endif
 
 static int
-at91_update_ios(device_t brdev, device_t reqdev)
+at91_mci_update_ios(device_t brdev, device_t reqdev)
 {
 	uint32_t at91_master_clock = AT91C_MASTER_CLOCK;
 	struct at91_mci_softc *sc;
@@ -284,20 +289,62 @@
 	return (0);
 }
 
+static void
+at91_mci_start_cmd(struct at91_mci_softc *sc, struct mmc_command *cmd)
+{
+	// XXX
+}
+
+static void
+at91_mci_start(struct at91_mci_softc *sc)
+{
+	struct mmc_request *req;
+
+	// assert locked
+	if (!(sc->flags & CMD_STARTED)) {
+		sc->flags |= CMD_STARTED;
+		at91_mci_start_cmd(sc, req->cmd);
+		return;
+	}
+	if (!(sc->flags & STOP_STARTED) && req->stop) {
+		sc->flags |= STOP_STARTED;
+		at91_mci_start_cmd(sc, req->stop);
+		return;
+	}
+	/* We must be done -- bad idea to do this while locked? */
+	req = sc->req;
+	sc->req = NULL;
+	req->done(req->done_data);
+}
+
 static int
-at91_request(device_t brdev, device_t reqdev, struct mmc_request *req)
+at91_mci_request(device_t brdev, device_t reqdev, struct mmc_request *req)
 {
-	return (EIO);	// XXX
+	struct at91_mci_softc *sc = device_get_softc(brdev);
+
+	AT91_MCI_LOCK(sc);
+	// XXX do we want to be able to queue up multiple commands?
+	// XXX sounds like a good idea, but all protocols are sync, so
+	// XXX maybe the idea is naive...
+	if (sc->req != NULL) {
+		AT91_MCI_UNLOCK(sc);
+		return EBUSY;
+	}
+	sc->req = req;
+	sc->flags = 0;
+	at91_mci_start(sc);
+	AT91_MCI_UNLOCK(sc);
+	return (0);
 }
 
 static int
-at91_get_ro(device_t brdev, device_t reqdev)
+at91_mci_get_ro(device_t brdev, device_t reqdev)
 {
 	return (-1);
 }
 
 static int
-at91_acquire_host(device_t brdev, device_t reqdev)
+at91_mci_acquire_host(device_t brdev, device_t reqdev)
 {
 	struct at91_mci_softc *sc = device_get_softc(brdev);
 	int err = 0;
@@ -311,7 +358,7 @@
 }
 
 static int
-at91_release_host(device_t brdev, device_t reqdev)
+at91_mci_release_host(device_t brdev, device_t reqdev)
 {
 	struct at91_mci_softc *sc = device_get_softc(brdev);
 
@@ -329,11 +376,11 @@
 	DEVMETHOD(device_detach, at91_mci_detach),
 
 	/* mmcbr_if */
-	DEVMETHOD(mmcbr_update_ios, at91_update_ios),
-	DEVMETHOD(mmcbr_request, at91_request),
-	DEVMETHOD(mmcbr_get_ro, at91_get_ro),
-	DEVMETHOD(mmcbr_acquire_host, at91_acquire_host),
-	DEVMETHOD(mmcbr_release_host, at91_release_host),
+	DEVMETHOD(mmcbr_update_ios, at91_mci_update_ios),
+	DEVMETHOD(mmcbr_request, at91_mci_request),
+	DEVMETHOD(mmcbr_get_ro, at91_mci_get_ro),
+	DEVMETHOD(mmcbr_acquire_host, at91_mci_acquire_host),
+	DEVMETHOD(mmcbr_release_host, at91_mci_release_host),
 
 	{0, 0},
 };

==== //depot/projects/arm/src/sys/dev/mmc/bridge.h#4 (text+ko) ====


==== //depot/projects/arm/src/sys/dev/mmc/mmcreg.h#9 (text+ko) ====

@@ -123,6 +123,8 @@
 #define	R1_STATE_DIS	8
 
 struct mmc_data {
+	size_t len;		/* size of the data */
+	void *data;		/* data buffer */
 	uint32_t	flags;
 #define	MMC_DATA_WRITE	(1UL << 8)
 #define	MMC_DATA_READ	(1UL << 9)
@@ -132,7 +134,6 @@
 
 struct mmc_request {
 	struct mmc_command *cmd;
-	struct mmc_data *data;
 	struct mmc_command *stop;
 	void (*done)(struct mmc_request *); /* Completion function */
 	void *done_data;		/* requestor set data */


More information about the p4-projects mailing list