Simon Glass | 6caa195 | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013, Google Inc. |
| 3 | * |
| 4 | * Copyright (C) 2011 |
| 5 | * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> |
| 6 | * - Added prep subcommand support |
| 7 | * - Reorganized source - modeled after powerpc version |
| 8 | * |
| 9 | * (C) Copyright 2002 |
| 10 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 11 | * Marius Groeger <mgroeger@sysgo.de> |
| 12 | * |
| 13 | * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) |
| 14 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 15 | * SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 6caa195 | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include <common.h> |
| 19 | #include <fdt_support.h> |
Tom Rini | 4588d61 | 2015-05-14 11:07:03 -0400 | [diff] [blame] | 20 | #ifdef CONFIG_ARMV7_NONSEC |
Jan Kiszka | d6b72da | 2015-04-21 07:18:32 +0200 | [diff] [blame] | 21 | #include <asm/armv7.h> |
Tom Rini | 4588d61 | 2015-05-14 11:07:03 -0400 | [diff] [blame] | 22 | #endif |
Tom Rini | dd09f7e | 2015-03-05 20:19:36 -0500 | [diff] [blame] | 23 | #include <asm/psci.h> |
Masahiro Yamada | 6b6024e | 2016-06-27 19:31:05 +0900 | [diff] [blame] | 24 | #include <asm/spin_table.h> |
Simon Glass | 6caa195 | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 25 | |
| 26 | DECLARE_GLOBAL_DATA_PTR; |
| 27 | |
Michal Simek | e2f88df | 2016-07-28 09:06:41 +0200 | [diff] [blame] | 28 | #ifdef CONFIG_ARCH_FIXUP_FDT |
Ma Haijun | e29607e | 2014-07-12 14:24:06 +0100 | [diff] [blame] | 29 | int arch_fixup_fdt(void *blob) |
Simon Glass | 6caa195 | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 30 | { |
| 31 | bd_t *bd = gd->bd; |
Marc Zyngier | e771a3d | 2014-07-12 14:24:07 +0100 | [diff] [blame] | 32 | int bank, ret; |
Simon Glass | 6caa195 | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 33 | u64 start[CONFIG_NR_DRAM_BANKS]; |
| 34 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 35 | |
| 36 | for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { |
| 37 | start[bank] = bd->bi_dram[bank].start; |
| 38 | size[bank] = bd->bi_dram[bank].size; |
Jan Kiszka | d6b72da | 2015-04-21 07:18:32 +0200 | [diff] [blame] | 39 | #ifdef CONFIG_ARMV7_NONSEC |
| 40 | ret = armv7_apply_memory_carveout(&start[bank], &size[bank]); |
| 41 | if (ret) |
| 42 | return ret; |
| 43 | #endif |
Simon Glass | 6caa195 | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Marc Zyngier | e771a3d | 2014-07-12 14:24:07 +0100 | [diff] [blame] | 46 | ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS); |
Marc Zyngier | e771a3d | 2014-07-12 14:24:07 +0100 | [diff] [blame] | 47 | if (ret) |
| 48 | return ret; |
| 49 | |
Masahiro Yamada | 6b6024e | 2016-06-27 19:31:05 +0900 | [diff] [blame] | 50 | #ifdef CONFIG_ARMV8_SPIN_TABLE |
| 51 | ret = spin_table_update_dt(blob); |
| 52 | if (ret) |
| 53 | return ret; |
| 54 | #endif |
| 55 | |
Hou Zhiqiang | 45684ae | 2016-06-28 20:18:16 +0800 | [diff] [blame] | 56 | #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) |
Tom Rini | dd09f7e | 2015-03-05 20:19:36 -0500 | [diff] [blame] | 57 | ret = psci_update_dt(blob); |
Masahiro Yamada | 6441e3d | 2016-06-17 21:51:48 +0900 | [diff] [blame] | 58 | if (ret) |
| 59 | return ret; |
Marc Zyngier | e771a3d | 2014-07-12 14:24:07 +0100 | [diff] [blame] | 60 | #endif |
Masahiro Yamada | 6441e3d | 2016-06-17 21:51:48 +0900 | [diff] [blame] | 61 | |
| 62 | return 0; |
Simon Glass | 6caa195 | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 63 | } |
Michal Simek | e2f88df | 2016-07-28 09:06:41 +0200 | [diff] [blame] | 64 | #endif |