socsvn commit: r287030 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner
pratiksinghal at FreeBSD.org
pratiksinghal at FreeBSD.org
Sat Jun 13 05:54:32 UTC 2015
Author: pratiksinghal
Date: Sat Jun 13 05:54:30 2015
New Revision: 287030
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287030
Log:
1) DMA partially working
2) Interrupt storm error still to be removed. (Interrupt handling is not correct now)
Modified:
soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c
Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c
==============================================================================
--- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sat Jun 13 01:28:19 2015 (r287029)
+++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sat Jun 13 05:54:30 2015 (r287030)
@@ -92,6 +92,8 @@
int a10_dma_ndesc;
void* a10_dma_desc ; /* Contains the kva of the descriptor which we will pass to DLBA */
int a10_dma_ops ; /* Which type of operation DMA is performing ? 0:read, 1:write, 2:other */
+ bus_dma_tag_t a10_dma_buff_tag ;
+ bus_dmamap_t a10_dma_buff_map ;
};
@@ -272,11 +274,11 @@
0,BUS_SPACE_MAXADDR_32BIT,BUS_SPACE_MAXADDR,
NULL,NULL,A10_DMA_BUFF_SIZE,
A10_DMA_NSEGS,A10_DMA_BUFF_SIZE,0,
- NULL,NULL,&sc->a10_dma_buf_tag) ;
+ NULL,NULL,&sc->a10_dma_buff_tag) ;
if(error)
return (error) ;
- error = bus_dma_map_create(sc->a10_dma_buf_tag,0,&sc->a10_dma_buf_map) ;
+ error = bus_dmamap_create(sc->a10_dma_buff_tag,0,&sc->a10_dma_buff_map) ;
if(error)
return (error) ;
@@ -299,12 +301,12 @@
uint32_t val;
desc = 0 ;
- device_printf(sc->a10_dev,"Before loop\n") ;
+
/* Pick a segment and program all the descriptors in the segment. */
bus_addr_t paddr = (sc->a10_dma_cb_arg).segs[0].ds_addr;
bus_size_t len = (sc->a10_dma_cb_arg).segs[0].ds_len ;
rem = min(len,cmd->data->len) ;
- device_printf(sc->a10_dev, "Before rem\n") ;
+
while(rem > 0)
{
if(desc == sc->a10_dma_ndesc)
@@ -333,22 +335,19 @@
desc++ ;
}
- device_printf(sc->a10_dev, "After the completion of loop\n") ;
if(desc == sc->a10_dma_ndesc) {
device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer! desc = %d,sc->a10_dma_ndesc = %d\n",desc, sc->a10_dma_ndesc) ;
return EIO ;
}
- device_printf(sc->a10_dev, "Before syncing\n") ;
bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ;
- device_printf(sc->a10_dev, "After syncing\n") ;
/* Enable DMA and interrupts*/
val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ;
val |= A10_MMC_DMA_ENABLE ;
val |= A10_MMC_INT_ENABLE ;
A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ;
-
+
/* Reset DMA */
val |= A10_MMC_DMA_RESET ;
A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ;
@@ -376,9 +375,9 @@
/* Configure the watermark level. */
A10_MMC_WRITE_4(sc, A10_MMC_FTRGL,A10_MMC_DMA_FTRGLEVEL_A10) ;
-
/* Disable debounce*/
- A10_MMC_WRITE_4(sc, A10_MMC_READ_4(sc, A10_MMC_GCTRL) & (~A10_MMC_DEBOUNCE_ENABLE), A10_MMC_GCTRL);
+ A10_MMC_WRITE_4(sc, A10_MMC_GCTRL, A10_MMC_READ_4(sc, A10_MMC_GCTRL) & (~A10_MMC_DEBOUNCE_ENABLE));
+
device_printf(sc->a10_dev, "Completed the prepare function\n") ;
return (0) ;
}
@@ -566,6 +565,7 @@
"Spurious interrupt - no active request, rint: 0x%08X\n",
rint);
A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint);
+ A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ;
A10_MMC_UNLOCK(sc);
return;
}
@@ -579,6 +579,7 @@
else
sc->a10_req->cmd->error = MMC_ERR_FAILED;
A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint);
+ A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ;
a10_mmc_req_done(sc);
A10_MMC_UNLOCK(sc);
return;
@@ -588,6 +589,7 @@
device_printf(sc->a10_dev, "error rint: 0x%08x\n", idst) ;
sc->a10_req->cmd->error = MMC_ERR_FAILED ;
A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ;
+ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint) ;
a10_mmc_req_done(sc) ;
A10_MMC_UNLOCK(sc) ;
return ;
@@ -601,6 +603,8 @@
bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_POSTWRITE) ;
else
device_printf(sc->a10_dev, "Invalid operations request!\n") ;
+ A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ;
+ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint) ;
a10_mmc_req_ok(sc) ;
A10_MMC_UNLOCK(sc) ;
return ;
@@ -664,13 +668,16 @@
if (cmd->data != NULL) {
sc->a10_intr_wait |= A10_MMC_DATA_OVER;
+ sc->a10_dma_ops = 0 ;
cmdreg |= A10_MMC_DATA_EXP | A10_MMC_WAIT_PREOVER;
if (cmd->data->flags & MMC_DATA_MULTI) {
cmdreg |= A10_MMC_SEND_AUTOSTOP;
sc->a10_intr_wait |= A10_MMC_AUTOCMD_DONE;
}
- if (cmd->data->flags & MMC_DATA_WRITE)
+ if (cmd->data->flags & MMC_DATA_WRITE) {
cmdreg |= A10_MMC_WRITE;
+ sc->a10_dma_ops = 1 ;
+ }
blksz = min(cmd->data->len, MMC_SECTOR_SIZE);
A10_MMC_WRITE_4(sc, A10_MMC_BLKSZ, blksz);
More information about the svn-soc-all
mailing list