xref: /openbmc/u-boot/arch/arm/lib/bootm-fdt.c (revision dcb11959)
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 #ifdef CONFIG_ARMV7_NONSEC
21 #include <asm/armv7.h>
22 #endif
23 #include <asm/psci.h>
24 #include <asm/spin_table.h>
25 
26 DECLARE_GLOBAL_DATA_PTR;
27 
28 #ifdef CONFIG_FMAN_ENET
29 __weak int fdt_update_ethernet_dt(void *blob)
30 {
31 	return 0;
32 }
33 #endif
34 
35 int arch_fixup_fdt(void *blob)
36 {
37 	int ret = 0;
38 #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_OF_LIBFDT)
39 	bd_t *bd = gd->bd;
40 	int bank;
41 	u64 start[CONFIG_NR_DRAM_BANKS];
42 	u64 size[CONFIG_NR_DRAM_BANKS];
43 
44 	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
45 		start[bank] = bd->bi_dram[bank].start;
46 		size[bank] = bd->bi_dram[bank].size;
47 #ifdef CONFIG_ARMV7_NONSEC
48 		ret = armv7_apply_memory_carveout(&start[bank], &size[bank]);
49 		if (ret)
50 			return ret;
51 #endif
52 	}
53 
54 #ifdef CONFIG_OF_LIBFDT
55 	ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
56 	if (ret)
57 		return ret;
58 #endif
59 
60 #ifdef CONFIG_ARMV8_SPIN_TABLE
61 	ret = spin_table_update_dt(blob);
62 	if (ret)
63 		return ret;
64 #endif
65 
66 #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \
67 	defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI)
68 	ret = psci_update_dt(blob);
69 	if (ret)
70 		return ret;
71 #endif
72 #endif
73 
74 #ifdef CONFIG_FMAN_ENET
75 	ret = fdt_update_ethernet_dt(blob);
76 	if (ret)
77 		return ret;
78 #endif
79 	return 0;
80 }
81