From patchwork Tue Apr 1 18:44:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 27561 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5670420553 for ; Tue, 1 Apr 2014 18:45:09 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf36700043oac.7 for ; Tue, 01 Apr 2014 11:45:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=RPlVPQETcd3h6zFqwGb+Z6DxD1XG31lh9M6JaOybc50=; b=O+5SPugFSFMUpd0fQQE4lWADTY5PihAnkzF6qSauLbSd4fS0dEEQsfvjXPz0wKObaa 0zX03mOlHp45eDNAIN2lD7z92HT0cJ6zuPb7doma3wgVGTX1nnVf4kbp4JR8X05ua2cf GaUJsQjzmOMG6jwXbBOrywXWu2FCE0GqX0tO9V4OQyqu4R4plSS4TUVcIkdnwF762Wei aVWtfRRnN55obQqlbg1gV1CwC/LUUu696EEJrPvdu6hvsRAFzJ/VkWPdBZgb+HXA9Vpl XZqtvloy6XLanQk18upqhf6xHMMQsYqsDx7FyriYXyC5SgCSuXPLtziJXrL9a58xt+Ok 8C2g== X-Gm-Message-State: ALoCoQlz4ETpnesStJ3fIseXPbVZqNeIvvpMLCjHGmsjgdCGUrxxT8GchDdlJO4tlMsH/1mg6hON X-Received: by 10.182.118.194 with SMTP id ko2mr14312635obb.32.1396377908545; Tue, 01 Apr 2014 11:45:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.97.8 with SMTP id l8ls100629qge.27.gmail; Tue, 01 Apr 2014 11:45:08 -0700 (PDT) X-Received: by 10.52.72.48 with SMTP id a16mr24992657vdv.19.1396377908422; Tue, 01 Apr 2014 11:45:08 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id rx10si3849192vdc.132.2014.04.01.11.45.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Apr 2014 11:45:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lg15so10181852vcb.2 for ; Tue, 01 Apr 2014 11:45:08 -0700 (PDT) X-Received: by 10.53.1.69 with SMTP id be5mr2040414vdd.27.1396377908326; Tue, 01 Apr 2014 11:45:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp261353vcv; Tue, 1 Apr 2014 11:45:07 -0700 (PDT) X-Received: by 10.204.72.9 with SMTP id k9mr25388703bkj.1.1396377907275; Tue, 01 Apr 2014 11:45:07 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id uk8si1180901bkb.301.2014.04.01.11.44.53 for ; Tue, 01 Apr 2014 11:45:07 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1D2034B858; Tue, 1 Apr 2014 20:44:53 +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 m5KM1bvbsTZD; Tue, 1 Apr 2014 20:44:52 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 591E54B84A; Tue, 1 Apr 2014 20:44:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 779084B859 for ; Tue, 1 Apr 2014 20:44:39 +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 ebZMJbLASvyQ for ; Tue, 1 Apr 2014 20:44:36 +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 devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by theia.denx.de (Postfix) with ESMTPS id 3859B4B84A for ; Tue, 1 Apr 2014 20:44:33 +0200 (CEST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s31IiWvD006971 for ; Tue, 1 Apr 2014 13:44:32 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s31IiW9e027460 for ; Tue, 1 Apr 2014 13:44:32 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 1 Apr 2014 13:44:32 -0500 Received: from ares-ubuntu.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s31IiVYu027948; Tue, 1 Apr 2014 13:44:32 -0500 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1WV3fj-00046e-Pj; Tue, 01 Apr 2014 14:44:31 -0400 From: Murali Karicheri To: , Date: Tue, 1 Apr 2014 14:44:23 -0400 Message-ID: <1396377869-15724-4-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1396377869-15724-1-git-send-email-m-karicheri2@ti.com> References: <1396377869-15724-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Subject: [U-Boot] [PATCH v5 3/9] arm: add support for arch timer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m-karicheri2@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Vitaly Andrianov This patch add basic support for the architecture timer found on recent ARMv7 based SoCs. Signed-off-by: Vitaly Andrianov Signed-off-by: Murali Karicheri Acked-by: Tom Rini --- arch/arm/lib/Makefile | 1 + arch/arm/lib/arch_timer.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 arch/arm/lib/arch_timer.c diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 9fc81cd..5860814 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -32,6 +32,7 @@ obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o else obj-$(CONFIG_SPL_FRAMEWORK) += spl.o endif +obj-$(CONFIG_SYS_ARCH_TIMER) += arch_timer.o obj-y += sections.o ifdef CONFIG_ARM64 diff --git a/arch/arm/lib/arch_timer.c b/arch/arm/lib/arch_timer.c new file mode 100644 index 0000000..0588e2b --- /dev/null +++ b/arch/arm/lib/arch_timer.c @@ -0,0 +1,58 @@ +/* + * (C) Copyright 2012-2014 + * Texas Instruments Incorporated, + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +int timer_init(void) +{ + gd->arch.tbl = 0; + gd->arch.tbu = 0; + + gd->arch.timer_rate_hz = CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ; + + return 0; +} + +unsigned long long get_ticks(void) +{ + ulong nowl, nowu; + + asm volatile("mrrc p15, 0, %0, %1, c14" : "=r" (nowl), "=r" (nowu)); + + gd->arch.tbl = nowl; + gd->arch.tbu = nowu; + + return (((unsigned long long)gd->arch.tbu) << 32) | gd->arch.tbl; +} + + +ulong get_timer(ulong base) +{ + return lldiv(get_ticks(), gd->arch.timer_rate_hz) - base; +} + +void __udelay(unsigned long usec) +{ + unsigned long long endtime; + + endtime = lldiv((unsigned long long)usec * gd->arch.timer_rate_hz, + 1000UL); + + endtime += get_ticks(); + + while (get_ticks() < endtime) + ; +} + +ulong get_tbclk(void) +{ + return gd->arch.timer_rate_hz; +}