Mode registers

DRAM mode registers are read and written through the MC CA_CMD port (ddr+0x24), with the result of a read appearing in MR_DATA (ddr+0x370). The protocol and encodings live in src/lib/k1_ddr_init.c, src/lib/k1_ddrt.c and src/lib/k1_ddrt_regs.h.

Read and write

  • Write (MRW): CA_CMD = 0x10020000 | cs_sel << 24 | (mr & 0xff); there is no completion bit, so a fixed delay (tMRW, 1 µs) separates writes. The written value comes from the active timing bank (confirmed on silicon for MR14 via ddr+0x30c and MR11 via ddr+0x310/0x314 in logsRefs/002-indep-vref-edge-16gib/readme.md and logsRefs/043-docsclean-claims-sweep/readme.md).

  • Read (MRR): CA_CMD = 0x10010000 | (cs+1) << 24 | ch << 18 | mr, then wait for MR_DATA bit 31 and take the low byte. MRRs must not be issued in self-refresh ([required], enforced by tools/test/model.c).

The firmware wrappers are k1_ddr_mr_write() and k1_ddrt_mr_read() (Controller bring-up, The training pass).

Registers the boot uses

  • MR5 (manufacturer), MR6, MR8 (density and width — drives the address map, Addressing and address map), MR12, MR11, MR13, MR21, MR22, MR23 are written during Device_Init in two batches around ZQ calibration (k1_mr_init1[] and k1_mr_init2[] in src/lib/k1_ddr_tables.c).

  • MR14 is the write-Vref register centred by write training; the firmware sweeps it (21..36 on LPDDR4X) and leaves the winner. The MC also keeps an MR14 field in CTL_TXVREF[21:16] (ddr+0x30c) that must match what the dies hold; the MR14 check compares them ([measured] across all 4 (cs, ch) pairs in logsRefs/002, 019, 020, 021, The training pass).

  • MR21 (0x95) is written on 16 GiB parts (logsRefs/020-eeprom-cs-num-16gib/readme.md).

Read quirks

Two [measured] quirks matter to the boot (logsRefs/043-docsclean-claims-sweep/readme.md, logsRefs/044-docsclean-claims-sweep-8gib/readme.md):

  • MR13 reads 0x00 on both ranks (CS0 and CS1);

  • the first MRR after a hardware frequency change to fp2 reads 0x00 (followed immediately by the real value 0x19 on the second MRR). The firmware absorbs this with a discarded read after every DFC in k1_boot_dfc() (Boot sequence).