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: 125181 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp352139ljf; Fri, 19 Jan 2018 07:56:34 -0800 (PST) X-Google-Smtp-Source: ACJfBosOqlh3wWC9gcxYdLn7tEYbKqVUHcnU+p7TMRtEtDXoyEq5uwYRmoqOSmo6ClRQ1rrp9tKh X-Received: by 10.98.133.193 with SMTP id m62mr34259073pfk.18.1516377394257; Fri, 19 Jan 2018 07:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516377394; cv=none; d=google.com; s=arc-20160816; b=inZwAyeENksP4Jab5bvcMe/K3p5NiyQwBuCRwVXmyZw3zyejVIZ0rlQ23Vr58IQlo+ b70qaVCFUI82AdjF9hWN7xnFVnwj30VZOwx3Bjz3KIKmUvfZwu13L+8MMpBFp2UQ0lsv u7memzUv5i0jeXqb2I/R2Vb0Gahx7m8Ge+FfZJ3SnePU72HxolM5zZEsX0cWbN2jvqm2 9gWcYmB1EstCV4oIDXgGPvCx7z9PFi7gc8oWqv0cuTTtWQKHnexxzzzEesw6Vqjd7UjZ m3lXU0C5xgathkB8Te85UY3RqLbQ0HnmbU8K+cVY6VmBO8TNkm4FmaL2yLoDqTUdhLYA 0gYQ== 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=mmo13YY5nX1RYh/GLAaPQA5j7D1cc/50G4bNawPLCEA=; b=XaIwLtbA+5T8BC0kxsw0DFf49au27VjvXDgmdw+id50DuE5jo5T4yrhLpWhBffqTaj dPh9P+AzH9esfW8vNRb75Kg22AkbDAs064YTfFCkbYpfJKJR+X67O6emLHdiY7TpbesE xKZU19lheoF3gJBYpLmqALjD+3LymNeMAKz6spWa5hWk8DpJUL1Chz8UB1l0E+UUj0XJ aDPi7PsB9aWK95O290FravP/RmMectjuNvtg8WWDqpv3Lo8Jm6Wwrm4Pcs8gp4sKFwMA iHl25R1sKq0DhViEPmNhe8OROdQVBeKonl9eR+7kWliXPaz769ntRR4hZIw0AHlvNKGx qf9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=sgtnOfik; 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 s15si8447989pgf.99.2018.01.19.07.56.34; Fri, 19 Jan 2018 07:56:34 -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=sgtnOfik; 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 S1756077AbeASP4b (ORCPT + 28 others); Fri, 19 Jan 2018 10:56:31 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46680 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755360AbeASPzk (ORCPT ); Fri, 19 Jan 2018 10:55:40 -0500 Received: by mail-wr0-f194.google.com with SMTP id g21so1969166wrb.13 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=H5csYsHteSE1NHQNFHC/eWgT7dLGpDHNEHlFhMOb/6jZujY6MAFr8n6S+0V3Ng5ydK PF0A+PwvHPmACRpOlQ3yOJxOakqBfaKJC3gHO0G9CjVmfaexqJTkXKjIrtniGjnPyfQd EjRxbZwCCeOKOqiL0d05cC0yx5uPWn2O7Tgs9IH0ryohDBkI5sUwY4IZoIES3DFS4vmE SoGJQE/+BiJaZAQESM1xGkqi2IT7SeOcsrNxdPm+ACe4dQ5AhDoVCQBIW73bh3IqisfT ieTUUjoaEFOWBhop0YXnob6sJclhJs6jbHaAGc1yq5ctyUuj/XnKh/vWtTxjUvZypH8F al7w== X-Gm-Message-State: AKwxytfALsqHPT3lGhX5VT2GkCnY6Fvdj7O3YrYFUeCTXn9tyEYckUwK KIGQVDtJkiWTt7mDcxpKYsRSgg== 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 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 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.14.3 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