Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp435056imm; Wed, 29 Aug 2018 03:51:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdamZQ8Gr8fungjODYfTSbXMbkxa52UlcAIdLFn5pr8js+/b4w6AQUL5ssPnLf2OyhttQ4qa X-Received: by 2002:a17:902:8f8c:: with SMTP id z12-v6mr5444707plo.4.1535539897079; Wed, 29 Aug 2018 03:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535539897; cv=none; d=google.com; s=arc-20160816; b=vrvZNsNSijFh5Y5NTh+Y5RebhvlX0ifDFnl/WU0SD8B42F7sSiCX/1ErepOdoAungb 8Yc71odwdDXMAF7+6mByIZFWwUNnUmZwWwQ2kS/7sJ3S0Qm2p0Y41bR7DNe7eRSt6YPa v1oBGNFMRILztvpyewORUPwD0AXu62aUmhiTW6hH6LL1eQoSd105WCqwxht6hyHTCldz NM9A5ryyNVZAeaUPByaqi2Yt6k01ystVOCU+8cewbgQZiLDCHCgHOZFNK8HwEnsR0EyX PSgha4YY9Eqfx07Gv6VRj/aTvbBZivS/I10w9NUz++xUqgkBtCWdY2te+z4WmlOJOTdv lscw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=ZtwiAnNv3Od7BWm4NfKG4RaPr42G5dx1XrypHtA8B38=; b=aw1tNIPTvVCcLqm3jZRoeNdS45mgLHSMVz9V5hnk6oBLrzcksWsqkYx56D/LsSRBCn qoyFnFS1nusKgV73yMYjEysH43Yd+3+WUVb70ltCLHwZuLc8/5ydNde6/eBeHmFOmXxR MPyj2wq6BpQjs9fEHZ6hvfjUBJijezcdvcGA1AI5NQIUfA5A+YW15cb3dx09H6VN40vI RxgTl4O12P4UFd4i7+JDGaHDBVNh/JUt+Rhrbie9UdmuwcgPo+UseCvucDWQgLQyYSa/ Xr5sAfWjoJGvgJKPQp4MGpd5EE1RrrSNKSUC+8m1+LrnXvd/4KZaDaYhD62UIKUYMJ/w DqNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2-v6si3642244pgb.417.2018.08.29.03.51.21; Wed, 29 Aug 2018 03:51:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728316AbeH2Oq2 (ORCPT + 99 others); Wed, 29 Aug 2018 10:46:28 -0400 Received: from mga09.intel.com ([134.134.136.24]:15406 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbeH2Oq2 (ORCPT ); Wed, 29 Aug 2018 10:46:28 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2018 03:50:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,301,1531810800"; d="scan'208";a="66029671" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.98]) ([10.237.72.98]) by fmsmga007.fm.intel.com with ESMTP; 29 Aug 2018 03:49:53 -0700 Subject: Re: [PATCH V7 6/9] mmc: sdhci: Add Auto CMD Auto Select support To: Chunyan Zhang , Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Baolin Wang , Billows Wu , Jason Wu , Chunyan Zhang , Chunyan Zhang References: <1535526184-32718-1-git-send-email-zhang.chunyan@linaro.org> <1535526184-32718-7-git-send-email-zhang.chunyan@linaro.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <6a704ff7-82aa-bc69-e7e3-a941a40ac524@intel.com> Date: Wed, 29 Aug 2018 13:48:12 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1535526184-32718-7-git-send-email-zhang.chunyan@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/08/18 10:03, Chunyan Zhang wrote: > As SD Host Controller Specification v4.10 documents: > Host Controller Version 4.10 defines this "Auto CMD Auto Select" mode. > Selection of Auto CMD depends on setting of CMD23 Enable in the Host > Control 2 register which indicates whether card supports CMD23. If CMD23 > Enable =1, Auto CMD23 is used and if CMD23 Enable =0, Auto CMD12 is > used. In case of Version 4.10 or later, use of Auto CMD Auto Select is > recommended rather than use of Auto CMD12 Enable or Auto CMD23 > Enable. > > This patch add this new mode support. > > Signed-off-by: Chunyan Zhang Acked-by: Adrian Hunter > --- > drivers/mmc/host/sdhci.c | 49 ++++++++++++++++++++++++++++++++++++++---------- > drivers/mmc/host/sdhci.h | 2 ++ > 2 files changed, 41 insertions(+), 10 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index 604bf4c..62d843ac90 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -1095,6 +1095,43 @@ static inline bool sdhci_auto_cmd12(struct sdhci_host *host, > !mrq->cap_cmd_during_tfr; > } > > +static inline void sdhci_auto_cmd_select(struct sdhci_host *host, > + struct mmc_command *cmd, > + u16 *mode) > +{ > + bool use_cmd12 = sdhci_auto_cmd12(host, cmd->mrq) && > + (cmd->opcode != SD_IO_RW_EXTENDED); > + bool use_cmd23 = cmd->mrq->sbc && (host->flags & SDHCI_AUTO_CMD23); > + u16 ctrl2; > + > + /* > + * In case of Version 4.10 or later, use of 'Auto CMD Auto > + * Select' is recommended rather than use of 'Auto CMD12 > + * Enable' or 'Auto CMD23 Enable'. > + */ > + if (host->version >= SDHCI_SPEC_410 && (use_cmd12 || use_cmd23)) { > + *mode |= SDHCI_TRNS_AUTO_SEL; > + > + ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); > + if (use_cmd23) > + ctrl2 |= SDHCI_CMD23_ENABLE; > + else > + ctrl2 &= ~SDHCI_CMD23_ENABLE; > + sdhci_writew(host, ctrl2, SDHCI_HOST_CONTROL2); > + > + return; > + } > + > + /* > + * If we are sending CMD23, CMD12 never gets sent > + * on successful completion (so no Auto-CMD12). > + */ > + if (use_cmd12) > + *mode |= SDHCI_TRNS_AUTO_CMD12; > + else if (use_cmd23) > + *mode |= SDHCI_TRNS_AUTO_CMD23; > +} > + > static void sdhci_set_transfer_mode(struct sdhci_host *host, > struct mmc_command *cmd) > { > @@ -1123,17 +1160,9 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host, > > if (mmc_op_multi(cmd->opcode) || data->blocks > 1) { > mode = SDHCI_TRNS_BLK_CNT_EN | SDHCI_TRNS_MULTI; > - /* > - * If we are sending CMD23, CMD12 never gets sent > - * on successful completion (so no Auto-CMD12). > - */ > - if (sdhci_auto_cmd12(host, cmd->mrq) && > - (cmd->opcode != SD_IO_RW_EXTENDED)) > - mode |= SDHCI_TRNS_AUTO_CMD12; > - else if (cmd->mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) { > - mode |= SDHCI_TRNS_AUTO_CMD23; > + sdhci_auto_cmd_select(host, cmd, &mode); > + if (cmd->mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) > sdhci_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); > - } > } > > if (data->flags & MMC_DATA_READ) > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > index f7a1079..4a19ff8 100644 > --- a/drivers/mmc/host/sdhci.h > +++ b/drivers/mmc/host/sdhci.h > @@ -42,6 +42,7 @@ > #define SDHCI_TRNS_BLK_CNT_EN 0x02 > #define SDHCI_TRNS_AUTO_CMD12 0x04 > #define SDHCI_TRNS_AUTO_CMD23 0x08 > +#define SDHCI_TRNS_AUTO_SEL 0x0C > #define SDHCI_TRNS_READ 0x10 > #define SDHCI_TRNS_MULTI 0x20 > > @@ -185,6 +186,7 @@ > #define SDHCI_CTRL_DRV_TYPE_D 0x0030 > #define SDHCI_CTRL_EXEC_TUNING 0x0040 > #define SDHCI_CTRL_TUNED_CLK 0x0080 > +#define SDHCI_CMD23_ENABLE 0x0800 > #define SDHCI_CTRL_V4_MODE 0x1000 > #define SDHCI_CTRL_64BIT_ADDR 0x2000 > #define SDHCI_CTRL_PRESET_VAL_ENABLE 0x8000 >