From patchwork Fri Mar 21 20:51:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 26868 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CEE2720143 for ; Fri, 21 Mar 2014 20:52:35 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf10147996iec.8 for ; Fri, 21 Mar 2014 13:52:35 -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=/wbzg3LuhowHDB02M8FG+Wp5d0jMrEvSZzkAH+m1rgU=; b=UdE9p6RpbI4zt90jOo4BrImYY4vo83OhcorWSl4akxttLy84RSS3DXq7nanWKD6+AM Ifzng9DScBYyvVX1Rxkcghxx3a2kT5TIyKxyaXaz9S3xSJz0SBC67iPBsCcPyywD9r4B b8Vpg/IDhFgom12VvVOke3cSjZo7/7vJF02KpxYBHB2UIxraJ/neWHevmsl13HWAEwNR 2mJ/Uw+mJPPjL7zlZrAdmDliAAxz4+GOwbEeuOJYUnMyUhXa3mDy8mrYgfWkPtxio3OD d697+2OQn/R37gaJXhTVo9+2zadZtG62QLf0/yQhYPU8h48PeVfJci594MvJuj2OW9X9 xlsQ== X-Gm-Message-State: ALoCoQlWBah/u2qfDVkmFvQ9WzSWGQOnVmdFEtrPB1ha8OA91Mrf5GcavpLdNhi2+jQLcjsVggeJ X-Received: by 10.182.28.36 with SMTP id y4mr6950946obg.46.1395435155285; Fri, 21 Mar 2014 13:52:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.245 with SMTP id u108ls760310qge.79.gmail; Fri, 21 Mar 2014 13:52:35 -0700 (PDT) X-Received: by 10.58.57.67 with SMTP id g3mr38462224veq.3.1395435155147; Fri, 21 Mar 2014 13:52:35 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id fn10si1440853vdc.45.2014.03.21.13.52.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 13:52:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 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.182; Received: by mail-vc0-f182.google.com with SMTP id ks9so3287809vcb.13 for ; Fri, 21 Mar 2014 13:52:35 -0700 (PDT) X-Received: by 10.58.202.106 with SMTP id kh10mr9357704vec.31.1395435155057; Fri, 21 Mar 2014 13:52:35 -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.78.9 with SMTP id i9csp58458vck; Fri, 21 Mar 2014 13:52:34 -0700 (PDT) X-Received: by 10.204.56.199 with SMTP id z7mr11015621bkg.5.1395435153962; Fri, 21 Mar 2014 13:52:33 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id pt3si2844579bkb.67.2014.03.21.13.52.33 for ; Fri, 21 Mar 2014 13:52:33 -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 3DF294B650; Fri, 21 Mar 2014 21:52:24 +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 PzprJ3SQijdO; Fri, 21 Mar 2014 21:52:23 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 14B804B5FB; Fri, 21 Mar 2014 21:51:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D85F64B164 for ; Fri, 21 Mar 2014 21:51: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 QwKsY791Ecu7 for ; Fri, 21 Mar 2014 21:51:49 +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 590314B5CD for ; Fri, 21 Mar 2014 21:51:42 +0100 (CET) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s2LKpeK5001453 for ; Fri, 21 Mar 2014 15:51:40 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s2LKpeVc027984 for ; Fri, 21 Mar 2014 15:51:40 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Fri, 21 Mar 2014 15:51:39 -0500 Received: from ares-ubuntu.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s2LKpdMl011510; Fri, 21 Mar 2014 15:51:39 -0500 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1WR6Pj-0007ol-Kv; Fri, 21 Mar 2014 16:51:39 -0400 From: Murali Karicheri To: , Date: Fri, 21 Mar 2014 16:51:32 -0400 Message-ID: <1395435098-30003-4-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1395435098-30003-1-git-send-email-m-karicheri2@ti.com> References: <1395435098-30003-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Subject: [U-Boot] [PATCH v3 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.182 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 45febcf..a1d774a 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -41,6 +41,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; +}