of_live.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2017 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. *
  6. * Support for a 'live' (as opposed to flat) device tree
  7. */
  8. #ifndef _OF_LIVE_H
  9. #define _OF_LIVE_H
  10. struct device_node;
  11. /**
  12. * of_live_build() - build a live (hierarchical) tree from a flat DT
  13. *
  14. * @fdt_blob: Input tree to convert
  15. * @rootp: Returns live tree that was created
  16. * Return: 0 if OK, -ve on error
  17. */
  18. int of_live_build(const void *fdt_blob, struct device_node **rootp);
  19. /**
  20. * unflatten_device_tree() - create tree of device_nodes from flat blob
  21. *
  22. * Note that this allocates a single block of memory, pointed to by *mynodes.
  23. * To free the tree, use free(*mynodes)
  24. *
  25. * unflattens a device-tree, creating the
  26. * tree of struct device_node. It also fills the "name" and "type"
  27. * pointers of the nodes so the normal device-tree walking functions
  28. * can be used.
  29. * @blob: The blob to expand
  30. * @mynodes: The device_node tree created by the call
  31. * Return: 0 if OK, -ve on error
  32. */
  33. int unflatten_device_tree(const void *blob, struct device_node **mynodes);
  34. /**
  35. * of_live_free() - Dispose of a livetree
  36. *
  37. * This frees memory used by the tree, after which @root becomes invalid and
  38. * cannot be used
  39. *
  40. * @root: Tree to dispose
  41. */
  42. void of_live_free(struct device_node *root);
  43. #endif