1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * board/renesas/common/common.c
4  *
5  * Copyright (C) 2013 Renesas Electronics Corporation
6  * Copyright (C) 2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
7  * Copyright (C) 2015 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
8  */
9 
10 #include <dm.h>
11 #include <fdt_support.h>
12 #include <hang.h>
13 #include <init.h>
14 #include <asm/global_data.h>
15 #include <asm/io.h>
16 #include <dm/uclass-internal.h>
17 #include <asm/arch/renesas.h>
18 #include <asm/system.h>
19 #include <linux/libfdt.h>
20 
21 DECLARE_GLOBAL_DATA_PTR;
22 
dram_init(void)23 int dram_init(void)
24 {
25 	int ret = fdtdec_setup_mem_size_base();
26 
27 	if (current_el() == 3 && gd->ram_base == 0x48000000) {
28 		/*
29 		 * If this U-Boot runs in EL3, make the bottom 128 MiB
30 		 * available for loading of follow up firmware blobs.
31 		 */
32 		gd->ram_base -= 0x8000000;
33 		gd->ram_size += 0x8000000;
34 	}
35 
36 	return ret;
37 }
38 
renesas_dram_init_banksize(void)39 __weak void renesas_dram_init_banksize(void) { }
40 
dram_init_banksize(void)41 int dram_init_banksize(void)
42 {
43 	int bank;
44 
45 	fdtdec_setup_memory_banksize();
46 
47 	if (current_el() != 3)
48 		return 0;
49 
50 	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
51 		if (gd->bd->bi_dram[bank].start != 0x48000000)
52 			continue;
53 
54 		/*
55 		 * If this U-Boot runs in EL3, make the bottom 128 MiB
56 		 * available for loading of follow up firmware blobs.
57 		 */
58 		gd->bd->bi_dram[bank].start -= 0x8000000;
59 		gd->bd->bi_dram[bank].size += 0x8000000;
60 		break;
61 	}
62 
63 	renesas_dram_init_banksize();
64 
65 	return 0;
66 }
67 
board_init(void)68 int __weak board_init(void)
69 {
70 	return 0;
71 }
72 
board_early_init_f(void)73 int __weak board_early_init_f(void)
74 {
75 	return 0;
76 }
77