Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDMMC_CD pin still needed despite EMMC set to non-removable #29

Open
HiFiPhile opened this issue Apr 27, 2023 · 0 comments
Open

SDMMC_CD pin still needed despite EMMC set to non-removable #29

HiFiPhile opened this issue Apr 27, 2023 · 0 comments

Comments

@HiFiPhile
Copy link

Hardware: SAMA5D27 customized board, EMMC connected to SDMMC0. SDMMC0_CD pin pulled-down for BootROM, also used as LED output.

Software: 76f7f55

Issue:
U-Boot can't detect EMMC despite it set to non-removable in DT, unless SDMMC0_CD is used (so this pin can't be used for other purpose)

sdmmc0: sdio-host@a0000000 {
			bus-width = <4>;
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_sdmmc0_default>;
			status = "okay";
			non-removable;
			no-1-8-v;
		};

Workaround: I have to FCD bit of SDMMC_MC1R register.

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 766e4a6b0c..89ceeaf3c1 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -758,7 +758,12 @@ static int sdhci_get_cd(struct udevice *dev)

        /* If nonremovable, assume that the card is always present. */
        if (mmc->cfg->host_caps & MMC_CAP_NONREMOVABLE)
+       {
+               value = sdhci_readb(host, SDHCI_HOST_MC1R);
+               sdhci_writeb(host, SDHCI_VENDOR_MC1R_FCD | value, SDHCI_HOST_MC1R);
                return 1;
+       }
+
        /* If polling, assume that the card is always present. */
        if (mmc->cfg->host_caps & MMC_CAP_NEEDS_POLL)
                return 1;
diff --git a/include/sdhci.h b/include/sdhci.h
index c718dd7206..61e7ebb2a1 100644
--- a/include/sdhci.h
+++ b/include/sdhci.h
@@ -223,6 +223,9 @@

 #define SDHCI_GET_VERSION(x) (x->version & SDHCI_SPEC_VER_MASK)

+#define SDHCI_HOST_MC1R                        0x204
+
+#define SDHCI_VENDOR_MC1R_FCD  0x80
 /*
  * End of controller registers.
  */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant