Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2226131imm; Thu, 16 Aug 2018 07:01:40 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyk1ZChHUVSGQy/p4l01TFpwNWNMjRfKr4GW405dgvDETR6AIQelsQes88a2TyMJYbd3qVi X-Received: by 2002:a62:5613:: with SMTP id k19-v6mr32442511pfb.212.1534428100668; Thu, 16 Aug 2018 07:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534428100; cv=none; d=google.com; s=arc-20160816; b=pB0nhacqBDmfgLdRzq/7cTHCILkR/kOtAXzPOkzgdpKZRblKTZrGXxEhOgfFRf0VVL 3hqUuKfSyPQMAqLRDoqtgK8XT86AXgx38/Npq1ss7r85KDLVokpaJt7d8gcQxrrrQlsR iG6NqnCBKWgONZ9RgWrINXT6Rh1FYYtGEQgNiVYQfmVMZlS/rQ7g19kyUNG1UO8qlvXW PT3j+jcSD6RsGp9cgC/YuLL4qlB7py6KuXrNMwWE0cLUypjzs5yN0kK7H9fPzXfwCwLG bZz/jrWx1I4dSZlUsV3pZ5dD8sKyOSd7k2QAPmEHFP6/chvL1sYSptD8U7dU50LZL78Z 5BVQ== 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=gWRkaXKJ7LnuvmIuqtMHfNjquIfkm3r7MkZBwNfZ4Eo=; b=p/wT1bhUXkExqDFfYdiwKLJMvV7cTHcBONqvnCoN6dUHJrnC+j43eMLSOBoZ0Hurpj gJBXFz3//iNpjrEhvWy0XfLrc4q8KXv0RPMK9tkDIUKYBiciLIITkY4XRMFPKeCEtMCf qEQbB1M7E/+D2X/orN2bpBvymX4Ohr1KWXX/VqqjZdxix4pG//AcmRGp+hhrME+bbm/Y 9kTENks9kktlC0wc4lCeNDoh0dYL2aK9AF4JQmghS+BIj99Jj7W4gQdNF8feRwvHg4fS Bo7TTgyWVaw5LVBXQDeX0k4Zte9+UZDQUDDgDiQ+Ny5IJvkO8csmJ5Ttd5TipPwMsIip m6sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dp1aCAmZ; 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=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 l7-v6si25783053pgm.677.2018.08.16.07.01.08; Thu, 16 Aug 2018 07:01:40 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Dp1aCAmZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389576AbeHPKwI (ORCPT + 99 others); Thu, 16 Aug 2018 06:52:08 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36299 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389564AbeHPKwH (ORCPT ); Thu, 16 Aug 2018 06:52:07 -0400 Received: by mail-pg1-f193.google.com with SMTP id h12-v6so1693330pgs.3 for ; Thu, 16 Aug 2018 00:55:26 -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=gWRkaXKJ7LnuvmIuqtMHfNjquIfkm3r7MkZBwNfZ4Eo=; b=Dp1aCAmZk2tDAJO6azlL9KmSn+SkRgrTxgYkDy8Z6Ba6V3AZdLgT8kzpdo6yiR59PK mGSyRkjPTeu7fbXESpC5b3sJFqSQUBkOE4TkpuoKbljZzgafdEqlTUKP/wC1YLvtZJPP 2nIFcVpdkLj0LqF+Z0RZPI76QEEtO0mo4o2y0= 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=gWRkaXKJ7LnuvmIuqtMHfNjquIfkm3r7MkZBwNfZ4Eo=; b=DaIVv/BB6hacFngo5Wbv9fV5kMsUVKPvuXj+H2Jmdg17dlJ4zHvthDhtmFeMg8+lZm ygnEFLBP0jQmbvM9Jrcf6sOZUbxNE5P5UheMKtMuYKMkMEFb+vqtN8l0Bvf8T06kdA0h AMNtixIg1bSP2zjJoyvBlZCjLw6HlrC60XBu5whQ7e+jfnWt3h98jGdo7grVHYDfSa1U gZ+47rr7BuigvIU1fmBabxfuSipy8Btc5JIaMqKPlgdNlJr8x+oyjdmgyKKtMlzPh9jW iDfMCve8rQFyoJlwqy9OuPOV4C3AM66Vrh9xvYBrrYi8x5+Xixr2QKfsghbdLNEUSL6J NI8Q== X-Gm-Message-State: AOUpUlGvQpLP9z8Pk5HyFFNraFCO82zyUwjy/r+CRC/Tl8YURSyY3bpo N5fJNhPVHf4dafuVWBzwLAfekA== X-Received: by 2002:a63:2506:: with SMTP id l6-v6mr27713658pgl.237.1534406126103; Thu, 16 Aug 2018 00:55:26 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id i25-v6sm50838137pfi.150.2018.08.16.00.55.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Aug 2018 00:55:25 -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 Subject: [PATCH V5 02/10] mmc: sdhci: Add sd host v4 mode Date: Thu, 16 Aug 2018 15:54:16 +0800 Message-Id: <1534406064-10065-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534406064-10065-1-git-send-email-zhang.chunyan@linaro.org> References: <1534406064-10065-1-git-send-email-zhang.chunyan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ca04834..d808a1f 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; @@ -3370,6 +3396,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 31c865e..5042c23 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 */ @@ -750,5 +752,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 */ -- 2.7.4