[U-Boot] [PATCH] mmc: implement SDHCI card detect

Ibai Erkiaga ibai.erkiaga-elorza at xilinx.com
Thu May 23 13:54:59 UTC 2019


Card detect function implemented for SDHCI framework.

Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza at xilinx.com>
---

 drivers/mmc/sdhci.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index e2bb90a..cb4db8d 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -390,6 +390,21 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 		return -ECOMM;
 }
 
+#if IS_ENABLED(CONFIG_DM_MMC)
+static int sdhci_get_cd(struct udevice *dev)
+{
+	struct mmc *mmc = mmc_get_mmc_dev(dev);
+#else
+static int sdhci_get_cd(struct mmc *mmc)
+{
+#endif
+	u32 state;
+	struct sdhci_host *host = mmc->priv;
+
+	state = sdhci_readl(host, SDHCI_PRESENT_STATE);
+	return (state & SDHCI_CARD_PRESENT);
+}
+
 #if defined(CONFIG_DM_MMC) && defined(MMC_SUPPORTS_TUNING)
 static int sdhci_execute_tuning(struct udevice *dev, uint opcode)
 {
@@ -627,6 +642,7 @@ int sdhci_probe(struct udevice *dev)
 const struct dm_mmc_ops sdhci_ops = {
 	.send_cmd	= sdhci_send_command,
 	.set_ios	= sdhci_set_ios,
+	.get_cd		= sdhci_get_cd,
 #ifdef MMC_SUPPORTS_TUNING
 	.execute_tuning	= sdhci_execute_tuning,
 #endif
@@ -635,6 +651,7 @@ const struct dm_mmc_ops sdhci_ops = {
 static const struct mmc_ops sdhci_ops = {
 	.send_cmd	= sdhci_send_command,
 	.set_ios	= sdhci_set_ios,
+	.get_cd		= sdhci_get_cd,
 	.init		= sdhci_init,
 };
 #endif
-- 
1.8.3.1



More information about the U-Boot mailing list