Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Sep 2006 04:46:49 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 106758 for review
Message-ID:  <200609270446.k8R4kn97027692@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=106758

Change 106758 by imp@imp_lighthouse on 2006/09/27 04:46:40

	Implement update_ios.

Affected files ...

.. //depot/projects/arm/src/sys/arm/at91/at91_mci.c#6 edit

Differences ...

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

@@ -67,6 +67,7 @@
 	bus_dma_tag_t dmatag;
 	bus_dmamap_t map;
 	struct mmc_host host;
+	int wire4;
 };
 
 static inline uint32_t
@@ -247,7 +248,40 @@
 static int
 at91_update_ios(device_t brdev, device_t reqdev)
 {
-	return (EIO);	// XXX
+	uint32_t at91_master_clock = AT91C_MASTER_CLOCK;
+	struct at91_mci_softc *sc;
+	struct mmc_host *host;
+	struct mmc_ios *ios;
+	uint32_t clkdiv;
+
+	sc = device_get_softc(brdev);
+	host = &sc->host;
+	ios = &host->ios;
+	// bus mode?
+	if (ios->clock == 0) {
+		WR4(sc, MCI_CR, MCI_CR_MCIDIS);
+		clkdiv = 0;
+	} else {
+		WR4(sc, MCI_CR, MCI_CR_MCIDIS);
+		if ((at91_master_clock % (ios->clock * 2)) == 0)
+			clkdiv = ((at91_master_clock / ios->clock) / 2) - 1;
+		else
+			clkdiv = (at91_master_clock / ios->clock) / 2;
+	}
+	if (ios->bus_width == bus_width_4 && sc->wire4)
+		WR4(sc, MCI_SDCR, RD4(sc, MCI_SDCR) | MCI_SDCR_SDCBUS);
+	else
+		WR4(sc, MCI_SDCR, RD4(sc, MCI_SDCR) & ~MCI_SDCR_SDCBUS);
+	WR4(sc, MCI_MR, (RD4(sc, MCI_MR) & ~MCI_MR_CLKDIV) | clkdiv);
+#if 0
+	if (sc->vcc_pin) {
+		if (sc->power_mode == MMC_POWER_OFF)
+			gpio_set(sc->vcc_pin, 0);
+		else
+			gpio_set(sc->vcc_pin, 1);
+	}
+#endif
+	return (0);
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609270446.k8R4kn97027692>