riscv: Add SOC early init support
authorDamien Le Moal <damien.lemoal@wdc.com>
Mon, 16 Mar 2020 00:47:38 +0000 (09:47 +0900)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Fri, 3 Apr 2020 17:46:43 +0000 (10:46 -0700)
commit335b139057ef79dbede01dea6e8c3f47c2b88802
treea00fb4785ff526dbca683b360e2239cad46c7487
parent956d705dd279f70d5a222375fa97b637d6e8c43d
riscv: Add SOC early init support

Add a mechanism for early SoC initialization for platforms that need
additional hardware initialization not possible through the regular
device tree and drivers mechanism. With this, a SoC specific
initialization function can be called very early, before DTB parsing
is done by parse_dtb() in Linux RISC-V kernel setup code.

This can be very useful for early hardware initialization for No-MMU
kernels booted directly in M-mode because it is quite likely that no
other booting stage exist prior to the No-MMU kernel.

Example use of a SoC early initialization is as follows:

static void vendor_abc_early_init(const void *fdt)
{
/*
 * some early init code here that can use simple matches
 * against the flat device tree file.
 */
}
SOC_EARLY_INIT_DECLARE("vendor,abc", abc_early_init);

This early initialization function is executed only if the flat device
tree for the board has a 'compatible = "vendor,abc"' entry;

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
arch/riscv/include/asm/soc.h [new file with mode: 0644]
arch/riscv/kernel/Makefile
arch/riscv/kernel/head.S
arch/riscv/kernel/soc.c [new file with mode: 0644]
arch/riscv/kernel/vmlinux.lds.S