From patchwork Sat Jul 27 03:41:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 2834578 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2E2FC9F243 for ; Sat, 27 Jul 2013 03:42:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A07A12013A for ; Sat, 27 Jul 2013 03:42:38 +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 C0EE820137 for ; Sat, 27 Jul 2013 03:42:36 +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 1V2vOj-0006ht-9Z; Sat, 27 Jul 2013 03:42:25 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V2vOh-0000Oh-1V; Sat, 27 Jul 2013 03:42:23 +0000 Received: from smtp21.mail.ru ([94.100.176.174]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V2vOd-0000ON-HN for linux-arm-kernel@lists.infradead.org; Sat, 27 Jul 2013 03:42:20 +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=Z/SkNBpRjC96Ltsh/wrsaINcbc1KQGctd8GhYQtm3iQ=; b=jnpkJ4QWc7X6IbIqAVxDxWRvEJ89uGXlm7ZdY5o2ZmUSajoXLbVOJ6pwjwV8SZuhR8GlxlQBhukOLWoC4n0eqPdUZ8kixaLOUF1Ey8k5ZrUgDx7fdDn4zRI/LR+3P1s6VqX2Sh55xXKhvO8EFXnZkJEvVD35Af2kBDjL0diXr48=; Received: from [188.134.40.128] (port=19160 helo=shc.zet) by smtp21.mail.ru with esmtpa (envelope-from ) id 1V2vOF-00021h-Jz; Sat, 27 Jul 2013 07:41:55 +0400 From: Alexander Shiyan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: imx: pllv1: Fix PLL calculation for i.MX27 Date: Sat, 27 Jul 2013 07:41:40 +0400 Message-Id: <1374896500-21862-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-20130726_234220_062764_6F392B39 X-CRM114-Status: UNSURE ( 9.90 ) X-CRM114-Notice: Please train this message. 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.5 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..e76d601 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 & 0x200; + 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;