PERFORCE change 106481 for review
Warner Losh
imp at FreeBSD.org
Thu Sep 21 17:20:24 PDT 2006
http://perforce.freebsd.org/chv.cgi?CH=106481
Change 106481 by imp at imp_lighthouse on 2006/09/22 00:19:47
checkpoint
Affected files ...
.. //depot/projects/arm/src/sys/arm/at91/at91_qdmmc.c#12 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/at91/at91_qdmmc.c#12 (text+ko) ====
@@ -731,9 +731,10 @@
struct at91_qdmmc_softc *sc = (struct at91_qdmmc_softc*)arg;
struct bio *bp;
int status;
- bus_addr_t addr;
+ bus_addr_t paddr;
int map = 0;
uint32_t *tmpbuf;
+ uint32_t rv;
int sz;
tmpbuf = malloc(sc->cards[0].sector_size, M_DEVBUF, M_WAITOK);
@@ -757,24 +758,33 @@
sz = sc->cards[0].sector_size;
for (block = bp->bio_pblkno; block < bp->bio_pblkno + (bp->bio_bcount / sz); block++) {
- char *paddr = bp->bio_data + (block - bp->bio_pblkno) * sz;
+ printf("Waiting for not busy\n");
+ // wait until completed
+ while (!(RD4(sc, MCI_SR) & MCI_SR_NOTBUSY))
+ continue;
+ printf("Waiting for the card to become ready\n");
+ do {
+ rv = at91_qdmmc_GetStatus(sc->dev, sc->cards[0].addr);
+ printf(".");
+ } while (rv != 0xffffffff && !(rv & AT91C_SR_READY_FOR_DATA));
+
+ char *vaddr = bp->bio_data + (block - bp->bio_pblkno) * sz;
- if (bus_dmamap_load(sc->dmatag, sc->map, paddr,
- sc->cards[0].sector_size, at91_getaddr, &addr, 0) != 0)
+ if (bus_dmamap_load(sc->dmatag, sc->map, vaddr,
+ sc->cards[0].sector_size, at91_getaddr, &paddr, 0) != 0)
goto out;
map = 1;
bus_dmamap_sync(sc->dmatag, sc->map, BUS_DMASYNC_PREREAD);
at91_qdmmc_wait_ready(sc);
WR4(sc, PDC_PTCR, PDC_PTCR_TXTDIS | PDC_PTCR_RXTDIS);
- WR4(sc, PDC_RPR, addr);
- WR4(sc, PDC_RCR, sz / 4);
+ WR4(sc, PDC_RPR, paddr);
+ WR4(sc, PDC_RCR, sz);
- printf("block = %#x paddr = %p, RPR = 0x%x, RCR = 0x%x\n", block, paddr,
+ printf("block = %#x vaddr = %p, RPR = 0x%x, RCR = 0x%x\n", block, vaddr,
RD4(sc, PDC_RPR), RD4(sc, PDC_RCR));
- status = at91_qdmmc_SendCommand(sc->dev,
- READ_SINGLE_BLOCK_CMD, block * sz);
- WR4(sc, MCI_IER, MCI_SR_RXBUFF | MCI_SR_ENDRX);
+ status = at91_qdmmc_SendCommand(sc->dev, READ_SINGLE_BLOCK_CMD, block * sz);
+// WR4(sc, MCI_IER, MCI_SR_RXBUFF | MCI_SR_ENDRX);
WR4(sc, PDC_PTCR, PDC_PTCR_RXTEN);
printf("at91_qdmmc_task: read-status = 0x%x\n", status);
@@ -786,10 +796,13 @@
printf("DONE SLEEPING\n");
#endif
at91_qdmmc_wait_ready(sc);
+ printf("SR is %x\n", RD4(sc, MCI_SR));
+#if 0
// safety check
- while ((RD4(sc, MCI_SR) & MCI_SR_RXBUFF) == 0)
+ while ((RD4(sc, MCI_SR) & MCI_SR_ENDRX) == 0)
DELAY(700);
+#endif
printf("DONE WAITING\n");
bus_dmamap_sync(sc->dmatag, sc->map, BUS_DMASYNC_POSTREAD);
@@ -798,14 +811,16 @@
WR4(sc, PDC_PTCR, PDC_PTCR_RXTDIS);
/* Fix Byteorder (Atmel Errata) */
- uint32_t* base = (uint32_t*)paddr;
+ uint32_t* base = (uint32_t*)vaddr;
for (int i = 0; i < sc->cards[0].sector_size / 4; i++) {
uint32_t tmp = base[i];
base[i] = (((tmp >> 24) & 0xff)) |
(((tmp >> 16) & 0xff) << 8) |
(((tmp >> 8) & 0xff) << 16) |
((tmp & 0xff) << 24);
+ printf("%08x", base[i]);
}
+ printf("\n");
}
printf("Delecting card!\n");
status = at91_qdmmc_SendCommand(sc->dev,
@@ -835,10 +850,10 @@
tmpbuf = malloc(sc->cards[0].sector_size, M_DEVBUF, M_WAITOK);
for (block = bp->bio_pblkno; block < bp->bio_pblkno + (bp->bio_bcount / sc->cards[0].sector_size); block++) {
- char *paddr = bp->bio_data + (block - bp->bio_pblkno) * sc->cards[0].sector_size;
+ char *vaddr = bp->bio_data + (block - bp->bio_pblkno) * sc->cards[0].sector_size;
/* Fix Byteorder (Atmel Errata) */
- uint32_t* base = (uint32_t*)paddr;
+ uint32_t* base = (uint32_t*)vaddr;
for (int i = 0; i < sc->cards[0].sector_size / 4; i++) {
uint32_t tmp = base[i];
tmpbuf[i] = (((tmp >> 24) & 0xff)) |
@@ -850,12 +865,12 @@
WR4(sc, PDC_PTCR, PDC_PTCR_TXTDIS | PDC_PTCR_RXTDIS);
if (bus_dmamap_load(sc->dmatag, sc->map, tmpbuf,
- sc->cards[0].sector_size, at91_getaddr, &addr, 0) != 0)
+ sc->cards[0].sector_size, at91_getaddr, &paddr, 0) != 0)
goto out;
map = 1;
bus_dmamap_sync(sc->dmatag, sc->map, BUS_DMASYNC_PREWRITE);
- WR4(sc, PDC_TPR, addr);
+ WR4(sc, PDC_TPR, paddr);
WR4(sc, PDC_TCR, sc->cards[0].sector_size / 4);
printf("status = 0x%x, tmpbuf = %p, TPR = 0x%x, TCR = 0x%x\n", status, tmpbuf,
More information about the p4-projects
mailing list