summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Chien Peter Lin <[email protected]>2026-02-24 11:17:32 +0800
committerAnup Patel <[email protected]>2026-03-22 11:16:33 +0530
commit4813a2042096b7860655761aad973723293a552e (patch)
treed1ad3b62c92126c6ccbd7cb6ec62c4c94355fa03
parent0ab0c470d5886ce5852c94f16725c990e7f08662 (diff)
lib: sbi_init: Call hart init and timer init before platform early init
To allow the platform early drivers to use the sbi_timer_mdelay(), sbi_timer_udelay() and sbi_hart_has_extension() helpers, reorder the initialization sequence must call sbi_hart_init() and sbi_timer_init() prior to sbi_platform_early_init() during both cold and warm boot paths. Reviewed-by: Greentime Hu <[email protected]> Reviewed-by: Zong Li <[email protected]> Signed-off-by: Yu-Chien Peter Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
-rw-r--r--lib/sbi/sbi_init.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index 5259064b..aae035e1 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -265,11 +265,15 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
*/
wake_coldboot_harts(scratch);
- rc = sbi_platform_early_init(plat, true);
+ rc = sbi_hart_init(scratch, true);
if (rc)
sbi_hart_hang();
- rc = sbi_hart_init(scratch, true);
+ rc = sbi_timer_init(scratch, true);
+ if (rc)
+ sbi_hart_hang();
+
+ rc = sbi_platform_early_init(plat, true);
if (rc)
sbi_hart_hang();
@@ -307,12 +311,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
sbi_hart_hang();
}
- rc = sbi_timer_init(scratch, true);
- if (rc) {
- sbi_printf("%s: timer init failed (error %d)\n", __func__, rc);
- sbi_hart_hang();
- }
-
rc = sbi_fwft_init(scratch, true);
if (rc) {
sbi_printf("%s: fwft init failed (error %d)\n", __func__, rc);
@@ -424,11 +422,15 @@ static void __noreturn init_warm_startup(struct sbi_scratch *scratch,
if (rc)
sbi_hart_hang();
- rc = sbi_platform_early_init(plat, false);
+ rc = sbi_hart_init(scratch, false);
if (rc)
sbi_hart_hang();
- rc = sbi_hart_init(scratch, false);
+ rc = sbi_timer_init(scratch, false);
+ if (rc)
+ sbi_hart_hang();
+
+ rc = sbi_platform_early_init(plat, false);
if (rc)
sbi_hart_hang();
@@ -452,10 +454,6 @@ static void __noreturn init_warm_startup(struct sbi_scratch *scratch,
if (rc)
sbi_hart_hang();
- rc = sbi_timer_init(scratch, false);
- if (rc)
- sbi_hart_hang();
-
rc = sbi_fwft_init(scratch, false);
if (rc)
sbi_hart_hang();