Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Nobuhiro Iwamatsu | 72fd383 | 2014-12-02 16:52:20 +0900 | [diff] [blame] | 2 | /* |
Nobuhiro Iwamatsu | a7da6f8 | 2016-04-01 03:51:33 +0900 | [diff] [blame] | 3 | * board/renesas/rcar-common/common.c |
Nobuhiro Iwamatsu | 72fd383 | 2014-12-02 16:52:20 +0900 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2013 Renesas Electronics Corporation |
| 6 | * Copyright (C) 2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> |
Nobuhiro Iwamatsu | 581183d | 2016-04-01 03:51:34 +0900 | [diff] [blame] | 7 | * Copyright (C) 2015 Nobuhiro Iwamatsu <iwamatsu@nigauri.org> |
Nobuhiro Iwamatsu | 72fd383 | 2014-12-02 16:52:20 +0900 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Nobuhiro Iwamatsu | 72fd383 | 2014-12-02 16:52:20 +0900 | [diff] [blame] | 11 | #include <asm/arch/rmobile.h> |
Marek Vasut | 6ef540d | 2019-05-19 23:25:16 +0200 | [diff] [blame^] | 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 |