]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: Support 32-bit only ADMA on 64-bit platforms
authorGreg Malysa <greg.malysa@timesys.com>
Tue, 26 Mar 2024 02:28:08 +0000 (22:28 -0400)
committerJaehoon Chung <jh80.chung@samsung.com>
Fri, 26 Apr 2024 06:31:11 +0000 (15:31 +0900)
Some arm64 platforms may include SDIO host controllers that
only support 32-bit ADMA. While the Linux kernel detects which
size is supported and adjusts the descriptor size used dynamically,
the previous u-boot implementation statically selected between the
two depending on whether DMA_ADDR_T_64BIT was defined. Because the
static selection is already in place and effective for most platforms,
this patch logically separates "64 bit addresses are used for DMA on
this platform" and "64 bit addresses are used by the SDIO host
controller for ADMA" in order to support the small number of platforms
where these statements are not equivalent.

Using 32 bits is opt-in and existing 64 bit platforms should be
unaffected by this change.

Co-developed-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
Signed-off-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
Co-developed-by: Ian Roberts <ian.roberts@timesys.com>
Signed-off-by: Ian Roberts <ian.roberts@timesys.com>
Signed-off-by: Greg Malysa <greg.malysa@timesys.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/mmc/Kconfig
drivers/mmc/sdhci-adma.c
drivers/mmc/sdhci.c
include/sdhci.h

index 06e32e75696af2a661a3d16dd82d716048e0620f..549634891a36d9a3a56bf916efb283cdf91284d1 100644 (file)
@@ -504,6 +504,24 @@ config SPL_MMC_SDHCI_ADMA
          This enables support for the ADMA (Advanced DMA) defined
          in the SD Host Controller Standard Specification Version 3.00 in SPL.
 
+config MMC_SDHCI_ADMA_FORCE_32BIT
+       bool "Force 32 bit mode for ADMA on 64 bit platforms"
+       help
+         This forces SDHCI ADMA to be built for 32 bit descriptors, even
+         on a 64 bit platform where they would otherwise be assumed to
+         be 64 bits. This is necessary for certain hardware platforms
+         that are 64-bit but include only 32-bit support within the selected
+         SD host controller IP.
+
+config MMC_SDHCI_ADMA_64BIT
+       bool "Use SHDCI ADMA with 64 bit descriptors"
+       depends on !MMC_SDHCI_ADMA_FORCE_32BIT
+       default y if DMA_ADDR_T_64BIT
+       help
+         This selects 64 bit descriptors for SDHCI ADMA. It is enabled by
+         default on 64 bit systems, but can be disabled if one of these
+         systems includes 32-bit ADMA.
+
 config FIXED_SDHCI_ALIGNED_BUFFER
        hex "SDRAM address for fixed buffer"
        depends on SPL && MVEBU_SPL_BOOT_DEVICE_MMC
index 8c38448b6a383662f7283d315ead7f7f2825c1e7..283ba956deb9514130a7f60f8ac40a6ce8b2e86d 100644 (file)
@@ -23,7 +23,7 @@ void sdhci_adma_write_desc(struct sdhci_host *host, void **next_desc,
        desc->len = len & 0xffff;
        desc->reserved = 0;
        desc->addr_lo = lower_32_bits(addr);
-#ifdef CONFIG_DMA_ADDR_T_64BIT
+#ifdef CONFIG_MMC_SDHCI_ADMA_64BIT
        desc->addr_hi = upper_32_bits(addr);
 #endif
 
index 65090348aeeddf4933e6ed6c92c155cda1d16265..ceeac32882fb17c11ce370e926bb5c540c959c64 100644 (file)
@@ -902,11 +902,10 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host,
                host->adma_addr = virt_to_phys(host->adma_desc_table);
        }
 
-#ifdef CONFIG_DMA_ADDR_T_64BIT
-       host->flags |= USE_ADMA64;
-#else
-       host->flags |= USE_ADMA;
-#endif
+       if (IS_ENABLED(CONFIG_MMC_SDHCI_ADMA_64BIT))
+               host->flags |= USE_ADMA64;
+       else
+               host->flags |= USE_ADMA;
 #endif
        if (host->quirks & SDHCI_QUIRK_REG32_RW)
                host->version =
index 2dd13b4c714a5c1d85c89aa0351a1303db0efcbb..78ef0d1c088db5739c4ab9000e214415964cfcda 100644 (file)
@@ -300,7 +300,7 @@ struct sdhci_ops {
 };
 
 #define ADMA_MAX_LEN   65532
-#ifdef CONFIG_DMA_ADDR_T_64BIT
+#ifdef CONFIG_MMC_SDHCI_ADMA_64BIT
 #define ADMA_DESC_LEN  16
 #else
 #define ADMA_DESC_LEN  8
@@ -325,7 +325,7 @@ struct sdhci_adma_desc {
        u8 reserved;
        u16 len;
        u32 addr_lo;
-#ifdef CONFIG_DMA_ADDR_T_64BIT
+#ifdef CONFIG_MMC_SDHCI_ADMA_64BIT
        u32 addr_hi;
 #endif
 } __packed;