Skip to content

Commit 6b2e7ff

Browse files
plappermaulhauke
authored andcommitted
realtek: RTL930x: setup highmem registers during init
For some reason the highmem configuration of RTL930x devices was totally missed until now. Take over the setup from the SDK. This will avoid boot stalls on switches with more than 256 MB RAM when switching over to kernel 6.18. Signed-off-by: Markus Stockhausen <[email protected]> Link: openwrt/openwrt#21327 Signed-off-by: Hauke Mehrtens <[email protected]>
1 parent 88e79af commit 6b2e7ff

File tree

1 file changed

+48
-0
lines changed
  • target/linux/realtek/files-6.12/arch/mips/rtl838x

1 file changed

+48
-0
lines changed

target/linux/realtek/files-6.12/arch/mips/rtl838x/prom.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@
1818
#include <mach-rtl83xx.h>
1919

2020
#define RTL_SOC_BASE ((volatile void *) 0xB8000000)
21+
2122
#define RTL83XX_DRAM_CONFIG 0x1004
23+
24+
#define RTL9300_SRAMSAR0 0x4000
25+
#define RTL9300_SRAMSAR1 0x4010
26+
#define RTL9300_SRAMSAR2 0x4020
27+
#define RTL9300_SRAMSAR3 0x4030
28+
#define RTL9300_UMSAR0 0x1300
29+
#define RTL9300_UMSAR1 0x1310
30+
#define RTL9300_UMSAR2 0x1320
31+
#define RTL9300_UMSAR3 0x1330
32+
#define RTL9300_O0DOR2 0x4220
33+
#define RTL9300_O0DMAR2 0x4224
34+
2235
#define RTL931X_DRAM_CONFIG 0x14304c
2336

2437
#define soc_r32(reg) readl(RTL_SOC_BASE + reg)
@@ -251,6 +264,39 @@ static void get_system_memory(void)
251264
soc_info.memory_size = 1 << bits;
252265
}
253266

267+
static void prepare_highmem(void)
268+
{
269+
if ((soc_info.family != RTL9300_FAMILY_ID) ||
270+
(soc_info.memory_size <= 256 * 1024 * 1024) ||
271+
!IS_ENABLED(CONFIG_HIGHMEM))
272+
return;
273+
274+
/*
275+
* To use highmem on RTL930x, SRAM must be deactivated and the highmem mapping
276+
* registers must be setup properly. The hardcoded 0x70000000 might be strange
277+
* but at least it conforms somehow to the RTL931x devices.
278+
*
279+
* - RTL930x: highmem start 0x20000000 + offset 0x70000000 = 0x90000000
280+
* - RTL931x: highmem start 0x90000000 + no offset at all = 0x90000000
281+
*/
282+
283+
pr_info("highmem kernel on RTL930x with > 256 MB RAM, adapt SoC memory mapping\n");
284+
285+
soc_w32(0, RTL9300_UMSAR0);
286+
soc_w32(0, RTL9300_UMSAR1);
287+
soc_w32(0, RTL9300_UMSAR2);
288+
soc_w32(0, RTL9300_UMSAR3);
289+
soc_w32(0, RTL9300_SRAMSAR0);
290+
soc_w32(0, RTL9300_SRAMSAR1);
291+
soc_w32(0, RTL9300_SRAMSAR2);
292+
soc_w32(0, RTL9300_SRAMSAR3);
293+
__sync();
294+
295+
soc_w32(0x70000000, RTL9300_O0DOR2);
296+
soc_w32(0x7fffffff, RTL9300_O0DMAR2);
297+
__sync();
298+
}
299+
254300
void __init prom_init(void)
255301
{
256302
u32 model = read_model();
@@ -261,6 +307,8 @@ void __init prom_init(void)
261307

262308
pr_info("%s SoC with %d MB\n", get_system_type(), soc_info.memory_size >> 20);
263309

310+
prepare_highmem();
311+
264312
/*
265313
* fw_arg2 is be the pointer to the environment. Some devices (e.g. HP JG924A) hand
266314
* over other than expected kernel boot arguments. Something like 0xfffdffff looks

0 commit comments

Comments
 (0)