diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig index 688da3f4ac..c28ec88b1d 100644 --- a/platform/generic/Kconfig +++ b/platform/generic/Kconfig @@ -58,6 +58,11 @@ config PLATFORM_SOPHGO_SG2042 select THEAD_C9XX_PMU default n +config PLATFORM_SOPHGO_SG2044 + bool "Sophgo sg2044 support" + select THEAD_C9XX_PMU + default n + config PLATFORM_STARFIVE_JH7110 bool "StarFive JH7110 support" default n diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig index 079bc4fef8..dc563801de 100644 --- a/platform/generic/configs/defconfig +++ b/platform/generic/configs/defconfig @@ -4,6 +4,7 @@ CONFIG_PLATFORM_RENESAS_RZFIVE=y CONFIG_PLATFORM_SIFIVE_FU540=y CONFIG_PLATFORM_SIFIVE_FU740=y CONFIG_PLATFORM_SOPHGO_SG2042=y +CONFIG_PLATFORM_SOPHGO_SG2044=y CONFIG_PLATFORM_STARFIVE_JH7110=y CONFIG_PLATFORM_THEAD=y CONFIG_FDT_GPIO=y diff --git a/platform/generic/sophgo/objects.mk b/platform/generic/sophgo/objects.mk index 3d2908ad12..022f6a7e47 100644 --- a/platform/generic/sophgo/objects.mk +++ b/platform/generic/sophgo/objects.mk @@ -7,3 +7,5 @@ carray-platform_override_modules-$(CONFIG_PLATFORM_SOPHGO_SG2042) += sophgo_sg2042 platform-objs-$(CONFIG_PLATFORM_SOPHGO_SG2042) += sophgo/sg2042.o +carray-platform_override_modules-$(CONFIG_PLATFORM_SOPHGO_SG2044) += sophgo_sg2044 +platform-objs-$(CONFIG_PLATFORM_SOPHGO_SG2044) += sophgo/sg2044.o diff --git a/platform/generic/sophgo/sg2044.c b/platform/generic/sophgo/sg2044.c new file mode 100644 index 0000000000..9b1bd189eb --- /dev/null +++ b/platform/generic/sophgo/sg2044.c @@ -0,0 +1,49 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) + * + * Authors: + * Inochi Amaoto + * YuQing Cai + * ZhenYu Zhang <1204122531@qq.com> + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static u32 selected_hartid = -1; + +static bool sg2044_cold_boot_allowed(u32 hartid, + const struct fdt_match *match) +{ + if (selected_hartid != -1) + return (selected_hartid == hartid); + + return true; +} + +static int sg2044_extensions_init(const struct fdt_match *match, + struct sbi_hart_features *hfeatures) +{ + thead_c9xx_register_pmu_device(); + return 0; +} + +static const struct fdt_match sophgo_sg2044_match[] = { + { .compatible = "sophgo,sg2044" }, + { }, +}; + +const struct platform_override sophgo_sg2044 = { + .match_table = sophgo_sg2044_match, + .cold_boot_allowed = sg2044_cold_boot_allowed, + .extensions_init = sg2044_extensions_init, +};