2 * Copyright (C) 2013 - ARM Ltd
3 * Author: Marc Zyngier <marc.zyngier@arm.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <stdio_dev.h>
20 #include <linux/ctype.h>
21 #include <linux/types.h>
22 #include <asm/global_data.h>
24 #include <fdt_support.h>
25 #include <asm/armv7.h>
28 static int fdt_psci(void *fdt)
30 #ifdef CONFIG_ARMV7_PSCI
34 nodeoff = fdt_path_offset(fdt, "/cpus");
36 printf("couldn't find /cpus\n");
40 /* add 'enable-method = "psci"' to each cpu node */
41 for (tmp = fdt_first_subnode(fdt, nodeoff);
43 tmp = fdt_next_subnode(fdt, tmp)) {
44 const struct fdt_property *prop;
47 prop = fdt_get_property(fdt, tmp, "device_type", &len);
52 if (strcmp(prop->data, "cpu"))
55 fdt_setprop_string(fdt, tmp, "enable-method", "psci");
58 nodeoff = fdt_path_offset(fdt, "/psci");
60 nodeoff = fdt_path_offset(fdt, "/");
64 nodeoff = fdt_add_subnode(fdt, nodeoff, "psci");
69 tmp = fdt_setprop_string(fdt, nodeoff, "compatible", "arm,psci");
72 tmp = fdt_setprop_string(fdt, nodeoff, "method", "smc");
75 tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_suspend", ARM_PSCI_FN_CPU_SUSPEND);
78 tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_off", ARM_PSCI_FN_CPU_OFF);
81 tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_on", ARM_PSCI_FN_CPU_ON);
84 tmp = fdt_setprop_u32(fdt, nodeoff, "migrate", ARM_PSCI_FN_MIGRATE);
91 int armv7_update_dt(void *fdt)
93 if (!armv7_boot_nonsec())
95 #ifndef CONFIG_ARMV7_SECURE_BASE
96 /* secure code lives in RAM, keep it alive */
97 fdt_add_mem_rsv(fdt, (unsigned long)__secure_start,
98 __secure_end - __secure_start);
101 return fdt_psci(fdt);