From d499c818a3ad75de772e2d94daa6c83e9d923c7a Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Fri, 30 Aug 2019 11:37:31 +0800 Subject: [PATCH] MLK-22528 imx8: cpu: get reg with new bindings for sid The dash-linux tree has dropped pd tree, so we could not get the reg. The power-doamins property has a cell indicating the resource id, let's use it for sid programming. Signed-off-by: Peng Fan Reviewed-by: Ye Li --- arch/arm/mach-imx/imx8/cpu.c | 37 ++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index 3ed4917664..283b648825 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -1025,10 +1025,12 @@ static void update_fdt_with_owned_resources_v2(void *blob) } #ifdef CONFIG_IMX_SMMU -static int get_srsc_from_fdt_node_power_domain(void *blob, int device_offset) +static int get_srsc_from_fdt_node_power_domain(void *blob, int device_offset, int index) { const fdt32_t *prop; int pdnode_offset; + int ret; + struct fdtdec_phandle_args args; prop = fdt_getprop(blob, device_offset, "power-domains", NULL); if (!prop) { @@ -1044,7 +1046,17 @@ static int get_srsc_from_fdt_node_power_domain(void *blob, int device_offset) return pdnode_offset; } - return fdtdec_get_uint(blob, pdnode_offset, "reg", -ENOENT); + ret = fdtdec_get_uint(blob, pdnode_offset, "reg", -ENOENT); + if (ret != -ENOENT) + return ret; + + ret = fdtdec_parse_phandle_with_args(blob, device_offset, + "power-domains", + "#power-domain-cells", 0, index, + &args); + if (ret) + return ret; + return args.args[0]; } static int config_smmu_resource_sid(int rsrc, int sid) @@ -1069,6 +1081,7 @@ static int config_smmu_fdt_device_sid(void *blob, int device_offset, int sid) { int rsrc; int proplen; + int i, count; const fdt32_t *prop; const char *name = fdt_get_name(blob, device_offset, NULL); @@ -1085,14 +1098,22 @@ static int config_smmu_fdt_device_sid(void *blob, int device_offset, int sid) return 0; } - rsrc = get_srsc_from_fdt_node_power_domain(blob, device_offset); - debug("configure node %s sid 0x%x rsrc=%d\n", name, sid, rsrc); - if (rsrc < 0) { - debug("failed to determine SC_R_* for node %s\n", name); - return rsrc; + count = fdtdec_parse_phandle_with_args(blob, device_offset, + "power-domains", + "#power-domain-cells", + 0, -1, NULL); + for (i = 0; i < count; i++) { + rsrc = get_srsc_from_fdt_node_power_domain(blob, device_offset, i); + debug("configure node %s sid 0x%x rsrc=%d\n", name, sid, rsrc); + if (rsrc < 0) { + debug("failed to determine SC_R_* for node %s\n", name); + return rsrc; + } + + config_smmu_resource_sid(rsrc, sid); } - return config_smmu_resource_sid(rsrc, sid); + return 0; } /* assign master sid based on iommu properties in fdt */ -- 2.17.1