]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc:fix: Set mmc width according to MMC host capabilities
authorŁukasz Majewski <l.majewski@samsung.com>
Mon, 12 Mar 2012 22:07:18 +0000 (22:07 +0000)
committerAndy Fleming <afleming@freescale.com>
Tue, 8 May 2012 23:02:21 +0000 (18:02 -0500)
This patch sets the MMC width according to the MMC host capabilities.
It turned out, that there are some targets (e.g. GONI), which are able
to read data from SPI only at 4 bit mode.
This patch restricts the width number according to the MMC host.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Andy Fleming <afleming@gmail.com>
drivers/mmc/mmc.c
include/mmc.h

index 596732e80e615f6a8ab1ccd559f11b80419647a6..aebe578ff6f2e0228baa3e5d010f6808ea269760 100644 (file)
@@ -1199,7 +1199,9 @@ int mmc_startup(struct mmc *mmc)
                else
                        mmc_set_clock(mmc, 25000000);
        } else {
-               for (width = EXT_CSD_BUS_WIDTH_8; width >= 0; width--) {
+               width = ((mmc->host_caps & MMC_MODE_MASK_WIDTH_BITS) >>
+                        MMC_MODE_WIDTH_BITS_SHIFT);
+               for (; width >= 0; width--) {
                        /* Set the card to use 4 bit*/
                        err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
                                        EXT_CSD_BUS_WIDTH, width);
index f52df70ad4879782fa15efb6943490dd74eab56b..ee16349f832d24ac662f5dcecdeb782141c9f845 100644 (file)
@@ -47,6 +47,9 @@
 #define MMC_MODE_SPI           0x400
 #define MMC_MODE_HC            0x800
 
+#define MMC_MODE_MASK_WIDTH_BITS (MMC_MODE_4BIT | MMC_MODE_8BIT)
+#define MMC_MODE_WIDTH_BITS_SHIFT 8
+
 #define SD_DATA_4BIT   0x00040000
 
 #define IS_SD(x) (x->version & SD_VERSION_SD)