mmc: Read sd card detect properties from DT
[platform/kernel/u-boot.git] / drivers / mmc / mmc-uclass.c
index f73f072..fa4d1af 100644 (file)
@@ -166,6 +166,19 @@ int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg)
                cfg->host_caps |= MMC_CAP(MMC_HS_200);
        if (dev_read_bool(dev, "mmc-hs200-1_2v"))
                cfg->host_caps |= MMC_CAP(MMC_HS_200);
+       if (dev_read_bool(dev, "mmc-hs400-1_8v"))
+               cfg->host_caps |= MMC_CAP(MMC_HS_400);
+       if (dev_read_bool(dev, "mmc-hs400-1_2v"))
+               cfg->host_caps |= MMC_CAP(MMC_HS_400);
+
+       if (dev_read_bool(dev, "non-removable")) {
+               cfg->host_caps |= MMC_CAP_NONREMOVABLE;
+       } else {
+               if (dev_read_bool(dev, "cd-inverted"))
+                       cfg->host_caps |= MMC_CAP_CD_ACTIVE_HIGH;
+               if (dev_read_bool(dev, "broken-cd"))
+                       cfg->host_caps |= MMC_CAP_NEEDS_POLL;
+       }
 
        return 0;
 }
@@ -364,6 +377,19 @@ static int mmc_blk_probe(struct udevice *dev)
        return 0;
 }
 
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
+    CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
+    CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
+static int mmc_blk_remove(struct udevice *dev)
+{
+       struct udevice *mmc_dev = dev_get_parent(dev);
+       struct mmc_uclass_priv *upriv = dev_get_uclass_priv(mmc_dev);
+       struct mmc *mmc = upriv->mmc;
+
+       return mmc_deinit(mmc);
+}
+#endif
+
 static const struct blk_ops mmc_blk_ops = {
        .read   = mmc_bread,
 #if CONFIG_IS_ENABLED(MMC_WRITE)
@@ -378,6 +404,12 @@ U_BOOT_DRIVER(mmc_blk) = {
        .id             = UCLASS_BLK,
        .ops            = &mmc_blk_ops,
        .probe          = mmc_blk_probe,
+#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || \
+    CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) || \
+    CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
+       .remove         = mmc_blk_remove,
+       .flags          = DM_FLAG_OS_PREPARE,
+#endif
 };
 #endif /* CONFIG_BLK */