2 * Copyright 2016 NXP Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <fdt_support.h>
10 #include <linux/sizes.h>
11 #include <linux/kernel.h>
13 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
14 #include <asm/armv8/sec_firmware.h>
17 int fdt_psci(void *fdt)
19 #if defined(CONFIG_ARMV8_PSCI) || defined(CONFIG_ARMV7_PSCI)
21 unsigned int psci_ver = 0;
25 nodeoff = fdt_path_offset(fdt, "/cpus");
27 printf("couldn't find /cpus\n");
31 /* add 'enable-method = "psci"' to each cpu node */
32 for (tmp = fdt_first_subnode(fdt, nodeoff);
34 tmp = fdt_next_subnode(fdt, tmp)) {
35 const struct fdt_property *prop;
38 prop = fdt_get_property(fdt, tmp, "device_type", &len);
43 if (strcmp(prop->data, "cpu"))
47 * Not checking rv here, our approach is to skip over errors in
48 * individual cpu nodes, hopefully some of the nodes are
49 * processed correctly and those will boot
51 fdt_setprop_string(fdt, tmp, "enable-method", "psci");
55 * The PSCI node might be called "/psci" or might be called something
56 * else but contain either of the compatible strings
57 * "arm,psci"/"arm,psci-0.2"
59 nodeoff = fdt_path_offset(fdt, "/psci");
63 nodeoff = fdt_node_offset_by_compatible(fdt, -1, "arm,psci");
67 nodeoff = fdt_node_offset_by_compatible(fdt, -1, "arm,psci-0.2");
71 nodeoff = fdt_node_offset_by_compatible(fdt, -1, "arm,psci-1.0");
75 nodeoff = fdt_path_offset(fdt, "/");
79 nodeoff = fdt_add_subnode(fdt, nodeoff, "psci");
84 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
85 psci_ver = sec_firmware_support_psci_version();
89 psci_compt = "arm,psci-1.0";
92 psci_compt = "arm,psci-0.2";
95 psci_compt = "arm,psci";
99 tmp = fdt_setprop_string(fdt, nodeoff, "compatible", psci_compt);
102 tmp = fdt_setprop_string(fdt, nodeoff, "method", "smc");
106 #ifdef CONFIG_ARMV7_PSCI
107 tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_suspend",
108 ARM_PSCI_FN_CPU_SUSPEND);
111 tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_off", ARM_PSCI_FN_CPU_OFF);
114 tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_on", ARM_PSCI_FN_CPU_ON);
117 tmp = fdt_setprop_u32(fdt, nodeoff, "migrate", ARM_PSCI_FN_MIGRATE);