Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp434001imm; Wed, 29 Aug 2018 03:49:46 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY7Pq+M5EYOmpUMtee+z4VR0KuocK+yrqOfOibFVCTkWRrB4iZzgfMQEh8ubpxE8bef1bxV X-Received: by 2002:a17:902:bf43:: with SMTP id u3-v6mr5452606pls.88.1535539786042; Wed, 29 Aug 2018 03:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535539786; cv=none; d=google.com; s=arc-20160816; b=weu18p1osWJT2SBXqh5iHhTNS0iSY18u8FQThGSDfmK08DsAeNrbt30Kj/A/JDSOtU Om5SwsMMbbHjYoy0wac8T/SMQqa0oSnNYCAaX8WpW9xZLCuYPQMBy4orUJDFfY1btEEI 9jAACN+WyxebiFuspt/2pLMEzVQIduLvL323XfuONUJmFw/7YekUYZszC5IZcxWM/pYF HRtV41EI9+dgsWfTwPkvVDqA/1s7BOc9fAcL+M48Pkuj0nhfclthIdVhrhald6y5wGz6 TBvYlx4Eng/IDjRDKr/PT35r3xRwOHZgVWtu0s2XPPMe2yQGlZNKQEqRnFX7fhnl9iZu ytNA== 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=1RksLKHLAM/8INzfNrndzmMsnWnVJXHG46vyPdx9Vug=; b=OvIPrYeFNIWmYpGbrsBTLBmHqxgjk1rBPtjEkxImmi+2MIBrwP61R4TWY7d2UUh7pA qFqyav3DA6wCPopdBexOupEIDNGquWuO+Qdayv8JZ9W5DynkSNnhjh2RQHM3XnDcSSXG L1BtWO+7VNCrfxgo2ZBArD/+PSPrUzLSTgn6BnnE2049godgknMcRj4NeuYwxv9GL009 l2X0D9ADOWp2KKN1fPSsdydweg/8yznAeyEAbS0bD3fj4VVrkpsczr3Uu7Ox3/bYcM2i kX7nyjq3w83wjaenMO4CQQsVDsmS9IErb3OipmfDj4U7Aqh7vJxawhf16HJN0YiMAE3j BDkA== 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 d7-v6si3325290pll.162.2018.08.29.03.49.31; Wed, 29 Aug 2018 03:49:46 -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 S1728268AbeH2Onk (ORCPT + 99 others); Wed, 29 Aug 2018 10:43:40 -0400 Received: from mga12.intel.com ([192.55.52.136]:22379 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbeH2Onj (ORCPT ); Wed, 29 Aug 2018 10:43:39 -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 fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2018 03:47:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,301,1531810800"; d="scan'208";a="66029304" 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:45:54 -0700 Subject: Re: [PATCH V7 2/9] mmc: sdhci: Add sd host v4 mode 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-3-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: <9e5ea176-1d13-3ac6-ad09-3b748a398f17@intel.com> Date: Wed, 29 Aug 2018 13:44:13 +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-3-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:02, Chunyan Zhang wrote: > For SD host controller version 4.00 or later ones, there're two > modes of implementation - Version 3.00 compatible mode or > Version 4 mode. This patch introduced an interface to enable > v4 mode. > > Signed-off-by: Chunyan Zhang Acked-by: Adrian Hunter > --- > drivers/mmc/host/sdhci.c | 29 +++++++++++++++++++++++++++++ > drivers/mmc/host/sdhci.h | 3 +++ > 2 files changed, 32 insertions(+) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index 01bf88c..0c61105 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -123,6 +123,29 @@ EXPORT_SYMBOL_GPL(sdhci_dumpregs); > * * > \*****************************************************************************/ > > +static void sdhci_do_enable_v4_mode(struct sdhci_host *host) > +{ > + u16 ctrl2; > + > + ctrl2 = sdhci_readb(host, SDHCI_HOST_CONTROL2); > + if (ctrl2 & SDHCI_CTRL_V4_MODE) > + return; > + > + ctrl2 |= SDHCI_CTRL_V4_MODE; > + sdhci_writeb(host, ctrl2, SDHCI_HOST_CONTROL); > +} > + > +/* > + * This can be called before sdhci_add_host() by Vendor's host controller > + * driver to enable v4 mode if supported. > + */ > +void sdhci_enable_v4_mode(struct sdhci_host *host) > +{ > + host->v4_mode = true; > + sdhci_do_enable_v4_mode(host); > +} > +EXPORT_SYMBOL_GPL(sdhci_enable_v4_mode); > + > static inline bool sdhci_data_line_cmd(struct mmc_command *cmd) > { > return cmd->data || cmd->flags & MMC_RSP_BUSY; > @@ -252,6 +275,9 @@ static void sdhci_init(struct sdhci_host *host, int soft) > else > sdhci_do_reset(host, SDHCI_RESET_ALL); > > + if (host->v4_mode) > + sdhci_do_enable_v4_mode(host); > + > sdhci_set_default_irqs(host); > > host->cqe_on = false; > @@ -3378,6 +3404,9 @@ void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps, u32 *caps1) > > sdhci_do_reset(host, SDHCI_RESET_ALL); > > + if (host->v4_mode) > + sdhci_do_enable_v4_mode(host); > + > of_property_read_u64(mmc_dev(host->mmc)->of_node, > "sdhci-caps-mask", &dt_caps_mask); > of_property_read_u64(mmc_dev(host->mmc)->of_node, > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > index dbd48a8..61611e3 100644 > --- a/drivers/mmc/host/sdhci.h > +++ b/drivers/mmc/host/sdhci.h > @@ -184,6 +184,7 @@ > #define SDHCI_CTRL_DRV_TYPE_D 0x0030 > #define SDHCI_CTRL_EXEC_TUNING 0x0040 > #define SDHCI_CTRL_TUNED_CLK 0x0080 > +#define SDHCI_CTRL_V4_MODE 0x1000 > #define SDHCI_CTRL_PRESET_VAL_ENABLE 0x8000 > > #define SDHCI_CAPABILITIES 0x40 > @@ -504,6 +505,7 @@ struct sdhci_host { > bool preset_enabled; /* Preset is enabled */ > bool pending_reset; /* Cmd/data reset is pending */ > bool irq_wake_enabled; /* IRQ wakeup is enabled */ > + bool v4_mode; /* Host Version 4 Enable */ > > struct mmc_request *mrqs_done[SDHCI_MAX_MRQS]; /* Requests done */ > struct mmc_command *cmd; /* Current command */ > @@ -752,6 +754,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error, > int *data_error); > > void sdhci_dumpregs(struct sdhci_host *host); > +void sdhci_enable_v4_mode(struct sdhci_host *host); > > void sdhci_start_tuning(struct sdhci_host *host); > void sdhci_end_tuning(struct sdhci_host *host); >