Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3935552imm; Mon, 30 Jul 2018 06:07:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfVD/IoLgvkh2nNsHSXVe8a/+YAX278whcQ62n+lN/pFLtaR04VMfQwcuNHxejs6Qyhjzff X-Received: by 2002:a17:902:543:: with SMTP id 61-v6mr16512192plf.126.1532956026713; Mon, 30 Jul 2018 06:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532956026; cv=none; d=google.com; s=arc-20160816; b=Ls//BDisJWbFIbmSlLcDNEHZqW8JRPooKgs3TI7N7qxpUZ0Ig3Of8yHlsvr3EkmrRE 9XeF6Ogmbm+n3xJPagNLzE+b4t1Wo3xnuxTHuHhh6IDcBqF8LInnZYEZ4TjrLP5OoNjw aJd6TKKIsqnAAp5TLF5S54GJOTT4AiayiixGv8usZ+9HxFL7KwCj8dE0ONcgu6yozB9l vwfcFU6VAZHz5UOzmKPftFvY8aKZA/yr/tJZ2yui6v1JhLeTNwtEmmkzBppe3PZwWbZC /QEv5bXuX9Mrk89dzEIymWV2BL/xRy+vaMSNL578Xm9F/WHRBZjfLAKfrTL+2Xhrteh9 XiSA== 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=TKAKHzp61IlB0v8/BEaHUDZtfFBI1sGcteU0FesU40A=; b=onodJaSMp6CVwBYc6p+363eGmSbZ1UuPxv6IWgCadEtuEqU9mtyTw6t2KUqJ9IV1QH NYG5+rlAw0Peq5GIMyRRqhz5wNN0zK+bILvqk/lv9Mk+MrZh39VaEt4a3D5nWUiVk252 nRg0P3xYY8OSoTtoswDsXIJ4Ixp16PlOIxfR3EGgS4NyBPKBLJ86NWDS4rBQ+/7iOH5j rZiWUKfVTmXDhpWEpxyQzPNHEZr2xkGI7BLsLRkywU5l1hM5QfYMWk/xPikCUQJOjl7q eNwvdNEDDQWlcWPEM2MWwRGtqgSdSB53Tht1rRafKQJAwJ6/WTVbtiHPLMlEhNXWjcqj BoBg== 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 k6-v6si9850819pla.473.2018.07.30.06.06.51; Mon, 30 Jul 2018 06:07:06 -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 S1726775AbeG3Ok4 (ORCPT + 99 others); Mon, 30 Jul 2018 10:40:56 -0400 Received: from mga18.intel.com ([134.134.136.126]:46034 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726649AbeG3Ok4 (ORCPT ); Mon, 30 Jul 2018 10:40:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2018 06:06:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,422,1526367600"; d="scan'208";a="71684175" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by fmsmga002.fm.intel.com with ESMTP; 30 Jul 2018 06:05:58 -0700 Subject: Re: [PATCH V4 1/7] 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 , zhang.lyra@gmail.com References: <1532340508-8749-1-git-send-email-zhang.chunyan@linaro.org> <1532340508-8749-2-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: <87ecfb68-775a-2a17-5b42-ae02b354e3d7@intel.com> Date: Mon, 30 Jul 2018 16:04:17 +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: <1532340508-8749-2-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 23/07/18 13:08, 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 > --- > drivers/mmc/host/sdhci.c | 28 ++++++++++++++++++++++++++++ > drivers/mmc/host/sdhci.h | 5 +++++ > 2 files changed, 33 insertions(+) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index 1c828e0..cab5350 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -123,6 +123,30 @@ 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); > +} > + > +/* > + * Vendor's Host Controller which supports v4 mode can call > + * this function to enable v4 mode before calling > + * __sdhci_add_host(). > + */ > +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; > @@ -224,6 +248,10 @@ static void sdhci_do_reset(struct sdhci_host *host, u8 mask) > > /* Resetting the controller clears many */ > host->preset_enabled = false; > + > + if (host->v4_mode) > + sdhci_do_enable_v4_mode(host); Instead of sdhci_do_reset() I would rather add this to sdhci_init() and __sdhci_read_caps() > + > } > } > > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h > index 23966f8..519d939 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 > @@ -565,6 +566,9 @@ struct sdhci_host { > > u64 data_timeout; > > + /* Host Version 4 Enable */ > + bool v4_mode; Let's put this with the other bools i.e. after bool irq_wake_enabled; > + > unsigned long private[0] ____cacheline_aligned; > }; > > @@ -747,5 +751,6 @@ 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); > > #endif /* __SDHCI_HW_H */ >