summaryrefslogtreecommitdiff
path: root/arch/powerpc/kernel/prom.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-07-15 13:03:10 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-08-14 14:58:02 +1000
commitb37193b71846858d816e152d3a5db010d7b73f5e (patch)
tree9200250b777ee9f8a9133f15810a4a65e6abc877 /arch/powerpc/kernel/prom.c
parentcc0efb57ebf04e066a57aa975c8a38884e603123 (diff)
downloadkernel-common-b37193b71846858d816e152d3a5db010d7b73f5e.tar.gz
kernel-common-b37193b71846858d816e152d3a5db010d7b73f5e.tar.bz2
kernel-common-b37193b71846858d816e152d3a5db010d7b73f5e.zip
powerpc/powernv: Add helper to get ibm,chip-id of a node
This includes walking the parent nodes if necessary. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/prom.c')
-rw-r--r--arch/powerpc/kernel/prom.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index eb23ac92abb9..2de07e52c356 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -795,6 +795,32 @@ struct device_node *of_find_next_cache_node(struct device_node *np)
return NULL;
}
+/**
+ * of_get_ibm_chip_id - Returns the IBM "chip-id" of a device
+ * @np: device node of the device
+ *
+ * This looks for a property "ibm,chip-id" in the node or any
+ * of its parents and returns its content, or -1 if it cannot
+ * be found.
+ */
+int of_get_ibm_chip_id(struct device_node *np)
+{
+ of_node_get(np);
+ while(np) {
+ struct device_node *old = np;
+ const __be32 *prop;
+
+ prop = of_get_property(np, "ibm,chip-id", NULL);
+ if (prop) {
+ of_node_put(np);
+ return be32_to_cpup(prop);
+ }
+ np = of_get_parent(np);
+ of_node_put(old);
+ }
+ return -1;
+}
+
#ifdef CONFIG_PPC_PSERIES
/*
* Fix up the uninitialized fields in a new device node: