Re: [PATCH v7 4/8] clk: sunxi-ng: a733: Add PLL clocks support

From: Junhui Liu

Date: Wed Nov 25 2026 - 22:38:53 EST


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