From patchwork Tue Nov 29 13:45:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kochetkov X-Patchwork-Id: 9452153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1C0F960235 for ; Tue, 29 Nov 2016 13:54:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E73027DC2 for ; Tue, 29 Nov 2016 13:54:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 030B12830A; Tue, 29 Nov 2016 13:54:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B80AE27DC2 for ; Tue, 29 Nov 2016 13:54:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBipL-0005aq-Ly; Tue, 29 Nov 2016 13:52:07 +0000 Received: from mail-lf0-f65.google.com ([209.85.215.65]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBijO-0007lW-VY; Tue, 29 Nov 2016 13:46:01 +0000 Received: by mail-lf0-f65.google.com with SMTP id o141so12750764lff.1; Tue, 29 Nov 2016 05:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fVLVfR2KP4TVUVp/ZFaa+/CFLkHQkz/Mguv4tym4GGo=; b=l2sPnL7KNFXz60ja2fiOY482W3pas54hhf1Nq6Wi5Es2gnG4SSifz8f0ocmazOeG0q H+SvgWwueqfcVuGPLveYqldv0L3urJ5kDhauOX8uXGprf3v6rPfTiR/GTvwRTwv5NUHQ qGfMaAkbUOWZED0Kx3867NWA3FILtvILLk3wswHbn6nLn2fxgHHeM5HkH3ZxdVGkELDV GjQmin+mlnicGNHjMMjF1JRhEXeIs2/WDP7m5XvcqYsQdUQcXensfk7MSPkICmhZweCf 0nikA/jIKlQhv6NVYflJbRxir2kQtA9WzhAAIjPXMDvS6jDNECJafpGP+VlJfsMmF9AE Pljg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fVLVfR2KP4TVUVp/ZFaa+/CFLkHQkz/Mguv4tym4GGo=; b=XA4eI0WjCkjzz37sGXGV0PxkKXp6iy4ybhSyOR5+YTmmL27zHE8PUHAOcHdrVwy5i5 A0reTrRS8PdkLfGOSBZCWBwhgxr/obezStyZMjfnv2Ex2UTKSyqeRCJwEG2TlulIajw1 gn0nf2FbLSoh8FO3lLcj+0ZBIa+WymSv8bGyr8JW4sYYZMzvzaq7nBVSxNq1ooRL2yat f+daCAFXZhnJ0mlNsw+M8xubkXPLtUMdLb7dOqL8fVgimPCVGonhjLwUGKXnaeBDbzxi X+Sk5JvN6YRFtpni+abEqBquu91umGg4w++3LnjLYCzTWDeimwBmim30xFT1+hgCJpNb NW/Q== X-Gm-Message-State: AKaTC033gjQ27396zCzrsv9W8WtkWkthlFHoDos4abtJlyX/Z7B7bsXftfoO7dxZCskZmw== X-Received: by 10.46.8.9 with SMTP id 9mr12666035lji.47.1480427136344; Tue, 29 Nov 2016 05:45:36 -0800 (PST) Received: from ubuntu.lintech.local ([185.35.119.87]) by smtp.gmail.com with ESMTPSA id y3sm250543lfj.42.2016.11.29.05.45.35 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Nov 2016 05:45:35 -0800 (PST) From: Alexander Kochetkov To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH v3 11/13] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer Date: Tue, 29 Nov 2016 16:45:16 +0300 Message-Id: <1480427118-5126-12-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1480427118-5126-1-git-send-email-al.kochet@gmail.com> References: <1480343486-25539-1-git-send-email-al.kochet@gmail.com> <1480427118-5126-1-git-send-email-al.kochet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161129_054559_517912_69CB625D X-CRM114-Status: UNSURE ( 9.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Huang Tao , Heiko Stuebner , Alexander Kochetkov , Daniel Lezcano , Russell King , Rob Herring , Thomas Gleixner , Caesar Wang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alexander Kochetkov --- drivers/clocksource/rockchip_timer.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/clocksource/rockchip_timer.c b/drivers/clocksource/rockchip_timer.c index c2b0454..6224aa9 100644 --- a/drivers/clocksource/rockchip_timer.c +++ b/drivers/clocksource/rockchip_timer.c @@ -19,6 +19,8 @@ #define TIMER_LOAD_COUNT0 0x00 #define TIMER_LOAD_COUNT1 0x04 +#define TIMER_CURRENT_VALUE0 0x08 +#define TIMER_CURRENT_VALUE1 0x0C #define TIMER_CONTROL_REG3288 0x10 #define TIMER_CONTROL_REG3399 0x1c #define TIMER_INT_STATUS 0x18 @@ -72,6 +74,25 @@ static void rk_timer_update_counter(u64 cycles, struct rk_timer *timer) writel_relaxed(upper, timer->base + TIMER_LOAD_COUNT1); } +static u64 rk_timer_counter_read(struct rk_timer *timer) +{ + u64 counter; + u32 lower; + u32 upper, old_upper; + + upper = readl_relaxed(timer->base + TIMER_CURRENT_VALUE1); + do { + old_upper = upper; + lower = readl_relaxed(timer->base + TIMER_CURRENT_VALUE0); + upper = readl_relaxed(timer->base + TIMER_CURRENT_VALUE1); + } while (upper != old_upper); + + counter = upper; + counter <<= 32; + counter |= lower; + return counter; +} + static void rk_timer_interrupt_clear(struct rk_timer *timer) { writel_relaxed(1, timer->base + TIMER_INT_STATUS);