From patchwork Fri Dec 15 01:24:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10114189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E457860224 for ; Fri, 15 Dec 2017 08:26:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C958C29E16 for ; Fri, 15 Dec 2017 08:26:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD83F29F1E; Fri, 15 Dec 2017 08:26:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B588129E16 for ; Fri, 15 Dec 2017 08:26:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD3106E076; Fri, 15 Dec 2017 08:26:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from relmlie1.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 249E16E769 for ; Fri, 15 Dec 2017 01:24:20 +0000 (UTC) Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie1.idc.renesas.com with ESMTP; 15 Dec 2017 10:24:20 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 2E079691C4; Fri, 15 Dec 2017 10:24:20 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.45,402,1508770800"; d="scan'208";a="266431234" Received: from mail-pu1apc01lp0023.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.23]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2017 10:24:19 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=J4bUlblq3C9+FsfKQroL67GFtBvAZFS/Fl9gn0+ku2g=; b=A7/bho7WGXl83hG/S/HQYVx5Bixyn2tp5GRtE8SjCc3fbHHx7IHvZvIYZteOVI0gyb+Y8HolowScM5InFTRvePdTiVqShHffQxBDQkG0y1HKuZQPZozjpOuW4YBHkgw+63eKy+F9P5oQqAFOU5M2Aj0GSRG8fkGgVJwgNs57D4Q= Received: from morimoto-PC.renesas.com (211.11.155.138) by PS1PR0601MB1881.apcprd06.prod.outlook.com (2603:1096:803:8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Fri, 15 Dec 2017 01:24:16 +0000 Message-ID: <871sjweqr4.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 2/2] drm: rcar-du: calculate DPLLCR to be more small jitter User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Laurent Pinchart , David Airlie In-Reply-To: <874loseqvp.wl%kuninori.morimoto.gx@renesas.com> References: <874loseqvp.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 15 Dec 2017 01:24:16 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: KAWPR01CA0064.jpnprd01.prod.outlook.com (2603:1096:402:b::24) To PS1PR0601MB1881.apcprd06.prod.outlook.com (2603:1096:803:8::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f0dd2b5-790b-43be-d64b-08d5435a8f0f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603307); SRVR:PS1PR0601MB1881; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1881; 3:5q9XSKIAAp708O+Nk31Owy5UMPM7YCwd45hjJB1kfFQHLgZ+PEcgpvTzJ6l+hS/fkav68svWXV9uYaPlEoK6n/ytPxpFEjv49cLY2w8H62cDdnHbIJU2xHZj6/RYFGM9m9nVTMXQGcMYfhOqHBi0DMq0/fhIuxplt32GpZ2YoUOYsbSIP33mP1hnV5YMg/9SBuC1AcZWEHKDAz58ZFSV6rjX2ZVvMJaiehapDAGtq2jRd64T2nfq7jiJ6k2V+MCX; 25:wDN87z8ckYt8/pE34nSeC73uo/gomW2ucfUoBm35bUei7+HtOqojSOB1xyiOB4U0QQd36cQsZ0wBMzxdMVfwiIEBodYchVJsdOjGqlITKp4OSm7JS6rDsGbtSJvB96YiPoTOSvCc8L2BgeGBKlYYg3yi3PiL/EUzHmvyFRe+xwGtdcE5LctENNjqpIzQQcvVEJKoG9SGg4c3C0y0ArLoCzRjkSNgnYuMTEguPmb+rmBv+vid08Oaj9PIcz2Xlw6bDD4ZeHM66lPQ18m5cXh6/EACDhCwNiLUht83/2vIEHb6A/GR1YHvRzk5rZiZI1TLpvBwp2t51SbnTClTeWqgjg==; 31:2kPnwcOlBa8wtPyQU1VtYrEnNvmGF+uyCSblksdn0RJTSPNiwF/Z2wlvLu94SL9NHbDJBnkhi0CDuKTUnaQcwTUtXyOs2L6oJtpZ0K1MsUDqYVuTG9OIzyS1UEYE9R64IpxfljsnpItE4ihDm+BAa+sUtcpjxdR7I/4ShAdh6JP03l19JPXXQSzlQDt5eY8NxNoT0//1dx0/YUb3hT+vIAmpPpJ7ttNb71lggaYnglc= X-MS-TrafficTypeDiagnostic: PS1PR0601MB1881: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1881; 20:yItePIJtXv+dMFWqST/KGaGAbHDIr6lHpbBpGGzHJX3QijfCcz0lFORCgMAsEDhDMajZC7pLbbx4+F0ebSeS/zgMsgdkrdVxBEJLyLZUA2uVz+bMold2u0ZFsRlIqhYDoImUp41opndpw6+rnd5Cf0ioVQBgcDD6zItlirEJ0yK0rbOAI1dYC+SPgYsrVXHpMwPE0yeisdn6Ylw8HZbcqOi+MkFm3UzEdaQx1Pa0tkjkNDUrn/3+AqWFD2AcJp1P8+fXY6TDRMLeMHfiGaoIWnUoYiYXXscirxwDqNw92ZSXK9CF1Et7FfMjd25lqhGHdk9I42HdK0wnZp+1JEoSPIZOWKpi3sAtsYi0FXwH/lqMXN6P8zsarhzB5+oJ2LRsAEtsXNJn+IBGKDZu7XTuYr2XTPE9vQwgOS24Pjlul+PL6N5QwPuEHhLcq3iXaJNmohjEiTbufKVKm1oFF1AzXNWgmUUrJraa1onLLRYHQEj+tDQ/L5FfrTv6/EAjH3If; 4:Aco+lLMoSH86iWunamRKD3/DMl/J8swSkr6fOjo4ensTUywAwegR+u/mVVrcSN2mES7+Kqvc7NpQIp7oJUNEmWMofWxu/BaPUXKffKRqZNbvmbWo8lKELeSZzXxYdH+9sRZWMrveeMr86YmoEYpsFWpzxcvJLDIrZi+ACfHcgogMgMDVOvE9aDOd/nEkoX6eLYP83f5NQWDE53/EnkNOizfbRwTwU+kgjgqbHNYpzUvESiNmFEq4l6QrljIXhaWJKEiaQtUaIe732wP0D5QxJw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231023)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123560025)(20161123555025)(6072148)(201708071742011); SRVR:PS1PR0601MB1881; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:PS1PR0601MB1881; X-Forefront-PRVS: 05220145DE X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(396003)(366004)(346002)(189003)(199004)(53416004)(4326008)(16586007)(47776003)(36756003)(66066001)(106356001)(58126008)(16526018)(6116002)(110136005)(54906003)(23726003)(478600001)(105586002)(316002)(69596002)(7696005)(53936002)(83506002)(50466002)(52116002)(3846002)(25786009)(6486002)(86362001)(97736004)(5660300001)(59450400001)(76176011)(2906002)(8936002)(305945005)(81156014)(7736002)(8676002)(2950100002)(81166006)(386003)(68736007)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR0601MB1881; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; PS1PR0601MB1881; 23:Dr8XvY/ZUa9/1kWydyRwgdIfjGMth6OwebJAcnH?= =?us-ascii?Q?5XDWM635hiPhukbNMqPb7isMNlr/wbV5IBf1yJyArYF7c1IStguejOT3YqyJ?= =?us-ascii?Q?lg7gninack6Ty2sFa6WtWkMDZbICrXoothCyyU9DLtkglUMj5O+Xu1aZJzeN?= =?us-ascii?Q?GtxI7woIBvma0i9PaZ64ZHsnnJUTwTddHzbq11sMRJjjFmiAvMGU2cKwTt6U?= =?us-ascii?Q?5Sr+jt2BDVOEtJNVQ8x1zYCcYy/Y/UEFm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FVkPpEdaGVSYHaDr1t7/3KizcTFlghc4cIzOGCRv6mpFm6f7LCxgbwnG7vd/1xLB/k7xan30h5piAeGaWb9T6oxzmCnpSRms/oEdy/DImVrKxBC9Mzgd0lHh+sPNzYhnZduNyFr7s/YXtcCaoMPFPWS/UGnGb4I= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2017 01:24:16.3934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f0dd2b5-790b-43be-d64b-08d5435a8f0f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR0601MB1881 X-Mailman-Approved-At: Fri, 15 Dec 2017 08:26:18 +0000 Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto In general, PLL has VCO (= Voltage controlled oscillator), one of the very important electronic feature called as "jitter" is related to this VCO. In academic generalism, VCO should be maximum to be more small jitter. In high frequency clock, jitter will be large impact. Thus, selecting Hi VCO is general theory. fin fvco fout fclkout in --> [1/M] --> |PD| -> [LPF] -> [VCO] -> [1/P] -+-> [1/FDPLL] -> out +-> | | | | | +-----------------[1/N]<-------------+ fclkout = fvco / P / FDPLL -- (1) In PD, it will loop until fin/M = fvco/P/N fvco = fin * P * N / M -- (2) (1) + (2) indicates fclkout = fin * N / M / FDPLL In this device, N = (n + 1), M = (m + 1), P = 2, FDPLL = (fdpll + 1). fclkout = fin * (n + 1) / (m + 1) / (fdpll + 1) This is the datasheet formula. One note here is that it should be 2000 < fvco < 4096MHz To be smaller jitter, fvco should be maximum, in other words, N as large as possible, M as small as possible driver should select. Here, basically M=1. This patch do it. Reported-by: HIROSHI INOSE Signed-off-by: Kuninori Morimoto --- v2 -> v3 - uses "* 1000" for number - uses "xx000U" for number - uses finnm to avoid duplicate calculation drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 58 +++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 6820461f..bb5ead6 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -125,13 +125,63 @@ static void rcar_du_dpll_divider(struct rcar_du_crtc *rcrtc, unsigned int m; unsigned int n; - for (n = 39; n < 120; n++) { - for (m = 0; m < 4; m++) { + /* + * fin fvco fout fclkout + * in --> [1/M] --> |PD| -> [LPF] -> [VCO] -> [1/P] -+-> [1/FDPLL] -> out + * +-> | | | + * | | + * +-----------------[1/N]<-------------+ + * + * fclkout = fvco / P / FDPLL -- (1) + * + * fin/M = fvco/P/N + * + * fvco = fin * P * N / M -- (2) + * + * (1) + (2) indicates + * + * fclkout = fin * N / M / FDPLL + * + * NOTES + * N : (n + 1) + * M : (m + 1) + * FDPLL : (fdpll + 1) + * P : 2 + * 2000 < fvco < 4096Mhz + * + * To be small jitter, + * N : as large as possible + * M : as small as possible + */ + for (m = 0; m < 4; m++) { + for (n = 119; n > 38; n--) { + /* + * NOTE: + * + * This code is assuming "used" from 64bit CPU only, + * not from 32bit CPU. But both can compile correctly + */ + + /* + * fvco = fin * P * N / M + * fclkout = fin * N / M / FDPLL + * + * To avoid duplicate calculation, let's use below + * + * finnm = fin * N / M + * fvco = finnm * P + * fclkout = finnm / FDPLL + */ + unsigned long finnm = input * (n + 1) / (m + 1); + unsigned long fvco = finnm * 2; + + if (fvco < 2000 || fvco > 4096 * 1000 * 1000U) + continue; + for (fdpll = 1; fdpll < 32; fdpll++) { unsigned long output; - output = input * (n + 1) / (m + 1) - / (fdpll + 1); + output = finnm / (fdpll + 1); if (output >= 400 * 1000 * 1000) continue;