Commit d499c818a3ad75de772e2d94daa6c83e9d923c7a

Authored by Peng Fan
1 parent fef52e9207

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 <peng.fan@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>

Showing 1 changed file with 29 additions and 8 deletions Side-by-side Diff

arch/arm/mach-imx/imx8/cpu.c
... ... @@ -1025,10 +1025,12 @@
1025 1025 }
1026 1026  
1027 1027 #ifdef CONFIG_IMX_SMMU
1028   -static int get_srsc_from_fdt_node_power_domain(void *blob, int device_offset)
  1028 +static int get_srsc_from_fdt_node_power_domain(void *blob, int device_offset, int index)
1029 1029 {
1030 1030 const fdt32_t *prop;
1031 1031 int pdnode_offset;
  1032 + int ret;
  1033 + struct fdtdec_phandle_args args;
1032 1034  
1033 1035 prop = fdt_getprop(blob, device_offset, "power-domains", NULL);
1034 1036 if (!prop) {
... ... @@ -1044,7 +1046,17 @@
1044 1046 return pdnode_offset;
1045 1047 }
1046 1048  
1047   - return fdtdec_get_uint(blob, pdnode_offset, "reg", -ENOENT);
  1049 + ret = fdtdec_get_uint(blob, pdnode_offset, "reg", -ENOENT);
  1050 + if (ret != -ENOENT)
  1051 + return ret;
  1052 +
  1053 + ret = fdtdec_parse_phandle_with_args(blob, device_offset,
  1054 + "power-domains",
  1055 + "#power-domain-cells", 0, index,
  1056 + &args);
  1057 + if (ret)
  1058 + return ret;
  1059 + return args.args[0];
1048 1060 }
1049 1061  
1050 1062 static int config_smmu_resource_sid(int rsrc, int sid)
... ... @@ -1069,6 +1081,7 @@
1069 1081 {
1070 1082 int rsrc;
1071 1083 int proplen;
  1084 + int i, count;
1072 1085 const fdt32_t *prop;
1073 1086 const char *name = fdt_get_name(blob, device_offset, NULL);
1074 1087  
1075 1088  
... ... @@ -1085,14 +1098,22 @@
1085 1098 return 0;
1086 1099 }
1087 1100  
1088   - rsrc = get_srsc_from_fdt_node_power_domain(blob, device_offset);
1089   - debug("configure node %s sid 0x%x rsrc=%d\n", name, sid, rsrc);
1090   - if (rsrc < 0) {
1091   - debug("failed to determine SC_R_* for node %s\n", name);
1092   - return rsrc;
  1101 + count = fdtdec_parse_phandle_with_args(blob, device_offset,
  1102 + "power-domains",
  1103 + "#power-domain-cells",
  1104 + 0, -1, NULL);
  1105 + for (i = 0; i < count; i++) {
  1106 + rsrc = get_srsc_from_fdt_node_power_domain(blob, device_offset, i);
  1107 + debug("configure node %s sid 0x%x rsrc=%d\n", name, sid, rsrc);
  1108 + if (rsrc < 0) {
  1109 + debug("failed to determine SC_R_* for node %s\n", name);
  1110 + return rsrc;
  1111 + }
  1112 +
  1113 + config_smmu_resource_sid(rsrc, sid);
1093 1114 }
1094 1115  
1095   - return config_smmu_resource_sid(rsrc, sid);
  1116 + return 0;
1096 1117 }
1097 1118  
1098 1119 /* assign master sid based on iommu properties in fdt */