From patchwork Fri Jan 19 15:55:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10175675 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 39E6C60392 for ; Fri, 19 Jan 2018 15:56:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D1DB2859F for ; Fri, 19 Jan 2018 15:56:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11A99286B5; Fri, 19 Jan 2018 15:56: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=unavailable 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 BB67E2859F for ; Fri, 19 Jan 2018 15:56: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=jlG2qY1MsfDwpXWIJv+ycOkS0y4JG3QmHZuvZPI+l10=; b=BJL7ZSwKZGzrjIvj3/lXreOHN+ jcROjXnpulPV6MiHI1Fa7Q2ISZOtsRp2Ut3Lyc/HI3Vu31fwFid9E8Kq7yjknJUM6l/UfGLUe5v0A qTY7aHo7YHK+OP5fhnrg+2yEL4mKVk2RJVwuUlhewF04f0XEovVj1BVwheGpyIvmfvqcsTJ0mLf3W 6+H1Jx1qwIANxqUVOmkCzNhA3QJnTI+oHEwRpy0+zM59uBpUzlPGD5h3PobsHrC1qUbKDRQu1LPrI 2TROkN2r35tfymGy97ZTdKWZMI5saS/2ZRk5HhNZNN0TUqA53cPOEZ8NcCudckwoOYmYZzCucGTvP 1Kz9ZBAQ==; 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 1ecZ1G-0005rZ-Kv; Fri, 19 Jan 2018 15:55:54 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecZ17-0005Y2-3h for linux-amlogic@lists.infradead.org; Fri, 19 Jan 2018 15:55:49 +0000 Received: by mail-wr0-x244.google.com with SMTP id w50so1968276wrc.11 for ; Fri, 19 Jan 2018 07:55:40 -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=mmo13YY5nX1RYh/GLAaPQA5j7D1cc/50G4bNawPLCEA=; b=sgtnOfikuO1w6K2ahckzLtKAqVz8R5gCk4vWfto/svtYfO7NG9ZF9gJp532LbnbJfr uBz2xTFw84LAcdsovc04M4k7FE4VmWO1Wja+LTyF0H2zC0SvshrwWT3yAe9Ne4TE+Obz H+pY08bZAjPGZbhGlBTi8uyXiOVmyWfjm+yyHVEC1O0/Jn+FrSnQLql310Sree6O4iNw xQF8X6AsB7EQ/7pXOxE1yYHYGiQWfFa3PYp8ftd87J4ti3yz1qDH8xEPRGo6vKTFjnJh Do9X9xhHmOuiw5mw7gkze4P6vLmYB2vUx9ZAMRV0to8/JZw0czQGfHAzQucm7zW+o6e1 Xlzw== 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=mmo13YY5nX1RYh/GLAaPQA5j7D1cc/50G4bNawPLCEA=; b=UvqVZfSraBq7EZRlFc2TdVXUQfe6o7Au1b4DhiT2+wJRHdnOsldH2R4CkPFUQ+CQ+3 Dh6nxQ4DRoejnsE1jNy3riaxzq6FFFG2vpiaP4b24XublS0lGqJg22uUW/PyUDfHhwU5 8Zui9oGoIsNLjQa0VP7rxSSxcdTfS93diEwZbgm0/rAMbPw/RtsyCsDJz4yAa4Gqkyeq Ojd8OdDzEQlzEB31umPeyACdAiPHLbsQo9OdAWlnEaXIduYv1dmqAXQncz8wOd7JFgTT ZsT5ccXIT7zRK9NYU5hUBtefJSmVs8r+gy8he8UlNIDckaF9oUKSa/rJWoF9cSgicy9a ZLwg== X-Gm-Message-State: AKwxyteOOzXpulKRemcXqNRVWXuUPx1qtTcTxau6xTVA0jnmLUq9OLJv +chi8fDCs0dHEz366+1DSbt74A== X-Google-Smtp-Source: ACJfBosTWONIcgD4ozrpwi1IMhZcGevw/lYVUg+fWO9CutefiRHoQhuwq63pk/d4EHOid+qvbaTo9Q== X-Received: by 10.223.144.100 with SMTP id h91mr10425198wrh.147.1516377339542; Fri, 19 Jan 2018 07:55:39 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id w73sm25883027wrb.34.2018.01.19.07.55.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jan 2018 07:55:39 -0800 (PST) From: Jerome Brunet To: Neil Armstrong Subject: [PATCH v2 7/9] clk: meson: fix rate calculation of plls with a fractional part Date: Fri, 19 Jan 2018 16:55:27 +0100 Message-Id: <20180119155529.11532-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180119155529.11532-1-jbrunet@baylibre.com> References: <20180119155529.11532-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 the pll has a fractional part. This is making the rate calculation of the 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 a fixed factor clock in front on the gxbb pll and remove this constant from the calculation to fix the problem 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 1595f02f610f..218c769c6d50 100644 --- a/drivers/clk/meson/clk-pll.c +++ b/drivers/clk/meson/clk-pll.c @@ -88,7 +88,6 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw, frac = PARM_GET(p->width, p->shift, reg); rate += mul_u64_u32_shr(parent_rate, frac, p->width); - rate *= 2; } return div_u64(rate, n) >> od >> od2 >> od3; diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c index f74ed52e2673..b773be1033f8 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