Skip to contentSkip to conversation

fix and enhancement patches for sdhci

PATCH Superseded Lei Wen 5 participants 30 messages Oct 3, 2011 – Nov 2, 2011 MMC, SD and SDIO

lore
Share & tools
lore

Lei Wen

author
#0 lore raw

cover fix and enhancement patches for sdhci

This seris fix several issue like flush cache and build warning. And give this generic driver enhancement for timeout when transferring data and additional structure member to access in platform self driver.

Lei Wen (4):
mmc: sdhci: fix cache flush
mmc: sdhci: fix build warning
mmc: sdhci: add mmc structure for host
mmc: sdhci: add timeout for data transfer

 drivers/mmc/sdhci.c |   12 ++++++++++--
 include/sdhci.h     |    3 +++
 2 files changed, 13 insertions(+), 2 deletions(-)
author
#1 lore raw

PATCH 1/4 mmc: sdhci: fix cache flush

Only flush the memory range needed.

---
 drivers/mmc/sdhci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +1 -1
index 9ebd33d..4a92453 100644
@@ -196,7 +196,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 
 	sdhci_writel(host, cmd->cmdarg, SDHCI_ARGUMENT);
 #ifdef CONFIG_MMC_SDMA
-	flush_cache(0, ~0);
+	flush_cache(start_addr, trans_bytes);
 #endif
 	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->cmdidx, flags), SDHCI_COMMAND);
 	do {
Signature · 1 line
1.7.0.4
author
#2 lore raw

PATCH 2/4 mmc: sdhci: fix build warning

In reply to Lei Wen

If CONFIG_MMC_SDHCI_IO_ACCESSORS is defined, the following warning would shows up:

include/sdhci.h:224: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:224: warning: its scope is only this definition or declaration, which is probably not what you want include/sdhci.h:225: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:226: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:227: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:228: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:229: warning: 'struct sdhci_host' declared inside parameter list

---
 include/sdhci.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/sdhci.h +1 -0
index 6d52ce9..6c6a8ea 100644
@@ -219,6 +219,7 @@
  */
 #define SDHCI_DEFAULT_BOUNDARY_SIZE	(512 * 1024)
 #define SDHCI_DEFAULT_BOUNDARY_ARG	(7)
+struct sdhci_host;
 struct sdhci_ops {
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
 	u32             (*read_l)(struct sdhci_host *host, int reg);
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 2/4 mmc: sdhci: fix build warning

Quoted 2 lines · Lei Wen

If CONFIG_MMC_SDHCI_IO_ACCESSORS is defined, the following warning would shows up:

[...]

include/sdhci.h line 225

Quoted 13 lines
include/sdhci.h +1 -0
index 6d52ce9..6c6a8ea 100644
@@ -219,6 +219,7 @@
  */
 #define SDHCI_DEFAULT_BOUNDARY_SIZE	(512 * 1024)
 #define SDHCI_DEFAULT_BOUNDARY_ARG	(7)
+struct sdhci_host;
 struct sdhci_ops {
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
 	u32             (*read_l)(struct sdhci_host *host, int reg);

Dear Lei Wen,

Please keep the newlines so it's not such an uniform blob of code. Thanks!

Cheers

#4 lore raw

PATCH 2/4 mmc: sdhci: fix build warning

Marek,

Quoted 22 lines · Marek Vasut
Quoted 2 lines · Lei Wen

If CONFIG_MMC_SDHCI_IO_ACCESSORS is defined, the following warning would shows up:

[...]

Quoted 6 lines
include/sdhci.h +0 -0
index 6d52ce9..6c6a8ea 100644
@@ -219,6 +219,7 @@
Quoted 7 lines

? */
?#define SDHCI_DEFAULT_BOUNDARY_SIZE ?(512 * 1024) ?#define SDHCI_DEFAULT_BOUNDARY_ARG ? (7)
+struct sdhci_host;
?struct sdhci_ops {
?#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
? ? ? u32 ? ? ? ? ? ? (*read_l)(struct sdhci_host *host, int reg);

Dear Lei Wen,

Quoted 2 lines

Please keep the newlines so it's not such an uniform blob of code. Thanks!

Got it,

Thanks,
Lei

author
#5 lore raw

PATCH 3/4 mmc: sdhci: add mmc structure for host

In reply to Lei Wen

So that sdhci host would tell in the driver that the mmc current attributes.

---
 drivers/mmc/sdhci.c |    1 +
 include/sdhci.h     |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)
drivers/mmc/sdhci.c +1 -0
index 4a92453..31c738e 100644
@@ -377,6 +377,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
 	}
 
 	mmc->priv = host;
+	host->mmc = mmc;
 
 	sprintf(mmc->name, "%s", host->name);
 	mmc->send_cmd = sdhci_send_command;
include/sdhci.h +2 -0
index 6c6a8ea..2dd36a4 100644
@@ -27,6 +27,7 @@
 #define __SDHCI_HW_H
 
 #include <asm/io.h>
+#include <mmc.h>
 /*
  * Controller registers
  */
@@ -237,6 +238,7 @@ struct sdhci_host {
 	unsigned int quirks;
 	unsigned int version;
 	unsigned int clock;
+	struct mmc *mmc;
 	const struct sdhci_ops *ops;
 };
 
Signature · 1 line
1.7.0.4
author
#6 lore raw

PATCH 4/4 mmc: sdhci: add timeout for data transfer

In reply to Lei Wen
---
 drivers/mmc/sdhci.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +8 -1
index 31c738e..77a9e70 100644
@@ -81,8 +81,9 @@ static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data)
 static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 				unsigned int start_addr)
 {
-	unsigned int stat, rdy, mask, block = 0;
+	unsigned int stat, rdy, mask, timeout, block = 0;
 
+	timeout = 10000;
 	rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL;
 	mask = SDHCI_DATA_AVAILABLE | SDHCI_SPACE_AVAILABLE;
 	do {
@@ -108,6 +109,12 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 			sdhci_writel(host, start_addr, SDHCI_DMA_ADDRESS);
 		}
 #endif
+		if (timeout-- > 0)
+			udelay(10);
+		else {
+			printf("Transfer data timeout\n");
+			return -1;
+		}
 	} while (!(stat & SDHCI_INT_DATA_END));
 	return 0;
 }
Signature · 1 line
1.7.0.4
author
#7 lore raw

v2 cover fix and enhancement patches for sdhci

In reply to Lei Wen

This seris fix several issue like flush cache and build warning. And give this generic driver enhancement for timeout when transferring data and additional structure member to access in platform self driver.

Changelog:
V2: code style change.

Lei Wen (4):
mmc: sdhci: fix cache flush
mmc: sdhci: fix build warning
mmc: sdhci: add mmc structure for host
mmc: sdhci: add timeout for data transfer

 drivers/mmc/sdhci.c |   12 ++++++++++--
 include/sdhci.h     |    3 +++
 2 files changed, 13 insertions(+), 2 deletions(-)
author
#8 lore raw

v3 cover fix and enhancement patches for sdhci

This seris fix several issue like flush cache and build warning. And give this generic driver enhancement for timeout when transferring data and additional structure member to access in platform self driver.

Changelog:
V2: code style change.

V3: add another fix of sdma handling bug including in this series

Lei Wen (5):
mmc: sdhci: fix cache flush
mmc: sdhci: fix build warning
mmc: sdhci: add mmc structure for host
mmc: sdhci: add timeout for data transfer
mmc: sdhci: fix sdma bug for large file transfer

 drivers/mmc/sdhci.c |   14 +++++++++++---
 include/sdhci.h     |    5 +++++
 2 files changed, 16 insertions(+), 3 deletions(-)
author
#9 lore raw

v4 cover fix and enhancement patches for sdhci

This seris fix several issue like flush cache and build warning. And give this generic driver enhancement for timeout when transferring data and additional structure member to access in platform self driver.

Changelog:
V2: code style change.
V3: add another fix of sdma handling bug including in this series
V4: minor code style change

Lei Wen (5):
mmc: sdhci: fix cache flush
mmc: sdhci: fix build warning
mmc: sdhci: add mmc structure for host
mmc: sdhci: add timeout for data transfer
mmc: sdhci: fix sdma bug for large file transfer

 drivers/mmc/sdhci.c |   14 +++++++++++---
 include/sdhci.h     |    6 ++++++
 2 files changed, 17 insertions(+), 3 deletions(-)
#10 lore raw

v4 cover fix and enhancement patches for sdhci

Hi Andy,

Quoted 16 lines · Lei Wen

This seris fix several issue like flush cache and build warning. And give this generic driver enhancement for timeout when transferring data and additional structure member to access in platform self driver.

Changelog:
V2: code style change.
V3: add another fix of sdma handling bug including in this series
V4: minor code style change

Lei Wen (5):
?mmc: sdhci: fix cache flush
?mmc: sdhci: fix build warning
?mmc: sdhci: add mmc structure for host
?mmc: sdhci: add timeout for data transfer
?mmc: sdhci: fix sdma bug for large file transfer

Quoted 4 lines

?drivers/mmc/sdhci.c | ? 14 +++++++++++--- ?include/sdhci.h ? ? | ? ?6 ++++++
?2 files changed, 17 insertions(+), 3 deletions(-)

Any comment for this patch series?

Thanks,
Lei

#11 lore raw

v4 cover fix and enhancement patches for sdhci

Hi Andy,

Quoted 19 lines · Lei Wen

Hi Andy,

Quoted 16 lines · Lei Wen

This seris fix several issue like flush cache and build warning. And give this generic driver enhancement for timeout when transferring data and additional structure member to access in platform self driver.

Changelog:
V2: code style change.
V3: add another fix of sdma handling bug including in this series
V4: minor code style change

Lei Wen (5):
?mmc: sdhci: fix cache flush
?mmc: sdhci: fix build warning
?mmc: sdhci: add mmc structure for host
?mmc: sdhci: add timeout for data transfer
?mmc: sdhci: fix sdma bug for large file transfer

Quoted 7 lines
Quoted 4 lines

?drivers/mmc/sdhci.c | ? 14 +++++++++++--- ?include/sdhci.h ? ? | ? ?6 ++++++
?2 files changed, 17 insertions(+), 3 deletions(-)

Any comment for this patch series?

Any comments?

Thanks,
Lei

#12 lore raw

v4 cover fix and enhancement patches for sdhci

Sorry for the delay, I am currently processing my patch backlog. I will be applying them today.

Quoted 35 lines · Lei Wen

Hi Andy,

Quoted 19 lines · Lei Wen

Hi Andy,

Quoted 16 lines · Lei Wen

This seris fix several issue like flush cache and build warning. And give this generic driver enhancement for timeout when transferring data and additional structure member to access in platform self driver.

Changelog:
V2: code style change.
V3: add another fix of sdma handling bug including in this series
V4: minor code style change

Lei Wen (5):
mmc: sdhci: fix cache flush
mmc: sdhci: fix build warning
mmc: sdhci: add mmc structure for host
mmc: sdhci: add timeout for data transfer
mmc: sdhci: fix sdma bug for large file transfer

Quoted 7 lines
Quoted 4 lines
 drivers/mmc/sdhci.c |   14 +++++++++++---
 include/sdhci.h     |    6 ++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

Any comment for this patch series?

Any comments?

Thanks,
Lei

author
#13 lore raw

PATCH v4 1/5 mmc: sdhci: fix cache flush

In reply to Lei Wen

Only flush the memory range needed.

---
Changelog:
V2: no change
V3: no change
V4: no change

 drivers/mmc/sdhci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +1 -1
index 9ebd33d..4a92453 100644
@@ -196,7 +196,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 
 	sdhci_writel(host, cmd->cmdarg, SDHCI_ARGUMENT);
 #ifdef CONFIG_MMC_SDMA
-	flush_cache(0, ~0);
+	flush_cache(start_addr, trans_bytes);
 #endif
 	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->cmdidx, flags), SDHCI_COMMAND);
 	do {
Signature · 1 line
1.7.0.4
author
#14 lore raw

PATCH v4 2/5 mmc: sdhci: fix build warning

In reply to Lei Wen

If CONFIG_MMC_SDHCI_IO_ACCESSORS is defined, the following warning would shows up:

include/sdhci.h:224: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:224: warning: its scope is only this definition or declaration, which is probably not what you want include/sdhci.h:225: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:226: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:227: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:228: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:229: warning: 'struct sdhci_host' declared inside parameter list

---
Changelog:
V2: code style change
V2.1: delete "Change-Id"
V3: no change
V4: no change

  include/sdhci.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/sdhci.h +3 -0
index 6d52ce9..e84d2dc 100644
@@ -214,6 +214,9 @@
  */
 #define SDHCI_QUIRK_32BIT_DMA_ADDR	(1 << 0)
 
+/* to make gcc happy */
+struct sdhci_host;
+
 /*
  * Host SDMA buffer boundary. Valid values from 4K to 512K in powers of 2.
  */
Signature · 1 line
1.7.0.4
author
#15 lore raw

PATCH v4 3/5 mmc: sdhci: add mmc structure for host

In reply to Lei Wen

So that sdhci host would tell in the driver that the mmc current attributes.

---
Changelog:
V2: no change
V3: no change
V4: add empty line after mmc.h include

 drivers/mmc/sdhci.c |    1 +
 include/sdhci.h     |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)
drivers/mmc/sdhci.c +1 -0
index 4a92453..31c738e 100644
@@ -377,6 +377,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
 	}
 
 	mmc->priv = host;
+	host->mmc = mmc;
 
 	sprintf(mmc->name, "%s", host->name);
 	mmc->send_cmd = sdhci_send_command;
include/sdhci.h +3 -0
index e84d2dc..0690938 100644
@@ -27,6 +27,8 @@
 #define __SDHCI_HW_H
 
 #include <asm/io.h>
+#include <mmc.h>
+
 /*
  * Controller registers
  */
@@ -239,6 +241,7 @@ struct sdhci_host {
 	unsigned int quirks;
 	unsigned int version;
 	unsigned int clock;
+	struct mmc *mmc;
 	const struct sdhci_ops *ops;
 };
 
Signature · 1 line
1.7.0.4
author
#16 lore raw

PATCH v4 4/5 mmc: sdhci: add timeout for data transfer

In reply to Lei Wen

---
Changelog:
V2: no change
V3: no change
V4: no change

 drivers/mmc/sdhci.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +8 -1
index 31c738e..77a9e70 100644
@@ -81,8 +81,9 @@ static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data)
 static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 				unsigned int start_addr)
 {
-	unsigned int stat, rdy, mask, block = 0;
+	unsigned int stat, rdy, mask, timeout, block = 0;
 
+	timeout = 10000;
 	rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL;
 	mask = SDHCI_DATA_AVAILABLE | SDHCI_SPACE_AVAILABLE;
 	do {
@@ -108,6 +109,12 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 			sdhci_writel(host, start_addr, SDHCI_DMA_ADDRESS);
 		}
 #endif
+		if (timeout-- > 0)
+			udelay(10);
+		else {
+			printf("Transfer data timeout\n");
+			return -1;
+		}
 	} while (!(stat & SDHCI_INT_DATA_END));
 	return 0;
 }
Signature · 1 line
1.7.0.4
author
#17 lore raw

PATCH v4 5/5 mmc: sdhci: fix sdma bug for large file transfer

In reply to Lei Wen

SDHCI spec need to reset the sdma base address while the software try to accorss the 512k bytes address boundary. When meet such accross behavior, sdhci controller would generate a interrupt automatically, and software need handle this.

---
Changelog:
V2: no change
V3: new added fix for sdma bug
V4: no change

 drivers/mmc/sdhci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +1 -1
index 77a9e70..fce0ef0 100644
@@ -104,7 +104,7 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 #ifdef CONFIG_MMC_SDMA
 		if (stat & SDHCI_INT_DMA_END) {
 			sdhci_writel(host, SDHCI_INT_DMA_END, SDHCI_INT_STATUS);
-			start_addr &= SDHCI_DEFAULT_BOUNDARY_SIZE - 1;
+			start_addr &= ~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1);
 			start_addr += SDHCI_DEFAULT_BOUNDARY_SIZE;
 			sdhci_writel(host, start_addr, SDHCI_DMA_ADDRESS);
 		}
Signature · 1 line
1.7.0.4
author
#18 lore raw

PATCH v3 1/5 mmc: sdhci: fix cache flush

In reply to Lei Wen

Only flush the memory range needed.

---
Changelog:
V2: no change
V3: no change

 drivers/mmc/sdhci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +1 -1
index 9ebd33d..4a92453 100644
@@ -196,7 +196,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 
 	sdhci_writel(host, cmd->cmdarg, SDHCI_ARGUMENT);
 #ifdef CONFIG_MMC_SDMA
-	flush_cache(0, ~0);
+	flush_cache(start_addr, trans_bytes);
 #endif
 	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->cmdidx, flags), SDHCI_COMMAND);
 	do {
Signature · 1 line
1.7.0.4
author
#19 lore raw

PATCH v3 2/5 mmc: sdhci: fix build warning

In reply to Lei Wen

If CONFIG_MMC_SDHCI_IO_ACCESSORS is defined, the following warning would shows up:

include/sdhci.h:224: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:224: warning: its scope is only this definition or declaration, which is probably not what you want include/sdhci.h:225: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:226: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:227: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:228: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:229: warning: 'struct sdhci_host' declared inside parameter list

---
Changelog:
V2: code style change
V2.1: delete "Change-Id"
V3: no change

 include/sdhci.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/sdhci.h +3 -0
index 6d52ce9..e84d2dc 100644
@@ -214,6 +214,9 @@
  */
 #define SDHCI_QUIRK_32BIT_DMA_ADDR	(1 << 0)
 
+/* to make gcc happy */
+struct sdhci_host;
+
 /*
  * Host SDMA buffer boundary. Valid values from 4K to 512K in powers of 2.
  */
Signature · 1 line
1.7.0.4
author
#20 lore raw

PATCH v3 3/5 mmc: sdhci: add mmc structure for host

In reply to Lei Wen

So that sdhci host would tell in the driver that the mmc current attributes.

---
Changelog:
V2: no change
V3: no change

 drivers/mmc/sdhci.c |    1 +
 include/sdhci.h     |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)
drivers/mmc/sdhci.c +1 -0
index 4a92453..31c738e 100644
@@ -377,6 +377,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
 	}
 
 	mmc->priv = host;
+	host->mmc = mmc;
 
 	sprintf(mmc->name, "%s", host->name);
 	mmc->send_cmd = sdhci_send_command;
include/sdhci.h +2 -0
index e84d2dc..e4e7ebe 100644
@@ -27,6 +27,7 @@
 #define __SDHCI_HW_H
 
 #include <asm/io.h>
+#include <mmc.h>
 /*
  * Controller registers
  */
@@ -239,6 +240,7 @@ struct sdhci_host {
 	unsigned int quirks;
 	unsigned int version;
 	unsigned int clock;
+	struct mmc *mmc;
 	const struct sdhci_ops *ops;
 };
 
Signature · 1 line
1.7.0.4
#21 lore raw

PATCH v3 3/5 mmc: sdhci: add mmc structure for host

Hello.

Quoted 4 lines · Lei Wen

So that sdhci host would tell in the driver that the mmc current attributes.

[...]

include/sdhci.h line 30

Quoted 9 lines
include/sdhci.h +1 -0
index e84d2dc..e4e7ebe 100644
@@ -27,6 +27,7 @@
  #define __SDHCI_HW_H
 
  #include<asm/io.h>
+#include<mmc.h>

Why remove empty line here?

include/sdhci.h line 33

Quoted 3 lines
include/sdhci.h +0 -0
  /*
   * Controller registers
   */

WBR, Sergei

#22 lore raw

PATCH v3 3/5 mmc: sdhci: add mmc structure for host

Hi Sergei,

Quoted 17 lines · Sergei Shtylyov

Hello.

Quoted 4 lines · Lei Wen

So that sdhci host would tell in the driver that the mmc current attributes.

[...]

Quoted 7 lines
include/sdhci.h +0 -0
index e84d2dc..e4e7ebe 100644
@@ -27,6 +27,7 @@

? #define __SDHCI_HW_H

Quoted 5 lines
Quoted 2 lines

? #include<asm/io.h>
+#include<mmc.h>

? ?Why remove empty line here?

Thanks for pointing that out! I would repost which keep the empty line.

Best regards,
Lei

author
#23 lore raw

PATCH v3 4/5 mmc: sdhci: add timeout for data transfer

In reply to Lei Wen

---
Changelog:
V2: no change
V3: no change

 drivers/mmc/sdhci.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +8 -1
index 31c738e..77a9e70 100644
@@ -81,8 +81,9 @@ static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data)
 static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 				unsigned int start_addr)
 {
-	unsigned int stat, rdy, mask, block = 0;
+	unsigned int stat, rdy, mask, timeout, block = 0;
 
+	timeout = 10000;
 	rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL;
 	mask = SDHCI_DATA_AVAILABLE | SDHCI_SPACE_AVAILABLE;
 	do {
@@ -108,6 +109,12 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 			sdhci_writel(host, start_addr, SDHCI_DMA_ADDRESS);
 		}
 #endif
+		if (timeout-- > 0)
+			udelay(10);
+		else {
+			printf("Transfer data timeout\n");
+			return -1;
+		}
 	} while (!(stat & SDHCI_INT_DATA_END));
 	return 0;
 }
Signature · 1 line
1.7.0.4
author
#24 lore raw

PATCH v3 5/5 mmc: sdhci: fix sdma bug for large file transfer

In reply to Lei Wen

SDHCI spec need to reset the sdma base address while the software try to accorss the 512k bytes address boundary. When meet such accross behavior, sdhci controller would generate a interrupt automatically, and software need handle this.

---
Changelog:
V2: no change
V3: new added fix for sdma bug

 drivers/mmc/sdhci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +1 -1
index 77a9e70..fce0ef0 100644
@@ -104,7 +104,7 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 #ifdef CONFIG_MMC_SDMA
 		if (stat & SDHCI_INT_DMA_END) {
 			sdhci_writel(host, SDHCI_INT_DMA_END, SDHCI_INT_STATUS);
-			start_addr &= SDHCI_DEFAULT_BOUNDARY_SIZE - 1;
+			start_addr &= ~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1);
 			start_addr += SDHCI_DEFAULT_BOUNDARY_SIZE;
 			sdhci_writel(host, start_addr, SDHCI_DMA_ADDRESS);
 		}
Signature · 1 line
1.7.0.4
author
#25 lore raw

PATCH v2 1/4 mmc: sdhci: fix cache flush

In reply to Lei Wen

Only flush the memory range needed.

---
Changelog:
V2: no change

 drivers/mmc/sdhci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +1 -1
index 9ebd33d..4a92453 100644
@@ -196,7 +196,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 
 	sdhci_writel(host, cmd->cmdarg, SDHCI_ARGUMENT);
 #ifdef CONFIG_MMC_SDMA
-	flush_cache(0, ~0);
+	flush_cache(start_addr, trans_bytes);
 #endif
 	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->cmdidx, flags), SDHCI_COMMAND);
 	do {
Signature · 1 line
1.7.0.4
author
#26 lore raw

PATCH v2 2/4 mmc: sdhci: fix build warning

In reply to Lei Wen

If CONFIG_MMC_SDHCI_IO_ACCESSORS is defined, the following warning would shows up:

include/sdhci.h:224: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:224: warning: its scope is only this definition or declaration, which is probably not what you want include/sdhci.h:225: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:226: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:227: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:228: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:229: warning: 'struct sdhci_host' declared inside parameter list

Change-Id I9e3588af34d90cda342cf32316ff9cfe57c1b5d1

---
Changelog:
V2: code style change

 include/sdhci.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/sdhci.h +3 -0
index 6d52ce9..e84d2dc 100644
@@ -214,6 +214,9 @@
  */
 #define SDHCI_QUIRK_32BIT_DMA_ADDR	(1 << 0)
 
+/* to make gcc happy */
+struct sdhci_host;
+
 /*
  * Host SDMA buffer boundary. Valid values from 4K to 512K in powers of 2.
  */
Signature · 1 line
1.7.0.4
author
#27 lore raw

PATCH 2/4 mmc: sdhci: fix build warning

If CONFIG_MMC_SDHCI_IO_ACCESSORS is defined, the following warning would shows up:

include/sdhci.h:224: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:224: warning: its scope is only this definition or declaration, which is probably not what you want include/sdhci.h:225: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:226: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:227: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:228: warning: 'struct sdhci_host' declared inside parameter list
include/sdhci.h:229: warning: 'struct sdhci_host' declared inside parameter list

---
Changelog:
V2: code style change
V2.1: delete "Change-Id"

 include/sdhci.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/sdhci.h +3 -0
index 6d52ce9..e84d2dc 100644
@@ -214,6 +214,9 @@
  */
 #define SDHCI_QUIRK_32BIT_DMA_ADDR	(1 << 0)
 
+/* to make gcc happy */
+struct sdhci_host;
+
 /*
  * Host SDMA buffer boundary. Valid values from 4K to 512K in powers of 2.
  */
Signature · 1 line
1.7.0.4
author
#28 lore raw

PATCH v2 3/4 mmc: sdhci: add mmc structure for host

In reply to Lei Wen

So that sdhci host would tell in the driver that the mmc current attributes.

---
Changelog:
V2: no change

 drivers/mmc/sdhci.c |    1 +
 include/sdhci.h     |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)
drivers/mmc/sdhci.c +1 -0
index 4a92453..31c738e 100644
@@ -377,6 +377,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
 	}
 
 	mmc->priv = host;
+	host->mmc = mmc;
 
 	sprintf(mmc->name, "%s", host->name);
 	mmc->send_cmd = sdhci_send_command;
include/sdhci.h +2 -0
index 6c6a8ea..2dd36a4 100644
@@ -27,6 +27,7 @@
 #define __SDHCI_HW_H
 
 #include <asm/io.h>
+#include <mmc.h>
 /*
  * Controller registers
  */
@@ -237,6 +238,7 @@ struct sdhci_host {
 	unsigned int quirks;
 	unsigned int version;
 	unsigned int clock;
+	struct mmc *mmc;
 	const struct sdhci_ops *ops;
 };
 
Signature · 1 line
1.7.0.4
author
#29 lore raw

PATCH v2 4/4 mmc: sdhci: add timeout for data transfer

In reply to Lei Wen

---
Changelog:
V2: no change

 drivers/mmc/sdhci.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/mmc/sdhci.c +8 -1
index 31c738e..77a9e70 100644
@@ -81,8 +81,9 @@ static void sdhci_transfer_pio(struct sdhci_host *host, struct mmc_data *data)
 static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 				unsigned int start_addr)
 {
-	unsigned int stat, rdy, mask, block = 0;
+	unsigned int stat, rdy, mask, timeout, block = 0;
 
+	timeout = 10000;
 	rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL;
 	mask = SDHCI_DATA_AVAILABLE | SDHCI_SPACE_AVAILABLE;
 	do {
@@ -108,6 +109,12 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 			sdhci_writel(host, start_addr, SDHCI_DMA_ADDRESS);
 		}
 #endif
+		if (timeout-- > 0)
+			udelay(10);
+		else {
+			printf("Transfer data timeout\n");
+			return -1;
+		}
 	} while (!(stat & SDHCI_INT_DATA_END));
 	return 0;
 }
Signature · 1 line
1.7.0.4