diff options
| author | Markus Stockhausen | 2025-12-30 09:33:32 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2025-12-31 20:55:32 +0000 |
| commit | 88e79af543cd0da4357b4327c694375c9b9610c6 (patch) | |
| tree | 6009ef971fae44ef6264fe6224b3e03c93bd5161 | |
| parent | 833757342206ebae4860b09b2ab4efb2344bbe21 (diff) | |
| download | openwrt-88e79af543cd0da4357b4327c694375c9b9610c6.tar.gz | |
realtek: determine memory size during initialization
For proper highmem initialization on RTL930x the size of the
installed memory is needed during early bootup. Enhance the
soc_info structure and fill the data from the registers.
While we are here remove the obsolete compatible variable from
the soc_info structure.
Adapt boot message to show the memory size.
old: SoC Type: Realtek RTL9301 rev B (6487)
new: Realtek RTL9301 rev B (6487) SoC with 512 MB
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21327
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | target/linux/realtek/files-6.12/arch/mips/include/asm/mach-rtl838x/mach-rtl83xx.h | 2 | ||||
| -rw-r--r-- | target/linux/realtek/files-6.12/arch/mips/rtl838x/prom.c | 26 |
2 files changed, 26 insertions, 2 deletions
diff --git a/target/linux/realtek/files-6.12/arch/mips/include/asm/mach-rtl838x/mach-rtl83xx.h b/target/linux/realtek/files-6.12/arch/mips/include/asm/mach-rtl838x/mach-rtl83xx.h index 0a98399591..8639661a94 100644 --- a/target/linux/realtek/files-6.12/arch/mips/include/asm/mach-rtl838x/mach-rtl83xx.h +++ b/target/linux/realtek/files-6.12/arch/mips/include/asm/mach-rtl838x/mach-rtl83xx.h @@ -48,8 +48,8 @@ struct rtl83xx_soc_info { unsigned int revision; unsigned int cpu; bool testchip; - unsigned char *compatible; int cpu_port; + int memory_size; }; #endif /* _MACH_RTL838X_H_ */ diff --git a/target/linux/realtek/files-6.12/arch/mips/rtl838x/prom.c b/target/linux/realtek/files-6.12/arch/mips/rtl838x/prom.c index 94d659913c..f8c13ee49f 100644 --- a/target/linux/realtek/files-6.12/arch/mips/rtl838x/prom.c +++ b/target/linux/realtek/files-6.12/arch/mips/rtl838x/prom.c @@ -17,6 +17,13 @@ #include <mach-rtl83xx.h> +#define RTL_SOC_BASE ((volatile void *) 0xB8000000) +#define RTL83XX_DRAM_CONFIG 0x1004 +#define RTL931X_DRAM_CONFIG 0x14304c + +#define soc_r32(reg) readl(RTL_SOC_BASE + reg) +#define soc_w32(val, reg) writel(val, RTL_SOC_BASE + reg) + struct rtl83xx_soc_info soc_info; const void *fdt; @@ -228,14 +235,31 @@ static void __init set_system_type(void) soc_info.name, es, revision, soc_info.cpu); } +static void get_system_memory(void) +{ + unsigned int dcr, bits; + + if (soc_info.family == RTL9310_FAMILY_ID) { + dcr = soc_r32(RTL931X_DRAM_CONFIG); + bits = (dcr >> 12) + ((dcr >> 6) & 0x3f) + (dcr & 0x3f); + } else { + dcr = soc_r32(RTL83XX_DRAM_CONFIG); + bits = ((dcr >> 28) & 0x3) + ((dcr >> 24) & 0x3) + + ((dcr >> 20) & 0xf) + ((dcr >> 16) & 0xf) + 20; + } + + soc_info.memory_size = 1 << bits; +} + void __init prom_init(void) { u32 model = read_model(); parse_model(model); set_system_type(); + get_system_memory(); - pr_info("SoC Type: %s\n", get_system_type()); + pr_info("%s SoC with %d MB\n", get_system_type(), soc_info.memory_size >> 20); /* * fw_arg2 is be the pointer to the environment. Some devices (e.g. HP JG924A) hand |