ARM Sunxi Platform Development
 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:37:34 +0800	[thread overview]
Message-ID: <DN4TUQIL3J9N.XYYN5MTODT2C@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

Before ordering an Orange Pi 4 Pro to investigate this, I checked its
schematic, "OPI 4 PRO V1_3_2_20260109.pdf". Y1 is marked
"26M-20pF-10ppm", with a "USE 26M" note, and the CK-SEL resistors are
configured for 26 MHz.

Could you double check the crystal frequency on your board?

> 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.

I also noticed that your DTS in your U-Boot patch sets sets the
oscillator frequency to 24 MHz. If the board actually uses a 26 MHz
crystal, but the DTB used by Linux declares 24 MHz, the PLL_REF N/M
ratio of 12/13 would give:

  Actual:   26000000 * 12 / 13 = 24000000 Hz
  Reported: 24000000 * 12 / 13 = 22153846 Hz

This would also explain the reported rate and UART baud error.

Could you check the oscillator frequency in the DTB Linux is using and
share the raw values of PLL_REF_CTRL (0x02002000) and RTC_XO_CTRL0
(0x07090160)? That should help distinguish these possibilities.

>
> 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).
>
> 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.
>
> Tested on OrangePi 4 Pro (Allwinner A733).
>
> Thanks,
> Alastair

-- 
Best regards,
Junhui Liu


  parent reply	other threads:[~2026-11-26  3:38 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
2026-11-26  3:37     ` Junhui Liu [this message]
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=DN4TUQIL3J9N.XYYN5MTODT2C@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