From patchwork Thu Jan 18 18:45:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 125011 Delivered-To: patch@linaro.org Received: by 10.46.64.27 with SMTP id n27csp247789lja; Thu, 18 Jan 2018 10:47:26 -0800 (PST) X-Google-Smtp-Source: ACJfBosaIREjwblchzQsnTLbI5+hMVwiGPLI/hxWuOWrR4glRWdpi9f9tPVAvzLZkcKQ7ryDvc3z X-Received: by 10.99.175.9 with SMTP id w9mr37907800pge.214.1516301246351; Thu, 18 Jan 2018 10:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516301246; cv=none; d=google.com; s=arc-20160816; b=Jv0lkVQ79BWiXzBnfClsfpVizCDZ/Ds5SQ9PS3gnTDQUKz7Xep6bovbHQ9/5sUKjtF IHyPJg0mIvIqIT9nbeVfCuzAmw62adDHmRiCOvycRLVCNvCKSyyXMMTUpeGUxzNBsT7B lAQ+r2MoDVDC9oCZnHXD7iLute46/Uqlj1PE0YaPPjaCYmxhqjxQPPW9ySqR+34GC1dP AZp9CShiGbOKc2WS5LJ0yRTpBZB5fvMN3eQMn6RBQALcRBSGYjjxMbekUb1pnmdPwpHv AHR9hDGbW0J+9PJgXGoNQg9BB2I65VLHQXdbAsdr4LkhUyKt4AsntWf3/Eii3h5O8A2T ncfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=CEwj8+aKvnsw6RvL6RGZY+g2z8uB/GU8+s1upffGAiI=; b=Kcqw/ju2EoqLDzYtuPC1UbWMg1/PKsfirUb4Wuwyn9nSMZe8M2Lmh3DozrxB0AngJv HcDN7a00/gLw5/HmIwC0rqpOXi6HqehJci7yTz+Jn0OqZnwmaqLO8FXB6T2G7LDIJZKq zcAaakI82bg/Zsa71WSF/ZqfJTegl9wQdGNeQuS//UGru+WCIo4/cu9JrSFaziqGfWw+ 4MYtrec8sgZDyHyUuthxlcV8iz74lKhZw6h2npk9Y23yhkcc+FXPbSQ8nNOH/B/eMuhU yYtSijsL4SYxRE3U7hDwTPiDtoU2y4BMGclXDceUWRueXnYKmYA1Ua5k6+6HeFo+xWYb 7mjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=u1pEAs/C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si6665263pgc.192.2018.01.18.10.47.26; Thu, 18 Jan 2018 10:47:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=u1pEAs/C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932712AbeARSrY (ORCPT + 28 others); Thu, 18 Jan 2018 13:47:24 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36156 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755733AbeARSpj (ORCPT ); Thu, 18 Jan 2018 13:45:39 -0500 Received: by mail-wm0-f65.google.com with SMTP id f3so24988950wmc.1 for ; Thu, 18 Jan 2018 10:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CEwj8+aKvnsw6RvL6RGZY+g2z8uB/GU8+s1upffGAiI=; b=u1pEAs/CwI3Ctnb8dSVSKqyVmryBZTKZTrkESt3j5PTDhVee3Kmg+qhBkGiJicjC/i y8CNah/yU+1RM0EGCKeLddDHdFs7CklFyWSyVXvtA/ASO4LB2udoS2wyysJzfn4OoumX ZPCd7/6B1c3p0h63NzMYXHKhKGgzYmwSv+CnWqZieophUkGgcycnFqu56O2lkEIGDMPq eKlTMM4eOWV3a2pSXau8XMhrZj4xPXoEmJm6fHYeGcQp2Qb2MmRGLk7vluTFnr8B90sz DgtbGKm56WY+kQTNG1a+sBxgmlysoq9tSjVJ2M+DoIX3MmCFRInZ5yjiIt4jLeX+4XVY OeqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CEwj8+aKvnsw6RvL6RGZY+g2z8uB/GU8+s1upffGAiI=; b=lOhpUT8SVx1TSRa76POWwG12M6WzXjm3faiaXYrIS29BMoQdqFVnc4gwuP4yzfDShJ rmuvMSbBht9FItAnpoKoqi3JX2L57LNH3CJPjR1yUO7vBdnEKFSUxX4HDZP7DsyOVhFz KrmRaPitOHGFuLerGWAMSnHa9oDuMsxHfJ8Jgl/YIhJ8isPghMKhP5uNfFTuqw0DR0AD gc4YNvCZ/7Ty42zRQhqhuFKXIaKK+u6Ld5PxO9AXTn9i2RMvObBMCCvNDxOd19lT/bhp FDD+Cc88X15LtVAdupAW6KarixV9jiuEJKp9h/gwrn6Y1RZs/O24ean+B+njU2BtHWwc 2uCw== X-Gm-Message-State: AKwxytd6VCS+5ZoZVozXICugWDArhWYYbl6/IZ2w1w5QnnXicUZPTIFX H1PHkyTGrH02FdYGBMi8xCF8zQ== X-Received: by 10.28.105.80 with SMTP id e77mr6209276wmc.123.1516301138073; Thu, 18 Jan 2018 10:45:38 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id y62sm6240236wrb.48.2018.01.18.10.45.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 10:45:37 -0800 (PST) From: Jerome Brunet To: Neil Armstrong Cc: Jerome Brunet , Kevin Hilman , Carlo Caione , Michael Turquette , Stephen Boyd , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/9] clk: meson: remove unnecessary rounding in the pll clock Date: Thu, 18 Jan 2018 19:45:26 +0100 Message-Id: <20180118184532.6856-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180118184532.6856-1-jbrunet@baylibre.com> References: <20180118184532.6856-1-jbrunet@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pll driver perform the rate calculation in Mhz, which adds an unnecessary rounding down to the Mhz of the rate. Use 64bits long integer to perform this calculation safely on meson8b and perform the calculation in Hz instead Fixes: 7a29a869434e ("clk: meson: Add support for Meson clock controller") Signed-off-by: Jerome Brunet --- drivers/clk/meson/clk-pll.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.14.3 diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c index 2614341fc4ad..fa4cec13d6e8 100644 --- a/drivers/clk/meson/clk-pll.c +++ b/drivers/clk/meson/clk-pll.c @@ -51,8 +51,7 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw, { struct meson_clk_pll *pll = to_meson_clk_pll(hw); struct parm *p; - unsigned long parent_rate_mhz = parent_rate / 1000000; - unsigned long rate_mhz; + u64 rate; u16 n, m, frac = 0, od, od2 = 0; u32 reg; @@ -74,17 +73,18 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw, od2 = PARM_GET(p->width, p->shift, reg); } + rate = (u64)m * parent_rate; + p = &pll->frac; if (p->width) { reg = readl(pll->base + p->reg_off); frac = PARM_GET(p->width, p->shift, reg); - rate_mhz = (parent_rate_mhz * m + \ - (parent_rate_mhz * frac >> 12)) * 2 / n; - rate_mhz = rate_mhz >> od >> od2; - } else - rate_mhz = (parent_rate_mhz * m / n) >> od >> od2; - return rate_mhz * 1000000; + rate += (u64)parent_rate * frac >> 12; + rate *= 2; + } + + return (rate / n) >> od >> od2; } static long meson_clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,