[PATCH v2 2/5] mmc: rockchip_sdhci: Disable DMA mode using a device tree property

Jonas Karlman jonas at kwiboo.se
Wed May 17 20:40:38 CEST 2023


Loading part of TF-A into SRAM from eMMC using DMA fails on RK3399
similar to other Rockchip SoCs. Checksum validation fails with:

  ## Checking hash(es) for Image atf-2 ... sha256 error!
  Bad hash value for 'hash' hash node in 'atf-2' image node
  spl_load_simple_fit: can't load image loadables index 1 (ret = -1)
  mmc_load_image_raw_sector: mmc block read error
  SPL: failed to boot from all boot devices
  ### ERROR ### Please RESET the board ###

Add a device tree property, u-boot,spl-fifo-mode, to control when the
rockchip_sdhci driver should disable the use of DMA and fallback on PIO
mode. Same device tree property is used by the rockchip_dw_mmc driver.

In commit 2cc6cde647e2 ("mmc: rockchip_sdhci: Limit number of blocks
read in a single command") the DMA mode was disabled using a CONFIG
option on RK3588. Revert that and instead disable DMA using the device
tree property for all RK3588 boards, also apply similar workaround for
all RK3399 boards.

Fixes: 2cc6cde647e2 ("mmc: rockchip_sdhci: Limit number of blocks read in a single command")
Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>
Tested-by: Quentin Schulz <foss+uboot at 0leil.net> # RK3399 Puma, RK3588 Tiger
---
v2:
- Rebase on top of defconfig and spi v2 series
- Collect r-b and t-b tags

 arch/arm/dts/rk3399-u-boot.dtsi  | 1 +
 arch/arm/dts/rk3588s-u-boot.dtsi | 1 +
 configs/rock5b-rk3588_defconfig  | 1 -
 drivers/mmc/rockchip_sdhci.c     | 8 ++++++++
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/rk3399-u-boot.dtsi b/arch/arm/dts/rk3399-u-boot.dtsi
index e677ae678dab..3423b882c437 100644
--- a/arch/arm/dts/rk3399-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-u-boot.dtsi
@@ -120,6 +120,7 @@
 &sdhci {
 	max-frequency = <200000000>;
 	bootph-all;
+	u-boot,spl-fifo-mode;
 };
 
 &sdmmc {
diff --git a/arch/arm/dts/rk3588s-u-boot.dtsi b/arch/arm/dts/rk3588s-u-boot.dtsi
index 64c309046587..c703e41802b6 100644
--- a/arch/arm/dts/rk3588s-u-boot.dtsi
+++ b/arch/arm/dts/rk3588s-u-boot.dtsi
@@ -239,6 +239,7 @@
 
 &sdhci {
 	bootph-pre-ram;
+	u-boot,spl-fifo-mode;
 };
 
 &uart2 {
diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig
index 9d0b55c01ac9..c1155c20efa8 100644
--- a/configs/rock5b-rk3588_defconfig
+++ b/configs/rock5b-rk3588_defconfig
@@ -66,7 +66,6 @@ CONFIG_MMC_DW=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SDMA=y
-# CONFIG_SPL_MMC_SDHCI_SDMA is not set
 CONFIG_MMC_SDHCI_ROCKCHIP=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_XTX=y
diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index 8e4a158049a9..285332d9f4fd 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -589,6 +589,14 @@ static int rockchip_sdhci_probe(struct udevice *dev)
 	if (ret)
 		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.
+	 */
+	if (IS_ENABLED(CONFIG_SPL_BUILD) &&
+	    dev_read_bool(dev, "u-boot,spl-fifo-mode"))
+		host->flags &= ~USE_DMA;
+
 	/*
 	 * Reading more than 4 blocks with a single CMD18 command in PIO mode
 	 * triggers Data End Bit Error on RK3568 and RK3588. Limit to reading
-- 
2.40.1



More information about the U-Boot mailing list