From patchwork Thu Feb 20 17:55: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: 25075 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 026ED203C6 for ; Thu, 20 Feb 2014 17:56:35 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id oy12sf4310145veb.6 for ; Thu, 20 Feb 2014 09:56:35 -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: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=fToHzLvs4xyzUBvnDiHopKYMmHO2XbnBflFuwYqKqNs=; b=KoPypzfv4yRMtHj7ZMb6IpVIB1SbxoCdofGUiGvnl5/k2OPyV9GexrmFlQh25hgVFU JcWkrcsWdvz97CMiHJySJwF+ACmkh6RZ7exlqBvdqwMI0kSQAaCE6NQC84vK3yMoWino lgOyP7bj7Ypl1lBSr59HpL3jcvlduszss0Wh9uQ0Dv3U+LwbGsRqE+g484YBWl4r3sKS 63rbe61llyQy02Yl0Wv3yiE3u0bb+J2HwcZN+akjvdAYTzx8mfFrYJHoRyLazutOl7XX xydXXicXpZ4ZLDkpzev6uj5SU6duZ/uInLHaHmM23fEcFtMOy3eNk+AUSwQr2qonqIWT MrSw== X-Gm-Message-State: ALoCoQkpa1kSLuvO3jz2D6Rdmz9j/mc9wzsRAb4RVdU6Wqwr8zhfD65d/SfeNBWxT3SZV4TfrUYB X-Received: by 10.236.134.174 with SMTP id s34mr1138939yhi.32.1392918995222; Thu, 20 Feb 2014 09:56:35 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.134 with SMTP id b6ls617742qgb.91.gmail; Thu, 20 Feb 2014 09:56:35 -0800 (PST) X-Received: by 10.52.65.171 with SMTP id y11mr1478109vds.52.1392918995074; Thu, 20 Feb 2014 09:56:35 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id eo4si1764662vdb.121.2014.02.20.09.56.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Feb 2014 09:56:35 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 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.180; Received: by mail-vc0-f180.google.com with SMTP id ks9so2185966vcb.39 for ; Thu, 20 Feb 2014 09:56:35 -0800 (PST) X-Received: by 10.220.192.71 with SMTP id dp7mr1739897vcb.45.1392918994979; Thu, 20 Feb 2014 09:56:34 -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 u4csp77530vcz; Thu, 20 Feb 2014 09:56:34 -0800 (PST) X-Received: by 10.204.21.69 with SMTP id i5mr987248bkb.8.1392918993948; Thu, 20 Feb 2014 09:56:33 -0800 (PST) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id os9si2522246bkb.240.2014.02.20.09.56.33 for ; Thu, 20 Feb 2014 09:56:33 -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 101DA4B645; Thu, 20 Feb 2014 18:56:33 +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 tH4Dmc2lW3VT; Thu, 20 Feb 2014 18:56:32 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7CDB94B604; Thu, 20 Feb 2014 18:56:15 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9CE4F4B5B1 for ; Thu, 20 Feb 2014 18:56:09 +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 RL2pnGjtmnjh for ; Thu, 20 Feb 2014 18:56:06 +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 bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by theia.denx.de (Postfix) with ESMTPS id 4583E4B615 for ; Thu, 20 Feb 2014 18:55:51 +0100 (CET) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s1KHtoMW027131 for ; Thu, 20 Feb 2014 11:55:50 -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 s1KHtobI014234 for ; Thu, 20 Feb 2014 11:55:50 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Thu, 20 Feb 2014 11:55:50 -0600 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 s1KHtome013866; Thu, 20 Feb 2014 11:55:50 -0600 Received: from a0868495 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1WGXqf-000445-W2; Thu, 20 Feb 2014 12:55:50 -0500 From: Murali Karicheri To: , Date: Thu, 20 Feb 2014 12:55:06 -0500 Message-ID: <1392918914-15564-5-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1392918914-15564-1-git-send-email-m-karicheri2@ti.com> References: <1392918914-15564-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Subject: [U-Boot] [U-Boot PATCH v2 04/12] 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.180 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 --- - No update since v1 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; +}