From patchwork Fri Jun 14 07:41:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 2720521 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 D893A9F472 for ; Fri, 14 Jun 2013 07:41:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC475201EF for ; Fri, 14 Jun 2013 07:41:47 +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 89E60201ED for ; Fri, 14 Jun 2013 07:41:45 +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 1UnOdi-0007pe-IV; Fri, 14 Jun 2013 07:41:43 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UnOdf-0000aE-SM; Fri, 14 Jun 2013 07:41:39 +0000 Received: from f400.i.mail.ru ([185.5.136.71]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UnOdc-0000Zm-Hv for linux-arm-kernel@lists.infradead.org; Fri, 14 Jun 2013 07:41:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Content-Type:Message-ID:Reply-To:Date:Mime-Version:Subject:To:From; bh=X+NigC9+9M2615gfTMODmTAIBTrOjCIbCVaNVFpm0ZM=; b=YMPXY2sjlltjfiEhHbk5u0+tJvJp+CAuch68YY6yQdM6Z+qAY8DwrwtaA4TJT1b1gMriHiNJucYd9ylHsLW9nAPHIwvO8Iv7K8Whihi5QS0VwqMBHGHZDWdMFjNVoWnj; Received: from mail by f400.i.mail.ru with local (envelope-from ) id 1UnOdC-0002Qi-2u; Fri, 14 Jun 2013 11:41:10 +0400 Received: from [217.119.30.118] by e.mail.ru with HTTP; Fri, 14 Jun 2013 11:41:10 +0400 From: =?UTF-8?B?QWxleGFuZGVyIFNoaXlhbg==?= To: linux-kernel@vger.kernel.org, =?UTF-8?B?R3JlZyBLcm9haC1IYXJ0bWFu?= , devel@driverdev.osuosl.org, =?UTF-8?B?U2FzY2hhIEhhdWVy?= , linux-arm-kernel@lists.infradead.org, =?UTF-8?B?U2hhd24gR3Vv?= , =?UTF-8?B?UGhpbGlwcCBaYWJlbA==?= Subject: =?UTF-8?B?W1JGQ10gU3RhZ2luZzogaW14LWRybTogRG8gbm90IHVzZSBmcmFjdGlvbmFs?= =?UTF-8?B?IHBhcnQgb2YgZGl2aWRlcg==?= Mime-Version: 1.0 X-Mailer: Mail.Ru Mailer 1.0 X-Originating-IP: [217.119.30.118] Date: Fri, 14 Jun 2013 11:41:10 +0400 X-Priority: 3 (Normal) Message-ID: <1371195670.904413971@f400.i.mail.ru> X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130614_034137_185100_46E13011 X-CRM114-Status: UNSURE ( 5.98 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.3 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: =?UTF-8?B?QWxleGFuZGVyIFNoaXlhbg==?= 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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, FROM_EXCESS_BASE64, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, 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 Hello. Analysis of driver imx-drm led me to believe that the use fractional part of the divider is not always a good idea. For example, for a parallel display bus connected to LVDS converter chip (DS90C363), in this case the use of fractional part, clock will unstable and the on-chip PLL is not working properly, or rather, does not work at all. Let me give a specific example. ipu_crtc_mode_set 0x36314752 imx-ipuv3 40000000.ipu: clk_di_round_rate: inrate: 133000000 div: 0x00000035 outrate: 40150928 wanted: 40000000 imx-ipuv3 40000000.ipu: clk_di_round_rate: inrate: 133000000 div: 0x00000035 outrate: 40150928 wanted: 40150928 imx-ipuv3 40000000.ipu: clk_di_set_rate: inrate: 133000000 desired: 40150928 div: 0x00000035 In this case the divider is 3.5, that result to clock is incorrect. See an attached oscillogram F0000TEK.jpg. After a patch the clocks is OK. Patch just uncomment some FSL code. imx-ipuv3 40000000.ipu: clk_di_round_rate: inrate: 133000000 div: 0x00000040 outrate: 33250000 wanted: 40000000 imx-ipuv3 40000000.ipu: clk_di_round_rate: inrate: 133000000 div: 0x00000040 outrate: 33250000 wanted: 33250000 imx-ipuv3 40000000.ipu: clk_di_set_rate: inrate: 133000000 desired: 33250000 div: 0x00000040 See an attached oscillogram F0001TEK.jpg. So, I want to review this from developers and wait for comments. diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/staging/imx-drm/ipu-v3/ipu-di.c index 19d777e..d424c22 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c @@ -154,22 +154,15 @@ static int ipu_di_clk_calc_div(unsigned long inrate, unsigned long outrate) if (div < 0x10) div = 0x10; - -#ifdef WTF_IS_THIS - /* - * Freescale has this in their Kernel. It is neither clear what - * it does nor why it does it - */ - if (div & 0x10) - div &= ~0x7; else { /* Round up divider if it gets us closer to desired pix clk */ - if ((div & 0xC) == 0xC) { + if (div & 0x0f) { div += 0x10; - div &= ~0xF; + /* Strip fractional part of divider */ + div &= ~0x0f; } } -#endif + return div; }