From patchwork Thu Aug 16 07:54:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 144327 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1760312ljj; Thu, 16 Aug 2018 00:55:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzk1WfcoWB5h6W95EnnNZY/P8e1aVChcsJwhHdjaxpdD1xF1DFef2KZtg3P+oLPoZbgUoZp X-Received: by 2002:a62:c699:: with SMTP id x25-v6mr31652487pfk.16.1534406128365; Thu, 16 Aug 2018 00:55:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534406128; cv=none; d=google.com; s=arc-20160816; b=JwqgZcuXRfaZcqNMgXGI240sGozJvI2UgtvwCRsfYmSQM7gpdvQ3jyKk8G0/5/SDHA ImyFL2fK9lR1xyl3/4udyqUe7N11Mdy7XeFBe7U+Qej+54dyPD+mR3sBTYOfKdAf5Z0m C6UAA43G1K4II5m5rj7N6uQDOz7qb2IVuakRrRjWb0mRt/ADGFXlIpohMRsMLnY0mV6Z ds5euVEJiK6VlW2iz7g8T1EOiTrd8+emzoaBpKaYn/vSs6YPBJyV7mOkHOORw/Fo1O0B GreWCDa91KYEhAXt+IT3Jzyq9oGbsgyE2P9m7nIX6qfODD7CMTbxdmKQXM50PNTgf+tC LOUQ== 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=CZLYHe2aS2EOh7yF1wNBWbzjQI2Ar/6k3aG59wWMze+RFb4c2VIAXVzH2zzsShdXXj 5k+0nPwLiRglXsQBEA4MXqjj6UftHw4UArEvLe0sc27TK3nROdGovSGu/h3vY0Z2DFYx T0PQe98yuH69D3ZpBdhZuoHmUxqEAPVKW2ySCIx1u7QZws7z/rwGgjgweUCWtgER75OJ 7FGbxJt/nWiRumHk27sSf0k+ihw1vZuDCaxwz6Rd7TZZ+lS2nIaMSMJzpk8/HtDcENu6 iX8mvEg4P0W8oYTTD3KMUuMvDE05FZY2SSrbgfHWNsGfWqJ/Zf3IN2Sf6puLIOUncIZk caUQ== 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-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 b34-v6si21154297plc.170.2018.08.16.00.55.28; Thu, 16 Aug 2018 00:55:28 -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=Dp1aCAmZ; 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 S2389565AbeHPKwH (ORCPT + 5 others); Thu, 16 Aug 2018 06:52:07 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41199 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389543AbeHPKwH (ORCPT ); Thu, 16 Aug 2018 06:52:07 -0400 Received: by mail-pf1-f195.google.com with SMTP id y10-v6so1647426pfn.8 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=IOTuOFue7UUoq9DUSOxljVin0tvoyFVhc6McDbSBeqHmG4WytQJCDPjERVhNXKV9sx SETSGeng4zBkp54jHXX9ej7BoAL++nSo4hiU3rEvDzyxl55a6EfTRQAT6CU1MIf/ZF7w 8+Bk0kNNUtgJBmpHnG3z7f7QbhlnJTlUoy6qcetqC6kGA/7AU1Et3Fx1cIEuYynb5XUU WOMv+qawrt5P3XZzzu6br5GatyLEYhm9FgOI7CuaHB2eQddm6QUTXTybI8hykTTom6kG cFhL9n55bpZJIAHr1apN2BB1jK2iousgr2VX2F2y4udA4a/vYS+dsNUKTxiJyPjKEcVF ORFQ== X-Gm-Message-State: AOUpUlFbgF/WbkjolgA7hFPdH9GDmr2wO9BpYH18Jj2bSpd1zkWxR5aH zzBATgEeh/PSrGtXFC2nEU7u0g== 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-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 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 */