From patchwork Thu Mar 27 15:59:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 27218 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2B876202FA for ; Thu, 27 Mar 2014 16:00:27 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id fp1sf8220818pdb.8 for ; Thu, 27 Mar 2014 09:00:26 -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=BXfySm3qjrZNSCK/9iVhxKPoI0WynF1Qey3aOLmXoHLpVFO+eaCN9Hr3vMsdh8ktWY 1VVNpjsAXJmEuqYiSPCPE8DPHsxDL+37BJib+KlGlELOBraKeAoNTNhPc46HUZxSzvXx jJ27mzftMjzXKbIbkXd0gRXPT5a7qIdERzvcQUaWNXFxg/Y9RVxAT0MupgY2Y6clsmFK UBqqm3eDni5e6IpK9w/7+JPzrxPu3JBBIP741Bch5y7w7+OqtQOEtDen0SZQ+T1wbkZ6 P2UzYLjjL40srRb+mkDnqxhrDQ36KwLqhY5ss5Sw3ZmIHJABliNCVNafi5dP9Xs7ageU sHcQ== X-Gm-Message-State: ALoCoQkIgHJDiGST5kCMUXtbHZx8oedkNjcuyWAPPb2Nb+tgPCnG428+ll9lVN7B13pCbCqSeRdw X-Received: by 10.66.222.105 with SMTP id ql9mr1103554pac.9.1395936026173; Thu, 27 Mar 2014 09:00:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.165 with SMTP id 34ls1268559qgb.30.gmail; Thu, 27 Mar 2014 09:00:26 -0700 (PDT) X-Received: by 10.52.166.103 with SMTP id zf7mr1781805vdb.30.1395936026009; Thu, 27 Mar 2014 09:00:26 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id is3si651067vec.45.2014.03.27.09.00.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Mar 2014 09:00:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 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.178; Received: by mail-vc0-f178.google.com with SMTP id im17so4449897vcb.37 for ; Thu, 27 Mar 2014 09:00:25 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr1778019vcb.28.1395936025932; Thu, 27 Mar 2014 09:00:25 -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 i9csp39591vck; Thu, 27 Mar 2014 09:00:25 -0700 (PDT) X-Received: by 10.204.64.134 with SMTP id e6mr933929bki.108.1395936024806; Thu, 27 Mar 2014 09:00:24 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id dz3si1866129bkc.244.2014.03.27.09.00.24 for ; Thu, 27 Mar 2014 09:00:24 -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 8638C4B669; Thu, 27 Mar 2014 17:00:14 +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 ujtAbEogVfaj; Thu, 27 Mar 2014 17:00:14 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37A964B614; Thu, 27 Mar 2014 16:59:35 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8421A4B605 for ; Thu, 27 Mar 2014 16:59:28 +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 yDMA3kNbPBdT for ; Thu, 27 Mar 2014 16:59:25 +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 comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by theia.denx.de (Postfix) with ESMTPS id 21F2D4B5F5 for ; Thu, 27 Mar 2014 16:59:18 +0100 (CET) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s2RFxGim028935 for ; Thu, 27 Mar 2014 10:59:16 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s2RFxFIJ019001 for ; Thu, 27 Mar 2014 10:59:16 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Thu, 27 Mar 2014 10:59:15 -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 s2RFxEDI010897; Thu, 27 Mar 2014 10:59:15 -0500 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1WTCi2-000310-BI; Thu, 27 Mar 2014 11:59:14 -0400 From: Murali Karicheri To: , Date: Thu, 27 Mar 2014 11:59:06 -0400 Message-ID: <1395935952-11542-4-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1395935952-11542-1-git-send-email-m-karicheri2@ti.com> References: <1395935952-11542-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Subject: [U-Boot] [PATCH v4 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.178 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; +}