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>
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;
#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)
{
/*
* 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;
+ }
}