Notes, limitations and open points
Findings that come from reading, building and testing the code. Each item says where it lives and what would close it.
Behaviour worth knowing
The image always trains fp0, fp0, fp1 and fp2
k1_ddr_dfc_plan() does not depend on the requested rate. A request for 1066
or 1200 MT/s still trains fp1 and fp2, and then the final DFC goes back down.
This keeps one code path for every rate at the cost of extra passes; every
frequency point the controller may later switch to is trained. The final DFC is
issued even when the final fp is the one just trained.
PLL1 is programmed for 2400 unless 2666 or 1333 is requested
k1_ddr_pll_init() writes the 2666 pair when data_rate is 2666 or 1333.
Every other value, including 1066, 1200 and 2133, gets the 2400 setting, which
then drives fp0 (PLL1/2) and fp2 (PLL1/1). With the 2666 VCO, fp0 is ≈1333 MT/s
and fp2 is 2666 MT/s. Programming 2400 after a 2666 attempt drops the PLL enable bits, restores
both BootROM PLL1 words (CTL1 = 0x2a200000, analog 0x50dd6432), then
does the usual [15:8]=0x3B RMW. RMW of the 2666 leftover would leave
CTL1 = 0x203c3b55 and analog 0x50dd6538.
Rate fallback on training failure
k1_blob_ddr_init() calls k1_ddr_boot_fallback(), not k1_ddr_boot()
directly. A retryable failure (PI or independent-eye EIO, DFC timeout)
stops the remaining frequency points of that attempt and retries at a
safer rate: 2666→2400→1066, 2133/1333→1200→1066, 2400/1200→1066. 1066 has no
next rate. EINVAL / ENOSYS and PLL or SW-FC timeouts are not
retried; there is no fallback to one rank, LPDDR4, or a different ODT.
Success after a retry returns 0 and logs fallback A -> B plus
running at B MT/s (asked A). The SPL still chose the first rate
(EEPROM TLV 0x43 or DDR_DEFAULT_DATA_RATE 2400); the firmware only
steps down when that request cannot train. K1_EXP_FORCE_EYE_FAIL
injects that failure on the first attempt (after, stack counter).
Confirmed on the 16 GiB Micron (logsRefs/029-fallback-2666-to-2400-16gib):
asked 2666, injected -EIO at fp2, fallback 2666 -> 2400, PLL1 restored
from 0x203c5555 / 0x50dd6538 to 0x2a203b00 / 0x50dd6432,
ddr_init rc 0, DRAM 0 errors.
Range checks never fail the boot (PI harvest path)
k1_ddr_accept_* only print and count. A pass whose results fall outside the
reference ranges still returns 0 if the hardware reported no error. The count
appears as N item(s) out of range in the final line. With K1_INDEP_EYE
those harvest checks are skipped on cold boot and on the re-train entry; the
boot fails only when the independent memory-pattern verify (or MR14) fails
(Acceptance and logging).
data_rate 1333 is the 2666 VCO at fp0
k1_ddr_final_fp() parks 1333 at fp0 (the same MC bank and DFC entry as
1200). k1_ddr_pll_init() programmes the 2666 PLL1 pair, so fp0 runs at
≈1333 MT/s and the fp2 training pass runs at 2666 MT/s. Confirmed on the 8 GiB
Samsung (logsRefs/026-indep-1333-vco-8gib) and 16 GiB Micron
(logsRefs/027-indep-1333-vco-16gib) boards: PLL1 0x203c5555, PI fp2
mins 9/8, independent verify OK. Logs 015 and 023 measured the previous
mapping (2400 VCO, 1200 MT/s at that request).
Mainline cannot see a failure
The mainline SPL ignores the return value and, unless built with DEBUG,
passes puts = NULL, so a failing ddr_init is silent; the SPL’s
magic-word test at address 0 is the only signal. The validation patch shows the
minimal change needed in spl.c to honour the return value
(Validation vehicle).
The HW-DFC kick is a whole-word write
k1_ddr_dfc() writes CC_AP = 1 << 22, clearing every other bit of that
register, while the SW-FC kick in k1_ddr_pll_init() is a read-modify-write
of bit 26. The test model enforces the exact 1 << 22 value. Keep the two
forms as they are unless a measurement says otherwise.
Building the DFC snapshot switches the live bank
k1_ddr_dfc_table_load() reads the banked registers by temporarily rewriting
CTL_FREQ[31:28] on the running MC, then restores it. It runs between passes
with the DRAM idle; it must not run while anything else uses the DRAM.
DFC engine preserves trained banked values across same-fp and downward DFCs
[measured] on both 16 GiB Micron
(logsRefs/043-docsclean-claims-sweep/readme.md) and 8 GiB Samsung
(logsRefs/044-docsclean-claims-sweep-8gib/readme.md) at 2666 MT/s: on the
final DFC (fp2 -> fp2 after fp2 training), CTL_TXVREF remained at the
trained value 0x9d174314 (not the pre-training snapshot value
0x9d194314), PI_RD_CFG remained 0x00005070 (not 0x00000450),
and the dies held MR14 = 0x17 (23). Across the fp1 -> fp2 transition,
CTL_TXVREF switched from fp1’s value (0x9d154314 on 16 GiB,
0x9d1e4314 on 8 GiB) to fp2’s 0x9d194314 while PI_RD_CFG stayed
0x00005070. On downward DFCs back to lower banks, logsRefs/025-indep-1066-8gib/readme.md
(fp2 -> fp1) and logsRefs/026-indep-1333-vco-8gib/readme.md
(fp2 -> fp0) also preserved trained MR14 values (0x21 and 0x1d
respectively, rather than reverting to the pre-training 0x19 snapshot) with
no MR14 differs warning; k1_boot_dfc() keeps k1_ddrt_check_mr14()
as a runtime guard.
Gate range bounds reflect fp0 vs fp2 trained values
k1_ddr_accept_final() expects gate bytes of 33..40 at the final fp (at
fp2, pass 3 on 8 GiB Samsung trains 34..39), whereas
k1_ddr_accept_pp0b_gate() expects 32..40 after the second fp0 pass (at
pp0 pass 1 on 8 GiB Samsung, CS0 byte 3 gate trains to 0x00012021,
g = 32 in logsRefs/044-docsclean-claims-sweep-8gib/serial.log). Both
checks are informational only and are skipped under K1_INDEP_EYE.
The re-train entry discards the first MR read
k1_blob_retrain() issues a discarded MR14 read before printing the
mode registers with k1_ddr_print_mrs(), matching k1_boot_dfc() so a
call right after a hardware DFC does not print 0 on the first read.
Timeouts and stack
A PI operation that never completes costs up to 1 s before the pass fails (the
engine has no hardware timeout; the budget is generous on purpose). Without a
clock (not the case in the image) the poll cap of 100 000 000 reads bounds every
wait. The worst-case stack use is about 2.1 KiB of the SPL’s stack
(Build and image); struct k1_ddrt_result (~400 bytes) is the main
contributor and the re-train entry holds two of them.
Limitations
One rank: MISC entries of the DFC table
k1_tbl_data() adapts the rank byte only for entries targeting USER_0,
CA_CMD and PI_CMD. The MISC entries (0x13010000, 0x13008000,
0x13020000) keep 0x13. [measured] on the 8 GiB Samsung board at
2666 MT/s (logsRefs/045-close-open-points-8gib/readme.md): single-rank
(cs_num = 1, 4096 MB) full bring-up, independent eye training, all three
DFCs and CS0 DRAM probes pass with MISC keeping 0x13, and rewriting the
three MISC entries to 0x11 also passes fp2 -> fp1 -> fp2 DFCs with 0
DRAM errors. True single-rank x16 hardware remains [open]
(docsClean/address-map, docsClean/configurations).
MR5 and MR8 come from rank 0, channel 0 only
k1_ddr_boot() reads MR5/MR8 once and applies the resulting geometry to both
ranks. Mixed parts per rank are not supported (the address-map code has one
geometry for both).
Supported MR8 values
k1_ddr_geometry() accepts x8 and x16 with density codes 0..6 (2–16 Gb per
channel) whose rank size has a CS-map code. It rejects 1 Gb (code 12), x8 12 Gb
(6144 MB per rank, no size code), larger densities and other widths, and the
boot stops at step address-map.
The rank count is trusted
cs_num comes from the caller (the SPL’s EEPROM read, default 2). The firmware
does not probe for a second rank. A wrong cs_num shows up as a training or
DFC failure, not as a clear message. Observed on the 16 GiB Micron two-rank
package with SPL cs_num 1: independent CS0 verify passed; a following PI
pass did not keep DRAM at 0x40000000 and 0x1c0000000. Repeating that
run after k1_set_mr14() followed cs_sel left those kept-errors
unchanged (logsRefs/019-mr14-cs-sel-cs1-16gib).
LPDDR4 (non-X) is enabled but untested on silicon
The IO table, WDQS words, PHY LDO setting, fp3 pass plan and 2133 MT/s final fp
are enabled in k1_ddr_boot() and verified against the host mock model. The
drop-in blob defaults to K1_DDR_LPDDR4X (the mainline ABI carries no memory
type), and can be compiled for LPDDR4 (non-X) by defining
K1_DDR_TYPE_LPDDR4. Unverified on hardware: an MR14 sweep range tuned for
LPDDR4 (the code sweeps 21..36) and whether CA training is needed (no CA stage
exists in k1_ddrt.c; PI_CA0/1 are never written, [open],
docsClean/ca-training). LPDDR4 (non-X) remains [open] / untested on silicon
(docsClean/configurations).
MC timing bytes isolated on 16 GiB fp2
k1_mc_timing still ships the programmed words. Measured fp2
windows: 16 GiB combo 16/16/3/4 (logsRefs/032); 8 GiB combo 16/3/4/17
(logsRefs/034); +0x3ac=16 load-faults 8 GiB (033). At 2666 on
8 GiB (logsRefs/035–037) stock chase is 277 ns;
+0x3b0=16 load-faults; +0x3ac=16 4762 errors; combo 18/4/4/18 →
265 ns. On 16 GiB at 2666 (logsRefs/038) 16 is OK on both those
bytes; combo 16/3/4/16 → 262 ns. That combo Oopses Linux
(logsRefs/039). Programmed 2666 Linux chase is 199–200 ns (logsRefs/040, 047;
213 ns at 2400 MT/s in logsRefs/048–049, matching vendor 051).
The 1408 MiB freeze observed under the mainline U-Boot booti vehicle
(logsRefs/050, 052–054) does not occur when the same GPL
k1_ddr_fw.bin runs inside vendor SPL into vendor OpenSBI + vendor U-Boot +
Linux 6.6.63 (logsRefs/055: 1×2048 MiB, 4×512 MiB and 4×2048 MiB
= 8 GiB total all pass with 0 errors). Candidate intersection is not
in the table (MC timing: accepted ranges and optima).
Open points
Source references to the specification
Comments in src/ cite sections of an older reStructuredText revision of the
clean-room specification as doc NN and P-NN amendment numbers. That
numbering does not correspond to the historical Markdown in docsClean/,
whose files are named by topic; the comments are kept as written.
check_tables.py also parses that historical reStructuredText source, not
the Markdown of docsClean/.
On silicon (logsRefs/045-close-open-points-8gib/readme.md),
PLL_NO_LOCK (-110) and GATE_TIMEOUT (-110) error detection and
recovery paths are [measured], whereas K1_EXP_DFC_TIMEOUT remains
[open] on silicon (docsClean/dfc-engine, verified against the mock model in
tools/test/test_exp.c; the zeroed-table DFC probe in logsRefs/045 hung).