From patchwork Mon May 15 17:35:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Anholt X-Patchwork-Id: 9727699 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 5C08960231 for ; Mon, 15 May 2017 17:35:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46CDC289A6 for ; Mon, 15 May 2017 17:35:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B994289A8; Mon, 15 May 2017 17:35:33 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID 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 B8005289A6 for ; Mon, 15 May 2017 17:35:32 +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: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:In-Reply-To: References:List-Owner; bh=xIlhZK7D4mycNlMjoRPs7OxmCGy9PXRYYhttBETOVlo=; b=XNC K5h+3mujxaRBsxNJtbFfzHt0VbkX4B30MJfepGzhaxaF+FtaHznLUC92L1qeGDEkESdWt4dnLC97s dYUhzYzoi7JaRvdmkiaUjtNV8SB271EKI16VQsG34XsNjt96MRyY4T6zWRCAVKmZKhYZ7vjOIV6vt pUOv9SwsPlKKiJ+BHHzgp+GkkGwc59TOlG//LgOx+d508RCq5OptY248W0l0De4Xq2eVSqAcXtfBd Jjfuot4ulAtNZfv0rC687N2bwdyrARW5r+yJeyAD8F2KoiawWT+SYWQvBZuLLND/so+7j+OLkmvAB Pwi9gaL0kNk7197ZPWoOQ+mkxYB3iYg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dAJu8-00088i-0n; Mon, 15 May 2017 17:35:32 +0000 Received: from anholt.net ([50.246.234.109]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dAJu5-000859-Cm; Mon, 15 May 2017 17:35:30 +0000 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 8848410A21E1; Mon, 15 May 2017 10:35:06 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2iE4Taj8bt_A; Mon, 15 May 2017 10:35:04 -0700 (PDT) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id D2E0910A1812; Mon, 15 May 2017 10:35:04 -0700 (PDT) Received: by eliezer.anholt.net (Postfix, from userid 1000) id 656E62E2AD3; Mon, 15 May 2017 10:35:04 -0700 (PDT) From: Eric Anholt To: Lee Jones , Florian Fainelli , Michael Turquette , Stephen Boyd Subject: [PATCH] clk: bcm2835: Correct the prediv logic Date: Mon, 15 May 2017 10:35:04 -0700 Message-Id: <20170515173504.11337-1-eric@anholt.net> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170515_103529_465500_88B391DC X-CRM114-Status: GOOD ( 10.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Wahren , Phil Elwell , linux-kernel@vger.kernel.org, Eric Anholt , bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Phil Elwell If a clock has the prediv flag set, both the integer and fractional parts must be scaled when calculating the resulting frequency. Signed-off-by: Phil Elwell Signed-off-by: Eric Anholt --- While this is a bugfix, I haven't put a "Fixes:" line in here to get it automatically backported to stable. We had trouble with the out-of-tree DSI panel driver, at least: Our old set_rate() didn't work, because the new PLL was just barely too fast to get the integer PLL divider we needed. We may run into similar troubles elsewhere. --anholt drivers/clk/bcm/clk-bcm2835.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 025853870619..7a35df6b45bd 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -616,8 +616,10 @@ static unsigned long bcm2835_pll_get_rate(struct clk_hw *hw, using_prediv = cprman_read(cprman, data->ana_reg_base + 4) & data->ana->fb_prediv_mask; - if (using_prediv) + if (using_prediv) { ndiv *= 2; + fdiv *= 2; + } return bcm2835_pll_rate_from_divisors(parent_rate, ndiv, fdiv, pdiv); }