| ← Previous: PMU Message Block | Index | Next: PHY Training Behavior → |
This document specifies the full-training path for one SpacemiT K3 LPDDR5 controller and the ordering across the two controllers. Quickboot is a different path and is covered only where it affects result ownership.
There are two execution agents:
The two DDRC instances are initialized sequentially, each with its own PHY, PMU execution, mailbox stream, and saved result. A controller-local failure must not be hidden by continuing as though both controllers were usable.
Observed reference behavior and recommended new-implementation policy are separated below. The reference contains unbounded waits and inconsistent PMU-error propagation; those are not desirable interface requirements.
For each controller, obtain DDRC_BASE from the hardware description rather than assuming a single fixed address:
CFG_BASE = DDRC_BASE + 0x600000
DPHY_BASE = DDRC_BASE + 0x800000
PHY resources use CSR indices: host byte address = DPHY_BASE + 4 * index. DDRC and CFG offsets in this document are byte offsets from their bases. PHY/mailbox values are 16-bit resources accessed through the indexed host window; preserve neighboring halfwords when only one is intended.
Important windows are:
| Resource | PHY CSR index | Role |
|---|---|---|
| ACSM SRAM | 0x41000 |
4096 halfwords collected after training |
| PMU IMEM | 0x50000 |
Training firmware loaded as halfwords |
| DMEM/message | 0x58000 |
320-byte message block |
| Serialized PHY parameters | 0x58200 |
Quickboot restore format, 5170 halfwords |
| DMEM clear start | 0x584d2 |
Clear through 0x5ffff in full-training preparation |
Do not access the PHY/PMU MMIO from an operating system after boot: on the reference board this stalled the SoC. Debug collection belongs in the loader while the relevant clocks and PMU are active, or on a suitable debug interface.
| Stage | Owner | Required result before advancing |
|---|---|---|
| 1 | Host | Part, ranks, organization, density, rate, electrical parameters, and firmware selected |
| 2 | Host | DPLL locked, clock switch complete, DCLK enabled |
| 3 | Host | DDRC timings, DFI, refresh, ZQ, ranks, address map, and configuration-mode state programmed |
| 4 | Host | IMEM/DMEM, PHY tables, overrides, message block, and DMEM clear complete |
| 5 | PMU, serviced by host | PMU completion 0x07 received, or a declared error returned |
| 6 | Host | PMU stopped, host ownership restored, post-run training table applied |
| 7 | Host | Message, 5170 PHY halfwords, and 4096 ACSM halfwords collected |
| 8 | Host | DFI operational, DDRC in normal state, self-refresh off, ports enabled |
| 9 | Host | Non-destructive-after-restore memory smoke test passed |
The host must not access PHY CSRs while the PMU owns the PHY, except for the defined mailbox interface. Conversely, the host must own the PHY before table application and result collection.
0x49a4 bytes.If a valid persisted result matches the current memory type, ranks, rate, integrity check, and format version, a loader may choose quickboot instead. That decision occurs before this full-training sequence; an invalid or mismatched result must not be partially reused.
CFG+0x1c bit 0 until lock.CFG+0x18[21:16] and select the observed source encoding: 7 << 19 for 4800 or 2 << 19 for 6400.CFG+0x18[25] and wait for that bit to clear.CFG+0x18[0].CFG+0x18[22]. The reference also sets bit 1 in this phase.Recommended: bound every lock/change wait and fail with a clock-specific diagnostic. Do not start the PMU after a clock timeout.
Configure the DDRC while the host owns the PHY:
opctrl1, inittmg0, pwrctl, and rfshctl0.swctl/swstat.dfimisc=0x00010014 before PMU execution, again using the DDRC configuration transaction mechanism.The relevant DDRC offsets are byte offsets. In particular, swctl=0x10c80, swstat=0x10c84, dfimisc=0x10510, dfistat=0x10514, pwrctl=0x10180, and controller status stat=0x10014.
Address-map invariants observed in the reference are:
ADDRMAP1=0x3f).This stage establishes state; it does not itself measure training eyes.
0x50000, in halfwords, using the actual decompressed/image length.0xdeadbeef means skip the write, not write that literal value.0x58000, including frequency, topology, MR inputs, and SequenceCtrl.0x584d2 through 0x5ffff.For a host 32-bit store covering two 16-bit CSR entries, both halfwords must be intentional. Use a read-modify-write or a paired write when only one halfword is known; do not accidentally zero its neighbor.
Hardware window restriction on DMEM (0x58000–0x580ff): All modifications to the message block (0x58000–0x5809f) and PHY pre-training overrides must be applied during the pre-training table/override phase, while the DMEM write window is enabled. Host MMIO stores to DPHY_BASE + 4 * 0x58000 performed after the pre-training phase completes (for example immediately before setting pwrctl bit 11 in Stage 5) are silently ignored by the hardware (0x58008 and other message words read back their pre-training values after PMU completion).
Immediately before releasing the PMU, the reference sets pwrctl bit 11.
MICRO_CONT_MUX_SEL (0xd0000) to 1, giving the PMU ownership.MICRO_RESET (0xd0099) in the exact order 9, 1, 0. Zero releases execution.0x07. Streaming messages can substantially outnumber major messages and must not block the producer.0xff, follow the error semantics in 08-mailbox-and-streaming.md; do not interpret a PLL-status value as a generic success/failure return.On normal completion, the reference acknowledges 0x07, returns success from its mailbox routine, writes MICRO_RESET=1, performs a short busy wait, and sets the mux to 0.
Recommended: use bounded mailbox waits, a single explicit completion/error result, and the same orderly PMU-stop/host-mux restoration on every exit where hardware permits. Do not proceed to collection or activation after PMU error or timeout.
After the first mailbox routine has completed and host ownership has been restored, the reference applies a second, rate/topology-specific PHY table. The electrical I/O override list is not reapplied in this phase.
The table’s observed terminal state is:
UCCLK_HCLK_ENABLES (0xc0080) = 2;0xd0003 = 0;MICRO_CONT_MUX_SEL = 1.There is no second explicit host mailbox-drain call between this table and result collection. A new implementation must preserve the observed hardware sequencing unless a revised PMU/host protocol is designed and validated as a whole. It must not invent a second training completion event.
The reference collection sequence is:
0x20037 for ACSM capture.0x140 bytes of message data beginning at 0x58000.0x41000.The 5170 values are not a linear CSR dump. They comprise 69 ordered scattered/sequential segments. Their serialization order is part of the quickboot interface and must be treated as a versioned format.
Per-controller saved layout:
| Saved offset | Component | Size |
|---|---|---|
0x0000 |
Complete message block | 0x140 bytes |
0x0140 |
Serialized PHY parameters | 5170 halfwords = 0x2864 bytes |
0x29a4 |
ACSM SRAM | 4096 halfwords = 0x2000 bytes |
| Total | 0x49a4 bytes |
The reference stores two such results consecutively. Persist a result only after all components and the configuration identity have been validated. Do not publish a partially collected result as quickboot-valid.
swctl/swstat transactions, change dfimisc to 0x00010034 and wait for dfistat bit 0.dfimisc to 0x00010015.pwrctl and wait for stat[1:0] == 01.zqctl0=0, zqctl2=0, rfshctl0=0 in the reference), with the required configuration transactions.pwrctl=0x10 to disable self-refresh, restore the operational DFI update timing, and clear opctrl1.0x20090, 0x21090, 0x22090, 0x23090, and 0x24090.Only after these steps is the DRAM array available for normal CPU accesses.
The reference smoke test operates on 0x4000-byte blocks with address-derived patterns and their complements. Required behavior is:
This host-side test is distinct from PMU training. Passing it does not prove adequate training margin, and PMU completion alone does not prove end-to-end addressing works.
The following are recommendations, not claims about the reference:
0xff, CsTestFail, collection failure, and memory-test failure.0xff, while one caller compares that value to 0xff; quickboot ignores the return. This inconsistency is observed behavior, not a contract to reproduce.For scale only, observed reference-board full-training times were about 5.6–5.8 seconds, versus about 9 ms for quickboot. These are measurements, not timeout limits.
SequenceCtrl = 1)When bringing up a new host loader or an initial PMU firmware build, the infrastructure (clock lock, DDRC setup, IMEM/DMEM loading, mailbox handshake, result collection, and DFI activation) can be validated before enabling full 1D/2D eye sweeps by configuring:
SequenceCtrl = 0x0001 (DevInit only);Quickboot = 0;HdtCtrl = 0xff (suppresses verbose streaming messages so mailbox completion is immediate).In this minimal mode:
DevInit) using the default/pre-training table delays and emits major completion 0x07 without running multi-second per-lane read/write eye sweeps.SequenceCtrl = 1 without valid saved training parameters (phypara + ACSM) leaves per-lane delays uncalibrated. Even if DRAM responds to basic reads/writes at nominal room temperature, this mode must not be persisted as a valid DDRT training envelope and is not a substitute for full training (the complete stage mask selected by the host table) or a validated quickboot restore.CFG+0x1c[0]), DDRC timing/address-map configuration (swctl/swstat), and PHY table/message-block loading without releasing the PMU. Read back DMEM 0x58000–0x5809f while MICRO_CONT_MUX_SEL = 0 to verify byte-for-byte alignment.DevInit (SequenceCtrl = 1): Enable MICRO_CONT_MUX_SEL = 1, release MICRO_RESET = 9, 1, 0, service the mailbox to 0x07, restore MICRO_CONT_MUX_SEL = 0, and activate DFI (stat[1:0] == 01).0x49a4 bytes) and smoke test: Implement the 69-segment phypara serializer (5170 halfwords) and ACSM readout (4096 halfwords), enable host ports 0x20090–0x24090, and run the non-destructive 0x4000-byte memory smoke test.SequenceCtrl stage mask from the host table): Enable all training stages, verify non-zero trained VREF/margin outputs on both controllers, and measure execution time (~5.6 s on reference hardware).0x9800-byte DDRT envelope only after both controllers pass the smoke test, then verify quickboot restoration (~9 ms).byte_addr = DPHY_BASE + 4 * index).MICRO_CONT_MUX_SEL == 1: When the PMU owns the mux, the host must access only the mailbox registers (0xd0004, 0xd0031, 0xd0032, 0xd0034, 0xd0099).0xdeadbeef literally to a PHY CSR: In topology override tables, 0xdeadbeef is a skip sentinel, not a register value.DPHY_BASE + 4 * index, modifying a single byte in the message block requires packing both the low and high bytes of that halfword.phypara segments: Quickboot expects the exact 5170-halfword sequence defined in appendix-phypara-order.md.0x41000) to DMEM (0x58200) during quickboot: phypara restores to 0x58200 before PMU execution; ACSM restores to 0x41000 after the PMU stops and 0x20037 bit 6 is cleared.0xff mailbox return value as a direct status code: Read and propagate 0x000000ff explicitly rather than returning raw PLL status (0x200c9).0x20090–0x24090) before stat[1:0] == 01 and self-refresh exit: Causes immediate bus hangs when the CPU touches DRAM.DDRT envelope before both controllers pass the memory smoke test: Locks the board into a broken quickboot state on the next reboot.0xcb800000/0xcc800000 from Linux (/dev/mem): Immediately wedges the SoC interconnect once the OS is running.0x58000–0x580ff) after the pre-training table phase has closed: Late host MMIO stores to DMEM before pwrctl bit 11 are discarded by the hardware; apply all message-block overrides inside the pre-training override table or before closing the pre-training load sequence.