From patchwork Wed Aug 29 07:02:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 145385 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp339896ljw; Wed, 29 Aug 2018 00:03:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaJqDDufvgxxZlhpfJE+MrhiET2wjfXGO5ZmmhhZQYQuCBB1kcS7LAtN+Ezd3oEfj2xVFAW X-Received: by 2002:a63:ca09:: with SMTP id n9-v6mr4491093pgi.287.1535526203918; Wed, 29 Aug 2018 00:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535526203; cv=none; d=google.com; s=arc-20160816; b=xKp07pfr9SdHGvUfj86DONHAfAlEEf5jdGMzz1S/rw3djlVOiFv2D+MPLyw0K5GfIH l1/0Q17lSNF+xEMLFgp92KCgDs0TCiV0tG3DTOoqmNMQ1Yye2mKeM6BgGaUT2mF44SGz /i6e4Y2TRdHKVy3+Dtk+S0my5REfZ/5uQfxS7Ae2stttraVxmznFK5Vo97314mfJGAp5 zQeU7TjxbpxnbRIh4FiKD/VApYZnA8Gz2ZjcpR5vI8rYq17v/8S0Dsrmf3Sq1kuM2Vp5 aiWxGslPz0XWcN6esUnLixLDSK4X1cCACcxyOofwBQ70V87YRVgUnqT+k0mYch0eGmD8 uxeg== 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=0bL6uBRbs/l+78y2aEPGUN9m7CQDwNO1TiU4HYYkWDc=; b=u8oSr7zKJsV3pCbK7ImQKtfzfIK4gZJi6umCYQr5m9NYU7UODTH7H5GneP2hMgbipp kkgL+pYFYzUt+rkwEX8naCXvDOKfbNfXl2swO6zWjrzO+gAQUHB8WcZXGgeOXVNAgx+I tlbicWpXL+q6i3ZXTUULhLmSwRbhEEKx5QK08vPaDswZjIYeIPyUYqCslESbvLnwn38c abnKkgBiMslMwG0g7nyEZLMGJCQJxQQJIvA8NtzV6t2od2PkQoUe9Ot3tBphcZi/Egf1 FSBWCzn7f9anG+2u50WckPwPAEBiQ9oa1Doe5+Dg3Yud9CabgyNwbftFD4vqXYas8oIa jGwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XSEqzSed; 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=pass (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 t89-v6si3030701pfe.59.2018.08.29.00.03.23; Wed, 29 Aug 2018 00:03:23 -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=pass header.i=@linaro.org header.s=google header.b=XSEqzSed; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727621AbeH2K6r (ORCPT + 5 others); Wed, 29 Aug 2018 06:58:47 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44730 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727542AbeH2K6r (ORCPT ); Wed, 29 Aug 2018 06:58:47 -0400 Received: by mail-pf1-f194.google.com with SMTP id k21-v6so1840819pff.11 for ; Wed, 29 Aug 2018 00:03:22 -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=0bL6uBRbs/l+78y2aEPGUN9m7CQDwNO1TiU4HYYkWDc=; b=XSEqzSedKXNLYfE5NpsZk4ZukWRCrcCS8Ptgchl3HwUEfTonVcJNiNjDWVXt4mgVqi cll3t+kMR2kfe6ca+IbbVwjBT4EsS7MDXCt1ist+6p9CSMRlnhTDJZUBiZLH1SpkM4No y0LjozQ914oQxRUvlpMEaQbvb2vkrf9mxnxlw= 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=0bL6uBRbs/l+78y2aEPGUN9m7CQDwNO1TiU4HYYkWDc=; b=Sb9kWYKwRoFsKW0Pdj0SclaIO7424dUigPQXYZi+HEh8JrQJyWsrsjjhktseKUNGHg IYwlBKrRVQB+7Egkp/Sypruxfl/o+uV4U9hY7SMiImnQVL1svz3wkBlapAKDzmld9V0q tA1kDiA7/Or4ciNZpwaEtE1bQverMkIl+/Adj3Az4LwyL35Yl+ioE/oqu2hsDimRxK6X 4o/9tJdKlslknrGQwFSjlcP1z04IYR8KF2bISDLiJQcEN9jAdBv5uUqBuPH+U84Oe2pa XYAM/C6X4EWWt3lhDdppyzw5N4X5AFBL2GEzxOXiuSkwD3+DNEgVO2QPkvoW7VT01D+X Mc/Q== X-Gm-Message-State: APzg51A6hDAjSXAXLOnDMs1mz6166QLk0SdIlBxvMwDE4n1BDmrcDjjx sClZSZtnixcMpfUmet3jGpUoqA== X-Received: by 2002:a62:174a:: with SMTP id 71-v6mr4718133pfx.217.1535526201978; Wed, 29 Aug 2018 00:03:21 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id d81-v6sm4317342pfj.122.2018.08.29.00.03.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Aug 2018 00:03:21 -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 , Chunyan Zhang , Chunyan Zhang Subject: [PATCH V7 2/9] mmc: sdhci: Add sd host v4 mode Date: Wed, 29 Aug 2018 15:02:57 +0800 Message-Id: <1535526184-32718-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535526184-32718-1-git-send-email-zhang.chunyan@linaro.org> References: <1535526184-32718-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 | 29 +++++++++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 3 +++ 2 files changed, 32 insertions(+) -- 2.7.4 Acked-by: Adrian Hunter 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);