[PATCH v1 2/4] clocksource: arm_architected_timer: support clock-frequency
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jul 30 01:13:06 PDT 2025
On 7/29/25 22:36, Ivaylo Ivanov wrote:
> Some platforms, like the Samsung Galaxy S8, leave CNTFRQ_EL0 unset in
> the previous stage bootloader. Therefore reading it causes a hang and
> the boot proccess is halted.
>
> Since on such retail devices there is no way to set it without replacing
> the entire boot chain, allow setting a value from clock-frequency
> whenever it's passed.
>
> Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1 at gmail.com>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
Linux does this too, so I think regressions are unlikely.
Cheers,
Ahmad
> ---
> drivers/clocksource/arm_architected_timer.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/arm_architected_timer.c b/drivers/clocksource/arm_architected_timer.c
> index 9a1f2d2b..daced94c 100644
> --- a/drivers/clocksource/arm_architected_timer.c
> +++ b/drivers/clocksource/arm_architected_timer.c
> @@ -24,7 +24,16 @@ static struct clocksource cs = {
>
> static int arm_arch_timer_probe(struct device *dev)
> {
> - cs.mult = clocksource_hz2mult(get_cntfrq(), cs.shift);
> + u32 cntfrq;
> + int ret;
> +
> + /* Some platforms don't set CNTFRQ_EL0 before barebox */
> + ret = of_property_read_u32(dev->of_node, "clock-frequency", &cntfrq);
> +
> + if (ret)
> + cntfrq = get_cntfrq();
> +
> + cs.mult = clocksource_hz2mult(cntfrq, cs.shift);
>
> return init_clock(&cs);
> }
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list