Skip to contentSkip to conversation

Patch about mmc and sdhci, Please look it, i can not pull the patch. I copy it here.

U-Boot richie_wang 3 participants 3 messages Sep 26, 2013 – Oct 30, 2013

lore
Share & tools
lore
#1 lore raw

Dear richie_wang,

Quoted 1 line · richie_wang <macro_system <at> 163.com> writes:

Submitting a patch isn't as easy as copy-n-pasting but it's all documented. Please read this page:

http://www.denx.de/wiki/U-Boot/Patches

Quoted 6 lines

From 133570dbb7f772f78558cfac9d8c558513d033a1 Mon Sep 17 00:00:00 2001
From: richie_wang <macro_system <at> 163.com>
Date: Wed, 25 Sep 2013 08:20:25 +0800
Subject: [PATCH 3/3] This commit solve mmc_write_blocks with async cmd12
hidden bug

<snipped>

#2 lore raw
In reply to richie_wang

Hi Richie,

Please take a look at our patch submission guidelines.

http://www.denx.de/wiki/U-Boot/Patches

Some of the methods you use are questionable to say the least.

Is your magic variable something to do with a quirk?
I understand what you're trying to do, but you need to be more forthcoming about why this patch is needed; i.e. what is the board you're seeing this bug occuring?

Please try to clean this up and submit again, I'm afraid that this patch is rejected.

Regards

-- Pantelis

Quoted 126 lines · richie_wang

From 133570dbb7f772f78558cfac9d8c558513d033a1 Mon Sep 17 00:00:00 2001
From: richie_wang <[email protected]>
Date: Wed, 25 Sep 2013 08:20:25 +0800
Subject: [PATCH 3/3] This commit solve mmc_write_blocks with async cmd12 hidden bug

When the processor use mmc_write_blocks to write multi-block data to SD Memory card
it will send CMD12 to finish the transfer. But if the code using PIO method and processor
speed is high than the SD host sending the data in SD host buffer.There will be a condition
CMD12 will on cmd line and some data still on data line, which will conflict will multi-write
Time requirement in SPEC. This commit makes CPU send CMD12 after register 0x24 bit8 change to
zero.

---
:100644 100644 aa2fdef... f2f982c... M drivers/mmc/mmc_write.c
:100644 100644 dfb2eee... d66cc9a... M drivers/mmc/sdhci.c
:100644 100644 74d06ae... a0c9e32... M include/sdhci.h

drivers/mmc/mmc_write.c |    8 ++++++++
drivers/mmc/sdhci.c     |   11 +++++++++++
include/sdhci.h         |    4 ++++
3 files changed, 23 insertions(+)
drivers/mmc/mmc_write.c +2 -0
index aa2fdef..f2f982c 100644
@@ -10,6 +10,7 @@
 #include <config.h>
 #include <common.h>
 #include <part.h>
+#include <sdhci.h>
 #include "mmc_private.h"
 
 static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt)
@@ -103,6 +104,7 @@ static ulong mmc_write_blocks(struct mmc *mmc, lbaint_t
 start,
 {
 	struct mmc_cmd cmd;
 	struct mmc_data data;
+	struct sdhci_host* host;
 	int timeout = 1000;
 
	if ((start + blkcnt) > mmc->block_dev.lba) {
drivers/mmc/mmc_write.c +6 -0
@@ -142,6 +144,12 @@ static ulong mmc_write_blocks(struct mmc *mmc, lbaint_t
 start,
 		cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
 		cmd.cmdarg = 0;
 		cmd.resp_type = MMC_RSP_R1b;
+		
+		/* cmd12 async timing problem */
+		host = (struct sdhci_host*)mmc->priv;
+		if(host->magic_num == SDHCI_MAGIC_NUM)
+			sdhci_cmd12_wait(host);
+		
 		if (mmc_send_cmd(mmc, &cmd, NULL)) {
 			printf("mmc fail to send stop cmd\n");
			return 0;
drivers/mmc/sdhci.c +1 -0
index dfb2eee..d66cc9a 100644
@@ -410,6 +410,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32
 min_clk)
 	struct mmc *mmc;
 	unsigned int caps;
 
+	host->magic_num = SDHCI_MAGIC_NUM;
 	mmc = malloc(sizeof(struct mmc));
 	if (!mmc) {
		printf("mmc malloc fail!\n");
drivers/mmc/sdhci.c +0 -0
@@ -482,3 +483,13 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32
 min_clk)
 
 	return 0;

}

drivers/mmc/sdhci.c +10 -0
+
+
+void sdhci_cmd12_wait(struct sdhci_host *host)
+{
+	u32 mask = SDHCI_DOING_WRITE;
+	
+	while(sdhci_readl(host, SDHCI_PRESENT_STATE) & mask);
+
+	return ;
+}
include/sdhci.h +4 -0
index 74d06ae..a0c9e32 100644
@@ -233,7 +233,10 @@ struct sdhci_ops {
 #endif
 };
 
+#define SDHCI_MAGIC_NUM		0x20131001
+
 struct sdhci_host {
+	unsigned int magic_num;
 	char *name;
 	void *ioaddr;
 	unsigned int quirks;
@@ -332,4 +335,5 @@ static inline u8 sdhci_readb(struct sdhci_host *host,
 int reg)
 #endif
 
 int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk);
+void sdhci_cmd12_wait(struct sdhci_host *host);

#endif /* __SDHCI_HW_H */

Signature · 12 lines
1.7.9.5




--
View this message in context: http://u-boot.10912.n7.nabble.com/Patch-about-mmc-and-sdhci-Please-look-it-i-can-not-pull-the-patch-I-copy-it-here-tp164059.html
Sent from the U-Boot mailing list archive at Nabble.com.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot