1 /* 2 * Copyright 2010 Michael Ellerman, IBM Corporation 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 */ 9 10 #include <linux/kernel.h> 11 #include <linux/of_platform.h> 12 13 #include "wsp.h" 14 15 /* 16 * Find chip-id by walking up device tree looking for ibm,wsp-chip-id property. 17 * Won't work for nodes that are not a descendant of a wsp node. 18 */ wsp_get_chip_id(struct device_node * dn)19int wsp_get_chip_id(struct device_node *dn) 20 { 21 const u32 *p; 22 int rc; 23 24 /* Start looking at the specified node, not its parent */ 25 dn = of_node_get(dn); 26 while (dn && !(p = of_get_property(dn, "ibm,wsp-chip-id", NULL))) 27 dn = of_get_next_parent(dn); 28 29 if (!dn) 30 return -1; 31 32 rc = *p; 33 of_node_put(dn); 34 35 return rc; 36 } 37