From patchwork Mon Dec 18 00:35:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10118443 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 8972560390 for ; Mon, 18 Dec 2017 08:38:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7733A28917 for ; Mon, 18 Dec 2017 08:38:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C0E12893F; Mon, 18 Dec 2017 08:38:15 +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 E3D2B28917 for ; Mon, 18 Dec 2017 08:38:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4ED0589F5F; Mon, 18 Dec 2017 08:38:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from relmlie2.idc.renesas.com (relmlor3.renesas.com [210.160.252.173]) by gabe.freedesktop.org (Postfix) with ESMTP id B7FAB89F27 for ; Mon, 18 Dec 2017 00:36:01 +0000 (UTC) Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 18 Dec 2017 09:36:00 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 3674C4B934; Mon, 18 Dec 2017 09:36:00 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.45,419,1508770800"; d="scan'208";a="266650268" Received: from mail-pu1apc01lp0016.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.16]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 18 Dec 2017 09:35:59 +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=vhBsq+Hg2uXDG3EQiHmiSfSo5CusRl+7J8910O6Zv6U=; b=dgkWON9QBZft1xlNS7zawm0xSqp5XWMAECehpaPMMhFWUQ88V3U8eTCaxMGkgNgbCGrgMg9sElzwLOsL6i3VRWTKGM1FHQdHuPT66juoQwhXLx/NWiLWvtrvaXIwbQeGBRO6x+lB5bZu3ZIkT+51O+AiwxvNgwIec1rPDkxAKM0= Received: from morimoto-PC.renesas.com (211.11.155.138) by HK2PR0601MB1873.apcprd06.prod.outlook.com (2603:1096:202:a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Mon, 18 Dec 2017 00:35:56 +0000 Message-ID: <87o9mwridk.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v4 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 , Geert Uytterhoeven , David Airlie In-Reply-To: <87r2rsrifu.wl%kuninori.morimoto.gx@renesas.com> References: <87r2rsrifu.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Mon, 18 Dec 2017 00:35:56 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: KAXPR01CA0046.jpnprd01.prod.outlook.com (2603:1096:402:1a::32) To HK2PR0601MB1873.apcprd06.prod.outlook.com (2603:1096:202:a::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b3d5c656-d076-4bb2-8aae-08d545af4e38 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:HK2PR0601MB1873; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1873; 3:8X83H3O9rq3GXOoVe4FTSQ/Lv//65grS4jf1b9gtbZ0sDDYtLQJHLGyDIAjJUYCiOqNA4k3X3exGug6xQc4lkUosgmqQkTad+nBXu6n1tshHXhwKCO7sHdlf/5ZkZPuk2VXhmgORbE4U+A4MptcL2tn1h6oTPprQNZ+I2BtHmiDJHrvTdNGiPreQjO1cQAxS/xatOb0ijXSH9A3KNLbkCQtaXMhYqWV1Qav7jEyy7AVb1jqJZxLNNIj7TpnEUPzF; 25:+YHPRcf8MJ6aMlS/p8z9Y9y8TcfP2DMnWIIcj0jm0bYZhK2OTw8tIARvB7sgKKvcTq0IRZHUSzgEI1bpnFA8aN4pXYbAbVk1N1WPP15940TeoOYMJJilP0OovZeESm1ijTiscbpe8c/vLjt90yxfXZOXQFouZ3mI1KlN2FjZbnvdxyGI0hIUOToOxN8UhRfXDqQsmmzxrJxnHo8fHxPw9CUhrDzyoxTIDAezxn+UiwtOxlgEU97vr+BwcgmJZKzoM5PjVgx4TkkSCgiVGB1DOE098mIwH6VaL4cEl09Ns/pBX+RezbbbhL9cMUq70uwMNO31xlUqa7urfEVSf6P7uGsY5p2ipYarR91HQhjLiwc=; 31:/C5pFszuO6Cn6/Q8AyB62RGy1qhZZ+UMw1CVILWW3E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change-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231023)(3002001)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(6072148)(201708071742011); SRVR:HK2PR0601MB1873; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HK2PR0601MB1873; X-Forefront-PRVS: 0525BB0ADF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(39850400004)(396003)(376002)(366004)(189003)(199004)(8676002)(81156014)(478600001)(2950100002)(2906002)(5660300001)(66066001)(47776003)(50466002)(7736002)(305945005)(76176011)(7696005)(4326008)(52116002)(386003)(59450400001)(6486002)(25786009)(83506002)(58126008)(68736007)(316002)(8936002)(36756003)(53936002)(69596002)(16526018)(81166006)(97736004)(53416004)(110136005)(54906003)(105586002)(106356001)(23726003)(86362001)(16586007)(6116002)(3846002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR0601MB1873; 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) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR0601MB1873; 23:1nxlLmbgQnMWCe20GyXZJxPIeZzn+PTaj9GoDt8?= =?us-ascii?Q?4AF9jNqoOrMIseokkqFGX3mygvisBtrl1x9aZRlv7YRqNG6u0OiaAfyVXKym?= =?us-ascii?Q?AeINltj+WGD1+bGSf8Bp50N+e6U3Un1ugVThNKNJB7bNbU+8m8XiaWvBl75Y?= =?us-ascii?Q?+0RtBAS8iRqSQpAbDeaAKG/3vTKwfpNfFy29y4Lfj/8psjr+LjBuNJDfMg4o?= =?us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A6aSBI9yRAliZ62?= =?us-ascii?Q?kZr63YSzmUiM=3D?= X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1873; 6:oAx3m+991tnmcdwVQekCfU6HQzlIS/e/mvpio1jlSGGp4+yispvjMKZgcXbqYd7xkZx0ICDWI3WeijKK9LteLBG+MZXsx+ZxmXOYkXyWNerJuLMR7LvCbbfqxRvmzjrxayo4th449EH55kcOJ/JDxbP1eyPZGTGMHODgI9QF//0SnnuYZnfuCx/pH1bR3zrDriDnY/lEae2Jbjbv+vLwwJiQzeW92cX47cJBABWyGswkbcKRslR/oENQrNrMHkeSy7OmTHYNintSuDwfmFB9CYjFgAK3NZO9DfqeK7THy1ic9RdgLgYfWmJTLiq61Ujn4xg5+iDZulqotU7fGl46oANkHMUZy5lwCmmawq0EtFg=; 5:/HVl5GUWzF+4uYgA6ZZl4RWdRf9qR4yy9bcUnyj4sy7PQ1q7yAQ07z/goPPchZw5eJRLG7sfKgANxiI1EO/HJ8Ul0Y3iOlZ/ui0Q9b7EUtqpslDPjNtLesbpJBZMdHF7O51qGiz6fptjIvDdRCBOJqeh+5PbJQ1v2h3yA2Cm8DI=; 24:uu7jyOhQxRlxFeUd1Sf5mQIoJ9pmcbmgHhC0+jCVnJehIBrlcJ562BbfgMJMqSNty6gzUbB1PA6wQNhGtoKQNqqpNfYxiQ0p2YK8CU74xqE=; 7:q8Acls2ZT44xsVfkrcbInd23Dp4i2aojjgfcSLBxfJBm91B36GLGwzenuBUTnK6yKC1W5Oues5kMW0IZWOf1mUFcilv1QoOxMtCL6U1H/lot25Jrzv4eqIu93N5T5PilgTYMdnglG4Ff+PsSC96RUKtaRUqnILEu88bi2xCFIovTzRsD8yfgF02v+CLdpgfFLBwb8qNfNRJIfri5lReJi6xHApxswg+Dg7e82C9yP+3l9wgvtm2VrnKExG781+fU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1873; 20:7GhO5DLecWZpzs0t2sqTxcLgR6DHpu9LooQFu3uat2DOegB+xUhoBKUHVjYio7Gwjh1R0VNO7C2zRZzqReA1sP+g8NagLiHuSI0AiFhVr94yuD7wIRIozhyX54j0A/QWQFCGihzXJ03gueqse8cweM7iNq0JD4/CzWUS5YIfn/k= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2017 00:35:56.7339 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3d5c656-d076-4bb2-8aae-08d545af4e38 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1873 X-Mailman-Approved-At: Mon, 18 Dec 2017 08:38:01 +0000 Cc: Linux-Renesas , Linux-Kernel , 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 2kHz < 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 --- v3 -> v4 - 2000 -> 2kHz 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..574854a 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 + * 2kHz < 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;