]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
MMC: Consolidate MMC/SD command definitions
authorHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
Thu, 22 May 2008 09:09:59 +0000 (11:09 +0200)
committerWolfgang Denk <wd@denx.de>
Sat, 28 Jun 2008 20:40:15 +0000 (22:40 +0200)
This moves the MMC and SD Card command definitions from
include/asm/arch/mmc.h into include/mmc.h. These definitions are
given by the MMC and SD Card standards, not by any particular
architecture.

There's a lot more room for consolidation in the MMC drivers which
I'm hoping to get done eventually, but this patch is a start.

Compile-tested for all avr32 boards as well as lpc2292sodimm and
lubbock. This should cover all three mmc drivers in the tree.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
cpu/at32ap/atmel_mci.c
cpu/pxa/mmc.c
include/asm-arm/arch-pxa/mmc.h
include/asm-avr32/arch-at32ap700x/mmc.h
include/mmc.h

index 3795addf05af60ca10e69d6e6d8e7bf086e7f3b1..61aa1849c24a3374776eea5487f5eb630ca22f1d 100644 (file)
@@ -349,7 +349,7 @@ static int sd_init_card(struct mmc_cid *cid, int verbose)
 
        mmc_idle_cards();
        for (i = 0; i < 1000; i++) {
-               ret = mmc_acmd(MMC_ACMD_SD_SEND_OP_COND, CFG_MMC_OP_COND,
+               ret = mmc_acmd(SD_CMD_APP_SEND_OP_COND, CFG_MMC_OP_COND,
                               resp, R3 | NID);
                if (ret || (resp[0] & 0x80000000))
                        break;
@@ -367,7 +367,7 @@ static int sd_init_card(struct mmc_cid *cid, int verbose)
                mmc_dump_cid(cid);
 
        /* Get RCA of the card that responded */
-       ret = mmc_cmd(MMC_CMD_SD_SEND_RELATIVE_ADDR, 0, resp, R6 | NCR);
+       ret = mmc_cmd(SD_CMD_SEND_RELATIVE_ADDR, 0, resp, R6 | NCR);
        if (ret)
                return ret;
 
index 039ce0f579a5bd084fe4185c194e56484e8ebec2..4495a808f5157c7aa1e14d1e19eba6e25c9d1601 100644 (file)
@@ -119,7 +119,7 @@ mmc_block_read(uchar * dst, ulong src, ulong len)
        MMC_RDTO = 0xffff;
        MMC_NOB = 1;
        MMC_BLKLEN = len;
-       mmc_cmd(MMC_CMD_READ_BLOCK, argh, argl,
+       mmc_cmd(MMC_CMD_READ_SINGLE_BLOCK, argh, argl,
                MMC_CMDAT_R1 | MMC_CMDAT_READ | MMC_CMDAT_BLOCK |
                MMC_CMDAT_DATA_EN);
 
@@ -568,7 +568,7 @@ mmc_init(int verbose)
        MMC_SPI = MMC_SPI_DISABLE;
 
        /* reset */
-       mmc_cmd(MMC_CMD_RESET, 0, 0, MMC_CMDAT_INIT | MMC_CMDAT_R0);
+       mmc_cmd(MMC_CMD_GO_IDLE_STATE, 0, 0, MMC_CMDAT_INIT | MMC_CMDAT_R0);
        udelay(200000);
        retries = 3;
        while (retries--) {
@@ -578,7 +578,10 @@ mmc_init(int verbose)
                        break;
                }
 
-               resp = mmc_cmd(SD_CMD_APP_OP_COND, 0x0020, 0, MMC_CMDAT_R3 | (retries < 2 ? 0 : MMC_CMDAT_INIT));       /* Select 3.2-3.3 and 3.3-3.4V */
+               /* Select 3.2-3.3 and 3.3-3.4V */
+               resp = mmc_cmd(SD_CMD_APP_SEND_OP_COND, 0x0020, 0,
+                               MMC_CMDAT_R3 | (retries < 2 ? 0
+                                       : MMC_CMDAT_INIT));
                if (resp[0] & 0x80000000) {
                        mmc_dev.if_type = IF_TYPE_SD;
                        debug("Detected SD card\n");
@@ -616,7 +619,7 @@ mmc_init(int verbose)
                memcpy(cid_resp, resp, sizeof(cid_resp));
 
                /* MMC exists, get CSD too */
-               resp = mmc_cmd(MMC_CMD_SET_RCA, 0, 0, MMC_CMDAT_R1);
+               resp = mmc_cmd(MMC_CMD_SET_RELATIVE_ADDR, 0, 0, MMC_CMDAT_R1);
                if (IF_TYPE_SD == mmc_dev.if_type)
                        rca = ((resp[0] & 0xffff0000) >> 16);
                resp = mmc_cmd(MMC_CMD_SEND_CSD, rca, 0, MMC_CMDAT_R2);
index 9440d80b500b583ee243f85d1843c8eed4f09436..85e144b682d7b199de65623a86a4f3b8662f218f 100644 (file)
 #define MMC_DEFAULT_RCA                        1
 
 #define MMC_BLOCK_SIZE                 512
-#define MMC_CMD_RESET                  0
-#define MMC_CMD_SEND_OP_COND           1
-#define MMC_CMD_ALL_SEND_CID           2
-#define MMC_CMD_SET_RCA                        3
-#define MMC_CMD_SELECT_CARD            7
-#define MMC_CMD_SEND_CSD               9
-#define MMC_CMD_SEND_CID               10
-#define MMC_CMD_SEND_STATUS            13
-#define MMC_CMD_SET_BLOCKLEN           16
-#define MMC_CMD_READ_BLOCK             17
-#define MMC_CMD_RD_BLK_MULTI           18
-#define MMC_CMD_WRITE_BLOCK            24
-#define MMC_CMD_APP_CMD                        55
-
-#define SD_CMD_APP_SET_BUS_WIDTH       6
-#define SD_CMD_APP_OP_COND             41
-
 #define MMC_MAX_BLOCK_SIZE             512
 
 #define MMC_R1_IDLE_STATE              0x01
index 6a33fef5a81ac28cad83d8fc8d40968a6a339939..9caba9168e65818c8ee3e87e9916181b6b106795 100644 (file)
@@ -71,25 +71,6 @@ struct mmc_csd
        u8      one:1;
 };
 
-/* MMC Command numbers */
-#define MMC_CMD_GO_IDLE_STATE          0
-#define MMC_CMD_SEND_OP_COND           1
-#define MMC_CMD_ALL_SEND_CID           2
-#define MMC_CMD_SET_RELATIVE_ADDR      3
-#define MMC_CMD_SD_SEND_RELATIVE_ADDR  3
-#define MMC_CMD_SET_DSR                        4
-#define MMC_CMD_SELECT_CARD            7
-#define MMC_CMD_SEND_CSD               9
-#define MMC_CMD_SEND_CID               10
-#define MMC_CMD_SEND_STATUS            13
-#define MMC_CMD_SET_BLOCKLEN           16
-#define MMC_CMD_READ_SINGLE_BLOCK      17
-#define MMC_CMD_READ_MULTIPLE_BLOCK    18
-#define MMC_CMD_WRITE_BLOCK            24
-#define MMC_CMD_APP_CMD                        55
-
-#define MMC_ACMD_SD_SEND_OP_COND       41
-
 #define R1_ILLEGAL_COMMAND             (1 << 22)
 #define R1_APP_CMD                     (1 << 5)
 
index a2716959e2cc016d0115380a5c3d08fb9d2a75eb..19c76fe4cd0c0c425159d30ee57e0b91af93bfcf 100644 (file)
 #define _MMC_H_
 #include <asm/arch/mmc.h>
 
+/* MMC command numbers */
+#define MMC_CMD_GO_IDLE_STATE          0
+#define MMC_CMD_SEND_OP_COND           1
+#define MMC_CMD_ALL_SEND_CID           2
+#define MMC_CMD_SET_RELATIVE_ADDR      3
+#define MMC_CMD_SET_DSR                        4
+#define MMC_CMD_SELECT_CARD            7
+#define MMC_CMD_SEND_CSD               9
+#define MMC_CMD_SEND_CID               10
+#define MMC_CMD_SEND_STATUS            13
+#define MMC_CMD_SET_BLOCKLEN           16
+#define MMC_CMD_READ_SINGLE_BLOCK      17
+#define MMC_CMD_READ_MULTIPLE_BLOCK    18
+#define MMC_CMD_WRITE_BLOCK            24
+#define MMC_CMD_APP_CMD                        55
+
+/* SD Card command numbers */
+#define SD_CMD_SEND_RELATIVE_ADDR      3
+#define SD_CMD_SWITCH                  6
+#define SD_CMD_SEND_IF_COND            8
+
+#define SD_CMD_APP_SET_BUS_WIDTH       6
+#define SD_CMD_APP_SEND_OP_COND                41
+
 int mmc_init(int verbose);
 int mmc_read(ulong src, uchar *dst, int size);
 int mmc_write(uchar *src, ulong dst, int size);