of_private.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. #define FDT_ALIGN_SIZE 8
  11. /**
  12. * struct alias_prop - Alias property in 'aliases' node
  13. * @link: List node to link the structure in aliases_lookup list
  14. * @alias: Alias property name
  15. * @np: Pointer to device_node that the alias stands for
  16. * @id: Index value from end of alias name
  17. * @stem: Alias string without the index
  18. *
  19. * The structure represents one alias property of 'aliases' node as
  20. * an entry in aliases_lookup list.
  21. */
  22. struct alias_prop {
  23. struct list_head link;
  24. const char *alias;
  25. struct device_node *np;
  26. int id;
  27. char stem[];
  28. };
  29. #if defined(CONFIG_SPARC)
  30. #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
  31. #else
  32. #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
  33. #endif
  34. #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
  35. extern struct mutex of_mutex;
  36. extern struct list_head aliases_lookup;
  37. extern struct kset *of_kset;
  38. #if defined(CONFIG_OF_DYNAMIC)
  39. extern int of_property_notify(int action, struct device_node *np,
  40. struct property *prop, struct property *old_prop);
  41. extern void of_node_release(struct kobject *kobj);
  42. extern int __of_changeset_apply_entries(struct of_changeset *ocs,
  43. int *ret_revert);
  44. extern int __of_changeset_apply_notify(struct of_changeset *ocs);
  45. extern int __of_changeset_revert_entries(struct of_changeset *ocs,
  46. int *ret_apply);
  47. extern int __of_changeset_revert_notify(struct of_changeset *ocs);
  48. #else /* CONFIG_OF_DYNAMIC */
  49. static inline int of_property_notify(int action, struct device_node *np,
  50. struct property *prop, struct property *old_prop)
  51. {
  52. return 0;
  53. }
  54. #endif /* CONFIG_OF_DYNAMIC */
  55. #if defined(CONFIG_OF_KOBJ)
  56. int of_node_is_attached(const struct device_node *node);
  57. int __of_add_property_sysfs(struct device_node *np, struct property *pp);
  58. void __of_remove_property_sysfs(struct device_node *np, struct property *prop);
  59. void __of_update_property_sysfs(struct device_node *np, struct property *newprop,
  60. struct property *oldprop);
  61. int __of_attach_node_sysfs(struct device_node *np);
  62. void __of_detach_node_sysfs(struct device_node *np);
  63. #else
  64. static inline int __of_add_property_sysfs(struct device_node *np, struct property *pp)
  65. {
  66. return 0;
  67. }
  68. static inline void __of_remove_property_sysfs(struct device_node *np, struct property *prop) {}
  69. static inline void __of_update_property_sysfs(struct device_node *np,
  70. struct property *newprop, struct property *oldprop) {}
  71. static inline int __of_attach_node_sysfs(struct device_node *np)
  72. {
  73. return 0;
  74. }
  75. static inline void __of_detach_node_sysfs(struct device_node *np) {}
  76. #endif
  77. #if defined(CONFIG_OF_RESOLVE)
  78. int of_resolve_phandles(struct device_node *tree);
  79. #endif
  80. void __of_phandle_cache_inv_entry(phandle handle);
  81. #if defined(CONFIG_OF_OVERLAY)
  82. void of_overlay_mutex_lock(void);
  83. void of_overlay_mutex_unlock(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_remove_property(struct device_node *np, struct property *prop);
  116. extern int __of_update_property(struct device_node *np,
  117. struct property *newprop, struct property **oldprop);
  118. extern void __of_detach_node(struct device_node *np);
  119. extern void __of_sysfs_remove_bin_file(struct device_node *np,
  120. struct property *prop);
  121. /* illegal phandle value (set when unresolved) */
  122. #define OF_PHANDLE_ILLEGAL 0xdeadbeef
  123. /* iterators for transactions, used for overlays */
  124. /* forward iterator */
  125. #define for_each_transaction_entry(_oft, _te) \
  126. list_for_each_entry(_te, &(_oft)->te_list, node)
  127. /* reverse iterator */
  128. #define for_each_transaction_entry_reverse(_oft, _te) \
  129. list_for_each_entry_reverse(_te, &(_oft)->te_list, node)
  130. extern int of_bus_n_addr_cells(struct device_node *np);
  131. extern int of_bus_n_size_cells(struct device_node *np);
  132. struct bus_dma_region;
  133. #if defined(CONFIG_OF_ADDRESS) && defined(CONFIG_HAS_DMA)
  134. int of_dma_get_range(struct device_node *np,
  135. const struct bus_dma_region **map);
  136. struct device_node *__of_get_dma_parent(const struct device_node *np);
  137. #else
  138. static inline int of_dma_get_range(struct device_node *np,
  139. const struct bus_dma_region **map)
  140. {
  141. return -ENODEV;
  142. }
  143. static inline struct device_node *__of_get_dma_parent(const struct device_node *np)
  144. {
  145. return of_get_parent(np);
  146. }
  147. #endif
  148. void fdt_init_reserved_mem(void);
  149. void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
  150. phys_addr_t base, phys_addr_t size);
  151. #endif /* _LINUX_OF_PRIVATE_H */