diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index c889c7bc985..01cca7c8b58 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -21,6 +21,9 @@ #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; /* DWCMSHC specific Mode Select value */ #define DWCMSHC_CTRL_HS400 0x7 @@ -607,12 +610,21 @@ static int rockchip_sdhci_probe(struct udevice *dev) return ret; /* - * Disable use of DMA and force use of PIO mode in SPL to fix an issue - * where loading part of TF-A into SRAM using DMA silently fails. + * Use a bounce buffer or PIO mode in SPL to fix an issue where loading + * part of TF-A directly into SRAM using DMA silently fails. */ if (IS_ENABLED(CONFIG_SPL_BUILD) && - dev_read_bool(dev, "u-boot,spl-fifo-mode")) - host->flags &= ~USE_DMA; + dev_read_bool(dev, "u-boot,spl-fifo-mode")) { + if (CONFIG_IS_ENABLED(SYS_MALLOC_F) && + gd->malloc_limit > SDHCI_DEFAULT_BOUNDARY_SIZE) { + cfg->b_max = SDHCI_DEFAULT_BOUNDARY_SIZE / + MMC_MAX_BLOCK_LEN; + host->force_align_buffer = true; + host->quirks |= SDHCI_QUIRK_32BIT_DMA_ADDR; + } else { + host->flags &= ~USE_DMA; + } + } return sdhci_probe(dev); } diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index af654ea8d13..4413f8de832 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -736,7 +736,7 @@ static int sdhci_init(struct mmc *mmc) host->force_align_buffer = true; #else if (host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) { - host->align_buffer = memalign(8, 512 * 1024); + host->align_buffer = memalign(8, SDHCI_DEFAULT_BOUNDARY_SIZE); if (!host->align_buffer) { printf("%s: Aligned buffer alloc failed!!!\n", __func__);