From: yixun.lan@amlogic.com (Yixun Lan)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH 3/9] clk: meson: remove unnecessary rounding in the pll clock
Date: Fri, 19 Jan 2018 10:06:50 +0800 [thread overview]
Message-ID: <31b18269-22f3-e536-9eb2-449a7e1fb863@amlogic.com> (raw)
In-Reply-To: <20180118184532.6856-4-jbrunet@baylibre.com>
On 01/19/18 02:45, Jerome Brunet wrote:
> The pll driver perform the rate calculation in Mhz, which adds an
> unnecessary rounding down to the Mhz of the rate. Use 64bits long
> integer to perform this calculation safely on meson8b and perform the
> calculation in Hz instead
>
> Fixes: 7a29a869434e ("clk: meson: Add support for Meson clock controller")
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
> drivers/clk/meson/clk-pll.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
> index 2614341fc4ad..fa4cec13d6e8 100644
> --- a/drivers/clk/meson/clk-pll.c
> +++ b/drivers/clk/meson/clk-pll.c
> @@ -51,8 +51,7 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
> {
> struct meson_clk_pll *pll = to_meson_clk_pll(hw);
> struct parm *p;
> - unsigned long parent_rate_mhz = parent_rate / 1000000;
> - unsigned long rate_mhz;
> + u64 rate;
> u16 n, m, frac = 0, od, od2 = 0;
> u32 reg;
>
> @@ -74,17 +73,18 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
> od2 = PARM_GET(p->width, p->shift, reg);
> }
>
> + rate = (u64)m * parent_rate;
> +
> p = &pll->frac;
> if (p->width) {
> reg = readl(pll->base + p->reg_off);
> frac = PARM_GET(p->width, p->shift, reg);
> - rate_mhz = (parent_rate_mhz * m + \
> - (parent_rate_mhz * frac >> 12)) * 2 / n;
> - rate_mhz = rate_mhz >> od >> od2;
> - } else
> - rate_mhz = (parent_rate_mhz * m / n) >> od >> od2;
>
> - return rate_mhz * 1000000;
> + rate += (u64)parent_rate * frac >> 12;
> + rate *= 2;
> + }
> +
> + return (rate / n) >> od >> od2;
> }
>
> static long meson_clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
>
Hi Jerome:
This is exactly what I want to propose, thanks for pushing this!
With the whole series, the fixed_pll is more accurate, and the ethernet
driver on axg is capable of choosing fclk_div2..
Yixun
next prev parent reply other threads:[~2018-01-19 2:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 18:45 [PATCH 0/9] clk: meson: pll fixes Jerome Brunet
2018-01-18 18:45 ` [PATCH 1/9] clk: meson: check pll rate param table before using it Jerome Brunet
2018-01-18 18:45 ` [PATCH 2/9] clk: meson: remove useless pll rate param tables Jerome Brunet
2018-01-18 18:45 ` [PATCH 3/9] clk: meson: remove unnecessary rounding in the pll clock Jerome Brunet
2018-01-19 2:06 ` Yixun Lan [this message]
2018-01-18 18:45 ` [PATCH 4/9] clk: meson: use frac parameter width instead of a constant Jerome Brunet
2018-01-18 18:45 ` [PATCH 5/9] clk: meson: add od3 to the pll driver Jerome Brunet
2018-01-18 18:45 ` [PATCH 6/9] clk: meson: add gxl hdmi pll Jerome Brunet
2018-01-18 18:45 ` [PATCH 7/9] clk: meson: fix pll with fractional part calculation Jerome Brunet
2018-01-18 18:45 ` [PATCH 8/9] clk: meson: gxbb: add the fractional part of the fixed_pll Jerome Brunet
2018-01-18 18:45 ` [PATCH 9/9] clk: meson: axg: " Jerome Brunet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31b18269-22f3-e536-9eb2-449a7e1fb863@amlogic.com \
--to=yixun.lan@amlogic.com \
--cc=linus-amlogic@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®