Skip to content

Commit 49cbcfb

Browse files
Windrow14xiaoxiang781216
authored andcommitted
drivers/mmcsd/mmcsd.h|mmcsd_sdio.c|mmcsd_sdio.h: support MMC high speed SDR mode
According to the eMMC specification, in Backwards Compatibility with legacy MMC card mode, the frequency of the SD clock must be 0-26 MHZ; in high speed SDR mode, it must be 0-52MHZ. So we should switch to high speed SDR mode if the clock frequency is higher than 26MHZ. Signed-off-by: Yinzhe Wu <Yinzhe.Wu@sony.com> Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Reviewed-by: Jacky Cao <Jacky.Cao@sony.com> Tested-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
1 parent 08ce36d commit 49cbcfb

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

drivers/mmcsd/mmcsd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct mmcsd_state_s
8181
uint8_t dma:1; /* true: hardware supports DMA */
8282
#endif
8383

84-
uint8_t mode:2; /* (See MMCSDMODE_* definitions) */
84+
uint8_t mode:4; /* (See MMCSDMODE_* definitions) */
8585
uint8_t type:4; /* Card type (See MMCSD_CARDTYPE_* definitions) */
8686
uint8_t buswidth:4; /* Bus widths supported (SD only) */
8787
sdio_capset_t caps; /* SDIO driver capabilities/limitations */

drivers/mmcsd/mmcsd_sdio.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,20 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv)
25832583
#ifdef CONFIG_MMCSD_MMCSUPPORT
25842584
else
25852585
{
2586+
if (priv->caps & SDIO_CAPS_MMC_HS_MODE)
2587+
{
2588+
mmcsd_sendcmdpoll(priv, MMCSD_CMD6,
2589+
MMC_CMD6_HS_TIMING(EXT_CSD_HS_TIMING_HS));
2590+
ret = mmcsd_recv_r1(priv, MMCSD_CMD6);
2591+
if (ret != OK)
2592+
{
2593+
ferr("ERROR: (MMCSD_CMD6) Setting MMC speed mode: %d\n", ret);
2594+
return ret;
2595+
}
2596+
2597+
priv->mode = EXT_CSD_HS_TIMING_HS;
2598+
}
2599+
25862600
SDIO_CLOCK(priv->dev, CLOCK_MMC_TRANSFER);
25872601
}
25882602
#endif /* #ifdef CONFIG_MMCSD_MMCSUPPORT */

drivers/mmcsd/mmcsd_sdio.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#define MMC_CMD6_MODE_WRITE_BYTE (0x03) /* Set target to value */
6060

6161
#define EXT_CSD_BUS_WIDTH 183 /* WO */
62+
#define EXT_CSD_HS_TIMING 185 /* R/W */
6263

6364
/* EXT_CSD_BUS_WIDTH */
6465
#define EXT_CSD_BUS_WIDTH_1 (0x00) /* Card is in 1 bit mode */
@@ -71,6 +72,16 @@
7172
MMC_CMD6_INDEX(EXT_CSD_BUS_WIDTH) | \
7273
MMC_CMD6_MODE(MMC_CMD6_MODE_WRITE_BYTE))
7374

75+
/* EXT_CSD_HS_TIMING */
76+
#define EXT_CSD_HS_TIMING_BC 0
77+
#define EXT_CSD_HS_TIMING_HS 1
78+
#define EXT_CSD_HS_TIMING_HS200 2
79+
#define EXT_CSD_HS_TIMING_HS400 3
80+
81+
#define MMC_CMD6_HS_TIMING(timing) (MMC_CMD6_VALUE(timing) | \
82+
MMC_CMD6_INDEX(EXT_CSD_HS_TIMING) | \
83+
MMC_CMD6_MODE(MMC_CMD6_MODE_WRITE_BYTE))
84+
7485
/* CMD8 Argument:
7586
* [31:12]: Reserved (shall be set to '0')
7687
* [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)

include/nuttx/sdio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@
479479
#define SDIO_CAPS_4BIT 0x08 /* Bit 3=1: Supports 4 bit operation */
480480
#define SDIO_CAPS_8BIT 0x10 /* Bit 4=1: Supports 8 bit operation */
481481
#define SDIO_CAPS_4BIT_ONLY 0x20 /* Bit 5=1: Supports 4-bit only operation */
482+
#define SDIO_CAPS_MMC_HS_MODE 0x40 /* Bit 6=1: Supports eMMC high speed mode */
482483

483484
/****************************************************************************
484485
* Name: SDIO_STATUS

0 commit comments

Comments
 (0)