Date: Mon, 15 Jun 2015 13:36:37 GMT From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r287119 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner Message-ID: <201506151336.t5FDabAJ062871@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pratiksinghal Date: Mon Jun 15 13:36:36 2015 New Revision: 287119 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287119 Log: 1) DMA transfer is working along with pio transfer. 2) Interrupt storm error resolved. Getting a translation fault though which needs to be resolved 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 Mon Jun 15 12:50:43 2015 (r287118) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Mon Jun 15 13:36:36 2015 (r287119) @@ -354,6 +354,7 @@ bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; /* Enable DMA and interrupts*/ + device_printf(sc->a10_dev, "Previous value of gctrl was 0x%08X and new value is 0x%08X\n", A10_MMC_READ_4(sc, A10_MMC_GCTRL), A10_MMC_READ_4(sc,A10_MMC_GCTRL) | A10_MMC_DMA_ENABLE | A10_MMC_INT_ENABLE) ; val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; val |= A10_MMC_DMA_ENABLE ; val |= A10_MMC_INT_ENABLE ; @@ -387,7 +388,7 @@ /* 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_GCTRL, A10_MMC_READ_4(sc, A10_MMC_GCTRL) & (~A10_MMC_DEBOUNCE_ENABLE)); + //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) ; @@ -399,9 +400,9 @@ a10_mmc_can_do_dma(struct mmc_request* req) { if(req->cmd->data->len > A10_MMC_DMA_MAXLEN) - return (0) ; + return (0) ; else - return (1) ; + return (1) ; } static void a10_dma_cb(void* arg, bus_dma_segment_t* segs, int nsegs, int error) @@ -445,26 +446,30 @@ break; DELAY(100); } - if (timeout == 0) { - device_printf(sc->a10_dev, "Getting timedout in reset\n") ; + if (timeout == 0) { + device_printf(sc->a10_dev, "Getting timedout in reset\n") ; return (ETIMEDOUT); } + device_printf(sc->a10_dev, "The resetted value is %#x\n", A10_MMC_READ_4(sc, A10_MMC_GCTRL)) ; /* Set the timeout. */ A10_MMC_WRITE_4(sc, A10_MMC_TIMEOUT, 0xffffffff); /* Clear pending interrupts. */ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, 0xffffffff); + /* Dubious Will it remove the interrupt throttle? */ + A10_MMC_WRITE_4(sc, A10_MMC_IDST, 0xffffffff) ; /* Unmask interrupts. */ A10_MMC_WRITE_4(sc, A10_MMC_IMASK, A10_MMC_CMD_DONE | A10_MMC_INT_ERR_BIT | A10_MMC_DATA_OVER | A10_MMC_AUTOCMD_DONE | A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ); + uint32_t temp_val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_INT_ENABLE | A10_MMC_ACCESS_BY_AHB ; + temp_val = temp_val & (~A10_MMC_DMA_ENABLE) ; + device_printf(sc->a10_dev, "The value I am writing is %#x\n",temp_val) ; /* Enable interrupts and AHB access. */ - A10_MMC_WRITE_4(sc, A10_MMC_GCTRL, - A10_MMC_READ_4(sc, A10_MMC_GCTRL) | - A10_MMC_INT_ENABLE | A10_MMC_ACCESS_BY_AHB); - device_printf(sc->a10_dev,"Reset succesfully in reset function\n") ; + A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,temp_val) ; + device_printf(sc->a10_dev,"Reset succesfully in reset function %#x\n", A10_MMC_READ_4(sc, A10_MMC_GCTRL)) ; return (0); } @@ -550,6 +555,7 @@ int i, write; uint32_t bit, *buf; + device_printf(sc->a10_dev, "Doing pio transfer\n") ; buf = (uint32_t *)data->data; write = (data->flags & MMC_DATA_WRITE) ? 1 : 0; bit = write ? A10_MMC_FIFO_FULL : A10_MMC_FIFO_EMPTY; @@ -587,7 +593,9 @@ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint) ; A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; A10_MMC_WRITE_4(sc, A10_MMC_IMASK, imask) ; - device_printf(sc->a10_dev, "imask: %#x, rint: %#x, idst: %#x\n", imask, rint,idst); +#ifdef DEBUG + device_printf(sc->a10_dev, "imask: %#x, rint: %#x, idst: %#x, gctrl: %#x\n", imask, rint,idst, A10_MMC_READ_4(sc, A10_MMC_GCTRL)); +#endif if (sc->a10_req == NULL) { device_printf(sc->a10_dev, "Spurious interrupt - no active request, rint: 0x%08X\n", @@ -610,7 +618,7 @@ } if(idst & A10_MMC_IDMAC_ERROR) { - device_printf(sc->a10_dev, "error rint: 0x%08x\n", idst) ; + device_printf(sc->a10_dev, "error idst: 0x%08x\n", idst) ; sc->a10_req->cmd->error = MMC_ERR_FAILED ; a10_mmc_req_done(sc) ; A10_MMC_UNLOCK(sc) ; @@ -636,11 +644,13 @@ sc->a10_req->cmd->error = MMC_ERR_TIMEOUT ; a10_mmc_req_done(sc) ; A10_MMC_UNLOCK(sc) ; + return ; } sc->a10_intr |= rint; data = sc->a10_req->cmd->data; + device_printf(sc->a10_dev, "Data is %p\n", data) ; if (data != NULL && (rint & (A10_MMC_DATA_OVER | A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0) a10_mmc_pio_transfer(sc, data); @@ -657,7 +667,7 @@ int blksz; struct a10_mmc_softc *sc; struct mmc_command *cmd; - uint32_t cmdreg ; + uint32_t cmdreg ; sc = device_get_softc(bus); A10_MMC_LOCK(sc); @@ -704,11 +714,23 @@ if((sc->a10_use_dma == 1)&&(a10_mmc_can_do_dma(req))) { uint32_t error = a10_mmc_prepare_dma(sc) ; if(error == 0) { - A10_MMC_WRITE_4(sc, A10_MMC_IMASK, A10_MMC_READ_4(sc, A10_MMC_IMASK) | (A10_MMC_TX_DATA_REQ | A10_MMC_RX_DATA_REQ)) ; + A10_MMC_WRITE_4(sc, A10_MMC_IMASK, A10_MMC_READ_4(sc, A10_MMC_IMASK) | (A10_MMC_TX_DATA_REQ | A10_MMC_RX_DATA_REQ)) ; } - else + else { + uint32_t temp_val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_INT_ENABLE | A10_MMC_ACCESS_BY_AHB ; + temp_val = temp_val & (~A10_MMC_DMA_ENABLE) ; + A10_MMC_WRITE_4(sc, A10_MMC_GCTRL, temp_val) ; device_printf(sc->a10_dev, "Couldn't prepare DMA, using pio instead\n") ; + } } + else + { + uint32_t temp_val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_INT_ENABLE | A10_MMC_ACCESS_BY_AHB ; + temp_val = temp_val & (~A10_MMC_DMA_ENABLE) ; + A10_MMC_WRITE_4(sc, A10_MMC_GCTRL, temp_val) ; + device_printf(sc->a10_dev, "Couldn't transfer this data with DMA, using pio instead\n") ; + } + } A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506151336.t5FDabAJ062871>