From patchwork Tue Jan 4 08:08:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minkyu Kang X-Patchwork-Id: 77393 X-Patchwork-Delegate: promsoft@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4E3EBB70E0 for ; Tue, 4 Jan 2011 19:19:52 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D1A202828E; Tue, 4 Jan 2011 09:19:49 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2PpoSZpmab+3; Tue, 4 Jan 2011 09:19:49 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A718C2828F; Tue, 4 Jan 2011 09:19:48 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1780C2828F for ; Tue, 4 Jan 2011 09:19:46 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PPeP5gmz-T1d for ; Tue, 4 Jan 2011 09:19:44 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by theia.denx.de (Postfix) with ESMTP id 0B6622828E for ; Tue, 4 Jan 2011 09:19:42 +0100 (CET) Received: from epmmp1 (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LEH00CM1NYZ2570@mailout4.samsung.com> for u-boot@lists.denx.de; Tue, 04 Jan 2011 17:08:59 +0900 (KST) Received: from TNRNDGASPAPP1.tn.corp.samsungelectronics.net ([165.213.149.150]) by mmp1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LEH00BK7NYZVX@mmp1.samsung.com> for u-boot@lists.denx.de; Tue, 04 Jan 2011 17:08:59 +0900 (KST) Received: from [10.89.9.135] ([10.89.9.135]) by TNRNDGASPAPP1.tn.corp.samsungelectronics.net with Microsoft SMTPSVC(6.0.3790.4675); Tue, 04 Jan 2011 17:08:59 +0900 Date: Tue, 04 Jan 2011 17:08:59 +0900 From: Minkyu Kang To: u-boot@lists.denx.de Message-id: <4D22D59B.7030902@samsung.com> MIME-version: 1.0 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; ko; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1 X-OriginalArrivalTime: 04 Jan 2011 08:08:59.0433 (UTC) FILETIME=[A41C3190:01CBABE6] Cc: kyungmin.park@samsung.com, hs@denx.de Subject: [U-Boot] [PATCH] S5P: timer: replace bss variable by gd X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Use the global data instead of bss variable, replace as follow. count_value -> timer_rate_hz timestamp -> timer_reset_value lastdec -> lastinc Signed-off-by: Minkyu Kang Signed-off-by: Kyungmin Park cc: Heiko Schocher --- arch/arm/cpu/armv7/s5p-common/timer.c | 48 +++++++++++++++------------------ 1 files changed, 22 insertions(+), 26 deletions(-) diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c index 651fd5d..0a1883f 100644 --- a/arch/arm/cpu/armv7/s5p-common/timer.c +++ b/arch/arm/cpu/armv7/s5p-common/timer.c @@ -28,6 +28,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + #define PRESCALER_1 (16 - 1) /* prescaler of timer 2, 3, 4 */ #define MUX_DIV_2 1 /* 1/2 period */ #define MUX_DIV_4 2 /* 1/4 period */ @@ -37,12 +39,6 @@ #define TCON_TIMER4_SHIFT 20 -static unsigned long count_value; - -/* Internal tick units */ -static unsigned long long timestamp; /* Monotonic incrementing timer */ -static unsigned long lastdec; /* Last decremneter snapshot */ - /* macro to read the 16 bit timer */ static inline struct s5p_timer *s5p_get_base_timer(void) { @@ -65,16 +61,16 @@ int timer_init(void) writel((PRESCALER_1 & 0xff) << 8, &timer->tcfg0); writel((MUX_DIV_2 & 0xf) << MUX4_DIV_SHIFT, &timer->tcfg1); - /* count_value = 2085937.5(HZ) (per 1 sec)*/ - count_value = get_pwm_clk() / ((PRESCALER_1 + 1) * + /* timer_rate_hz = 2085937.5(HZ) (per 1 sec)*/ + gd->timer_rate_hz = get_pwm_clk() / ((PRESCALER_1 + 1) * (MUX_DIV_2 + 1)); - /* count_value / 100 = 20859.375(HZ) (per 10 msec) */ - count_value = count_value / 100; + /* timer_rate_hz / 100 = 20859.375(HZ) (per 10 msec) */ + gd->timer_rate_hz = gd->timer_rate_hz / 100; /* set count value */ - writel(count_value, &timer->tcntb4); - lastdec = count_value; + writel(gd->timer_rate_hz, &timer->tcntb4); + gd->lastinc = gd->timer_rate_hz; val = (readl(&timer->tcon) & ~(0x07 << TCON_TIMER4_SHIFT)) | TCON4_AUTO_RELOAD; @@ -85,7 +81,7 @@ int timer_init(void) /* start PWM timer 4 */ writel(val | TCON4_START, &timer->tcon); - timestamp = 0; + gd->timer_reset_value = 0; return 0; } @@ -105,7 +101,7 @@ unsigned long get_timer(unsigned long base) void set_timer(unsigned long t) { - timestamp = t; + gd->timer_reset_value = t; } /* delay x useconds */ @@ -114,7 +110,7 @@ void __udelay(unsigned long usec) struct s5p_timer *const timer = s5p_get_base_timer(); unsigned long tmo, tmp; - count_value = readl(&timer->tcntb4); + gd->timer_rate_hz = readl(&timer->tcntb4); if (usec >= 1000) { /* @@ -125,19 +121,19 @@ void __udelay(unsigned long usec) * 3. finish normalize. */ tmo = usec / 1000; - tmo *= (CONFIG_SYS_HZ * count_value / 10); + tmo *= (CONFIG_SYS_HZ * gd->timer_rate_hz / 10); tmo /= 1000; } else { /* else small number, don't kill it prior to HZ multiply */ - tmo = usec * CONFIG_SYS_HZ * count_value / 10; + tmo = usec * CONFIG_SYS_HZ * gd->timer_rate_hz / 10; tmo /= (1000 * 1000); } - /* get current timestamp */ + /* get current timer_reset_value */ tmp = get_timer(0); /* if setting this fordward will roll time stamp */ - /* reset "advancing" timestamp to 0, set lastdec value */ + /* reset "advancing" timer_reset_value to 0, set lastinc value */ /* else, set advancing stamp wake up time */ if ((tmo + tmp + 1) < tmp) reset_timer_masked(); @@ -154,8 +150,8 @@ void reset_timer_masked(void) struct s5p_timer *const timer = s5p_get_base_timer(); /* reset time */ - lastdec = readl(&timer->tcnto4); - timestamp = 0; + gd->lastinc = readl(&timer->tcnto4); + gd->timer_reset_value = 0; } unsigned long get_timer_masked(void) @@ -163,14 +159,14 @@ unsigned long get_timer_masked(void) struct s5p_timer *const timer = s5p_get_base_timer(); unsigned long now = readl(&timer->tcnto4); - if (lastdec >= now) - timestamp += lastdec - now; + if (gd->lastinc >= now) + gd->timer_reset_value += gd->lastinc - now; else - timestamp += lastdec + count_value - now; + gd->timer_reset_value += gd->lastinc + gd->timer_rate_hz - now; - lastdec = now; + gd->lastinc = now; - return timestamp; + return gd->timer_reset_value; } /*