From patchwork Mon Jul 18 12:04:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_Kohlsch=C3=BCtter?= X-Patchwork-Id: 12921152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3227CC43334 for ; Mon, 18 Jul 2022 12:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Message-Id:In-Reply-To:To:References: Date:Subject:Mime-Version:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RRwfthtuqiTZyztWeNj1NbNP+Vr+dIxZHzgOCi6FSIk=; b=2wMI5DM9Q3b29x Qq9/nY+feVfrrpFqWf6xlNrvs+f7rUSWsca9nQoyu+vwkuXPqDevdrveXoCiLIzhFyOBNux3atQGs vZHLa7sh50VSnD6jBY7BfcvLgCmKiuHwYI5CXcrdIMMc3eoCB/pmyxwk9vDTJ1/TMopgbkjtHcmrm DC4kupQtghL5V0aHlhp2PGz+qWCm///eexpMq+q03tHAysFDhpUs9JqojqTg/oh62vVbpSiK/67AI r6lnp3KJs7rStDGv0kGjw5M/6wJIJHLFFrVSxzP2ZNjqchfQGuEtjpJ+ZOw7LObttJE24d6hFAjhf mhFFHYcL9W5A4GkbDdWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDPUL-00D59g-Mw; Mon, 18 Jul 2022 12:04:37 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDPUI-00D57B-AR for linux-rockchip@lists.infradead.org; Mon, 18 Jul 2022 12:04:37 +0000 Received: by mail-ej1-x633.google.com with SMTP id ss3so20741814ejc.11 for ; Mon, 18 Jul 2022 05:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kohlschutter-com.20210112.gappssmtp.com; s=20210112; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=PQ4rIL+dXxSoAf2L0QQkIcDArwZfdbAiRX/9Z9IDwAw=; b=dr8niMg/x9uzV0DOsVncE9RkhT1oLr5LE0woFvKhtJ45utWsNlJnyZ/8DTL+kBmYVc LcBOcGwzSlhjgw0BS1N2Be/+xR+0sD/1ccVATUv/ntkZ/t8gC7vGoG6pCmQeeh7/N0AR 5050cBbIH78lYFq5F0xJBYqyo0XmgaI8x/al1bhu9EDHSi5hDqq7+iezJ+4YCCItM/9Q VIK15dubVZb6YSdGmdOwO/WLsyyfi1oiqOi/I8YQx5BkNX4K9dO4afPIGOXiq2XzIpVv RcEdogrJE7WMtu8hwTuuxewAB85SB3hUOCCzviAzaaGRQClJT8dbhQ88asS7735HCsKC PvXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=PQ4rIL+dXxSoAf2L0QQkIcDArwZfdbAiRX/9Z9IDwAw=; b=zq4ELDsLBXW2fEl9a/71OIVLO4wA4Zjbe7pR1QC2TTHqUI4wavUtNXWzoWtsooxOj/ PnPp9SiPa13wMRc2loD2/tA+ixtP9PkpYtSA6rVQotvbWKDiPxfkaZ5MzflxDSYNdmnz n7ecv4grlIk6wR/59SY17xWPi/BOxYBAtYIU+yvPnx0WNAJATBaK4EZpAZwsTjeIUx+d nbHki2zMq7HVTpVccWvlQtbqYCOQkn02nKXyh/jz33Zd4iZSnc7bRGTn698KO8mmnSLz TQLi8+9SCuDZiMZn0Ne5oq1+KZpss9EDqRdrCmFnyiebmCsOHWSIDSWxr2dzT+vhqjU4 dg/w== X-Gm-Message-State: AJIora9y9hNgYEJastEPO5gicn7doALBEpxbi7yHKMhPisucnnZ1eiaN mdsPxubly0TfXNsbNgz7Vn+Blg== X-Google-Smtp-Source: AGRyM1uWQJUGPqMWpWdlTVf5h7q2TWkLPk6FGThh1XPMLHY9dPNkba2XOHKyvOSAHt30hQyeppF+3g== X-Received: by 2002:a17:906:6a29:b0:72e:e716:d220 with SMTP id qw41-20020a1709066a2900b0072ee716d220mr17696601ejc.82.1658145872777; Mon, 18 Jul 2022 05:04:32 -0700 (PDT) Received: from smtpclient.apple (ip5b434222.dynamic.kabel-deutschland.de. [91.67.66.34]) by smtp.gmail.com with ESMTPSA id mb1-20020a170906eb0100b0072aa38d768esm5430355ejb.64.2022.07.18.05.04.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2022 05:04:32 -0700 (PDT) From: =?utf-8?q?Christian_Kohlsch=C3=BCtter?= Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: [PATCH v6] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4 Date: Mon, 18 Jul 2022 14:04:31 +0200 References: <12878108.O9o76ZdvQC@diego> <103b714c-b07c-f016-1062-84bd94786b22@arm.com> <9AF1E75F-5947-49B0-887D-82C426527B99@kohlschutter.com> <590f7a08-a6ca-be54-4254-363343642a52@arm.com> <5ca9bd94-54d9-04f8-0098-a56ffb6f5fe1@arm.com> <502b3fbe-3077-407e-6010-a8cb3ffce7d6@arm.com> <449292CA-CE60-4B90-90F7-295FBFEAB3F8@kohlschutter.com> <73F9AED0-D2A8-4294-B6E1-1B92D2A36529@kohlschutter.com> <115AD6A4-021B-4879-BFB5-BC7689A0203E@kohlschutter.com> <17a4c6f6-d79c-a7b2-860f-e5944b778f9f@arm.com> <9405b97a-6758-ad4e-ccff-eed072096539@arm.com> <3912A668-9F73-40FD-8993-5060F632238A@kohlschutter.com> <7E830C9F-BB5D-4EFC-B3F4-1C580E9326A3@kohlschutter.com> To: Robin Murphy , wens@kernel.org, =?utf-8?q?Heiko_St?= =?utf-8?q?=C3=BCbner?= , Markus Reichl , linux-arm-kernel , "open list:ARM/Rockchip SoC..." , linux-kernel , Linux MMC List In-Reply-To: <7E830C9F-BB5D-4EFC-B3F4-1C580E9326A3@kohlschutter.com> Message-Id: X-Mailer: Apple Mail (2.3696.100.31) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220718_050434_379435_90B9682A X-CRM114-Status: GOOD ( 14.98 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org 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 --- 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";