From patchwork Fri Jul 5 22:55:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 2824463 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 252D5C0AB2 for ; Fri, 5 Jul 2013 23:51:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2CFB720188 for ; Fri, 5 Jul 2013 23:51:46 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1AEB20158 for ; Fri, 5 Jul 2013 23:51:44 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvEvj-0001di-8f; Fri, 05 Jul 2013 22:56:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvEv1-0000oL-OA; Fri, 05 Jul 2013 22:55:59 +0000 Received: from gloria.sntech.de ([95.129.55.99]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvEuy-0000nP-8U for linux-arm-kernel@lists.infradead.org; Fri, 05 Jul 2013 22:55:56 +0000 Received: from 146-52-210-25-dynip.superkabel.de ([146.52.210.25] helo=marty.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1UvEub-0005XK-2r; Sat, 06 Jul 2013 00:55:33 +0200 From: Heiko =?utf-8?q?St=C3=BCbner?= To: John Stultz Subject: [PATCH 7/9] clocksource: dw_apb_timer: quirk for inverted timer mode setting Date: Sat, 6 Jul 2013 00:55:31 +0200 User-Agent: KMail/1.13.7 (Linux/3.2.0-3-686-pae; KDE/4.8.4; i686; ; ) References: <201307060051.09716.heiko@sntech.de> In-Reply-To: <201307060051.09716.heiko@sntech.de> MIME-Version: 1.0 Message-Id: <201307060055.31882.heiko@sntech.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130705_185556_430200_97CF1A54 X-CRM114-Status: GOOD ( 14.11 ) X-Spam-Score: -2.1 (--) Cc: Arnd Bergmann , devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, Rob Herring , Olof Johansson , Dinh Nguyen , Grant Likely , Jamie Iles , Thomas Gleixner , Ulrich Prinz , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ulrich Prinz Some variants of SOCs using dw_apb_timer have inverted logic for the bit that sets one-shot / periodic mode or free running timer. This commit adds the new APBTMR_QUIRK_INVERSE_PERIODIC. Signed-off-by: Ulrich Prinz --- drivers/clocksource/dw_apb_timer.c | 11 +++++++++-- include/linux/dw_apb_timer.h | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/clocksource/dw_apb_timer.c b/drivers/clocksource/dw_apb_timer.c index 7705d13..a2e8306 100644 --- a/drivers/clocksource/dw_apb_timer.c +++ b/drivers/clocksource/dw_apb_timer.c @@ -159,7 +159,11 @@ static void apbt_set_mode(enum clock_event_mode mode, case CLOCK_EVT_MODE_PERIODIC: period = DIV_ROUND_UP(timer->freq, HZ); ctrl = apbt_readl(timer, timer->reg_control); - ctrl |= APBTMR_CONTROL_MODE_PERIODIC; + + if (timer->quirks & APBTMR_QUIRK_INVERSE_PERIODIC) + ctrl &= ~APBTMR_CONTROL_MODE_PERIODIC; + else + ctrl |= APBTMR_CONTROL_MODE_PERIODIC; apbt_writel(timer, ctrl, timer->reg_control); /* * DW APB p. 46, have to disable timer before load counter, @@ -186,7 +190,10 @@ static void apbt_set_mode(enum clock_event_mode mode, * the next event, therefore emulate the one-shot mode. */ ctrl &= ~APBTMR_CONTROL_ENABLE; - ctrl &= ~APBTMR_CONTROL_MODE_PERIODIC; + if (timer->quirks & APBTMR_QUIRK_INVERSE_PERIODIC) + ctrl |= APBTMR_CONTROL_MODE_PERIODIC; + else + ctrl &= ~APBTMR_CONTROL_MODE_PERIODIC; apbt_writel(timer, ctrl, timer->reg_control); /* write again to set free running mode */ diff --git a/include/linux/dw_apb_timer.h b/include/linux/dw_apb_timer.h index 7d36d91..5d9210cc 100644 --- a/include/linux/dw_apb_timer.h +++ b/include/linux/dw_apb_timer.h @@ -36,6 +36,12 @@ */ #define APBTMR_QUIRK_INVERSE_INTMASK BIT(2) +/* The IP uses inverted logic for the bit setting periodic mode. + * Periodic means it times out after the period is over and is set to + * 1 in the original IP. This IP uses 1 for free running mode. + */ +#define APBTMR_QUIRK_INVERSE_PERIODIC BIT(3) + struct dw_apb_timer { void __iomem *base; unsigned long freq;