Devicetree
 help / color / mirror / Atom feed
From: "Junhui Liu" <junhui.liu@pigmoral.tech>
To: "Alastair D'Silva" <alastair@d-silva.org>,
	"Junhui Liu" <junhui.liu@pigmoral.tech>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>,
	"Chen-Yu Tsai" <wens@kernel.org>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Samuel Holland" <samuel@sholland.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Richard Cochran" <richardcochran@gmail.com>
Cc: <linux-clk@vger.kernel.org>, <linux-sunxi@lists.linux.dev>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	"Andre Przywara" <andre.przywara@arm.com>,
	<netdev@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-riscv@lists.infradead.org>,
	"Jerome Brunet" <jbrunet@baylibre.com>,
	"Enzo Adriano" <enzo.adriano.code@gmail.com>,
	"Norman Herms" <dockseed@proton.me>,
	"Vinicius Pedrosa" <vinicius.eduardo.pedrosa@gmail.com>
Subject: Re: [PATCH v7 4/8] clk: sunxi-ng: a733: Add PLL clocks support
Date: Thu, 26 Nov 2026 11:19:39 +0800	[thread overview]
Message-ID: <DN4TH0CNAM11.2OA7W5L11W78S@pigmoral.tech> (raw)
In-Reply-To: <20261125122452.3966873-1-alastair@d-silva.org>

Hi Alastair,

On Wed Nov 25, 2026 at 8:24 PM CST, Alastair D'Silva wrote:
> Hi Junhui,
>
> On Thu, 12 Nov 2026, Junhui Liu wrote:
>> static struct ccu_nkmp pll_ref_clk = {
>> ...
>> };
>> ...
>> static CLK_FIXED_FACTOR_HWS(sys_24M_clk, "sys-24M", pll_ref_hws, 1, 1, 0);
>
> While testing this v7 series on the OrangePi 4 Pro (24 MHz HOSC), ttyS0
> switches from earlycon to garbled output with:
>
>   2500000.serial: ttyS0 MMIO32:0x0000000002500000 (irq = 414, base_baud = 1384615) is a 16550A
>
> Because the hardware bypasses pll-ref (0x02002000) when HOSC is 24 MHz,
> sys-24M physically runs at 24 MHz from HOSC, while pll-ref remains
> disabled with reset/unprogrammed N=12, M=13 fields. Since
> ccu_nkmp_ops.recalc_rate() computes parent_rate * N / M regardless of
> the enable bit, pll-ref reports 24000000 * 12 / 13 = 22153846 Hz.
>
> sys-24M, apb-uart, and bus-uart0 inherit 22153846 Hz instead of
> 24000000 Hz, so 8250_dw calculates base_baud = 1384615 (instead of
> 1500000) and programs divisor 12 instead of 13 (+8.3% baud error).

Thanks for testing and reporting this. This is indeed a problem. I had
assumed that PLL_REF would be used on all boards.

I also tried manually disabling or bypassing PLL_REF on my Radxa Cubie
A7A, but have not yet managed to establish a working bypass
configuration... I currently suspect that the selection is handled
automatically by the hardware, but this needs further confirm.

>
> If pll-ref is disabled/bypassed (or if sys-24M is physically fixed at
> 24 MHz as the comment describes), either pll_ref_clk needs a recalc_rate
> that returns 24 MHz when disabled/bypassed, or sys_24M_clk should not
> inherit an unenabled pll-ref N/M ratio.

The issue may affect not just sys-24M, but also the downstream PLLs.
According to the vendor SDK, their control registers have a PLL_FREF_SEL
mux at bit 24, selecting between HOSC and REFPLL. The driver currently
models these PLLs as having PLL_REF as their only parent, so their rates
could also be calculated incorrectly when they actually use HOSC. We
should model those muxes as well.

However, my A7A, A7S and A7Z boards all use 26 MHz crystals, so I cannot
properly validate the 24 MHz case until I get a board with a 24 MHz
crystal. In the meantime, if you have a fix in mind, please feel
free to send a separate patch.

>
> Tested on OrangePi 4 Pro (Allwinner A733).
>
> Thanks,
> Alastair

-- 
Best regards,
Junhui Liu


  reply	other threads:[~2026-11-26  3:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  7:11 [PATCH v7 0/8] clk: sunxi-ng: Add support for Allwinner A733 CCU and PRCM Junhui Liu
2026-11-12  7:11 ` [PATCH v7 1/8] dt-bindings: clk: sun60i-a733-ccu: Add Allwinner A733 support Junhui Liu
2026-11-12  7:11 ` [PATCH v7 2/8] clk: sunxi-ng: sdm: Add dual patterns support Junhui Liu
2026-11-12  7:11 ` [PATCH v7 3/8] clk: sunxi-ng: a733: Add PRCM CCU Junhui Liu
2026-11-12  7:11 ` [PATCH v7 4/8] clk: sunxi-ng: a733: Add PLL clocks support Junhui Liu
2026-11-25 12:24   ` Alastair D'Silva
2026-11-26  3:19     ` Junhui Liu [this message]
2026-11-26  3:37     ` Junhui Liu
2026-11-26  6:48   ` Alastair D'Silva
2026-11-12  7:11 ` [PATCH v7 5/8] clk: sunxi-ng: a733: Add bus " Junhui Liu
2026-11-12  7:11 ` [PATCH v7 6/8] clk: sunxi-ng: a733: Add mod " Junhui Liu
2026-11-12 14:58   ` Chen-Yu Tsai
2026-11-13  7:18   ` sashiko-bot
2026-11-15 11:55     ` Chen-Yu Tsai
2026-11-12  7:11 ` [PATCH v7 7/8] clk: sunxi-ng: a733: Add bus clock gates Junhui Liu
2026-11-25 11:53   ` Alastair D'Silva
2026-11-26  3:56     ` Chen-Yu Tsai
2026-11-12  7:11 ` [PATCH v7 8/8] clk: sunxi-ng: a733: Add reset lines Junhui Liu
2026-11-15 12:09 ` [PATCH v7 0/8] clk: sunxi-ng: Add support for Allwinner A733 CCU and PRCM Chen-Yu Tsai

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=DN4TH0CNAM11.2OA7W5L11W78S@pigmoral.tech \
    --to=junhui.liu@pigmoral.tech \
    --cc=alastair@d-silva.org \
    --cc=alex@ghiti.fr \
    --cc=andre.przywara@arm.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=bmasney+clk@redhat.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dockseed@proton.me \
    --cc=enzo.adriano.code@gmail.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=jbrunet@baylibre.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=robh@kernel.org \
    --cc=samuel@sholland.org \
    --cc=sboyd@kernel.org \
    --cc=vinicius.eduardo.pedrosa@gmail.com \
    --cc=wens@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