Index | Thread | Search

From:
"Jan Schreiber" <jes@posteo.de>
Subject:
RK3588 board reset on reboot
To:
<tech@openbsd.org>
Date:
Wed, 15 Jul 2026 13:47:34 +0000

Download raw body.

Thread
When rebooting a RK3588 more often than not I a serial output that wants
me to reset the board. When using following patch it does reboot
reliably.

Values are found the RK3588 TRM Part 1.

diff --git sys/dev/fdt/rkclock.c sys/dev/fdt/rkclock.c
index 5cf37730bbd..3237e698bb7 100644
--- sys/dev/fdt/rkclock.c
+++ sys/dev/fdt/rkclock.c
@@ -235,6 +235,8 @@
 #define RK3588_CRU_CLKSEL_CON(i)	(0x00300 + (i) * 4)
 #define RK3588_CRU_GATE_CON(i)		(0x00800 + (i) * 4)
 #define RK3588_CRU_SOFTRST_CON(i)	(0x00a00 + (i) * 4)
+#define RK3588_CRU_GLB_SRST_FST		0x00c08
+#define  RK3588_GLB_SRST_FST_VAL		0xfdb9

 #define RK3588_PHPTOPCRU_PPLL_CON(i)	(0x08200 + (i) * 4)
 #define RK3588_PHPTOPCRU_SOFTRST_CON(i)	(0x08a00 + (i) * 4)
@@ -4987,11 +4989,28 @@ const uint32_t rk3588_gates[78] = {
 	[66] = 0x00000004,
 };

+extern void (*cpuresetfn)(void);
+struct rkclock_softc *rk3588_cru_sc;
+
+void
+rk3588_cpureset(void)
+{
+	struct rkclock_softc *sc = rk3588_cru_sc;
+
+	if (sc != NULL)
+		HWRITE4(sc, RK3588_CRU_GLB_SRST_FST, RK3588_GLB_SRST_FST_VAL);
+	for (;;)
+		continue;
+}
+
 void
 rk3588_init(struct rkclock_softc *sc)
 {
 	int i;

+	rk3588_cru_sc = sc;
+	cpuresetfn = rk3588_cpureset;
+
 	/* The code below assumes all clocks are enabled.  Check this!. */
 	for (i = 0; i < nitems(rk3588_gates); i++) {
 		if (HREAD4(sc, RK3588_CRU_GATE_CON(i)) != rk3588_gates[i]) {