Changeset bcaa8a2 in rtems-libbsd


Ignore:
Timestamp:
Feb 5, 2018, 3:45:59 PM (16 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5cb01f277962d3127d364bf871f799b34e6b6be6, cc60cbeef68291b54f73c2d26fe3da4b837a8e06
Children:
b79c025
Parents:
138bf25
git-author:
Sebastian Huber <sebastian.huber@…> (02/05/18 15:45:59)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/06/18 08:56:35)
Message:

dw_mmc: Properly init/reset DMA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/sys/dev/dw_mmc/dw_mmc.c

    r138bf25 rbcaa8a2  
    178178}
    179179
     180static void
     181dw_mmc_configure_dma(struct dw_mmc_softc *sc)
     182{
     183
     184        WR4(sc, DW_MMC_BMOD, DW_MMC_BMOD_DE | DW_MMC_BMOD_FB);
     185}
     186
    180187static int
    181188dw_mmc_init(struct dw_mmc_softc *sc)
     
    185192        int err;
    186193
    187         err = dw_mmc_poll_reset_completion(sc, DW_MMC_CTRL_RESET);
     194        err = dw_mmc_poll_reset_completion(sc, DW_MMC_CTRL_DMA_RESET |
     195            DW_MMC_CTRL_FIFO_RESET | DW_MMC_CTRL_RESET);
    188196        if (err != 0) {
    189197                return err;
     
    191199
    192200        sc->card_clock = UINT32_MAX;
     201
     202        dw_mmc_configure_dma(sc);
    193203
    194204        /* Clear interrupt status */
     
    224234dw_mmc_fini(struct dw_mmc_softc *sc)
    225235{
    226         WR4(sc, DW_MMC_CTRL, DW_MMC_CTRL_FIFO_RESET | DW_MMC_CTRL_RESET);
     236        WR4(sc, DW_MMC_CTRL, DW_MMC_CTRL_DMA_RESET | DW_MMC_CTRL_FIFO_RESET |
     237            DW_MMC_CTRL_RESET);
     238        wmb();
     239        WR4(sc, DW_MMC_BMOD, DW_MMC_BMOD_SWR);
    227240}
    228241
     
    534547        uint32_t ctrl_resets = DW_MMC_CTRL_FIFO_RESET | DW_MMC_CTRL_DMA_RESET;
    535548        uint32_t ctrl = RD4(sc, DW_MMC_CTRL);
    536 
     549        int err;
     550
     551        ctrl &= ~DW_MMC_CTRL_DMA_ENABLE;
    537552        ctrl |= ctrl_resets;
    538553
    539554        WR4(sc, DW_MMC_CTRL, ctrl);
    540555
    541         return dw_mmc_poll_reset_completion(sc, ctrl_resets);
     556        err = dw_mmc_poll_reset_completion(sc, ctrl_resets);
     557        if (err != 0)
     558                return (err);
     559
     560        WR4(sc, DW_MMC_BMOD, DW_MMC_BMOD_SWR);
     561        return (0);
    542562}
    543563
     
    833853
    834854        des[i].des0 = DW_MMC_DES0_OWN | DW_MMC_DES0_ER | fs | DW_MMC_DES0_LD;
    835 
    836 #ifdef __arm__
    837         _ARM_Data_synchronization_barrier();
    838 #else
    839         /* TODO */
    840 #endif
     855        wmb();
    841856}
    842857
     
    898913                if (use_dma) {
    899914                        ctrl |= DW_MMC_CTRL_DMA_ENABLE;
    900                 } else {
    901                         ctrl &= ~DW_MMC_CTRL_DMA_ENABLE;
    902                 }
    903 
    904                 WR4(sc, DW_MMC_CTRL, ctrl);
     915                        WR4(sc, DW_MMC_CTRL, ctrl);
     916                        wmb();
     917                        dw_mmc_configure_dma(sc);
     918                }
     919
    905920                WR4(sc, DW_MMC_BLKSIZ, MIN(count_bytes, MMC_SECTOR_SIZE));
    906921                WR4(sc, DW_MMC_BYTCNT, count_bytes);
Note: See TracChangeset for help on using the changeset viewer.