Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp307747imm; Wed, 29 Aug 2018 00:05:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZMTpCM46LnocQMGvHUbJYGElUYQkzQ1gl4igWCabJghmh47R3HB2UaZcjV8NsmLpVI6EJl X-Received: by 2002:a62:6547:: with SMTP id z68-v6mr4661758pfb.20.1535526325913; Wed, 29 Aug 2018 00:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535526325; cv=none; d=google.com; s=arc-20160816; b=qkmb+V+TrouJ/mSE1HeTUpLw7p84r3UHZAwi54zlc0Ixab574TEseL3Mh4kPPUXd2k rul3AEqvN1+rLHx2m0R3hF+K/NCfs0dexoMUlHWaCZfkUwyr8c6kINkcddpZRaS2I7Pd 6cCWMQni0R0TIo4ZK6AUiIRL7/WnceGQrd0oLVbt/KKib6M8OPAO5MsxU/+IOZ3wddYj 3CriDc866O8rM0tY8vk4SUHtQ6VfFdygTGWgCezuDi2zK28QzAQH1HxjEJeNb5hvZ9sN zbauNqsNkEL5REevMq9BQCTM1pUM6dvg6OHAhRB8Ik4hUcikWD1K8OEZ9ViQnTCl0IK2 tmzg== 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=k2dJBM+jlgSTdSAIcOrrk2li8X/+iTU/ueEOov1kXXB/xXwEbbkZ4VAOvmDbmxHLyW cxHm4TKv53JyOeGHTGKalmCL3Pak0BRX9N67HulGcFsgBYph63COgdBQ9Ezdhz9TS4k7 cDS/rc1fW+TifP0NWRfV+WlH6eTWgilkHrpgRpOe1wpEK0RQyYLMCqfs14o/kwAM8Exc 4vJJDpWTN1yMLL6z4WG6N9KunjUDMTdfPlLr1NqgPpre1vkPeohtN5+rnaJyjMzCvoqw SVqOZXAcWYXa5tyOOiDN4cG5kRbQAaAlNgdS6//TnXPani/vpwvs6I896Q8xPyxf28tp Qn0A== 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-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 c22-v6si3155206pgk.237.2018.08.29.00.05.11; Wed, 29 Aug 2018 00:05:25 -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=XSEqzSed; 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 S1727664AbeH2K6s (ORCPT + 99 others); Wed, 29 Aug 2018 06:58:48 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40045 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbeH2K6r (ORCPT ); Wed, 29 Aug 2018 06:58:47 -0400 Received: by mail-pg1-f195.google.com with SMTP id z25-v6so1916592pgu.7 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=qvgMiQLaf5PIE3lasfvTjLuBkTHshly2g5pILs8SVrqMv4bTmUMvL8jXgg+hOrs6cY 98la1DzAKPRpbp/D2XshKo0LGS5IoR1dwQvVg9417aNkgWwKdeSgsy5od0zZ+UKO3qfm XxIr9ryUmv6ZvwtirCkYmfVtgbrkZ3ULsS78icCC0uQITOVhttJ9VF+lpwk6ZMCuIdZu s0LqHThkZNJX9TZab3KcQaumJXtpUIaARHtBocxNFO/FEphXrGvZ/0hPO39DSYa0M1Qu SRPwZros/HZdA1jgAKddZeQFp05RGGpp3L4NfpwHgaqhyzGJ5pF7ygDbXJONFmG1fb3O Rvag== X-Gm-Message-State: APzg51Csd95vRY8K/QfbKN6dcfaHKGjqDenYd/ayYUvjnradDCXW2Cjw 0L9LH+wCbcXP66T1djwZr3cN4A== 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-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 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); -- 2.7.4