Provide a generic CPU type with some common routines that expected to be implemented at CPU level.
Signed-off-by: Jiaxun Yang <jiaxun.y...@flygoat.com> --- arch/loongarch/Kconfig | 1 + arch/loongarch/cpu/generic/Kconfig | 13 +++++++++++++ arch/loongarch/cpu/generic/Makefile | 7 +++++++ arch/loongarch/cpu/generic/cpu.c | 22 ++++++++++++++++++++++ arch/loongarch/cpu/generic/dram.c | 21 +++++++++++++++++++++ 5 files changed, 64 insertions(+) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 109d37d8e2c7..5254afb2cd05 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -12,6 +12,7 @@ endchoice # board-specific options below # platform-specific options below +source "arch/loongarch/cpu/generic/Kconfig" # architecture-specific options below choice diff --git a/arch/loongarch/cpu/generic/Kconfig b/arch/loongarch/cpu/generic/Kconfig new file mode 100644 index 000000000000..ac7556d6d4d0 --- /dev/null +++ b/arch/loongarch/cpu/generic/Kconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2024 Jiaxun yang <jiaxun.y...@flygoat.com> +# + +config GENERIC_LOONGARCH + bool + select SYS_CACHE_SHIFT_6 + imply CPU + imply CPU_LOONGARCH + imply LOONGARCH_TIMER + imply CMD_CPU + diff --git a/arch/loongarch/cpu/generic/Makefile b/arch/loongarch/cpu/generic/Makefile new file mode 100644 index 000000000000..c98d63b4f831 --- /dev/null +++ b/arch/loongarch/cpu/generic/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2024 Jiaxun yang <jiaxun.y...@flygoat.com> +# + +obj-y += dram.o +obj-y += cpu.o diff --git a/arch/loongarch/cpu/generic/cpu.c b/arch/loongarch/cpu/generic/cpu.c new file mode 100644 index 000000000000..5c849faf2bac --- /dev/null +++ b/arch/loongarch/cpu/generic/cpu.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2024 Jiaxun Yang <jiaxun.y...@flygoat.com> + */ + +#include <irq_func.h> +#include <asm/cache.h> + +/* + * cleanup_before_linux() is called just before we call linux + * it prepares the processor for linux + * + * we disable interrupt and caches. + */ +int cleanup_before_linux(void) +{ + disable_interrupts(); + + cache_flush(); + + return 0; +} diff --git a/arch/loongarch/cpu/generic/dram.c b/arch/loongarch/cpu/generic/dram.c new file mode 100644 index 000000000000..101b45786194 --- /dev/null +++ b/arch/loongarch/cpu/generic/dram.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2024 Jiaxun Yang <jiaxun.y...@flygoat.com> + */ + +#include <fdtdec.h> +#include <init.h> +#include <asm/global_data.h> +#include <linux/sizes.h> + +DECLARE_GLOBAL_DATA_PTR; + +int dram_init(void) +{ + return fdtdec_setup_mem_size_base_lowest(); +} + +int dram_init_banksize(void) +{ + return fdtdec_setup_memory_banksize(); +} -- 2.43.0