@@ -63,6 +63,11 @@ config PLATFORM_STARFIVE_JH7110
bool "StarFive JH7110 support"
default n
+config PLATFORM_THEAD_GENERIC
+ bool "T-HEAD generic support"
+ select THEAD_C9XX_CSR
+ default n
+
config PLATFORM_THEAD_TH1520
bool "T-HEAD TH1520 support"
select THEAD_C9XX_CSR
@@ -5,6 +5,7 @@ CONFIG_PLATFORM_SIFIVE_FU540=y
CONFIG_PLATFORM_SIFIVE_FU740=y
CONFIG_PLATFORM_SOPHGO_SG2042=y
CONFIG_PLATFORM_STARFIVE_JH7110=y
+CONFIG_PLATFORM_THEAD_GENERIC=y
CONFIG_PLATFORM_THEAD_TH1520=y
CONFIG_FDT_GPIO=y
CONFIG_FDT_GPIO_DESIGNWARE=y
@@ -12,5 +12,8 @@ platform-objs-$(CONFIG_THEAD_C9XX_PMU) += thead/thead_c9xx_pmu.o
platform-objs-$(CONFIG_THEAD_C9XX_ERRATA) += thead/thead_c9xx_tlb_trap_handler.o
platform-objs-$(CONFIG_THEAD_C9XX_ERRATA) += thead/thead_c9xx_errata_tlb_flush.o
+carray-platform_override_modules-$(CONFIG_PLATFORM_THEAD_GENERIC) += thead_generic
+platform-objs-$(CONFIG_PLATFORM_THEAD_GENERIC) += thead/thead-generic.o
+
carray-platform_override_modules-$(CONFIG_PLATFORM_THEAD_TH1520) += thead_th1520
platform-objs-$(CONFIG_PLATFORM_THEAD_TH1520) += thead/thead-th1520.o
new file mode 100644
@@ -0,0 +1,27 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Authors:
+ * Christoph Müllner <christoph.muellner@vrull.eu>
+ */
+
+#include <platform_override.h>
+#include <sbi/sbi_platform.h>
+#include <sbi_utils/fdt/fdt_helper.h>
+#include <thead/c9xx_csr.h>
+#include <thead/c9xx_encoding.h>
+
+static unsigned long thead_generic_vendor_ids[] = {
+ THEAD_VENDOR_ID,
+ 0,
+};
+
+static const struct fdt_match thead_generic_match[] = {
+ { },
+};
+
+const struct platform_override thead_generic = {
+ .match_table = thead_generic_match,
+ .match_vendor_ids = thead_generic_vendor_ids,
+ .read_csr = thead_c9xx_read_csr,
+};
Currently, we have support for three T-Head C9xx platforms: * Allwinner D1 * T-Head TH1520 * Sophgo SG2042 To make the platform detection more generic, let's add a T-Head generic override that matches on T-Head's vendor ID. Proper detection of T-Head harts is needed so we can insert the CSR read-handler for th.mxstatus. Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> --- platform/generic/Kconfig | 5 +++++ platform/generic/configs/defconfig | 1 + platform/generic/thead/objects.mk | 3 +++ platform/generic/thead/thead-generic.c | 27 ++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 platform/generic/thead/thead-generic.c