setup.c 862 B

12345678910111213141516171819202122232425262728293031323334353637
  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. #include <linux/kernel.h>
  10. #include <linux/of_platform.h>
  11. #include "wsp.h"
  12. /*
  13. * Find chip-id by walking up device tree looking for ibm,wsp-chip-id property.
  14. * Won't work for nodes that are not a descendant of a wsp node.
  15. */
  16. int wsp_get_chip_id(struct device_node *dn)
  17. {
  18. const u32 *p;
  19. int rc;
  20. /* Start looking at the specified node, not its parent */
  21. dn = of_node_get(dn);
  22. while (dn && !(p = of_get_property(dn, "ibm,wsp-chip-id", NULL)))
  23. dn = of_get_next_parent(dn);
  24. if (!dn)
  25. return -1;
  26. rc = *p;
  27. of_node_put(dn);
  28. return rc;
  29. }