* [PATCH v8 1/3] dt-bindings: timer: mips,p8700-gcru
2026-06-10 8:22 [PATCH v8 0/3] riscv: Use GCR.U timer device as clocksource Aleksa Paunovic via B4 Relay
@ 2026-06-10 8:22 ` Aleksa Paunovic via B4 Relay
2026-06-10 8:26 ` sashiko-bot
2026-06-10 8:22 ` [PATCH v8 2/3] riscv: clocksource: Add readq options to clocksource mmio Aleksa Paunovic via B4 Relay
2026-06-10 8:22 ` [PATCH v8 3/3] riscv: clocksource: Add p8700-gcru driver Aleksa Paunovic via B4 Relay
2 siblings, 1 reply; 5+ messages in thread
From: Aleksa Paunovic via B4 Relay @ 2026-06-10 8:22 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Paul Walmsley, John Stultz, Stephen Boyd,
Vivian Wang
Cc: linux-kernel, devicetree, linux-riscv, Djordje Todorovic,
Aleksa Paunovic, Chao-ying Fu, Conor Dooley
From: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
Add dt-bindings for the GCR.U memory mapped timer device for RISC-V
platforms. The GCR.U memory region contains shadow copies of the RISC-V
mtime register and the hrtime Global Configuration Register.
Signed-off-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
.../devicetree/bindings/timer/mips,p8700-gcru.yaml | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/Documentation/devicetree/bindings/timer/mips,p8700-gcru.yaml b/Documentation/devicetree/bindings/timer/mips,p8700-gcru.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..3498255762cce6b3f491292d340d9639bb573e6d
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/mips,p8700-gcru.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/timer/mips,p8700-gcru.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: GCR.U timer device for the MIPS P8700 platform
+
+maintainers:
+ - Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
+
+description:
+ The GCR.U memory region contains memory mapped shadow copies of
+ mtime and hrtime Global Configuration Registers,
+ which software can choose to make accessible from user mode.
+
+properties:
+ compatible:
+ const: mips,p8700-gcru
+
+ reg:
+ items:
+ - description: Read-only shadow copy of the RISC-V mtime register.
+ - description: Read-only shadow copy of the P8700 high resolution timer register.
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ timer@1617f000 {
+ compatible = "mips,p8700-gcru";
+ reg = <0x1617f050 0x8>,
+ <0x1617f090 0x8>;
+ };
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v8 1/3] dt-bindings: timer: mips,p8700-gcru
2026-06-10 8:22 ` [PATCH v8 1/3] dt-bindings: timer: mips,p8700-gcru Aleksa Paunovic via B4 Relay
@ 2026-06-10 8:26 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-06-10 8:26 UTC (permalink / raw)
To: Aleksa Paunovic via B4 Relay; +Cc: robh, devicetree, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Mismatch between the node's unit-address and the first address in its 'reg' property in the device tree example.
--
commit 28ad318962744fd052dc7a14265d2214d613bc60
Author: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
dt-bindings: timer: mips,p8700-gcru
Add dt-bindings for the GCR.U memory mapped timer device for RISC-V
platforms. The GCR.U memory region contains shadow copies of the RISC-V
mtime register and the hrtime Global Configuration Register.
> diff --git a/Documentation/devicetree/bindings/timer/mips,p8700-gcru.yaml b/Documentation/devicetree/bindings/timer/mips,p8700-gcru.yaml
> new file mode 100644
> index 0000000000000..3498255762cce
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/mips,p8700-gcru.yaml
[ ... ]
> +examples:
> + - |
> + timer@1617f000 {
> + compatible = "mips,p8700-gcru";
> + reg = <0x1617f050 0x8>,
[Severity: Low]
Does the unit-address in the node name (1617f000) need to exactly match the
first address specified in the reg property (1617f050)? This mismatch will
likely trigger a unit_address_vs_reg warning during dt_binding_check.
> + <0x1617f090 0x8>;
> + };
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260610-riscv-time-mmio-v8-0-a865206675c6@htecgroup.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v8 2/3] riscv: clocksource: Add readq options to clocksource mmio
2026-06-10 8:22 [PATCH v8 0/3] riscv: Use GCR.U timer device as clocksource Aleksa Paunovic via B4 Relay
2026-06-10 8:22 ` [PATCH v8 1/3] dt-bindings: timer: mips,p8700-gcru Aleksa Paunovic via B4 Relay
@ 2026-06-10 8:22 ` Aleksa Paunovic via B4 Relay
2026-06-10 8:22 ` [PATCH v8 3/3] riscv: clocksource: Add p8700-gcru driver Aleksa Paunovic via B4 Relay
2 siblings, 0 replies; 5+ messages in thread
From: Aleksa Paunovic via B4 Relay @ 2026-06-10 8:22 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Paul Walmsley, John Stultz, Stephen Boyd,
Vivian Wang
Cc: linux-kernel, devicetree, linux-riscv, Djordje Todorovic,
Aleksa Paunovic, Chao-ying Fu
From: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
Add read functions for 64-bit register size to the generic
mmio clocksource, covering both up and down counters.
Signed-off-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
---
drivers/clocksource/mmio.c | 14 ++++++++++++++
include/linux/clocksource.h | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
index 9de75153183124cc8997c6ab61d0c01d9b2637bc..f3b6f7e93ffbf0ed68e56c58c3d9f711d2193caa 100644
--- a/drivers/clocksource/mmio.c
+++ b/drivers/clocksource/mmio.c
@@ -17,6 +17,20 @@ static inline struct clocksource_mmio *to_mmio_clksrc(struct clocksource *c)
return container_of(c, struct clocksource_mmio, clksrc);
}
+#if defined(CONFIG_64BIT) && defined(readq_relaxed)
+
+u64 clocksource_mmio_readq_up(struct clocksource *c)
+{
+ return (u64)readq_relaxed(to_mmio_clksrc(c)->reg);
+}
+
+u64 clocksource_mmio_readq_down(struct clocksource *c)
+{
+ return ~(u64)readq_relaxed(to_mmio_clksrc(c)->reg) & c->mask;
+}
+
+#endif
+
u64 clocksource_mmio_readl_up(struct clocksource *c)
{
return (u64)readl_relaxed(to_mmio_clksrc(c)->reg);
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 65b7c41471c390463770c2da13694e58e83b84ea..39e0df5a0ab52cbb7016b53a4d7500f2697e2797 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -276,6 +276,10 @@ static inline void clocksource_arch_init(struct clocksource *cs) { }
extern int timekeeping_notify(struct clocksource *clock);
+#if defined(CONFIG_64BIT) && defined(readq_relaxed)
+extern u64 clocksource_mmio_readq_up(struct clocksource *c);
+extern u64 clocksource_mmio_readq_down(struct clocksource *c);
+#endif
extern u64 clocksource_mmio_readl_up(struct clocksource *);
extern u64 clocksource_mmio_readl_down(struct clocksource *);
extern u64 clocksource_mmio_readw_up(struct clocksource *);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v8 3/3] riscv: clocksource: Add p8700-gcru driver
2026-06-10 8:22 [PATCH v8 0/3] riscv: Use GCR.U timer device as clocksource Aleksa Paunovic via B4 Relay
2026-06-10 8:22 ` [PATCH v8 1/3] dt-bindings: timer: mips,p8700-gcru Aleksa Paunovic via B4 Relay
2026-06-10 8:22 ` [PATCH v8 2/3] riscv: clocksource: Add readq options to clocksource mmio Aleksa Paunovic via B4 Relay
@ 2026-06-10 8:22 ` Aleksa Paunovic via B4 Relay
2 siblings, 0 replies; 5+ messages in thread
From: Aleksa Paunovic via B4 Relay @ 2026-06-10 8:22 UTC (permalink / raw)
To: Daniel Lezcano, Thomas Gleixner, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Paul Walmsley, John Stultz, Stephen Boyd,
Vivian Wang
Cc: linux-kernel, devicetree, linux-riscv, Djordje Todorovic,
Aleksa Paunovic, Chao-ying Fu
From: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
Add a clocksource driver for the P8700 GCRU.
Initialization uses helper functions
provided by clocksource/mmio.c and timer-of.c.
Since the GCRU does not support any kind of interrupts,
the default RISC-V clockevent implementation should suffice.
Signed-off-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
---
drivers/clocksource/Kconfig | 9 ++++++++
drivers/clocksource/Makefile | 1 +
drivers/clocksource/timer-p8700.c | 47 +++++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index ffcd23668763fe7707a4e917bf240caadbb09a8c..a775a301f3f08ca97699e46aaf3ccfaf99734e6b 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -672,6 +672,15 @@ config CLINT_TIMER
This option enables the CLINT timer for RISC-V systems. The CLINT
driver is usually used for NoMMU RISC-V systems.
+config P8700_TIMER
+ bool "MIPS P8700 timer driver"
+ depends on GENERIC_SCHED_CLOCK && RISCV && RISCV_SBI && 64BIT
+ select CLKSRC_MMIO
+ select TIMER_PROBE
+ select TIMER_OF
+ help
+ Enables support for MIPS P8700 timer driver.
+
config CSKY_MP_TIMER
bool "SMP Timer for the C-SKY platform" if COMPILE_TEST
depends on CSKY
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index ec4452ee958f1a814c708aeba6412bea61d24892..fae9a58d6c8663a7c857b9ab7fdae05782b3551c 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -95,3 +95,4 @@ obj-$(CONFIG_CLKSRC_LOONGSON1_PWM) += timer-loongson1-pwm.o
obj-$(CONFIG_EP93XX_TIMER) += timer-ep93xx.o
obj-$(CONFIG_RALINK_TIMER) += timer-ralink.o
obj-$(CONFIG_NXP_STM_TIMER) += timer-nxp-stm.o
+obj-$(CONFIG_P8700_TIMER) += timer-p8700.o
diff --git a/drivers/clocksource/timer-p8700.c b/drivers/clocksource/timer-p8700.c
new file mode 100644
index 0000000000000000000000000000000000000000..dd20b4e72fcdd77a6b33775f286d0945c2a2b659
--- /dev/null
+++ b/drivers/clocksource/timer-p8700.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2025 MIPS.
+ */
+
+#include <linux/sched_clock.h>
+#include <linux/delay.h>
+#include <linux/of_address.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/clocksource.h>
+
+#include "timer-of.h"
+
+static struct timer_of gcru_of = { .flags = TIMER_OF_BASE };
+static u64 __iomem *p8700_time_val __ro_after_init;
+
+static u64 notrace p8700_timer_sched_read(void)
+{
+ return (u64)readq_relaxed(p8700_time_val);
+}
+
+static int __init p8700_timer_init(struct device_node *node)
+{
+ int error = 0;
+
+ error = timer_of_init(node, &gcru_of);
+ if (error)
+ return error;
+
+ p8700_time_val = timer_of_base(&gcru_of);
+ /* Now init the mmio timer with the address we got from DT */
+ error = clocksource_mmio_init(p8700_time_val, "mips,p8700-gcru",
+ riscv_timebase, 450, 64,
+ clocksource_mmio_readq_up);
+ if (error) {
+ timer_of_cleanup(&gcru_of);
+ return error;
+ }
+
+ /* Sched clock */
+ sched_clock_register(p8700_timer_sched_read, 64, riscv_timebase);
+
+ return error;
+}
+
+TIMER_OF_DECLARE(p8700_timer, "mips,p8700-gcru", p8700_timer_init);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread