1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2016 NXP Semiconductor, Inc.
4  */
5 
6 #include <asm/cache.h>
7 #include <asm/psci.h>
8 #include <asm/system.h>
9 #include <asm/armv8/sec_firmware.h>
10 #include <linux/libfdt.h>
11 
psci_update_dt(void * fdt)12 __weak int psci_update_dt(void *fdt)
13 {
14 	/*
15 	 * If the PSCI in SEC Firmware didn't work, avoid to update the
16 	 * device node of PSCI. But still return 0 instead of an error
17 	 * number to support detecting PSCI dynamically and then switching
18 	 * the SMP boot method between PSCI and spin-table.
19 	 */
20 	if (CONFIG_IS_ENABLED(SEC_FIRMWARE_ARMV8_PSCI) &&
21 	    sec_firmware_support_psci_version() == PSCI_INVALID_VER)
22 		return 0;
23 
24 	fdt_psci(fdt);
25 
26 #if defined(CONFIG_ARMV8_PSCI) && !defined(CONFIG_ARMV8_SECURE_BASE)
27 	/* secure code lives in RAM, keep it alive */
28 	fdt_add_mem_rsv(fdt, (unsigned long)__secure_start,
29 			__secure_end - __secure_start);
30 #endif
31 
32 	return 0;
33 }
34