bootm-fdt.c 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * Copyright (c) 2013, Google Inc.
 *
 * Copyright (C) 2011
 * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
 *  - Added prep subcommand support
 *  - Reorganized source - modeled after powerpc version
 *
 * (C) Copyright 2002
 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
 * Marius Groeger <mgroeger@sysgo.de>
 *
 * Copyright (C) 2001  Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
 *
15
 * SPDX-License-Identifier:	GPL-2.0+
16 17 18 19
 */

#include <common.h>
#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 27

DECLARE_GLOBAL_DATA_PTR;

28
int arch_fixup_fdt(void *blob)
29 30
{
	bd_t *bd = gd->bd;
31
	int bank, ret;
32 33 34 35 36 37
	u64 start[CONFIG_NR_DRAM_BANKS];
	u64 size[CONFIG_NR_DRAM_BANKS];

	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
		start[bank] = bd->bi_dram[bank].start;
		size[bank] = bd->bi_dram[bank].size;
38 39 40 41 42
#ifdef CONFIG_ARMV7_NONSEC
		ret = armv7_apply_memory_carveout(&start[bank], &size[bank]);
		if (ret)
			return ret;
#endif
43 44
	}

45 46 47 48
	ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
	if (ret)
		return ret;

49 50 51 52 53 54
#ifdef CONFIG_ARMV8_SPIN_TABLE
	ret = spin_table_update_dt(blob);
	if (ret)
		return ret;
#endif

55
#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI)
56
	ret = psci_update_dt(blob);
57 58
	if (ret)
		return ret;
59
#endif
60 61

	return 0;
62
}