[PATCH 09/17] board: k1: initialize clock and serial devices in SPL
Raymond Mao
raymondmaoca at gmail.com
Sat Jan 17 20:01:43 CET 2026
From: Raymond Mao <raymond.mao at riscstar.com>
Initialize clock and serial devices in SPL. Otherwise, the device
driver won't be loaded in SPL.
Signed-off-by: Raymond Mao <raymond.mao at riscstar.com>
---
board/spacemit/k1/spl.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/board/spacemit/k1/spl.c b/board/spacemit/k1/spl.c
index 11a097389f1..1c299810d39 100644
--- a/board/spacemit/k1/spl.c
+++ b/board/spacemit/k1/spl.c
@@ -3,8 +3,44 @@
* Copyright (c) 2025-2026, RISCStar Ltd.
*/
+#include <dm/device.h>
+#include <dm/uclass.h>
#include <spl.h>
+static void clk_early_init(void)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_get_device_by_name(UCLASS_CLK, "clock-controller at d4090000", &dev);
+ if (ret)
+ panic("Fail to detect clock-controller at d4090000\n");
+ ret = uclass_get_device_by_name(UCLASS_CLK, "system-controller at d4050000", &dev);
+ if (ret)
+ panic("Fail to detect system-controller at d4050000\n");
+ ret = uclass_get_device_by_name(UCLASS_CLK, "system-controller at d4282800", &dev);
+ if (ret)
+ panic("Fail to detect system-controller at d4282800\n");
+ ret = uclass_get_device_by_name(UCLASS_CLK, "system-controller at d4015000", &dev);
+ if (ret)
+ panic("Fail to detect system-controller at d4015000\n");
+
+ if (device_active(dev))
+ debug("clk: device is active\n");
+ else
+ debug("clk: device not active, probing...\n");
+}
+
+void serial_early_init(void)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_get_device(UCLASS_SERIAL, 0, &dev);
+ if (ret)
+ panic("Serial uclass init failed: %d\n", ret);
+}
+
void board_init_f(ulong dummy)
{
int ret;
@@ -15,6 +51,8 @@ void board_init_f(ulong dummy)
riscv_cpu_setup();
+ clk_early_init();
+ serial_early_init();
preloader_console_init();
}
--
2.25.1
More information about the U-Boot
mailing list