From mboxrd@z Thu Jan 1 00:00:00 1970 From: Reinhard Meyer Date: Wed, 10 Nov 2010 14:02:54 +0100 Subject: [U-Boot] Timer Statics (was: arm926ejs: fix linker file for newer ld support) In-Reply-To: <4CDA9096.2080505@schmid-telecom.ch> References: <1288909332-26220-1-git-send-email-albert.aribaud@free.fr> <4CD991EA.6090004@schmid-telecom.ch> <4CD99755.7000103@free.fr> <4CDA9096.2080505@schmid-telecom.ch> Message-ID: <4CDA97FE.7010701@emk-elektronik.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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