blob: 7677358742e1bd3ee257495bbff71f67f2965cc4 [file] [log] [blame]
Simon Glass6caa1952013-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 Denk1a459662013-07-08 09:37:19 +020015 * SPDX-License-Identifier: GPL-2.0+
Simon Glass6caa1952013-05-08 08:06:03 +000016 */
17
18#include <common.h>
19#include <fdt_support.h>
Tom Rini4588d612015-05-14 11:07:03 -040020#ifdef CONFIG_ARMV7_NONSEC
Jan Kiszkad6b72da2015-04-21 07:18:32 +020021#include <asm/armv7.h>
Tom Rini4588d612015-05-14 11:07:03 -040022#endif
Tom Rinidd09f7e2015-03-05 20:19:36 -050023#include <asm/psci.h>
Simon Glass6caa1952013-05-08 08:06:03 +000024
25DECLARE_GLOBAL_DATA_PTR;
26
Ma Haijune29607e2014-07-12 14:24:06 +010027int arch_fixup_fdt(void *blob)
Simon Glass6caa1952013-05-08 08:06:03 +000028{
29 bd_t *bd = gd->bd;
Marc Zyngiere771a3d2014-07-12 14:24:07 +010030 int bank, ret;
Simon Glass6caa1952013-05-08 08:06:03 +000031 u64 start[CONFIG_NR_DRAM_BANKS];
32 u64 size[CONFIG_NR_DRAM_BANKS];
33
34 for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
35 start[bank] = bd->bi_dram[bank].start;
36 size[bank] = bd->bi_dram[bank].size;
Jan Kiszkad6b72da2015-04-21 07:18:32 +020037#ifdef CONFIG_ARMV7_NONSEC
38 ret = armv7_apply_memory_carveout(&start[bank], &size[bank]);
39 if (ret)
40 return ret;
41#endif
Simon Glass6caa1952013-05-08 08:06:03 +000042 }
43
Marc Zyngiere771a3d2014-07-12 14:24:07 +010044 ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
Jan Kiszka104d6fb2015-04-21 07:18:24 +020045#ifdef CONFIG_ARMV7_NONSEC
Marc Zyngiere771a3d2014-07-12 14:24:07 +010046 if (ret)
47 return ret;
48
Tom Rinidd09f7e2015-03-05 20:19:36 -050049 ret = psci_update_dt(blob);
Marc Zyngiere771a3d2014-07-12 14:24:07 +010050#endif
51 return ret;
Simon Glass6caa1952013-05-08 08:06:03 +000052}