diff mbox

[v6,5/5] MMC: SDHCI AutoCMD23 support.

Message ID 1306181199-13915-6-git-send-email-andreiw@motorola.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrei Warkentin May 23, 2011, 8:06 p.m. UTC
Enables Auto-CMD23 support where available (SDHCI 3.0 controllers)

Cc: arindam.nath@amd.com
Cc: cjb@laptop.org
Cc: arnd@arndb.de
Cc: subhashj@codeaurora.org
Cc: malchev@google.com
Tested-by: Arindam Nath <arindam.nath@amd.com>
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
 drivers/mmc/host/sdhci.c  |   17 ++++++++++++++++-
 drivers/mmc/host/sdhci.h  |    2 ++
 include/linux/mmc/sdhci.h |    1 +
 3 files changed, 19 insertions(+), 1 deletions(-)

Comments

Chris Ball May 24, 2011, 11:27 p.m. UTC | #1
Hi Andrei,

On Mon, May 23 2011, Andrei Warkentin wrote:
> Enables Auto-CMD23 support where available (SDHCI 3.0 controllers)
>
> Cc: arindam.nath@amd.com
> Cc: cjb@laptop.org
> Cc: arnd@arndb.de
> Cc: subhashj@codeaurora.org
> Cc: malchev@google.com
> Tested-by: Arindam Nath <arindam.nath@amd.com>
> Signed-off-by: Andrei Warkentin <andreiw@motorola.com>

Looks like this patch is breaking boot on my XO-1.75/Marvell MMP2 A2
with SD 3.0 controller.  :/

[    1.217156] sdhci: Secure Digital Host Controller Interface driver
[    1.223361] sdhci: Copyright(c) Pierre Ossman
[    1.227793] mmc0: Auto-CMD23 available
[    1.227793] mmc0: no vmmc regulator found
[    1.242557] mmc0: SDHCI controller on MMC [sdhci-pxa.0] using DMA
[    1.248748] mmc1: Auto-CMD23 available
[    1.252479] mmc1: no vmmc regulator found
[    1.256599] mmc1: SDHCI controller on MMC [sdhci-pxa.1] using DMA
[    1.262694] mmc2: Auto-CMD23 available
[    1.266571] mmc2: no vmmc regulator found
[    1.270655] mmc2: SDHCI controller on MMC [sdhci-pxa.2] using DMA
[    1.656280] mmc1: new SDIO card at address 0001
[    2.423849] libertas: 20:7c:8f:4a:79:c5, fw 9.70.7p0, cap 0x000003a3
[    2.432951] libertas: wlan0: Marvell WLAN 802.11 adapter
[    2.438262] Waiting for root device /dev/mmcblk0p2...
[    2.528607] mmc2: new high speed DDR MMC card at address 0001
[    2.534597] mmcblk0: mmc2:0001 SEM04G 3.68 GiB
[    2.539198] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB
[    2.545166] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB
[    2.555985]  mmcblk0: unknown partition table
^^^^^
[    2.562610]  mmcblk0boot1: unknown partition table
[    2.569715]  mmcblk0boot0: unknown partition table
[    2.663264] VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2)

With the patch reverted, mmcblk0 comes up with partitions 1 and 2 and
mmcblk0p2 is mounted.  In this log, we fail to find a partition table
and panic.

Any ideas/suggestions?  I'm surprised that we enabled Auto-CMD23 on this
hardware; it is a v3 controller, but it has SDHCI_QUIRK_BROKEN_ADMA set..

Philip/Zhangfei, were you able to test this patch on MMP2?

Thanks,

- Chris.
Andrei Warkentin May 25, 2011, 12:37 a.m. UTC | #2
Hi Chris,

On Tue, May 24, 2011 at 6:27 PM, Chris Ball <cjb@laptop.org> wrote:
> Hi Andrei,
>
> On Mon, May 23 2011, Andrei Warkentin wrote:
>> Enables Auto-CMD23 support where available (SDHCI 3.0 controllers)
>>
>> Cc: arindam.nath@amd.com
>> Cc: cjb@laptop.org
>> Cc: arnd@arndb.de
>> Cc: subhashj@codeaurora.org
>> Cc: malchev@google.com
>> Tested-by: Arindam Nath <arindam.nath@amd.com>
>> Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
>
> Looks like this patch is breaking boot on my XO-1.75/Marvell MMP2 A2
> with SD 3.0 controller.  :/
>
> [    1.217156] sdhci: Secure Digital Host Controller Interface driver
> [    1.223361] sdhci: Copyright(c) Pierre Ossman
> [    1.227793] mmc0: Auto-CMD23 available
> [    1.227793] mmc0: no vmmc regulator found
> [    1.242557] mmc0: SDHCI controller on MMC [sdhci-pxa.0] using DMA
> [    1.248748] mmc1: Auto-CMD23 available
> [    1.252479] mmc1: no vmmc regulator found
> [    1.256599] mmc1: SDHCI controller on MMC [sdhci-pxa.1] using DMA
> [    1.262694] mmc2: Auto-CMD23 available
> [    1.266571] mmc2: no vmmc regulator found
> [    1.270655] mmc2: SDHCI controller on MMC [sdhci-pxa.2] using DMA
> [    1.656280] mmc1: new SDIO card at address 0001
> [    2.423849] libertas: 20:7c:8f:4a:79:c5, fw 9.70.7p0, cap 0x000003a3
> [    2.432951] libertas: wlan0: Marvell WLAN 802.11 adapter
> [    2.438262] Waiting for root device /dev/mmcblk0p2...
> [    2.528607] mmc2: new high speed DDR MMC card at address 0001
> [    2.534597] mmcblk0: mmc2:0001 SEM04G 3.68 GiB
> [    2.539198] mmcblk0boot0: mmc2:0001 SEM04G partition 1 1.00 MiB
> [    2.545166] mmcblk0boot1: mmc2:0001 SEM04G partition 2 1.00 MiB
> [    2.555985]  mmcblk0: unknown partition table
> ^^^^^
> [    2.562610]  mmcblk0boot1: unknown partition table
> [    2.569715]  mmcblk0boot0: unknown partition table
> [    2.663264] VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2)
>
> With the patch reverted, mmcblk0 comes up with partitions 1 and 2 and
> mmcblk0p2 is mounted.  In this log, we fail to find a partition table
> and panic.
>
> Any ideas/suggestions?  I'm surprised that we enabled Auto-CMD23 on this
> hardware; it is a v3 controller, but it has SDHCI_QUIRK_BROKEN_ADMA set..
>

Looks like I am not honoring the broken ADMA flag :(. I was under the
impression that it would have resulted in clearing the ADMA flag
earlier, but looks like I was wrong.

Will resend tomorrow.

A
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 3a53512..fbb1842 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -860,7 +860,13 @@  static void sdhci_set_transfer_mode(struct sdhci_host *host,
 		if (!host->mrq->sbc &&
 		    host->flags & SDHCI_AUTO_CMD12)
 			mode |= SDHCI_TRNS_AUTO_CMD12;
+		else if (host->mrq->sbc &&
+			 host->flags & SDHCI_AUTO_CMD23) {
+			mode |= SDHCI_TRNS_AUTO_CMD23;
+			sdhci_writel(host, host->mrq->sbc->arg, SDHCI_ARGUMENT2);
+		}
 	}
+
 	if (data->flags & MMC_DATA_READ)
 		mode |= SDHCI_TRNS_READ;
 	if (host->flags & SDHCI_REQ_USE_DMA)
@@ -1255,7 +1261,7 @@  static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 			host->mrq = mrq;
 		}
 
-		if (mrq->sbc)
+		if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23))
 			sdhci_send_command(host, mrq->sbc);
 		else
 			sdhci_send_command(host, mrq->cmd);
@@ -2491,6 +2497,15 @@  int sdhci_add_host(struct sdhci_host *host)
 	if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12)
 		host->flags |= SDHCI_AUTO_CMD12;
 
+	/* Auto-CMD23 stuff only works in ADMA or PIO. */
+	if ((host->version == SDHCI_SPEC_300) &&
+	    ((host->flags & SDHCI_USE_ADMA) ||
+	     !(host->flags & SDHCI_REQ_USE_DMA))) {
+		host->flags |= SDHCI_AUTO_CMD23;
+		printk(KERN_INFO "%s: Auto-CMD23 available\n", mmc_hostname(mmc));
+	} else
+		printk(KERN_INFO "%s: Auto-CMD23 unavailable\n", mmc_hostname(mmc));
+
 	/*
 	 * A controller may support 8-bit width, but the board itself
 	 * might not have the pins brought out.  Boards that support
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 2c3fbc5..745c42f 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -25,6 +25,7 @@ 
  */
 
 #define SDHCI_DMA_ADDRESS	0x00
+#define SDHCI_ARGUMENT2		SDHCI_DMA_ADDRESS
 
 #define SDHCI_BLOCK_SIZE	0x04
 #define  SDHCI_MAKE_BLKSZ(dma, blksz) (((dma & 0x7) << 12) | (blksz & 0xFFF))
@@ -37,6 +38,7 @@ 
 #define  SDHCI_TRNS_DMA		0x01
 #define  SDHCI_TRNS_BLK_CNT_EN	0x02
 #define  SDHCI_TRNS_AUTO_CMD12	0x04
+#define  SDHCI_TRNS_AUTO_CMD23	0x08
 #define  SDHCI_TRNS_READ	0x10
 #define  SDHCI_TRNS_MULTI	0x20
 
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 73e27ba..6a68c4e 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -114,6 +114,7 @@  struct sdhci_host {
 #define SDHCI_SDR50_NEEDS_TUNING (1<<4)	/* SDR50 needs tuning */
 #define SDHCI_NEEDS_RETUNING	(1<<5)	/* Host needs retuning */
 #define SDHCI_AUTO_CMD12	(1<<6)	/* Auto CMD12 support */
+#define SDHCI_AUTO_CMD23	(1<<7)	/* Auto CMD23 support */
 
 	unsigned int version;	/* SDHCI spec. version */