sunxi: enable dual rank memory on R40
authorIcenowy Zheng <icenowy@aosc.io>
Thu, 25 Feb 2021 16:13:25 +0000 (00:13 +0800)
committerAndre Przywara <andre.przywara@arm.com>
Fri, 16 Apr 2021 00:12:58 +0000 (01:12 +0100)
commita5ff6f5c72ae26f218f8fa2739a368fcdefca093
tree3aaa815045a660635e5af1ba8066d1a988410d44
parente9dfd8e96031317a837e659ac2aa1a59278c2ce6
sunxi: enable dual rank memory on R40

Previously we do not have proper dual rank memory detection on R40
(because we omitted PIR_QSGATE, which does not work on R40 with our
configuration), and dual rank memory is just simply disabled as early
R40 boards available (Banana Pi M2 Ultra and Berry) have single rank
memory.

As a board with dual rank memory (Forlinx OKA40i-C) is now known to us,
we need to have a way to do memory rank detection to support that board.

Add some routine to detect memory rank by trying to access the memory
in rank 1 and check for error status of the memory controller, and then
enable dual rank memory on R40.

Similar routine can be used to detect half DQ width (which is also
detected by PIR_QSGATE on other SoCs), but it's left unimplemented
because there's no known R40 board with half DQ width now.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
[Andre: Move R40 detect code call into sunxi_dram_init()]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
arch/arm/mach-sunxi/dram_sunxi_dw.c