From patchwork Wed Dec 6 06:05:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10095083 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 3497860327 for ; Wed, 6 Dec 2017 08:40:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25D5629C54 for ; Wed, 6 Dec 2017 08:40:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18D5F29C56; Wed, 6 Dec 2017 08:40:05 +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 8275829C54 for ; Wed, 6 Dec 2017 08:40:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 44F8A6E6DE; Wed, 6 Dec 2017 08:39:02 +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 8052F6E0EB for ; Wed, 6 Dec 2017 06:05:44 +0000 (UTC) Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 06 Dec 2017 15:05:43 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 21C0579E96; Wed, 6 Dec 2017 15:05:43 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.45,367,1508770800"; d="scan'208";a="264300141" Received: from mail-hk2apc01lp0207.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.207]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 06 Dec 2017 15:05:42 +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=pn6ws/3RHXkQv0bMjU2Tv/7TyZBBv/zs31ABysM+Mh8=; b=ejyTWPO7MJ1foUXf/ujSJyy5fz6m6OjjQCKM9wIyorU7fyX4wGMYWFt7UNDiDnPhJiekfqdhDFVXp9Y2cnDyELH3BbqjQjNbZqLZERLfsz89PJuwutdjoLjkgydsrRD3ggOUqIGznbdP7WUCSpwALfR/l52cFIF+V9fyByO9Ayw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.138) by SG2PR0601MB1887.apcprd06.prod.outlook.com (2603:1096:3:9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Wed, 6 Dec 2017 06:05:38 +0000 Message-ID: <87374oz9f9.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2] 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 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Wed, 6 Dec 2017 06:05:38 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: KAWPR01CA0077.jpnprd01.prod.outlook.com (2603:1096:402:c::13) To SG2PR0601MB1887.apcprd06.prod.outlook.com (2603:1096:3:9::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 070eca25-a28c-4f10-a9a0-08d53c6f6015 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603286); SRVR:SG2PR0601MB1887; X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 3:Oi+zZkodiJVg70YbqwMr1d8YVleqzjNjNgnR5a+q8NlXvvWvLuJ1I7eG9DvJrwuAsg4TL4r/uwd3qkRAhPGS1JApy4lgyUIV0dnTW7EeKMik2PWBjS9az0Avhi78f+ktM5mGSHdgSe9FFXGWT0B9d+pm8WBQDtgz63op6zwxVb9QGNpo9yTjW9S+6FxhwwGZq6NOqXFdNpDH8p7SKXfT4voRs8Fl38Nn8vkn5MGHwlZ6eP3wYe+VG7PSdqFKtVnL; 25:4+WKC2pR6mU8IALA6uqn5aFGyFngAfyJ6L1pmKXUcxshk50KnoUA8FqIB91iDHpRlD7c2hoY9zGpK7UriJ48a89Re8h4repQ4s2c1wnO2wCoooGBVnJo15QeaBWaAZOW5QAajDHlXxdVA+xYzYF7f5e3+g6POuWZbeCquHpSGAsMZU6F7lPvy82BX4hZpgOdtUt8MF5uAMKsKs26+OmgJvHzOl95HZ8AKOz+c7kQtF3tVixi5DE9S3+RjKnD6yCnwpWdSd+Lc0mjs1g5HaMEWxrG828nmkC+guOA15XiGd8bvldVoWk6e7TBsuK8K6qpvUtNBaVukyecD3rMgo/1aQ==; 31:Y8YcR6ptepTtHVS068P/HvxA5h+LBjdLrQSgXAx+kYM/LemXOy9GeEn9ACZturoSbjg8YpVfJYzpQnrjLeL/YC4r/+X4tvnIT8oC0FGzYJPuge+xVAwA93l4p4Ia50+5MqqwCB1h52mU7Rpx2gs1otSM2slklNaIkNY/mc7z5pA1w1A3fZx9FG1rwBeAAEjt+BdaxhYijEn7KKNje8FOG5DquO+ylZ/WvMonxvacSuM= X-MS-TrafficTypeDiagnostic: SG2PR0601MB1887: X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 20:zBSTvFkGi+4KHvbb8tmb3OIWOYjnWDYTWKORmkfxEFQs8ICNffM9xZmhJ78xEvm7Cjdcr0f5++1efjd+tgaJh+3tB96aYov8aDDqAUbUxEIk2XWk+WfMpxLUyziEAeUZKSOG92P2PfU12n3JkIA0yYMBHVZQEadIEr1EFXwq9caWd9zpDQgnQXKVqzMl0q8zfWYffNI0NG/YHsEZpcG/JWyEUcs8ofYUVzS7lULXrrcuteqx1j3VWrc8IA9VJ8+i4Fr7b9VXxod2g6osWaJKOIQa7qLBevFU6PzYcuMa/ZjKEOJspvl7O4OmiKUcGnBHxf4vfJIFzuwTpaejdgfZ9zjfZZIJVP+0jZsTNa2RBQ6s6+NH1YUALt9clF+NWz+5WEbgD7agD5bmXlA2izZmS4RyaCPKW2SvV9tzZLHB6DGvkBX4XAOroRAzVrRZ7pvA90PliaUSjUvaHXPjcPUbysI167R1MIwj0TkVWGnbJ8p08afz3itIxDSeezqlJC5Z; 4:cDAAyMbdIipu36qhZFeo5BatTqlI0V537DMZ3EgC+T4FnvHsomXRLH1lGTqtzKzvV4nCmV4r8n3qP+4uZpdDb7QTGX/PUugloA4tGMEW+nxQ70pqPKxBIPVnBPFh1MHS96uoQLyemmBDRGdBppdkJIwJyNWZ79G0mi1ffhXSRCCfQ09PtPG5kHgqaFjQU6OffR7cFdiYtsdjdwQAp4DaXka/9/W+ZXBe4Hzem/GG6dGH5tGOQjZqJjt2c2HlxT6qDKO99SdW4BdWN5vnOzxE7Q== 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)(3231022)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123555025)(20161123558100)(20161123560025)(6072148)(201708071742011); SRVR:SG2PR0601MB1887; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SG2PR0601MB1887; X-Forefront-PRVS: 05134F8B4F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39860400002)(366004)(346002)(376002)(199004)(189003)(97736004)(4326008)(83506002)(110136005)(16586007)(58126008)(53416004)(316002)(81166006)(81156014)(86362001)(50466002)(7736002)(305945005)(68736007)(33646002)(106356001)(478600001)(47776003)(23726003)(6116002)(3846002)(25786009)(69596002)(105586002)(101416001)(66066001)(2906002)(5660300001)(8676002)(16526018)(7696005)(36756003)(53936002)(6486002)(8936002)(52116002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR0601MB1887; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; SG2PR0601MB1887; 23:LY2+7LE7EyHEdrmt4lwCfalkcNRsqVrwgqTIoUd?= =?us-ascii?Q?pNI3bnMiHVxlVpkVC3HoHeTYQpDQToBAu99ikyvxKXjjJTaoWWtxtAbSQQWy?= =?us-ascii?Q?maDUEOUhaBmm6quocMS1Mq87ztt6AFZbwtLLX1w9wmW8CoHpwly7X3ayzYf0?= =?us-ascii?Q?nBfkdnQn8VtJCRtJWyqPrcBrRHTd3eJFbshVnrD1nyfOYPtCymxkf0IlkFxo?= =?us-ascii?Q?RLj/Xb4x3ef0fz/k2XA/yE3eZHXlJw73n+/t8o9/2qvA62hQI6O4igzAYNrg?= =?us-ascii?Q?6PRPwz+MJznLfz5a8s1WkreIvZJNYCGuH+iwzm3LhaXNPuMdwcv1rktsnN9J?= =?us-ascii?Q?cqNaSOJXC+CfMQqyEIEBKIJAa7kAhMY5xZxdSi/OIpGBbeapGaeKveg2kQrx?= =?us-ascii?Q?MsXyoIbBsVkZ7MUa8Uajcc/pwjMoghTAVfjYJAuGAWV4mXzsxgO7RDh0OBL2?= =?us-ascii?Q?1j6qnBdYC/RmqbZscuAzgbzz34LTGpACe0UPylicAc4tInI05U9OmcNdkPKP?= =?us-ascii?Q?dIFwWok/rCyK5UnRVTtD/ClMZZpXgmpGhkmIGamkBZngIasM/iisK7lxDmaE?= =?us-ascii?Q?04CWEvhqgm9gaSyIZfUvJ7MKewan0TVtLm9T89FlYo0MorB55Rzg6RMDmv/j?= =?us-ascii?Q?gvo0WV+a4IKkEMGZuuEz1EK2mT32tYhsYBMAwkTpXxbyBIwAVtG3znWRAfpH?= =?us-ascii?Q?K2euwih3H3M3ZiSbCk8HOalVK10udSfp8qqLVfdAFElYUAzvKw/XX+cAcqbl?= =?us-ascii?Q?4Omj5y4TF2O/LmH2mSyqbquvFQ7nUUVSmdasByjopFLsaBVBLWFS+4EdSbmV?= =?us-ascii?Q?aMaWaVGLVOHHzQtZGD++kFLY/BvfXPKrmsiJWNGXJDouoZ2JiybxziGUalDW?= =?us-ascii?Q?oQAYGFrHlDG3XspsJ500y6IWPWNTJa3xyCsem/YsfHYIF9bzqLnLmuC0BvEi?= =?us-ascii?Q?j240NRoNgMqGbNPuHYmthZU3O4pd8Gshm+KUtOGBlqHe8Qo1BQCnJiVMt8w7?= =?us-ascii?Q?+u6jg4mpPqubSVJUevZPr8OBkuDxxwAME9QInhhEKRQhMaQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 6:UTNo7yFHFBaQ6jngdsHDD8dVQrhtm91d/6P9NNG5UdQ09QE7F6r+0mg0q/f96dx0Rm+MD8niyVZ2ysCarMOwtXHh2hDIHZAwHo53wcQTEST2kNEHmB6sjo7+wCPPm+e18QmzOtyypeohSDJTu8AffkmdBezh56N5F9FZNQSc8T3SFreHMpAN2El+658S2M3+WaFWwAfi5+X17UiJouM3oG3Zdwmk4Xm7Gfj8roTTwcIxaWsNt/yjvm79xOgQMWEjt8645lg4S5x1zrz6ru6n3tqv4ab79D6hrubvhlmGNHFuZJkfdUJstEAEpeFhWB49F1bjZCvo7nMNMLiKi7EPwshyD49U5lS5mmhPI3U5JVQ=; 5:TRPxuvw7xB4bFW0647qCzC+eaIhyEm+2DcbGZuqmQP6rTp8PyRqPnnIMlwF3bUlI7/o+rK0kzVD7p4GRy98ukUW+pFhGzLfbNtCfBnykr6b0QhASoJf1gUPts4aOItwJFk6RtgEpJssZeQLvsunTvWEcrTGZrD1wvufyCLkcYfE=; 24:h2HxEk4ExyXFLX4r1r2nWWce5jkdMF0CEIxIiZ9JhSyc4RGpN2BJ34aBe8k9KbH2etvLxro0NtvcAYNbzPM/eRwTFIIS98oZJq3XiT4qM0s=; 7:gUu8lMtWHJNnmuhVoHLar9lTcqFFwCilRaV5QkSXlzlnx4VTwh09BB+e9fmfcw+kYsauaJhvVGQsv3qsmdXl4vSS3GL+sb1XPHoFYgT1Jok8zK5GWIDca5Eu2UeeFOR+G0ryFKF3yOYP5iXpgdg9wwAewJchEUr3pBNYD+bRze3nkfWtuRcMulOVL/8UVfidThm9CEMmXzh0F/7jm6aDw2LGrfK020UiAO403kkgVNSJx7oZ7xEZctDSosISZg+w SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 20:X87LYe0j514apc0Q/syiXJnOUXSnSe4YuXXIuArB5Ouocyzar7nK7cJcH1FqShKMbyM6EuA0wP3B2wiYu4AppUXq7EluCD0+FxaI2AvnFcVNVL59OI2MyqilEK1qDJF1639/2USr/dS/ZrdBTZK+SkawYDsUj+85JEDaJSBSnSI= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2017 06:05:38.8237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 070eca25-a28c-4f10-a9a0-08d53c6f6015 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR0601MB1887 X-Mailman-Approved-At: Wed, 06 Dec 2017 08:38:48 +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, thus fclkout = fin * (n + 1) / (m + 1) / FDPLL 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 --- v1 -> v2 - tidyup typo on git-log "fout" -> "fclkout" - tidyup for loop terminate condition 40 -> 38 for n drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 36 ++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index b492063..57479c9 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -125,8 +125,40 @@ 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), P = 2 + * 2000 < fvco < 4096Mhz + * Basically M=1 + * + * 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--) { + unsigned long long fvco = input * 2 * (n + 1) / (m + 1); + + if ((fvco < 2000) || + (fvco > 4096000000ll)) + continue; + for (fdpll = 1; fdpll < 32; fdpll++) { unsigned long output;