From patchwork Tue Jan 22 16:44:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Afzal Mohammed X-Patchwork-Id: 2019381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 8C0AA3FD1A for ; Tue, 22 Jan 2013 16:47:05 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TxgxZ-00026h-Qm; Tue, 22 Jan 2013 16:44:30 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TxgxQ-00024W-Rw for linux-arm-kernel@lists.infradead.org; Tue, 22 Jan 2013 16:44:22 +0000 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0MGiCGi015174; Tue, 22 Jan 2013 10:44:13 -0600 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0MGiCrK008271; Tue, 22 Jan 2013 22:14:12 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Tue, 22 Jan 2013 22:14:12 +0530 Received: from psplinux063.india.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0MGiBIf004379; Tue, 22 Jan 2013 22:14:12 +0530 From: Afzal Mohammed To: , , Subject: [PATCH 1/4] ARM: OMAP2+: dpll: round rate to closest value Date: Tue, 22 Jan 2013 22:14:11 +0530 Message-ID: <2e1a48e0a326e914c8a7497f9a61243387c61862.1358871018.git.afzal@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130122_114421_092942_FADDB361 X-CRM114-Status: GOOD ( 11.07 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.94.94.40 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.7 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: Tony Lindgren , Mike Turquette , Paul Walmsley , Russell King X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently round rate function would return proper rate iff requested rate exactly matches the PLL lockable rate. This causes set_rate to fail if exact rate could not be set. Instead round rate may return closest rate possible (less than the requested). And if any user is badly in need of exact rate, then return value of round rate could be used to decide whether to invoke set rate or not. Modify round rate so that it return closest possible rate. This was required to get display working on am335x. Without this display rate could not be set (taking help of SET_RATE_PARENT). Couple of the downstream clocks of display PLL are basic clock dividers and they do MULT_ROUND_UP before requesting rate on PLL causing values that mostly could not be locked by PLL. And even otherwise, if requested rate for a particular pixel clock could not be satisfied by PLL, display would not work. This change will resolve the issue. Signed-off-by: Afzal Mohammed --- arch/arm/mach-omap2/clkt_dpll.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c index 924c230..15e6d41 100644 --- a/arch/arm/mach-omap2/clkt_dpll.c +++ b/arch/arm/mach-omap2/clkt_dpll.c @@ -345,20 +345,22 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate, pr_debug("clock: %s: m = %d: n = %d: new_rate = %ld\n", clk_name, m, n, new_rate); - if (target_rate == new_rate) { + if ((new_rate <= target_rate) && + (new_rate > dd->last_rounded_rate)) { dd->last_rounded_m = m; dd->last_rounded_n = n; - dd->last_rounded_rate = target_rate; - break; + dd->last_rounded_rate = new_rate; + if (new_rate == target_rate) + break; } } - if (target_rate != new_rate) { + if (!dd->last_rounded_rate) { pr_debug("clock: %s: cannot round to rate %ld\n", clk_name, target_rate); return ~0; } - return target_rate; + return dd->last_rounded_rate; }