Skip to content

Commit

Permalink
ARM: sun4i: honor memory information passed by the bootloader
Browse files Browse the repository at this point in the history
unless CONFIG_SUNXI_IGNORE_ATAG_MEM is set
  • Loading branch information
amery committed Jul 15, 2012
1 parent 5bba4fb commit 5b47d67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions arch/arm/mach-sun4i/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ config SW_DEBUG_UART
Choose the UART on which kernel low-level debug messages should be
output.

config SUNXI_IGNORE_ATAG_MEM
bool "Use AllWinner's hack to assume memory size"
default n
endif
21 changes: 15 additions & 6 deletions arch/arm/mach-sun4i/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void __init sw_core_map_io(void)
iotable_init(sw_io_desc, ARRAY_SIZE(sw_io_desc));
}

#ifdef CONFIG_SUNXI_IGNORE_ATAG_MEM
static u32 DRAMC_get_dram_size(void)
{
u32 reg_val;
Expand Down Expand Up @@ -107,16 +108,17 @@ static u32 DRAMC_get_dram_size(void)

return dram_size;
}
#endif

static void __init sw_core_fixup(struct tag *tags, char **cmdline,
static void __init sw_core_fixup(struct tag *t, char **cmdline,
struct meminfo *mi)
{
u32 size;
u32 size = 0;
int banks = 0;

#ifdef CONFIG_SUNXI_IGNORE_ATAG_MEM
size = DRAMC_get_dram_size();

early_printk("DRAM: %d", size);

if (size <= 512) {
mi->nr_banks = 1;
mi->bank[0].start = 0x40000000;
Expand All @@ -128,8 +130,15 @@ static void __init sw_core_fixup(struct tag *tags, char **cmdline,
mi->bank[1].start = 0x60000000;
mi->bank[1].size = SZ_1M * (size - 512);
}

pr_info("Total Detected Memory: %uMB with %d banks\n", size, mi->nr_banks);
banks = mi->nr_banks;
#else
for (; t->hdr.size; t = tag_next(t)) if (t->hdr.tag == ATAG_MEM) {
size += t->u.mem.size / SZ_1M;
if (banks++ == 0)
t->u.mem.size -= 64 * SZ_1M;
}
#endif
pr_info("Total Detected Memory: %uMB with %d banks\n", size, banks);
}

/* Only reserve certain important memory blocks if there are actually
Expand Down

0 comments on commit 5b47d67

Please sign in to comment.