From patchwork Fri Feb 7 23:23:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 24335 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6A43F2096A for ; Fri, 7 Feb 2014 23:32:12 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf8117079qac.0 for ; Fri, 07 Feb 2014 15:32:11 -0800 (PST) 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:cc: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=p14OS5s5nDzlDfXXgsGK2S0jsTO3xDIGnxIsFxlgJiY=; b=CQD0gXDtUoLE8RK5i0hA2Ck6Uej33sJx8sdU0i7J477rnik+OzEdWCCDtTGvCXEWKQ OgKmECstUUwXjUk9pvhAgwZ+GlB9Pym22CFd5RCBBM1cgORKFUO/AuUqS021B6Sq77so c03odoqomql1nFBOwQ7V9XdzuOuGhfoCBZtVV+E/YEhGKVpT085tCgM2demzS5RhhtSP YhOMpCUHxLWFUGzf0F+qyVsdVcS9jzpE8ew8VKD/ODOUasP41EPTtVPUOpMEeSfmps1O iyPGBB4EVC/TzMjvrfQPWBIb+qBzgvEJSNihWZE3l0x3n7NhxtyIjqtpD5ymKkjhezoA Xlpw== X-Gm-Message-State: ALoCoQmU3DDXkqLNLcYZnP2pLrcGMbSWl4KuUebIeKhwJiwlWyuwjdEb8WGa/RsElJ280JVQLAyB X-Received: by 10.52.78.98 with SMTP id a2mr6042310vdx.3.1391815931573; Fri, 07 Feb 2014 15:32:11 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.146 with SMTP id 18ls343531qgj.58.gmail; Fri, 07 Feb 2014 15:32:11 -0800 (PST) X-Received: by 10.221.29.196 with SMTP id rz4mr12598030vcb.8.1391815931481; Fri, 07 Feb 2014 15:32:11 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id cy15si1886965veb.144.2014.02.07.15.32.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Feb 2014 15:32:11 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id oz11so3273621veb.4 for ; Fri, 07 Feb 2014 15:32:11 -0800 (PST) X-Received: by 10.220.103.141 with SMTP id k13mr8415221vco.25.1391815931356; Fri, 07 Feb 2014 15:32:11 -0800 (PST) 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.174.196 with SMTP id u4csp400vcz; Fri, 7 Feb 2014 15:32:10 -0800 (PST) X-Received: by 10.15.42.72 with SMTP id t48mr19602838eev.45.1391815436708; Fri, 07 Feb 2014 15:23:56 -0800 (PST) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id f45si10941975eep.215.2014.02.07.15.23.56 for ; Fri, 07 Feb 2014 15:23:56 -0800 (PST) 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 812734BB8D; Sat, 8 Feb 2014 00:23:50 +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 qmU2Ymz70U6H; Sat, 8 Feb 2014 00:23:50 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F10E34BB49; Sat, 8 Feb 2014 00:23:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 81B284BAF3 for ; Sat, 8 Feb 2014 00:23:31 +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 bkLWjYOlfmJ8 for ; Sat, 8 Feb 2014 00:23:27 +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 arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by theia.denx.de (Postfix) with ESMTPS id 5AFCD4BAF4 for ; Sat, 8 Feb 2014 00:23:23 +0100 (CET) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s17NNJ9U008290; Fri, 7 Feb 2014 17:23:19 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s17NNJ86030911; Fri, 7 Feb 2014 17:23:19 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Fri, 7 Feb 2014 17:23:18 -0600 Received: from ares-ubuntu.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s17NNIhY021143; Fri, 7 Feb 2014 17:23:18 -0600 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1WBulS-00055v-Eh; Fri, 07 Feb 2014 18:23:18 -0500 From: Murali Karicheri To: Date: Fri, 7 Feb 2014 18:23:11 -0500 Message-ID: <1391815393-19536-5-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1391815393-19536-1-git-send-email-m-karicheri2@ti.com> References: <1391815393-19536-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Cc: trini@ti.com, Murali@theia.denx.de, Vitaly Andrianov Subject: [U-Boot] [U-Boot:RESEND][[PATCH 4/7 v1] 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.128.173 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 --- - Resending with some more in cc - Resending the patch along with SoC/board patch 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 321997c..726f229 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -42,6 +42,7 @@ obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o else obj-$(CONFIG_SPL_FRAMEWORK) += spl.o endif +obj-$(CONFIG_SYS_ARCH_TIMER) += arch_timer.o ifdef CONFIG_ARM64 obj-y += interrupts_64.o 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; +}