Merge branch '2020-06-15-misc-bugfixes'
[oweals/u-boot.git] / drivers / mmc / mmc_legacy.c
index 6c8b50830f338a9f658a7224ec778636cf4120ea..2bb12ceeaf105ad630ebfc7d110c559293fb9676 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <log.h>
 #include <malloc.h>
 #include <mmc.h>
 #include "mmc_private.h"
 static struct list_head mmc_devices;
 static int cur_dev_num = -1;
 
-#if !CONFIG_IS_ENABLED(MMC_TINY)
+#if CONFIG_IS_ENABLED(MMC_TINY)
+static struct mmc mmc_static;
+struct mmc *find_mmc_device(int dev_num)
+{
+       return &mmc_static;
+}
+
+void mmc_do_preinit(void)
+{
+       struct mmc *m = &mmc_static;
+#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
+       mmc_set_preinit(m, 1);
+#endif
+       if (m->preinit)
+               mmc_start_init(m);
+}
+
+struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)
+{
+       return &mmc->block_dev;
+}
+#else
 struct mmc *find_mmc_device(int dev_num)
 {
        struct mmc *m;
@@ -129,6 +151,15 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
 {
        struct mmc *mmc = &mmc_static;
 
+       /* First MMC device registered, fail to register a new one.
+        * Given users are not expecting this to fail, instead
+        * of failing let's just return the only MMC device
+        */
+       if (mmc->cfg) {
+               debug("Warning: MMC_TINY doesn't support multiple MMC devices\n");
+               return mmc;
+       }
+
        mmc->cfg = cfg;
        mmc->priv = priv;