Skip to contentSkip to conversation

mmc: prepare SDHCI_HOST_CONTROL for SDMA operation

RFC PATCH New Rommel G Custodio 2 participants 2 messages Nov 7, 2012 – Nov 8, 2012 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 mmc: prepare SDHCI_HOST_CONTROL for SDMA operation

modification for commit 804c7f422169212e92530e1ddaf74bf1ca9ebfa1

The original patch contained a bug.
Using a char with sdhci_readl/sdhci_writel operation.
The adjacent bytes to SDHCI_HOST_CONTROL (specially SDHCI_POWER_CONTROL) get mangled and can result in the controller entering an unstable state.

This patch also moves the process inside sdhci_init().

---
 drivers/mmc/sdhci.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/mmc/sdhci.c +8 -7
index 7845f87..fae2169 100644
@@ -82,13 +82,6 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 				unsigned int start_addr)
 {
 	unsigned int stat, rdy, mask, timeout, block = 0;
-#ifdef CONFIG_MMC_SDMA
-	unsigned char ctrl;
-	ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
-	ctrl &= ~SDHCI_CTRL_DMA_MASK;
-	ctrl |= SDHCI_CTRL_SDMA;
-	sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
-#endif
 
 	timeout = 1000000;
 	rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL;
@@ -386,6 +379,14 @@ int sdhci_init(struct mmc *mmc)
 {
 	struct sdhci_host *host = (struct sdhci_host *)mmc->priv;
 
+#ifdef CONFIG_MMC_SDMA
+	unsigned int ctrl;
+	ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
+	ctrl &= ~SDHCI_CTRL_DMA_MASK;
+	ctrl |= SDHCI_CTRL_SDMA;
+	sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
+#endif
+
 	if ((host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) && !aligned_buffer) {
 		aligned_buffer = memalign(8, 512*1024);
 		if (!aligned_buffer) {
Signature · 9 lines
1.8.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121108/44e83d25/attachment.pgp>
#1 lore raw

RFC PATCH 1/1 mmc: prepare SDHCI_HOST_CONTROL for SDMA operation

Hi Rommel,

Looks good to me. Thank you.

Quoted 48 lines · Rommel G Custodio

modification for commit 804c7f422169212e92530e1ddaf74bf1ca9ebfa1

The original patch contained a bug.
Using a char with sdhci_readl/sdhci_writel operation.
The adjacent bytes to SDHCI_HOST_CONTROL (specially SDHCI_POWER_CONTROL) get mangled and can result in the controller entering an unstable state.

This patch also moves the process inside sdhci_init().

---
 drivers/mmc/sdhci.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/mmc/sdhci.c +8 -7
index 7845f87..fae2169 100644
@@ -82,13 +82,6 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 				unsigned int start_addr)
 {
 	unsigned int stat, rdy, mask, timeout, block = 0;
-#ifdef CONFIG_MMC_SDMA
-	unsigned char ctrl;
-	ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
-	ctrl &= ~SDHCI_CTRL_DMA_MASK;
-	ctrl |= SDHCI_CTRL_SDMA;
-	sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
-#endif
 
 	timeout = 1000000;
 	rdy = SDHCI_INT_SPACE_AVAIL | SDHCI_INT_DATA_AVAIL;
@@ -386,6 +379,14 @@ int sdhci_init(struct mmc *mmc)
 {
 	struct sdhci_host *host = (struct sdhci_host *)mmc->priv;
 
+#ifdef CONFIG_MMC_SDMA
+	unsigned int ctrl;
+	ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
+	ctrl &= ~SDHCI_CTRL_DMA_MASK;
+	ctrl |= SDHCI_CTRL_SDMA;
+	sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
+#endif
+
 	if ((host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) && !aligned_buffer) {
 		aligned_buffer = memalign(8, 512*1024);
 		if (!aligned_buffer) {