sunxi: H616: dram: fix LPDDR3 mode register settings
authorAndre Przywara <andre.przywara@arm.com>
Sun, 27 Jul 2025 13:04:09 +0000 (14:04 +0100)
committerAndre Przywara <andre.przywara@arm.com>
Tue, 12 Aug 2025 09:44:07 +0000 (10:44 +0100)
commitc453a80cc3b999ad515ed7fcfcf3062e8de1f696
tree8ce13368c1301aee4702cce50682ba594fddb4d0
parent7161a5f6861ee620f97d1c622a2281dfbba6fd4b
sunxi: H616: dram: fix LPDDR3 mode register settings

The JEDEC LPDDR3 spec defines mode register 0 (MR0) as being read-only,
so there is no point in trying to set its value.
Also the H616 memory controller encodes the mode register index to be
written starting from bit 8 in MRCTRL1 (for LPDDR3 and LPDDR4 chips), so
we need to OR in that number to tell the controller which MR to program.

On top of that, the mode registers between DDR3 and LPDDR3 are
completely different, so writing values crafted for DDR3 into a LPDDR3
chip is just wrong. Due to the above mentioned bugs the writes for
MR0-MR2 did not have any effect (as they were all trying to set the
read-only MR0), so the mode registers just stayed unchanged.

Looking at the LPDDR3 spec and the BSP code, let's write the proper MR
values into LPDDR3 chips, using the proper addressing mode.
Use the opportunity to document the LPDDR3 mode register bits written.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
arch/arm/mach-sunxi/dram_sun50i_h616.c