Skip to content

Commit

Permalink
aarch64: add function to get PSCI method from device tree
Browse files Browse the repository at this point in the history
We need to get the "method" property of the psci node in the device tree to
determine if we should use hvc or smc to issue PSCI commands.

https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/psci.txt

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@dornerworks.com>
Message-Id: <20210219215249.25453-3-stewart.hildebrand@dornerworks.com>
  • Loading branch information
stewdk authored and wkozaczuk committed Feb 22, 2021
1 parent 84c6300 commit b90c08c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions arch/aarch64/arch-dtb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,34 @@ bool dtb_get_vmm_is_xen()
return fdt_node_offset_by_compatible(dtb, -1, "xen,xen") >= 0;
}

const char *dtb_get_psci_method()
{
const char *psci_compatible[] = {
"arm,psci",
"arm,psci-0.2",
"arm,psci-1.0",
};
unsigned int i;
int node;

for (i = 0; i < sizeof(psci_compatible)/sizeof(psci_compatible[0]); i++) {
node = fdt_node_offset_by_compatible(dtb, -1, psci_compatible[i]);
if (node >= 0)
break;
}

if (node < 0) {
return NULL;
}

const char *method = (char *)fdt_getprop(dtb, node, "method", NULL);
if (!method) {
return NULL;
}

return method;
}

void __attribute__((constructor(init_prio::dtb))) dtb_setup()
{
void *olddtb;
Expand Down
7 changes: 7 additions & 0 deletions arch/aarch64/arch-dtb.hh
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,11 @@ bool dtb_get_pci_irqmap(u32 *bdfs, int *irq_ids, int n);

bool dtb_get_vmm_is_xen();

/* const char *dtb_get_psci_method();
*
* Returns the PSCI method, "hvc" or "smc", if found in the device tree.
* Returne NULL otherwise.
*/
const char *dtb_get_psci_method();

#endif /* ARCH_DTB_HH */

0 comments on commit b90c08c

Please sign in to comment.