From patchwork Fri Oct 4 15:22:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 280650 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 62A862C00A2 for ; Sat, 5 Oct 2013 01:24:52 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3B9614A06E; Fri, 4 Oct 2013 17:24:32 +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 6YixUPcYT1kR; Fri, 4 Oct 2013 17:24:32 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C11124A0B0; Fri, 4 Oct 2013 17:23:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 149DC4A099 for ; Fri, 4 Oct 2013 17:23:35 +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 AfQ5LsbCaRp7 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-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) by theia.denx.de (Postfix) with ESMTPS id 72B5F4A081 for ; Fri, 4 Oct 2013 17:23:14 +0200 (CEST) Received: by mail-ie0-f175.google.com with SMTP id e14so9003265iej.6 for ; Fri, 04 Oct 2013 08:23:13 -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=F0IU+jnDNWVW/AJemZe3z4CpE0NXJ9OQ01z5W1W+KiY=; b=TaOYvcPt+JUf8hpz7SKUZzFN+JiYLRH09/GUhawxrYzDagFGdpm4aLL8cL8eJZEN3J ulBJmLRcdGP+obTnsCIUnBuRfua+XL8nPN3oU/olKOolFMojys16fwWjZBveVYMhFqVX jDT12fSS0jfyfs/SKs14rZ3XywY0SN+PwBSQyBDQg56T7cC8WA43fTDPjw11S4WOVBF9 GTzLiUh/stJRtNnabSbtR3tWRAaO6Fg5rVtSoUm21ky5k5qwsAMxLKapUsZDkjHxWzQu FxHVzRvaH0r9bQQ72qrXj0xXZyLyPwL60ypDK7khJ2QZpZoIka2uiqiE8NFiqbMXOpbw UwAw== X-Received: by 10.50.72.33 with SMTP id a1mr6897258igv.58.1380900192880; Fri, 04 Oct 2013 08:23:12 -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:12 -0700 (PDT) From: Rob Herring To: u-boot@lists.denx.de Date: Fri, 4 Oct 2013 10:22:42 -0500 Message-Id: <1380900168-23791-4-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 3/9] sh: 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 sh to use the commmon timer code. Remove reset_timer and set_timer as they are unused on sh. Signed-off-by: Rob Herring --- arch/sh/lib/time.c | 61 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 59 deletions(-) diff --git a/arch/sh/lib/time.c b/arch/sh/lib/time.c index 1fe537e..b182dd2 100644 --- a/arch/sh/lib/time.c +++ b/arch/sh/lib/time.c @@ -12,7 +12,6 @@ */ #include -#include #include #include #include @@ -20,28 +19,15 @@ static struct tmu_regs *tmu = (struct tmu_regs *)TMU_BASE; static u16 bit; -static unsigned long last_tcnt; -static unsigned long long overflow_ticks; unsigned long get_tbclk(void) { return get_tmu0_clk_rate() >> ((bit + 1) * 2); } -static inline unsigned long long tick_to_time(unsigned long long tick) +unsigned long timer_read_counter(void) { - tick *= CONFIG_SYS_HZ; - do_div(tick, get_tbclk()); - - return tick; -} - -static inline unsigned long long usec_to_tick(unsigned long long usec) -{ - usec *= get_tbclk(); - do_div(usec, 1000000); - - return usec; + return ~readl(&tmu->tcnt0); } static void tmu_timer_start(unsigned int timer) @@ -66,49 +52,6 @@ int timer_init(void) tmu_timer_stop(0); tmu_timer_start(0); - last_tcnt = 0; - overflow_ticks = 0; - return 0; } -unsigned long long get_ticks(void) -{ - unsigned long tcnt = 0 - readl(&tmu->tcnt0); - - if (last_tcnt > tcnt) /* overflow */ - overflow_ticks++; - last_tcnt = tcnt; - - return (overflow_ticks << 32) | tcnt; -} - -void __udelay(unsigned long usec) -{ - unsigned long long tmp; - ulong tmo; - - tmo = usec_to_tick(usec); - tmp = get_ticks() + tmo; /* get current timestamp */ - - while (get_ticks() < tmp) /* loop till event */ - /*NOP*/; -} - -unsigned long get_timer(unsigned long base) -{ - /* return msec */ - return tick_to_time(get_ticks()) - base; -} - -void set_timer(unsigned long t) -{ - writel((0 - t), &tmu->tcnt0); -} - -void reset_timer(void) -{ - tmu_timer_stop(0); - set_timer(0); - tmu_timer_start(0); -}