From: Przemyslaw Marczak Date: Thu, 18 Sep 2014 14:20:29 +0000 (+0200) Subject: samsung:board: dram_init(): alloc memory to store fdt dram info X-Git-Tag: submit/tizen_common/20141030.153846~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4443070f8ce408cffe9097e5dd085096adacb51;p=platform%2Fkernel%2Fu-boot.git samsung:board: dram_init(): alloc memory to store fdt dram info For CONFIG_OF_MULTI the dram_init() function gets memory information from the device tree blob by the call to fdtdec_decode_memory(). The same is done second time in dram_init_banksize() - this was the simplest because board info structure is not initialized at dram_init() stage. This change uses malloc and gd->priv pointer to store the memory banks parameters and next uses it in dram_init_banksize(). Thanks to this change, the boot time decreases, because, the function fdtdec_decode_memory() is called only once. Change-Id: I8f357c6a641d4440f32d2fe24d7e1e2dc5bc4a3d Signed-off-by: Przemyslaw Marczak --- diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c index dc729d529e..dce519081f 100644 --- a/board/samsung/common/board.c +++ b/board/samsung/common/board.c @@ -21,10 +21,12 @@ #include #include #include +#include #include #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -97,16 +99,19 @@ int dram_init(void) { int i; #ifdef CONFIG_FDTDEC_MEMORY - int dram_banks; + struct memory_info *mem; - uint64_t mem_size[CONFIG_NR_DRAM_BANKS]; + mem = malloc(sizeof(struct memory_info)); - dram_banks = fdtdec_decode_memory(gd->fdt_blob, NULL, mem_size, + mem->banks = fdtdec_decode_memory(gd->fdt_blob, &mem->addr[0], + &mem->size[0], CONFIG_NR_DRAM_BANKS); - for (i = 0; i < dram_banks; i++) - gd->ram_size += (uint32_t)mem_size[i]; + for (i = 0; i < mem->banks; i++) + gd->ram_size += (uint32_t)mem->size[i]; + /* Save the mem_info for dram_init_banksize() */ + gd->priv = mem; #else u32 addr; @@ -122,17 +127,11 @@ void dram_init_banksize(void) { int i; #ifdef CONFIG_FDTDEC_MEMORY - int dram_banks; + struct memory_info *mem = gd->priv; - uint64_t mem_addr[CONFIG_NR_DRAM_BANKS]; - uint64_t mem_size[CONFIG_NR_DRAM_BANKS]; - - dram_banks = fdtdec_decode_memory(gd->fdt_blob, mem_addr, mem_size, - CONFIG_NR_DRAM_BANKS); - - for (i = 0; i < dram_banks; i++) { - gd->bd->bi_dram[i].start = (uint32_t)mem_addr[i]; - gd->bd->bi_dram[i].size = (uint32_t)mem_size[i]; + for (i = 0; i < mem->banks ; i++) { + gd->bd->bi_dram[i].start = (uint32_t)mem->addr[i]; + gd->bd->bi_dram[i].size = (uint32_t)mem->size[i]; } #else u32 addr, size; diff --git a/include/samsung/multi-plat.h b/include/samsung/multi-plat.h new file mode 100644 index 0000000000..29f5f503bd --- /dev/null +++ b/include/samsung/multi-plat.h @@ -0,0 +1,13 @@ +#ifndef __INCLUDE__MULTI_PLAT__H__ +#define __INCLUDE__MULTI_PLAT__H__ + +#include + +#ifdef CONFIG_OF_MULTI +struct memory_info { + uint64_t addr[CONFIG_NR_DRAM_BANKS]; + uint64_t size[CONFIG_NR_DRAM_BANKS]; + uint32_t banks; +}; +#endif +#endif \ No newline at end of file