blob: 04f566d2b0f423ccfc02ed6acf0e1ceded810fe7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass653909f2013-05-08 08:06:03 +00002/*
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 Glass653909f2013-05-08 08:06:03 +000015 */
16
17#include <common.h>
18#include <fdt_support.h>
Tom Rini9fcb5ef2015-05-14 11:07:03 -040019#ifdef CONFIG_ARMV7_NONSEC
Jan Kiszkacb334402015-04-21 07:18:32 +020020#include <asm/armv7.h>
Tom Rini9fcb5ef2015-05-14 11:07:03 -040021#endif
Tom Rinifb02cc12015-03-05 20:19:36 -050022#include <asm/psci.h>
Masahiro Yamada2663cd62016-06-27 19:31:05 +090023#include <asm/spin_table.h>
Simon Glass653909f2013-05-08 08:06:03 +000024
25DECLARE_GLOBAL_DATA_PTR;
26
Prabhakar Kushwahac10b9672017-11-23 16:51:41 +053027#ifdef CONFIG_FMAN_ENET
28__weak int fdt_update_ethernet_dt(void *blob)
29{
30 return 0;
31}
32#endif
33
Ma Haijun62358242014-07-12 14:24:06 +010034int arch_fixup_fdt(void *blob)
Simon Glass653909f2013-05-08 08:06:03 +000035{
Heiko Schocher375cc6e2018-01-17 07:00:37 +010036 __maybe_unused int ret = 0;
B, Ravi4d863562017-04-18 17:27:26 +053037#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_OF_LIBFDT)
Simon Glass653909f2013-05-08 08:06:03 +000038 bd_t *bd = gd->bd;
B, Ravi4d863562017-04-18 17:27:26 +053039 int bank;
Simon Glass653909f2013-05-08 08:06:03 +000040 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 Kiszkacb334402015-04-21 07:18:32 +020046#ifdef CONFIG_ARMV7_NONSEC
47 ret = armv7_apply_memory_carveout(&start[bank], &size[bank]);
48 if (ret)
49 return ret;
50#endif
Simon Glass653909f2013-05-08 08:06:03 +000051 }
52
B, Ravi4d863562017-04-18 17:27:26 +053053#ifdef CONFIG_OF_LIBFDT
Marc Zyngierb32cf0e2014-07-12 14:24:07 +010054 ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
Marc Zyngierb32cf0e2014-07-12 14:24:07 +010055 if (ret)
56 return ret;
B, Ravi4d863562017-04-18 17:27:26 +053057#endif
Marc Zyngierb32cf0e2014-07-12 14:24:07 +010058
Masahiro Yamada2663cd62016-06-27 19:31:05 +090059#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.com05725ed2016-12-08 11:58:25 +080065#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \
Hou Zhiqiang6be115d2017-01-16 17:31:48 +080066 defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI)
Tom Rinifb02cc12015-03-05 20:19:36 -050067 ret = psci_update_dt(blob);
Masahiro Yamada909cc1c2016-06-17 21:51:48 +090068 if (ret)
69 return ret;
Marc Zyngierb32cf0e2014-07-12 14:24:07 +010070#endif
B, Ravi4d863562017-04-18 17:27:26 +053071#endif
Masahiro Yamada909cc1c2016-06-17 21:51:48 +090072
Prabhakar Kushwahac10b9672017-11-23 16:51:41 +053073#ifdef CONFIG_FMAN_ENET
74 ret = fdt_update_ethernet_dt(blob);
75 if (ret)
76 return ret;
77#endif
Masahiro Yamada909cc1c2016-06-17 21:51:48 +090078 return 0;
Simon Glass653909f2013-05-08 08:06:03 +000079}