[PATCH 2/2] lib: utils/timer: mtimer: add MIPS P8700 compatible

Benoît Monin benoit.monin at bootlin.com
Thu Oct 9 08:09:40 PDT 2025


The MTIMER of the MIPS P8700 is compliant with the ACLINT specification,
so add a compatible string for it.

In a multi-cluster configuration, there is one MTIMER per cluster, each
associated with the HARTS of the cluster. To be able to select a
reference MTIMER in that case, add a quirk to select any MTIMER as the
reference. The first parsed will be used as the reference to
synchronize the others.

Signed-off-by: Benoît Monin <benoit.monin at bootlin.com>
---
 lib/utils/timer/fdt_timer_mtimer.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c
index 224534d..9175363 100644
--- a/lib/utils/timer/fdt_timer_mtimer.c
+++ b/lib/utils/timer/fdt_timer_mtimer.c
@@ -20,6 +20,7 @@ struct timer_mtimer_quirks {
 	unsigned int	clint_mtime_offset;
 	bool		clint_without_mtime;
 	bool		has_64bit_mmio;
+	bool		use_any_ref;
 };
 
 struct timer_mtimer_node {
@@ -39,6 +40,7 @@ static int timer_mtimer_cold_init(const void *fdt, int nodeoff,
 	struct aclint_mtimer_data *mt;
 	const struct timer_mtimer_quirks *quirks = match->data;
 	bool is_clint = quirks && quirks->is_clint;
+	bool use_any_ref = quirks && quirks->use_any_ref;
 
 	mtn = sbi_zalloc(sizeof(*mtn));
 	if (!mtn)
@@ -116,7 +118,7 @@ static int timer_mtimer_cold_init(const void *fdt, int nodeoff,
 	 * define an optional DT property or some other mechanism to
 	 * help us select the reference MTIMER device.
 	 */
-	if (!mt->hart_count && !mt_reference) {
+	if ((!mt->hart_count || use_any_ref) && !mt_reference) {
 		mt_reference = mt;
 		/*
 		 * Set reference for already propbed MTIMER devices
@@ -152,12 +154,18 @@ static const struct timer_mtimer_quirks thead_aclint_quirks = {
 	.has_64bit_mmio		= false,
 };
 
+static const struct timer_mtimer_quirks mips_aclint_quirks = {
+	.use_any_ref		= true,
+};
+
 static const struct fdt_match timer_mtimer_match[] = {
 	{ .compatible = "riscv,clint0", .data = &sifive_clint_quirks },
 	{ .compatible = "sifive,clint0", .data = &sifive_clint_quirks },
 	{ .compatible = "thead,c900-clint", .data = &thead_clint_quirks },
 	{ .compatible = "thead,c900-aclint-mtimer",
 	  .data = &thead_aclint_quirks },
+	{ .compatible = "mips,p8700-aclint-mtimer",
+	  .data = &mips_aclint_quirks },
 	{ .compatible = "riscv,aclint-mtimer" },
 	{ },
 };

-- 
2.51.0




More information about the opensbi mailing list