From patchwork Fri Oct 4 15:22:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 280649 X-Patchwork-Delegate: trini@ti.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 0519B2C00A2 for ; Sat, 5 Oct 2013 01:24:40 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 97B844A067; Fri, 4 Oct 2013 17:24:21 +0200 (CEST) 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 gtaxhm5EUG87; Fri, 4 Oct 2013 17:24:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D4C234A087; Fri, 4 Oct 2013 17:23:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C2C854A092 for ; Fri, 4 Oct 2013 17:23:30 +0200 (CEST) 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 1m6WoAzjKmQf for ; Fri, 4 Oct 2013 17:23:30 +0200 (CEST) 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 mail-ie0-f172.google.com (mail-ie0-f172.google.com [209.85.223.172]) by theia.denx.de (Postfix) with ESMTPS id 7084A4A080 for ; Fri, 4 Oct 2013 17:23:17 +0200 (CEST) Received: by mail-ie0-f172.google.com with SMTP id x13so9413536ief.31 for ; Fri, 04 Oct 2013 08:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=33iyec/xPE/Qcd5YpSRsEBW4JiUyeNHsRip2d4qYPmk=; b=Hki6W2GwgK5uxy/lvr88yplTbrWjA5Mc9Ic4ga4F90DclX0bjvlR2ygnt1/okz9ukt NYsYE1flDvTyh3zmgyVKffn5/Yw4b3/T+Bs0+1KyfEPOkvgxVABXNZtt0GZoknY98AFR sOPQHDJqRGTotuuodAgNNqPpTdLCGhHGhC4/XgKnA4qglPPMlWQkwg36cLiVPw5Hxi82 LCz+z+C/I3GjaNFCspCRoSVXftOhHfbJ6cw7kaychq4as/Q9wHvkDtkvdnddfu1oDpfI 0KBzl6DMLl/o3Z53rQ7KoTIpUGW37O5hb+c/ofRLL1fIJo8wsWJpFplXE38rDiLyxXI0 mTcA== X-Received: by 10.42.98.76 with SMTP id r12mr1204040icn.59.1380900196672; Fri, 04 Oct 2013 08:23:16 -0700 (PDT) Received: from rob-laptop.calxeda.com ([173.226.190.126]) by mx.google.com with ESMTPSA id f5sm7421998igc.4.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Oct 2013 08:23:16 -0700 (PDT) From: Rob Herring To: u-boot@lists.denx.de Date: Fri, 4 Oct 2013 10:22:46 -0500 Message-Id: <1380900168-23791-8-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1380900168-23791-1-git-send-email-robherring2@gmail.com> References: <1378671174-18535-1-git-send-email-robherring2@gmail.com> <1380900168-23791-1-git-send-email-robherring2@gmail.com> Cc: Rob Herring Subject: [U-Boot] [PATCH v2 7/9] ARM: socfpga: convert to common timer code X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Rob Herring Convert socfpga to use the commmon timer code. Signed-off-by: Rob Herring --- arch/arm/cpu/armv7/socfpga/timer.c | 72 -------------------------------------- include/configs/socfpga_cyclone5.h | 5 +-- 2 files changed, 3 insertions(+), 74 deletions(-) diff --git a/arch/arm/cpu/armv7/socfpga/timer.c b/arch/arm/cpu/armv7/socfpga/timer.c index 09f6f14..58fc789 100644 --- a/arch/arm/cpu/armv7/socfpga/timer.c +++ b/arch/arm/cpu/armv7/socfpga/timer.c @@ -8,8 +8,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - static const struct socfpga_timer *timer_base = (void *)CONFIG_SYS_TIMERBASE; /* @@ -22,73 +20,3 @@ int timer_init(void) writel(readl(&timer_base->ctrl) | 0x3, &timer_base->ctrl); return 0; } - -static u32 read_timer(void) -{ - return readl(&timer_base->curr_val); -} - -/* - * Delay x useconds - */ -void __udelay(unsigned long usec) -{ - unsigned long now, last; - /* - * get the tmo value based on timer clock speed - * tmo = delay required / period of timer clock - */ - long tmo = usec * CONFIG_TIMER_CLOCK_KHZ / 1000; - - last = read_timer(); - while (tmo > 0) { - now = read_timer(); - if (last >= now) - /* normal mode (non roll) */ - tmo -= last - now; - else - /* we have overflow of the count down timer */ - tmo -= TIMER_LOAD_VAL - last + now; - last = now; - } -} - -/* - * Get the timer value - */ -ulong get_timer(ulong base) -{ - return get_timer_masked() - base; -} - -/* - * Timer : get the time difference - * Unit of tick is based on the CONFIG_SYS_HZ - */ -ulong get_timer_masked(void) -{ - /* current tick value */ - ulong now = read_timer() / (CONFIG_TIMER_CLOCK_KHZ/CONFIG_SYS_HZ); - if (gd->arch.lastinc >= now) { - /* normal mode (non roll) */ - /* move stamp forward with absolute diff ticks */ - gd->arch.tbl += gd->arch.lastinc - now; - } else { - /* we have overflow of the count down timer */ - gd->arch.tbl += TIMER_LOAD_VAL - gd->arch.lastinc + now; - } - gd->arch.lastinc = now; - return gd->arch.tbl; -} - -/* - * Reset the timer - */ -void reset_timer(void) -{ - /* capture current decrementer value time */ - gd->arch.lastinc = read_timer() / - (CONFIG_TIMER_CLOCK_KHZ / CONFIG_SYS_HZ); - /* start "advancing" time stamp from 0 */ - gd->arch.tbl = 0; -} diff --git a/include/configs/socfpga_cyclone5.h b/include/configs/socfpga_cyclone5.h index 06aeba6..fa49f85 100644 --- a/include/configs/socfpga_cyclone5.h +++ b/include/configs/socfpga_cyclone5.h @@ -197,10 +197,11 @@ /* Timer info */ #define CONFIG_SYS_HZ 1000 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET -#define CONFIG_TIMER_CLOCK_KHZ 2400 +#define CONFIG_SYS_TIMER_RATE 2400000 #else -#define CONFIG_TIMER_CLOCK_KHZ 25000 +#define CONFIG_SYS_TIMER_RATE 25000000 #endif +#define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMERBASE + 0x4) #define CONFIG_ENV_IS_NOWHERE