diff mbox

[[v4] 5/5] MMC: SDHCI AutoCMD23 support.

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

Commit Message

Andrei Warkentin April 27, 2011, 2:10 a.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
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

Arindam Nath April 27, 2011, 5:49 a.m. UTC | #1
Hi Andrei,

Is there any more change to your V4 than the ones we discussed yesterday? I did the mod we discussed, but seems like the driver only sends CMD23 now, not Auto CMD23.

Thanks,
Arindam

> -----Original Message-----
> From: Andrei Warkentin [mailto:andreiw@motorola.com]
> Sent: Wednesday, April 27, 2011 7:41 AM
> To: linux-mmc@vger.kernel.org
> Cc: Andrei Warkentin; Nath, Arindam; cjb@laptop.org; arnd@arndb.de;
> subhashj@codeaurora.org
> Subject: [[v4] 5/5] MMC: SDHCI AutoCMD23 support.
> 
> 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
> 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(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 41c987d..bf9aedb 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -844,7 +844,13 @@ static void sdhci_set_transfer_mode(struct
> sdhci_host *host,
>  		if (!host->mrq->sbc &&
>  		    host->flags & SDHCI_ACMD12)
>  			mode |= SDHCI_TRNS_ACMD12;
> +		else if (host->mrq->sbc &&
> +			 host->flags & SDHCI_ACMD23) {
> +			mode |= SDHCI_TRNS_ACMD23;
> +			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)
> @@ -1189,7 +1195,7 @@ static void sdhci_request(struct mmc_host *mmc,
> struct mmc_request *mrq)
>  		tasklet_schedule(&host->finish_tasklet);
>  	} else {
> 
> -		if (mrq->sbc)
> +		if (mrq->sbc && !(host->flags & SDHCI_ACMD23))
>  			sdhci_send_command(host, mrq->sbc);
>  		else
>  			sdhci_send_command(host, mrq->cmd);
> @@ -1947,6 +1953,15 @@ int sdhci_add_host(struct sdhci_host *host)
>  	if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12)
>  		host->flags |= SDHCI_ACMD12;
> 
> +	/* 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_ACMD23;
> +		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 85750a9..2b3fb76 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		0x00
> 
>  #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_ACMD12	0x04
> +#define  SDHCI_TRNS_ACMD23	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 c54ac14..d91585a 100644
> --- a/include/linux/mmc/sdhci.h
> +++ b/include/linux/mmc/sdhci.h
> @@ -110,6 +110,7 @@ struct sdhci_host {
>  #define SDHCI_REQ_USE_DMA	(1<<2)	/* Use DMA for this req. */
>  #define SDHCI_DEVICE_DEAD	(1<<3)	/* Device unresponsive */
>  #define SDHCI_ACMD12		(1<<4)	/* Auto CMD12 support */
> +#define SDHCI_ACMD23		(1<<5)	/* Auto CMD23 support */
> 
>  	unsigned int version;	/* SDHCI spec. version */
> 
> --
> 1.7.0.4
> 


--
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
Andrei Warkentin April 27, 2011, 5:59 a.m. UTC | #2
Hi Arindam,

On Wed, Apr 27, 2011 at 12:49 AM, Nath, Arindam <Arindam.Nath@amd.com> wrote:
> Hi Andrei,
>
> Is there any more change to your V4 than the ones we discussed yesterday? I did the mod we discussed, but seems like the driver only sends CMD23 now, not Auto CMD23.
>

Two things V4 does, both of which we discussed yesterday -
1) Make sure the code that set SDHCI_ACMD23 is always run (got rid of
the Kconfig conditional)
2) Make sure value written into ARGUMENT2 comes from sbc struct.

Only (1) should have affected you. (2) would have broken rel. writes.
I put in an info print telling you if you have auto-cmd23 available or
not. If you see CMD23 getting sent, then AutoCMD23 was not detected as
a feature. Weird. SDHCI_ACMD23 is set if
a) Host controller is version 3
b) You're using ADMA or no DMA.

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
Arindam Nath April 27, 2011, 6:02 a.m. UTC | #3
Guess I will have to hand modify my code based on your V4 patches again, I don't think your patches are based on top of mine.

Thanks,
Arindam

> -----Original Message-----
> From: Andrei Warkentin [mailto:andreiw@motorola.com]
> Sent: Wednesday, April 27, 2011 11:30 AM
> To: Nath, Arindam
> Cc: linux-mmc@vger.kernel.org; cjb@laptop.org; arnd@arndb.de;
> subhashj@codeaurora.org
> Subject: Re: [[v4] 5/5] MMC: SDHCI AutoCMD23 support.
> 
> Hi Arindam,
> 
> On Wed, Apr 27, 2011 at 12:49 AM, Nath, Arindam <Arindam.Nath@amd.com>
> wrote:
> > Hi Andrei,
> >
> > Is there any more change to your V4 than the ones we discussed
> yesterday? I did the mod we discussed, but seems like the driver only
> sends CMD23 now, not Auto CMD23.
> >
> 
> Two things V4 does, both of which we discussed yesterday -
> 1) Make sure the code that set SDHCI_ACMD23 is always run (got rid of
> the Kconfig conditional)
> 2) Make sure value written into ARGUMENT2 comes from sbc struct.
> 
> Only (1) should have affected you. (2) would have broken rel. writes.
> I put in an info print telling you if you have auto-cmd23 available or
> not. If you see CMD23 getting sent, then AutoCMD23 was not detected as
> a feature. Weird. SDHCI_ACMD23 is set if
> a) Host controller is version 3
> b) You're using ADMA or no DMA.
> 
> 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
Andrei Warkentin April 27, 2011, 6:05 a.m. UTC | #4
On Wed, Apr 27, 2011 at 1:02 AM, Nath, Arindam <Arindam.Nath@amd.com> wrote:
> Guess I will have to hand modify my code based on your V4 patches again, I don't think your patches are based on top of mine.
>
> Thanks,
> Arindam
>

Just verify these blobs look similar -

+               else if (host->mrq->sbc &&
+                        host->flags & SDHCI_ACMD23) {
+                       mode |= SDHCI_TRNS_ACMD23;
+                       sdhci_writel(host, host->mrq->sbc->arg,
SDHCI_ARGUMENT2);
+               }

and

               host->flags |= SDHCI_ACMD12;

+       /* 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_ACMD23;
+               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

I apologize for the fuss.

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
Arindam Nath April 28, 2011, 8:34 a.m. UTC | #5
Hi Andrei,

The controller is able to send Auto CMD23 with your patch.

Thanks,
Arindam

> -----Original Message-----
> From: Andrei Warkentin [mailto:andreiw@motorola.com]
> Sent: Wednesday, April 27, 2011 11:36 AM
> To: Nath, Arindam
> Cc: linux-mmc@vger.kernel.org; cjb@laptop.org; arnd@arndb.de;
> subhashj@codeaurora.org
> Subject: Re: [[v4] 5/5] MMC: SDHCI AutoCMD23 support.
> 
> On Wed, Apr 27, 2011 at 1:02 AM, Nath, Arindam <Arindam.Nath@amd.com>
> wrote:
> > Guess I will have to hand modify my code based on your V4 patches
> again, I don't think your patches are based on top of mine.
> >
> > Thanks,
> > Arindam
> >
> 
> Just verify these blobs look similar -
> 
> +               else if (host->mrq->sbc &&
> +                        host->flags & SDHCI_ACMD23) {
> +                       mode |= SDHCI_TRNS_ACMD23;
> +                       sdhci_writel(host, host->mrq->sbc->arg,
> SDHCI_ARGUMENT2);
> +               }
> 
> and
> 
>                host->flags |= SDHCI_ACMD12;
> 
> +       /* 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_ACMD23;
> +               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
> 
> I apologize for the fuss.
> 
> 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
Andrei Warkentin April 28, 2011, 7:09 p.m. UTC | #6
On Thu, Apr 28, 2011 at 3:34 AM, Nath, Arindam <Arindam.Nath@amd.com> wrote:
> Hi Andrei,
>
> The controller is able to send Auto CMD23 with your patch.
>
> Thanks,
> Arindam
>

Whoo hoo :-). This just about made my day... Thanks a lot Arindam, I
really appreciate you taking your time to test this out!

So is that an Ack?

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
Arindam Nath April 29, 2011, 5:34 a.m. UTC | #7
Hi Andrei,


> -----Original Message-----
> From: Andrei Warkentin [mailto:andreiw@motorola.com]
> Sent: Friday, April 29, 2011 12:40 AM
> To: Nath, Arindam
> Cc: linux-mmc@vger.kernel.org; cjb@laptop.org; arnd@arndb.de;
> subhashj@codeaurora.org; Xu, Suki
> Subject: Re: [[v4] 5/5] MMC: SDHCI AutoCMD23 support.
> 
> On Thu, Apr 28, 2011 at 3:34 AM, Nath, Arindam <Arindam.Nath@amd.com>
> wrote:
> > Hi Andrei,
> >
> > The controller is able to send Auto CMD23 with your patch.
> >
> > Thanks,
> > Arindam
> >
> 
> Whoo hoo :-). This just about made my day... Thanks a lot Arindam, I
> really appreciate you taking your time to test this out!
> 
> So is that an Ack?

I am not sure whether I qualify for an Acked-by, but I can give you Tested-by.

Tested-by: Arindam Nath <arindam.nath@amd.com>

Thanks,
Arindam


--
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 41c987d..bf9aedb 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -844,7 +844,13 @@  static void sdhci_set_transfer_mode(struct sdhci_host *host,
 		if (!host->mrq->sbc &&
 		    host->flags & SDHCI_ACMD12)
 			mode |= SDHCI_TRNS_ACMD12;
+		else if (host->mrq->sbc &&
+			 host->flags & SDHCI_ACMD23) {
+			mode |= SDHCI_TRNS_ACMD23;
+			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)
@@ -1189,7 +1195,7 @@  static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
 		tasklet_schedule(&host->finish_tasklet);
 	} else {
 
-		if (mrq->sbc)
+		if (mrq->sbc && !(host->flags & SDHCI_ACMD23))
 			sdhci_send_command(host, mrq->sbc);
 		else
 			sdhci_send_command(host, mrq->cmd);
@@ -1947,6 +1953,15 @@  int sdhci_add_host(struct sdhci_host *host)
 	if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12)
 		host->flags |= SDHCI_ACMD12;
 
+	/* 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_ACMD23;
+		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 85750a9..2b3fb76 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		0x00
 
 #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_ACMD12	0x04
+#define  SDHCI_TRNS_ACMD23	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 c54ac14..d91585a 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -110,6 +110,7 @@  struct sdhci_host {
 #define SDHCI_REQ_USE_DMA	(1<<2)	/* Use DMA for this req. */
 #define SDHCI_DEVICE_DEAD	(1<<3)	/* Device unresponsive */
 #define SDHCI_ACMD12		(1<<4)	/* Auto CMD12 support */
+#define SDHCI_ACMD23		(1<<5)	/* Auto CMD23 support */
 
 	unsigned int version;	/* SDHCI spec. version */