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: 10173885 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 40209601E7 for ; Thu, 18 Jan 2018 18:46:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30EFA28437 for ; Thu, 18 Jan 2018 18:46:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2553A28446; Thu, 18 Jan 2018 18:46:07 +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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BBC1328445 for ; Thu, 18 Jan 2018 18:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=26wA38cxSLNTHGpxqROCAPYpgm03+Xil2pRq+Il9HlI=; b=Pqy8eQ3L9dRy6EbFj+wQbAHNZk UChBfrvdPIZ6/f2hrU0uS29UUNf0bUxaj9jmfR1hDauxQvTeR6z9fT2g6J1ClMyVx0n04V1NMkUnJ Oa40/JVj/BYxezBevRMt6JHhNZhxXdU0ImakHlyrkGFjvH1weGqh8qWKOelU/jvLRKHComMtWXBOG qhrYR1z4RX1XNdg4AifgFzml9xGx7vFJZtNE5xUg8UBKpL7+WzSRPeCHmSRpSkn//Oe0TCOvMGwij UtrNFh+NdliOw4Kqik0gjzmMwKBUzoaUAibrkQ/R48Ve4kAgahb40v9Dz+E54RwyiYlDEWqYOBhTM gu3ADzQQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ecFCI-0003hV-Az; Thu, 18 Jan 2018 18:45:58 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecFCA-0003b1-3R for linux-amlogic@lists.infradead.org; Thu, 18 Jan 2018 18:45:51 +0000 Received: by mail-wm0-x244.google.com with SMTP id r78so25013069wme.0 for ; Thu, 18 Jan 2018 10:45:39 -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=rBhhnUdOIRIZwRRp7DT4xietc0M1gEFDUa3u3yzWEpzBdND5dSEyB0t2OH5C6bFGTh 0Ylgq+NA5T0yxImTjcowR+C0YYlE5ygKkXvMkNRCsxCx/+JQFeY9t837qnrZ5uXIjTEE +njk3R4h0kUhIhpT2SC1GUHRRlvQiI8rH8U62HcfUDEL3SDBcE5QTnIGCekqMg+1lulL 9Ul4VDaUM07VL3oTNQiQxKJtD56+xRxUpnZ7D9cdOzpq9OOuFB3AKqS/NHtKiZUs7jse yut2jVlJRZIx5YqeUBPxwjYOzHQdW1BM5zy0/hTOuXSRRszCiMKJxtH1ozqyScyNF0b+ WmJg== X-Gm-Message-State: AKwxytcF2aM0EQD9J5ZST1ogLCiy4eeLkdcU3rtQHjEvJ27oPfw+USaS rzUFq6Yp2Wc9d/wWc9nVz5KoHw== X-Google-Smtp-Source: ACJfBovuqpO62LyJtansBnWBx7whEQzR5ZOXkbHemk0CQPQ4pcR2In6K9j6MKSnugRqgJs2PobsTAw== 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 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> X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Hilman , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, Carlo Caione , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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,