From patchwork Thu Aug 16 07:54:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 144326 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1760249ljj; Thu, 16 Aug 2018 00:55:23 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxujJBcTfTwtZq+llA+2wcCT7UKBi9nssAaOcRcaMODXO2ICAH8zvSdiWgX9QAbUYCmemFc X-Received: by 2002:a63:1c5f:: with SMTP id c31-v6mr28447759pgm.321.1534406123615; Thu, 16 Aug 2018 00:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534406123; cv=none; d=google.com; s=arc-20160816; b=VCGIUmlgtwNPtUzqs5aebJj2vJcM/HneTnnUH/tmAil1crpq4ggypXOitdR7JiyJcg VWwVMFgww3q93I3sg+2dJW/FEvrzYOondRZU95jfLaCPCzhSH3g7Lqmlt9OwwvY2zo5i RW272t4W3BlqDh9ZQQ4f4o3Yx+6tV5j7Fco741vtYRK9XrpBrW8YFxYT/dmVPGZiB7k1 rHbtFHVwiZ0KnMoYKfEphm6g5SM/SD6H2nYS3VMp7V/dSYz5/95wj9TJgLU9DsALL2TS GV23mjcZgejPl64ZKvtO0QenO8q1W2irzDbhiAcswC37qp/3mG7K8J2yQy11maAAYCn5 2OZw== 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=GsEzQ7lSqbmfxpWd258e2/q3aWNtngoojSJwB6WE4qw=; b=m5sGmsL1c02BuyAU944hFXAgswu3n788rVvWW0mjQ7qV7YprGQz340xeeXAV5KSehX VJGrIMJsMtFbhertHg6MUaEVwAJLE+V/kd2YfJPJNBQGf9u4Aag8r74zHp9WyjAFNWlt ZprdsWgKnjjBNSvR1ejIbop0oesCZriem+RBKN/jr+D+wuV4uv/vvltpxUc6lFm+2FoD Q6nk1Tt6yAj99BviGJ3PSPwv9fGcXIYTwix6HXdNN7QQA9IPaqz866EQpMk5fAUOKzdr zJbDaRzz2mCrwLFb3ytBZYZq9GbubKk5dwTAYSHlJHI5c1OqgO0A2jGVzNr8FMOXC24K odTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eujLU0C4; 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 t135-v6si29155358pfc.139.2018.08.16.00.55.23; Thu, 16 Aug 2018 00:55: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=eujLU0C4; 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 S1726987AbeHPKwD (ORCPT + 5 others); Thu, 16 Aug 2018 06:52:03 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46138 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389542AbeHPKwD (ORCPT ); Thu, 16 Aug 2018 06:52:03 -0400 Received: by mail-pg1-f194.google.com with SMTP id f14-v6so1668584pgv.13 for ; Thu, 16 Aug 2018 00:55: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=GsEzQ7lSqbmfxpWd258e2/q3aWNtngoojSJwB6WE4qw=; b=eujLU0C4+JUe/hyhRoQ5nTiOaYS1e29W4GzEUIREvLlyapwKrqbuSiIogff2g1m2zx TUeuQ3gz9UPGej9JO3AUWvbMmeE8kr+9ZHODhh8M2gkgaV3H39aDOCtRv6H+6dni01wX o92F0bEtJ/O0376BjbiEGphmyPsohCiedh0ug= 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=GsEzQ7lSqbmfxpWd258e2/q3aWNtngoojSJwB6WE4qw=; b=o4iSBrOiZj2PZqWkUlkEdU5fNVyozHeK331UXAYHaEY+Cs+rzN3hbgQC8pi6Hg5BI5 y4iB887RyZQVmWNw5kZeghO3XWPTjonw5EG67SWEcAktXJQEoPTI/3VLzwL3fBhJ5nl/ 2EhC6SStgHLfKA1XlZGLxv/2fPHNlEX8qLeThlEhWJN8fBK0/jTp+Y7obySwRh6gqVzT 8QeD9/+mAF9ALIPvPT/3fsStVuIyyrO5FHu6/V+iMmG1tsfUsDoIMvsOyYWazmVKwgxB dTlwLdTGBfyruScGGNoQiWFuAE+dmOMV+n1rqUEKo3vbDP0nnh/1upltXucTfHuFYebc 4z0A== X-Gm-Message-State: AOUpUlE0Fcnx+OQXYqiBKk6vxCj+x6kCN7kAE2s28PPxQEMNpqA81ali uWGeJ14STN52rVL8rQcYzTmSLw== X-Received: by 2002:a62:c0c4:: with SMTP id g65-v6mr30849687pfk.72.1534406122151; Thu, 16 Aug 2018 00:55:22 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Aug 2018 00:55: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 Subject: [PATCH V5 01/10] mmc: sdhci: Add version V4 definition Date: Thu, 16 Aug 2018 15:54:15 +0800 Message-Id: <1534406064-10065-2-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 Added definitions for v400, v410, v420. Signed-off-by: Chunyan Zhang --- drivers/mmc/host/sdhci.c | 2 +- drivers/mmc/host/sdhci.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 1c828e0..ca04834 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3500,7 +3500,7 @@ int sdhci_setup_host(struct sdhci_host *host) override_timeout_clk = host->timeout_clk; - if (host->version > SDHCI_SPEC_300) { + if (host->version > SDHCI_SPEC_420) { pr_err("%s: Unknown controller version (%d). You may experience problems.\n", mmc_hostname(mmc), host->version); } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 23966f8..31c865e 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -270,6 +270,9 @@ #define SDHCI_SPEC_100 0 #define SDHCI_SPEC_200 1 #define SDHCI_SPEC_300 2 +#define SDHCI_SPEC_400 3 +#define SDHCI_SPEC_410 4 +#define SDHCI_SPEC_420 5 /* * End of controller registers. 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 */ From patchwork Thu Aug 16 07:54:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 144328 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1760362ljj; Thu, 16 Aug 2018 00:55:31 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyPrA9sj/xyBCHzJKRqRUnIcm/zNyJahw91gdfSOYS+/UenDLYnHWsTz5mDO3/aZ/vzDs9k X-Received: by 2002:a63:1810:: with SMTP id y16-v6mr10389644pgl.48.1534406131862; Thu, 16 Aug 2018 00:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534406131; cv=none; d=google.com; s=arc-20160816; b=cToTfY09+CpPrJTsmBZbrvmql76ZW6WrCnlnXSB5/28OwnEfjcf0CdGTwD3gkUHCul bw5W8qjFStTrBWdsB9Z3B08QrHmZbXl6D0ezMOQeENFgl/huQ5YzxFD33XkrJA9oJtq/ 70fgnXCQUnHw7beU/K9nSXww1l0nidcXGYEn3mJ94/H2dkVLoIlFKgTh+HxCddpLbxMK xk6NkXMHMES9mUQXXgd+mu4oXqcnUK0A/uzHby2jhRzsJW77vOL7ROV0ZAHcAC9o0S++ rW0D/vxUGr39ih3YRYEJ1ZLpczztkZGAXAL1J/+OGerwo/2Z2RTqyC2arkoyvWROf/T8 KGHg== 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=oQ908iqEE1J6YcVEb5PbZH8Isswa4HYhkkDHD7JZWDk=; b=qv6PYOOjUK3F7VwnbpmtARJZyUjf5ZryYjMesr5hpp0+ZjeOMOc+cyKWyFfRknYCSp giQ9gYGnXfRfivj7YQTYTkm/dCo8/XcTJpruV8CAxOvoOPHaqQj7SWpmpy02j7COdXcX 7mXDK2nbYUqbbSk+DAeHjyTXwY9mWZj7SIbCaZ/+bqW5X8XNyh50Dvok8cK5G2S3UPQW FwTGdTptM6UvaLkTw6FK3Icis1si/HwoH48lSBlcQx7i5C+7XEzoatSOB7z+TAcsMHKb PX7MxJYfuz8k/lgPzgFW9mOCHLy5Ypvd2t0JV7lh0JrSVxDzbHnGufweiExPhcWVHlWb y5uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D2gkwNP2; 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 v14-v6si26059777pga.270.2018.08.16.00.55.31; Thu, 16 Aug 2018 00:55:31 -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=D2gkwNP2; 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 S2389564AbeHPKwL (ORCPT + 5 others); Thu, 16 Aug 2018 06:52:11 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45141 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389581AbeHPKwL (ORCPT ); Thu, 16 Aug 2018 06:52:11 -0400 Received: by mail-pg1-f193.google.com with SMTP id f1-v6so1669860pgq.12 for ; Thu, 16 Aug 2018 00:55:30 -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=oQ908iqEE1J6YcVEb5PbZH8Isswa4HYhkkDHD7JZWDk=; b=D2gkwNP27FNp+EIKCqhP6epjkXpR5xzFg9eMhHtCo4XC8wZnYznPqLr5aLbF1vvd6t M0Y5Dq3TzQhV2E7PbI2DrDwUZVC2fAgyuQklN5swoPKW0hKTWeo+mK6Bz7yB9d2eN+Sl c7d/hBaFOdlaskHAglMaZQwS8T46GtUmZ4La4= 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=oQ908iqEE1J6YcVEb5PbZH8Isswa4HYhkkDHD7JZWDk=; b=ChXq1T04flefQRi68Hjy1RUNeDZH8nQ9fF2jGMsAV0BKYMRNm7tE30r6/HcFOeN1uq VMjAPexRtJZVr93hQODV/bv8d+kTLoAfkESA5aOaewQUABOvj9WQsEXhVasPHluFyrj4 OK0M8VZhkB1R10oR42BNS0j6KTqklIvwGsddO4p0jeK+xXS05npg5UofGo/8ZOuetgIm SAn0ET6EzqqHAfOKaFxgVSPUbBs2V2hVR7aBcjawxtsvslYLXRTy3twtqq3OOsfnMQVQ i7j4YOVZhMB0KEmWvHS9t5UW/rVGMzwkYoakt88Z4gked9AAze0czBsf/K5x2H2mlP08 s30g== X-Gm-Message-State: AOUpUlEMolWMpe5e7StJjp9DhVTHjLmftek+29hh3E0zvY6JnmPsfIcN ggOmkQXcVyAVx0p2rEgGTcK/kQ== X-Received: by 2002:a65:5288:: with SMTP id y8-v6mr4307694pgp.284.1534406129869; Thu, 16 Aug 2018 00:55:29 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Aug 2018 00:55:28 -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 03/10] mmc: sdhci: Change SDMA address register for v4 mode Date: Thu, 16 Aug 2018 15:54:17 +0800 Message-Id: <1534406064-10065-4-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 According to the SD host controller specification version 4.10, when Host Version 4 is enabled, SDMA uses ADMA System Address register (05Fh-058h) instead of using SDMA System Address register to support both 32-bit and 64-bit addressing. Signed-off-by: Chunyan Zhang --- drivers/mmc/host/sdhci.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index d808a1f..1f0f1e4 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -727,7 +727,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host, } } -static u32 sdhci_sdma_address(struct sdhci_host *host) +static dma_addr_t sdhci_sdma_address(struct sdhci_host *host) { if (host->bounce_buffer) return host->bounce_addr; @@ -735,6 +735,17 @@ static u32 sdhci_sdma_address(struct sdhci_host *host) return sg_dma_address(host->data->sg); } +static void sdhci_set_sdma_addr(struct sdhci_host *host, dma_addr_t addr) +{ + if (host->v4_mode) { + sdhci_writel(host, addr, SDHCI_ADMA_ADDRESS); + if (host->flags & SDHCI_USE_64_BIT_DMA) + sdhci_writel(host, (u64)addr >> 32, SDHCI_ADMA_ADDRESS_HI); + } else { + sdhci_writel(host, addr, SDHCI_DMA_ADDRESS); + } +} + static unsigned int sdhci_target_timeout(struct sdhci_host *host, struct mmc_command *cmd, struct mmc_data *data) @@ -994,8 +1005,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) SDHCI_ADMA_ADDRESS_HI); } else { WARN_ON(sg_cnt != 1); - sdhci_writel(host, sdhci_sdma_address(host), - SDHCI_DMA_ADDRESS); + sdhci_set_sdma_addr(host, sdhci_sdma_address(host)); } } @@ -2822,7 +2832,7 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) * some controllers are faulty, don't trust them. */ if (intmask & SDHCI_INT_DMA_END) { - u32 dmastart, dmanow; + dma_addr_t dmastart, dmanow; dmastart = sdhci_sdma_address(host); dmanow = dmastart + host->data->bytes_xfered; @@ -2830,12 +2840,12 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) * Force update to the next DMA block boundary. */ dmanow = (dmanow & - ~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1)) + + ~((dma_addr_t)SDHCI_DEFAULT_BOUNDARY_SIZE - 1)) + SDHCI_DEFAULT_BOUNDARY_SIZE; host->data->bytes_xfered = dmanow - dmastart; - DBG("DMA base 0x%08x, transferred 0x%06x bytes, next 0x%08x\n", - dmastart, host->data->bytes_xfered, dmanow); - sdhci_writel(host, dmanow, SDHCI_DMA_ADDRESS); + DBG("DMA base %pad, transferred 0x%06x bytes, next %pad\n", + &dmastart, host->data->bytes_xfered, &dmanow); + sdhci_set_sdma_addr(host, dmanow); } if (intmask & SDHCI_INT_DATA_END) { @@ -3582,8 +3592,8 @@ int sdhci_setup_host(struct sdhci_host *host) } } - /* SDMA does not support 64-bit DMA */ - if (host->flags & SDHCI_USE_64_BIT_DMA) + /* SDMA does not support 64-bit DMA if v4 mode not set */ + if ((host->flags & SDHCI_USE_64_BIT_DMA) && !host->v4_mode) host->flags &= ~SDHCI_USE_SDMA; if (host->flags & SDHCI_USE_ADMA) { From patchwork Thu Aug 16 07:54:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 144332 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1760631ljj; Thu, 16 Aug 2018 00:55:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyQFwgswhOjZ1m6w0dQ5IpqtlHnoFCsbjahCVPyNJvdWrTsRgwGfTyRWw9zfihejgAxTNk3 X-Received: by 2002:a62:c98e:: with SMTP id l14-v6mr30977932pfk.10.1534406150082; Thu, 16 Aug 2018 00:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534406150; cv=none; d=google.com; s=arc-20160816; b=m5Oj4mrKf6OA9w6fTNJMi4dcldOEzz/dzPa+ib1Bam5KmqVrutfrbYxqvOvcQIjXKh 7UCmD5q9u4TajQ3o31H2XJ/cbr0k2+LUK6WzLIN9uEFEflZCRScGC9jiku92kUqVfOUt 9G+9K0nCgV+VpnpyZIyuue+Z65YSSV+6PiTC3YFqHkUWj5k2PCGjtwbOUnYKJG8E8uha 78oS3U91CJ2v/vBIcK4LvC+wlRgfUdiAsjrcknRYQVxMhJJzXUhda5LIczC16E/gEivZ jTEflNQUqYV1rlpvgJF6qrRgqQQ/njKhKV4mg9m6Nx8fBqx3//jPB1rWECExTTDM/URo SzyQ== 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=zUSIlBoQBXb7x6oxFMIHoqh7Gy2b5VOn8aSKwFqgVZ4=; b=zeyI2qgAXF3AB+B9HBE268GHUr0nM7IiYqwm0BlkpcOd93DKALtRjepvF9fR5xVFgf yqs5lSRq8PwtPruYpEZoeMgZhb51EaVnpBBMCF5RuV+Iu2SZPLoBo7BVN6eVAhWRUis4 XCkjpteaMQJz8FAbSS05SCMJvH4Yghqz8WzvvuUm6oh3vNm0EwFUaXTA2Z2W3nlVWEYt hwrTtKZamC9RVLUR/kmMRsAUUpDf2/k6XFxIMbVZyF+1iYE7gF2IVvcpUPyc/Xd024Qb 6vzp4xrQT9xUK5a41GLXRCGBVEFXD9oIhNsVYks/5i8+WRCy4IJt1P5XcLHnBhLIYXr0 DFHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="aegRell/"; 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 w18-v6si26584313pfi.88.2018.08.16.00.55.49; Thu, 16 Aug 2018 00:55:50 -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="aegRell/"; 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 S2389651AbeHPKw3 (ORCPT + 5 others); Thu, 16 Aug 2018 06:52:29 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41226 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387985AbeHPKw3 (ORCPT ); Thu, 16 Aug 2018 06:52:29 -0400 Received: by mail-pf1-f196.google.com with SMTP id y10-v6so1647808pfn.8 for ; Thu, 16 Aug 2018 00:55:47 -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=zUSIlBoQBXb7x6oxFMIHoqh7Gy2b5VOn8aSKwFqgVZ4=; b=aegRell/uXSTpalhIJIjuAcM9LYAzHMKPIQkc/TH+PfYCpoFTAHL0w5kmKlf3btj15 z51cHNN7F/XQ3vNsJoO8AGaXEiifDqDdtjW+7eUjPlyeNKuBoOHOsAGC3srxUwGoxP7V PwV9tkvrd2WXeLQU9ctdp09r4XKPf1lG0+6FI= 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=zUSIlBoQBXb7x6oxFMIHoqh7Gy2b5VOn8aSKwFqgVZ4=; b=gUfHepHgHQ4UpiOHeuCVIvm9K7PQjABb9w8kDAfY4Gled46dN6Dd+EgiK0ppHKM63B wWR5RqaWKLCstiI3dFy1J1floGFn2BRBj+ZOnrhWGr0WH6DeuaIKdM/ABrLtWr2pdqAr OE0I6S+bX099X0BE5j1nlar9Mc1byYfEmQ/lnatwYgv9fi4bfPQUr/3/xLG7sqhMUm9T Lij38q0UYQSRksT6g8kHnQwRYx7Z+x7UQHyu1YE8xzsDR1G5LgLCtyxMXxpk8CjwQ942 cZfhBjMAENP9w6/lVUTKxxF8khlE7f/tvwtBM1mT/UNQcifDwHBH2uQsF697KMWoZsaa he3Q== X-Gm-Message-State: AOUpUlGGOR97t+ePM4nwEUwQvoG11lTkTCX53X0SNeE3pfwHD9u3JVVT 7qTYYcRxIwGxt9HP4K7V6DMcPw== X-Received: by 2002:a63:d002:: with SMTP id z2-v6mr28349949pgf.262.1534406147498; Thu, 16 Aug 2018 00:55:47 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Aug 2018 00:55:46 -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 07/10] mmc: sdhci: Add Auto CMD Auto Select support Date: Thu, 16 Aug 2018 15:54:21 +0800 Message-Id: <1534406064-10065-8-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 As SD Host Controller Specification v4.10 documents: Host Controller Version 4.10 defines this "Auto CMD Auto Select" mode. Selection of Auto CMD depends on setting of CMD23 Enable in the Host Control 2 register which indicates whether card supports CMD23. If CMD23 Enable =1, Auto CMD23 is used and if CMD23 Enable =0, Auto CMD12 is used. In case of Version 4.10 or later, use of Auto CMD Auto Select is recommended rather than use of Auto CMD12 Enable or Auto CMD23 Enable. This patch add this new mode support. Signed-off-by: Chunyan Zhang --- drivers/mmc/host/sdhci.c | 67 ++++++++++++++++++++++++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 58 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index a72ad0d..06c2ae9 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -312,6 +312,23 @@ static void sdhci_config_dma(struct sdhci_host *host) sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); } +static void sdhci_enable_cmd23(struct sdhci_host *host) +{ + u16 ctrl2; + + /* + * This is used along with "Auto CMD Auto Select" feature, + * which is introduced from v4.10, if card supports CMD23, + * Auto CMD23 should be used instead of Auto CMD12. + */ + if (host->version >= SDHCI_SPEC_410 && + (host->mmc->caps & MMC_CAP_CMD23)) { + ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); + ctrl2 |= SDHCI_CMD23_ENABLE; + sdhci_writew(host, ctrl2, SDHCI_HOST_CONTROL2); + } +} + static void sdhci_init(struct sdhci_host *host, int soft) { struct mmc_host *mmc = host->mmc; @@ -1095,6 +1112,44 @@ static inline bool sdhci_auto_cmd12(struct sdhci_host *host, !mrq->cap_cmd_during_tfr; } +static inline void sdhci_auto_cmd_select(struct sdhci_host *host, + struct mmc_command *cmd, + u16 *mode) +{ + bool use_cmd12 = sdhci_auto_cmd12(host, cmd->mrq) && + (cmd->opcode != SD_IO_RW_EXTENDED); + bool use_cmd23 = cmd->mrq->sbc && (host->flags & SDHCI_AUTO_CMD23); + + /* + * In case of Version 4.10 or later, use of 'Auto CMD Auto + * Select' is recommended rather than use of 'Auto CMD12 + * Enable' or 'Auto CMD23 Enable'. + */ + if (host->version >= SDHCI_SPEC_410 && (use_cmd12 || use_cmd23)) { + *mode |= SDHCI_TRNS_AUTO_SEL; + /* + * Note no need to set SDHCI_ARGUMENT2 here, since for version + * 4.10 and aboves, it doesn't support stuff bits of CMD23 + * argument but only number of blocks which have been set + * already during prepare data. + */ + if (use_cmd23) + sdhci_enable_cmd23(host); + return; + } + + /* + * If we are sending CMD23, CMD12 never gets sent + * on successful completion (so no Auto-CMD12). + */ + if (use_cmd12) { + *mode |= SDHCI_TRNS_AUTO_CMD12; + } else if (use_cmd23) { + *mode |= SDHCI_TRNS_AUTO_CMD23; + sdhci_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); + } +} + static void sdhci_set_transfer_mode(struct sdhci_host *host, struct mmc_command *cmd) { @@ -1121,17 +1176,7 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host, if (mmc_op_multi(cmd->opcode) || data->blocks > 1) { mode = SDHCI_TRNS_BLK_CNT_EN | SDHCI_TRNS_MULTI; - /* - * If we are sending CMD23, CMD12 never gets sent - * on successful completion (so no Auto-CMD12). - */ - if (sdhci_auto_cmd12(host, cmd->mrq) && - (cmd->opcode != SD_IO_RW_EXTENDED)) - mode |= SDHCI_TRNS_AUTO_CMD12; - else if (cmd->mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) { - mode |= SDHCI_TRNS_AUTO_CMD23; - sdhci_writel(host, cmd->mrq->sbc->arg, SDHCI_ARGUMENT2); - } + sdhci_auto_cmd_select(host, cmd, &mode); } if (data->flags & MMC_DATA_READ) diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index daf8c1e..a8d5be5 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -43,6 +43,7 @@ #define SDHCI_TRNS_BLK_CNT_EN 0x02 #define SDHCI_TRNS_AUTO_CMD12 0x04 #define SDHCI_TRNS_AUTO_CMD23 0x08 +#define SDHCI_TRNS_AUTO_SEL 0x0C #define SDHCI_TRNS_READ 0x10 #define SDHCI_TRNS_MULTI 0x20 @@ -186,6 +187,7 @@ #define SDHCI_CTRL_DRV_TYPE_D 0x0030 #define SDHCI_CTRL_EXEC_TUNING 0x0040 #define SDHCI_CTRL_TUNED_CLK 0x0080 +#define SDHCI_CMD23_ENABLE 0x0800 #define SDHCI_CTRL_V4_MODE 0x1000 #define SDHCI_CTRL_64BIT_ADDR 0x2000 #define SDHCI_CTRL_PRESET_VAL_ENABLE 0x8000