summaryrefslogtreecommitdiffstats
path: root/arm64-Revert-mmc-sdhci-tegra-drop---get_ro-implementation.patch
blob: 831ec8a18a8890a8c336a6acd13e97ee5b01d8b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
From patchwork Thu Aug  8 22:24:30 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Dmitry Osipenko <digetx@gmail.com>
X-Patchwork-Id: 11084925
Return-Path: <linux-mmc-owner@kernel.org>
Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org
 [172.30.200.125])
	by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E38C414DB
	for <patchwork-linux-mmc@patchwork.kernel.org>;
 Thu,  8 Aug 2019 22:25:47 +0000 (UTC)
Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D121728911
	for <patchwork-linux-mmc@patchwork.kernel.org>;
 Thu,  8 Aug 2019 22:25:47 +0000 (UTC)
Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486)
	id C3F6B289AD; Thu,  8 Aug 2019 22:25:47 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
	pdx-wl-mail.web.codeaurora.org
X-Spam-Level: 
X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI
	autolearn=ham version=3.3.1
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 656C628911
	for <patchwork-linux-mmc@patchwork.kernel.org>;
 Thu,  8 Aug 2019 22:25:47 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S2404695AbfHHWZr (ORCPT
        <rfc822;patchwork-linux-mmc@patchwork.kernel.org>);
        Thu, 8 Aug 2019 18:25:47 -0400
Received: from mail-lj1-f196.google.com ([209.85.208.196]:39456 "EHLO
        mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
        with ESMTP id S1732708AbfHHWZq (ORCPT
        <rfc822;linux-mmc@vger.kernel.org>); Thu, 8 Aug 2019 18:25:46 -0400
Received: by mail-lj1-f196.google.com with SMTP id v18so90278587ljh.6;
        Thu, 08 Aug 2019 15:25:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:to:cc:subject:date:message-id:mime-version
         :content-transfer-encoding;
        bh=Q9p8dp4Vwd7zb49ZfmkHjOde2lTf1kQmZ0LZmoXXg+Y=;
        b=X/HCeJp6SdIpegsENNIX5jnBFbtDSt0UzsTUaN0a3V8l4KnCb/S47gsOo5w4dI/NuL
         V5etWewZyguGVw5FG6KZWbW1LS15klZZSFCTiM7xpoSJFKT0PQDSyqOStwc5XptUNDIb
         qgY409tTcnSLMME5LL0QF9qUqJEJ5eul/A29A05dpYuiAE/VlwyFHs9wqNchY3n6E3tm
         PvQ0AGqmCEPC4oalZvcTWwYpZWM+7HKgb3eXOP5yluvevmLCNFylOeAYk+oId8vPdONf
         JOWaRweXeFZl1b7jrY0HUlayIuG7iqV2+q/o6hzKZx9BLRodDP11LPPM9cHiWEb3wN3X
         4CBA==
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:mime-version
         :content-transfer-encoding;
        bh=Q9p8dp4Vwd7zb49ZfmkHjOde2lTf1kQmZ0LZmoXXg+Y=;
        b=JGAzGWjuAZo8BCyJ+jFiDtGtbpEogcNiooDB8Q1/3nLH0goLK+zBDHd1O9vjLhGwy2
         AMGb5hZq8/csTSRCwTLpO0XWbLb+GETMzbiW7kBz5wrUIXdMfnxkVrAemaUbPFFPp8jh
         17jh5PvWtDEfBiixw6hba23owcAHs9TZ6s+6adekP+0J4Rw+hLjVuJQ1J/eIcS8Ea5T5
         9pj9rHF7cZ+CvccJTgTk45Q6YVjZIVbOTZmvvRTVwNULu29Op2EPzwI9oTVQj75V+RpE
         QFGIAEgayyd0hCaz93b9eC/4UjtpyX3SLjqWLNoa7OgLy2F+D3tQzZ+dzq1ljGT2bwWt
         UnPA==
X-Gm-Message-State: APjAAAUx1JJ0CXUgSqw4EMqq5ZYk57Si1XVKMzl5tKnOckrzsVCbL18C
        y0L1c2r4HgvumbNZx1lPlCY=
X-Google-Smtp-Source: 
 APXvYqyRb0wvQlmXB+gXw3/gwm+pd7UaBZTu3orpe9dFWQXE6Yy8xkJqi7BlFLmgkM9E0td9w8j+IQ==
X-Received: by 2002:a2e:9b48:: with SMTP id o8mr9572286ljj.122.1565303144838;
        Thu, 08 Aug 2019 15:25:44 -0700 (PDT)
Received: from localhost.localdomain ([94.29.34.218])
        by smtp.gmail.com with ESMTPSA id
 g5sm19318415ljj.69.2019.08.08.15.25.43
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 08 Aug 2019 15:25:43 -0700 (PDT)
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
        Jonathan Hunter <jonathanh@nvidia.com>,
        Adrian Hunter <adrian.hunter@intel.com>,
        Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org,
        linux-kernel@vger.kernel.org
Subject: [PATCH v1] Revert "mmc: sdhci-tegra: drop ->get_ro() implementation"
Date: Fri,  9 Aug 2019 01:24:30 +0300
Message-Id: <20190808222430.28477-1-digetx@gmail.com>
X-Mailer: git-send-email 2.22.0
MIME-Version: 1.0
Sender: linux-mmc-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-mmc.vger.kernel.org>
X-Mailing-List: linux-mmc@vger.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP

The WRITE_PROTECT bit is always in a "protected mode" on Tegra and
WP-GPIO state need to be used instead. In a case of the GPIO absence,
write-enable should be assumed. External SD is writable once again as
a result of this patch because the offending commit changed behaviour for
the case of a missing WP-GPIO to fall back to WRITE_PROTECT bit-checking,
which is incorrect for Tegra.

Cc: stable@vger.kernel.org # v5.1+
Fixes: e8391453e27f ("mmc: sdhci-tegra: drop ->get_ro() implementation")
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-tegra.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index f4d4761cf20a..02d8f524bb9e 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -258,6 +258,16 @@ static void tegra210_sdhci_writew(struct sdhci_host *host, u16 val, int reg)
 	}
 }
 
+static unsigned int tegra_sdhci_get_ro(struct sdhci_host *host)
+{
+	/*
+	 * Write-enable shall be assumed if GPIO is missing in a board's
+	 * device-tree because SDHCI's WRITE_PROTECT bit doesn't work on
+	 * Tegra.
+	 */
+	return mmc_gpio_get_ro(host->mmc);
+}
+
 static bool tegra_sdhci_is_pad_and_regulator_valid(struct sdhci_host *host)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -1224,6 +1234,7 @@ static const struct cqhci_host_ops sdhci_tegra_cqhci_ops = {
 };
 
 static const struct sdhci_ops tegra_sdhci_ops = {
+	.get_ro     = tegra_sdhci_get_ro,
 	.read_w     = tegra_sdhci_readw,
 	.write_l    = tegra_sdhci_writel,
 	.set_clock  = tegra_sdhci_set_clock,
@@ -1279,6 +1290,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra30 = {
 };
 
 static const struct sdhci_ops tegra114_sdhci_ops = {
+	.get_ro     = tegra_sdhci_get_ro,
 	.read_w     = tegra_sdhci_readw,
 	.write_w    = tegra_sdhci_writew,
 	.write_l    = tegra_sdhci_writel,
@@ -1332,6 +1344,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra124 = {
 };
 
 static const struct sdhci_ops tegra210_sdhci_ops = {
+	.get_ro     = tegra_sdhci_get_ro,
 	.read_w     = tegra_sdhci_readw,
 	.write_w    = tegra210_sdhci_writew,
 	.write_l    = tegra_sdhci_writel,
@@ -1366,6 +1379,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra210 = {
 };
 
 static const struct sdhci_ops tegra186_sdhci_ops = {
+	.get_ro     = tegra_sdhci_get_ro,
 	.read_w     = tegra_sdhci_readw,
 	.write_l    = tegra_sdhci_writel,
 	.set_clock  = tegra_sdhci_set_clock,