[U-Boot] [PATCH v1 2/2] mmc: sdhci: Read sdhci card detect properties from DT

Michal Simek michal.simek at xilinx.com
Fri Jun 7 08:35:07 UTC 2019


From: T Karthik Reddy <t.karthik.reddy at xilinx.com>

This patch reads card detect properties from device tree.

Signed-off-by: T Karthik Reddy <t.karthik.reddy at xilinx.com>
Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---

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

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 67ca324c9320..a451ccbdf014 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -591,7 +591,22 @@ static int sdhci_set_ios(struct mmc *mmc)
 static int sdhci_init(struct mmc *mmc)
 {
 	struct sdhci_host *host = mmc->priv;
+#if CONFIG_IS_ENABLED(DM_MMC)
+	struct udevice *dev = mmc->dev;
 
+	if (dev_read_bool(dev, "non-removable")) {
+		host->host_caps |= MMC_CAP_NONREMOVABLE;
+	} else {
+		if (dev_read_bool(dev, "cd-inverted"))
+			host->host_caps |= MMC_CAP_CD_ACTIVE_HIGH;
+		if (dev_read_bool(dev, "broken-cd"))
+			host->host_caps |= MMC_CAP_NEEDS_POLL;
+#if CONFIG_IS_ENABLED(DM_GPIO)
+		gpio_request_by_name(dev, "cd-gpio", 0,
+				     &host->cd_gpio, GPIOD_IS_IN);
+#endif
+	}
+#endif
 	sdhci_reset(host, SDHCI_RESET_ALL);
 
 	if ((host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) && !aligned_buffer) {
-- 
2.17.1



More information about the U-Boot mailing list