Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936476AbcKWRav (ORCPT ); Wed, 23 Nov 2016 12:30:51 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36624 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757197AbcKWR3z (ORCPT ); Wed, 23 Nov 2016 12:29:55 -0500 From: Alexander Kochetkov To: daniel.lezcano@linaro.org, tglx@linutronix.de, heiko@sntech.de, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Alexander Kochetkov Subject: [PATCH 6/9] clocksource/drivers/rockchip_timer: implement reading 64bit value from timer Date: Wed, 23 Nov 2016 20:29:34 +0300 Message-Id: <1479922177-20136-6-git-send-email-al.kochet@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1479922177-20136-1-git-send-email-al.kochet@gmail.com> References: <1479922177-20136-1-git-send-email-al.kochet@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1352 Lines: 46 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 f4c26be..61787c5 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); -- 1.7.9.5