SpacemiT_K1_DDR

← Previous: Clocks, PLLs and the PMU Index Next: Device_Init →

Memory Controller (MC)

Base: ddr = 0xc0000000. The MC does not compute delays. For the boot it is a set of command ports plus configuration storage:

Command word format

The command registers share one layout (inferred from every command used by the boot; all observed commands fit it):

 31   28 27 26 25 24 23                                 0
+-------+-----+-------+------------------------------------+
| 0001  |  0  |CS mask|            command payload         |
+-------+-----+-------+------------------------------------+

So 0x13… addresses both ranks, 0x11… CS0 only and 0x12… CS1 only.

USER_0 (ddr+0x20): DRAM sequencing

Command Word (both ranks) Effect
DRAM init 0x10000001 \| (cs_sel << 24) JEDEC power-up sequence (RESET_n, CKE, tINIT1..5) performed by the MC
Self-refresh enter 0x10000040 \| (mask << 24) → 0x13000040 Puts the selected ranks in SR
Self-refresh exit 0x10000080 \| (mask << 24) → 0x13000080 Takes them out
ZQCAL START, CS0 0x11002000 MPC ZQCAL start
ZQCAL LATCH, CS0 0x11001000 MPC ZQCAL latch
ZQCAL START / LATCH, CS1 0x12002000 / 0x12001000  
FSP-WR request 0x13000008 Toggles the FSP being written, driven from the PMU side; only used inside the DFC flow
FSP-OP request 0x13000004 Switches the operating FSP; only used inside the DFC flow
(DFC flow) 0x13000010 Used by the DFC flows; meaning opaque

ZQCAL is an MPC that goes through USER_0, not through CA_CMD. No completion bit exists for ZQCAL or for the FSP requests; see device-init.md for the delays.

Do not issue the FSP requests by hand after a DFC: 0x13000008 after a frequency change flips FSP-WR away from the set that mode-register reads observe.

CA_CMD / USER_1 (ddr+0x24): mode registers

CA_CMD = 0x10000000 | (cs_mask << 24) | (ch << 18) | (op << 16) | mr
         op = 1: MRR (read)    op = 2: MRW (write)
         ch = JEDEC channel 0/1 (read only)
         mr = mode-register number, [7:0]

Full protocol in mode-registers.md.

MISC (ddr+0x28): CA port on/off

Not a static configuration register but a command port:

Word Effect
0x13010000 CA on
0x13008000 CA off

The LPDDR4X training does not write it. The DFC flows write both values (DRAM out of self-refresh). After Device_Init it reads 0 on the reference board.

STATUS (ddr+0x08)

Per-rank status bits, in pairs CS0/CS1:

Bit Rank Meaning
0 / 4 CS0 / CS1 DRAM init done
1 / 5 CS0 / CS1 CKE / active (inferred)
2 / 6 CS0 / CS1 In self-refresh

Typical values: 0x33 after Device_Init (ranks up, not in SR), 0x77 in training SR, 0x11 after the training SR exit. The bits are not W1C; they change only with USER_0 commands and with the MC reset. Full semantics in self-refresh.md.

CTL0 (ddr+0x44)

Global control word. Device_Init writes 0x00040300. The DFC flows write other variants (0x00040303, 0x00040380, 0x00040b43, 0x00040b00), and the DFC snapshot header uses CTL0 | (1 << 2) | (1 << 12). Bit meanings are opaque. ddr+0x44 holding a written value is the simplest check that the MC clock is running.

CTL_FREQ (ddr+0x304): frequency point and bank select

[31:30]  fp: active frequency point AND the timing bank that register
         accesses go to
[29:28]  sel: frequency select (equal to fp in the normal boot)
[27:0]   0x0800400 on the reference board (opaque, preserve)
fp CTL_FREQ
0 0x00800400
1 0x50800400
2 0xa0800400
3 0xf0800400

Software writes CTL_FREQ only while filling the banks during Device_Init (and while building the DFC snapshot). In the normal boot the HW-DFC engine updates it; the training never writes it. The CA-training path is the exception: there software writes [29:28] itself (ca-training.md).

PI_CFG (ddr+0x13e0)

[3:2] = active fp (observed values 0, 4, 8 for fp0, fp1, fp2). Written by Device_Init (|= fp << 2 with fp = 0) and maintained by the DFC. The training must not write it: doing so races with the DFC.

Timing banks

The MC keeps one copy of every frequency-dependent register per frequency point. Writing CTL_FREQ[31:30] = fp selects the copy that subsequent register reads and writes access. Device_Init fills all four banks (including fp3 on LPDDR4X). Frequency changes only select a bank; they never rewrite it.

The list of banked and global registers follows from the DFC snapshot layout (dfc-engine.md):

Values are in device-init.md.

Other registers

Offset Role
0x70 / 0x74 / 0x78 DFC table port: INDEX / DATA / ADDR. Filled through the 0xf0000000 window (dfc-engine.md).
0x148 Written 0x80ac0000 before every HW-DFC. Not touched by Device_Init. Opaque.
0x200–0x224 Address map (address-map.md)
0x370 MR_DATA (mode-registers.md)
0x13d0 PI_CMD; also the DFI init_start command port (device-init.md, pi-training-engine.md)
0x13e8–0x13fc PI configuration and status (pi-training-engine.md)

Gaps


← Previous: Clocks, PLLs and the PMU Index Next: Device_Init →