ramips: lzma-loader: use virtual memory segments for uart base address
authorMichael Pratt <mcpratt@pm.me>
Tue, 5 Dec 2023 23:36:42 +0000 (18:36 -0500)
committerHauke Mehrtens <hauke@hauke-m.de>
Tue, 2 Jan 2024 21:10:34 +0000 (22:10 +0100)
commit4c1e9bd8581e01793b26f3bc964975311450ece0
tree0347fcea2061379e9f8261f0516c90c10b178a1d
parentf393ffcac163926bf9dbbda47c25cc7809952609
ramips: lzma-loader: use virtual memory segments for uart base address

The native bus address for UART was entered for rt305x UART_BASE,
but the bootloaders have memory space remapped with the same
virtual memory map the kernel uses for program addressing at boot time.

In UBoot, the remapped address is often defined as TEXT_BASE.
In the kernel, for rt305x this remapped address is RT305X_SYSC_BASE.
(arch/mips/include/asm/mach-ralink/rt305x.h)

Because the ralink I/O busses begin at a low address of 0x10000000,
they are remapped using KSEG0 or KSEG1, which for all 32-bit MIPS SOCs
(arch/mips/include/asm/addrspace.h)
are offsets of 0x80000000 and 0xa0000000 respectively.
This is consistent with the other UART_BASE macros here
and with MIPS memory map documentation.

Before the recent rework of the lzma-loader for ramips,
the original board-$(PLATFORM).c files also did not
use KSEG1ADDR for UART_BASE despite being defined,
which made this mistake easier to occur.

Fix this by defining KSEG1ADDR again and actually use it.
Copy and paste from the kernel's macros for consistency.

Link: https://training.mips.com/basic_mips/PDF/Memory_Map.pdf
Fixes: c31319b66 ("ramips: lzma-loader: Refactor loader")
Reported-by: Lech Perczak <lech.perczak@gmail.com>
Signed-off-by: Michael Pratt <mcpratt@pm.me>
target/linux/ramips/image/lzma-loader/src/board.c