blob: 292867e496c461870b6f299919b3c03727fca470 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Nobuhiro Iwamatsu72fd3832014-12-02 16:52:20 +09002/*
Nobuhiro Iwamatsua7da6f82016-04-01 03:51:33 +09003 * board/renesas/rcar-common/common.c
Nobuhiro Iwamatsu72fd3832014-12-02 16:52:20 +09004 *
5 * Copyright (C) 2013 Renesas Electronics Corporation
6 * Copyright (C) 2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Nobuhiro Iwamatsu581183d2016-04-01 03:51:34 +09007 * Copyright (C) 2015 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Nobuhiro Iwamatsu72fd3832014-12-02 16:52:20 +09008 */
9
10#include <common.h>
Nobuhiro Iwamatsu72fd3832014-12-02 16:52:20 +090011#include <asm/arch/rmobile.h>
Marek Vasut6ef540d2019-05-19 23:25:16 +020012
13#ifdef CONFIG_RCAR_GEN3
14
15DECLARE_GLOBAL_DATA_PTR;
16
17/* If the firmware passed a device tree use it for U-Boot DRAM setup. */
18extern u64 rcar_atf_boot_args[];
19
20int 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
34int 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