From: Ye Li Date: Mon, 16 Apr 2018 07:32:18 +0000 (-0700) Subject: MLK-16560-3: imx8: config_smmu_fdt: Support mmu-masters binding X-Git-Tag: rel_imx_4.19.35_1.1.0~891 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=dcbcab8c3f4df4ab03068da7a8c84d9a80ea550f;p=u-boot.git MLK-16560-3: imx8: config_smmu_fdt: Support mmu-masters binding This is deprecated in favor of the generic iommus binding but xen only supports this older version. Signed-off-by: Leonard Crestez Reviewed-by: Ye Li Acked-by: Peng Fan (cherry picked from commit c6b64c4e2927ee272f7abc5e94703013b2b2b443) --- diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c index 30fe1754ab..45d04da408 100644 --- a/arch/arm/mach-imx/imx8/cpu.c +++ b/arch/arm/mach-imx/imx8/cpu.c @@ -629,10 +629,34 @@ static int config_smmu_fdt_device_sid(void *blob, int device_offset, int sid) /* assign master sid based on iommu properties in fdt */ static int config_smmu_fdt(void *blob) { - int offset, proplen; + int offset, proplen, i; const fdt32_t *prop; const char *name; + /* Legacy smmu bindings, still used by xen. */ + offset = fdt_node_offset_by_compatible(blob, 0, "arm,mmu-500"); + if (offset > 0 && (prop = fdt_getprop(blob, offset, "mmu-masters", &proplen))) + { + debug("found legacy mmu-masters property\n"); + + for (i = 0; i < proplen / 8; ++i) { + uint32_t phandle = fdt32_to_cpu(prop[2 * i]); + int sid = fdt32_to_cpu(prop[2 * i + 1]); + int device_offset; + + device_offset = fdt_node_offset_by_phandle(blob, phandle); + if (device_offset < 0) { + pr_err("Failed to fetch device reference from mmu_masters: %d", device_offset); + continue; + } + config_smmu_fdt_device_sid(blob, device_offset, sid); + } + + /* Ignore new bindings if old bindings found, just like linux. */ + return 0; + } + + /* Generic smmu bindings */ offset = 0; while ((offset = fdt_next_node(blob, offset, NULL)) > 0) {