Re: [PATCH] clocksource/drivers/sun5i: Allow enabling the driver on 64-bit sunxi

From: Chen-Yu Tsai

Date: Wed Nov 11 2026 - 02:35:10 EST


On Tue, Nov 10, 2026 at 3:07 PM Arun Iyengar via B4 Relay
<devnull+aiyengar1990.gmail.com@xxxxxxxxxx> wrote:
>
> From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
>
> The high-speed timer driver binds "allwinner,sun20i-d1-hstimer", which
> the H616 device tree uses as the fallback compatible of its
> "allwinner,sun50i-h616-hstimer" node and the D1/T113 device tree uses
> directly. SUN5I_HSTIMER, however, only has a prompt under COMPILE_TEST
> and is selected by the 32-bit sunxi machine Kconfig alone, so arm64 and
> RISC-V sunxi kernels cannot enable it and these nodes never probe.

This could be simplified: the high speed timer is available on many
newer platforms, but it is only selected by the few original platforms,
and not visible to the user.

> Make the prompt visible on ARCH_SUNXI. The driver registers its
> clocksource and clockevent at rating 340: below the architected timer's
> clocksource (400) and below the sun4i timer (350), which ARCH_SUNXI
> already selects on arm64 and RISC-V. Enabling it therefore adds a
> second hardware time base without changing which one the kernel uses.
>
> Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
> ---
> The H616 and D1/T113 hstimer nodes and the D1 driver support were merged
> for 7.2, but the driver still cannot be enabled outside COMPILE_TEST on
> arm64 and RISC-V.
>
> Tested on an Orange Pi Zero2 (H616) with a 7.3 kernel carrying this
> patch and CONFIG_SUN5I_HSTIMER=y: the hstimer node at 0x3005000
> probes and available_clocksource lists "arch_sys_counter timer
> hstimer".
>
> This patch was developed with Claude (Anthropic) as a coding
> assistant. It investigated the problem and wrote the code and the commit
> message; I reviewed it, and it was tested on an Orange Pi Zero2 (H616)
> as described above.
> ---
> drivers/clocksource/Kconfig | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index da83483296d5..971491d2e584 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -172,12 +172,17 @@ config SUN4I_TIMER
> Enables support for the Sun4i timer.
>
> config SUN5I_HSTIMER
> - bool "Sun5i timer driver" if COMPILE_TEST
> + bool "Sun5i timer driver" if COMPILE_TEST || ARCH_SUNXI

Nit: I would probably write "if ARCH_SUNXI || COMPILE_TEST" just to match
the other instances.

> select CLKSRC_MMIO
> depends on COMMON_CLK
> help
> Enables support the Sun5i timer.
>
> + The 32-bit sunxi platforms that have this timer select it. On

"selected"? BTW I think we can drop the "selects" from those platforms
if the option is now visible to the user.

> + 64-bit (ARM64, RISC-V) sunxi SoCs such as the H616 and D1 it
> + registers an additional clocksource and clockevent device, rated
> + below the ones the kernel already uses there.
> +

This doesn't really say _why_ a user might want to enable it though.
The only reason to do so is to get a higher resolution timer, but
the rating for sun5i-timer is lower than sun4i-timer for both clocksource
and clockevents. Realistically speaking this is never going to get used.


ChenYu

> config TEGRA_TIMER
> bool "Tegra timer driver" if COMPILE_TEST
> select CLKSRC_MMIO
>
> ---
> base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
> change-id: 20261110-sun5i-hstimer-arch-sunxi-167ea2ebcbd7
>
> Best regards,
> --
> Arun Iyengar <aiyengar1990@xxxxxxxxx>
>
>