You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/03/29 18:35:36 UTC
[incubator-nuttx] 02/05: driver/mmcsd: add option to support SD/MMC PHYs that only run in 4-bit mode
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 163e3fd93cd661d97cc38aaadc0210554fe2f0f8
Author: Richard Tucker <ri...@motec.com.au>
AuthorDate: Thu Mar 24 14:56:40 2022 +1100
driver/mmcsd: add option to support SD/MMC PHYs that only run in 4-bit mode
---
drivers/mmcsd/mmcsd_sdio.c | 29 ++++++++++++++++++++++++-----
include/nuttx/sdio.h | 1 +
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c
index d0fa5c4..bcb8e77 100644
--- a/drivers/mmcsd/mmcsd_sdio.c
+++ b/drivers/mmcsd/mmcsd_sdio.c
@@ -2881,6 +2881,22 @@ static int mmcsd_sdinitialize(FAR struct mmcsd_state_s *priv)
SDIO_CLOCK(priv->dev, CLOCK_SD_TRANSFER_1BIT);
nxsig_usleep(MMCSD_CLK_DELAY);
+ /* If the hardware only supports 4-bit transfer mode then we forced to
+ * attempt to setup the card in this mode before checking the SCR register.
+ */
+
+ if ((priv->caps & SDIO_CAPS_4BIT_ONLY) != 0)
+ {
+ /* Select width (4-bit) bus operation */
+
+ priv->buswidth = 4;
+ ret = mmcsd_widebus(priv);
+ if (ret != OK)
+ {
+ ferr("ERROR: Failed to set wide bus operation: %d\n", ret);
+ }
+ }
+
/* Get the SD card Configuration Register (SCR). We need this now because
* that configuration register contains the indication whether or not
* this card supports wide bus operation.
@@ -2895,12 +2911,15 @@ static int mmcsd_sdinitialize(FAR struct mmcsd_state_s *priv)
mmcsd_decode_scr(priv, scr);
- /* Select width (4-bit) bus operation (if the card supports it) */
-
- ret = mmcsd_widebus(priv);
- if (ret != OK)
+ if ((priv->caps & SDIO_CAPS_4BIT_ONLY) == 0)
{
- ferr("ERROR: Failed to set wide bus operation: %d\n", ret);
+ /* Select width (4-bit) bus operation (if the card supports it) */
+
+ ret = mmcsd_widebus(priv);
+ if (ret != OK)
+ {
+ ferr("ERROR: Failed to set wide bus operation: %d\n", ret);
+ }
}
/* TODO: If wide-bus selected, then send CMD6 to see if the card supports
diff --git a/include/nuttx/sdio.h b/include/nuttx/sdio.h
index 9fa97c8..b32f617 100644
--- a/include/nuttx/sdio.h
+++ b/include/nuttx/sdio.h
@@ -477,6 +477,7 @@
#define SDIO_CAPS_DMABEFOREWRITE 0x04 /* Bit 2=1: Executes DMA before write command */
#define SDIO_CAPS_4BIT 0x08 /* Bit 3=1: Supports 4 bit operation */
#define SDIO_CAPS_8BIT 0x10 /* Bit 4=1: Supports 8 bit operation */
+#define SDIO_CAPS_4BIT_ONLY 0x20 /* Bit 5=1: Supports 4-bit only operation */
/****************************************************************************
* Name: SDIO_STATUS