xref: /openbmc/u-boot/arch/arm/lib/bootm-fdt.c (revision 2b605154)
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  *
15  * SPDX-License-Identifier:	GPL-2.0+
16  */
17 
18 #include <common.h>
19 #include <fdt_support.h>
20 #include <asm/armv7.h>
21 
22 DECLARE_GLOBAL_DATA_PTR;
23 
24 int arch_fixup_fdt(void *blob)
25 {
26 	bd_t *bd = gd->bd;
27 	int bank, ret;
28 	u64 start[CONFIG_NR_DRAM_BANKS];
29 	u64 size[CONFIG_NR_DRAM_BANKS];
30 
31 	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
32 		start[bank] = bd->bi_dram[bank].start;
33 		size[bank] = bd->bi_dram[bank].size;
34 	}
35 
36 	ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
37 #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV7_VIRT)
38 	if (ret)
39 		return ret;
40 
41 	ret = armv7_update_dt(blob);
42 #endif
43 	return ret;
44 }
45