xref: /linux-6.15/include/linux/of.h (revision 76d09ea7)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 #ifndef _LINUX_OF_H
3 #define _LINUX_OF_H
4 /*
5  * Definitions for talking to the Open Firmware PROM on
6  * Power Macintosh and other computers.
7  *
8  * Copyright (C) 1996-2005 Paul Mackerras.
9  *
10  * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
11  * Updates for SPARC64 by David S. Miller
12  * Derived from PowerPC and Sparc prom.h files by Stephen Rothwell, IBM Corp.
13  */
14 #include <linux/types.h>
15 #include <linux/bitops.h>
16 #include <linux/errno.h>
17 #include <linux/kobject.h>
18 #include <linux/mod_devicetable.h>
19 #include <linux/spinlock.h>
20 #include <linux/topology.h>
21 #include <linux/notifier.h>
22 #include <linux/property.h>
23 #include <linux/list.h>
24 
25 #include <asm/byteorder.h>
26 #include <asm/errno.h>
27 
28 typedef u32 phandle;
29 typedef u32 ihandle;
30 
31 struct property {
32 	char	*name;
33 	int	length;
34 	void	*value;
35 	struct property *next;
36 #if defined(CONFIG_OF_DYNAMIC) || defined(CONFIG_SPARC)
37 	unsigned long _flags;
38 #endif
39 #if defined(CONFIG_OF_PROMTREE)
40 	unsigned int unique_id;
41 #endif
42 #if defined(CONFIG_OF_KOBJ)
43 	struct bin_attribute attr;
44 #endif
45 };
46 
47 #if defined(CONFIG_SPARC)
48 struct of_irq_controller;
49 #endif
50 
51 struct device_node {
52 	const char *name;
53 	const char *type;
54 	phandle phandle;
55 	const char *full_name;
56 	struct fwnode_handle fwnode;
57 
58 	struct	property *properties;
59 	struct	property *deadprops;	/* removed properties */
60 	struct	device_node *parent;
61 	struct	device_node *child;
62 	struct	device_node *sibling;
63 #if defined(CONFIG_OF_KOBJ)
64 	struct	kobject kobj;
65 #endif
66 	unsigned long _flags;
67 	void	*data;
68 #if defined(CONFIG_SPARC)
69 	const char *path_component_name;
70 	unsigned int unique_id;
71 	struct of_irq_controller *irq_trans;
72 #endif
73 };
74 
75 #define MAX_PHANDLE_ARGS 16
76 struct of_phandle_args {
77 	struct device_node *np;
78 	int args_count;
79 	uint32_t args[MAX_PHANDLE_ARGS];
80 };
81 
82 struct of_phandle_iterator {
83 	/* Common iterator information */
84 	const char *cells_name;
85 	int cell_count;
86 	const struct device_node *parent;
87 
88 	/* List size information */
89 	const __be32 *list_end;
90 	const __be32 *phandle_end;
91 
92 	/* Current position state */
93 	const __be32 *cur;
94 	uint32_t cur_count;
95 	phandle phandle;
96 	struct device_node *node;
97 };
98 
99 struct of_reconfig_data {
100 	struct device_node	*dn;
101 	struct property		*prop;
102 	struct property		*old_prop;
103 };
104 
105 /* initialize a node */
106 extern struct kobj_type of_node_ktype;
107 extern const struct fwnode_operations of_fwnode_ops;
108 static inline void of_node_init(struct device_node *node)
109 {
110 #if defined(CONFIG_OF_KOBJ)
111 	kobject_init(&node->kobj, &of_node_ktype);
112 #endif
113 	node->fwnode.ops = &of_fwnode_ops;
114 }
115 
116 #if defined(CONFIG_OF_KOBJ)
117 #define of_node_kobj(n) (&(n)->kobj)
118 #else
119 #define of_node_kobj(n) NULL
120 #endif
121 
122 #ifdef CONFIG_OF_DYNAMIC
123 extern struct device_node *of_node_get(struct device_node *node);
124 extern void of_node_put(struct device_node *node);
125 #else /* CONFIG_OF_DYNAMIC */
126 /* Dummy ref counting routines - to be implemented later */
127 static inline struct device_node *of_node_get(struct device_node *node)
128 {
129 	return node;
130 }
131 static inline void of_node_put(struct device_node *node) { }
132 #endif /* !CONFIG_OF_DYNAMIC */
133 
134 /* Pointer for first entry in chain of all nodes. */
135 extern struct device_node *of_root;
136 extern struct device_node *of_chosen;
137 extern struct device_node *of_aliases;
138 extern struct device_node *of_stdout;
139 extern raw_spinlock_t devtree_lock;
140 
141 /* flag descriptions (need to be visible even when !CONFIG_OF) */
142 #define OF_DYNAMIC	1 /* node and properties were allocated via kmalloc */
143 #define OF_DETACHED	2 /* node has been detached from the device tree */
144 #define OF_POPULATED	3 /* device already created for the node */
145 #define OF_POPULATED_BUS	4 /* of_platform_populate recursed to children of this node */
146 
147 #define OF_BAD_ADDR	((u64)-1)
148 
149 #ifdef CONFIG_OF
150 void of_core_init(void);
151 
152 static inline bool is_of_node(const struct fwnode_handle *fwnode)
153 {
154 	return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &of_fwnode_ops;
155 }
156 
157 #define to_of_node(__fwnode)						\
158 	({								\
159 		typeof(__fwnode) __to_of_node_fwnode = (__fwnode);	\
160 									\
161 		is_of_node(__to_of_node_fwnode) ?			\
162 			container_of(__to_of_node_fwnode,		\
163 				     struct device_node, fwnode) :	\
164 			NULL;						\
165 	})
166 
167 #define of_fwnode_handle(node)						\
168 	({								\
169 		typeof(node) __of_fwnode_handle_node = (node);		\
170 									\
171 		__of_fwnode_handle_node ?				\
172 			&__of_fwnode_handle_node->fwnode : NULL;	\
173 	})
174 
175 static inline bool of_have_populated_dt(void)
176 {
177 	return of_root != NULL;
178 }
179 
180 static inline bool of_node_is_root(const struct device_node *node)
181 {
182 	return node && (node->parent == NULL);
183 }
184 
185 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
186 {
187 	return test_bit(flag, &n->_flags);
188 }
189 
190 static inline int of_node_test_and_set_flag(struct device_node *n,
191 					    unsigned long flag)
192 {
193 	return test_and_set_bit(flag, &n->_flags);
194 }
195 
196 static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
197 {
198 	set_bit(flag, &n->_flags);
199 }
200 
201 static inline void of_node_clear_flag(struct device_node *n, unsigned long flag)
202 {
203 	clear_bit(flag, &n->_flags);
204 }
205 
206 #if defined(CONFIG_OF_DYNAMIC) || defined(CONFIG_SPARC)
207 static inline int of_property_check_flag(struct property *p, unsigned long flag)
208 {
209 	return test_bit(flag, &p->_flags);
210 }
211 
212 static inline void of_property_set_flag(struct property *p, unsigned long flag)
213 {
214 	set_bit(flag, &p->_flags);
215 }
216 
217 static inline void of_property_clear_flag(struct property *p, unsigned long flag)
218 {
219 	clear_bit(flag, &p->_flags);
220 }
221 #endif
222 
223 extern struct device_node *__of_find_all_nodes(struct device_node *prev);
224 extern struct device_node *of_find_all_nodes(struct device_node *prev);
225 
226 /*
227  * OF address retrieval & translation
228  */
229 
230 /* Helper to read a big number; size is in cells (not bytes) */
231 static inline u64 of_read_number(const __be32 *cell, int size)
232 {
233 	u64 r = 0;
234 	while (size--)
235 		r = (r << 32) | be32_to_cpu(*(cell++));
236 	return r;
237 }
238 
239 /* Like of_read_number, but we want an unsigned long result */
240 static inline unsigned long of_read_ulong(const __be32 *cell, int size)
241 {
242 	/* toss away upper bits if unsigned long is smaller than u64 */
243 	return of_read_number(cell, size);
244 }
245 
246 #if defined(CONFIG_SPARC)
247 #include <asm/prom.h>
248 #endif
249 
250 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
251 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
252 
253 extern bool of_node_name_eq(const struct device_node *np, const char *name);
254 extern bool of_node_name_prefix(const struct device_node *np, const char *prefix);
255 
256 static inline const char *of_node_full_name(const struct device_node *np)
257 {
258 	return np ? np->full_name : "<no-node>";
259 }
260 
261 #define for_each_of_allnodes_from(from, dn) \
262 	for (dn = __of_find_all_nodes(from); dn; dn = __of_find_all_nodes(dn))
263 #define for_each_of_allnodes(dn) for_each_of_allnodes_from(NULL, dn)
264 extern struct device_node *of_find_node_by_name(struct device_node *from,
265 	const char *name);
266 extern struct device_node *of_find_node_by_type(struct device_node *from,
267 	const char *type);
268 extern struct device_node *of_find_compatible_node(struct device_node *from,
269 	const char *type, const char *compat);
270 extern struct device_node *of_find_matching_node_and_match(
271 	struct device_node *from,
272 	const struct of_device_id *matches,
273 	const struct of_device_id **match);
274 
275 extern struct device_node *of_find_node_opts_by_path(const char *path,
276 	const char **opts);
277 static inline struct device_node *of_find_node_by_path(const char *path)
278 {
279 	return of_find_node_opts_by_path(path, NULL);
280 }
281 
282 extern struct device_node *of_find_node_by_phandle(phandle handle);
283 extern struct device_node *of_get_parent(const struct device_node *node);
284 extern struct device_node *of_get_next_parent(struct device_node *node);
285 extern struct device_node *of_get_next_child(const struct device_node *node,
286 					     struct device_node *prev);
287 extern struct device_node *of_get_next_available_child(
288 	const struct device_node *node, struct device_node *prev);
289 
290 extern struct device_node *of_get_compatible_child(const struct device_node *parent,
291 					const char *compatible);
292 extern struct device_node *of_get_child_by_name(const struct device_node *node,
293 					const char *name);
294 
295 /* cache lookup */
296 extern struct device_node *of_find_next_cache_node(const struct device_node *);
297 extern int of_find_last_cache_level(unsigned int cpu);
298 extern struct device_node *of_find_node_with_property(
299 	struct device_node *from, const char *prop_name);
300 
301 extern struct property *of_find_property(const struct device_node *np,
302 					 const char *name,
303 					 int *lenp);
304 extern int of_property_count_elems_of_size(const struct device_node *np,
305 				const char *propname, int elem_size);
306 extern int of_property_read_u32_index(const struct device_node *np,
307 				       const char *propname,
308 				       u32 index, u32 *out_value);
309 extern int of_property_read_u64_index(const struct device_node *np,
310 				       const char *propname,
311 				       u32 index, u64 *out_value);
312 extern int of_property_read_variable_u8_array(const struct device_node *np,
313 					const char *propname, u8 *out_values,
314 					size_t sz_min, size_t sz_max);
315 extern int of_property_read_variable_u16_array(const struct device_node *np,
316 					const char *propname, u16 *out_values,
317 					size_t sz_min, size_t sz_max);
318 extern int of_property_read_variable_u32_array(const struct device_node *np,
319 					const char *propname,
320 					u32 *out_values,
321 					size_t sz_min,
322 					size_t sz_max);
323 extern int of_property_read_u64(const struct device_node *np,
324 				const char *propname, u64 *out_value);
325 extern int of_property_read_variable_u64_array(const struct device_node *np,
326 					const char *propname,
327 					u64 *out_values,
328 					size_t sz_min,
329 					size_t sz_max);
330 
331 extern int of_property_read_string(const struct device_node *np,
332 				   const char *propname,
333 				   const char **out_string);
334 extern int of_property_match_string(const struct device_node *np,
335 				    const char *propname,
336 				    const char *string);
337 extern int of_property_read_string_helper(const struct device_node *np,
338 					      const char *propname,
339 					      const char **out_strs, size_t sz, int index);
340 extern int of_device_is_compatible(const struct device_node *device,
341 				   const char *);
342 extern int of_device_compatible_match(struct device_node *device,
343 				      const char *const *compat);
344 extern bool of_device_is_available(const struct device_node *device);
345 extern bool of_device_is_big_endian(const struct device_node *device);
346 extern const void *of_get_property(const struct device_node *node,
347 				const char *name,
348 				int *lenp);
349 extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
350 extern struct device_node *of_get_next_cpu_node(struct device_node *prev);
351 
352 #define for_each_property_of_node(dn, pp) \
353 	for (pp = dn->properties; pp != NULL; pp = pp->next)
354 
355 extern int of_n_addr_cells(struct device_node *np);
356 extern int of_n_size_cells(struct device_node *np);
357 extern const struct of_device_id *of_match_node(
358 	const struct of_device_id *matches, const struct device_node *node);
359 extern int of_modalias_node(struct device_node *node, char *modalias, int len);
360 extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args);
361 extern struct device_node *of_parse_phandle(const struct device_node *np,
362 					    const char *phandle_name,
363 					    int index);
364 extern int of_parse_phandle_with_args(const struct device_node *np,
365 	const char *list_name, const char *cells_name, int index,
366 	struct of_phandle_args *out_args);
367 extern int of_parse_phandle_with_args_map(const struct device_node *np,
368 	const char *list_name, const char *stem_name, int index,
369 	struct of_phandle_args *out_args);
370 extern int of_parse_phandle_with_fixed_args(const struct device_node *np,
371 	const char *list_name, int cells_count, int index,
372 	struct of_phandle_args *out_args);
373 extern int of_count_phandle_with_args(const struct device_node *np,
374 	const char *list_name, const char *cells_name);
375 
376 /* phandle iterator functions */
377 extern int of_phandle_iterator_init(struct of_phandle_iterator *it,
378 				    const struct device_node *np,
379 				    const char *list_name,
380 				    const char *cells_name,
381 				    int cell_count);
382 
383 extern int of_phandle_iterator_next(struct of_phandle_iterator *it);
384 extern int of_phandle_iterator_args(struct of_phandle_iterator *it,
385 				    uint32_t *args,
386 				    int size);
387 
388 extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
389 extern int of_alias_get_id(struct device_node *np, const char *stem);
390 extern int of_alias_get_highest_id(const char *stem);
391 extern int of_alias_get_alias_list(const struct of_device_id *matches,
392 				   const char *stem, unsigned long *bitmap,
393 				   unsigned int nbits);
394 
395 extern int of_machine_is_compatible(const char *compat);
396 
397 extern int of_add_property(struct device_node *np, struct property *prop);
398 extern int of_remove_property(struct device_node *np, struct property *prop);
399 extern int of_update_property(struct device_node *np, struct property *newprop);
400 
401 /* For updating the device tree at runtime */
402 #define OF_RECONFIG_ATTACH_NODE		0x0001
403 #define OF_RECONFIG_DETACH_NODE		0x0002
404 #define OF_RECONFIG_ADD_PROPERTY	0x0003
405 #define OF_RECONFIG_REMOVE_PROPERTY	0x0004
406 #define OF_RECONFIG_UPDATE_PROPERTY	0x0005
407 
408 extern int of_attach_node(struct device_node *);
409 extern int of_detach_node(struct device_node *);
410 
411 #define of_match_ptr(_ptr)	(_ptr)
412 
413 /**
414  * of_property_read_u8_array - Find and read an array of u8 from a property.
415  *
416  * @np:		device node from which the property value is to be read.
417  * @propname:	name of the property to be searched.
418  * @out_values:	pointer to return value, modified only if return value is 0.
419  * @sz:		number of array elements to read
420  *
421  * Search for a property in a device node and read 8-bit value(s) from
422  * it. Returns 0 on success, -EINVAL if the property does not exist,
423  * -ENODATA if property does not have a value, and -EOVERFLOW if the
424  * property data isn't large enough.
425  *
426  * dts entry of array should be like:
427  *	property = /bits/ 8 <0x50 0x60 0x70>;
428  *
429  * The out_values is modified only if a valid u8 value can be decoded.
430  */
431 static inline int of_property_read_u8_array(const struct device_node *np,
432 					    const char *propname,
433 					    u8 *out_values, size_t sz)
434 {
435 	int ret = of_property_read_variable_u8_array(np, propname, out_values,
436 						     sz, 0);
437 	if (ret >= 0)
438 		return 0;
439 	else
440 		return ret;
441 }
442 
443 /**
444  * of_property_read_u16_array - Find and read an array of u16 from a property.
445  *
446  * @np:		device node from which the property value is to be read.
447  * @propname:	name of the property to be searched.
448  * @out_values:	pointer to return value, modified only if return value is 0.
449  * @sz:		number of array elements to read
450  *
451  * Search for a property in a device node and read 16-bit value(s) from
452  * it. Returns 0 on success, -EINVAL if the property does not exist,
453  * -ENODATA if property does not have a value, and -EOVERFLOW if the
454  * property data isn't large enough.
455  *
456  * dts entry of array should be like:
457  *	property = /bits/ 16 <0x5000 0x6000 0x7000>;
458  *
459  * The out_values is modified only if a valid u16 value can be decoded.
460  */
461 static inline int of_property_read_u16_array(const struct device_node *np,
462 					     const char *propname,
463 					     u16 *out_values, size_t sz)
464 {
465 	int ret = of_property_read_variable_u16_array(np, propname, out_values,
466 						      sz, 0);
467 	if (ret >= 0)
468 		return 0;
469 	else
470 		return ret;
471 }
472 
473 /**
474  * of_property_read_u32_array - Find and read an array of 32 bit integers
475  * from a property.
476  *
477  * @np:		device node from which the property value is to be read.
478  * @propname:	name of the property to be searched.
479  * @out_values:	pointer to return value, modified only if return value is 0.
480  * @sz:		number of array elements to read
481  *
482  * Search for a property in a device node and read 32-bit value(s) from
483  * it. Returns 0 on success, -EINVAL if the property does not exist,
484  * -ENODATA if property does not have a value, and -EOVERFLOW if the
485  * property data isn't large enough.
486  *
487  * The out_values is modified only if a valid u32 value can be decoded.
488  */
489 static inline int of_property_read_u32_array(const struct device_node *np,
490 					     const char *propname,
491 					     u32 *out_values, size_t sz)
492 {
493 	int ret = of_property_read_variable_u32_array(np, propname, out_values,
494 						      sz, 0);
495 	if (ret >= 0)
496 		return 0;
497 	else
498 		return ret;
499 }
500 
501 /**
502  * of_property_read_u64_array - Find and read an array of 64 bit integers
503  * from a property.
504  *
505  * @np:		device node from which the property value is to be read.
506  * @propname:	name of the property to be searched.
507  * @out_values:	pointer to return value, modified only if return value is 0.
508  * @sz:		number of array elements to read
509  *
510  * Search for a property in a device node and read 64-bit value(s) from
511  * it. Returns 0 on success, -EINVAL if the property does not exist,
512  * -ENODATA if property does not have a value, and -EOVERFLOW if the
513  * property data isn't large enough.
514  *
515  * The out_values is modified only if a valid u64 value can be decoded.
516  */
517 static inline int of_property_read_u64_array(const struct device_node *np,
518 					     const char *propname,
519 					     u64 *out_values, size_t sz)
520 {
521 	int ret = of_property_read_variable_u64_array(np, propname, out_values,
522 						      sz, 0);
523 	if (ret >= 0)
524 		return 0;
525 	else
526 		return ret;
527 }
528 
529 /*
530  * struct property *prop;
531  * const __be32 *p;
532  * u32 u;
533  *
534  * of_property_for_each_u32(np, "propname", prop, p, u)
535  *         printk("U32 value: %x\n", u);
536  */
537 const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
538 			       u32 *pu);
539 /*
540  * struct property *prop;
541  * const char *s;
542  *
543  * of_property_for_each_string(np, "propname", prop, s)
544  *         printk("String value: %s\n", s);
545  */
546 const char *of_prop_next_string(struct property *prop, const char *cur);
547 
548 bool of_console_check(struct device_node *dn, char *name, int index);
549 
550 extern int of_cpu_node_to_id(struct device_node *np);
551 
552 int of_map_rid(struct device_node *np, u32 rid,
553 	       const char *map_name, const char *map_mask_name,
554 	       struct device_node **target, u32 *id_out);
555 
556 #else /* CONFIG_OF */
557 
558 static inline void of_core_init(void)
559 {
560 }
561 
562 static inline bool is_of_node(const struct fwnode_handle *fwnode)
563 {
564 	return false;
565 }
566 
567 static inline struct device_node *to_of_node(const struct fwnode_handle *fwnode)
568 {
569 	return NULL;
570 }
571 
572 static inline bool of_node_name_eq(const struct device_node *np, const char *name)
573 {
574 	return false;
575 }
576 
577 static inline bool of_node_name_prefix(const struct device_node *np, const char *prefix)
578 {
579 	return false;
580 }
581 
582 static inline const char* of_node_full_name(const struct device_node *np)
583 {
584 	return "<no-node>";
585 }
586 
587 static inline struct device_node *of_find_node_by_name(struct device_node *from,
588 	const char *name)
589 {
590 	return NULL;
591 }
592 
593 static inline struct device_node *of_find_node_by_type(struct device_node *from,
594 	const char *type)
595 {
596 	return NULL;
597 }
598 
599 static inline struct device_node *of_find_matching_node_and_match(
600 	struct device_node *from,
601 	const struct of_device_id *matches,
602 	const struct of_device_id **match)
603 {
604 	return NULL;
605 }
606 
607 static inline struct device_node *of_find_node_by_path(const char *path)
608 {
609 	return NULL;
610 }
611 
612 static inline struct device_node *of_find_node_opts_by_path(const char *path,
613 	const char **opts)
614 {
615 	return NULL;
616 }
617 
618 static inline struct device_node *of_find_node_by_phandle(phandle handle)
619 {
620 	return NULL;
621 }
622 
623 static inline struct device_node *of_get_parent(const struct device_node *node)
624 {
625 	return NULL;
626 }
627 
628 static inline struct device_node *of_get_next_child(
629 	const struct device_node *node, struct device_node *prev)
630 {
631 	return NULL;
632 }
633 
634 static inline struct device_node *of_get_next_available_child(
635 	const struct device_node *node, struct device_node *prev)
636 {
637 	return NULL;
638 }
639 
640 static inline struct device_node *of_find_node_with_property(
641 	struct device_node *from, const char *prop_name)
642 {
643 	return NULL;
644 }
645 
646 #define of_fwnode_handle(node) NULL
647 
648 static inline bool of_have_populated_dt(void)
649 {
650 	return false;
651 }
652 
653 static inline struct device_node *of_get_compatible_child(const struct device_node *parent,
654 					const char *compatible)
655 {
656 	return NULL;
657 }
658 
659 static inline struct device_node *of_get_child_by_name(
660 					const struct device_node *node,
661 					const char *name)
662 {
663 	return NULL;
664 }
665 
666 static inline int of_device_is_compatible(const struct device_node *device,
667 					  const char *name)
668 {
669 	return 0;
670 }
671 
672 static inline  int of_device_compatible_match(struct device_node *device,
673 					      const char *const *compat)
674 {
675 	return 0;
676 }
677 
678 static inline bool of_device_is_available(const struct device_node *device)
679 {
680 	return false;
681 }
682 
683 static inline bool of_device_is_big_endian(const struct device_node *device)
684 {
685 	return false;
686 }
687 
688 static inline struct property *of_find_property(const struct device_node *np,
689 						const char *name,
690 						int *lenp)
691 {
692 	return NULL;
693 }
694 
695 static inline struct device_node *of_find_compatible_node(
696 						struct device_node *from,
697 						const char *type,
698 						const char *compat)
699 {
700 	return NULL;
701 }
702 
703 static inline int of_property_count_elems_of_size(const struct device_node *np,
704 			const char *propname, int elem_size)
705 {
706 	return -ENOSYS;
707 }
708 
709 static inline int of_property_read_u8_array(const struct device_node *np,
710 			const char *propname, u8 *out_values, size_t sz)
711 {
712 	return -ENOSYS;
713 }
714 
715 static inline int of_property_read_u16_array(const struct device_node *np,
716 			const char *propname, u16 *out_values, size_t sz)
717 {
718 	return -ENOSYS;
719 }
720 
721 static inline int of_property_read_u32_array(const struct device_node *np,
722 					     const char *propname,
723 					     u32 *out_values, size_t sz)
724 {
725 	return -ENOSYS;
726 }
727 
728 static inline int of_property_read_u64_array(const struct device_node *np,
729 					     const char *propname,
730 					     u64 *out_values, size_t sz)
731 {
732 	return -ENOSYS;
733 }
734 
735 static inline int of_property_read_u32_index(const struct device_node *np,
736 			const char *propname, u32 index, u32 *out_value)
737 {
738 	return -ENOSYS;
739 }
740 
741 static inline int of_property_read_u64_index(const struct device_node *np,
742 			const char *propname, u32 index, u64 *out_value)
743 {
744 	return -ENOSYS;
745 }
746 
747 static inline const void *of_get_property(const struct device_node *node,
748 				const char *name,
749 				int *lenp)
750 {
751 	return NULL;
752 }
753 
754 static inline struct device_node *of_get_cpu_node(int cpu,
755 					unsigned int *thread)
756 {
757 	return NULL;
758 }
759 
760 static inline struct device_node *of_get_next_cpu_node(struct device_node *prev)
761 {
762 	return NULL;
763 }
764 
765 static inline int of_n_addr_cells(struct device_node *np)
766 {
767 	return 0;
768 
769 }
770 static inline int of_n_size_cells(struct device_node *np)
771 {
772 	return 0;
773 }
774 
775 static inline int of_property_read_variable_u8_array(const struct device_node *np,
776 					const char *propname, u8 *out_values,
777 					size_t sz_min, size_t sz_max)
778 {
779 	return -ENOSYS;
780 }
781 
782 static inline int of_property_read_variable_u16_array(const struct device_node *np,
783 					const char *propname, u16 *out_values,
784 					size_t sz_min, size_t sz_max)
785 {
786 	return -ENOSYS;
787 }
788 
789 static inline int of_property_read_variable_u32_array(const struct device_node *np,
790 					const char *propname,
791 					u32 *out_values,
792 					size_t sz_min,
793 					size_t sz_max)
794 {
795 	return -ENOSYS;
796 }
797 
798 static inline int of_property_read_u64(const struct device_node *np,
799 				       const char *propname, u64 *out_value)
800 {
801 	return -ENOSYS;
802 }
803 
804 static inline int of_property_read_variable_u64_array(const struct device_node *np,
805 					const char *propname,
806 					u64 *out_values,
807 					size_t sz_min,
808 					size_t sz_max)
809 {
810 	return -ENOSYS;
811 }
812 
813 static inline int of_property_read_string(const struct device_node *np,
814 					  const char *propname,
815 					  const char **out_string)
816 {
817 	return -ENOSYS;
818 }
819 
820 static inline int of_property_match_string(const struct device_node *np,
821 					   const char *propname,
822 					   const char *string)
823 {
824 	return -ENOSYS;
825 }
826 
827 static inline int of_property_read_string_helper(const struct device_node *np,
828 						 const char *propname,
829 						 const char **out_strs, size_t sz, int index)
830 {
831 	return -ENOSYS;
832 }
833 
834 static inline struct device_node *of_parse_phandle(const struct device_node *np,
835 						   const char *phandle_name,
836 						   int index)
837 {
838 	return NULL;
839 }
840 
841 static inline int of_parse_phandle_with_args(const struct device_node *np,
842 					     const char *list_name,
843 					     const char *cells_name,
844 					     int index,
845 					     struct of_phandle_args *out_args)
846 {
847 	return -ENOSYS;
848 }
849 
850 static inline int of_parse_phandle_with_args_map(const struct device_node *np,
851 						 const char *list_name,
852 						 const char *stem_name,
853 						 int index,
854 						 struct of_phandle_args *out_args)
855 {
856 	return -ENOSYS;
857 }
858 
859 static inline int of_parse_phandle_with_fixed_args(const struct device_node *np,
860 	const char *list_name, int cells_count, int index,
861 	struct of_phandle_args *out_args)
862 {
863 	return -ENOSYS;
864 }
865 
866 static inline int of_count_phandle_with_args(struct device_node *np,
867 					     const char *list_name,
868 					     const char *cells_name)
869 {
870 	return -ENOSYS;
871 }
872 
873 static inline int of_phandle_iterator_init(struct of_phandle_iterator *it,
874 					   const struct device_node *np,
875 					   const char *list_name,
876 					   const char *cells_name,
877 					   int cell_count)
878 {
879 	return -ENOSYS;
880 }
881 
882 static inline int of_phandle_iterator_next(struct of_phandle_iterator *it)
883 {
884 	return -ENOSYS;
885 }
886 
887 static inline int of_phandle_iterator_args(struct of_phandle_iterator *it,
888 					   uint32_t *args,
889 					   int size)
890 {
891 	return 0;
892 }
893 
894 static inline int of_alias_get_id(struct device_node *np, const char *stem)
895 {
896 	return -ENOSYS;
897 }
898 
899 static inline int of_alias_get_highest_id(const char *stem)
900 {
901 	return -ENOSYS;
902 }
903 
904 static inline int of_alias_get_alias_list(const struct of_device_id *matches,
905 					  const char *stem, unsigned long *bitmap,
906 					  unsigned int nbits)
907 {
908 	return -ENOSYS;
909 }
910 
911 static inline int of_machine_is_compatible(const char *compat)
912 {
913 	return 0;
914 }
915 
916 static inline bool of_console_check(const struct device_node *dn, const char *name, int index)
917 {
918 	return false;
919 }
920 
921 static inline const __be32 *of_prop_next_u32(struct property *prop,
922 		const __be32 *cur, u32 *pu)
923 {
924 	return NULL;
925 }
926 
927 static inline const char *of_prop_next_string(struct property *prop,
928 		const char *cur)
929 {
930 	return NULL;
931 }
932 
933 static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
934 {
935 	return 0;
936 }
937 
938 static inline int of_node_test_and_set_flag(struct device_node *n,
939 					    unsigned long flag)
940 {
941 	return 0;
942 }
943 
944 static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
945 {
946 }
947 
948 static inline void of_node_clear_flag(struct device_node *n, unsigned long flag)
949 {
950 }
951 
952 static inline int of_property_check_flag(struct property *p, unsigned long flag)
953 {
954 	return 0;
955 }
956 
957 static inline void of_property_set_flag(struct property *p, unsigned long flag)
958 {
959 }
960 
961 static inline void of_property_clear_flag(struct property *p, unsigned long flag)
962 {
963 }
964 
965 static inline int of_cpu_node_to_id(struct device_node *np)
966 {
967 	return -ENODEV;
968 }
969 
970 static inline int of_map_rid(struct device_node *np, u32 rid,
971 			     const char *map_name, const char *map_mask_name,
972 			     struct device_node **target, u32 *id_out)
973 {
974 	return -EINVAL;
975 }
976 
977 #define of_match_ptr(_ptr)	NULL
978 #define of_match_node(_matches, _node)	NULL
979 #endif /* CONFIG_OF */
980 
981 /* Default string compare functions, Allow arch asm/prom.h to override */
982 #if !defined(of_compat_cmp)
983 #define of_compat_cmp(s1, s2, l)	strcasecmp((s1), (s2))
984 #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
985 #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
986 #endif
987 
988 #if defined(CONFIG_OF) && defined(CONFIG_NUMA)
989 extern int of_node_to_nid(struct device_node *np);
990 #else
991 static inline int of_node_to_nid(struct device_node *device)
992 {
993 	return NUMA_NO_NODE;
994 }
995 #endif
996 
997 #ifdef CONFIG_OF_NUMA
998 extern int of_numa_init(void);
999 #else
1000 static inline int of_numa_init(void)
1001 {
1002 	return -ENOSYS;
1003 }
1004 #endif
1005 
1006 static inline struct device_node *of_find_matching_node(
1007 	struct device_node *from,
1008 	const struct of_device_id *matches)
1009 {
1010 	return of_find_matching_node_and_match(from, matches, NULL);
1011 }
1012 
1013 static inline const char *of_node_get_device_type(const struct device_node *np)
1014 {
1015 	return of_get_property(np, "device_type", NULL);
1016 }
1017 
1018 static inline bool of_node_is_type(const struct device_node *np, const char *type)
1019 {
1020 	const char *match = of_node_get_device_type(np);
1021 
1022 	return np && match && type && !strcmp(match, type);
1023 }
1024 
1025 /**
1026  * of_property_count_u8_elems - Count the number of u8 elements in a property
1027  *
1028  * @np:		device node from which the property value is to be read.
1029  * @propname:	name of the property to be searched.
1030  *
1031  * Search for a property in a device node and count the number of u8 elements
1032  * in it. Returns number of elements on sucess, -EINVAL if the property does
1033  * not exist or its length does not match a multiple of u8 and -ENODATA if the
1034  * property does not have a value.
1035  */
1036 static inline int of_property_count_u8_elems(const struct device_node *np,
1037 				const char *propname)
1038 {
1039 	return of_property_count_elems_of_size(np, propname, sizeof(u8));
1040 }
1041 
1042 /**
1043  * of_property_count_u16_elems - Count the number of u16 elements in a property
1044  *
1045  * @np:		device node from which the property value is to be read.
1046  * @propname:	name of the property to be searched.
1047  *
1048  * Search for a property in a device node and count the number of u16 elements
1049  * in it. Returns number of elements on sucess, -EINVAL if the property does
1050  * not exist or its length does not match a multiple of u16 and -ENODATA if the
1051  * property does not have a value.
1052  */
1053 static inline int of_property_count_u16_elems(const struct device_node *np,
1054 				const char *propname)
1055 {
1056 	return of_property_count_elems_of_size(np, propname, sizeof(u16));
1057 }
1058 
1059 /**
1060  * of_property_count_u32_elems - Count the number of u32 elements in a property
1061  *
1062  * @np:		device node from which the property value is to be read.
1063  * @propname:	name of the property to be searched.
1064  *
1065  * Search for a property in a device node and count the number of u32 elements
1066  * in it. Returns number of elements on sucess, -EINVAL if the property does
1067  * not exist or its length does not match a multiple of u32 and -ENODATA if the
1068  * property does not have a value.
1069  */
1070 static inline int of_property_count_u32_elems(const struct device_node *np,
1071 				const char *propname)
1072 {
1073 	return of_property_count_elems_of_size(np, propname, sizeof(u32));
1074 }
1075 
1076 /**
1077  * of_property_count_u64_elems - Count the number of u64 elements in a property
1078  *
1079  * @np:		device node from which the property value is to be read.
1080  * @propname:	name of the property to be searched.
1081  *
1082  * Search for a property in a device node and count the number of u64 elements
1083  * in it. Returns number of elements on sucess, -EINVAL if the property does
1084  * not exist or its length does not match a multiple of u64 and -ENODATA if the
1085  * property does not have a value.
1086  */
1087 static inline int of_property_count_u64_elems(const struct device_node *np,
1088 				const char *propname)
1089 {
1090 	return of_property_count_elems_of_size(np, propname, sizeof(u64));
1091 }
1092 
1093 /**
1094  * of_property_read_string_array() - Read an array of strings from a multiple
1095  * strings property.
1096  * @np:		device node from which the property value is to be read.
1097  * @propname:	name of the property to be searched.
1098  * @out_strs:	output array of string pointers.
1099  * @sz:		number of array elements to read.
1100  *
1101  * Search for a property in a device tree node and retrieve a list of
1102  * terminated string values (pointer to data, not a copy) in that property.
1103  *
1104  * If @out_strs is NULL, the number of strings in the property is returned.
1105  */
1106 static inline int of_property_read_string_array(const struct device_node *np,
1107 						const char *propname, const char **out_strs,
1108 						size_t sz)
1109 {
1110 	return of_property_read_string_helper(np, propname, out_strs, sz, 0);
1111 }
1112 
1113 /**
1114  * of_property_count_strings() - Find and return the number of strings from a
1115  * multiple strings property.
1116  * @np:		device node from which the property value is to be read.
1117  * @propname:	name of the property to be searched.
1118  *
1119  * Search for a property in a device tree node and retrieve the number of null
1120  * terminated string contain in it. Returns the number of strings on
1121  * success, -EINVAL if the property does not exist, -ENODATA if property
1122  * does not have a value, and -EILSEQ if the string is not null-terminated
1123  * within the length of the property data.
1124  */
1125 static inline int of_property_count_strings(const struct device_node *np,
1126 					    const char *propname)
1127 {
1128 	return of_property_read_string_helper(np, propname, NULL, 0, 0);
1129 }
1130 
1131 /**
1132  * of_property_read_string_index() - Find and read a string from a multiple
1133  * strings property.
1134  * @np:		device node from which the property value is to be read.
1135  * @propname:	name of the property to be searched.
1136  * @index:	index of the string in the list of strings
1137  * @out_string:	pointer to null terminated return string, modified only if
1138  *		return value is 0.
1139  *
1140  * Search for a property in a device tree node and retrieve a null
1141  * terminated string value (pointer to data, not a copy) in the list of strings
1142  * contained in that property.
1143  * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if
1144  * property does not have a value, and -EILSEQ if the string is not
1145  * null-terminated within the length of the property data.
1146  *
1147  * The out_string pointer is modified only if a valid string can be decoded.
1148  */
1149 static inline int of_property_read_string_index(const struct device_node *np,
1150 						const char *propname,
1151 						int index, const char **output)
1152 {
1153 	int rc = of_property_read_string_helper(np, propname, output, 1, index);
1154 	return rc < 0 ? rc : 0;
1155 }
1156 
1157 /**
1158  * of_property_read_bool - Findfrom a property
1159  * @np:		device node from which the property value is to be read.
1160  * @propname:	name of the property to be searched.
1161  *
1162  * Search for a property in a device node.
1163  * Returns true if the property exists false otherwise.
1164  */
1165 static inline bool of_property_read_bool(const struct device_node *np,
1166 					 const char *propname)
1167 {
1168 	struct property *prop = of_find_property(np, propname, NULL);
1169 
1170 	return prop ? true : false;
1171 }
1172 
1173 static inline int of_property_read_u8(const struct device_node *np,
1174 				       const char *propname,
1175 				       u8 *out_value)
1176 {
1177 	return of_property_read_u8_array(np, propname, out_value, 1);
1178 }
1179 
1180 static inline int of_property_read_u16(const struct device_node *np,
1181 				       const char *propname,
1182 				       u16 *out_value)
1183 {
1184 	return of_property_read_u16_array(np, propname, out_value, 1);
1185 }
1186 
1187 static inline int of_property_read_u32(const struct device_node *np,
1188 				       const char *propname,
1189 				       u32 *out_value)
1190 {
1191 	return of_property_read_u32_array(np, propname, out_value, 1);
1192 }
1193 
1194 static inline int of_property_read_s32(const struct device_node *np,
1195 				       const char *propname,
1196 				       s32 *out_value)
1197 {
1198 	return of_property_read_u32(np, propname, (u32*) out_value);
1199 }
1200 
1201 #define of_for_each_phandle(it, err, np, ln, cn, cc)			\
1202 	for (of_phandle_iterator_init((it), (np), (ln), (cn), (cc)),	\
1203 	     err = of_phandle_iterator_next(it);			\
1204 	     err == 0;							\
1205 	     err = of_phandle_iterator_next(it))
1206 
1207 #define of_property_for_each_u32(np, propname, prop, p, u)	\
1208 	for (prop = of_find_property(np, propname, NULL),	\
1209 		p = of_prop_next_u32(prop, NULL, &u);		\
1210 		p;						\
1211 		p = of_prop_next_u32(prop, p, &u))
1212 
1213 #define of_property_for_each_string(np, propname, prop, s)	\
1214 	for (prop = of_find_property(np, propname, NULL),	\
1215 		s = of_prop_next_string(prop, NULL);		\
1216 		s;						\
1217 		s = of_prop_next_string(prop, s))
1218 
1219 #define for_each_node_by_name(dn, name) \
1220 	for (dn = of_find_node_by_name(NULL, name); dn; \
1221 	     dn = of_find_node_by_name(dn, name))
1222 #define for_each_node_by_type(dn, type) \
1223 	for (dn = of_find_node_by_type(NULL, type); dn; \
1224 	     dn = of_find_node_by_type(dn, type))
1225 #define for_each_compatible_node(dn, type, compatible) \
1226 	for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
1227 	     dn = of_find_compatible_node(dn, type, compatible))
1228 #define for_each_matching_node(dn, matches) \
1229 	for (dn = of_find_matching_node(NULL, matches); dn; \
1230 	     dn = of_find_matching_node(dn, matches))
1231 #define for_each_matching_node_and_match(dn, matches, match) \
1232 	for (dn = of_find_matching_node_and_match(NULL, matches, match); \
1233 	     dn; dn = of_find_matching_node_and_match(dn, matches, match))
1234 
1235 #define for_each_child_of_node(parent, child) \
1236 	for (child = of_get_next_child(parent, NULL); child != NULL; \
1237 	     child = of_get_next_child(parent, child))
1238 #define for_each_available_child_of_node(parent, child) \
1239 	for (child = of_get_next_available_child(parent, NULL); child != NULL; \
1240 	     child = of_get_next_available_child(parent, child))
1241 
1242 #define for_each_of_cpu_node(cpu) \
1243 	for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
1244 	     cpu = of_get_next_cpu_node(cpu))
1245 
1246 #define for_each_node_with_property(dn, prop_name) \
1247 	for (dn = of_find_node_with_property(NULL, prop_name); dn; \
1248 	     dn = of_find_node_with_property(dn, prop_name))
1249 
1250 static inline int of_get_child_count(const struct device_node *np)
1251 {
1252 	struct device_node *child;
1253 	int num = 0;
1254 
1255 	for_each_child_of_node(np, child)
1256 		num++;
1257 
1258 	return num;
1259 }
1260 
1261 static inline int of_get_available_child_count(const struct device_node *np)
1262 {
1263 	struct device_node *child;
1264 	int num = 0;
1265 
1266 	for_each_available_child_of_node(np, child)
1267 		num++;
1268 
1269 	return num;
1270 }
1271 
1272 #if defined(CONFIG_OF) && !defined(MODULE)
1273 #define _OF_DECLARE(table, name, compat, fn, fn_type)			\
1274 	static const struct of_device_id __of_table_##name		\
1275 		__used __section(__##table##_of_table)			\
1276 		 = { .compatible = compat,				\
1277 		     .data = (fn == (fn_type)NULL) ? fn : fn  }
1278 #else
1279 #define _OF_DECLARE(table, name, compat, fn, fn_type)			\
1280 	static const struct of_device_id __of_table_##name		\
1281 		__attribute__((unused))					\
1282 		 = { .compatible = compat,				\
1283 		     .data = (fn == (fn_type)NULL) ? fn : fn }
1284 #endif
1285 
1286 typedef int (*of_init_fn_2)(struct device_node *, struct device_node *);
1287 typedef int (*of_init_fn_1_ret)(struct device_node *);
1288 typedef void (*of_init_fn_1)(struct device_node *);
1289 
1290 #define OF_DECLARE_1(table, name, compat, fn) \
1291 		_OF_DECLARE(table, name, compat, fn, of_init_fn_1)
1292 #define OF_DECLARE_1_RET(table, name, compat, fn) \
1293 		_OF_DECLARE(table, name, compat, fn, of_init_fn_1_ret)
1294 #define OF_DECLARE_2(table, name, compat, fn) \
1295 		_OF_DECLARE(table, name, compat, fn, of_init_fn_2)
1296 
1297 /**
1298  * struct of_changeset_entry	- Holds a changeset entry
1299  *
1300  * @node:	list_head for the log list
1301  * @action:	notifier action
1302  * @np:		pointer to the device node affected
1303  * @prop:	pointer to the property affected
1304  * @old_prop:	hold a pointer to the original property
1305  *
1306  * Every modification of the device tree during a changeset
1307  * is held in a list of of_changeset_entry structures.
1308  * That way we can recover from a partial application, or we can
1309  * revert the changeset
1310  */
1311 struct of_changeset_entry {
1312 	struct list_head node;
1313 	unsigned long action;
1314 	struct device_node *np;
1315 	struct property *prop;
1316 	struct property *old_prop;
1317 };
1318 
1319 /**
1320  * struct of_changeset - changeset tracker structure
1321  *
1322  * @entries:	list_head for the changeset entries
1323  *
1324  * changesets are a convenient way to apply bulk changes to the
1325  * live tree. In case of an error, changes are rolled-back.
1326  * changesets live on after initial application, and if not
1327  * destroyed after use, they can be reverted in one single call.
1328  */
1329 struct of_changeset {
1330 	struct list_head entries;
1331 };
1332 
1333 enum of_reconfig_change {
1334 	OF_RECONFIG_NO_CHANGE = 0,
1335 	OF_RECONFIG_CHANGE_ADD,
1336 	OF_RECONFIG_CHANGE_REMOVE,
1337 };
1338 
1339 #ifdef CONFIG_OF_DYNAMIC
1340 extern int of_reconfig_notifier_register(struct notifier_block *);
1341 extern int of_reconfig_notifier_unregister(struct notifier_block *);
1342 extern int of_reconfig_notify(unsigned long, struct of_reconfig_data *rd);
1343 extern int of_reconfig_get_state_change(unsigned long action,
1344 					struct of_reconfig_data *arg);
1345 
1346 extern void of_changeset_init(struct of_changeset *ocs);
1347 extern void of_changeset_destroy(struct of_changeset *ocs);
1348 extern int of_changeset_apply(struct of_changeset *ocs);
1349 extern int of_changeset_revert(struct of_changeset *ocs);
1350 extern int of_changeset_action(struct of_changeset *ocs,
1351 		unsigned long action, struct device_node *np,
1352 		struct property *prop);
1353 
1354 static inline int of_changeset_attach_node(struct of_changeset *ocs,
1355 		struct device_node *np)
1356 {
1357 	return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
1358 }
1359 
1360 static inline int of_changeset_detach_node(struct of_changeset *ocs,
1361 		struct device_node *np)
1362 {
1363 	return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
1364 }
1365 
1366 static inline int of_changeset_add_property(struct of_changeset *ocs,
1367 		struct device_node *np, struct property *prop)
1368 {
1369 	return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
1370 }
1371 
1372 static inline int of_changeset_remove_property(struct of_changeset *ocs,
1373 		struct device_node *np, struct property *prop)
1374 {
1375 	return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
1376 }
1377 
1378 static inline int of_changeset_update_property(struct of_changeset *ocs,
1379 		struct device_node *np, struct property *prop)
1380 {
1381 	return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
1382 }
1383 #else /* CONFIG_OF_DYNAMIC */
1384 static inline int of_reconfig_notifier_register(struct notifier_block *nb)
1385 {
1386 	return -EINVAL;
1387 }
1388 static inline int of_reconfig_notifier_unregister(struct notifier_block *nb)
1389 {
1390 	return -EINVAL;
1391 }
1392 static inline int of_reconfig_notify(unsigned long action,
1393 				     struct of_reconfig_data *arg)
1394 {
1395 	return -EINVAL;
1396 }
1397 static inline int of_reconfig_get_state_change(unsigned long action,
1398 						struct of_reconfig_data *arg)
1399 {
1400 	return -EINVAL;
1401 }
1402 #endif /* CONFIG_OF_DYNAMIC */
1403 
1404 /**
1405  * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node
1406  * @np: Pointer to the given device_node
1407  *
1408  * return true if present false otherwise
1409  */
1410 static inline bool of_device_is_system_power_controller(const struct device_node *np)
1411 {
1412 	return of_property_read_bool(np, "system-power-controller");
1413 }
1414 
1415 /**
1416  * Overlay support
1417  */
1418 
1419 enum of_overlay_notify_action {
1420 	OF_OVERLAY_PRE_APPLY = 0,
1421 	OF_OVERLAY_POST_APPLY,
1422 	OF_OVERLAY_PRE_REMOVE,
1423 	OF_OVERLAY_POST_REMOVE,
1424 };
1425 
1426 struct of_overlay_notify_data {
1427 	struct device_node *overlay;
1428 	struct device_node *target;
1429 };
1430 
1431 #ifdef CONFIG_OF_OVERLAY
1432 
1433 int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size,
1434 			 int *ovcs_id);
1435 int of_overlay_remove(int *ovcs_id);
1436 int of_overlay_remove_all(void);
1437 
1438 int of_overlay_notifier_register(struct notifier_block *nb);
1439 int of_overlay_notifier_unregister(struct notifier_block *nb);
1440 
1441 #else
1442 
1443 static inline int of_overlay_fdt_apply(void *overlay_fdt, int *ovcs_id)
1444 {
1445 	return -ENOTSUPP;
1446 }
1447 
1448 static inline int of_overlay_remove(int *ovcs_id)
1449 {
1450 	return -ENOTSUPP;
1451 }
1452 
1453 static inline int of_overlay_remove_all(void)
1454 {
1455 	return -ENOTSUPP;
1456 }
1457 
1458 static inline int of_overlay_notifier_register(struct notifier_block *nb)
1459 {
1460 	return 0;
1461 }
1462 
1463 static inline int of_overlay_notifier_unregister(struct notifier_block *nb)
1464 {
1465 	return 0;
1466 }
1467 
1468 #endif
1469 
1470 #endif /* _LINUX_OF_H */
1471