diff --git a/arch/risc-v/src/mpfs/mpfs_opensbi.c b/arch/risc-v/src/mpfs/mpfs_opensbi.c index 058bb2d8b7..5627f857e8 100644 --- a/arch/risc-v/src/mpfs/mpfs_opensbi.c +++ b/arch/risc-v/src/mpfs/mpfs_opensbi.c @@ -22,25 +22,12 @@ * Included Files ****************************************************************************/ -#include -#include -#include -#include -#include "riscv_arch.h" - #include #include #include #include -/* OpenSBI will also define NULL. Undefine NULL in order to avoid warning: - * 'warning: "NULL" redefined' - */ - -#ifdef NULL - #undef NULL -#endif - +#include #include #include #include @@ -251,8 +238,6 @@ static const uint64_t sbi_entrypoints[] = static unsigned long mpfs_hart_to_scratch(int hartid) { - DEBUGASSERT(hartid < MPFS_MAX_NUM_HARTS); - return (unsigned long)(&g_scratches[hartid].scratch); } @@ -425,6 +410,8 @@ static int mpfs_timer_init(bool cold_boot) static int mpfs_early_init(bool cold_boot) { + uint32_t val; + /* We expect that e51 has terminated the following irqs with * up_disable_irq(): * 1. MPFS_IRQ_MMC_MAIN @@ -441,15 +428,16 @@ static int mpfs_early_init(bool cold_boot) /* Explicitly reset eMMC */ - modifyreg32(MPFS_SYSREG_SOFT_RESET_CR, 0, SYSREG_SOFT_RESET_CR_MMC); - modifyreg32(MPFS_SYSREG_SOFT_RESET_CR, SYSREG_SOFT_RESET_CR_MMC, 0); + val = readl((void *)MPFS_SYSREG_SOFT_RESET_CR); + writel(val | SYSREG_SOFT_RESET_CR_MMC, (void *)MPFS_SYSREG_SOFT_RESET_CR); + writel(val & ~SYSREG_SOFT_RESET_CR_MMC, (void *)MPFS_SYSREG_SOFT_RESET_CR); /* There are other clocks that need to be enabled for the Linux kernel to * run. For now, turn on all the clocks. */ - putreg32(0x0, MPFS_SYSREG_SOFT_RESET_CR); - putreg32(0x7fffffff, MPFS_SYSREG_SUBBLK_CLOCK_CR); + writel(0x0, (void *)MPFS_SYSREG_SOFT_RESET_CR); + writel(0x7fffffff, (void *)MPFS_SYSREG_SUBBLK_CLOCK_CR); return 0; } @@ -472,8 +460,6 @@ static int mpfs_early_init(bool cold_boot) static void mpfs_opensbi_scratch_setup(uint32_t hartid) { - DEBUGASSERT(hartid < MPFS_MAX_NUM_HARTS); - g_scratches[hartid].scratch.options = SBI_SCRATCH_DEBUG_PRINTS; g_scratches[hartid].scratch.hartid_to_scratch = (unsigned long)mpfs_hart_to_scratch; @@ -487,8 +473,6 @@ static void mpfs_opensbi_scratch_setup(uint32_t hartid) g_scratches[hartid].scratch.fw_start = (unsigned long)&__mpfs_nuttx_start; g_scratches[hartid].scratch.fw_size = (unsigned long)&__mpfs_nuttx_end - (unsigned long)&__mpfs_nuttx_start; - - DEBUGASSERT(g_scratches[hartid].scratch.fw_size > 0); } /**************************************************************************** @@ -556,5 +540,5 @@ void __attribute__((noreturn)) mpfs_opensbi_setup(void) /* Will never get here */ - PANIC(); + sbi_panic(__func__); }