1 // SPDX-License-Identifier: GPL-2.0+
7 #include <asm/arch/sci/sci.h>
9 #include <fdt_support.h>
11 DECLARE_GLOBAL_DATA_PTR;
13 static bool check_owned_resource(sc_rsrc_t rsrc_id)
17 owned = sc_rm_is_resource_owned(-1, rsrc_id);
22 static int disable_fdt_node(void *blob, int nodeoffset)
25 const char *status = "disabled";
28 rc = fdt_setprop(blob, nodeoffset, "status", status,
31 if (rc == -FDT_ERR_NOSPACE) {
32 ret = fdt_increase_size(blob, 512);
37 } while (rc == -FDT_ERR_NOSPACE);
42 static void update_fdt_with_owned_resources(void *blob)
45 * Traverses the fdt nodes, check its power domain and use
46 * the resource id in the power domain for checking whether
47 * it is owned by current partition
49 struct fdtdec_phandle_args args;
50 int offset = 0, depth = 0;
54 for (offset = fdt_next_node(blob, offset, &depth); offset > 0;
55 offset = fdt_next_node(blob, offset, &depth)) {
56 debug("Node name: %s, depth %d\n",
57 fdt_get_name(blob, offset, NULL), depth);
59 if (!fdt_get_property(blob, offset, "power-domains", NULL)) {
60 debug(" - ignoring node %s\n",
61 fdt_get_name(blob, offset, NULL));
65 if (!fdtdec_get_is_enabled(blob, offset)) {
66 debug(" - ignoring node %s\n",
67 fdt_get_name(blob, offset, NULL));
73 rc = fdtdec_parse_phandle_with_args(blob, offset,
75 "#power-domain-cells",
80 printf("Parse power-domains of %s wrong: %d\n",
81 fdt_get_name(blob, offset, NULL), rc);
85 rsrc_id = args.args[0];
87 if (!check_owned_resource(rsrc_id)) {
88 rc = disable_fdt_node(blob, offset);
90 printf("Disable %s rsrc %u not owned\n",
91 fdt_get_name(blob, offset, NULL),
94 printf("Unable to disable %s, err=%s\n",
95 fdt_get_name(blob, offset, NULL),
103 int ft_system_setup(void *blob, bd_t *bd)
105 update_fdt_with_owned_resources(blob);