BOOLEAN PsciSmcSupported;\r
UINTN OriginalFdtSize;\r
BOOLEAN CpusNodeExist;\r
+ UINTN CoreMpId;\r
+ UINTN Smc;\r
\r
NewFdtBlobAllocation = 0;\r
\r
}\r
\r
//\r
- // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms\r
+ // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms.\r
+ //\r
+ // For 'cpus' and 'cpu' device tree nodes bindings, refer to this file\r
+ // in the kernel documentation:\r
+ // Documentation/devicetree/bindings/arm/cpus.txt\r
//\r
for (Index=0; Index < gST->NumberOfTableEntries; Index++) {\r
// Check for correct GUID type\r
// Create the /cpus node\r
node = fdt_add_subnode(fdt, 0, "cpus");\r
fdt_setprop_string(fdt, node, "name", "cpus");\r
- fdt_setprop_cell(fdt, node, "#address-cells", 1);\r
+ fdt_setprop_cell (fdt, node, "#address-cells", sizeof (UINTN) / 4);\r
fdt_setprop_cell(fdt, node, "#size-cells", 0);\r
CpusNodeExist = FALSE;\r
} else {\r
for (Index = 0; Index < ArmProcessorTable->NumberOfEntries; Index++) {\r
AsciiSPrint (Name, 10, "cpu@%d", Index);\r
\r
- // If the 'cpus' node did not exist then creates the 'cpu' nodes. In case 'cpus' node\r
- // is provided in the original FDT then we do not add any 'cpu' node.\r
+ // If the 'cpus' node did not exist then create all the 'cpu' nodes.\r
+ // In case 'cpus' node is provided in the original FDT then we do not add\r
+ // any 'cpu' node.\r
if (!CpusNodeExist) {\r
- cpu_node = fdt_add_subnode(fdt, node, Name);\r
- fdt_setprop_string(fdt, cpu_node, "device-type", "cpu");\r
- fdt_setprop(fdt, cpu_node, "reg", &Index, sizeof(Index));\r
+ cpu_node = fdt_add_subnode (fdt, node, Name);\r
+ if (cpu_node < 0) {\r
+ DEBUG ((EFI_D_ERROR, "Error on creating '%s' node\n", Name));\r
+ Status = EFI_INVALID_PARAMETER;\r
+ goto FAIL_COMPLETE_FDT;\r
+ }\r
+\r
+ fdt_setprop_string (fdt, cpu_node, "device_type", "cpu");\r
+ CoreMpId = (UINTN) GET_MPID (ArmCoreInfoTable[Index].ClusterId,\r
+ ArmCoreInfoTable[Index].CoreId);\r
+ CoreMpId = cpu_to_fdtn (CoreMpId);\r
+ fdt_setprop (fdt, cpu_node, "reg", &CoreMpId, sizeof (CoreMpId));\r
+ if (PsciSmcSupported) {\r
+ fdt_setprop_string (fdt, cpu_node, "enable-method", "psci");\r
+ }\r
} else {\r
cpu_node = fdt_subnode_offset(fdt, node, Name);\r
}\r
Status = EFI_INVALID_PARAMETER;\r
goto FAIL_COMPLETE_FDT;\r
} else {\r
- fdt_setprop_string(fdt, node, "compatible", "arm,psci");\r
- fdt_setprop_string(fdt, node, "method", "smc");\r
- fdt_setprop_cell(fdt, node, "cpu_suspend", ARM_SMC_ARM_CPU_SUSPEND);\r
- fdt_setprop_cell(fdt, node, "cpu_off", ARM_SMC_ARM_CPU_OFF);\r
- fdt_setprop_cell(fdt, node, "cpu_on", ARM_SMC_ARM_CPU_ON);\r
- fdt_setprop_cell(fdt, node, "cpu_migrate", ARM_SMC_ARM_MIGRATE);\r
+ fdt_setprop_string (fdt, node, "compatible", "arm,psci");\r
+ fdt_setprop_string (fdt, node, "method", "smc");\r
+\r
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_SUSPEND);\r
+ fdt_setprop (fdt, node, "cpu_suspend", &Smc, sizeof (Smc));\r
+\r
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_OFF);\r
+ fdt_setprop (fdt, node, "cpu_off", &Smc, sizeof (Smc));\r
+\r
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_ON);\r
+ fdt_setprop (fdt, node, "cpu_on", &Smc, sizeof (Smc));\r
+\r
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_MIGRATE);\r
+ fdt_setprop (fdt, node, "migrate", &Smc, sizeof (Smc));\r
}\r
}\r
}\r