mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clocksource/drivers/sun5i: Allow enabling the driver on 64-bit sunxi
@ 2026-11-10  6:07 Arun Iyengar via B4 Relay
  2026-11-11  7:32 ` Chen-Yu Tsai
  0 siblings, 1 reply; 3+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-10  6:07 UTC (permalink / raw)
  To: Daniel Lezcano, Thomas Gleixner
  Cc: linux-kernel, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	Michal Piekos, linux-arm-kernel, linux-sunxi

From: Arun Iyengar <aiyengar1990@gmail.com>

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.

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@gmail.com>
---
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
 	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
+	  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.
+
 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@gmail.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource/drivers/sun5i: Allow enabling the driver on 64-bit sunxi
  2026-11-10  6:07 [PATCH] clocksource/drivers/sun5i: Allow enabling the driver on 64-bit sunxi Arun Iyengar via B4 Relay
@ 2026-11-11  7:32 ` Chen-Yu Tsai
  2026-11-12  9:24   ` Arun Iyengar
  0 siblings, 1 reply; 3+ messages in thread
From: Chen-Yu Tsai @ 2026-11-11  7:32 UTC (permalink / raw)
  To: aiyengar1990
  Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel, Jernej Skrabec,
	Samuel Holland, Michal Piekos, linux-arm-kernel, linux-sunxi

On Tue, Nov 10, 2026 at 3:07 PM Arun Iyengar via B4 Relay
<devnull+aiyengar1990.gmail.com@kernel.org> wrote:
>
> From: Arun Iyengar <aiyengar1990@gmail.com>
>
> 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@gmail.com>
> ---
> 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@gmail.com>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource/drivers/sun5i: Allow enabling the driver on 64-bit sunxi
  2026-11-11  7:32 ` Chen-Yu Tsai
@ 2026-11-12  9:24   ` Arun Iyengar
  0 siblings, 0 replies; 3+ messages in thread
From: Arun Iyengar @ 2026-11-12  9:24 UTC (permalink / raw)
  To: wens
  Cc: Daniel Lezcano, Thomas Gleixner, linux-kernel, Jernej Skrabec,
	Samuel Holland, Michal Piekos, linux-arm-kernel, linux-sunxi

Hi Chen-Yu,

On Wed, Nov 11, 2026, Chen-Yu Tsai wrote:
> 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.

Thanks for the review. You're right: with its rating below both the
architected timer and the sun4i timer, the kernel never picks it, and I
have no use case that would. I'll drop this patch.

Best regards,
Arun

On Tue, Nov 10, 2026 at 11:33 PM Chen-Yu Tsai <wens@kernel.org> wrote:
>
> On Tue, Nov 10, 2026 at 3:07 PM Arun Iyengar via B4 Relay
> <devnull+aiyengar1990.gmail.com@kernel.org> wrote:
> >
> > From: Arun Iyengar <aiyengar1990@gmail.com>
> >
> > 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@gmail.com>
> > ---
> > 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@gmail.com>
> >
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-12  9:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10  6:07 [PATCH] clocksource/drivers/sun5i: Allow enabling the driver on 64-bit sunxi Arun Iyengar via B4 Relay
2026-11-11  7:32 ` Chen-Yu Tsai
2026-11-12  9:24   ` Arun Iyengar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®