[U-Boot] Timer Statics (was: arm926ejs: fix linker file for newer ld support)

Reinhard Meyer u-boot at emk-elektronik.de
Wed Nov 10 14:02:54 CET 2010


Dear concerned,

>  - Move static variables to struct global_data, so they can be used
>    before relocation. Used by AT91 timers and proposed for A320 and
>    S3C64xx in:
> 
>    http://article.gmane.org/gmane.comp.boot-loaders.u-boot/88095
>    http://article.gmane.org/gmane.comp.boot-loaders.u-boot/88160
> 
> I hope we can solve this problem in the same way for all ARM timers. And
> if we use the second approach, we probably can generalize the AT91 data
> in struct global_data as proposed by Andreas.

The AT91 global data for clock/timer use has 2 parts:
#ifdef CONFIG_AT91FAMILY
	/* "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

I have removed reset_timer() from the AT91 timer now, making the global
variable "timer_reset_value" obsolete. For that all occurences of the
sequence

reset_timer();
...
loop .. if .. get_timer(0) >= timeout

has to be replaced by

u32 start_time = get_timer(0);
...
loop .. if .. get_timer(start_time) >= timeout

Currently, for AT91, that is only in the file
drivers/mtd/nand/nand_base.c

In that view, we could put
	unsigned long	timer_rate_hz;
	unsigned long	tbl;
	unsigned long	tbu;
outside the AT91FAMILY ifdef.

We can even split the timer implementation into two parts:
part 1 (hardware specific) implements a method to increment tbu/tbl
and exports the function get_ticks(), and
part 2 (hardware independant) uses get_ticks() and timer_rate_hz
to implement udelay() and get_timer().

Best Regards,
Reinhard


More information about the U-Boot mailing list