mips: add an option to support initialize SRAM for initial stack
authorWeijie Gao <weijie.gao@mediatek.com>
Tue, 21 Apr 2020 07:28:27 +0000 (09:28 +0200)
committerDaniel Schwierzeck <daniel.schwierzeck@gmail.com>
Mon, 27 Apr 2020 18:29:33 +0000 (20:29 +0200)
Currently CONFIG_MIPS_INIT_STACK_IN_SRAM assumes the memory space for the
initial stack can be used directly. However on some platform the SRAM needs
initialization, e.g. lock cache.

This patch adds an option to allow a new function mips_sram_init() being
called before setup_stack_gd.

Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
arch/mips/Kconfig
arch/mips/cpu/start.S

index b76ad8c..f7439c4 100644 (file)
@@ -425,6 +425,15 @@ config MIPS_INIT_STACK_IN_SRAM
          lowlevel_init. Thus lowlevel_init does not need to be implemented
          in assembler.
 
+config MIPS_SRAM_INIT
+       bool
+       default n
+       depends on MIPS_INIT_STACK_IN_SRAM
+       help
+         Select this if the SRAM for initial stack needs to be initialized
+         before it can be used. If enabled, a function mips_sram_init() will
+         be called just before setup_stack_gd.
+
 config SYS_DCACHE_SIZE
        int
        default 0
index 784b8be..dd93df9 100644 (file)
@@ -217,6 +217,13 @@ wr_done:
 #endif
 
 #ifdef CONFIG_MIPS_INIT_STACK_IN_SRAM
+#ifdef CONFIG_MIPS_SRAM_INIT
+       /* Initialize the SRAM first */
+       PTR_LA  t9, mips_sram_init
+       jalr    t9
+        nop
+#endif
+
        /* Set up initial stack and global data */
        setup_stack_gd