From e3e641993a1a5148e71bdd3f7b3cb5da695b1632 Mon Sep 17 00:00:00 2001
From: Yangbo Lu <yangbo.lu@nxp.com>
Date: Fri, 20 May 2016 11:17:30 +0800
Subject: [PATCH 34/93] mmc: fsl_esdhc: add workaround for non-removable card
 of esdhc-2

The esdhc-2 usually uses some on-board memory devices such as eMMC
card or SDIO wifi module, and it doesn't support SDHC_CD_B. So we
could only assume it always has a card instead of detecting SDHC_CD_B
status. This patch is to add workaround for these non-removable
cards which are used by esdhc-2.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
 drivers/mmc/fsl_esdhc.c |    6 +++++-
 include/fsl_esdhc.h     |    1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index cacf879..2c6e175 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -628,6 +628,8 @@ static int esdhc_getcd(struct mmc *mmc)
 	struct fsl_esdhc *regs = (struct fsl_esdhc *)cfg->esdhc_base;
 	int timeout = 1000;
 
+	if (cfg->non_removable_card)
+		return 1;
 #ifdef CONFIG_ESDHC_DETECT_QUIRK
 	if (CONFIG_ESDHC_DETECT_QUIRK)
 		return 1;
@@ -759,7 +761,9 @@ int fsl_esdhc_mmc_init(bd_t *bis)
 	cfg_1 = calloc(sizeof(struct fsl_esdhc_cfg), 1);
 	cfg_1->esdhc_base = CONFIG_SYS_FSL_ESDHC_1_ADDR;
 	cfg_1->sdhc_clk = gd->arch.sdhc_clk;
-
+#ifdef CONFIG_FSL_ESDHC_1_NON_REMOVABLE_CARD
+	cfg_1->non_removable_card = true;
+#endif
 	if (fsl_esdhc_initialize(bis, cfg))
 		return -1;
 	if (fsl_esdhc_initialize(bis, cfg_1))
diff --git a/include/fsl_esdhc.h b/include/fsl_esdhc.h
index 073048f..8335106 100644
--- a/include/fsl_esdhc.h
+++ b/include/fsl_esdhc.h
@@ -175,6 +175,7 @@ struct fsl_esdhc_cfg {
 #endif
 	u32	sdhc_clk;
 	u8	max_bus_width;
+	bool	non_removable_card;
 	struct mmc_config cfg;
 };
 
-- 
1.7.9.5

