Merge branch 'master' of git://git.denx.de/u-boot-sh
[platform/kernel/u-boot.git] / board / renesas / rcar-common / common.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * board/renesas/rcar-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 <common.h>
11 #include <asm/arch/rmobile.h>
12
13 #ifdef CONFIG_RCAR_GEN3
14
15 DECLARE_GLOBAL_DATA_PTR;
16
17 /* If the firmware passed a device tree use it for U-Boot DRAM setup. */
18 extern u64 rcar_atf_boot_args[];
19
20 int dram_init(void)
21 {
22         const void *atf_fdt_blob = (const void *)(rcar_atf_boot_args[1]);
23         const void *blob;
24
25         /* Check if ATF passed us DTB. If not, fall back to builtin DTB. */
26         if (fdt_magic(atf_fdt_blob) == FDT_MAGIC)
27                 blob = atf_fdt_blob;
28         else
29                 blob = gd->fdt_blob;
30
31         return fdtdec_setup_mem_size_base_fdt(blob);
32 }
33
34 int dram_init_banksize(void)
35 {
36         const void *atf_fdt_blob = (const void *)(rcar_atf_boot_args[1]);
37         const void *blob;
38
39         /* Check if ATF passed us DTB. If not, fall back to builtin DTB. */
40         if (fdt_magic(atf_fdt_blob) == FDT_MAGIC)
41                 blob = atf_fdt_blob;
42         else
43                 blob = gd->fdt_blob;
44
45         fdtdec_setup_memory_banksize_fdt(blob);
46
47         return 0;
48 }
49 #endif