[U-Boot] AT91 clock and timer cleanups (was: ARM relocation, probably trivial mistake - back to original problem)

Reinhard Meyer
2010-10-04T07:44:28Z

I wrote:
> Dear Wolfgang Denk,
>> In message <4CA5D26D.2090505@emk-elektronik.de> you wrote:
>>>> If this is really for all AT91 SoCs, then please feel free to
>>>> introduce a common define (CONFIG_SYS_AT91 ?) and use that. Eventually
>>>> you can clean up some other such #if's on the way.
>>> That would have to be set either in each board.h file or in each at91*.h
>>> file.
>> Isn't there a central place?
>>
>>>> Probably there is a header file common to all AT91 SoCs when then can
>>>> use a single such construct to #define the new variable so you don;t
>>>> have to touch all the many board config files.
>>> The only files I can see included in each instance are those of the kind
>>> hardware.h, memory_map.h and similiar. The define does not really belong
>>> in any of those.
>
> I tried arch-at91/hardware.h. Apparently it gets included after
> global_data.h. Same would be true for all files included inside hardware.h.
> Without reordering the includes (which I don't want to do) the remaining
> place would be each board's config file. Since all AT91 boards are broken
> anyway right now; adding it could be left to the respective maintainers :)
>
>> If no better place is found, we can even add this to <common.h> (we do
>> similar things there already for CONFIG_MPC866_FAMILY, CONFIG_MPC86x,
>> CONFIG_MPC8272_FAMILY, CONFIG_TQM8xxM, CONFIG_TQM8xxL, etc.
>
> Into this chain?
> #if defined(CONFIG_MPC852) || defined(CONFIG_MPC852T) || \
> defined(CONFIG_MPC859) || defined(CONFIG_MPC859T) || \
> defined(CONFIG_MPC859DSL) || \
> defined(CONFIG_MPC866) || defined(CONFIG_MPC866T) || \
> defined(CONFIG_MPC866P)
> # define CONFIG_MPC866_FAMILY 1
> #elif defined(CONFIG_MPC870) \
>
> Ugly, but possible :)
> Just hoping that everytime a new AT91 comes out, it will not be forgotten to be added there ;)

I have added required variables to global_data.h, it looks like
this now:

...
#ifdef CONFIG_FSL_ESDHC
unsigned long sdhc_clk;
#endif
#if defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9XE)
/* "static data" needed by at91's clock.c */
unsigned long cpu_clk_rate_hz;
unsigned long main_clk_rate_hz;
unsigned long mck_rate_hz;
unsigned long plla_rate_hz;
unsigned long pllb_rate_hz;
unsigned long at91_pllb_usb_init;
/* "static data" needed by at91's timer.c */
unsigned long timer_rate_hz;
unsigned long tbl;
unsigned long tbu;
unsigned long long timer_reset_value;
#endif
#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC)
unsigned long relocaddr; /* Start address of U-Boot in RAM */
...

At the same time I cleaned up timer.c to really operate using
64 bit values like on powerpc (hence tbu, tbl)

The Qs that remain now are:

1. currently I see about 8 CONFIG_AT91SAMxxx defines required
(not only 2 like above). The method is still undecided how to
handle this. Add "CONFIG_AT91SAM9_FAMILY" to "common.h"? Or put
all 8 defined() into "global_data.h" (would give 4 lines there)?

2. How many patches would this change need, and who would collect them?
It affects at worst 3 areas:
common.h, arm/global_data.h, at91/clock.c+timer.c ---
Or is it ok to put that into one patch and add it later to my atmel tree?

Reinhard