Linux clock framework development
 help / color / mirror / Atom feed
From: Chuan Liu <chuan.liu@amlogic.com>
To: Jerome Brunet <jbrunet@baylibre.com>,
	Chuan Liu via B4 Relay <devnull+chuan.liu.amlogic.com@kernel.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/4] clk: meson: Fix an issue with inaccurate hifi_pll frequency
Date: Fri, 6 Sep 2024 16:12:12 +0800	[thread overview]
Message-ID: <ceb00323-7956-4259-9f12-08045396da89@amlogic.com> (raw)
In-Reply-To: <1jo751qn4u.fsf@starbuckisacylon.baylibre.com>


On 2024/9/6 15:04, Jerome Brunet wrote:
> [ EXTERNAL EMAIL ]
>
> On Fri 06 Sep 2024 at 13:52, Chuan Liu via B4 Relay <devnull+chuan.liu.amlogic.com@kernel.org> wrote:
>
>> Some PLLs with fractional multipliers have fractional denominators that
>> are fixed to "100000" instead of the previous "(1 << pll->frac.width)".
>>
>> The hifi_pll for both C3 and S4 supports a fractional multiplier and has
>> a fixed fractional denominator of "100000".
>>
>> Here are the results of the C3-based command tests (already defined
>> CLOCK_ALLOW_WRITE_DEBUGFS):
>> * echo 491520000 > /sys/kernel/debug/clk/hifi_pll/clk_rate
>> * cat /sys/kernel/debug/clk/hifi_pll/clk_rate
>> 491520000
>> * echo 1 > /sys/kernel/debug/clk/hifi_pll/clk_prepare_enable
>> * cat /sys/kernel/debug/meson-clk-msr/clks/hifi_pll_clk
>> 491515625       +/-15625Hz
>> * devmem 0xfe008100 32
>> 0xD00304A3
>> * devmem 0xfe008104 32
>> 0x00014820
>>
>> Based on the register information read above, it can be obtained:
>> m = 0xA3 = 0d163;
>> n = 0x1 = 0d1
>> frac = 0x14820 = 0d84000
>> od = 0x3 = 0d3
>>
>> hifi_pll calculates the output frequency:
>> calc_rate = xtal_rate / n * (m + (frac / frac_max)) >> od;
>> calc_rate = 24000000 / 1 * (163 + (84000 / 100000)) >> 3;
>> calc_rate = 491520000
>>
>> clk_rate, msr_rate, and calc_rate all match.
> Thanks for the detailed description.
>
> Is there a possibility this applies to the g12/sm1 as well ? HiFi PLL
> has had trouble on these SoCs since support has been added. It sometimes
> takes a long time to report a lock. So long we consider it a failure.
>
> There was no such issue on AXG. If you check DT, it is the reason why
> AXG use the HiFi PLL for the sound card and G12/SM1 does not.


I have confirmed that only the hifi_pll of the chip in recent years has 
this feature,

and g12a/sm1/axg is not like this.


I confirm that our sm1 uses hifi_pll, and I have not encountered the
situation you said. There was a probability of lock failure in pll
before, which was solved by adding 50us delay in meson_clk_pll_enable:
@@ -378,6 +378,8 @@ static int meson_clk_pll_enable(struct clk_hw *hw)
         /* Enable the pll */
         meson_parm_write(clk->map, &pll->en, 1);

+       udelay(50);
+
         /* Take the pll out reset */
         if (MESON_PARM_APPLICABLE(&pll->rst))
                 meson_parm_write(clk->map, &pll->rst, 0);

This patch is also prepare to push to upstream later.


Another detail is that the larger the frac value, the longer the lock
time, but the time is at the us level, so that the timeout in the pll
driver is not triggered.


>
>> The test and calculation results of S4 are consistent with those of C3,
>> which will not be repeated here.
>>
>> Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
>> ---
>> Chuan Liu (4):
>>        clk: meson: Support PLL with fixed fractional denominators
>>        clk: meson: c3: pll: hifi_pll frequency is not accurate
>>        clk: meson: s4: pll: hifi_pll support fractional multiplier
>>        clk: meson: s4: pll: hifi_pll frequency is not accurate
>>
>>   drivers/clk/meson/c3-pll.c  |  1 +
>>   drivers/clk/meson/clk-pll.c | 22 +++++++++++++++++++---
>>   drivers/clk/meson/clk-pll.h |  1 +
>>   drivers/clk/meson/s4-pll.c  |  9 +++++++--
>>   4 files changed, 28 insertions(+), 5 deletions(-)
>> ---
>> base-commit: adac147c6a32e2919cb04555387e12e738991a19
>> change-id: 20240904-fix_clk-668f7a1a2b16
>>
>> Best regards,
> --
> Jerome

  reply	other threads:[~2024-09-06  8:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06  5:52 [PATCH 0/4] clk: meson: Fix an issue with inaccurate hifi_pll frequency Chuan Liu via B4 Relay
2024-09-06  5:52 ` [PATCH 1/4] clk: meson: Support PLL with fixed fractional denominators Chuan Liu via B4 Relay
2024-09-06  6:51   ` Jerome Brunet
2024-09-06  8:24     ` Chuan Liu
2024-09-06  5:52 ` [PATCH 2/4] clk: meson: c3: pll: hifi_pll frequency is not accurate Chuan Liu via B4 Relay
2024-09-06  6:55   ` Jerome Brunet
2024-09-06  8:26     ` Chuan Liu
2024-09-06  5:52 ` [PATCH 3/4] clk: meson: s4: pll: hifi_pll support fractional multiplier Chuan Liu via B4 Relay
2024-09-06  6:58   ` Jerome Brunet
2024-09-06  5:52 ` [PATCH 4/4] clk: meson: s4: pll: hifi_pll frequency is not accurate Chuan Liu via B4 Relay
2024-09-06  7:04 ` [PATCH 0/4] clk: meson: Fix an issue with inaccurate hifi_pll frequency Jerome Brunet
2024-09-06  8:12   ` Chuan Liu [this message]
2024-09-06  7:11 ` (subset) " 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=ceb00323-7956-4259-9f12-08045396da89@amlogic.com \
    --to=chuan.liu@amlogic.com \
    --cc=devnull+chuan.liu.amlogic.com@kernel.org \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=mturquette@baylibre.com \
    --cc=neil.armstrong@linaro.org \
    --cc=sboyd@kernel.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