diff mbox series

[v2,02/12] mach-sunxi: Move timer code to mach folder

Message ID 20220126135329.2997430-3-Mr.Bossman075@gmail.com
State Superseded
Delegated to: Andre Przywara
Headers show
Series Add support for SUNIV and F1C100s. | expand

Commit Message

Jesse T Jan. 26, 2022, 1:53 p.m. UTC
Both armv7 and arm926ejs use this timer code so move it to mach-sunxi.

Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
---
V1->V2:
* New commit
---
 arch/arm/mach-sunxi/Makefile                     | 3 +++
 arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c | 7 ++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
 rename arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c (97%)

Comments

Andre Przywara Jan. 27, 2022, 10:21 a.m. UTC | #1
On Wed, 26 Jan 2022 08:53:19 -0500
Jesse Taube <mr.bossman075@gmail.com> wrote:

> Both armv7 and arm926ejs use this timer code so move it to mach-sunxi.

Very nice, thanks for cleaning this up.

But please remove the respective line from the Makefile in
arch/arm/cpu/armv7/sunxi/, otherwise 32-bit board builds fail:
make[2]: *** No rule to make target 'arch/arm/cpu/armv7/sunxi/timer.o' ...

Cheers,
Andre

> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
> ---
> V1->V2:
> * New commit
> ---
>  arch/arm/mach-sunxi/Makefile                     | 3 +++
>  arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c | 7 ++++---
>  2 files changed, 7 insertions(+), 3 deletions(-)
>  rename arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c (97%)
> 
> diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
> index 5d3fd70f74..b1adb75e17 100644
> --- a/arch/arm/mach-sunxi/Makefile
> +++ b/arch/arm/mach-sunxi/Makefile
> @@ -25,6 +25,9 @@ obj-$(CONFIG_MACH_SUN8I)	+= clock_sun6i.o
>  endif
>  obj-$(CONFIG_MACH_SUN9I)	+= clock_sun9i.o gtbus_sun9i.o
>  obj-$(CONFIG_SUN50I_GEN_H6)	+= clock_sun50i_h6.o
> +ifndef CONFIG_ARM64
> +obj-y	+= timer.o
> +endif
>  
>  ifdef CONFIG_SPL_BUILD
>  obj-$(CONFIG_DRAM_SUN4I)	+= dram_sun4i.o
> diff --git a/arch/arm/cpu/armv7/sunxi/timer.c b/arch/arm/mach-sunxi/timer.c
> similarity index 97%
> rename from arch/arm/cpu/armv7/sunxi/timer.c
> rename to arch/arm/mach-sunxi/timer.c
> index b758599636..fc9d419a25 100644
> --- a/arch/arm/cpu/armv7/sunxi/timer.c
> +++ b/arch/arm/mach-sunxi/timer.c
> @@ -51,6 +51,7 @@ int timer_init(void)
>  	struct sunxi_timer_reg *timers =
>  		(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
>  	struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
> +
>  	writel(TIMER_LOAD_VAL, &timer->inter);
>  	writel(TIMER_MODE | TIMER_DIV | TIMER_SRC | TIMER_RELOAD | TIMER_EN,
>  	       &timer->ctl);
> @@ -58,15 +59,14 @@ int timer_init(void)
>  	return 0;
>  }
>  
> -/* timer without interrupts */
>  static ulong get_timer_masked(void)
>  {
>  	/* current tick value */
>  	ulong now = TICKS_TO_HZ(read_timer());
>  
> -	if (now >= gd->arch.lastinc)	/* normal (non rollover) */
> +	if (now >= gd->arch.lastinc) {	/* normal (non rollover) */
>  		gd->arch.tbl += (now - gd->arch.lastinc);
> -	else {
> +	} else {
>  		/* rollover */
>  		gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL)
>  				- gd->arch.lastinc) + now;
> @@ -76,6 +76,7 @@ static ulong get_timer_masked(void)
>  	return gd->arch.tbl;
>  }
>  
> +/* timer without interrupts */
>  ulong get_timer(ulong base)
>  {
>  	return get_timer_masked() - base;
Jesse T Jan. 27, 2022, 8:40 p.m. UTC | #2
On 1/27/22 05:21, Andre Przywara wrote:
> On Wed, 26 Jan 2022 08:53:19 -0500
> Jesse Taube <mr.bossman075@gmail.com> wrote:
> 
>> Both armv7 and arm926ejs use this timer code so move it to mach-sunxi.
> 
> Very nice, thanks for cleaning this up.
> 
> But please remove the respective line from the Makefile in
> arch/arm/cpu/armv7/sunxi/, otherwise 32-bit board builds fail:
> make[2]: *** No rule to make target 'arch/arm/cpu/armv7/sunxi/timer.o' ...
Oh my I'm very sorry about this. There is one thing though 
arch/arm/cpu/armv7/sunxi/ needs to have one .o file in there to compile.
If I remove `ifdef CONFIG_SPL_BUILD` for fel_utils it will work but its 
not used in u-boot proper.
> Cheers,
> Andre
> 
>> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
>> ---
>> V1->V2:
>> * New commit
>> ---
>>   arch/arm/mach-sunxi/Makefile                     | 3 +++
>>   arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c | 7 ++++---
>>   2 files changed, 7 insertions(+), 3 deletions(-)
>>   rename arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c (97%)
>>
>> diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
>> index 5d3fd70f74..b1adb75e17 100644
>> --- a/arch/arm/mach-sunxi/Makefile
>> +++ b/arch/arm/mach-sunxi/Makefile
>> @@ -25,6 +25,9 @@ obj-$(CONFIG_MACH_SUN8I)	+= clock_sun6i.o
>>   endif
>>   obj-$(CONFIG_MACH_SUN9I)	+= clock_sun9i.o gtbus_sun9i.o
>>   obj-$(CONFIG_SUN50I_GEN_H6)	+= clock_sun50i_h6.o
>> +ifndef CONFIG_ARM64
>> +obj-y	+= timer.o
>> +endif
>>   
>>   ifdef CONFIG_SPL_BUILD
>>   obj-$(CONFIG_DRAM_SUN4I)	+= dram_sun4i.o
>> diff --git a/arch/arm/cpu/armv7/sunxi/timer.c b/arch/arm/mach-sunxi/timer.c
>> similarity index 97%
>> rename from arch/arm/cpu/armv7/sunxi/timer.c
>> rename to arch/arm/mach-sunxi/timer.c
>> index b758599636..fc9d419a25 100644
>> --- a/arch/arm/cpu/armv7/sunxi/timer.c
>> +++ b/arch/arm/mach-sunxi/timer.c
>> @@ -51,6 +51,7 @@ int timer_init(void)
>>   	struct sunxi_timer_reg *timers =
>>   		(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
>>   	struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
>> +
>>   	writel(TIMER_LOAD_VAL, &timer->inter);
>>   	writel(TIMER_MODE | TIMER_DIV | TIMER_SRC | TIMER_RELOAD | TIMER_EN,
>>   	       &timer->ctl);
>> @@ -58,15 +59,14 @@ int timer_init(void)
>>   	return 0;
>>   }
>>   
>> -/* timer without interrupts */
>>   static ulong get_timer_masked(void)
>>   {
>>   	/* current tick value */
>>   	ulong now = TICKS_TO_HZ(read_timer());
>>   
>> -	if (now >= gd->arch.lastinc)	/* normal (non rollover) */
>> +	if (now >= gd->arch.lastinc) {	/* normal (non rollover) */
>>   		gd->arch.tbl += (now - gd->arch.lastinc);
>> -	else {
>> +	} else {
>>   		/* rollover */
>>   		gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL)
>>   				- gd->arch.lastinc) + now;
>> @@ -76,6 +76,7 @@ static ulong get_timer_masked(void)
>>   	return gd->arch.tbl;
>>   }
>>   
>> +/* timer without interrupts */
>>   ulong get_timer(ulong base)
>>   {
>>   	return get_timer_masked() - base;
>
Andre Przywara Jan. 28, 2022, 12:41 a.m. UTC | #3
On Thu, 27 Jan 2022 15:40:13 -0500
Jesse Taube <mr.bossman075@gmail.com> wrote:

Hi,

> On 1/27/22 05:21, Andre Przywara wrote:
> > On Wed, 26 Jan 2022 08:53:19 -0500
> > Jesse Taube <mr.bossman075@gmail.com> wrote:
> >   
> >> Both armv7 and arm926ejs use this timer code so move it to mach-sunxi.  
> > 
> > Very nice, thanks for cleaning this up.
> > 
> > But please remove the respective line from the Makefile in
> > arch/arm/cpu/armv7/sunxi/, otherwise 32-bit board builds fail:
> > make[2]: *** No rule to make target 'arch/arm/cpu/armv7/sunxi/timer.o' ...  
> Oh my I'm very sorry about this. There is one thing though 
> arch/arm/cpu/armv7/sunxi/ needs to have one .o file in there to compile.
> If I remove `ifdef CONFIG_SPL_BUILD` for fel_utils it will work but its 
> not used in u-boot proper.

Mmh, not sure I follow, I cannot reproduce any problem. Can you
elaborate? And did you do a "make clean" afterwards?

Cheers,
Andre


> > Cheers,
> > Andre
> >   
> >> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
> >> ---
> >> V1->V2:
> >> * New commit
> >> ---
> >>   arch/arm/mach-sunxi/Makefile                     | 3 +++
> >>   arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c | 7 ++++---
> >>   2 files changed, 7 insertions(+), 3 deletions(-)
> >>   rename arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c (97%)
> >>
> >> diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
> >> index 5d3fd70f74..b1adb75e17 100644
> >> --- a/arch/arm/mach-sunxi/Makefile
> >> +++ b/arch/arm/mach-sunxi/Makefile
> >> @@ -25,6 +25,9 @@ obj-$(CONFIG_MACH_SUN8I)	+= clock_sun6i.o
> >>   endif
> >>   obj-$(CONFIG_MACH_SUN9I)	+= clock_sun9i.o gtbus_sun9i.o
> >>   obj-$(CONFIG_SUN50I_GEN_H6)	+= clock_sun50i_h6.o
> >> +ifndef CONFIG_ARM64
> >> +obj-y	+= timer.o
> >> +endif
> >>   
> >>   ifdef CONFIG_SPL_BUILD
> >>   obj-$(CONFIG_DRAM_SUN4I)	+= dram_sun4i.o
> >> diff --git a/arch/arm/cpu/armv7/sunxi/timer.c b/arch/arm/mach-sunxi/timer.c
> >> similarity index 97%
> >> rename from arch/arm/cpu/armv7/sunxi/timer.c
> >> rename to arch/arm/mach-sunxi/timer.c
> >> index b758599636..fc9d419a25 100644
> >> --- a/arch/arm/cpu/armv7/sunxi/timer.c
> >> +++ b/arch/arm/mach-sunxi/timer.c
> >> @@ -51,6 +51,7 @@ int timer_init(void)
> >>   	struct sunxi_timer_reg *timers =
> >>   		(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
> >>   	struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
> >> +
> >>   	writel(TIMER_LOAD_VAL, &timer->inter);
> >>   	writel(TIMER_MODE | TIMER_DIV | TIMER_SRC | TIMER_RELOAD | TIMER_EN,
> >>   	       &timer->ctl);
> >> @@ -58,15 +59,14 @@ int timer_init(void)
> >>   	return 0;
> >>   }
> >>   
> >> -/* timer without interrupts */
> >>   static ulong get_timer_masked(void)
> >>   {
> >>   	/* current tick value */
> >>   	ulong now = TICKS_TO_HZ(read_timer());
> >>   
> >> -	if (now >= gd->arch.lastinc)	/* normal (non rollover) */
> >> +	if (now >= gd->arch.lastinc) {	/* normal (non rollover) */
> >>   		gd->arch.tbl += (now - gd->arch.lastinc);
> >> -	else {
> >> +	} else {
> >>   		/* rollover */
> >>   		gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL)
> >>   				- gd->arch.lastinc) + now;
> >> @@ -76,6 +76,7 @@ static ulong get_timer_masked(void)
> >>   	return gd->arch.tbl;
> >>   }
> >>   
> >> +/* timer without interrupts */
> >>   ulong get_timer(ulong base)
> >>   {
> >>   	return get_timer_masked() - base;  
> >
Jesse T Jan. 28, 2022, 4:51 a.m. UTC | #4
On 1/27/22 19:41, Andre Przywara wrote:
> On Thu, 27 Jan 2022 15:40:13 -0500
> Jesse Taube <mr.bossman075@gmail.com> wrote:
> 
> Hi,
> 
>> On 1/27/22 05:21, Andre Przywara wrote:
>>> On Wed, 26 Jan 2022 08:53:19 -0500
>>> Jesse Taube <mr.bossman075@gmail.com> wrote:
>>>    
>>>> Both armv7 and arm926ejs use this timer code so move it to mach-sunxi.
>>>
>>> Very nice, thanks for cleaning this up.
>>>
>>> But please remove the respective line from the Makefile in
>>> arch/arm/cpu/armv7/sunxi/, otherwise 32-bit board builds fail:
>>> make[2]: *** No rule to make target 'arch/arm/cpu/armv7/sunxi/timer.o' ...
>> Oh my I'm very sorry about this. There is one thing though
>> arch/arm/cpu/armv7/sunxi/ needs to have one .o file in there to compile.
>> If I remove `ifdef CONFIG_SPL_BUILD` for fel_utils it will work but its
>> not used in u-boot proper.
> 
> Mmh, not sure I follow, I cannot reproduce any problem. Can you
> elaborate? And did you do a "make clean" afterwards?
If nothing is built by that MAKEFILE which would happen if
!(CONFIG_MACH_SUN6I || CONFIG_MACH_SUN8I_H3
CONFIG_MACH_SUN8I || CONFIG_ARMV7_PSCI) it will error with the following
`ar: arch/arm/cpu/armv7/sunxi/built-in.o: No such file or directory`

I don't know if there is a config that will break it currently but it is 
possible. So we will have to let it generate some .o file. Even if it is 
optimized out.

Should I still wait for your review of V2?

Also thank you so much for being interested in this!

Have my patches been okay so far?

I really hope this gets in before cleanup of sunxi starts as rebasing it 
was already difficult.

Thank you,
	Jesse Taube
> Cheers, 
> Andre
> 
> 
>>> Cheers,
>>> Andre
>>>    
>>>> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
>>>> ---
>>>> V1->V2:
>>>> * New commit
>>>> ---
>>>>    arch/arm/mach-sunxi/Makefile                     | 3 +++
>>>>    arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c | 7 ++++---
>>>>    2 files changed, 7 insertions(+), 3 deletions(-)
>>>>    rename arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c (97%)
>>>>
>>>> diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
>>>> index 5d3fd70f74..b1adb75e17 100644
>>>> --- a/arch/arm/mach-sunxi/Makefile
>>>> +++ b/arch/arm/mach-sunxi/Makefile
>>>> @@ -25,6 +25,9 @@ obj-$(CONFIG_MACH_SUN8I)	+= clock_sun6i.o
>>>>    endif
>>>>    obj-$(CONFIG_MACH_SUN9I)	+= clock_sun9i.o gtbus_sun9i.o
>>>>    obj-$(CONFIG_SUN50I_GEN_H6)	+= clock_sun50i_h6.o
>>>> +ifndef CONFIG_ARM64
>>>> +obj-y	+= timer.o
>>>> +endif
>>>>    
>>>>    ifdef CONFIG_SPL_BUILD
>>>>    obj-$(CONFIG_DRAM_SUN4I)	+= dram_sun4i.o
>>>> diff --git a/arch/arm/cpu/armv7/sunxi/timer.c b/arch/arm/mach-sunxi/timer.c
>>>> similarity index 97%
>>>> rename from arch/arm/cpu/armv7/sunxi/timer.c
>>>> rename to arch/arm/mach-sunxi/timer.c
>>>> index b758599636..fc9d419a25 100644
>>>> --- a/arch/arm/cpu/armv7/sunxi/timer.c
>>>> +++ b/arch/arm/mach-sunxi/timer.c
>>>> @@ -51,6 +51,7 @@ int timer_init(void)
>>>>    	struct sunxi_timer_reg *timers =
>>>>    		(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
>>>>    	struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
>>>> +
>>>>    	writel(TIMER_LOAD_VAL, &timer->inter);
>>>>    	writel(TIMER_MODE | TIMER_DIV | TIMER_SRC | TIMER_RELOAD | TIMER_EN,
>>>>    	       &timer->ctl);
>>>> @@ -58,15 +59,14 @@ int timer_init(void)
>>>>    	return 0;
>>>>    }
>>>>    
>>>> -/* timer without interrupts */
>>>>    static ulong get_timer_masked(void)
>>>>    {
>>>>    	/* current tick value */
>>>>    	ulong now = TICKS_TO_HZ(read_timer());
>>>>    
>>>> -	if (now >= gd->arch.lastinc)	/* normal (non rollover) */
>>>> +	if (now >= gd->arch.lastinc) {	/* normal (non rollover) */
>>>>    		gd->arch.tbl += (now - gd->arch.lastinc);
>>>> -	else {
>>>> +	} else {
>>>>    		/* rollover */
>>>>    		gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL)
>>>>    				- gd->arch.lastinc) + now;
>>>> @@ -76,6 +76,7 @@ static ulong get_timer_masked(void)
>>>>    	return gd->arch.tbl;
>>>>    }
>>>>    
>>>> +/* timer without interrupts */
>>>>    ulong get_timer(ulong base)
>>>>    {
>>>>    	return get_timer_masked() - base;
>>>    
>
Andre Przywara Jan. 28, 2022, 2:28 p.m. UTC | #5
On Thu, 27 Jan 2022 23:51:09 -0500
Jesse Taube <mr.bossman075@gmail.com> wrote:

Hi Jesse,

> On 1/27/22 19:41, Andre Przywara wrote:
> > On Thu, 27 Jan 2022 15:40:13 -0500
> > Jesse Taube <mr.bossman075@gmail.com> wrote:
> > 
> > Hi,
> >   
> >> On 1/27/22 05:21, Andre Przywara wrote:  
> >>> On Wed, 26 Jan 2022 08:53:19 -0500
> >>> Jesse Taube <mr.bossman075@gmail.com> wrote:
> >>>      
> >>>> Both armv7 and arm926ejs use this timer code so move it to mach-sunxi.  
> >>>
> >>> Very nice, thanks for cleaning this up.
> >>>
> >>> But please remove the respective line from the Makefile in
> >>> arch/arm/cpu/armv7/sunxi/, otherwise 32-bit board builds fail:
> >>> make[2]: *** No rule to make target 'arch/arm/cpu/armv7/sunxi/timer.o' ...  
> >> Oh my I'm very sorry about this. There is one thing though
> >> arch/arm/cpu/armv7/sunxi/ needs to have one .o file in there to compile.
> >> If I remove `ifdef CONFIG_SPL_BUILD` for fel_utils it will work but its
> >> not used in u-boot proper.  
> > 
> > Mmh, not sure I follow, I cannot reproduce any problem. Can you
> > elaborate? And did you do a "make clean" afterwards?  
> If nothing is built by that MAKEFILE which would happen if
> !(CONFIG_MACH_SUN6I || CONFIG_MACH_SUN8I_H3
> CONFIG_MACH_SUN8I || CONFIG_ARMV7_PSCI) it will error with the following
> `ar: arch/arm/cpu/armv7/sunxi/built-in.o: No such file or directory`

How did you trigger this? I built all 159 (+1 F1C100s) sunxi defconfigs
without errors.
What toolchain are you using? I see that for instance Cubieboard_defconfig
comes out empty for U-Boot proper, but this does not seem to be a problem
for my "arm-linux-gnueabihf-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" and
"GNU ld (GNU Binutils for Ubuntu) 2.34". I see an 8 byte sized built-in.o,
and no other .o files in the directory.

> I don't know if there is a config that will break it currently but it is 
> possible. So we will have to let it generate some .o file. Even if it is 
> optimized out.
> 
> Should I still wait for your review of V2?

I will check the rest of the patches today, but there are only minor
things.

> Also thank you so much for being interested in this!

Yeah, I decided to bite the bullet and join Allwinner's race to the
bottom ;-) After all, a mainline Linux capable device in the size of an SD
card has something to it, even when it's missing half of the bits ;-)
I ordered a LicheePi Nano, but not sure if that makes it out before
Chinese New Year still.

> Have my patches been okay so far?

They look good so far, yes.

> I really hope this gets in before cleanup of sunxi starts as rebasing it 
> was already difficult.

Pretty sure of that.

Cheers,
Andre

> 
> Thank you,
> 	Jesse Taube
> > Cheers, 
> > Andre
> > 
> >   
> >>> Cheers,
> >>> Andre
> >>>      
> >>>> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
> >>>> ---
> >>>> V1->V2:
> >>>> * New commit
> >>>> ---
> >>>>    arch/arm/mach-sunxi/Makefile                     | 3 +++
> >>>>    arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c | 7 ++++---
> >>>>    2 files changed, 7 insertions(+), 3 deletions(-)
> >>>>    rename arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c (97%)
> >>>>
> >>>> diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
> >>>> index 5d3fd70f74..b1adb75e17 100644
> >>>> --- a/arch/arm/mach-sunxi/Makefile
> >>>> +++ b/arch/arm/mach-sunxi/Makefile
> >>>> @@ -25,6 +25,9 @@ obj-$(CONFIG_MACH_SUN8I)	+= clock_sun6i.o
> >>>>    endif
> >>>>    obj-$(CONFIG_MACH_SUN9I)	+= clock_sun9i.o gtbus_sun9i.o
> >>>>    obj-$(CONFIG_SUN50I_GEN_H6)	+= clock_sun50i_h6.o
> >>>> +ifndef CONFIG_ARM64
> >>>> +obj-y	+= timer.o
> >>>> +endif
> >>>>    
> >>>>    ifdef CONFIG_SPL_BUILD
> >>>>    obj-$(CONFIG_DRAM_SUN4I)	+= dram_sun4i.o
> >>>> diff --git a/arch/arm/cpu/armv7/sunxi/timer.c b/arch/arm/mach-sunxi/timer.c
> >>>> similarity index 97%
> >>>> rename from arch/arm/cpu/armv7/sunxi/timer.c
> >>>> rename to arch/arm/mach-sunxi/timer.c
> >>>> index b758599636..fc9d419a25 100644
> >>>> --- a/arch/arm/cpu/armv7/sunxi/timer.c
> >>>> +++ b/arch/arm/mach-sunxi/timer.c
> >>>> @@ -51,6 +51,7 @@ int timer_init(void)
> >>>>    	struct sunxi_timer_reg *timers =
> >>>>    		(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
> >>>>    	struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
> >>>> +
> >>>>    	writel(TIMER_LOAD_VAL, &timer->inter);
> >>>>    	writel(TIMER_MODE | TIMER_DIV | TIMER_SRC | TIMER_RELOAD | TIMER_EN,
> >>>>    	       &timer->ctl);
> >>>> @@ -58,15 +59,14 @@ int timer_init(void)
> >>>>    	return 0;
> >>>>    }
> >>>>    
> >>>> -/* timer without interrupts */
> >>>>    static ulong get_timer_masked(void)
> >>>>    {
> >>>>    	/* current tick value */
> >>>>    	ulong now = TICKS_TO_HZ(read_timer());
> >>>>    
> >>>> -	if (now >= gd->arch.lastinc)	/* normal (non rollover) */
> >>>> +	if (now >= gd->arch.lastinc) {	/* normal (non rollover) */
> >>>>    		gd->arch.tbl += (now - gd->arch.lastinc);
> >>>> -	else {
> >>>> +	} else {
> >>>>    		/* rollover */
> >>>>    		gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL)
> >>>>    				- gd->arch.lastinc) + now;
> >>>> @@ -76,6 +76,7 @@ static ulong get_timer_masked(void)
> >>>>    	return gd->arch.tbl;
> >>>>    }
> >>>>    
> >>>> +/* timer without interrupts */
> >>>>    ulong get_timer(ulong base)
> >>>>    {
> >>>>    	return get_timer_masked() - base;  
> >>>      
> >
Jesse T Jan. 28, 2022, 10:40 p.m. UTC | #6
On 1/28/22 09:28, Andre Przywara wrote:
> On Thu, 27 Jan 2022 23:51:09 -0500
> Jesse Taube <mr.bossman075@gmail.com> wrote:
> 
> Hi Jesse,
> 
>> On 1/27/22 19:41, Andre Przywara wrote:
>>> On Thu, 27 Jan 2022 15:40:13 -0500
>>> Jesse Taube <mr.bossman075@gmail.com> wrote:
>>>
>>> Hi,
>>>    
>>>> On 1/27/22 05:21, Andre Przywara wrote:
>>>>> On Wed, 26 Jan 2022 08:53:19 -0500
>>>>> Jesse Taube <mr.bossman075@gmail.com> wrote:
>>>>>       
>>>>>> Both armv7 and arm926ejs use this timer code so move it to mach-sunxi.
>>>>>
>>>>> Very nice, thanks for cleaning this up.
>>>>>
>>>>> But please remove the respective line from the Makefile in
>>>>> arch/arm/cpu/armv7/sunxi/, otherwise 32-bit board builds fail:
>>>>> make[2]: *** No rule to make target 'arch/arm/cpu/armv7/sunxi/timer.o' ...
>>>> Oh my I'm very sorry about this. There is one thing though
>>>> arch/arm/cpu/armv7/sunxi/ needs to have one .o file in there to compile.
>>>> If I remove `ifdef CONFIG_SPL_BUILD` for fel_utils it will work but its
>>>> not used in u-boot proper.
>>>
>>> Mmh, not sure I follow, I cannot reproduce any problem. Can you
>>> elaborate? And did you do a "make clean" afterwards?
>> If nothing is built by that MAKEFILE which would happen if
>> !(CONFIG_MACH_SUN6I || CONFIG_MACH_SUN8I_H3
>> CONFIG_MACH_SUN8I || CONFIG_ARMV7_PSCI) it will error with the following
>> `ar: arch/arm/cpu/armv7/sunxi/built-in.o: No such file or directory`
> 
> How did you trigger this? I built all 159 (+1 F1C100s) sunxi defconfigs
> without errors.
> What toolchain are you using? I see that for instance Cubieboard_defconfig
> comes out empty for U-Boot proper, but this does not seem to be a problem
> for my "arm-linux-gnueabihf-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" and
> "GNU ld (GNU Binutils for Ubuntu) 2.34". I see an 8 byte sized built-in.o,
> and no other .o files in the directory.

Ah I see. My misunderstanding of how it worked.
If the MAKEFILE has nothing in it it will cause it.
It will also happen if ifdefs make the file empty. This was happening 
with arm926ejs/sunxi and I thought it had to do with there being nothing 
assembled or compiled. I thought the same may happen with this file but 
adding anything not in an ifdef will cuase it to be fixed. If you dont 
understand what I'm saying that's fine its unimportant because my issue 
doesn't exist sorry for the confusion.

Sorry,
	Jesse Taube
>> I don't know if there is a config that will break it currently but it is
>> possible. So we will have to let it generate some .o file. Even if it is
>> optimized out.
>>
>> Should I still wait for your review of V2?
> 
> I will check the rest of the patches today, but there are only minor
> things.
> 
>> Also thank you so much for being interested in this!
> 
> Yeah, I decided to bite the bullet and join Allwinner's race to the
> bottom ;-) After all, a mainline Linux capable device in the size of an SD
> card has something to it, even when it's missing half of the bits ;-)
> I ordered a LicheePi Nano, but not sure if that makes it out before
> Chinese New Year still.
> 
>> Have my patches been okay so far?
> 
> They look good so far, yes.
> 
>> I really hope this gets in before cleanup of sunxi starts as rebasing it
>> was already difficult.
> 
> Pretty sure of that.
> 
> Cheers,
> Andre
> 
>>
>> Thank you,
>> 	Jesse Taube
>>> Cheers,
>>> Andre
>>>
>>>    
>>>>> Cheers,
>>>>> Andre
>>>>>       
>>>>>> Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
>>>>>> ---
>>>>>> V1->V2:
>>>>>> * New commit
>>>>>> ---
>>>>>>     arch/arm/mach-sunxi/Makefile                     | 3 +++
>>>>>>     arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c | 7 ++++---
>>>>>>     2 files changed, 7 insertions(+), 3 deletions(-)
>>>>>>     rename arch/arm/{cpu/armv7/sunxi => mach-sunxi}/timer.c (97%)
>>>>>>
>>>>>> diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
>>>>>> index 5d3fd70f74..b1adb75e17 100644
>>>>>> --- a/arch/arm/mach-sunxi/Makefile
>>>>>> +++ b/arch/arm/mach-sunxi/Makefile
>>>>>> @@ -25,6 +25,9 @@ obj-$(CONFIG_MACH_SUN8I)	+= clock_sun6i.o
>>>>>>     endif
>>>>>>     obj-$(CONFIG_MACH_SUN9I)	+= clock_sun9i.o gtbus_sun9i.o
>>>>>>     obj-$(CONFIG_SUN50I_GEN_H6)	+= clock_sun50i_h6.o
>>>>>> +ifndef CONFIG_ARM64
>>>>>> +obj-y	+= timer.o
>>>>>> +endif
>>>>>>     
>>>>>>     ifdef CONFIG_SPL_BUILD
>>>>>>     obj-$(CONFIG_DRAM_SUN4I)	+= dram_sun4i.o
>>>>>> diff --git a/arch/arm/cpu/armv7/sunxi/timer.c b/arch/arm/mach-sunxi/timer.c
>>>>>> similarity index 97%
>>>>>> rename from arch/arm/cpu/armv7/sunxi/timer.c
>>>>>> rename to arch/arm/mach-sunxi/timer.c
>>>>>> index b758599636..fc9d419a25 100644
>>>>>> --- a/arch/arm/cpu/armv7/sunxi/timer.c
>>>>>> +++ b/arch/arm/mach-sunxi/timer.c
>>>>>> @@ -51,6 +51,7 @@ int timer_init(void)
>>>>>>     	struct sunxi_timer_reg *timers =
>>>>>>     		(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
>>>>>>     	struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
>>>>>> +
>>>>>>     	writel(TIMER_LOAD_VAL, &timer->inter);
>>>>>>     	writel(TIMER_MODE | TIMER_DIV | TIMER_SRC | TIMER_RELOAD | TIMER_EN,
>>>>>>     	       &timer->ctl);
>>>>>> @@ -58,15 +59,14 @@ int timer_init(void)
>>>>>>     	return 0;
>>>>>>     }
>>>>>>     
>>>>>> -/* timer without interrupts */
>>>>>>     static ulong get_timer_masked(void)
>>>>>>     {
>>>>>>     	/* current tick value */
>>>>>>     	ulong now = TICKS_TO_HZ(read_timer());
>>>>>>     
>>>>>> -	if (now >= gd->arch.lastinc)	/* normal (non rollover) */
>>>>>> +	if (now >= gd->arch.lastinc) {	/* normal (non rollover) */
>>>>>>     		gd->arch.tbl += (now - gd->arch.lastinc);
>>>>>> -	else {
>>>>>> +	} else {
>>>>>>     		/* rollover */
>>>>>>     		gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL)
>>>>>>     				- gd->arch.lastinc) + now;
>>>>>> @@ -76,6 +76,7 @@ static ulong get_timer_masked(void)
>>>>>>     	return gd->arch.tbl;
>>>>>>     }
>>>>>>     
>>>>>> +/* timer without interrupts */
>>>>>>     ulong get_timer(ulong base)
>>>>>>     {
>>>>>>     	return get_timer_masked() - base;
>>>>>       
>>>    
>
diff mbox series

Patch

diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
index 5d3fd70f74..b1adb75e17 100644
--- a/arch/arm/mach-sunxi/Makefile
+++ b/arch/arm/mach-sunxi/Makefile
@@ -25,6 +25,9 @@  obj-$(CONFIG_MACH_SUN8I)	+= clock_sun6i.o
 endif
 obj-$(CONFIG_MACH_SUN9I)	+= clock_sun9i.o gtbus_sun9i.o
 obj-$(CONFIG_SUN50I_GEN_H6)	+= clock_sun50i_h6.o
+ifndef CONFIG_ARM64
+obj-y	+= timer.o
+endif
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_DRAM_SUN4I)	+= dram_sun4i.o
diff --git a/arch/arm/cpu/armv7/sunxi/timer.c b/arch/arm/mach-sunxi/timer.c
similarity index 97%
rename from arch/arm/cpu/armv7/sunxi/timer.c
rename to arch/arm/mach-sunxi/timer.c
index b758599636..fc9d419a25 100644
--- a/arch/arm/cpu/armv7/sunxi/timer.c
+++ b/arch/arm/mach-sunxi/timer.c
@@ -51,6 +51,7 @@  int timer_init(void)
 	struct sunxi_timer_reg *timers =
 		(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
 	struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
+
 	writel(TIMER_LOAD_VAL, &timer->inter);
 	writel(TIMER_MODE | TIMER_DIV | TIMER_SRC | TIMER_RELOAD | TIMER_EN,
 	       &timer->ctl);
@@ -58,15 +59,14 @@  int timer_init(void)
 	return 0;
 }
 
-/* timer without interrupts */
 static ulong get_timer_masked(void)
 {
 	/* current tick value */
 	ulong now = TICKS_TO_HZ(read_timer());
 
-	if (now >= gd->arch.lastinc)	/* normal (non rollover) */
+	if (now >= gd->arch.lastinc) {	/* normal (non rollover) */
 		gd->arch.tbl += (now - gd->arch.lastinc);
-	else {
+	} else {
 		/* rollover */
 		gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL)
 				- gd->arch.lastinc) + now;
@@ -76,6 +76,7 @@  static ulong get_timer_masked(void)
 	return gd->arch.tbl;
 }
 
+/* timer without interrupts */
 ulong get_timer(ulong base)
 {
 	return get_timer_masked() - base;