Subject: [PATCH 1/1] ARM:lib32: add architected timer

Renaud Barbier Renaud.Barbier at ametek.com
Mon Mar 6 05:13:06 PST 2023


> > ---
> >  arch/arm/lib32/Makefile                |  2 ++
> >  arch/arm/lib32/arm_architected_timer.c | 17 +++++++++++++++++
> >  include/clock.h                        |  2 ++
> >  3 files changed, 21 insertions(+)
> > --- /dev/null
> > +++ b/arch/arm/lib32/arm_architected_timer.c
> > @@ -0,0 +1,17 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +
> > +#include <asm/system.h>
> > +#include <clock.h>
> > +#include <common.h>
> > +
> > +/* Unlike the ARMv8, the timer is not generic to ARM32 */ void
> > +arm_architected_timer_udelay(unsigned long us) {
> > +     unsigned long long ticks, cntfrq = get_cntfrq();
> > +     unsigned long long start = get_cntpct();
> > +
> > +     ticks = us * cntfrq + 999999;
> > +     do_div(ticks, 1000000);
> 
> There's DIV_ROUND_UP_ULL you could use instead of opencoding that.
> I see that we round down in the udelay for ARM64.
> Do you think we should rather be rounding up there too?
> 
> In any case, it's worth mentioning why you choose to round up here in the
> commit message.
> 
 I must have picked up these two lines of code somewhere because I had to use do_div as I was getting an error: " undefined reference to `__udivdi3'"
To round down I will use DIV_ROUND_DOWN_ULL instead. 
Thanks you for pointing this out. 


More information about the barebox mailing list