MIPS: ralink: mt7621: add memory detection support
authorChuanhong Guo <gch981213@gmail.com>
Sat, 27 Mar 2021 05:38:40 +0000 (22:38 -0700)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Mon, 29 Mar 2021 09:18:54 +0000 (11:18 +0200)
commit139c949f7f0ac0dd1c0da132675be80e6d76c65d
tree85e70d4b58eff856d28892db0f7274acc1511827
parent8eb6eb4882f2eb3ed516484bdde7db359785b6df
MIPS: ralink: mt7621: add memory detection support

mt7621 has the following memory map:
0x0-0x1c000000: lower 448m memory
0x1c000000-0x2000000: peripheral registers
0x20000000-0x2400000: higher 64m memory

detect_memory_region in arch/mips/kernel/setup.c only adds the first
memory region and isn't suitable for 512m memory detection because
it may accidentally read the memory area for peripheral registers.

This commit adds memory detection capability for mt7621:
  1. Add the highmem area when 512m is detected.
  2. Guard memcmp from accessing peripheral registers:
     This only happens when a user decided to change kernel load address
     to 256m or higher address. Since this is a quite unusual case, we
     just skip 512m testing and return 256m as memory size.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
[Minor commit message reword, make mt7621_memory_detect static]
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/include/asm/mach-ralink/mt7621.h
arch/mips/ralink/common.h
arch/mips/ralink/mt7621.c
arch/mips/ralink/of.c