diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index 49023628ea2..9507ffbf0c4 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -493,6 +493,25 @@ static int mmcsd_recv_r6(FAR struct mmcsd_state_s *priv, uint32_t cmd) static int mmcsd_get_scr(FAR struct mmcsd_state_s *priv, uint32_t scr[2]) { int ret; +#ifdef CONFIG_SDIO_DMA + bool drop = false; +#endif + +#if defined(CONFIG_SDIO_DMA) && defined(CONFIG_ARCH_HAVE_SDIO_PREFLIGHT) + /* If we think we are going to perform a DMA transfer, make sure that we + * will be able to before we commit the card to the operation. + */ + + if ((priv->caps & SDIO_CAPS_DMASUPPORTED) != 0) + { + ret = SDIO_DMAPREFLIGHT(priv->dev, (FAR uint8_t *)scr, 8); + if (ret != OK) + { + finfo("SDIO_DMAPREFLIGHT: error %d, drop to RECVSETUP\n", ret); + drop = true; + } + } +#endif /* Set Block Size To 8 Bytes */ @@ -506,7 +525,22 @@ static int mmcsd_get_scr(FAR struct mmcsd_state_s *priv, uint32_t scr[2]) /* Setup up to receive data with interrupt mode */ SDIO_BLOCKSETUP(priv->dev, 8, 1); - SDIO_RECVSETUP(priv->dev, (FAR uint8_t *)scr, 8); +#ifdef CONFIG_SDIO_DMA + if (!drop && (priv->caps & SDIO_CAPS_DMASUPPORTED) != 0) + { + ret = SDIO_DMARECVSETUP(priv->dev, (FAR uint8_t *)scr, 8); + if (ret != OK) + { + finfo("SDIO_DMARECVSETUP: error %d, drop to RECVSETUP\n", ret); + drop = true; + } + } + + if (drop) +#endif + { + SDIO_RECVSETUP(priv->dev, (FAR uint8_t *)scr, 8); + } SDIO_WAITENABLE(priv->dev, SDIOWAIT_TRANSFERDONE | SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR, @@ -2621,7 +2655,7 @@ static int mmcsd_ioctl(FAR struct inode *inode, int cmd, unsigned long arg) } break; - case MMC_IOC_MULTI_CMD: /* MMCSD device ioctl muti commands */ + case MMC_IOC_MULTI_CMD: /* MMCSD device ioctl multi commands */ { finfo("MMC_IOC_MULTI_CMD\n"); ret = mmcsd_multi_iocmd(part, (FAR struct mmc_ioc_multi_cmd *)arg);