]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
powerpc/powernv: Add helper to get ibm,chip-id of a node
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 15 Jul 2013 03:03:10 +0000 (13:03 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 14 Aug 2013 04:58:02 +0000 (14:58 +1000)
This includes walking the parent nodes if necessary.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/prom.h
arch/powerpc/kernel/prom.c

index bc2da154f68be579d19e81e5789073e436ac838b..3bac73ecc349799ba6d7587f2ef363d3df96cc52 100644 (file)
@@ -58,6 +58,8 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; }
 
 extern void of_instantiate_rtc(void);
 
+extern int of_get_ibm_chip_id(struct device_node *np);
+
 /* The of_drconf_cell struct defines the layout of the LMB array
  * specified in the device tree property
  * ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory
index eb23ac92abb9089cea9ebc7fa19fd3a7e1404dbd..2de07e52c356079284e0a34f938d7068e4faee49 100644 (file)
@@ -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: