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>
This commit is contained in:
Windrow14 2024-08-12 13:22:19 +08:00 committed by Xiang Xiao
parent 08ce36d292
commit 49cbcfb5e6
4 changed files with 27 additions and 1 deletions

View File

@ -81,7 +81,7 @@ struct mmcsd_state_s
uint8_t dma:1; /* true: hardware supports DMA */
#endif
uint8_t mode:2; /* (See MMCSDMODE_* definitions) */
uint8_t mode:4; /* (See MMCSDMODE_* definitions) */
uint8_t type:4; /* Card type (See MMCSD_CARDTYPE_* definitions) */
uint8_t buswidth:4; /* Bus widths supported (SD only) */
sdio_capset_t caps; /* SDIO driver capabilities/limitations */

View File

@ -2583,6 +2583,20 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv)
#ifdef CONFIG_MMCSD_MMCSUPPORT
else
{
if (priv->caps & SDIO_CAPS_MMC_HS_MODE)
{
mmcsd_sendcmdpoll(priv, MMCSD_CMD6,
MMC_CMD6_HS_TIMING(EXT_CSD_HS_TIMING_HS));
ret = mmcsd_recv_r1(priv, MMCSD_CMD6);
if (ret != OK)
{
ferr("ERROR: (MMCSD_CMD6) Setting MMC speed mode: %d\n", ret);
return ret;
}
priv->mode = EXT_CSD_HS_TIMING_HS;
}
SDIO_CLOCK(priv->dev, CLOCK_MMC_TRANSFER);
}
#endif /* #ifdef CONFIG_MMCSD_MMCSUPPORT */

View File

@ -59,6 +59,7 @@
#define MMC_CMD6_MODE_WRITE_BYTE (0x03) /* Set target to value */
#define EXT_CSD_BUS_WIDTH 183 /* WO */
#define EXT_CSD_HS_TIMING 185 /* R/W */
/* EXT_CSD_BUS_WIDTH */
#define EXT_CSD_BUS_WIDTH_1 (0x00) /* Card is in 1 bit mode */
@ -71,6 +72,16 @@
MMC_CMD6_INDEX(EXT_CSD_BUS_WIDTH) | \
MMC_CMD6_MODE(MMC_CMD6_MODE_WRITE_BYTE))
/* EXT_CSD_HS_TIMING */
#define EXT_CSD_HS_TIMING_BC 0
#define EXT_CSD_HS_TIMING_HS 1
#define EXT_CSD_HS_TIMING_HS200 2
#define EXT_CSD_HS_TIMING_HS400 3
#define MMC_CMD6_HS_TIMING(timing) (MMC_CMD6_VALUE(timing) | \
MMC_CMD6_INDEX(EXT_CSD_HS_TIMING) | \
MMC_CMD6_MODE(MMC_CMD6_MODE_WRITE_BYTE))
/* CMD8 Argument:
* [31:12]: Reserved (shall be set to '0')
* [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)

View File

@ -479,6 +479,7 @@
#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 */
#define SDIO_CAPS_MMC_HS_MODE 0x40 /* Bit 6=1: Supports eMMC high speed mode */
/****************************************************************************
* Name: SDIO_STATUS