Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 653909f | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013, Google Inc. |
| 4 | * |
| 5 | * Copyright (C) 2011 |
| 6 | * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de> |
| 7 | * - Added prep subcommand support |
| 8 | * - Reorganized source - modeled after powerpc version |
| 9 | * |
| 10 | * (C) Copyright 2002 |
| 11 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 12 | * Marius Groeger <mgroeger@sysgo.de> |
| 13 | * |
| 14 | * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) |
Simon Glass | 653909f | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Simon Glass | 653909f | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 17 | #include <fdt_support.h> |
Tom Rini | 9fcb5ef | 2015-05-14 11:07:03 -0400 | [diff] [blame] | 18 | #ifdef CONFIG_ARMV7_NONSEC |
Jan Kiszka | cb33440 | 2015-04-21 07:18:32 +0200 | [diff] [blame] | 19 | #include <asm/armv7.h> |
Tom Rini | 9fcb5ef | 2015-05-14 11:07:03 -0400 | [diff] [blame] | 20 | #endif |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 21 | #include <asm/global_data.h> |
Tom Rini | fb02cc1 | 2015-03-05 20:19:36 -0500 | [diff] [blame] | 22 | #include <asm/psci.h> |
Masahiro Yamada | 2663cd6 | 2016-06-27 19:31:05 +0900 | [diff] [blame] | 23 | #include <asm/spin_table.h> |
Simon Glass | 653909f | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 24 | |
| 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
Prabhakar Kushwaha | c10b967 | 2017-11-23 16:51:41 +0530 | [diff] [blame] | 27 | #ifdef CONFIG_FMAN_ENET |
| 28 | __weak int fdt_update_ethernet_dt(void *blob) |
| 29 | { |
| 30 | return 0; |
| 31 | } |
| 32 | #endif |
| 33 | |
Ma Haijun | 6235824 | 2014-07-12 14:24:06 +0100 | [diff] [blame] | 34 | int arch_fixup_fdt(void *blob) |
Simon Glass | 653909f | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 35 | { |
Heiko Schocher | 375cc6e | 2018-01-17 07:00:37 +0100 | [diff] [blame] | 36 | __maybe_unused int ret = 0; |
B, Ravi | 4d86356 | 2017-04-18 17:27:26 +0530 | [diff] [blame] | 37 | #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_OF_LIBFDT) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 38 | struct bd_info *bd = gd->bd; |
B, Ravi | 4d86356 | 2017-04-18 17:27:26 +0530 | [diff] [blame] | 39 | int bank; |
Simon Glass | 653909f | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 40 | u64 start[CONFIG_NR_DRAM_BANKS]; |
| 41 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 42 | |
| 43 | for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { |
| 44 | start[bank] = bd->bi_dram[bank].start; |
| 45 | size[bank] = bd->bi_dram[bank].size; |
Jan Kiszka | cb33440 | 2015-04-21 07:18:32 +0200 | [diff] [blame] | 46 | #ifdef CONFIG_ARMV7_NONSEC |
| 47 | ret = armv7_apply_memory_carveout(&start[bank], &size[bank]); |
| 48 | if (ret) |
| 49 | return ret; |
| 50 | #endif |
Simon Glass | 653909f | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 51 | } |
| 52 | |
B, Ravi | 4d86356 | 2017-04-18 17:27:26 +0530 | [diff] [blame] | 53 | #ifdef CONFIG_OF_LIBFDT |
Marc Zyngier | b32cf0e | 2014-07-12 14:24:07 +0100 | [diff] [blame] | 54 | ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS); |
Marc Zyngier | b32cf0e | 2014-07-12 14:24:07 +0100 | [diff] [blame] | 55 | if (ret) |
| 56 | return ret; |
B, Ravi | 4d86356 | 2017-04-18 17:27:26 +0530 | [diff] [blame] | 57 | #endif |
Marc Zyngier | b32cf0e | 2014-07-12 14:24:07 +0100 | [diff] [blame] | 58 | |
Masahiro Yamada | 2663cd6 | 2016-06-27 19:31:05 +0900 | [diff] [blame] | 59 | #ifdef CONFIG_ARMV8_SPIN_TABLE |
| 60 | ret = spin_table_update_dt(blob); |
| 61 | if (ret) |
| 62 | return ret; |
| 63 | #endif |
| 64 | |
macro.wave.z@gmail.com | 05725ed | 2016-12-08 11:58:25 +0800 | [diff] [blame] | 65 | #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \ |
Michael Walle | 16fd24c | 2020-11-18 17:45:54 +0100 | [diff] [blame] | 66 | CONFIG_IS_ENABLED(SEC_FIRMWARE_ARMV8_PSCI) |
Tom Rini | fb02cc1 | 2015-03-05 20:19:36 -0500 | [diff] [blame] | 67 | ret = psci_update_dt(blob); |
Masahiro Yamada | 909cc1c | 2016-06-17 21:51:48 +0900 | [diff] [blame] | 68 | if (ret) |
| 69 | return ret; |
Marc Zyngier | b32cf0e | 2014-07-12 14:24:07 +0100 | [diff] [blame] | 70 | #endif |
B, Ravi | 4d86356 | 2017-04-18 17:27:26 +0530 | [diff] [blame] | 71 | #endif |
Masahiro Yamada | 909cc1c | 2016-06-17 21:51:48 +0900 | [diff] [blame] | 72 | |
Prabhakar Kushwaha | c10b967 | 2017-11-23 16:51:41 +0530 | [diff] [blame] | 73 | #ifdef CONFIG_FMAN_ENET |
| 74 | ret = fdt_update_ethernet_dt(blob); |
| 75 | if (ret) |
| 76 | return ret; |
| 77 | #endif |
Masahiro Yamada | 909cc1c | 2016-06-17 21:51:48 +0900 | [diff] [blame] | 78 | return 0; |
Simon Glass | 653909f | 2013-05-08 08:06:03 +0000 | [diff] [blame] | 79 | } |