[RFC 6/7] mmc: fsl_esdhc_imx: add CD support when OF_PLATDATA is enabled

Walter Lozano walter.lozano at collabora.com
Mon Mar 30 05:31:57 CEST 2020


Signed-off-by: Walter Lozano <walter.lozano at collabora.com>
---
 drivers/mmc/fsl_esdhc_imx.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 049a1b6ea8..a3a9e5ff96 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -31,6 +31,7 @@
 #include <dm/pinctrl.h>
 #include <dt-structs.h>
 #include <mapmem.h>
+#include <dm/ofnode.h>
 
 #if !CONFIG_IS_ENABLED(BLK)
 #include "mmc_private.h"
@@ -1490,7 +1491,30 @@ static int fsl_esdhc_probe(struct udevice *dev)
 		priv->bus_width = 4;
 	else
 		priv->bus_width = 1;
-	priv->non_removable = 1;
+
+	if (dtplat->non_removable)
+		priv->non_removable = 1;
+	else
+		priv->non_removable = 0;
+
+#if CONFIG_IS_ENABLED(DM_GPIO)
+	if (!priv->non_removable) {
+		struct udevice *gpiodev;
+
+		ret = uclass_get_device_by_platdata(UCLASS_GPIO, (void *)dtplat->cd_gpios->node, &gpiodev);
+
+		if (ret)
+			return ret;
+
+		ret = gpio_dev_request_index(gpiodev, gpiodev->name, "cd-gpios",
+					     dtplat->cd_gpios->arg[0], GPIOD_IS_IN,
+					     dtplat->cd_gpios->arg[1], &priv->cd_gpio);
+
+		if (ret)
+			return ret;
+
+	}
+#endif
 #endif
 
 	if (data)
-- 
2.20.1



More information about the U-Boot mailing list