From patchwork Wed Dec 6 05:16:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 120789 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6625454qgn; Tue, 5 Dec 2017 21:17:06 -0800 (PST) X-Google-Smtp-Source: AGs4zMarid9tqAVEPEYUN7NHi2aejzHlA5OqztQpXccEF+R2uyCBkvOIi8IRRGZUhByoUeMsJ/K9 X-Received: by 10.80.206.26 with SMTP id y26mr8647235edi.117.1512537426252; Tue, 05 Dec 2017 21:17:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512537426; cv=none; d=google.com; s=arc-20160816; b=yfKARBfdn9owKp2iYAKZ2dmVuMpjXG3fiDexKBOKWbvr/TSwBPKHw3jE1GmFV47kzu RyNz8e0Wp2zsPyaNF2UduOgsRvQ1u7Gb79XiRScpyEI8Rkb/GZgM4lQBr/hLBw+/W0An 2LvZMXEf83aWdXAt30m/7zz9k+wxISyDq8BEwh9k+AMCIdsbX1doXZOa0yhNouBOXn6g q30HWex5ZBy/D9imagHyPwzeTmOQJONV871z1Sg04POIXGJHPJOsK5uGmCKa/Spk0erx pDbNr+2qrxnMkeUCg+3CqjFCPJK+mZOiOuqqt5xfoWs3Sk97o+OazWXzrcDk3JoGzP1O zBVA== 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:message-id:date:to:from:dkim-signature :dkim-filter:arc-authentication-results; bh=eFFGfsorRlOTRyjcM/HKd0jwr9hQOfW8zjB357pNmg8=; b=ngi1aUc50iQokUPRTLM7IpafimUd905aUkDlVoyQXovYj4pIkd0zWMn+ArWU9okhcG Kve30YYWvp4rMeegi2avObn32moFaZIrOMIpMEMweNEy2yPNRzcABglj0kMasC1RsbIC 22aluINJcVCFJJijzVC/i2CWjCkaL0krKoy/WYaivEkQsqrhYwWO62+bPkz8vZjX/Uz+ IQ0cp3l1JbUxKpNSdlXG+2dK02Sd4iEz3WhSxeDiNtSkdvnuMBLFkuKOHvbuqZLeBVrb MWYNk4ko9lh34xJ7TGuxmNzKwt5irXE6sNQv86FbDYXGx9X0/0aQgDbOU+9Ld8H9yC1d Fs6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=mbPddcf9; 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 r38si1950170edd.139.2017.12.05.21.17.04; Tue, 05 Dec 2017 21:17:06 -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=mbPddcf9; 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 A67A3C21F7A; Wed, 6 Dec 2017 05:17:01 +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 633B3C21DCE; Wed, 6 Dec 2017 05:16:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AC909C21DE8; 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 6FDCBC21DCE 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 vB65GdxQ011389; Wed, 6 Dec 2017 14:16:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vB65GdxQ011389 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1512537400; bh=1gx2MOp3TvbJU0ef1CIrg0tixPkd3W6d4n1PYPlB0Hs=; h=From:To:Cc:Subject:Date:From; b=mbPddcf9z7liZiGRrWBDwRecYM40sb2TMsOl6b66MOHcptECJmXnasQzGP2bbWkGm DftwOiPryvlTllas3i5GSwL2/yW4aqpdXGVYZ+Kqs9YS6bowiYkm91eQaY8vpySIkQ xpO16Y2VZHtE4B6kJkulmxzZ0XD/lOyG6yGy6+PW3PwcTAW64tOwIBveSB277ggEpF AcyZHQVnFPOMmF76vMcf84Ml7sGvvMycOOwUnxdkizdbNbDmtNmPU96madKFVTn1fs OT1D2rIJShBbjJmrksYGdaBxMxUbZLBpQ8XMMajbVW9oZGXRwJTyHpXbeDrlC+eKTV AVdCywjJZKKDg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 6 Dec 2017 14:16:32 +0900 Message-Id: <1512537394-9608-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Subject: [U-Boot] [PATCH 1/3] ARM: uniphier: fix SSCPLL init code for LD11 SoC 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" From: Dai Okamura Commit 682e09ff9f35 ("ARM: uniphier: add PLL init code for LD20 SoC") missed to write the computed value to the SSCPLLCTRL2 register. Fixes: 682e09ff9f35 ("ARM: uniphier: add PLL init code for LD20 SoC") Signed-off-by: Dai Okamura Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/clk/pll-base-ld20.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-uniphier/clk/pll-base-ld20.c b/arch/arm/mach-uniphier/clk/pll-base-ld20.c index 3aa42f8..45fdf0a 100644 --- a/arch/arm/mach-uniphier/clk/pll-base-ld20.c +++ b/arch/arm/mach-uniphier/clk/pll-base-ld20.c @@ -48,6 +48,7 @@ int uniphier_ld20_sscpll_init(unsigned long reg_base, unsigned int freq, tmp = readl(base + 4); tmp &= ~SC_PLLCTRL2_SSC_JK_MASK; tmp |= (41859 * freq / divn) & SC_PLLCTRL2_SSC_JK_MASK; + writel(tmp, base + 4); udelay(50); } 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); From patchwork Wed Dec 6 05:16:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 120790 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6626272qgn; Tue, 5 Dec 2017 21:18:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ1JJazmh8jA3MkaBlT/sSG0QFdPyGTReGTFaN9By7F809+DBlIxJAMgua5WcZi9kEPZeT2 X-Received: by 10.80.182.148 with SMTP id d20mr38596932ede.63.1512537497621; Tue, 05 Dec 2017 21:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512537497; cv=none; d=google.com; s=arc-20160816; b=GULepcWe6/b1ZBFrPba+r2EfkWgLAmKUjGiSMRmMM85OOW6MAzyp9hXp5pKaYlQgdU 8jISYkcvT3dpqmN6wXHqd5TbDWbLWFsxEv5LLHE6SVmnE2ldaSg7hItMByT5ZjJz1GPB utiwOTGHgkXG1vynVv0J5xlH5PS0D3QTiBa6pBSbQ4+F8Qm2ZN9fnX10fPwoKm+ZJnSV xHH2SDaYVn6nMA4ry5EZk/qZAM28AYKie4R+67LgzELUyAi9SEMIW+wQdL12rjgAblGK eLc5SSY776b8YS6iiMrUqQnAT9olRDlKyl/9YVaROg1dRR0yRZLeX3kt8JyQ5oHBmQCY nfKA== 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=7IZ+0TwzppPcA6WVoGQPg+8Qkhv5ksEX3HInHZ6zZcM=; b=ieT26nXER1g4dq6PPh+jgcP1sgsEZgWSkKhTkYSoQfSW7CLtr94x1m7JXsHzRnNY0t SpqsAchBX+NHAP/p0KQHZapLHX+mZIGVqeADWjDSAsQAWNMEH/JrgvU6UV3NSN5gj2ka QBV994dRRkZqwF9BGd6G+b/Q1XF+9d61s0nOkGgsm2pJ7TlqieFFnvGiN84g/Bij9MK8 JXwyLBRY5fcXgcng/NHynJNPRTCeOPxSv+ZtiZ9AoJJ7XeIl6PEy77Hj64R+PrXAWo9B XoBuMpnGwKerDgGOW894QdMdIcfPrgcJ2eM7kJOgnDMw0e1bqhPxVIOAaH3//iEdKJ4V DLKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=RJUejzHF; 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 o4si1911813edb.184.2017.12.05.21.18.17; Tue, 05 Dec 2017 21:18:17 -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=RJUejzHF; 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 30354C21E14; Wed, 6 Dec 2017 05:17:18 +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 E05E5C21E22; Wed, 6 Dec 2017 05:16:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C7BBBC21C5D; 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 59F38C21C5D 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 vB65GdxS011389; Wed, 6 Dec 2017 14:16:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vB65GdxS011389 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1512537401; bh=Aoteq4kGnGqHnTtGLhF8l6HmUbS4E92h6a8pRJC7DRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RJUejzHFeAobHQeAxGFdk+42OQs8vPsmyutrxkpB4PkILwcqgdn/tcaUhKHIhybIK RmIU7WpT0poYVY2dAn82vd67QVFwC0LUCGoAHNOd+6asEF8ZCbV/fo/rWZizyX9JVg SRjc9yqt84+vkLk1MtzYTDc6dr2/TnalpSex/WOxNwKjkN5B7WzAvVeS5i0Ir3gbrr SJiXn7PP0Evf2WS5tEmnqrD3Y2aPHK8CUk11zi+CofID1/znCMmiv32PrDA+rL+Gcf wlrMwAwKij+nF+ILBIGErwEo4DBwB+mxIG80+3p01aJsSZULz+LJ1IUcjeBm5Wpuny Z0qvFWcyckDgQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 6 Dec 2017 14:16:34 +0900 Message-Id: <1512537394-9608-3-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 3/3] ARM: uniphier: use FIELD_PREP for PLL settings 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" It is tedious to define both mask and bit-shift. provides a convenient way to get access to register fields with a single shifted mask. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/clk/pll-base-ld20.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-uniphier/clk/pll-base-ld20.c b/arch/arm/mach-uniphier/clk/pll-base-ld20.c index c9b78b9..385f54d 100644 --- a/arch/arm/mach-uniphier/clk/pll-base-ld20.c +++ b/arch/arm/mach-uniphier/clk/pll-base-ld20.c @@ -5,6 +5,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include #include #include #include @@ -19,7 +20,6 @@ #define SC_PLLCTRL_SSC_EN BIT(31) #define SC_PLLCTRL2_NRSTDS BIT(28) #define SC_PLLCTRL2_SSC_JK_MASK GENMASK(26, 0) -#define SC_PLLCTRL3_REGI_SHIFT 16 #define SC_PLLCTRL3_REGI_MASK GENMASK(19, 16) /* PLL type: VPLL27 */ @@ -42,14 +42,16 @@ 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 |= DIV_ROUND_CLOSEST(487UL * freq * ssc_rate, divn * 512) & - SC_PLLCTRL_SSC_DK_MASK; + tmp |= FIELD_PREP(SC_PLLCTRL_SSC_DK_MASK, + DIV_ROUND_CLOSEST(487UL * freq * ssc_rate, + divn * 512)); writel(tmp, base); tmp = readl(base + 4); tmp &= ~SC_PLLCTRL2_SSC_JK_MASK; - tmp |= DIV_ROUND_CLOSEST(21431887UL * freq, divn * 512) & - SC_PLLCTRL2_SSC_JK_MASK; + tmp |= FIELD_PREP(SC_PLLCTRL2_SSC_JK_MASK, + DIV_ROUND_CLOSEST(21431887UL * freq, + divn * 512)); writel(tmp, base + 4); udelay(50); @@ -93,7 +95,7 @@ int uniphier_ld20_sscpll_set_regi(unsigned long reg_base, unsigned regi) tmp = readl(base + 8); /* SSCPLLCTRL3 */ tmp &= ~SC_PLLCTRL3_REGI_MASK; - tmp |= regi << SC_PLLCTRL3_REGI_SHIFT; + tmp |= FIELD_PREP(SC_PLLCTRL3_REGI_MASK, regi); writel(tmp, base + 8); iounmap(base);