From patchwork Wed Dec 6 05:16:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 120791 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6626371qgn; Tue, 5 Dec 2017 21:18:25 -0800 (PST) X-Google-Smtp-Source: AGs4zMbxBueelLvfiia+8NW5/7aHIaINo8EVSBVY6kPmjW8dIFaBT2Npa/5vbmFTGz9Sw2afINMv X-Received: by 10.80.145.81 with SMTP id f17mr39338449eda.215.1512537505292; Tue, 05 Dec 2017 21:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512537505; cv=none; d=google.com; s=arc-20160816; b=vxJ7IK2S/+BctmlPJmj77Doe3J5aBOP+9FVQPubS5Ft7V8onjA7EvbI5iGcqZppQft T7uhyvQCGitENYS42VmbEJRZiPmMi8a3OcP6pfvWUucB8wJV6i7T9wWs0IBI4OBvx5CJ RxlffUpl1mcPgA0QvyQGqEz/nqeUu9hy1tjG8FU7/6svPvK4RNbGfIOAU3KiO9G6lTtb MDPVc/ueCuVeU11ywRYXJAFsw9/47QnE1BLXKI4OOh7C8uNZdh6T13hdEZkappfQfKJs Ul7ZHfQT5BDeimetaXce/8AIbJD/z2h1oQuSeu8PEj6v832u2UeguEKx3OngiKts7tdj 0ISg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=8eaOMoImLrVX2Np8QLMSf/949WnQyDM+3Y74GvCiDUQ=; b=I9XF6LFuwwJrVdOSCCDmUBGJ1GspMbGLHeyOXXNsz5vJBMqy9kiQtQlGLVh3NXcPQo 8CRbfWayD4z29jNSGkQOqQ60PsM+wXsOvf3ph2JVgE2Q67tSOg78kjxl59e2hLtW+3Pg hj+uHGoHfdEc0ISpkIyOxtfvxNPQz4L6kn76NzJjDzN5OKraenpBt1DgBj/s9p+940W5 ZHNYkzoJDxz5WTSKFg/nwXyidc+3y/8ONs8DE89ZflUM3aaKgFQIf85f/3Ts59wEGg0U awk1ktRmdML+06mUXrKuahfhGX38ch1Jc2I4e1ZQec47xLGxKMqPgUL7lrXwATIMg9Hk ZSQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=hcaJoHhE; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id o92si704496edb.275.2017.12.05.21.18.25; Tue, 05 Dec 2017 21:18:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=hcaJoHhE; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id DA463C21FC6; Wed, 6 Dec 2017 05:17:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 727A6C21EB9; Wed, 6 Dec 2017 05:16:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D9505C21DCE; Wed, 6 Dec 2017 05:16:56 +0000 (UTC) Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lists.denx.de (Postfix) with ESMTPS id 7E4BBC21DE7 for ; Wed, 6 Dec 2017 05:16:55 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id vB65GdxR011389; Wed, 6 Dec 2017 14:16:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vB65GdxR011389 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1512537400; bh=+JVK14ownL0GBNqFx2Q2dFAyKeAoQwGL6mU2I31MFhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hcaJoHhEybZSPVbydWB3Lc4LwIfwI+uonTdWa4xEF67y6/XdnxZX1zkLfRfHIhhhE 02dgwdkmbeqv/rDnqfkeysuMLtm5JkLsHlZMEeeieRbnygBEmSBAkuEJHZx68eFmjE 95T2pohywkbhek+dkb4dqytj6uVROsT9Rhcs8PP8tecRAxTGBIavPyjOoWBIdlQ2C3 N+4DqBpdBZVYqkzVk72Y6RV46PENKuPWgNXx149fSQFh6cGJyPnygqiJ6tmVC6PFwG ZmKkkoLqXX4OdJ+LiErcu8quDwi+WXm8Aa/WTstRo8RUZVNmC3PcpzZYB84JsjFla+ UBbAhyQDBeetw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 6 Dec 2017 14:16:33 +0900 Message-Id: <1512537394-9608-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512537394-9608-1-git-send-email-yamada.masahiro@socionext.com> References: <1512537394-9608-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 2/3] ARM: uniphier: compute SSCPLL values more precisely X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Use DIV_ROUND_CLOSEST(). To make the JK value even more precise, I used a bigger coefficient, then divide it by 512. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/clk/pll-base-ld20.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-uniphier/clk/pll-base-ld20.c b/arch/arm/mach-uniphier/clk/pll-base-ld20.c index 45fdf0a..c9b78b9 100644 --- a/arch/arm/mach-uniphier/clk/pll-base-ld20.c +++ b/arch/arm/mach-uniphier/clk/pll-base-ld20.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -41,13 +42,14 @@ int uniphier_ld20_sscpll_init(unsigned long reg_base, unsigned int freq, if (freq != UNIPHIER_PLL_FREQ_DEFAULT) { tmp = readl(base); /* SSCPLLCTRL */ tmp &= ~SC_PLLCTRL_SSC_DK_MASK; - tmp |= (487 * freq * ssc_rate / divn / 512) & + tmp |= DIV_ROUND_CLOSEST(487UL * freq * ssc_rate, divn * 512) & SC_PLLCTRL_SSC_DK_MASK; writel(tmp, base); tmp = readl(base + 4); tmp &= ~SC_PLLCTRL2_SSC_JK_MASK; - tmp |= (41859 * freq / divn) & SC_PLLCTRL2_SSC_JK_MASK; + tmp |= DIV_ROUND_CLOSEST(21431887UL * freq, divn * 512) & + SC_PLLCTRL2_SSC_JK_MASK; writel(tmp, base + 4); udelay(50);