]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
board: rockchip: set M.2 NVMe PERSTN low in spl_board_init on Jaguar
authorJakob Unterwurzacher <jakob.unterwurzacher@cherry.de>
Thu, 25 Jun 2026 11:55:15 +0000 (13:55 +0200)
committerQuentin Schulz <u-boot@0leil.net>
Fri, 10 Jul 2026 08:45:05 +0000 (10:45 +0200)
As it is, an NVMe's built-in PERSTN pull-up fights against the
SoC's built-in pull-down which results in an undefined logic state
on the Samsung SSD 980 and likely others.

Fix that by forcing PERSTN low as early as possible, which is SPL.

Both Linux and U-Boot (via "pci enum") set the pin high later
as needed and the NVMe is detected fine.

Oscillocope shots ("x" means undefined logic state at around 1.5V):

Before:

3V3     ____|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
PERSTN  ____xxxxxxxxxxxxxxx_|‾‾‾‾‾
PCICLK  ____∿∿∿∿∿∿∿∿∿∿∿∿___∿∿∿∿∿∿∿
                    ^U-Boot     ^ Linux

After:

3V3     ____|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
PERSTN  ____x_______________|‾‾‾‾‾
PCICLK  ____∿∿∿∿∿∿∿∿∿∿∿∿___∿∿∿∿∿∿∿
                    ^U-Boot     ^ Linux

With this change, the power-up sequence conforms to PCIe specs,
except a remaining short PERSTN glitch. The glitch is about 400ms
long. It could be shortened by moving the logic to TPL, but
completely fixing it is only possible in hardware.

Signed-off-by: Jakob Unterwurzacher <jakob.unterwurzacher@cherry.de>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Link: https://patch.msgid.link/20260625-pub-jaguar-puma-ringneck-tiger-v2025-07_nvme-v2-1-c57bf1020d63@cherry.de
Signed-off-by: Quentin Schulz <u-boot@0leil.net>
arch/arm/dts/rk3588-jaguar-u-boot.dtsi
board/theobroma-systems/jaguar_rk3588/jaguar_rk3588.c

index dcda4f99d6e44d0faf5ccdb508650ba287e0cfc7..0fbbb50fc5a03bd5da428723a01f9310f2b032c3 100644 (file)
        bootph-some-ram;
 };
 
+&gpio0 {
+       /* Need gpio0 in SPL for spl_board_init() to control GPIO0_D0 */
+       /* TODO: once we have a U-Boot TPL, use bootph-pre-sram; */
+       bootph-pre-ram;
+};
+
 &gpio2 {
        bootph-pre-ram;
        bootph-some-ram;
index 3f484646701a452cec8ed1172d6869f44450a297..5177aa9d6e80c9f2173038215da594210bc591f9 100644 (file)
@@ -54,6 +54,8 @@ int rockchip_early_misc_init_r(void)
 
 #define GPIO0B7_PU_EN BIT(15)
 
+#define M2_NVME_PERSTN 24 /* GPIO0_D0, PERSTN signal to the M.2 NVMe slot */
+
 void spl_board_init(void)
 {
        /*
@@ -67,6 +69,24 @@ void spl_board_init(void)
         * pull-up.
         */
        struct rk3588_pmu2_ioc * const ioc = (void *)PMU2_IOC_BASE;
+       int ret;
 
+       /* TODO: once we have a U-Boot TPL, move this to tpl_board_init() */
        rk_setreg(&ioc->gpio0b_p, GPIO0B7_PU_EN);
+
+       /*
+        * Set the M.2 NVMe slot PERSTN to a defined low
+        * state as early as possible
+        */
+       ret = gpio_request(M2_NVME_PERSTN, "M2_NVME_PERSTN");
+       if (ret) {
+               log_err("M2_NVME_PERSTN: gpio request failed: %d\n", ret);
+               return;
+       }
+
+       ret = gpio_direction_output(M2_NVME_PERSTN, 0);
+       if (ret) {
+               log_err("M2_NVME_PERSTN: gpio direction set failed: %d\n", ret);
+               return;
+       }
 }