From patchwork Mon Jul 29 15:37:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 2835044 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 B4D86C0319 for ; Mon, 29 Jul 2013 15:38:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8C99B202BA for ; Mon, 29 Jul 2013 15:38:12 +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 DE3ED20277 for ; Mon, 29 Jul 2013 15:38:10 +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 1V3pWR-0005Ur-P2; Mon, 29 Jul 2013 15:38:08 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V3pWP-0006OY-DK; Mon, 29 Jul 2013 15:38:05 +0000 Received: from smtp34.i.mail.ru ([94.100.177.94]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V3pWM-0006Mm-IE for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2013 15:38:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=eZWV7SZnX5jBhnOwlgcNvVw6CFeqr7F73S6Dd9Y2LJI=; b=NTrn87Q2Ko8a5zI08km2/b9rcESxUOcbi6S3p87TnAkBe4zU/cipl7AzJW3NxnAGJfa74e0Ri/SX4Ja5maPoRMR5Yb0J6kCofGWlBl3+EeEoGgBB3KMNNv/CA8rnuEKStawepI3xhbi8Rok4+T4ONUVxoOaGTFpjLf5rOYAVtXY=; Received: from [188.134.40.128] (port=44346 helo=shc.zet) by smtp34.i.mail.ru with esmtpa (envelope-from ) id 1V3pVy-0002Ee-NV; Mon, 29 Jul 2013 19:37:38 +0400 From: Alexander Shiyan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] ARM: imx: pllv1: Fix PLL calculation for i.MX27 Date: Mon, 29 Jul 2013 19:37:23 +0400 Message-Id: <1375112243-1557-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.1.5 X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130729_113803_158715_1B68CE90 X-CRM114-Status: GOOD ( 10.78 ) X-Spam-Score: -2.0 (--) Cc: Russell King , Alexander Shiyan , Sascha Hauer 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 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, 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 MFN bit 9 on i.MX27 has a different meaning than in other SOCs. This is a just sign bit. This patch makes different calculation for i.MX27. Signed-off-by: Alexander Shiyan --- arch/arm/mach-imx/clk-pllv1.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/clk-pllv1.c b/arch/arm/mach-imx/clk-pllv1.c index c1eaee3..a289ccd 100644 --- a/arch/arm/mach-imx/clk-pllv1.c +++ b/arch/arm/mach-imx/clk-pllv1.c @@ -25,6 +25,11 @@ struct clk_pllv1 { #define to_clk_pllv1(clk) (container_of(clk, struct clk_pllv1, clk)) +static inline bool allow_signed_mfn(void) +{ + return !cpu_is_mx1() && !cpu_is_mx21(); +} + static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { @@ -59,9 +64,14 @@ static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw, /* * On all i.MXs except i.MX1 and i.MX21 mfn is a 10bit * 2's complements number + * On i.MX27 the bit 9 is the sign bit. */ - if (!cpu_is_mx1() && !cpu_is_mx21() && mfn >= 0x200) - mfn_abs = 0x400 - mfn; + if (allow_signed_mfn() && (mfn & 0x200)) { + if (cpu_is_mx27()) + mfn_abs = mfn & 0x1ff; + else + mfn_abs = 0x400 - mfn; + } rate = parent_rate * 2; rate /= pd + 1; @@ -70,7 +80,7 @@ static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw, do_div(ll, mfd + 1); - if (!cpu_is_mx1() && !cpu_is_mx21() && mfn >= 0x200) + if (allow_signed_mfn() && (mfn & 0x200)) ll = -ll; ll = (rate * mfi) + ll;