From patchwork Thu Jan 18 18:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10173883 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 D55E46055D for ; Thu, 18 Jan 2018 18:46:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1BC628437 for ; Thu, 18 Jan 2018 18:46:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B656B28449; Thu, 18 Jan 2018 18:46:06 +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 5A6A128451 for ; Thu, 18 Jan 2018 18:46:06 +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=q+uxJ832tFbCIYYuyuPDiUt1qloXRGSMedt1NqOYYaw=; b=h47DSYM5P0+EEhfGth4TBJPGzI hz76Upr9eygnaFS6CWdGXYa+/Bavc5sLLgx2lUeHAM4+t7tHTcocMWfXvQEwX6AwlJkC2koJUcpx8 IM+pxfHMGop7PrwH/8hGfKaFxRXhPQwQjRpIvvsqWnNbMlIvDpRar8AFGmLqWnwUanAREpxrb90z2 biWdJMfmT3am/knT8txhOMcK6zUC1J9H9vbE5p1QSHLo2oiAjLGERyxiUJMznR+7QU/GCepUrqM/q a+ewr0+f0wGZFZtIEp1G9v4fSRx8qu0QXNY3uFCn6JMI+xI1ATBwK8Go4vZfIZraRc0Zv1fxERVQx Kk9lQfyw==; 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 1ecFCE-0003e5-CS; Thu, 18 Jan 2018 18:45:54 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecFC8-0003b8-Aw for linux-amlogic@lists.infradead.org; Thu, 18 Jan 2018 18:45:51 +0000 Received: by mail-wr0-x241.google.com with SMTP id f11so13151104wre.4 for ; Thu, 18 Jan 2018 10:45:42 -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=w6EjjEdrPKEoNKhNDQMO21CbBaUHfd05Ifnbiyg/MxE=; b=zoBFtJMXCER7a3TimijtilHMxFHmZTGEBzXURfZTADoh6HtLoKzlBcelsaa5qCvdQ1 SV0NORFd/wUGTRfgoQMztf1zqgGkzHibo5Cl7Sh7B/SiWcwWxI/TUsjAkesiG93ifI41 d/+PBXo5+wNR7t9zkOIal/HcUTVrVwCv50JmfnnUQGQGDSDhIjEfA0/FJha5SQd2iLyE kp0h/U5l3kr3aKO/F16UT1fAx7elAoHALv6hUHop3xxKrqD6WFM2u0SK2RMI8se8Uehs hlWz9IKwfRKG2/BTm7IkQol1qPYvGoVubq08UyPe0OCbrDd/qvsddNcbzWPGU939r56A 3G+Q== 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=w6EjjEdrPKEoNKhNDQMO21CbBaUHfd05Ifnbiyg/MxE=; b=Fq4U9dk/CItvuO8jYisSjygISX+LhmYNu9LhIthPV/zJAI8+SJo1Ndf9Bn+y9VIRRl hsQtpWHiuJd8lsORNWVsXBKb4aR91uHlDni6RmvAjQe6MYPIjH1OHGH0xmC9/jDocHOa Okqn9z8Rw54n95wgjNsA/NbYbOU83fq2dqAC9YLpnd8pr0fTkG/Jo2OEs0AD/4pPjHbW t3cjPNK+ZnLWWjm3XMKpyUM+88xFiIsjM0/ITS6LI6vWh+iUsujUZKosO1OBAu6Qwo/6 5i2QIf7q8qPpib5I3AnDGHmvKqBsRT19I5mLbei7agQdwORKti/tnqM7Td0p9l6lBrM+ Y2vg== X-Gm-Message-State: AKwxytfR1u4X8rBIgFUXJjyiHoVFVRPj6XG3wLxhQeoBdUme99oniEUB VAn+0dffjRdcUhlila6uVlBErw== X-Google-Smtp-Source: ACJfBouNw/Q7XSssTAwAy6Xs7fOveaeyaB53yd4pQlAE46hn+xf3IHngEjsMg6tZfTxCcwZEs95ezQ== X-Received: by 10.223.139.11 with SMTP id n11mr6596027wra.102.1516301141638; Thu, 18 Jan 2018 10:45:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 10:45:41 -0800 (PST) From: Jerome Brunet To: Neil Armstrong Subject: [PATCH 7/9] clk: meson: fix pll with fractional part calculation Date: Thu, 18 Jan 2018 19:45:30 +0100 Message-Id: <20180118184532.6856-8-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 rate of the parent should not be multiplied by 2 when there is a fractional part to the pll. This is making the rate calculation of gxl_hdmi_pll wrong (and others as well). This multiplication is specific to the hdmi_pll of gxbb and is most likely due to a multiplier sitting in front of this particular pll. Add fixed factor clock in front on the gxbb pll and remove this constant from the calculation Fixes: 4a47295144dd ("clk: meson: fractional pll support") Signed-off-by: Jerome Brunet --- drivers/clk/meson/clk-pll.c | 1 - drivers/clk/meson/gxbb.c | 14 +++++++++++++- drivers/clk/meson/gxbb.h | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c index 3f560b2cd83b..8845f65aeb07 100644 --- a/drivers/clk/meson/clk-pll.c +++ b/drivers/clk/meson/clk-pll.c @@ -87,7 +87,6 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw, frac = PARM_GET(p->width, p->shift, reg); rate += (u64)parent_rate * frac >> p->width; - rate *= 2; } return (rate / n) >> od >> od2 >> od3; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index 08b3e1cdba5b..9a92e64b428c 100644 --- a/drivers/clk/meson/gxbb.c +++ b/drivers/clk/meson/gxbb.c @@ -212,6 +212,17 @@ static struct meson_clk_pll gxbb_fixed_pll = { }, }; +static struct clk_fixed_factor gxbb_hdmi_pll_pre_mult = { + .mult = 2, + .div = 1, + .hw.init = &(struct clk_init_data){ + .name = "hdmi_pll_pre_mult", + .ops = &clk_fixed_factor_ops, + .parent_names = (const char *[]){ "xtal" }, + .num_parents = 1, + }, +}; + static struct meson_clk_pll gxbb_hdmi_pll = { .m = { .reg_off = HHI_HDMI_PLL_CNTL, @@ -247,7 +258,7 @@ static struct meson_clk_pll gxbb_hdmi_pll = { .hw.init = &(struct clk_init_data){ .name = "hdmi_pll", .ops = &meson_clk_pll_ro_ops, - .parent_names = (const char *[]){ "xtal" }, + .parent_names = (const char *[]){ "hdmi_pll_pre_mult" }, .num_parents = 1, .flags = CLK_GET_RATE_NOCACHE, }, @@ -1558,6 +1569,7 @@ static struct clk_hw_onecell_data gxbb_hw_onecell_data = { [CLKID_VAPB_1] = &gxbb_vapb_1.hw, [CLKID_VAPB_SEL] = &gxbb_vapb_sel.hw, [CLKID_VAPB] = &gxbb_vapb.hw, + [CLKID_HDMI_PLL_PRE_MULT] = &gxbb_hdmi_pll_pre_mult.hw, [NR_CLKS] = NULL, }, .num = NR_CLKS, diff --git a/drivers/clk/meson/gxbb.h b/drivers/clk/meson/gxbb.h index aee6fbba2004..42573b28a137 100644 --- a/drivers/clk/meson/gxbb.h +++ b/drivers/clk/meson/gxbb.h @@ -194,8 +194,9 @@ #define CLKID_VPU_1_DIV 130 #define CLKID_VAPB_0_DIV 134 #define CLKID_VAPB_1_DIV 137 +#define CLKID_HDMI_PLL_PRE_MULT 141 -#define NR_CLKS 141 +#define NR_CLKS 142 /* include the CLKIDs that have been made part of the DT binding */ #include