Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753114Ab3FZVRK (ORCPT ); Wed, 26 Jun 2013 17:17:10 -0400 Received: from mail.free-electrons.com ([94.23.35.102]:51830 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063Ab3FZVRG (ORCPT ); Wed, 26 Jun 2013 17:17:06 -0400 From: Maxime Ripard To: John Stultz , Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Emilio Lopez , kevin@allwinnertech.com, sunny@allwinnertech.com, shuge@allwinnertech.com, linux-sunxi@googlegroups.com, Maxime Ripard Subject: [PATCH 4/8] clocksource: sun4i: Fix the next event code Date: Wed, 26 Jun 2013 23:16:57 +0200 Message-Id: <1372281421-2099-5-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1372281421-2099-1-git-send-email-maxime.ripard@free-electrons.com> References: <1372281421-2099-1-git-send-email-maxime.ripard@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1723 Lines: 48 The next_event logic was setting the next interval to fire in the current timer value instead of the interval value register, which is obviously wrong. Plus the logic to set the actual value was wrong as well, so this code has always been broken. Signed-off-by: Maxime Ripard --- drivers/clocksource/sun4i_timer.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c index 8bd66df..032e504 100644 --- a/drivers/clocksource/sun4i_timer.c +++ b/drivers/clocksource/sun4i_timer.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -69,9 +70,14 @@ static void sun4i_clkevt_mode(enum clock_event_mode mode, static int sun4i_clkevt_next_event(unsigned long evt, struct clock_event_device *unused) { - u32 u = readl(timer_base + TIMER_CTL_REG(0)); - writel(evt, timer_base + TIMER_CNTVAL_REG(0)); - writel(u | TIMER_CTL_ENABLE | TIMER_CTL_AUTORELOAD, + u32 val = readl(timer_base + TIMER_CTL_REG(0)); + writel(val & ~TIMER_CTL_ENABLE, timer_base + TIMER_CTL_REG(0)); + udelay(1); + + writel(evt, timer_base + TIMER_INTVAL_REG(0)); + + val = readl(timer_base + TIMER_CTL_REG(0)); + writel(val | TIMER_CTL_ENABLE | TIMER_CTL_AUTORELOAD, timer_base + TIMER_CTL_REG(0)); return 0; -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/