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