summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorZixun LI <admin@hifiphile.com>2023-05-17 16:49:45 +0300
committerEugen Hristev <eugen.hristev@collabora.com>2023-07-24 14:21:00 +0300
commite83b6f99fc512acda05691db35e7d83817eac0b9 (patch)
tree879cb0ed8d9e7534805e92dbd66ff74e2eb820ab /drivers
parentf5b9587449f7f240da58c1cf8468d8103386ec8c (diff)
downloadu-boot-e83b6f99fc512acda05691db35e7d83817eac0b9.tar.xz
atmel_sdhci: Force card-detect if MMC_CAP_NONREMOVABLE.
If the device attached to the MMC bus is not removable, set force card-detect bit to bypass card detection procedure, so card detection pin can be used for other purposes. It's also a workaround for SAMA5D2 who doesn't drive CMD if using GPIO for card detection. Signed-off-by: Zixun LI <zli@ogga.fr> Reviewed-by: Eugen Hristev <eugen.hristev@collabora.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/atmel_sdhci.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
index 37b0beeed4..5347ba9043 100644
--- a/drivers/mmc/atmel_sdhci.c
+++ b/drivers/mmc/atmel_sdhci.c
@@ -15,6 +15,9 @@
#define ATMEL_SDHC_MIN_FREQ 400000
#define ATMEL_SDHC_GCK_RATE 240000000
+#define ATMEL_SDHC_MC1R 0x204
+#define ATMEL_SDHC_MC1R_FCD 0x80
+
#ifndef CONFIG_DM_MMC
int atmel_sdhci_init(void *regbase, u32 id)
{
@@ -52,11 +55,37 @@ struct atmel_sdhci_plat {
struct mmc mmc;
};
+static void atmel_sdhci_config_fcd(struct sdhci_host *host)
+{
+ u8 mc1r;
+
+ /* If nonremovable, assume that the card is always present.
+ *
+ * WA: SAMA5D2 doesn't drive CMD if using CD GPIO line.
+ */
+ if ((host->mmc->cfg->host_caps & MMC_CAP_NONREMOVABLE)
+#if CONFIG_IS_ENABLED(DM_GPIO)
+ || dm_gpio_get_value(&host->cd_gpio) >= 0
+#endif
+ ) {
+ sdhci_readb(host, ATMEL_SDHC_MC1R);
+ mc1r |= ATMEL_SDHC_MC1R_FCD;
+ sdhci_writeb(host, mc1r, ATMEL_SDHC_MC1R);
+ }
+}
+
static int atmel_sdhci_deferred_probe(struct sdhci_host *host)
{
struct udevice *dev = host->mmc->dev;
+ int ret;
- return sdhci_probe(dev);
+ ret = sdhci_probe(dev);
+ if (ret)
+ return ret;
+
+ atmel_sdhci_config_fcd(host);
+
+ return 0;
}
static const struct sdhci_ops atmel_sdhci_ops = {
@@ -120,7 +149,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
clk_free(&clk);
- return sdhci_probe(dev);
+ ret = sdhci_probe(dev);
+ if (ret)
+ return ret;
+
+ atmel_sdhci_config_fcd(host);
+
+ return 0;
}
static int atmel_sdhci_bind(struct udevice *dev)