From patchwork Mon May 23 20:06:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Warkentin X-Patchwork-Id: 809922 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4NJX6e1021009 for ; Mon, 23 May 2011 19:33:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932667Ab1EWTdd (ORCPT ); Mon, 23 May 2011 15:33:33 -0400 Received: from exprod5og112.obsmtp.com ([64.18.0.24]:56321 "EHLO exprod5og112.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932368Ab1EWTdd (ORCPT ); Mon, 23 May 2011 15:33:33 -0400 Received: from DE01MGRG01.AM.MOT-MOBILITY.COM ([192.54.82.14]) (using TLSv1) by exprod5ob112.postini.com ([64.18.4.12]) with SMTP ID DSNKTdq2i0DU/NQo7xMXiyMD6vAH7dzuaqfA@postini.com; Mon, 23 May 2011 12:33:32 PDT Received: from DE01MGRG01.AM.MOT-MOBILITY.COM ([10.22.94.167]) by DE01MGRG01.AM.MOT-MOBILITY.COM (8.14.3/8.14.3) with ESMTP id p4NJY3AC024256 for ; Mon, 23 May 2011 15:34:03 -0400 (EDT) Received: from mail-pw0-f42.google.com (mail-pw0-f42.google.com [209.85.160.42]) by DE01MGRG01.AM.MOT-MOBILITY.COM (8.14.3/8.14.3) with ESMTP id p4NJXhhb024088 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=OK) for ; Mon, 23 May 2011 15:34:02 -0400 (EDT) Received: by mail-pw0-f42.google.com with SMTP id 3so3491829pwj.15 for ; Mon, 23 May 2011 12:33:30 -0700 (PDT) Received: by 10.142.62.23 with SMTP id k23mr823420wfa.316.1306179210413; Mon, 23 May 2011 12:33:30 -0700 (PDT) Received: from localhost.localdomain (dyngate-ca119-13.motorola.com [144.189.96.13]) by mx.google.com with ESMTPS id x11sm6073611wfd.13.2011.05.23.12.33.27 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 May 2011 12:33:29 -0700 (PDT) From: Andrei Warkentin To: linux-mmc@vger.kernel.org Cc: cjb@laptop.org, Andrei Warkentin , arindam.nath@amd.com, arnd@arndb.de, subhashj@codeaurora.org, malchev@google.com Subject: [v6 5/5] MMC: SDHCI AutoCMD23 support. Date: Mon, 23 May 2011 15:06:39 -0500 Message-Id: <1306181199-13915-6-git-send-email-andreiw@motorola.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1305841590-26963-1-git-send-email-andreiw@motorola.com> References: <1305841590-26963-1-git-send-email-andreiw@motorola.com> X-CFilter-Loop: Reflected Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 23 May 2011 19:33:42 +0000 (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 Signed-off-by: Andrei Warkentin --- 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 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 */