mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 07:41:42 +01:00
lib: Simplify sbi_platform early_init() and final_init() hooks
Instead of having separate early_init() and final_init() hooks for cold and warm boot, this patch updates struct sbi_platform to have just one early_init() and one final_init() hook. The type of boot (cold or warm) is now a boolean flag parameter for the updated early_init() and final_init() hooks. Signed-off-by: Anup Patel <anup.patel@wdc.com>
This commit is contained in:
@@ -102,8 +102,6 @@ struct sbi_platform platform = {
|
||||
.timer_event_start = clint_timer_event_start,
|
||||
.warm_timer_init = clint_warm_timer_init,
|
||||
|
||||
.cold_final_init = NULL,
|
||||
|
||||
.system_reboot = k210_system_reboot,
|
||||
.system_shutdown = k210_system_shutdown
|
||||
};
|
||||
|
@@ -29,11 +29,15 @@
|
||||
#define SIFIVE_U_UART0_ADDR 0x10013000
|
||||
#define SIFIVE_U_UART1_ADDR 0x10023000
|
||||
|
||||
static int sifive_u_cold_final_init(void)
|
||||
static int sifive_u_final_init(u32 hartid, bool cold_boot)
|
||||
{
|
||||
u32 i;
|
||||
void *fdt = sbi_scratch_thishart_arg1_ptr();
|
||||
void *fdt;
|
||||
|
||||
if (!cold_boot)
|
||||
return 0;
|
||||
|
||||
fdt = sbi_scratch_thishart_arg1_ptr();
|
||||
for (i = 0; i < SIFIVE_U_HART_COUNT; i++)
|
||||
plic_fdt_fixup(fdt, "riscv,plic0", 2 * i);
|
||||
|
||||
@@ -110,7 +114,7 @@ struct sbi_platform platform = {
|
||||
.disabled_hart_mask = 0,
|
||||
.pmp_region_count = sifive_u_pmp_region_count,
|
||||
.pmp_region_info = sifive_u_pmp_region_info,
|
||||
.cold_final_init = sifive_u_cold_final_init,
|
||||
.final_init = sifive_u_final_init,
|
||||
.console_putc = sifive_uart_putc,
|
||||
.console_getc = sifive_uart_getc,
|
||||
.console_init = sifive_u_console_init,
|
||||
|
@@ -29,11 +29,15 @@
|
||||
#define VIRT_UART_BAUDRATE 115200
|
||||
#define VIRT_UART_SHIFTREG_ADDR 1843200
|
||||
|
||||
static int virt_cold_final_init(void)
|
||||
static int virt_final_init(u32 hartid, bool cold_boot)
|
||||
{
|
||||
u32 i;
|
||||
void *fdt = sbi_scratch_thishart_arg1_ptr();
|
||||
void *fdt;
|
||||
|
||||
if (!cold_boot)
|
||||
return 0;
|
||||
|
||||
fdt = sbi_scratch_thishart_arg1_ptr();
|
||||
for (i = 0; i < VIRT_HART_COUNT; i++)
|
||||
plic_fdt_fixup(fdt, "riscv,plic0", 2 * i);
|
||||
|
||||
@@ -111,7 +115,7 @@ struct sbi_platform platform = {
|
||||
.disabled_hart_mask = 0,
|
||||
.pmp_region_count = virt_pmp_region_count,
|
||||
.pmp_region_info = virt_pmp_region_info,
|
||||
.cold_final_init = virt_cold_final_init,
|
||||
.final_init = virt_final_init,
|
||||
.console_putc = uart8250_putc,
|
||||
.console_getc = uart8250_getc,
|
||||
.console_init = virt_console_init,
|
||||
|
@@ -38,11 +38,15 @@
|
||||
#define SIFIVE_PRCI_CLKMUXSTATUSREG 0x002C
|
||||
#define SIFIVE_PRCI_CLKMUX_STATUS_TLCLKSEL (0x1 << 1)
|
||||
|
||||
static int sifive_u_cold_final_init(void)
|
||||
static int sifive_u_final_init(u32 hartid, bool cold_boot)
|
||||
{
|
||||
u32 i;
|
||||
void *fdt = sbi_scratch_thishart_arg1_ptr();
|
||||
void *fdt;
|
||||
|
||||
if (!cold_boot)
|
||||
return 0;
|
||||
|
||||
fdt = sbi_scratch_thishart_arg1_ptr();
|
||||
plic_fdt_fixup(fdt, "riscv,plic0", 0);
|
||||
for (i = 1; i < SIFIVE_U_HART_COUNT; i++)
|
||||
plic_fdt_fixup(fdt, "riscv,plic0", 2 * i - 1);
|
||||
@@ -130,7 +134,7 @@ struct sbi_platform platform = {
|
||||
.disabled_hart_mask = ~(1 << SIFIVE_U_HARITD_ENABLED),
|
||||
.pmp_region_count = sifive_u_pmp_region_count,
|
||||
.pmp_region_info = sifive_u_pmp_region_info,
|
||||
.cold_final_init = sifive_u_cold_final_init,
|
||||
.final_init = sifive_u_final_init,
|
||||
.console_putc = sifive_uart_putc,
|
||||
.console_getc = sifive_uart_getc,
|
||||
.console_init = sifive_u_console_init,
|
||||
|
Reference in New Issue
Block a user