]> git.sur5r.net Git - u-boot/blobdiff - drivers/mmc/mmc.c
pinctrl: uniphier: fix NAND and SD pin-mux settings for PH1-LD11/LD20
[u-boot] / drivers / mmc / mmc.c
index e6028d503f279ee6617b29e9657d1c8a17e39a85..d3c22abfd5a8c198499308cb4b8e24f161f9be3d 100644 (file)
@@ -61,7 +61,10 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
        printf("CMD_SEND:%d\n", cmd->cmdidx);
        printf("\t\tARG\t\t\t 0x%08X\n", cmd->cmdarg);
        ret = mmc->cfg->ops->send_cmd(mmc, cmd, data);
-       switch (cmd->resp_type) {
+       if (ret) {
+               printf("\t\tRET\t\t\t %d\n", ret);
+       } else {
+               switch (cmd->resp_type) {
                case MMC_RSP_NONE:
                        printf("\t\tMMC_RSP_NONE\n");
                        break;
@@ -101,6 +104,7 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
                default:
                        printf("\t\tERROR MMC rsp not supported\n");
                        break;
+               }
        }
 #else
        ret = mmc->cfg->ops->send_cmd(mmc, cmd, data);
@@ -182,7 +186,7 @@ struct mmc *find_mmc_device(int dev_num)
        list_for_each(entry, &mmc_devices) {
                m = list_entry(entry, struct mmc, link);
 
-               if (m->block_dev.dev == dev_num)
+               if (m->block_dev.devnum == dev_num)
                        return m;
        }
 
@@ -234,10 +238,10 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
        return blkcnt;
 }
 
-static ulong mmc_bread(block_dev_desc_t *block_dev, lbaint_t start,
+static ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start,
                       lbaint_t blkcnt, void *dst)
 {
-       int dev_num = block_dev->dev;
+       int dev_num = block_dev->devnum;
        int err;
        lbaint_t cur, blocks_todo = blkcnt;
 
@@ -906,20 +910,20 @@ retry_scr:
        mmc->scr[1] = __be32_to_cpu(scr[1]);
 
        switch ((mmc->scr[0] >> 24) & 0xf) {
-               case 0:
-                       mmc->version = SD_VERSION_1_0;
-                       break;
-               case 1:
-                       mmc->version = SD_VERSION_1_10;
-                       break;
-               case 2:
-                       mmc->version = SD_VERSION_2;
-                       if ((mmc->scr[0] >> 15) & 0x1)
-                               mmc->version = SD_VERSION_3;
-                       break;
-               default:
-                       mmc->version = SD_VERSION_1_0;
-                       break;
+       case 0:
+               mmc->version = SD_VERSION_1_0;
+               break;
+       case 1:
+               mmc->version = SD_VERSION_1_10;
+               break;
+       case 2:
+               mmc->version = SD_VERSION_2;
+               if ((mmc->scr[0] >> 15) & 0x1)
+                       mmc->version = SD_VERSION_3;
+               break;
+       default:
+               mmc->version = SD_VERSION_1_0;
+               break;
        }
 
        if (mmc->scr[0] & SD_DATA_4BIT)
@@ -1102,24 +1106,24 @@ static int mmc_startup(struct mmc *mmc)
                int version = (cmd.response[0] >> 26) & 0xf;
 
                switch (version) {
-                       case 0:
-                               mmc->version = MMC_VERSION_1_2;
-                               break;
-                       case 1:
-                               mmc->version = MMC_VERSION_1_4;
-                               break;
-                       case 2:
-                               mmc->version = MMC_VERSION_2_2;
-                               break;
-                       case 3:
-                               mmc->version = MMC_VERSION_3;
-                               break;
-                       case 4:
-                               mmc->version = MMC_VERSION_4;
-                               break;
-                       default:
-                               mmc->version = MMC_VERSION_1_2;
-                               break;
+               case 0:
+                       mmc->version = MMC_VERSION_1_2;
+                       break;
+               case 1:
+                       mmc->version = MMC_VERSION_1_4;
+                       break;
+               case 2:
+                       mmc->version = MMC_VERSION_2_2;
+                       break;
+               case 3:
+                       mmc->version = MMC_VERSION_3;
+                       break;
+               case 4:
+                       mmc->version = MMC_VERSION_4;
+                       break;
+               default:
+                       mmc->version = MMC_VERSION_1_2;
+                       break;
                }
        }
 
@@ -1495,7 +1499,7 @@ static int mmc_startup(struct mmc *mmc)
        mmc->block_dev.revision[0] = 0;
 #endif
 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
-       init_part(&mmc->block_dev);
+       part_init(&mmc->block_dev);
 #endif
 
        return 0;
@@ -1556,7 +1560,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
        mmc->dsr = 0xffffffff;
        /* Setup the universal parts of the block interface just once */
        mmc->block_dev.if_type = IF_TYPE_MMC;
-       mmc->block_dev.dev = cur_dev_num++;
+       mmc->block_dev.devnum = cur_dev_num++;
        mmc->block_dev.removable = 1;
        mmc->block_dev.block_read = mmc_bread;
        mmc->block_dev.block_write = mmc_bwrite;
@@ -1579,7 +1583,7 @@ void mmc_destroy(struct mmc *mmc)
 }
 
 #ifdef CONFIG_PARTITIONS
-block_dev_desc_t *mmc_get_dev(int dev)
+struct blk_desc *mmc_get_dev(int dev)
 {
        struct mmc *mmc = find_mmc_device(dev);
        if (!mmc || mmc_init(mmc))
@@ -1728,7 +1732,7 @@ void print_mmc_devices(char separator)
                else
                        mmc_type = NULL;
 
-               printf("%s: %d", m->cfg->name, m->block_dev.dev);
+               printf("%s: %d", m->cfg->name, m->block_dev.devnum);
                if (mmc_type)
                        printf(" (%s)", mmc_type);
 
@@ -1780,18 +1784,28 @@ static int mmc_probe(bd_t *bis)
 #elif defined(CONFIG_DM_MMC)
 static int mmc_probe(bd_t *bis)
 {
-       int ret;
+       int ret, i;
        struct uclass *uc;
-       struct udevice *m;
+       struct udevice *dev;
 
        ret = uclass_get(UCLASS_MMC, &uc);
        if (ret)
                return ret;
 
-       uclass_foreach_dev(m, uc) {
-               ret = device_probe(m);
+       /*
+        * Try to add them in sequence order. Really with driver model we
+        * should allow holes, but the current MMC list does not allow that.
+        * So if we request 0, 1, 3 we will get 0, 1, 2.
+        */
+       for (i = 0; ; i++) {
+               ret = uclass_get_device_by_seq(UCLASS_MMC, i, &dev);
+               if (ret == -ENODEV)
+                       break;
+       }
+       uclass_foreach_dev(dev, uc) {
+               ret = device_probe(dev);
                if (ret)
-                       printf("%s - probe failed: %d\n", m->name, ret);
+                       printf("%s - probe failed: %d\n", dev->name, ret);
        }
 
        return 0;