blob: 4481f9e2fa9ceb26f2f54f21e67f6b825c016601 [file] [log] [blame]
Simon Glass653909f2013-05-08 08:06:03 +00001/*
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 Denkd79de1d2013-07-08 09:37:19 +020015 * SPDX-License-Identifier: GPL-2.0+
Simon Glass653909f2013-05-08 08:06:03 +000016 */
17
18#include <common.h>
19#include <fdt_support.h>
Tom Rini9fcb5ef2015-05-14 11:07:03 -040020#ifdef CONFIG_ARMV7_NONSEC
Jan Kiszkacb334402015-04-21 07:18:32 +020021#include <asm/armv7.h>
Tom Rini9fcb5ef2015-05-14 11:07:03 -040022#endif
Tom Rinifb02cc12015-03-05 20:19:36 -050023#include <asm/psci.h>
Masahiro Yamada2663cd62016-06-27 19:31:05 +090024#include <asm/spin_table.h>
Simon Glass653909f2013-05-08 08:06:03 +000025
26DECLARE_GLOBAL_DATA_PTR;
27
Ma Haijun62358242014-07-12 14:24:06 +010028int arch_fixup_fdt(void *blob)
Simon Glass653909f2013-05-08 08:06:03 +000029{
30 bd_t *bd = gd->bd;
Marc Zyngierb32cf0e2014-07-12 14:24:07 +010031 int bank, ret;
Simon Glass653909f2013-05-08 08:06:03 +000032 u64 start[CONFIG_NR_DRAM_BANKS];
33 u64 size[CONFIG_NR_DRAM_BANKS];
34
35 for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
36 start[bank] = bd->bi_dram[bank].start;
37 size[bank] = bd->bi_dram[bank].size;
Jan Kiszkacb334402015-04-21 07:18:32 +020038#ifdef CONFIG_ARMV7_NONSEC
39 ret = armv7_apply_memory_carveout(&start[bank], &size[bank]);
40 if (ret)
41 return ret;
42#endif
Simon Glass653909f2013-05-08 08:06:03 +000043 }
44
Marc Zyngierb32cf0e2014-07-12 14:24:07 +010045 ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
Marc Zyngierb32cf0e2014-07-12 14:24:07 +010046 if (ret)
47 return ret;
48
Masahiro Yamada2663cd62016-06-27 19:31:05 +090049#ifdef CONFIG_ARMV8_SPIN_TABLE
50 ret = spin_table_update_dt(blob);
51 if (ret)
52 return ret;
53#endif
54
Hou Zhiqiangdae02772016-06-28 20:18:16 +080055#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI)
Tom Rinifb02cc12015-03-05 20:19:36 -050056 ret = psci_update_dt(blob);
Masahiro Yamada909cc1c2016-06-17 21:51:48 +090057 if (ret)
58 return ret;
Marc Zyngierb32cf0e2014-07-12 14:24:07 +010059#endif
Masahiro Yamada909cc1c2016-06-17 21:51:48 +090060
61 return 0;
Simon Glass653909f2013-05-08 08:06:03 +000062}