From patchwork Mon Jul 23 10:08:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 142558 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5862389ljj; Mon, 23 Jul 2018 03:09:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfjqjg/tufih8iFpUxbsHSagfa49e8aDeRhw03OA6PVnoAARaOzQJWTlMBWK2BMIlNDrR6u X-Received: by 2002:a17:902:7688:: with SMTP id m8-v6mr12230056pll.338.1532340556419; Mon, 23 Jul 2018 03:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532340556; cv=none; d=google.com; s=arc-20160816; b=pkl1+95Q0J7gO4TiumAtb6aepiG4/GbW/HvUMI8Ecx3Bwjh8VRZO9Tfa0eu/Qu6Qyq I9dUh9/j1XBOGYVxqYYHzccqVS89ge36wyqc6oQcnfsDAOLDUPb0Gi/mCNbgfAe0mp+U yttYz5JSXhLLlFuEZnYzOH0NlUanXr49ba5m4UkJ3WK1WO2eu1/el6Ul7qjKmO/idaNi wJE2prtooEMaTZQepnPHmJH3pTR3AhSe0je4bwy0ld3PKp4dOl8tl34P8iFXYoT7DV28 rvWBJfDcNS4kMr0y41Dy1GomVveuC2KF2rn+au5SEzMzckvOthUC469tejy/nCaRHZZl aatw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=pXtHcthF1Aq4t5hDmvnE87mFop3sUmCPDU1eY3bcuq4=; b=kN7fvFT4Te25TzD7rFtp6ED6LKpT6tfRDULo2c3nEOvI431JuC9CeJw3XUhskeBO1X d0dttZ66rHQVS4LzP5cEdYjfpftT8mn1U4mku8Ak2TI8DO6wliYewtEk3PFq7HELCGL9 ZN4c2cy7zByS4eNBLTGznl9niZObli+8XRuv2d5MYQW/j658MR5abCCjatEsMot8sHYM g4thr1IyMWRUydQmEG7TbXEAx1W/seOvbLb8nn6h62OaGIzQEzWanzyKQSzobaK5MKDF APxzmG3+yy/OUygrPfZTh84R2HjwYE+3JOzj2sQL+O0lrwH5pehsFVDSaXM11tOpbvRZ 9SkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GzGfZSyD; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2-v6si8310691pgh.565.2018.07.23.03.09.16; Mon, 23 Jul 2018 03:09:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GzGfZSyD; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388137AbeGWLJl (ORCPT + 5 others); Mon, 23 Jul 2018 07:09:41 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:33364 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388263AbeGWLJk (ORCPT ); Mon, 23 Jul 2018 07:09:40 -0400 Received: by mail-pl0-f68.google.com with SMTP id 6-v6so35275plb.0 for ; Mon, 23 Jul 2018 03:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M7vCwreaGTb+OgwtgSaE5FF7B3FBPIGjJoxy7kBg1p8=; b=GzGfZSyDMO7pnTpQYplG/G3gF4dCd7uTJK/VLknFdGTrdXP+mJpzqfCpRHgonVzvQh lJTAxiO2nVHdbSB6RZZLwlbkINaaeP/FgS0xue+QX2mnBpQ2mEaGAh7b+LQ2GHy0JAuF DVRCCAohrNKYpT5+7fAi0GNaJGyne2QbJmul8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=M7vCwreaGTb+OgwtgSaE5FF7B3FBPIGjJoxy7kBg1p8=; b=p4yURTurRqAPl919iauBlqwS5o5qQzZJM/NzAdDYGxv8Ik5e0oA4MauplLpF7zQ5ah YKMkDU9SX5dh+BKhFQs4G3dFmN+GvQuJYfFbckPMTdmQTKvOt/Y+mC6/D7ABqa8Ou8tN cc1RG1Ir/gyDB2Fdq8irblx3EZQCPm5MAvnGAYOaGkMDhpRUa3m6KUejyBeWLMqU0XIT 4nAL4AxYupxEcq4ANZHBnI2S1AAaLWXlIlrqQ2+1elJIzdTcjrKgG0OHSCRga+YbXU8W VcGBHzAqm9ra+6GtKwu3QZbsTxbXEDQIrlAOB7ynL9yo4kZIYK81hgNM1x9dQtqFuRGl 4uLg== X-Gm-Message-State: AOUpUlEjGPo83aDBiSvSly74Lem0DYfm9V+eV43p5XyNjDXAdTBBhLBe v6sYi9GYrugTzqBxVBC9mPs7GQ== X-Received: by 2002:a17:902:900b:: with SMTP id a11-v6mr12347410plp.143.1532340554034; Mon, 23 Jul 2018 03:09:14 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id e82-v6sm13470698pfk.87.2018.07.23.03.09.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jul 2018 03:09:13 -0700 (PDT) From: Chunyan Zhang To: Ulf Hansson , Adrian Hunter Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Baolin Wang , Billows Wu , Jason Wu , zhang.lyra@gmail.com Subject: [PATCH V4 1/7] mmc: sdhci: add sd host v4 mode Date: Mon, 23 Jul 2018 18:08:22 +0800 Message-Id: <1532340508-8749-2-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532340508-8749-1-git-send-email-zhang.chunyan@linaro.org> References: <1532340508-8749-1-git-send-email-zhang.chunyan@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); + } } 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; + 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 */