Jerome Brunet | 33e3378 | 2018-10-05 17:00:37 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) Copyright 2016 Beniamino Galvani <b.galvani@gmail.com> |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <linux/libfdt.h> |
| 8 | #include <linux/err.h> |
| 9 | #include <asm/arch/mem.h> |
| 10 | #include <asm/arch/sm.h> |
| 11 | #include <asm/armv8/mmu.h> |
| 12 | #include <asm/unaligned.h> |
| 13 | #include <efi_loader.h> |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | int dram_init(void) |
| 18 | { |
| 19 | const fdt64_t *val; |
| 20 | int offset; |
| 21 | int len; |
| 22 | |
| 23 | offset = fdt_path_offset(gd->fdt_blob, "/memory"); |
| 24 | if (offset < 0) |
| 25 | return -EINVAL; |
| 26 | |
| 27 | val = fdt_getprop(gd->fdt_blob, offset, "reg", &len); |
| 28 | if (len < sizeof(*val) * 2) |
| 29 | return -EINVAL; |
| 30 | |
| 31 | /* Use unaligned access since cache is still disabled */ |
| 32 | gd->ram_size = get_unaligned_be64(&val[1]); |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | void meson_board_add_reserved_memory(void *fdt, u64 start, u64 size) |
| 38 | { |
| 39 | int ret; |
| 40 | |
| 41 | ret = fdt_add_mem_rsv(fdt, start, size); |
| 42 | if (ret) |
| 43 | printf("Could not reserve zone @ 0x%llx\n", start); |
| 44 | |
| 45 | if (IS_ENABLED(CONFIG_EFI_LOADER)) { |
| 46 | efi_add_memory_map(start, |
| 47 | ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT, |
| 48 | EFI_RESERVED_MEMORY_TYPE, false); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | void reset_cpu(ulong addr) |
| 53 | { |
| 54 | psci_system_reset(); |
| 55 | } |