Clocks and PMU

The DDR clocks come from two PLLs (PLL1, PLL2) in the APMU at pmu = 0xd4282800. The firmware programs them, waits for lock, moves to frequency point 0 by a software frequency change (SW-FC) and enables the MC clock. The register offsets and PLL words are defined in src/lib/k1_ddrt_regs.h and programmed in k1_ddr_pll_init() in src/lib/k1_ddr_init.c (Controller bring-up).

PLLs and the data rate

PLL1 carries the data-rate-dependent VCO. The two settings the firmware uses are 2400 and 2666 MT/s. data_rate 2666 and 1333 take the 2666 pair (0x203c5555 / 0x50dd6538, [measured] in logsRefs/014-indep-2666-16gib/readme.md, logsRefs/022-indep-2666-8gib/readme.md, logsRefs/026-indep-1333-vco-8gib/readme.md and logsRefs/027-indep-1333-vco-16gib/readme.md); every other requested rate is served by the 2400 setting (0x2a203b00 / 0x50dd6432, [measured] in logsRefs/016, 017, 020, 021, 024, 025) driving the right frequency point. When falling back from 2666 to 2400, restoring the BootROM analog word 0x50dd6432 before the 0x3b RMW is [measured] and [required] in logsRefs/029-fallback-2666-to-2400-16gib/readme.md. 2666 is the SoC maximum and trains with smaller margins (shorter unit interval, [measured] in logsRefs/014 and 022). A ≈1333 MT/s operating point is PLL1 at the 2666 VCO, ending at fp0 (The boot interface).

Clock-select, lock and SW-FC

CLKSEL (pmu+0x3b4) enables PLL1/PLL2 and reports their lock bits. Bring-up order in k1_ddr_pll_init() (src/lib/k1_ddr_init.c, [measured] in logsRefs/020-eeprom-cs-num-16gib/readme.md and logsRefs/021-eeprom-cs-num-8gib/readme.md):

  1. write the PLL1/PLL2 VCO and analog words;

  2. enable both PLLs in CLKSEL and wait for both lock bits;

  3. select the fp0 clock word (0x3b50), set HW_SLP for a SW-FC, kick CC_AP bit 26 and wait for it to clear;

  4. enable the MC clock (MCK_CTRL).

No MC register may be read or written before the MC clock is on (enforced by tools/test/model.c; [required]). The per-fp clock words are k1_clksel[] in src/lib/k1_ddr_tables.c (Data tables).

MC reset

Pulsing HW_SLP bit 21 low then high (≥100 µs each half) resets the MC and PHY while keeping the PLL configuration (k1_ddr_mc_reset() in src/lib/k1_ddr_init.c). The firmware uses it before the x8 re-initialization (Controller bring-up, [measured] in logsRefs/020 and 021) and between rate-fallback attempts ([measured] in logsRefs/029-fallback-2666-to-2400-16gib/readme.md); it must be followed by a full Device_Init.

Frequency-change kicks

Two kicks share the PMU: the SW-FC kick (CC_AP bit 26, a read-modify-write, used once to reach fp0) and the hardware DFC kick (CC_AP bit 22, a whole-word write, used for every run-time frequency change). The DFC side is in DFC engine and DFC table and hardware freq. change.