From: Ye Li Date: Fri, 9 Aug 2019 01:12:31 +0000 (-0700) Subject: MLK-22418 imx8: Support new power domain design during updating kernel DTB X-Git-Tag: rel_imx_4.19.35_1.1.0~68 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=fef52e9207ed588cd01e9d680e094a3a4ef7cad2;p=u-boot.git MLK-22418 imx8: Support new power domain design during updating kernel DTB Upstream kernel refactors the power domain nodes and the usage of power-domains property in DTB. So when checking available resources in AP partition with this kernel DTB, u-boot will reports some warnings. This patch will support both two power domain designs during updating kernel DTB. Signed-off-by: Ye Li Reviewed-by: Peng Fan --- diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index 3ee5f9eb8a..3ed4917664 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -962,6 +962,68 @@ static void update_fdt_with_owned_resources(void *blob) } } +static void update_fdt_with_owned_resources_v2(void *blob) +{ + int count, i, ret, rc; + int offset = 0, depth = 0; + struct fdtdec_phandle_args args; + + /* Check the new PD, if not find, continue with old PD tree */ + count = fdt_node_offset_by_compatible(blob, -1, "fsl,scu-pd"); + if (count < 0) + return update_fdt_with_owned_resources(blob); + + debug("Update FDT V2\n"); + + for (offset = fdt_next_node(blob, offset, &depth); offset > 0; + offset = fdt_next_node(blob, offset, &depth)) { + + debug("Node name: %s, depth %d\n", fdt_get_name(blob, offset, NULL), depth); + + if (!fdtdec_get_is_enabled(blob, offset)) { + debug(" - ignoring disabled device\n"); + continue; + } + + count = fdtdec_parse_phandle_with_args(blob, + offset, + "power-domains", "#power-domain-cells", + 0, -1, NULL); + if (count < 1) { + debug("no power-domains found\n"); + continue; + } + + debug("count %d\n", count); + + for (i = 0; i < count; i++) { + ret = fdtdec_parse_phandle_with_args(blob, + offset, + "power-domains", "#power-domain-cells", + 0, i, &args); + + if (ret) { + debug("Error in parsing power-domains\n"); + continue; + } + + debug("check resource id %u\n", args.args[0]); + + if (!check_owned_resource(args.args[0])) { + /* If the resource is not owned, disable it in FDT */ + rc = disable_fdt_node(blob, offset); + if (!rc) + printf("Disable %s, resource id %u not owned\n", + fdt_get_name(blob, offset, NULL), args.args[0]); + else + printf("Unable to disable %s, err=%s\n", + fdt_get_name(blob, offset, NULL), fdt_strerror(rc)); + } + + } + } +} + #ifdef CONFIG_IMX_SMMU static int get_srsc_from_fdt_node_power_domain(void *blob, int device_offset) { @@ -1146,7 +1208,7 @@ int ft_system_setup(void *blob, bd_t *bd) #endif #ifndef CONFIG_SKIP_RESOURCE_CHECKING - update_fdt_with_owned_resources(blob); + update_fdt_with_owned_resources_v2(blob); #endif update_fdt_edma_nodes(blob);