of_private.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. #ifndef _LINUX_OF_PRIVATE_H
  3. #define _LINUX_OF_PRIVATE_H
  4. /*
  5. * Private symbols used by OF support code
  6. *
  7. * Paul Mackerras August 1996.
  8. * Copyright (C) 1996-2005 Paul Mackerras.
  9. */
  10. /**
  11. * struct alias_prop - Alias property in 'aliases' node
  12. * @link: List node to link the structure in aliases_lookup list
  13. * @alias: Alias property name
  14. * @np: Pointer to device_node that the alias stands for
  15. * @id: Index value from end of alias name
  16. * @stem: Alias string without the index
  17. *
  18. * The structure represents one alias property of 'aliases' node as
  19. * an entry in aliases_lookup list.
  20. */
  21. struct alias_prop {
  22. struct list_head link;
  23. const char *alias;
  24. struct device_node *np;
  25. int id;
  26. char stem[0];
  27. };
  28. #if defined(CONFIG_SPARC)
  29. #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
  30. #else
  31. #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
  32. #endif
  33. #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
  34. extern struct mutex of_mutex;
  35. extern struct list_head aliases_lookup;
  36. extern struct kset *of_kset;
  37. #if defined(CONFIG_OF_DYNAMIC)
  38. extern int of_property_notify(int action, struct device_node *np,
  39. struct property *prop, struct property *old_prop);
  40. extern void of_node_release(struct kobject *kobj);
  41. extern int __of_changeset_apply_entries(struct of_changeset *ocs,
  42. int *ret_revert);
  43. extern int __of_changeset_apply_notify(struct of_changeset *ocs);
  44. extern int __of_changeset_revert_entries(struct of_changeset *ocs,
  45. int *ret_apply);
  46. extern int __of_changeset_revert_notify(struct of_changeset *ocs);
  47. #else /* CONFIG_OF_DYNAMIC */
  48. static inline int of_property_notify(int action, struct device_node *np,
  49. struct property *prop, struct property *old_prop)
  50. {
  51. return 0;
  52. }
  53. #endif /* CONFIG_OF_DYNAMIC */
  54. #if defined(CONFIG_OF_KOBJ)
  55. int of_node_is_attached(struct device_node *node);
  56. int __of_add_property_sysfs(struct device_node *np, struct property *pp);
  57. void __of_remove_property_sysfs(struct device_node *np, struct property *prop);
  58. void __of_update_property_sysfs(struct device_node *np, struct property *newprop,
  59. struct property *oldprop);
  60. int __of_attach_node_sysfs(struct device_node *np);
  61. void __of_detach_node_sysfs(struct device_node *np);
  62. #else
  63. static inline int __of_add_property_sysfs(struct device_node *np, struct property *pp)
  64. {
  65. return 0;
  66. }
  67. static inline void __of_remove_property_sysfs(struct device_node *np, struct property *prop) {}
  68. static inline void __of_update_property_sysfs(struct device_node *np,
  69. struct property *newprop, struct property *oldprop) {}
  70. static inline int __of_attach_node_sysfs(struct device_node *np)
  71. {
  72. return 0;
  73. }
  74. static inline void __of_detach_node_sysfs(struct device_node *np) {}
  75. #endif
  76. #if defined(CONFIG_OF_RESOLVE)
  77. int of_resolve_phandles(struct device_node *tree);
  78. #endif
  79. #if defined(CONFIG_OF_OVERLAY)
  80. void of_overlay_mutex_lock(void);
  81. void of_overlay_mutex_unlock(void);
  82. int of_free_phandle_cache(void);
  83. void of_populate_phandle_cache(void);
  84. #else
  85. static inline void of_overlay_mutex_lock(void) {};
  86. static inline void of_overlay_mutex_unlock(void) {};
  87. #endif
  88. #if defined(CONFIG_OF_UNITTEST) && defined(CONFIG_OF_OVERLAY)
  89. extern void __init unittest_unflatten_overlay_base(void);
  90. #else
  91. static inline void unittest_unflatten_overlay_base(void) {};
  92. #endif
  93. extern void *__unflatten_device_tree(const void *blob,
  94. struct device_node *dad,
  95. struct device_node **mynodes,
  96. void *(*dt_alloc)(u64 size, u64 align),
  97. bool detached);
  98. /**
  99. * General utilities for working with live trees.
  100. *
  101. * All functions with two leading underscores operate
  102. * without taking node references, so you either have to
  103. * own the devtree lock or work on detached trees only.
  104. */
  105. struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
  106. struct device_node *__of_node_dup(const struct device_node *np,
  107. const char *full_name);
  108. struct device_node *__of_find_node_by_path(struct device_node *parent,
  109. const char *path);
  110. struct device_node *__of_find_node_by_full_path(struct device_node *node,
  111. const char *path);
  112. extern const void *__of_get_property(const struct device_node *np,
  113. const char *name, int *lenp);
  114. extern int __of_add_property(struct device_node *np, struct property *prop);
  115. extern int __of_add_property_sysfs(struct device_node *np,
  116. struct property *prop);
  117. extern int __of_remove_property(struct device_node *np, struct property *prop);
  118. extern void __of_remove_property_sysfs(struct device_node *np,
  119. struct property *prop);
  120. extern int __of_update_property(struct device_node *np,
  121. struct property *newprop, struct property **oldprop);
  122. extern void __of_update_property_sysfs(struct device_node *np,
  123. struct property *newprop, struct property *oldprop);
  124. extern int __of_attach_node_sysfs(struct device_node *np);
  125. extern void __of_detach_node(struct device_node *np);
  126. extern void __of_detach_node_sysfs(struct device_node *np);
  127. extern void __of_sysfs_remove_bin_file(struct device_node *np,
  128. struct property *prop);
  129. /* illegal phandle value (set when unresolved) */
  130. #define OF_PHANDLE_ILLEGAL 0xdeadbeef
  131. /* iterators for transactions, used for overlays */
  132. /* forward iterator */
  133. #define for_each_transaction_entry(_oft, _te) \
  134. list_for_each_entry(_te, &(_oft)->te_list, node)
  135. /* reverse iterator */
  136. #define for_each_transaction_entry_reverse(_oft, _te) \
  137. list_for_each_entry_reverse(_te, &(_oft)->te_list, node)
  138. #endif /* _LINUX_OF_PRIVATE_H */