From patchwork Tue Apr 23 15:46:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2479661 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 547BB3FCA5 for ; Tue, 23 Apr 2013 18:42:29 +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 1UUfTt-0007Jk-Py; Tue, 23 Apr 2013 15:50:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUfSt-0004MN-05; Tue, 23 Apr 2013 15:49:07 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUfSf-0004Le-3C for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2013 15:48:53 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MLP001JST9G7M20@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2013 00:48:52 +0900 (KST) X-AuditID: cbfee61b-b7f8e6d000000f44-83-5176ad636de1 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 91.B0.03908.36DA6715; Wed, 24 Apr 2013 00:48:52 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MLP0032TT5SFQ80@mmp1.samsung.com>; Wed, 24 Apr 2013 00:48:51 +0900 (KST) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 08/13] clocksource: samsung_pwm_timer: Correct programming of clock events Date: Tue, 23 Apr 2013 17:46:29 +0200 Message-id: <1366731994-7478-9-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1366731994-7478-1-git-send-email-t.figa@samsung.com> References: <1366731994-7478-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t9jAd2UtWWBBsfvMVr8nXSM3WLSugNM FgdmP2S1OPNb16J3wVU2i7NNb9gtNj2+xmox4/w+Jou1R+6yW5y6/pnNYv2M1ywWmzdNZbY4 NmMJo8WqXX8YHfg8fv+axOjxd9ULZo+ds+6ye9y5tofN4925c+wem5fUe5yfsZDR48qJJlaP vi2rGD0+b5IL4IrisklJzcksSy3St0vgyti/4z1LwQ++ih3H2lgbGM/zdDFyckgImEhMf9vB CmGLSVy4t56ti5GLQ0hgEaPEnguTGCGcLiaJfQtvs4BUsQmoSXxueMQGYosIaEhM6XrMDlLE LHCJSWL+rk1go4QF4iX6HzaDNbAIqEr0TlrABGLzCjhKPF6ykhFinbzE0/t9YIM4BZwkdh59 CGYLAdUc/dvONIGRdwEjwypG0dSC5ILipPRcI73ixNzi0rx0veT83E2M4GB+Jr2DcVWDxSFG AQ5GJR7eF7PKAoVYE8uKK3MPMUpwMCuJ8FrPBgrxpiRWVqUW5ccXleakFh9ilOZgURLnPdhq HSgkkJ5YkpqdmlqQWgSTZeLglGpgtMubwH/m2vU73KyrNtV9MdDT2R2559fE56XmsR3C/2Z9 kGFP/jnrbG3R3xqzFsfnk3de+moygWn1/gLdD2tmc/+csT8unv+Uyse/G2bUOSXn3D++0d7w 5Dd7lX+/cutbHwqp3c2yMlOrunF0o3XoXF/GuYu8kmxYM+1N6h6s0Mv59+nD+mleW5VYijMS DbWYi4oTATYkmcBiAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130423_114853_406376_EAFDDEF6 X-CRM114-Status: GOOD ( 10.40 ) X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.33 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, arnd@arndb.de, devicetree-discuss@lists.ozlabs.org, tomasz.figa@gmail.com, kyungmin.park@samsung.com, linux-samsung-soc@vger.kernel.org, john.stultz@linaro.org, ben-linux@fluff.org, olof@lixom.net, thomas.abraham@linaro.org, tglx@linutronix.de, Tomasz Figa , m.szyprowski@samsung.com 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In current code, the tick count value programmed to the hardware is always decremented by one. This is reasonable for periodic mode, since there is one extra tick between 0 and COUNT (after reloading), but it makes oneshot events happen 1 tick earlier than requested, because the interrupt is triggered on transition from 1 to 0. This patch removes the decrementation from PWM channel setup code and moves it instead to periodic timer setup, to make both periodic and oneshot modes work correctly. Signed-off-by: Tomasz Figa Signed-off-by: Kyungmin Park --- drivers/clocksource/samsung_pwm_timer.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c index cb86615..92b2f13 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c @@ -138,8 +138,6 @@ static void samsung_time_setup(unsigned int channel, unsigned long tcnt) tcon = __raw_readl(pwm.base + REG_TCON); - tcnt--; - tcon &= ~(TCON_START(tcon_chan) | TCON_AUTORELOAD(tcon_chan)); tcon |= TCON_MANUALUPDATE(tcon_chan); @@ -187,7 +185,7 @@ static int samsung_set_next_event(unsigned long cycles, static void samsung_timer_resume(void) { /* event timer restart */ - samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick); + samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick - 1); samsung_time_start(pwm.event_id, true); /* source timer restart */ @@ -202,7 +200,7 @@ static void samsung_set_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick); + samsung_time_setup(pwm.event_id, pwm.clock_count_per_tick - 1); samsung_time_start(pwm.event_id, true); break;