diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index d0fa5c4ccf..bcb8e77714 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 9fa97c84c6..b32f61743d 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