]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mmc: exynos_dw_mmc: Add quirk for disabling FMP
authorSam Protsenko <semen.protsenko@linaro.org>
Sun, 26 Oct 2025 01:06:56 +0000 (20:06 -0500)
committerPeng Fan <peng.fan@nxp.com>
Fri, 7 Nov 2025 01:28:29 +0000 (09:28 +0800)
Add DWMCI_QUIRK_DISABLE_FMP which disables Flash Memory Protector (FMP)
during driver's init. It's usually done by early bootloaders, but in
some cases (like USB boot) the FMP may be left unconfigured. The issue
was observed on Exynos850 SoC (the E850-96 board). Enabling this quirk
makes eMMC functional even in such cases.

No functional change, as this feature is only added here but not enabled
for any chips yet.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Anand Moon <linux.amoon@gmail.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
arch/arm/mach-exynos/include/mach/dwmmc.h
drivers/mmc/exynos_dw_mmc.c

index 75d84988b7d6e255906607a7a61cd213c2153a5a..4432deedef7defd21a7cbc5ee3a7cba94864fb6a 100644 (file)
 
 /* Protector Register */
 #define DWMCI_EMMCP_BASE               0x1000
+#define EMMCP_MPSECURITY               (DWMCI_EMMCP_BASE + 0x0010)
 #define EMMCP_MPSBEGIN0                        (DWMCI_EMMCP_BASE + 0x0200)
 #define EMMCP_SEND0                    (DWMCI_EMMCP_BASE + 0x0204)
 #define EMMCP_CTRL0                    (DWMCI_EMMCP_BASE + 0x020c)
 
+/* EMMCP_MPSECURITY bits */
+#define MPSECURITY_FMP_ON              BIT(29)
+#define MPSECURITY_MMC_SFR_PROT_ON     BIT(28)
+
+/* EMMCP_CTRL0 bits */
 #define MPSCTRL_SECURE_READ_BIT                BIT(7)
 #define MPSCTRL_SECURE_WRITE_BIT       BIT(6)
 #define MPSCTRL_NON_SECURE_READ_BIT    BIT(5)
index 51867a55249565f4d38775d0d83a52f8d2e928f8..be17bc4692c1aaccba05c43aeb83146e9d8c5e6f 100644 (file)
  *
  * %DWMCI_QUIRK_DISABLE_SMU: DW MMC block has Security Management Unit (SMU)
  * which has to be configured in non-encryption mode during driver's init.
+ *
+ * %DWMCI_QUIRK_DISABLE_FMP: DW MMC block has Flash Memory Protector (FMP) which
+ * has to be disabled during driver's init. This flag disables FMP encryption
+ * and lets external non-secure main CPUs access the SFR (peripheral memory
+ * region, i.e. registers) in MMC core. Although it's usually done by early
+ * bootloaders (before U-Boot), in some cases like during USB boot the FMP might
+ * be left unconfigured.
  */
 #define DWMCI_QUIRK_DISABLE_SMU                BIT(0)
+#define DWMCI_QUIRK_DISABLE_FMP                BIT(1)
 
 #ifdef CONFIG_DM_MMC
 #include <dm.h>
@@ -225,6 +233,18 @@ static void exynos_dwmci_board_init(struct dwmci_host *host)
                             MPSCTRL_NON_SECURE_WRITE_BIT | MPSCTRL_VALID);
        }
 
+       if (priv->chip->quirks & DWMCI_QUIRK_DISABLE_FMP) {
+               u32 reg;
+
+               reg = dwmci_readl(host, EMMCP_MPSECURITY);
+               if (reg & MPSECURITY_FMP_ON ||
+                   reg & MPSECURITY_MMC_SFR_PROT_ON) {
+                       reg &= ~MPSECURITY_FMP_ON;
+                       reg &= ~MPSECURITY_MMC_SFR_PROT_ON;
+                       dwmci_writel(host, EMMCP_MPSECURITY, reg);
+               }
+       }
+
        if (priv->sdr_timing)
                exynos_dwmci_clksel(host);
 }