Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <paul@crapouillou.net>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Paul Cercueil and committed by
Thomas Bogendoerfer
48f5dd56 714b649d

+8 -29
+8 -29
arch/mips/jz4740/setup.c
··· 14 14 #include <linux/of_clk.h> 15 15 #include <linux/of_fdt.h> 16 16 #include <linux/pm.h> 17 + #include <linux/sizes.h> 17 18 #include <linux/suspend.h> 18 19 19 20 #include <asm/bootinfo.h> ··· 22 21 #include <asm/prom.h> 23 22 #include <asm/reboot.h> 24 23 #include <asm/time.h> 25 - 26 - #define JZ4740_EMC_BASE_ADDR 0x13010000 27 - 28 - #define JZ4740_EMC_SDRAM_CTRL 0x80 29 - 30 - static void __init jz4740_detect_mem(void) 31 - { 32 - void __iomem *jz_emc_base; 33 - u32 ctrl, bus, bank, rows, cols; 34 - phys_addr_t size; 35 - 36 - jz_emc_base = ioremap(JZ4740_EMC_BASE_ADDR, 0x100); 37 - ctrl = readl(jz_emc_base + JZ4740_EMC_SDRAM_CTRL); 38 - bus = 2 - ((ctrl >> 31) & 1); 39 - bank = 1 + ((ctrl >> 19) & 1); 40 - cols = 8 + ((ctrl >> 26) & 7); 41 - rows = 11 + ((ctrl >> 20) & 3); 42 - printk(KERN_DEBUG 43 - "SDRAM preconfigured: bus:%u bank:%u rows:%u cols:%u\n", 44 - bus, bank, rows, cols); 45 - iounmap(jz_emc_base); 46 - 47 - size = 1 << (bus + bank + cols + rows); 48 - add_memory_region(0, size, BOOT_MEM_RAM); 49 - } 50 24 51 25 static unsigned long __init get_board_mach_type(const void *fdt) 52 26 { ··· 44 68 void __init plat_mem_setup(void) 45 69 { 46 70 void *dtb = (void *)fw_passed_dtb; 47 - int offset; 48 71 49 72 __dt_setup_arch(dtb); 50 73 51 - offset = fdt_path_offset(dtb, "/memory"); 52 - if (offset < 0) 53 - jz4740_detect_mem(); 74 + /* 75 + * Old devicetree files for the qi,lb60 board did not have a /memory 76 + * node. Hardcode the memory info here. 77 + */ 78 + if (!fdt_node_check_compatible(dtb, 0, "qi,lb60") && 79 + fdt_path_offset(dtb, "/memory") < 0) 80 + early_init_dt_add_memory_arch(0, SZ_32M); 54 81 55 82 mips_machtype = get_board_mach_type(dtb); 56 83 }