2
0

device_tree.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Header with function prototypes to help device tree manipulation using
  3. * libfdt. It also provides functions to read entries from device tree proc
  4. * interface.
  5. *
  6. * Copyright 2008 IBM Corporation.
  7. * Authors: Jerone Young <jyoung5@us.ibm.com>
  8. * Hollis Blanchard <hollisb@us.ibm.com>
  9. *
  10. * This work is licensed under the GNU GPL license version 2 or later.
  11. *
  12. */
  13. #ifndef __DEVICE_TREE_H__
  14. #define __DEVICE_TREE_H__
  15. void *create_device_tree(int *sizep);
  16. void *load_device_tree(const char *filename_path, int *sizep);
  17. int qemu_devtree_setprop(void *fdt, const char *node_path,
  18. const char *property, const void *val_array, int size);
  19. int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
  20. const char *property, uint32_t val);
  21. int qemu_devtree_setprop_u64(void *fdt, const char *node_path,
  22. const char *property, uint64_t val);
  23. int qemu_devtree_setprop_string(void *fdt, const char *node_path,
  24. const char *property, const char *string);
  25. int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
  26. const char *property,
  27. const char *target_node_path);
  28. const void *qemu_devtree_getprop(void *fdt, const char *node_path,
  29. const char *property, int *lenp);
  30. uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path,
  31. const char *property);
  32. uint32_t qemu_devtree_get_phandle(void *fdt, const char *path);
  33. uint32_t qemu_devtree_alloc_phandle(void *fdt);
  34. int qemu_devtree_nop_node(void *fdt, const char *node_path);
  35. int qemu_devtree_add_subnode(void *fdt, const char *name);
  36. #define qemu_devtree_setprop_cells(fdt, node_path, property, ...) \
  37. do { \
  38. uint32_t qdt_tmp[] = { __VA_ARGS__ }; \
  39. int i; \
  40. \
  41. for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) { \
  42. qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]); \
  43. } \
  44. qemu_devtree_setprop(fdt, node_path, property, qdt_tmp, \
  45. sizeof(qdt_tmp)); \
  46. } while (0)
  47. #endif /* __DEVICE_TREE_H__ */