]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - cpu/at32ap/atmel_mci.c
Merge branch 'master' of git://www.denx.de/git/u-boot-ppc4xx
[people/ms/u-boot.git] / cpu / at32ap / atmel_mci.c
index cf48be10ba4d44795aadef6afda5cdfa0df30f22..3795addf05af60ca10e69d6e6d8e7bf086e7f3b1 100644 (file)
@@ -21,8 +21,6 @@
  */
 #include <common.h>
 
-#ifdef CONFIG_MMC
-
 #include <part.h>
 #include <mmc.h>
 
@@ -139,7 +137,7 @@ mmc_cmd(unsigned long cmd, unsigned long arg,
 
        pr_debug("mmc: status 0x%08lx\n", status);
 
-       if (status & ERROR_FLAGS) {
+       if (status & error_flags) {
                printf("mmc: command %lu failed (status: 0x%08lx)\n",
                       cmd, status);
                return -EIO;
@@ -182,12 +180,13 @@ static int mmc_acmd(unsigned long cmd, unsigned long arg,
 
 static unsigned long
 mmc_bread(int dev, unsigned long start, lbaint_t blkcnt,
-         unsigned long *buffer)
+         void *buffer)
 {
        int ret, i = 0;
        unsigned long resp[4];
        unsigned long card_status, data;
        unsigned long wordcount;
+       u32 *p = buffer;
        u32 status;
 
        if (blkcnt == 0)
@@ -198,11 +197,11 @@ mmc_bread(int dev, unsigned long start, lbaint_t blkcnt,
 
        /* Put the device into Transfer state */
        ret = mmc_cmd(MMC_CMD_SELECT_CARD, mmc_rca << 16, resp, R1 | NCR);
-       if (ret) goto fail;
+       if (ret) goto out;
 
        /* Set block length */
        ret = mmc_cmd(MMC_CMD_SET_BLOCKLEN, mmc_blkdev.blksz, resp, R1 | NCR);
-       if (ret) goto fail;
+       if (ret) goto out;
 
        pr_debug("MCI_DTOR = %08lx\n", mmci_readl(DTOR));
 
@@ -211,7 +210,7 @@ mmc_bread(int dev, unsigned long start, lbaint_t blkcnt,
                              start * mmc_blkdev.blksz, resp,
                              (R1 | NCR | TRCMD_START | TRDIR_READ
                               | TRTYP_BLOCK));
-               if (ret) goto fail;
+               if (ret) goto out;
 
                ret = -EIO;
                wordcount = 0;
@@ -219,13 +218,13 @@ mmc_bread(int dev, unsigned long start, lbaint_t blkcnt,
                        do {
                                status = mmci_readl(SR);
                                if (status & (ERROR_FLAGS | MMCI_BIT(OVRE)))
-                                       goto fail;
+                                       goto read_error;
                        } while (!(status & MMCI_BIT(RXRDY)));
 
                        if (status & MMCI_BIT(RXRDY)) {
                                data = mmci_readl(RDR);
                                /* pr_debug("%x\n", data); */
-                               *buffer++ = data;
+                               *p++ = data;
                                wordcount++;
                        }
                } while(wordcount < (mmc_blkdev.blksz / 4));
@@ -244,9 +243,10 @@ out:
        mmc_cmd(MMC_CMD_SELECT_CARD, 0, resp, NCR);
        return i;
 
-fail:
+read_error:
        mmc_cmd(MMC_CMD_SEND_STATUS, mmc_rca << 16, &card_status, R1 | NCR);
-       printf("mmc: bread failed, card status = %08x\n", card_status);
+       printf("mmc: bread failed, status = %08x, card status = %08x\n",
+              status, card_status);
        goto out;
 }
 
@@ -442,6 +442,7 @@ static void mci_set_data_timeout(struct mmc_csd *csd)
 
        dtocyc = timeout_clks;
        dtomul = 0;
+       shift = 0;
        while (dtocyc > 15 && dtomul < 8) {
                dtomul++;
                shift = dtomul_to_shift[dtomul];
@@ -545,5 +546,3 @@ int mmc2info(ulong addr)
 {
        return 0;
 }
-
-#endif /* CONFIG_MMC */