of_private.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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[];
  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. void __of_phandle_cache_inv_entry(phandle handle);
  80. #if defined(CONFIG_OF_OVERLAY)
  81. void of_overlay_mutex_lock(void);
  82. void of_overlay_mutex_unlock(void);
  83. #else
  84. static inline void of_overlay_mutex_lock(void) {};
  85. static inline void of_overlay_mutex_unlock(void) {};
  86. #endif
  87. #if defined(CONFIG_OF_UNITTEST) && defined(CONFIG_OF_OVERLAY)
  88. extern void __init unittest_unflatten_overlay_base(void);
  89. #else
  90. static inline void unittest_unflatten_overlay_base(void) {};
  91. #endif
  92. extern void *__unflatten_device_tree(const void *blob,
  93. struct device_node *dad,
  94. struct device_node **mynodes,
  95. void *(*dt_alloc)(u64 size, u64 align),
  96. bool detached);
  97. /**
  98. * General utilities for working with live trees.
  99. *
  100. * All functions with two leading underscores operate
  101. * without taking node references, so you either have to
  102. * own the devtree lock or work on detached trees only.
  103. */
  104. struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
  105. struct device_node *__of_node_dup(const struct device_node *np,
  106. const char *full_name);
  107. struct device_node *__of_find_node_by_path(struct device_node *parent,
  108. const char *path);
  109. struct device_node *__of_find_node_by_full_path(struct device_node *node,
  110. const char *path);
  111. extern const void *__of_get_property(const struct device_node *np,
  112. const char *name, int *lenp);
  113. extern int __of_add_property(struct device_node *np, struct property *prop);
  114. extern int __of_add_property_sysfs(struct device_node *np,
  115. struct property *prop);
  116. extern int __of_remove_property(struct device_node *np, struct property *prop);
  117. extern void __of_remove_property_sysfs(struct device_node *np,
  118. struct property *prop);
  119. extern int __of_update_property(struct device_node *np,
  120. struct property *newprop, struct property **oldprop);
  121. extern void __of_update_property_sysfs(struct device_node *np,
  122. struct property *newprop, struct property *oldprop);
  123. extern int __of_attach_node_sysfs(struct device_node *np);
  124. extern void __of_detach_node(struct device_node *np);
  125. extern void __of_detach_node_sysfs(struct device_node *np);
  126. extern void __of_sysfs_remove_bin_file(struct device_node *np,
  127. struct property *prop);
  128. /* illegal phandle value (set when unresolved) */
  129. #define OF_PHANDLE_ILLEGAL 0xdeadbeef
  130. /* iterators for transactions, used for overlays */
  131. /* forward iterator */
  132. #define for_each_transaction_entry(_oft, _te) \
  133. list_for_each_entry(_te, &(_oft)->te_list, node)
  134. /* reverse iterator */
  135. #define for_each_transaction_entry_reverse(_oft, _te) \
  136. list_for_each_entry_reverse(_te, &(_oft)->te_list, node)
  137. extern int of_bus_n_addr_cells(struct device_node *np);
  138. extern int of_bus_n_size_cells(struct device_node *np);
  139. struct bus_dma_region;
  140. #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_HAS_DMA)
  141. int of_dma_get_range(struct device_node *np,
  142. const struct bus_dma_region **map);
  143. #else
  144. static inline int of_dma_get_range(struct device_node *np,
  145. const struct bus_dma_region **map)
  146. {
  147. return -ENODEV;
  148. }
  149. #endif
  150. #endif /* _LINUX_OF_PRIVATE_H */