Training engine
Each frequency point must have its data eye centred before it can be used. The
K1 brings up the PHY with a PI (PHY-independent) training sequencer inside the
MC: the firmware arms it, issues one operation per stage, and the engine drives
the bus and writes back per-DQ margins. The firmware treats the sequencer’s internal edge search as a black box
([design], docsClean/pi-training-engine; src/lib/k1_ddrt.c). With
K1_INDEP_EYE (the production build), after PI bring-up and DQS gate,
src/lib/k1_ddr_eye.c independently trains WL, RX/TX Vref and per-lane
RX/TX DQ delays on both ranks from DRAM memory-pattern sweeps without reading
the PI harvest ([measured] in logsRefs/000–013).
The PI engine
Operations are issued on the PI_CMD port (ddr+0x13d0) with a 1-based
rank field; each has a done mask in PI_STATUS (ddr+0x13fc) that the
firmware polls (the engine has no hardware timeout, so the budget is 1 s). A
command clears its own done bits; a done bit still set immediately after
issuing is a leftover from an earlier operation. CFG registers (PI_WL_CFG,
PI_RD_CFG, PI_WR_CFG) are written once before each stage. See
src/lib/k1_ddrt_regs.h and The training pass.
The stages
A PI pass runs four stages in a fixed order, with the ranks in self-refresh
([measured] durations ~8.5–9.0 ms in logsRefs/020, 021):
stage |
what it centres |
|---|---|
write leveling |
the DQS-to-clock phase per byte ( |
read gate (DQS gate) |
the read DQS gating window per byte ( |
read training |
the read eye: PHY Vref ( |
write training |
the write eye: MR14 is swept (21..36 on LPDDR4X) and the best value kept
(independently verified in |
CA training exists in the hardware but is unused by the LPDDR4X boot
([open], docsClean/ca-training; PI_CA0/PI_CA1 are never written in
src/).
Vref selection (max-min)
For both the read and write PI sweeps the firmware takes, at each Vref step,
the worst per-DQ margin over every rank and DQ, and picks the step with the
largest of those minima — on a plateau the lowest step wins. This max-min
rule (k1_ddrt_max_min() in src/lib/k1_ddrt.c) is shared by the
firmware and its tests (The training pass). A pass succeeds only
when every gate run passed and PHY_STATUS reads 0 after the sweeps.
Acceptance ranges
The trained WL, gate, read and write taps of the 8 GiB Samsung board define
the informational PI-harvest ranges in src/lib/k1_ddr_accept.c
(Acceptance and logging). Because Micron 16 GiB taps fall
outside Samsung’s ranges while verifying clean on DRAM (logsRefs/001,
005), the production K1_INDEP_EYE build checks independent
memory-pattern verification and MR14 consistency instead.