Skip to contentSkip to conversation

mmc:fix: Set mmc width according to MMC host capabilities

PATCH New Lukasz Majewski 1 participant 3 messages Mar 13, 2012 – Apr 2, 2012 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc:fix: Set mmc width according to MMC host capabilities

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.

---
 drivers/mmc/mmc.c |    4 +++-
 include/mmc.h     |    3 +++
 2 files changed, 6 insertions(+), 1 deletions(-)
drivers/mmc/mmc.c +3 -1
index 49c3349..51c0106 100644
@@ -1103,7 +1103,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);
include/mmc.h +3 -0
index 30c2375..ff2f28e 100644
@@ -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)
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/1 mmc:fix: Set mmc width according to MMC host capabilities

Hi Andy,

Quoted 35 lines

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.

---
 drivers/mmc/mmc.c |    4 +++-
 include/mmc.h     |    3 +++
 2 files changed, 6 insertions(+), 1 deletions(-)
drivers/mmc/mmc.c +1 -1
index 49c3349..51c0106 100644
@@ -1103,7 +1103,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)
Quoted 1 line
Quoted 1 line
drivers/mmc/mmc.c +2 -0
+			 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);
include/mmc.h +0 -0
index 30c2375..ff2f28e 100644

include/mmc.h line 55

Quoted 9 lines
include/mmc.h +3 -0
@@ -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)

Do you have any opinions/comments about this patch? It has already spent some time on the mainling list and nobody complaint :-)

Signature · 6 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center
Platform Group
#2 lore raw

PATCH 1/1 mmc:fix: Set mmc width according to MMC host capabilities

Hi Andy,

Quoted 46 lines

Hi Andy,

Quoted 44 lines

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.

---
 drivers/mmc/mmc.c |    4 +++-
 include/mmc.h     |    3 +++
 2 files changed, 6 insertions(+), 1 deletions(-)
drivers/mmc/mmc.c +1 -1
index 49c3349..51c0106 100644
@@ -1103,7 +1103,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)
Quoted 1 line
Quoted 1 line
drivers/mmc/mmc.c +2 -0
+			 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);

include/mmc.h +3 -0
index 30c2375..ff2f28e 100644
@@ -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
 
Quoted 6 lines

include/mmc.h line 55

Quoted 1 line
include/mmc.h +0 -0
 #define IS_SD(x) (x->version & SD_VERSION_SD)

Do you have any opinions/comments about this patch? It has already spent some time on the mainling list and nobody complaint :-)

Do you have any questions about this patch?

Signature · 6 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center
Platform Group