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 #ifdef CONFIG_DRM_ROCKCHIP 26 #include <video_rockchip.h> 27 #endif 28 29 DECLARE_GLOBAL_DATA_PTR; 30 31 #ifdef CONFIG_FMAN_ENET 32 __weak int fdt_update_ethernet_dt(void *blob) 33 { 34 return 0; 35 } 36 #endif 37 38 int arch_fixup_fdt(void *blob) 39 { 40 int ret = 0; 41 #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_OF_LIBFDT) 42 bd_t *bd = gd->bd; 43 int bank; 44 u64 start[CONFIG_NR_DRAM_BANKS]; 45 u64 size[CONFIG_NR_DRAM_BANKS]; 46 47 for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { 48 start[bank] = bd->bi_dram[bank].start; 49 size[bank] = bd->bi_dram[bank].size; 50 if (size[bank] == 0) 51 continue; 52 printf("Adding bank: start=0x%08llx, size=0x%08llx\n", 53 start[bank], size[bank]); 54 55 #ifdef CONFIG_ARMV7_NONSEC 56 ret = armv7_apply_memory_carveout(&start[bank], &size[bank]); 57 if (ret) 58 return ret; 59 #endif 60 } 61 62 #ifdef CONFIG_OF_LIBFDT 63 ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS); 64 if (ret) 65 return ret; 66 #endif 67 68 #ifdef CONFIG_ARMV8_SPIN_TABLE 69 ret = spin_table_update_dt(blob); 70 if (ret) 71 return ret; 72 #endif 73 74 #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \ 75 defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI) 76 ret = psci_update_dt(blob); 77 if (ret) 78 return ret; 79 #endif 80 #endif 81 #ifdef CONFIG_DRM_ROCKCHIP 82 rockchip_display_fixup(blob); 83 #endif 84 #ifdef CONFIG_FMAN_ENET 85 ret = fdt_update_ethernet_dt(blob); 86 if (ret) 87 return ret; 88 #endif 89 return 0; 90 } 91