linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Christian Kohlschütter" <christian@kohlschutter.com>
To: "Robin Murphy" <robin.murphy@arm.com>,
	wens@kernel.org, "Heiko Stübner" <heiko@sntech.de>,
	"Markus Reichl" <m.reichl@fivetechno.de>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"Linux MMC List" <linux-mmc@vger.kernel.org>
Subject: [PATCH v6] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4
Date: Mon, 18 Jul 2022 14:04:31 +0200	[thread overview]
Message-ID: <E5A1A1E7-449F-4161-87B9-7A6CA0CAA42C@kohlschutter.com> (raw)
In-Reply-To: <7E830C9F-BB5D-4EFC-B3F4-1C580E9326A3@kohlschutter.com>

mmc/SD-card initialization may fail on NanoPi R4S with
"mmc1: problem reading SD Status register" /
"mmc1: error -110 whilst initialising SD card"
either on cold boot or after a reboot.

Moreover, the system would also sometimes hang upon reboot.

This is caused by vcc3v0-sd's "regulator-always-on", which triggers
an erroneous double-initialization of the regulator. This causes
voltage fluctuations that can, depending on timing, prevent the
SD card from initializing correctly.

Adding some liberal delay via "off-on-delay-us" is ineffective since
that codepath is skipped as long "regulator-always-on" is set.

Removing "regulator-always-on" alone is not sufficient because that
would allow the system to set GPIO0_A1 to LOW upon reboot, which may
cause the system to hang.

In order to allow the system to set GPIO0_A1 to HIGH upon initialization
but prevent it from changing it back to LOW, this patch increases the
usage count of vcc3v0-sd from 1 to 2, whereas the additional reference,
"vcc1v8_s3", is marked as "always-on", causing permanent retention.

Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
---
arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
index 8c0ff6c96e03..38507a6e3046 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi
@@ -61,7 +61,17 @@ vcc1v8_s3: vcc1v8-s3 {
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-name = "vcc1v8_s3";
-		vin-supply = <&vcc_1v8>;
+
+		/*
+		 * Workaround to skip setting gpio0 RK_PA1 to LOW upon reboot,
+		 * which may freeze the system.
+		 *
+		 * Adding a reference to vcc3v0_sd increases its num_users
+		 * count to 2, preventing deactivation since this regulator is
+		 * marked "always-on".
+		 */
+		// vin-supply = <&vcc_1v8>; // actual supply
+		vin-supply = <&vcc3v0_sd>;
	};

	vcc3v0_sd: vcc3v0-sd {
@@ -70,7 +80,6 @@ vcc3v0_sd: vcc3v0-sd {
		gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&sdmmc0_pwr_h>;
-		regulator-always-on;
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;
		regulator-name = "vcc3v0_sd";
-- 
2.36.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-07-18 12:05 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 22:22 [PATCH] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4 Christian Kohlschütter
2022-07-13 23:41 ` Heiko Stübner
2022-07-14 11:41   ` Robin Murphy
2022-07-14 12:14     ` Christian Kohlschütter
2022-07-14 13:14       ` Markus Reichl
2022-07-14 13:50       ` Robin Murphy
2022-07-14 16:24         ` Christian Kohlschütter
2022-07-14 16:26           ` [PATCH v2] " Christian Kohlschütter
2022-07-14 16:44             ` Christian Loehle
2022-07-14 17:20               ` Christian Kohlschütter
2022-07-15 17:02                 ` Christian Loehle
2022-07-14 17:02             ` Chen-Yu Tsai
2022-07-14 17:35               ` Robin Murphy
2022-07-14 17:57                 ` Christian Kohlschütter
2022-07-14 23:44                 ` Robin Murphy
2022-07-15 17:01                   ` [PATCH v3] " Christian Kohlschütter
2022-07-15 17:12                     ` [PATCH v4] " Christian Kohlschütter
2022-07-15 17:16                       ` Christian Kohlschütter
2022-07-15 18:11                         ` Robin Murphy
2022-07-15 18:57                           ` Christian Kohlschütter
2022-07-15 18:57                           ` Robin Murphy
2022-07-15 19:04                             ` Christian Kohlschütter
2022-07-15 19:38                               ` Robin Murphy
2022-07-15 22:33                                 ` Christian Kohlschütter
2022-07-16  0:24                                   ` Christian Kohlschütter
2022-07-16 19:43                                     ` [PATCH v5] " Christian Kohlschütter
2022-07-18 12:04                                       ` Christian Kohlschütter [this message]
2022-07-18 12:05                                         ` [PATCH v6] " Christian Kohlschütter
2022-07-18 21:04                                           ` Christian Kohlschütter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E5A1A1E7-449F-4161-87B9-7A6CA0CAA42C@kohlschutter.com \
    --to=christian@kohlschutter.com \
    --cc=heiko@sntech.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=m.reichl@fivetechno.de \
    --cc=robin.murphy@arm.com \
    --cc=wens@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).