summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZiyuan Xu <xzy.xu@rock-chips.com>2017-05-15 09:07:02 +0300
committerKever Yang <kever.yang@rock-chips.com>2017-07-18 17:02:27 +0300
commitc212b2bf6b59bf6d015ae1b288b7e352d797357b (patch)
tree739c1fae7a5f532c7dd3a1ea2a63152c7f08ea43
parent849ec3e318e79dd4e7bddb3f31f16c83a87b3fbe (diff)
downloadu-boot-c212b2bf6b59bf6d015ae1b288b7e352d797357b.tar.xz
mmc: sdhci: implement card_busy detection
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
-rw-r--r--drivers/mmc/sdhci.c19
-rw-r--r--include/sdhci.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index ebbe2b3fbe..57445006a0 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -423,6 +423,23 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
}
#ifdef CONFIG_DM_MMC_OPS
+static bool sdhci_card_busy(struct udevice *dev)
+{
+ struct mmc *mmc = mmc_get_mmc_dev(dev);
+#else
+static bool sdhci_card_busy(struct mmc *mmc)
+{
+#endif
+ struct sdhci_host *host = mmc->priv;
+ u32 present_state;
+
+ /* Check whether DAT[0] is 0 */
+ present_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
+
+ return !(present_state & SDHCI_DATA_0_LVL);
+}
+
+#ifdef CONFIG_DM_MMC_OPS
static int sdhci_set_ios(struct udevice *dev)
{
struct mmc *mmc = mmc_get_mmc_dev(dev);
@@ -509,11 +526,13 @@ int sdhci_probe(struct udevice *dev)
}
const struct dm_mmc_ops sdhci_ops = {
+ .card_busy = sdhci_card_busy,
.send_cmd = sdhci_send_command,
.set_ios = sdhci_set_ios,
};
#else
static const struct mmc_ops sdhci_ops = {
+ .card_busy = sdhci_card_busy,
.send_cmd = sdhci_send_command,
.set_ios = sdhci_set_ios,
.init = sdhci_init,
diff --git a/include/sdhci.h b/include/sdhci.h
index 6a43271e96..75432dbab2 100644
--- a/include/sdhci.h
+++ b/include/sdhci.h
@@ -64,6 +64,7 @@
#define SDHCI_CARD_STATE_STABLE BIT(17)
#define SDHCI_CARD_DETECT_PIN_LEVEL BIT(18)
#define SDHCI_WRITE_PROTECT BIT(19)
+#define SDHCI_DATA_0_LVL BIT(20)
#define SDHCI_HOST_CONTROL 0x28
#define SDHCI_CTRL_LED BIT(0)