From patchwork Tue Nov 5 15:36:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 2006936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XjXWg1qX9z1xxN for ; Wed, 6 Nov 2024 02:37:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD75B891C0; Tue, 5 Nov 2024 16:36:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 59873891B0; Tue, 5 Nov 2024 16:36:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-bc0f.mail.infomaniak.ch (smtp-bc0f.mail.infomaniak.ch [IPv6:2001:1600:7:10::bc0f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 058378900E for ; Tue, 5 Nov 2024 16:36:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=foss+uboot@0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (unknown [IPv6:2001:1600:7:10:40ca:feff:fe05:0]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4XjXWW3ZH4zY6D; Tue, 5 Nov 2024 16:36:55 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4XjXWV1F52zPPv; Tue, 5 Nov 2024 16:36:54 +0100 (CET) From: Quentin Schulz Subject: [PATCH next 0/5] rockchip: rk3399: allow to trigger sysreset in TPL Date: Tue, 05 Nov 2024 16:36:31 +0100 Message-Id: <20241105-rk3399-sysreset-gpio-tpl-v1-0-12caff07a4e4@cherry.de> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAH87KmcC/x3MQQqDMBBA0avIrB1IotbGq0gXYqZ2sMQwE4oi3 t3Q5Vv8f4KSMCkM1QlCP1beYoGtK5g/U1wIORSDM6611nQoa9N4j3qokFLGJfGGOX2xMw9n+qe dQ/BQ8iT05v2/HiHSnuF1XTfM4O+DcAAAAA== X-Change-ID: 20241105-rk3399-sysreset-gpio-tpl-50620781cdd9 To: Tom Rini , Simon Glass , Philipp Tomsich , Kever Yang , Klaus Goger Cc: u-boot@lists.denx.de, Paul Kocialkowski , Paul Kocialkowski , Quentin Schulz X-Mailer: b4 0.14.2 X-Infomaniak-Routing: alpha X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean A sysreset-gpio can be provided in an RK3399 platform's Device Tree and if U-Boot detects a "warm" boot was done, it'll toggle that GPIO to perform a reset of the PMIC, essentially forcing a cold boot to make sure there are no non-default values in SoC registers. For now, this was only supported in SPL, probably because when this was implemented RK3399 (and specifically Puma) didn't have TPL support so SPL was the earliest stage. Now that most RK3399 boards (and specifically Puma) have TPL enabled, it makes sense to add support for triggering this sysreset from it. It brings the following advantages: - faster boot time as we don't need to reach SPL to be able to reset the system on a condition we know is already met in TPL, - have less code to be impacted by the issue this system reset works around (that is, "unclean" SoC registers after a reboot), - less confusion around the reason for restarting. Indeed when done from SPL, the following log can be observed: """ U-Boot TPL 2025.01-rc1-00165-gd79216ca9878-dirty (Nov 05 2024 - 15:31:45) Channel 0: DDR3, 666MHz BW=32 Col=10 Bk=8 CS0 Row=16 CS=1 Die BW=16 Size=2048MB Channel 1: DDR3, 666MHz BW=32 Col=10 Bk=8 CS0 Row=16 CS=1 Die BW=16 Size=2048MB 256B stride Trying to boot from BOOTROM Returning to boot ROM... U-Boot SPL 2025.01-rc1-00165-gd79216ca9878-dirty (Nov 05 2024 - 15:31:45 +0100) Trying to boot from MMC2 U-Boot TPL 2025.01-rc1-00165-gd79216ca9878-dirty (Nov 05 2024 - 15:31:45) """ possibly hinting at an issue within the SPL when loading the fitImage from MMC2 instead of the normal course of events (a system reset). For this to be possible, the sysreset function is adapted to be able to run in SPL and TPL by checking the appropriate symbols and a weak callback is added in the TPL main C code so that we can hook this sysreset function within the TPL code path. @Cc Paul since he's trying to add support for this sysreset to the Firefly ROC-RK3399-PC[1] and Pine64 ROCKPro64[2]. You'll want to have gpio1 with boopth-pre-sram though so it makes it to the TPL DTB. [1] https://lore.kernel.org/u-boot/20240926183111.1324284-1-paulk@sys-base.io/ [2] https://lore.kernel.org/u-boot/20240926183111.1324284-2-paulk@sys-base.io/ Signed-off-by: Quentin Schulz --- Quentin Schulz (5): pinctrl: rockchip: allow to build for TPL rockchip: rk3399: merge CRU check within rk3399_force_power_on_reset rockchip: tpl: allow to call board/SoC-specific code before DRAM init rockchip: rk3399: allow to handle sysreset-gpio in TPL rockchip: configs: puma-rk3399: do the system reset in TPL arch/arm/mach-rockchip/rk3399/rk3399.c | 58 +++++++++++++++++++--------------- arch/arm/mach-rockchip/tpl.c | 6 ++++ configs/puma-rk3399_defconfig | 3 ++ drivers/pinctrl/Kconfig | 8 +++++ drivers/pinctrl/rockchip/Kconfig | 7 ++++ 5 files changed, 56 insertions(+), 26 deletions(-) --- base-commit: 56accc56b9aab87ef4809ccc588e1257969cd271 change-id: 20241105-rk3399-sysreset-gpio-tpl-50620781cdd9 Best regards,