From patchwork Sat Jul 16 19:43:46 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: 591269 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25EC8C433EF for ; Sat, 16 Jul 2022 19:43:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232583AbiGPTnx (ORCPT ); Sat, 16 Jul 2022 15:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232585AbiGPTnw (ORCPT ); Sat, 16 Jul 2022 15:43:52 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE3157646 for ; Sat, 16 Jul 2022 12:43:49 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id tk8so3189258ejc.7 for ; Sat, 16 Jul 2022 12:43:49 -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=H/T5SCRTZnvNt4JlT7zW83Ocmb/ZGFQfFEQNlDPUCI8=; b=n9MXmbtnvdtjnx5J2nrdopHTJx07KpjcmhDzg7sg6Qf5Y4FALt6HjxT8YXyIeYVkmt ufyrYXmuOYn1BpWZfcyYRtOz8/BOA5iemqNLy5SeSaDz26yp0/HgPHwJ5d530GTfovMC l7XyKXc6Ma+vlFjc+SQw1jdgT2mLgpkPRusTZ3H9bGSOkTgCiXtreMkEvGtmcmv9zf3I ti3l8jlLXSNLR34055wrdpBMguTfCMHh+fGGrQ05IbxjyFWlfxYSM5eSUisfmpQUUgeR YQ82luhh7y69WCpF4pMnpTTtvVzAwUgTVi4cwrNFcM46vAhZ1odde3p05bNKm3d0UHGc +f9Q== 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=H/T5SCRTZnvNt4JlT7zW83Ocmb/ZGFQfFEQNlDPUCI8=; b=57mrdD17riA7/Foo/VKNasxbueCBo1XA3WaRBDugCmnWQUX0sByzJhubg1mGb2dhZF UR3FEcFR5vHmmLNPtzYCr387esbebb39BIwreW9qNyhXSXQz1SEJq3z1IJD7ucrbUFGC S/T2UKdho1anGriyuiJBixI2UFgcRemngFueVS5AMUz8EqT9+msbKlL3D+5Hq+PzpFl/ sOAEG8mFJJPJ7jzoPYsKp5OQjC4YKejUF+1vxGsXms1jZHcSQYezUqBerLnuKOOOiyIB rqMm15XOKrw4fL5zKV10TRszHA1+YjVrRbb0z/n+RtEHXrq0rkJiJTcaiEqnNEUBG5RV xs4Q== X-Gm-Message-State: AJIora/D+VWOzOUZudw4g7sGAqeyis1AUftOdg8Xm6qhy0K5MZ3nh5l/ fnYi1k0R2HOsACxBU3dO2rfqeg== X-Google-Smtp-Source: AGRyM1tfaw6taoKWBs3jjagj6BkI+UEYOKsGCFybdoJ0w7ESh2k81dmaxHS3p8Oue9CB1K3uUXCiaA== X-Received: by 2002:a17:906:2da:b0:712:14b:62da with SMTP id 26-20020a17090602da00b00712014b62damr19317613ejk.351.1658000628431; Sat, 16 Jul 2022 12:43:48 -0700 (PDT) Received: from smtpclient.apple (ip5b434222.dynamic.kabel-deutschland.de. [91.67.66.34]) by smtp.gmail.com with ESMTPSA id q25-20020a1709066ad900b0072b2ef2757csm3489152ejs.180.2022.07.16.12.43.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Jul 2022 12:43:47 -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 v5] arm64: dts: rockchip: Fix SD card init on rk3399-nanopi4 Date: Sat, 16 Jul 2022 21:43:46 +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> 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: <3912A668-9F73-40FD-8993-5060F632238A@kohlschutter.com> Message-Id: <7E830C9F-BB5D-4EFC-B3F4-1C580E9326A3@kohlschutter.com> X-Mailer: Apple Mail (2.3696.100.31) Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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. As a welcome side-effect, this change allows the SD card voltage to be set back to 3.0V upon reboot, allowing bootloaders to use the card right away, obsoleting further patching. 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";