Skip to content

Commit 48f5dd5

Browse files
pcercueitsbogend
authored andcommitted
MIPS: ingenic: Hardcode mem size for qi,lb60 board
Old Device Tree for the qi,lb60 (aka. Ben Nanonote) did not have a 'memory' node. The kernel would then read the memory controller registers to know how much RAM was available. Since every other supported board has had a 'memory' node from the beginning, we can just hardcode a RAM size of 32 MiB when running with an old Device Tree without the 'memory' node. Signed-off-by: Paul Cercueil <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 714b649 commit 48f5dd5

File tree

1 file changed

+8
-29
lines changed

1 file changed

+8
-29
lines changed

arch/mips/jz4740/setup.c

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/of_clk.h>
1515
#include <linux/of_fdt.h>
1616
#include <linux/pm.h>
17+
#include <linux/sizes.h>
1718
#include <linux/suspend.h>
1819

1920
#include <asm/bootinfo.h>
@@ -22,31 +23,6 @@
2223
#include <asm/reboot.h>
2324
#include <asm/time.h>
2425

25-
#define JZ4740_EMC_BASE_ADDR 0x13010000
26-
27-
#define JZ4740_EMC_SDRAM_CTRL 0x80
28-
29-
static void __init jz4740_detect_mem(void)
30-
{
31-
void __iomem *jz_emc_base;
32-
u32 ctrl, bus, bank, rows, cols;
33-
phys_addr_t size;
34-
35-
jz_emc_base = ioremap(JZ4740_EMC_BASE_ADDR, 0x100);
36-
ctrl = readl(jz_emc_base + JZ4740_EMC_SDRAM_CTRL);
37-
bus = 2 - ((ctrl >> 31) & 1);
38-
bank = 1 + ((ctrl >> 19) & 1);
39-
cols = 8 + ((ctrl >> 26) & 7);
40-
rows = 11 + ((ctrl >> 20) & 3);
41-
printk(KERN_DEBUG
42-
"SDRAM preconfigured: bus:%u bank:%u rows:%u cols:%u\n",
43-
bus, bank, rows, cols);
44-
iounmap(jz_emc_base);
45-
46-
size = 1 << (bus + bank + cols + rows);
47-
add_memory_region(0, size, BOOT_MEM_RAM);
48-
}
49-
5026
static unsigned long __init get_board_mach_type(const void *fdt)
5127
{
5228
if (!fdt_node_check_compatible(fdt, 0, "ingenic,x2000"))
@@ -68,13 +44,16 @@ static unsigned long __init get_board_mach_type(const void *fdt)
6844
void __init plat_mem_setup(void)
6945
{
7046
void *dtb = (void *)fw_passed_dtb;
71-
int offset;
7247

7348
__dt_setup_arch(dtb);
7449

75-
offset = fdt_path_offset(dtb, "/memory");
76-
if (offset < 0)
77-
jz4740_detect_mem();
50+
/*
51+
* Old devicetree files for the qi,lb60 board did not have a /memory
52+
* node. Hardcode the memory info here.
53+
*/
54+
if (!fdt_node_check_compatible(dtb, 0, "qi,lb60") &&
55+
fdt_path_offset(dtb, "/memory") < 0)
56+
early_init_dt_add_memory_arch(0, SZ_32M);
7857

7958
mips_machtype = get_board_mach_type(dtb);
8059
}

0 commit comments

Comments
 (0)