DFC engine
A hardware dynamic frequency change (DFC) engine moves the running controller
between frequency points without re-initializing it. The firmware loads a
command table once and then kicks one frequency change at a time. The table
layout, command flows and kick protocol live in src/lib/k1_ddr_tables.c and
src/lib/k1_ddr_init.c (DFC table and hardware freq. change).
The table window
The table is written through a separate window (0xf0000000 in the image),
one entry at a time, as a (DATA, ADDR, INDEX) triple where writing INDEX commits
the entry. The window aliases the MC on the BPI-F3 ([measured]
DFC window ctl0 0x00040300, ddr ctl0 0x00040300 (alias) in
logsRefs/020 and 021); the firmware detects and logs whether it aliases
or is separate. The table has an entry flow, an exit flow, a snapshot of the
live MC state (globals plus the four banks) and a tail, delimited by header and
end flags, followed by three PHY marker triplets (DFC table and hardware freq. change).
Building the snapshot captures the banked MC registers by temporarily selecting each bank on the live MC and reading the offsets back, so it must run with the DRAM idle.
The kick
A DFC is kicked by masking the DCLK frequency-change IRQ, writing a pre-command
word (ddr+0x148 = 0x80ac0000), selecting the target clock word and
HW_SLP, then writing CC_AP = 1 << 22 (a whole-word write) and waiting
for bit 22 to clear. The engine is refused while ranks are in self-refresh ([measured] in
logsRefs/045-close-open-points-8gib/readme.md: STATUS 0x77 returns
-5) or while a previous kick is still stuck (bit 22 held), which only an MC
reset clears (DFC table and hardware freq. change).
On success ([measured] in ~25–26 µs for fp1, fp2 and final down-shifts to
fp0/fp1 in logsRefs/015–017, 020–021, 023–027), the
engine switches the bank, updates CTL_FREQ/PI_CFG/STATUS and re-sends
MR14 from the target bank ([measured] on both 16 GiB and 8 GiB in
logsRefs/043-docsclean-claims-sweep/readme.md and
logsRefs/044-docsclean-claims-sweep-8gib/readme.md; same-fp final DFC
fp2->fp2 preserves trained CTL_TXVREF and PI_RD_CFG rather than
overwriting them with the initial snapshot values, and downward DFCs
fp2->fp1 / fp2->fp0 preserve trained MR14 in logsRefs/025 /
026).
A kick with an incomplete table parks the ranks and leaves CTL_FREQ
unchanged — verified in the test double (K1_EXP_DFC_TIMEOUT in
tools/test/test_exp.c; [open] on silicon, docsClean/dfc-engine).
16 GiB variant
For 16 GiB parts an extra MR21 write (0x13020095) is inserted into both
command flows and the following entries shift up by one index
(src/lib/k1_ddr_init.c, [measured] in
logsRefs/020-eeprom-cs-num-16gib/readme.md; DFC table and hardware freq. change).