Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2034779imm; Thu, 21 Jun 2018 06:18:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIf1eCtLWH/N2yekaUy1nKtSaseMpei8d8CmW9/aL2Fpn8YYXCd488mauDeSOaF+GlRAn71 X-Received: by 2002:a17:902:7202:: with SMTP id ba2-v6mr27976657plb.119.1529587083876; Thu, 21 Jun 2018 06:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529587083; cv=none; d=google.com; s=arc-20160816; b=1CaT69gxB5majQkWb7138mW7MNY5HvvmU2G4ToAoHKtwuGajD+Jp1fMBUWDE2JSSpv TFuXeVea9IQgcHBbtRWLlkWSvVpurCAbFM84KPXjG5qcfF4lLa4KGZ0RmRdaMsPxFaz8 trpSms7MibtdAHWHQPiq66uCcUxXIKlr9sy2r6RHPvGMBn545lhOyn5DdSnawmnoyMws 0SZFXZ9JSQf9sm2fK0mA68JRUt3Vu1ttvNjsWGKJ24CpaPqgGsmSMu7m+5xlnR/80GmX CFG9WvuqMNYDiQA/4DY8K+KizIk/mrJYWM6S3hMncFgMT3pvKWLQR0kzXq3E25WSc1xT 1M6w== 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=KMBtwWD3CAJO0Sj1F8mHEcFPynZjYdb+Pm8ZGxVmIn0=; b=ANIrREn8yRYXPMFn/T3DJvb6MdYinAmL9oPRf2taUs9o0f64y8+RPt9jDw1Kyuaic7 K/9raBiPijZ/Sv+CewCXTsuFJ28YormL5HO0BvGbDr18A2iCIscPFvTzOp/X6xHr2VcI jDrbxKg9+/N/l+0REF1CuIneIc++wB5bzKuy+G8IUpXcssaoe7D76Oit0bBH65HwByih 8h+xw8i0J53NgXj7oYY1MsjyCikmO+xv8/11SC5yNSX9rQpMoGPrD/CJNtwiihYIOgFP QvP7OSq/iQt2Ln4GddSe0U/ZspmGGjasIwsiATU2UmrYE1VOMb7ZRqc1WKpdW1mn4k0E fRxg== 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 o10-v6si4072074pgq.545.2018.06.21.06.17.49; Thu, 21 Jun 2018 06:18:03 -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 S933186AbeFUNQz (ORCPT + 99 others); Thu, 21 Jun 2018 09:16:55 -0400 Received: from mga06.intel.com ([134.134.136.31]:17671 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753948AbeFUNQx (ORCPT ); Thu, 21 Jun 2018 09:16:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 06:16:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,252,1526367600"; d="scan'208";a="51128684" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by orsmga008.jf.intel.com with ESMTP; 21 Jun 2018 06:16:40 -0700 Subject: Re: [PATCH V2 1/7] mmc: sdhci: add sd host v4 mode To: Chunyan Zhang Cc: Chunyan Zhang , Ulf Hansson , linux-mmc@vger.kernel.org, Linux Kernel Mailing List , Orson Zhai , Baolin Wang , Billows Wu References: <1529028255-6022-1-git-send-email-zhang.chunyan@linaro.org> <1529028255-6022-2-git-send-email-zhang.chunyan@linaro.org> <1f3e7e87-be4e-37ab-af46-1c4e5dd79a1d@intel.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <38c47bf5-d320-7767-59c1-958d1bbb6dc9@intel.com> Date: Thu, 21 Jun 2018 16:15:16 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: 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 21/06/18 14:14, Chunyan Zhang wrote: > On 21 June 2018 at 18:49, Adrian Hunter wrote: >> On 15/06/18 05:04, 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 introduces a flag to record this. >>> >>> Signed-off-by: Chunyan Zhang >>> --- >>> drivers/mmc/host/sdhci.c | 6 ++++++ >>> drivers/mmc/host/sdhci.h | 6 ++++++ >>> 2 files changed, 12 insertions(+) >>> >>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c >>> index 2ededa7f..cf5695f 100644 >>> --- a/drivers/mmc/host/sdhci.c >>> +++ b/drivers/mmc/host/sdhci.c >>> @@ -3302,6 +3302,12 @@ void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps, u32 *caps1) >>> v = ver ? *ver : sdhci_readw(host, SDHCI_HOST_VERSION); >>> host->version = (v & SDHCI_SPEC_VER_MASK) >> SDHCI_SPEC_VER_SHIFT; >>> >>> + if (host->version >= SDHCI_SPEC_400) { >>> + if (sdhci_readw(host, SDHCI_HOST_CONTROL2) & >>> + SDHCI_CTRL_V4_MODE) >>> + host->v4_mode = true; >>> + } >> >> At this point the host controller has just been reset which would mean it >> must be in version 3 compatibility mode, which would mean this code doesn't >> do anything. > > Why is it version 3 mode at this point? According to the specification, reset clears RW fields to zero. > > I've tested this code on the sd host controller which was introduced > in 6/7 in this patch-set, the result showed that it was v4_mode. > Moreover without this patch, the Spreadtrum's sdhci driver in patch > 6/7 couldn't work. > > Am I missing something here? It seems the Spreadtrum controller doesn't clear the "Host Version 4 Enable" bit upon software reset for all. Also this seems the wrong way around. The driver should decide whether or not to use V4 mode and then the "Host Version 4 Enable" bit should be set accordingly. V4 has been around so long that we can't just enable all supporting hardware without risking the possibility it will break some platform. So I suggest adding a function sdhci_enable_v4_mode() which is called during probe. > > Best, > Chunyan > >> >>> + >>> if (host->quirks & SDHCI_QUIRK_MISSING_CAPS) >>> return; >>> >>> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h >>> index c95b0a4..128b0ba 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 >>> @@ -270,6 +271,8 @@ >>> #define SDHCI_SPEC_100 0 >>> #define SDHCI_SPEC_200 1 >>> #define SDHCI_SPEC_300 2 >>> +#define SDHCI_SPEC_400 3 >>> +#define SDHCI_SPEC_410 4 >>> >>> /* >>> * End of controller registers. >>> @@ -551,6 +554,9 @@ struct sdhci_host { >>> u32 sdma_boundary; >>> >>> unsigned long private[0] ____cacheline_aligned; >>> + >>> + /* Host Version 4 Enable */ >>> + bool v4_mode; >>> }; >>> >>> struct sdhci_ops { >>> >> >