From patchwork Tue Jul 23 23:32:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2832378 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 272ADC0319 for ; Tue, 23 Jul 2013 23:33:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E831C203FF for ; Tue, 23 Jul 2013 23:33:09 +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 EFECD203FE for ; Tue, 23 Jul 2013 23:33:08 +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 1V1m4l-0003wi-Kf; Tue, 23 Jul 2013 23:33:03 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1m4j-0003fJ-De; Tue, 23 Jul 2013 23:33:01 +0000 Received: from mail-bk0-x229.google.com ([2a00:1450:4008:c01::229]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1m4g-0003ep-6Z for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2013 23:32:59 +0000 Received: by mail-bk0-f41.google.com with SMTP id jc3so3299018bkc.28 for ; Tue, 23 Jul 2013 16:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding:content-type; bh=bHF/Ro8LibVJre6FMDOxgr60OBQgtecEoQ6APCf1ou8=; b=Ybe3JHqfWPrLACHjcgLXYc6cItx61vRpBNNejPWW4insfoV7NjyXMLCrA4922l/Fd/ MTcUXGR2NJkbXtKFw3+gyX4L9SZYji95EShI5Q2z39L7Kd2yUhKkYKPsQ166sqOSnawU aydxWmaKnyk1Qa7kg+/FQ4eeTPTyZYZWkYUh1YiCOPHUo6UDKNd8VpNb6hZBgxG6T+vN pDdw3UPCDoj1dZV/5mqikwfTLjIqvbsDyPSf3bcMU3BhWrAtnV0K2VsfVhCoiYlDREQJ zdum/965dJWtsZK2h5OC1neRodgAytKDlombGQEGJzygrACkRFh8oZjavTiVz6UUf5Cz eXrw== X-Received: by 10.205.21.129 with SMTP id qs1mr5095854bkb.13.1374622354316; Tue, 23 Jul 2013 16:32:34 -0700 (PDT) Received: from flatron.localnet (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id fc7sm8817800bkc.3.2013.07.23.16.32.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Jul 2013 16:32:33 -0700 (PDT) From: Tomasz Figa To: Daniel Lezcano Subject: [PATCH v6 02/20] clocksource: samsung_pwm_timer: Correct definition of AUTORELOAD bit Date: Wed, 24 Jul 2013 01:32:31 +0200 Message-ID: <2416336.ny4L9Sf7Ts@flatron> User-Agent: KMail/4.10.5 (Linux/3.10.1-gentoo; KDE/4.10.5; x86_64; ; ) In-Reply-To: <51EDA3EA.9020502@linaro.org> References: <1374278673-25615-1-git-send-email-tomasz.figa@gmail.com> <1658534.7nG6RFjcTc@flatron> <51EDA3EA.9020502@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130723_193258_376780_480C5FD2 X-CRM114-Status: GOOD ( 11.63 ) X-Spam-Score: -2.0 (--) Cc: linux-pwm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Heiko =?ISO-8859-1?Q?St=FCbner?= , Arnd Bergmann , Mark Brown , Kukjin Kim , Thierry Reding , Olof Johansson , Sylwester Nawrocki , 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 PWM channel 4 has its autoreload bit located at different position. This patch fixes the driver to account for that. This fixes a problem with the clocksource hanging after it overflows because it is not reloaded any more. Signed-off-by: Tomasz Figa Reviewed-by: Sylwester Nawrocki Acked-by: Daniel Lezcano --- drivers/clocksource/samsung_pwm_timer.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) Changes since v5: - Added more detailed comment about bit layout in TCON register. diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c index 3fa5b07..5d0049f 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c @@ -44,10 +44,21 @@ #define TCFG1_SHIFT(x) ((x) * 4) #define TCFG1_MUX_MASK 0xf +/* + * Each channel occupies 4 bits in TCON register, but there is a gap of 4 + * bits (one channel) after channel 0, so channels have different numbering + * when accessing TCON register. + * + * In addition, the location of autoreload bit for channel 4 (TCON channel 5) + * in its set of bits is 2 as opposed to 3 for other channels. + */ #define TCON_START(chan) (1 << (4 * (chan) + 0)) #define TCON_MANUALUPDATE(chan) (1 << (4 * (chan) + 1)) #define TCON_INVERT(chan) (1 << (4 * (chan) + 2)) -#define TCON_AUTORELOAD(chan) (1 << (4 * (chan) + 3)) +#define _TCON_AUTORELOAD(chan) (1 << (4 * (chan) + 3)) +#define _TCON_AUTORELOAD4(chan) (1 << (4 * (chan) + 2)) +#define TCON_AUTORELOAD(chan) \ + ((chan < 5) ? _TCON_AUTORELOAD(chan) : _TCON_AUTORELOAD4(chan)) DEFINE_SPINLOCK(samsung_pwm_lock); EXPORT_SYMBOL(samsung_pwm_lock);