diff --git a/drivers/mmcsd/mmcsd.h b/drivers/mmcsd/mmcsd.h index f9083711de5..ca5d4623ad3 100644 --- a/drivers/mmcsd/mmcsd.h +++ b/drivers/mmcsd/mmcsd.h @@ -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 */ diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index 177ac6ca516..ddba0cd4bb1 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -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 */ diff --git a/drivers/mmcsd/mmcsd_sdio.h b/drivers/mmcsd/mmcsd_sdio.h index 4f02e7415a2..47006d2ac48 100644 --- a/drivers/mmcsd/mmcsd_sdio.h +++ b/drivers/mmcsd/mmcsd_sdio.h @@ -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) diff --git a/include/nuttx/sdio.h b/include/nuttx/sdio.h index 0862e5a4487..e31df62374c 100644 --- a/include/nuttx/sdio.h +++ b/include/nuttx/sdio.h @@ -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