Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2018113ybv; Sun, 23 Feb 2020 20:50:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwc9pTcIRZkI5f13uUs94+mWaa2iqIhC75UKxCHl/3s4HT1fug5vO9uL3PQWO6v6dkmbAUH X-Received: by 2002:aca:b504:: with SMTP id e4mr11696182oif.28.1582519855443; Sun, 23 Feb 2020 20:50:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582519855; cv=none; d=google.com; s=arc-20160816; b=jNXQBy/ldpOPNiw9PhHaRod27bPa9x5ibUWPwI+TykDeq/zIQh0cX7LZfR7dYwmMUG yv25NX0WwAm55+j0OniMtA60uY0URVgSpEE7c/YSeQ5KShXA2HzNSxbMH0tHCMN8qZdM gQZWnxPJOP9sxrzLdVP4BxrS/oMBx7k/KUAHJWfkY8slbad7WjBls2asQw840GcTogIL zZCbUERllCMBMelFU/5wefwUZRTyGUnegBEMBCz88S4BjSP0tQQJ9GFcP5Qi9HJjlmgp 9ZsQx52X3QGjqA/uyXNWCmqDQvtf/ZxCoJrcOgDzPTBOivQJVa3zogW1RGJfsw6p+Dc9 fcuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=draGFm7RAA0mhjngQtm7wZdCxww8tHZNBCP7gzZFvFM=; b=PXeWtzIxImSzXL0ZidnMMCwuUnskjJ6oehoY7DVJdIAEk6SWYGVaj8htsJCfubG7vC Ln42cC2T0IPzwQfDPovZZtDhJ9Y87oKwniJFVkNzTt2X1DNeP5qE7TMWtZDGG7k6hjsY tegPCeyaw8v7lbL8jtAl6wAdDE32MHGZGAxHY5AlpSoH5wTFTnMXjB2QMOsas7eLdX5R /mnfDRVWQ5y99ZtU1blGrGN7o0RhY45ZNhJQ7MHMfhRtn205B+YAVoaGUEN0CkDQBekl RF/j6PVbHpXIWKYuwkIw12kj1juQO6rpZRk5+SSV6Tw4ZnIexJ2frR1qoAKzqaR1UIRc h0mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vTzcjVrS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w207si4547034oia.226.2020.02.23.20.50.43; Sun, 23 Feb 2020 20:50:55 -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=@kernel.org header.s=default header.b=vTzcjVrS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727314AbgBXEue (ORCPT + 99 others); Sun, 23 Feb 2020 23:50:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:38262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727186AbgBXEud (ORCPT ); Sun, 23 Feb 2020 23:50:33 -0500 Received: from localhost.localdomain (unknown [122.182.199.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4CDC20675; Mon, 24 Feb 2020 04:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582519832; bh=I45mpKN9HaTxsj/paq804ElnxebxHGDKm3u/O96MCI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vTzcjVrSpaAJ59FHhV7ccL5z9sAnLoWYz1JOyZJ7lwpUKXw1qqDatEdC3MvmYJUkJ DUeJuxf+t2BSDp4v6yrI9v642YDzoD39LikAP50lGvg/UnCqKCw+wj4s9QPa6LaaXR fDiB3e6MY6D7s/2ssAvyaYS8ZS7HD9B5JvFsDOF8= From: Vinod Koul To: Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Taniya Das , Rob Herring , Mark Rutland , devicetree@vger.kernel.org, Andy Gross , Michael Turquette , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, psodagud@codeaurora.org, tsoni@codeaurora.org, jshriram@codeaurora.org, vnkgutta@codeaurora.org, Vinod Koul Subject: [PATCH v4 2/5] clk: qcom: clk-alpha-pll: Refactor trion PLL Date: Mon, 24 Feb 2020 10:20:00 +0530 Message-Id: <20200224045003.3783838-3-vkoul@kernel.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200224045003.3783838-1-vkoul@kernel.org> References: <20200224045003.3783838-1-vkoul@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Taniya Das Remove duplicate function for calculating the round rate of PLL and also update the trion pll ops to use the common function. Signed-off-by: Taniya Das Signed-off-by: Venkata Narendra Kumar Gutta Signed-off-by: Vinod Koul --- drivers/clk/qcom/clk-alpha-pll.c | 33 ++++++-------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c index 0bdf6e45fac9..0adec585eb4f 100644 --- a/drivers/clk/qcom/clk-alpha-pll.c +++ b/drivers/clk/qcom/clk-alpha-pll.c @@ -845,33 +845,12 @@ static unsigned long clk_trion_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { struct clk_alpha_pll *pll = to_clk_alpha_pll(hw); - struct regmap *regmap = pll->clkr.regmap; - u32 l, frac; - u64 prate = parent_rate; - - regmap_read(regmap, PLL_L_VAL(pll), &l); - regmap_read(regmap, PLL_ALPHA_VAL(pll), &frac); - - return alpha_pll_calc_rate(prate, l, frac, ALPHA_REG_16BIT_WIDTH); -} - -static long clk_trion_pll_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *prate) -{ - struct clk_alpha_pll *pll = to_clk_alpha_pll(hw); - unsigned long min_freq, max_freq; - u32 l; - u64 a; - - rate = alpha_pll_round_rate(rate, *prate, - &l, &a, ALPHA_REG_16BIT_WIDTH); - if (!pll->vco_table || alpha_pll_find_vco(pll, rate)) - return rate; + u32 l, frac, alpha_width = pll_alpha_width(pll); - min_freq = pll->vco_table[0].min_freq; - max_freq = pll->vco_table[pll->num_vco - 1].max_freq; + regmap_read(pll->clkr.regmap, PLL_L_VAL(pll), &l); + regmap_read(pll->clkr.regmap, PLL_ALPHA_VAL(pll), &frac); - return clamp(rate, min_freq, max_freq); + return alpha_pll_calc_rate(parent_rate, l, frac, alpha_width); } const struct clk_ops clk_alpha_pll_fixed_ops = { @@ -917,7 +896,7 @@ const struct clk_ops clk_trion_fixed_pll_ops = { .disable = clk_trion_pll_disable, .is_enabled = clk_trion_pll_is_enabled, .recalc_rate = clk_trion_pll_recalc_rate, - .round_rate = clk_trion_pll_round_rate, + .round_rate = clk_alpha_pll_round_rate, }; EXPORT_SYMBOL_GPL(clk_trion_fixed_pll_ops); @@ -1173,7 +1152,7 @@ static int alpha_pll_fabia_set_rate(struct clk_hw *hw, unsigned long rate, * Due to limited number of bits for fractional rate programming, the * rounded up rate could be marginally higher than the requested rate. */ - if (rrate > max || rrate < rate) { + if (rrate > (rate + PLL_RATE_MARGIN) || rrate < rate) { pr_err("%s: Rounded rate %lu not within range [%lu, %lu)\n", clk_hw_get_name(hw), rrate, rate, max); return -EINVAL; -- 2.24.1