MMC/SD SDIO: Some drivers need to start DMA before sending CMD24 and some AFTER

This commit is contained in:
Alan Carvalho de Assis
2017-02-09 11:13:05 -06:00
committed by Gregory Nutt
parent abcbb24cf2
commit 248d5d3185
2 changed files with 30 additions and 9 deletions
+27 -7
View File
@@ -1694,14 +1694,19 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
return ret;
}
/* Send CMD24, WRITE_BLOCK, and verify that good R1 status is returned */
/* If Controller doesn't need DMA before Write then send CMD */
mmcsd_sendcmdpoll(priv, MMCSD_CMD24, offset);
ret = mmcsd_recvR1(priv, MMCSD_CMD24);
if (ret != OK)
if ((priv->caps & SDIO_CAPS_DMABEFOREWRITE) == 0)
{
ferr("ERROR: mmcsd_recvR1 for CMD24 failed: %d\n", ret);
return ret;
/* Send CMD24, WRITE_BLOCK, and verify that good R1 status is returned */
mmcsd_sendcmdpoll(priv, MMCSD_CMD24, offset);
ret = mmcsd_recvR1(priv, MMCSD_CMD24);
if (ret != OK)
{
ferr("ERROR: mmcsd_recvR1 for CMD24 failed: %d\n", ret);
return ret;
}
}
/* Configure SDIO controller hardware for the write transfer */
@@ -1732,6 +1737,21 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
priv->wrbusy = true;
/* If Controller needs DMA before Write then only send CMD now */
if ((priv->caps & SDIO_CAPS_DMABEFOREWRITE) != 0)
{
/* Send CMD24, WRITE_BLOCK, and verify that good R1 status is returned */
mmcsd_sendcmdpoll(priv, MMCSD_CMD24, offset);
ret = mmcsd_recvR1(priv, MMCSD_CMD24);
if (ret != OK)
{
ferr("ERROR: mmcsd_recvR1 for CMD24 failed: %d\n", ret);
return ret;
}
}
/* Wait for the transfer to complete */
ret = mmcsd_eventwait(priv,
@@ -2238,7 +2258,7 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry)
geometry->geo_mediachanged ? "true" : "false",
geometry->geo_writeenabled ? "true" : "false");
finfo("nsectors: %lu sectorsize: %d\n",
((unsigned long))geometry->geo_nsectors,
(unsigned long)geometry->geo_nsectors,
geometry->geo_sectorsize);
priv->mediachanged = false;
+3 -2
View File
@@ -380,8 +380,9 @@
/* SDIO capability bits */
#define SDIO_CAPS_1BIT_ONLY 0x01 /* Bit 0=1: Supports only 1-bit operation */
#define SDIO_CAPS_DMASUPPORTED 0x02 /* Bit 1=1: Supports DMA data transfers */
#define SDIO_CAPS_1BIT_ONLY 0x01 /* Bit 0=1: Supports only 1-bit operation */
#define SDIO_CAPS_DMASUPPORTED 0x02 /* Bit 1=1: Supports DMA data transfers */
#define SDIO_CAPS_DMABEFOREWRITE 0x04 /* Bit 2=1: Executes DMA before write command */
/****************************************************************************
* Name: SDIO_STATUS