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