Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Nobuhiro Iwamatsu | a541344 | 2014-12-02 16:52:20 +0900 | [diff] [blame] | 2 | /* |
Nobuhiro Iwamatsu | 8040395 | 2016-04-01 03:51:33 +0900 | [diff] [blame] | 3 | * board/renesas/rcar-common/common.c |
Nobuhiro Iwamatsu | a541344 | 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 | 4dc515a | 2016-04-01 03:51:34 +0900 | [diff] [blame] | 7 | * Copyright (C) 2015 Nobuhiro Iwamatsu <iwamatsu@nigauri.org> |
Nobuhiro Iwamatsu | a541344 | 2014-12-02 16:52:20 +0900 | [diff] [blame] | 8 | */ |
| 9 | |
Marek Vasut | 45eaf05 | 2019-07-09 01:46:35 +0200 | [diff] [blame] | 10 | #include <dm.h> |
Geert Uytterhoeven | af90acf | 2022-03-29 14:19:08 +0200 | [diff] [blame] | 11 | #include <fdt_support.h> |
Marek Vasut | 78cea93 | 2023-05-31 20:10:28 +0200 | [diff] [blame] | 12 | #include <hang.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 13 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 14 | #include <asm/global_data.h> |
Marek Vasut | 78cea93 | 2023-05-31 20:10:28 +0200 | [diff] [blame] | 15 | #include <asm/io.h> |
Marek Vasut | 45eaf05 | 2019-07-09 01:46:35 +0200 | [diff] [blame] | 16 | #include <dm/uclass-internal.h> |
Marek Vasut | 97a070b | 2024-02-27 17:05:54 +0100 | [diff] [blame] | 17 | #include <asm/arch/renesas.h> |
Marek Vasut | 1d60fee | 2024-12-21 22:46:36 +0100 | [diff] [blame] | 18 | #include <asm/system.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 19 | #include <linux/libfdt.h> |
Marek Vasut | 276a1d8 | 2019-05-19 23:25:16 +0200 | [diff] [blame] | 20 | |
Hai Pham | 9046b5f | 2023-02-28 22:22:03 +0100 | [diff] [blame] | 21 | #ifdef CONFIG_RCAR_64 |
Marek Vasut | 276a1d8 | 2019-05-19 23:25:16 +0200 | [diff] [blame] | 22 | |
| 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
Marek Vasut | da8646a | 2020-04-11 20:50:24 +0200 | [diff] [blame] | 25 | int dram_init(void) |
Marek Vasut | 276a1d8 | 2019-05-19 23:25:16 +0200 | [diff] [blame] | 26 | { |
Marek Vasut | 1d60fee | 2024-12-21 22:46:36 +0100 | [diff] [blame] | 27 | int ret = fdtdec_setup_mem_size_base(); |
| 28 | |
| 29 | if (current_el() == 3 && gd->ram_base == 0x48000000) { |
| 30 | /* |
| 31 | * If this U-Boot runs in EL3, make the bottom 128 MiB |
| 32 | * available for loading of follow up firmware blobs. |
| 33 | */ |
| 34 | gd->ram_base -= 0x8000000; |
| 35 | gd->ram_size += 0x8000000; |
| 36 | } |
| 37 | |
| 38 | return ret; |
Marek Vasut | da8646a | 2020-04-11 20:50:24 +0200 | [diff] [blame] | 39 | } |
Marek Vasut | 276a1d8 | 2019-05-19 23:25:16 +0200 | [diff] [blame] | 40 | |
Marek Vasut | da8646a | 2020-04-11 20:50:24 +0200 | [diff] [blame] | 41 | int dram_init_banksize(void) |
| 42 | { |
Marek Vasut | 1d60fee | 2024-12-21 22:46:36 +0100 | [diff] [blame] | 43 | int bank; |
| 44 | |
Michal Simek | c7ac6ac | 2020-07-10 13:16:48 +0200 | [diff] [blame] | 45 | fdtdec_setup_memory_banksize(); |
Marek Vasut | 276a1d8 | 2019-05-19 23:25:16 +0200 | [diff] [blame] | 46 | |
Marek Vasut | 1d60fee | 2024-12-21 22:46:36 +0100 | [diff] [blame] | 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 | |
Marek Vasut | 276a1d8 | 2019-05-19 23:25:16 +0200 | [diff] [blame] | 63 | return 0; |
| 64 | } |
Marek Vasut | ce52852 | 2021-04-03 16:58:49 +0200 | [diff] [blame] | 65 | |
Marek Vasut | 9c6ad45 | 2023-05-31 20:33:04 +0200 | [diff] [blame] | 66 | int __weak board_init(void) |
| 67 | { |
| 68 | return 0; |
| 69 | } |
Marek Vasut | 78cea93 | 2023-05-31 20:10:28 +0200 | [diff] [blame] | 70 | |
Marek Vasut | 276a1d8 | 2019-05-19 23:25:16 +0200 | [diff] [blame] | 71 | #endif |