mmcsd: fix MMC bus width switch using wrong condition and add 8-bit support

The MMC CMD6 bus width switch was gated on priv->buswidth which is
derived from the SD SCR register. For MMC cards this field is never
set (unless SDIO_CAPS_4BIT_ONLY), so the CMD6 was skipped while the
host PROCTL DTW was still changed - causing a bus width mismatch and
data transfer timeouts.

Fix by checking priv->caps instead of priv->buswidth for MMC cards.
Also select EXT_CSD_BUS_WIDTH_8 when host reports SDIO_CAPS_8BIT.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
buxiasen
2026-03-06 15:48:48 +08:00
committed by Xiang Xiao
parent 7a3b7922ee
commit 9feaa4d841
+14 -6
View File
@@ -2822,15 +2822,23 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv)
}
#ifdef CONFIG_MMCSD_MMCSUPPORT
else if (IS_MMC(priv->type) &&
((priv->buswidth & MMCSD_SCR_BUSWIDTH_4BIT) != 0 &&
(priv->caps & SDIO_CAPS_1BIT_ONLY) == 0))
(priv->caps & SDIO_CAPS_1BIT_ONLY) == 0)
{
/* SD card supports 4-bit BUS and host settings is not 1-bit only.
* Configuring MMC - Use MMC_SWITCH access modes.
/* Configuring MMC - Use MMC_SWITCH access modes.
* Select 8-bit if host supports it, otherwise 4-bit.
*/
mmcsd_sendcmdpoll(priv, MMCSD_CMD6,
MMC_CMD6_BUSWIDTH(EXT_CSD_BUS_WIDTH_4));
if (priv->caps & SDIO_CAPS_8BIT)
{
mmcsd_sendcmdpoll(priv, MMCSD_CMD6,
MMC_CMD6_BUSWIDTH(EXT_CSD_BUS_WIDTH_8));
}
else
{
mmcsd_sendcmdpoll(priv, MMCSD_CMD6,
MMC_CMD6_BUSWIDTH(EXT_CSD_BUS_WIDTH_4));
}
ret = mmcsd_recv_r1(priv, MMCSD_CMD6);
if (ret != OK)