Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3399350imm; Tue, 17 Jul 2018 04:19:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpclSI2VOiu3b3RBp5Bew2R2/TFWfSL2kGqQxijYZpDHjLEVffVfsDkOvZ9D6tGKAuJk1bmU X-Received: by 2002:aa7:808f:: with SMTP id v15-v6mr283838pff.38.1531826356268; Tue, 17 Jul 2018 04:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531826356; cv=none; d=google.com; s=arc-20160816; b=bUfcFt6O3T0997c7qk8piaFybU0HkRa1XoxZfeo8WApZsZm/JgVWWGZuYQAKxG3c69 PzpluJTGEN8L5DjTCU+4Z4y+5AelB4j1dRTn/nXX6f6M/eoNHrT/JlS+h2cg7BTQGd7n 7cx1mAVX9+2d/x8UuCkPFy+bVhqrdGrL3bNCqpQGM+R5R1/UUIBsjSInlTFYEb2Q71ee p1l1wBHxJSRGC3Yi2jzZur3Q/bksRaWmix5SWbBx1BLrMbw72VBS6lbnc6wSeJq/H5xb 9p4hJhMK2n9IuVrJcvmnHjjTYhEXp/EMd/Ua7wvrRw4Wna53WB5B1+1PqH+bVweJeM2C letQ== 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=xGmm6EmoIWutVkMIPNeHndsDU3I4RbV+B1PKVViHO7I=; b=nSOnAIvtrXXZC3DMFnEh5d54C/M0Zvj5PNfCkt396w3yq8wT4lod7ygbI9qJcSk7SK cJH7zbA66pM5c72qkeLUDoSuM/EQN31I9LcTg+ULkIN9aABRfX/mkQp5/0nylwM3d9ra w8k/aQKIcUac3eBoIUPTr3ZSUamHH8AP/vgA+c+8qeHUpABy2LLa4P8R77KIYdCd0AFO HSPIx+q/bp7elDWbVLKsV/rU5GmK+srN9GrP6aJAUxEaBvPzk2UFd4NKgoF/Oa6RtGSQ rfRqALBEvDdVklHcMf+FXOxg75XZ/F5tpjkzFlWrQQMkLIFeQWSEiDq3yo0J5BMP1TaL gKRw== 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 p1-v6si670071pfe.150.2018.07.17.04.19.01; Tue, 17 Jul 2018 04:19:16 -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 S1730947AbeGQLue (ORCPT + 99 others); Tue, 17 Jul 2018 07:50:34 -0400 Received: from mga07.intel.com ([134.134.136.100]:40700 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730169AbeGQLud (ORCPT ); Tue, 17 Jul 2018 07:50:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 04:18:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,365,1526367600"; d="scan'208";a="73026217" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by fmsmga001.fm.intel.com with ESMTP; 17 Jul 2018 04:17:50 -0700 Subject: Re: [PATCH V3 5/7] 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 , zhang.lyra@gmail.com References: <1531106398-14062-1-git-send-email-zhang.chunyan@linaro.org> <1531106398-14062-6-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: <3cc11907-5248-ea5a-5e2a-f93e12ef4e68@intel.com> Date: Tue, 17 Jul 2018 14:16:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 In-Reply-To: <1531106398-14062-6-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 09/07/18 06:19, 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 > --- > drivers/mmc/host/sdhci.c | 39 ++++++++++++++++++++++++++++----------- > drivers/mmc/host/sdhci.h | 2 ++ > 2 files changed, 30 insertions(+), 11 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index f64e766..1ca3871 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -1033,6 +1033,33 @@ static inline bool sdhci_auto_cmd12(struct sdhci_host *host, > !mrq->cap_cmd_during_tfr; > } > > +static inline void sdhci_auto_cmd_enable(struct sdhci_host *host, > + struct mmc_command *cmd, > + u16 *mode) > +{ > + /* > + * 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) { > + *mode |= SDHCI_TRNS_AUTO_SEL; The rules for selecting auto commands still need to be applied. In effect: if (sdhci_auto_cmd12(host, cmd->mrq) && (cmd->opcode != SD_IO_RW_EXTENDED)) { *mode |= SDHCI_TRNS_AUTO_SEL; } else if (cmd->mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) { *mode |= SDHCI_TRNS_AUTO_SEL; sdhci_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); } Also the selection of Host Control 2 register CMD23 Enable should be done by SDHCI (if supported by the card) not the Spreadtrum driver. > + return; > + } > + > + /* > + * 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_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); > + } > +} > + > static void sdhci_set_transfer_mode(struct sdhci_host *host, > struct mmc_command *cmd) > { > @@ -1059,17 +1086,7 @@ 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_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); > - } > + sdhci_auto_cmd_enable(host, cmd, &mode); > } > > if (data->flags & MMC_DATA_READ) > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > index 889e48b..8263ac6 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 >