Blame view

include/linux/of.h 31.7 KB
76c1ce787   Stephen Rothwell   Split out common ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #ifndef _LINUX_OF_H
  #define _LINUX_OF_H
  /*
   * Definitions for talking to the Open Firmware PROM on
   * Power Macintosh and other computers.
   *
   * Copyright (C) 1996-2005 Paul Mackerras.
   *
   * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
   * Updates for SPARC64 by David S. Miller
   * Derived from PowerPC and Sparc prom.h files by Stephen Rothwell, IBM Corp.
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version
   * 2 of the License, or (at your option) any later version.
   */
  #include <linux/types.h>
1977f0327   Jiri Slaby   remove asm/bitops...
19
  #include <linux/bitops.h>
e51130c0f   Kalle Valo   of: include errno.h
20
  #include <linux/errno.h>
75b57ecf9   Grant Likely   of: Make device n...
21
  #include <linux/kobject.h>
283029d16   Grant Likely   [POWERPC] Add of_...
22
  #include <linux/mod_devicetable.h>
0d351c3e9   Grant Likely   of/sparc: Remove ...
23
  #include <linux/spinlock.h>
5ca4db61e   Paul Mundt   irqdomain: Simple...
24
  #include <linux/topology.h>
1cf3d8b3d   Nathan Fontenot   powerpc+of: Add o...
25
  #include <linux/notifier.h>
b31384fa5   Rafael J. Wysocki   Driver core: Unif...
26
  #include <linux/property.h>
7518b5890   Pantelis Antoniou   of/overlay: Intro...
27
  #include <linux/list.h>
76c1ce787   Stephen Rothwell   Split out common ...
28

2e89e685a   Jeremy Kerr   of: use __be32 fo...
29
  #include <asm/byteorder.h>
d0a994028   Paul Gortmaker   of: fix implicit ...
30
  #include <asm/errno.h>
2e89e685a   Jeremy Kerr   of: use __be32 fo...
31

731581e6a   Grant Likely   of: merge phandle...
32
33
34
35
36
37
38
39
40
41
  typedef u32 phandle;
  typedef u32 ihandle;
  
  struct property {
  	char	*name;
  	int	length;
  	void	*value;
  	struct property *next;
  	unsigned long _flags;
  	unsigned int unique_id;
75b57ecf9   Grant Likely   of: Make device n...
42
  	struct bin_attribute attr;
731581e6a   Grant Likely   of: merge phandle...
43
  };
6f1924928   Grant Likely   of: merge struct ...
44
45
46
47
48
49
50
  #if defined(CONFIG_SPARC)
  struct of_irq_controller;
  #endif
  
  struct device_node {
  	const char *name;
  	const char *type;
6016a363f   Grant Likely   of: unify phandle...
51
  	phandle phandle;
c22618a11   Grant Likely   drivers/of: Const...
52
  	const char *full_name;
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
53
  	struct fwnode_handle fwnode;
6f1924928   Grant Likely   of: merge struct ...
54
55
56
57
58
59
  
  	struct	property *properties;
  	struct	property *deadprops;	/* removed properties */
  	struct	device_node *parent;
  	struct	device_node *child;
  	struct	device_node *sibling;
75b57ecf9   Grant Likely   of: Make device n...
60
  	struct	kobject kobj;
6f1924928   Grant Likely   of: merge struct ...
61
62
63
  	unsigned long _flags;
  	void	*data;
  #if defined(CONFIG_SPARC)
c22618a11   Grant Likely   drivers/of: Const...
64
  	const char *path_component_name;
6f1924928   Grant Likely   of: merge struct ...
65
66
67
68
  	unsigned int unique_id;
  	struct of_irq_controller *irq_trans;
  #endif
  };
b66548e2a   Andreas Herrmann   of: Increase MAX_...
69
  #define MAX_PHANDLE_ARGS 16
15c9a0acc   Grant Likely   of: create of_pha...
70
71
72
73
74
  struct of_phandle_args {
  	struct device_node *np;
  	int args_count;
  	uint32_t args[MAX_PHANDLE_ARGS];
  };
f5242e5a8   Grant Likely   of/reconfig: Alwa...
75
76
77
78
79
  struct of_reconfig_data {
  	struct device_node	*dn;
  	struct property		*prop;
  	struct property		*old_prop;
  };
0829f6d1f   Pantelis Antoniou   of: device_node k...
80
81
82
83
84
  /* initialize a node */
  extern struct kobj_type of_node_ktype;
  static inline void of_node_init(struct device_node *node)
  {
  	kobject_init(&node->kobj, &of_node_ktype);
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
85
  	node->fwnode.type = FWNODE_OF;
0829f6d1f   Pantelis Antoniou   of: device_node k...
86
87
88
89
90
91
92
93
94
95
96
97
98
  }
  
  /* true when node is initialized */
  static inline int of_node_is_initialized(struct device_node *node)
  {
  	return node && node->kobj.state_initialized;
  }
  
  /* true when node is attached (i.e. present on sysfs) */
  static inline int of_node_is_attached(struct device_node *node)
  {
  	return node && node->kobj.state_in_sysfs;
  }
0f22dd395   Grant Likely   of: Only compile ...
99
100
101
102
  #ifdef CONFIG_OF_DYNAMIC
  extern struct device_node *of_node_get(struct device_node *node);
  extern void of_node_put(struct device_node *node);
  #else /* CONFIG_OF_DYNAMIC */
3ecdd0515   Rob Herring   dt: add empty of_...
103
104
105
106
107
  /* Dummy ref counting routines - to be implemented later */
  static inline struct device_node *of_node_get(struct device_node *node)
  {
  	return node;
  }
0f22dd395   Grant Likely   of: Only compile ...
108
109
  static inline void of_node_put(struct device_node *node) { }
  #endif /* !CONFIG_OF_DYNAMIC */
3ecdd0515   Rob Herring   dt: add empty of_...
110

41f880091   Grant Likely   of/flattree: Merg...
111
  /* Pointer for first entry in chain of all nodes. */
5063e25a3   Grant Likely   of: Eliminate of_...
112
  extern struct device_node *of_root;
fc0bdae49   Grant Likely   of: move definiti...
113
  extern struct device_node *of_chosen;
611cad720   Shawn Guo   dt: add of_alias_...
114
  extern struct device_node *of_aliases;
a752ee56a   Grant Likely   tty: Update hyper...
115
  extern struct device_node *of_stdout;
d6d3c4e65   Thomas Gleixner   OF: convert devtr...
116
  extern raw_spinlock_t devtree_lock;
41f880091   Grant Likely   of/flattree: Merg...
117

391b459d7   Pantelis Antoniou   of: Move OF flags...
118
119
120
121
122
  /* flag descriptions (need to be visible even when !CONFIG_OF) */
  #define OF_DYNAMIC	1 /* node and properties were allocated via kmalloc */
  #define OF_DETACHED	2 /* node has been detached from the device tree */
  #define OF_POPULATED	3 /* device already created for the node */
  #define OF_POPULATED_BUS	4 /* of_platform_populate recursed to children of this node */
b1d06b60e   Guenter Roeck   of: Provide stati...
123
  #define OF_BAD_ADDR	((u64)-1)
6d09dc6b7   Hans de Goede   of.h: Keep extern...
124
  #ifdef CONFIG_OF
194ec9368   Sudeep Holla   drivers: of/base:...
125
  void of_core_init(void);
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
126
127
128
129
  static inline bool is_of_node(struct fwnode_handle *fwnode)
  {
  	return fwnode && fwnode->type == FWNODE_OF;
  }
c181fb3e7   Alexander Sverdlin   ACPI / OF: Rename...
130
  static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
131
  {
4bf011815   Andy Shevchenko   device property: ...
132
133
  	return is_of_node(fwnode) ?
  		container_of(fwnode, struct device_node, fwnode) : NULL;
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
134
  }
3bcbaf6e0   Sebastian Andrzej Siewior   rtc: cmos: Add OF...
135
136
  static inline bool of_have_populated_dt(void)
  {
5063e25a3   Grant Likely   of: Eliminate of_...
137
  	return of_root != NULL;
3bcbaf6e0   Sebastian Andrzej Siewior   rtc: cmos: Add OF...
138
  }
035ebefc7   Andres Salomon   of/sparc: move is...
139
140
141
142
  static inline bool of_node_is_root(const struct device_node *node)
  {
  	return node && (node->parent == NULL);
  }
50436312f   Grant Likely   of: merge of_node...
143
144
145
146
  static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
  {
  	return test_bit(flag, &n->_flags);
  }
c6e126de4   Pawel Moll   of: Keep track of...
147
148
149
150
151
  static inline int of_node_test_and_set_flag(struct device_node *n,
  					    unsigned long flag)
  {
  	return test_and_set_bit(flag, &n->_flags);
  }
50436312f   Grant Likely   of: merge of_node...
152
153
154
155
  static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
  {
  	set_bit(flag, &n->_flags);
  }
588453c69   Pantelis Antoniou   of: Introduce dev...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
  static inline void of_node_clear_flag(struct device_node *n, unsigned long flag)
  {
  	clear_bit(flag, &n->_flags);
  }
  
  static inline int of_property_check_flag(struct property *p, unsigned long flag)
  {
  	return test_bit(flag, &p->_flags);
  }
  
  static inline void of_property_set_flag(struct property *p, unsigned long flag)
  {
  	set_bit(flag, &p->_flags);
  }
  
  static inline void of_property_clear_flag(struct property *p, unsigned long flag)
  {
  	clear_bit(flag, &p->_flags);
  }
5063e25a3   Grant Likely   of: Eliminate of_...
175
  extern struct device_node *__of_find_all_nodes(struct device_node *prev);
e91edcf5a   Grant Likely   of: merge of_find...
176
  extern struct device_node *of_find_all_nodes(struct device_node *prev);
b6caf2ad7   Grant Likely   of: merge of_read...
177
  /*
3d6b88282   Lennert Buytenhek   dt: Typo fix.
178
   * OF address retrieval & translation
b6caf2ad7   Grant Likely   of: merge of_read...
179
180
181
   */
  
  /* Helper to read a big number; size is in cells (not bytes) */
2e89e685a   Jeremy Kerr   of: use __be32 fo...
182
  static inline u64 of_read_number(const __be32 *cell, int size)
b6caf2ad7   Grant Likely   of: merge of_read...
183
184
185
  {
  	u64 r = 0;
  	while (size--)
2e89e685a   Jeremy Kerr   of: use __be32 fo...
186
  		r = (r << 32) | be32_to_cpu(*(cell++));
b6caf2ad7   Grant Likely   of: merge of_read...
187
188
189
190
  	return r;
  }
  
  /* Like of_read_number, but we want an unsigned long result */
2e89e685a   Jeremy Kerr   of: use __be32 fo...
191
  static inline unsigned long of_read_ulong(const __be32 *cell, int size)
b6caf2ad7   Grant Likely   of: merge of_read...
192
  {
2be09cb99   Grant Likely   of: remove specia...
193
194
  	/* toss away upper bits if unsigned long is smaller than u64 */
  	return of_read_number(cell, size);
b6caf2ad7   Grant Likely   of: merge of_read...
195
  }
b6caf2ad7   Grant Likely   of: merge of_read...
196

b5b4bb3f6   Rob Herring   of: only include ...
197
  #if defined(CONFIG_SPARC)
76c1ce787   Stephen Rothwell   Split out common ...
198
  #include <asm/prom.h>
b5b4bb3f6   Rob Herring   of: only include ...
199
  #endif
76c1ce787   Stephen Rothwell   Split out common ...
200

7c7b60cb8   Grant Likely   of: put default s...
201
202
203
204
205
206
207
208
  /* Default #address and #size cells.  Allow arch asm/prom.h to override */
  #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT)
  #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
  #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
  #endif
  
  /* Default string compare functions, Allow arch asm/prom.h to override */
  #if !defined(of_compat_cmp)
1976152fd   Grant Likely   of: Fix compariso...
209
  #define of_compat_cmp(s1, s2, l)	strcasecmp((s1), (s2))
7c7b60cb8   Grant Likely   of: put default s...
210
211
212
  #define of_prop_cmp(s1, s2)		strcmp((s1), (s2))
  #define of_node_cmp(s1, s2)		strcasecmp((s1), (s2))
  #endif
61e955db5   Grant Likely   of: Move OF_IS_DY...
213
214
  #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
  #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
c0a05bf01   Steffen Trumtrar   of: add 'const' t...
215
  static inline const char *of_node_full_name(const struct device_node *np)
74a7f0844   Grant Likely   devicetree: add h...
216
217
218
  {
  	return np ? np->full_name : "<no-node>";
  }
5063e25a3   Grant Likely   of: Eliminate of_...
219
220
221
  #define for_each_of_allnodes_from(from, dn) \
  	for (dn = __of_find_all_nodes(from); dn; dn = __of_find_all_nodes(dn))
  #define for_each_of_allnodes(dn) for_each_of_allnodes_from(NULL, dn)
76c1ce787   Stephen Rothwell   Split out common ...
222
223
  extern struct device_node *of_find_node_by_name(struct device_node *from,
  	const char *name);
76c1ce787   Stephen Rothwell   Split out common ...
224
225
  extern struct device_node *of_find_node_by_type(struct device_node *from,
  	const char *type);
76c1ce787   Stephen Rothwell   Split out common ...
226
227
  extern struct device_node *of_find_compatible_node(struct device_node *from,
  	const char *type, const char *compat);
50c8af4cf   Stephen Warren   of: introduce for...
228
229
230
231
  extern struct device_node *of_find_matching_node_and_match(
  	struct device_node *from,
  	const struct of_device_id *matches,
  	const struct of_device_id **match);
662372e42   Rob Herring   of: restructure f...
232

75c28c09a   Leif Lindholm   of: add optional ...
233
234
235
236
237
238
  extern struct device_node *of_find_node_opts_by_path(const char *path,
  	const char **opts);
  static inline struct device_node *of_find_node_by_path(const char *path)
  {
  	return of_find_node_opts_by_path(path, NULL);
  }
76c1ce787   Stephen Rothwell   Split out common ...
239
240
  extern struct device_node *of_find_node_by_phandle(phandle handle);
  extern struct device_node *of_get_parent(const struct device_node *node);
f4eb01070   Michael Ellerman   [POWERPC] Add of_...
241
  extern struct device_node *of_get_next_parent(struct device_node *node);
76c1ce787   Stephen Rothwell   Split out common ...
242
243
  extern struct device_node *of_get_next_child(const struct device_node *node,
  					     struct device_node *prev);
3296193d1   Timur Tabi   dt: introduce for...
244
245
  extern struct device_node *of_get_next_available_child(
  	const struct device_node *node, struct device_node *prev);
9c19761a7   Srinivas Kandagatla   dt: introduce of_...
246
247
  extern struct device_node *of_get_child_by_name(const struct device_node *node,
  					const char *name);
954e04b94   Bryan Wu   of: introduce of_...
248

a3e31b458   Sudeep KarkadaNagesha   of: Move definiti...
249
250
  /* cache lookup */
  extern struct device_node *of_find_next_cache_node(const struct device_node *);
1e291b14c   Michael Ellerman   of: Add helpers f...
251
252
  extern struct device_node *of_find_node_with_property(
  	struct device_node *from, const char *prop_name);
1e291b14c   Michael Ellerman   of: Add helpers f...
253

76c1ce787   Stephen Rothwell   Split out common ...
254
255
256
  extern struct property *of_find_property(const struct device_node *np,
  					 const char *name,
  					 int *lenp);
ad54a0cfb   Heiko Stuebner   of: add functions...
257
258
  extern int of_property_count_elems_of_size(const struct device_node *np,
  				const char *propname, int elem_size);
3daf37260   Tony Prisk   of: Add support f...
259
260
261
  extern int of_property_read_u32_index(const struct device_node *np,
  				       const char *propname,
  				       u32 index, u32 *out_value);
be193249b   Viresh Kumar   dt: add helper fu...
262
263
264
265
  extern int of_property_read_u8_array(const struct device_node *np,
  			const char *propname, u8 *out_values, size_t sz);
  extern int of_property_read_u16_array(const struct device_node *np,
  			const char *propname, u16 *out_values, size_t sz);
0e373639a   Rob Herring   dt: add helper fu...
266
  extern int of_property_read_u32_array(const struct device_node *np,
aac285c6c   Jamie Iles   of: constify prop...
267
  				      const char *propname,
0e373639a   Rob Herring   dt: add helper fu...
268
269
  				      u32 *out_values,
  				      size_t sz);
4cd7f7a31   Jamie Iles   dt: add helper to...
270
271
  extern int of_property_read_u64(const struct device_node *np,
  				const char *propname, u64 *out_value);
b31384fa5   Rafael J. Wysocki   Driver core: Unif...
272
273
274
275
  extern int of_property_read_u64_array(const struct device_node *np,
  				      const char *propname,
  				      u64 *out_values,
  				      size_t sz);
0e373639a   Rob Herring   dt: add helper fu...
276

aac285c6c   Jamie Iles   of: constify prop...
277
278
279
  extern int of_property_read_string(struct device_node *np,
  				   const char *propname,
  				   const char **out_string);
7aff0fe33   Grant Likely   of: Add of_proper...
280
281
282
  extern int of_property_match_string(struct device_node *np,
  				    const char *propname,
  				    const char *string);
a87fa1d81   Grant Likely   of: Fix overflow ...
283
284
285
  extern int of_property_read_string_helper(struct device_node *np,
  					      const char *propname,
  					      const char **out_strs, size_t sz, int index);
76c1ce787   Stephen Rothwell   Split out common ...
286
287
  extern int of_device_is_compatible(const struct device_node *device,
  				   const char *);
53a4ab96c   Kevin Cernekee   of: Change of_dev...
288
  extern bool of_device_is_available(const struct device_node *device);
37786c7fe   Kevin Cernekee   of: Add helper fu...
289
  extern bool of_device_is_big_endian(const struct device_node *device);
76c1ce787   Stephen Rothwell   Split out common ...
290
291
292
  extern const void *of_get_property(const struct device_node *node,
  				const char *name,
  				int *lenp);
183912d35   Sudeep KarkadaNagesha   of: move of_get_c...
293
  extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
8af0da93d   Dong Aisheng   dt: reform for_ea...
294
295
  #define for_each_property_of_node(dn, pp) \
  	for (pp = dn->properties; pp != NULL; pp = pp->next)
611cad720   Shawn Guo   dt: add of_alias_...
296

76c1ce787   Stephen Rothwell   Split out common ...
297
298
  extern int of_n_addr_cells(struct device_node *np);
  extern int of_n_size_cells(struct device_node *np);
283029d16   Grant Likely   [POWERPC] Add of_...
299
300
  extern const struct of_device_id *of_match_node(
  	const struct of_device_id *matches, const struct device_node *node);
3f07af494   Grant Likely   of: adapt of_find...
301
  extern int of_modalias_node(struct device_node *node, char *modalias, int len);
624cfca53   Grant Likely   of: Add helper fo...
302
  extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args);
b8fbdc42c   Steffen Trumtrar   of: add 'const' f...
303
  extern struct device_node *of_parse_phandle(const struct device_node *np,
739649c53   Grant Likely   of: add of_parse_...
304
305
  					    const char *phandle_name,
  					    int index);
93c667ca2   Guennadi Liakhovetski   of: *node argumen...
306
  extern int of_parse_phandle_with_args(const struct device_node *np,
64b60e096   Anton Vorontsov   of: Add new helpe...
307
  	const char *list_name, const char *cells_name, int index,
15c9a0acc   Grant Likely   of: create of_pha...
308
  	struct of_phandle_args *out_args);
035fd9482   Stephen Warren   of: introduce of_...
309
310
311
  extern int of_parse_phandle_with_fixed_args(const struct device_node *np,
  	const char *list_name, int cells_count, int index,
  	struct of_phandle_args *out_args);
bd69f73f2   Grant Likely   of: Create functi...
312
313
  extern int of_count_phandle_with_args(const struct device_node *np,
  	const char *list_name, const char *cells_name);
76c1ce787   Stephen Rothwell   Split out common ...
314

611cad720   Shawn Guo   dt: add of_alias_...
315
316
  extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
  extern int of_alias_get_id(struct device_node *np, const char *stem);
351d224f6   Wolfram Sang   of: base: add fun...
317
  extern int of_alias_get_highest_id(const char *stem);
611cad720   Shawn Guo   dt: add of_alias_...
318

21b082ecd   Grant Likely   of: Remove old an...
319
  extern int of_machine_is_compatible(const char *compat);
79d1c7129   Nathan Fontenot   powerpc+of: Renam...
320
321
322
  extern int of_add_property(struct device_node *np, struct property *prop);
  extern int of_remove_property(struct device_node *np, struct property *prop);
  extern int of_update_property(struct device_node *np, struct property *newprop);
21b082ecd   Grant Likely   of: Remove old an...
323

fcdeb7fed   Grant Likely   of: merge of_atta...
324
  /* For updating the device tree at runtime */
1cf3d8b3d   Nathan Fontenot   powerpc+of: Add o...
325
326
327
328
329
  #define OF_RECONFIG_ATTACH_NODE		0x0001
  #define OF_RECONFIG_DETACH_NODE		0x0002
  #define OF_RECONFIG_ADD_PROPERTY	0x0003
  #define OF_RECONFIG_REMOVE_PROPERTY	0x0004
  #define OF_RECONFIG_UPDATE_PROPERTY	0x0005
1cf3d8b3d   Nathan Fontenot   powerpc+of: Add o...
330
331
  extern int of_attach_node(struct device_node *);
  extern int of_detach_node(struct device_node *);
fcdeb7fed   Grant Likely   of: merge of_atta...
332

3a1e362e3   Ben Dooks   OF: Add of_match_...
333
  #define of_match_ptr(_ptr)	(_ptr)
c541adc63   Stephen Warren   dt: add property ...
334
335
336
337
338
339
340
341
342
343
344
345
  
  /*
   * struct property *prop;
   * const __be32 *p;
   * u32 u;
   *
   * of_property_for_each_u32(np, "propname", prop, p, u)
   *         printk("U32 value: %x
  ", u);
   */
  const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur,
  			       u32 *pu);
c541adc63   Stephen Warren   dt: add property ...
346
347
348
349
350
351
352
353
354
  /*
   * struct property *prop;
   * const char *s;
   *
   * of_property_for_each_string(np, "propname", prop, s)
   *         printk("String value: %s
  ", s);
   */
  const char *of_prop_next_string(struct property *prop, const char *cur);
c541adc63   Stephen Warren   dt: add property ...
355

3482f2c52   Grant Likely   of: Create of_con...
356
  bool of_console_check(struct device_node *dn, char *name, int index);
5c19e9521   Sascha Hauer   OF: Add helper fo...
357

b98c02392   Shawn Guo   dt: add empty of_...
358
  #else /* CONFIG_OF */
3bcbaf6e0   Sebastian Andrzej Siewior   rtc: cmos: Add OF...
359

194ec9368   Sudeep Holla   drivers: of/base:...
360
361
362
  static inline void of_core_init(void)
  {
  }
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
363
364
365
366
  static inline bool is_of_node(struct fwnode_handle *fwnode)
  {
  	return false;
  }
c181fb3e7   Alexander Sverdlin   ACPI / OF: Rename...
367
  static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
8a0662d9e   Rafael J. Wysocki   Driver core: Unif...
368
369
370
  {
  	return NULL;
  }
4c358e155   Stephen Rothwell   of: fix CONFIG_OF...
371
  static inline const char* of_node_full_name(const struct device_node *np)
74a7f0844   Grant Likely   devicetree: add h...
372
373
374
  {
  	return "<no-node>";
  }
1cc44f435   Peter Ujfalusi   dt: Add empty of_...
375
376
377
378
379
  static inline struct device_node *of_find_node_by_name(struct device_node *from,
  	const char *name)
  {
  	return NULL;
  }
662372e42   Rob Herring   of: restructure f...
380
381
  static inline struct device_node *of_find_node_by_type(struct device_node *from,
  	const char *type)
066ec1dd4   Alexander Shiyan   of: Add stub of_g...
382
383
384
  {
  	return NULL;
  }
662372e42   Rob Herring   of: restructure f...
385
386
387
388
  static inline struct device_node *of_find_matching_node_and_match(
  	struct device_node *from,
  	const struct of_device_id *matches,
  	const struct of_device_id **match)
3bcbaf6e0   Sebastian Andrzej Siewior   rtc: cmos: Add OF...
389
  {
662372e42   Rob Herring   of: restructure f...
390
  	return NULL;
3bcbaf6e0   Sebastian Andrzej Siewior   rtc: cmos: Add OF...
391
  }
20cd477c3   Alexander Shiyan   of: add empty of_...
392
393
394
395
  static inline struct device_node *of_find_node_by_path(const char *path)
  {
  	return NULL;
  }
75c28c09a   Leif Lindholm   of: add optional ...
396
397
398
399
400
  static inline struct device_node *of_find_node_opts_by_path(const char *path,
  	const char **opts)
  {
  	return NULL;
  }
ce16b9d23   Suman Anna   of: define of_fin...
401
402
403
404
  static inline struct device_node *of_find_node_by_phandle(phandle handle)
  {
  	return NULL;
  }
662372e42   Rob Herring   of: restructure f...
405
  static inline struct device_node *of_get_parent(const struct device_node *node)
00b2c76a6   David Howells   include/linux/of....
406
  {
662372e42   Rob Herring   of: restructure f...
407
  	return NULL;
00b2c76a6   David Howells   include/linux/of....
408
  }
662372e42   Rob Herring   of: restructure f...
409
410
411
412
413
  static inline struct device_node *of_get_next_child(
  	const struct device_node *node, struct device_node *prev)
  {
  	return NULL;
  }
aba3dfff9   Stephen Warren   dt: add empty for...
414

662372e42   Rob Herring   of: restructure f...
415
416
417
418
419
  static inline struct device_node *of_get_next_available_child(
  	const struct device_node *node, struct device_node *prev)
  {
  	return NULL;
  }
f6f0747e5   Sylwester Nawrocki   of: Add empty for...
420

662372e42   Rob Herring   of: restructure f...
421
422
  static inline struct device_node *of_find_node_with_property(
  	struct device_node *from, const char *prop_name)
25c040c99   Olof Johansson   of: add stub of_g...
423
424
425
  {
  	return NULL;
  }
662372e42   Rob Herring   of: restructure f...
426
  static inline bool of_have_populated_dt(void)
183f1d0c6   Dong Aisheng   dt: add of_get_ch...
427
  {
662372e42   Rob Herring   of: restructure f...
428
  	return false;
183f1d0c6   Dong Aisheng   dt: add of_get_ch...
429
  }
662372e42   Rob Herring   of: restructure f...
430
431
432
  static inline struct device_node *of_get_child_by_name(
  					const struct device_node *node,
  					const char *name)
954e04b94   Bryan Wu   of: introduce of_...
433
  {
662372e42   Rob Herring   of: restructure f...
434
  	return NULL;
954e04b94   Bryan Wu   of: introduce of_...
435
  }
36a0904ea   Rajendra Nayak   dt: add empty dt ...
436
437
438
439
440
  static inline int of_device_is_compatible(const struct device_node *device,
  					  const char *name)
  {
  	return 0;
  }
53a4ab96c   Kevin Cernekee   of: Change of_dev...
441
  static inline bool of_device_is_available(const struct device_node *device)
d71956960   Rob Herring   OF: add empty of_...
442
  {
53a4ab96c   Kevin Cernekee   of: Change of_dev...
443
  	return false;
d71956960   Rob Herring   OF: add empty of_...
444
  }
37786c7fe   Kevin Cernekee   of: Add helper fu...
445
446
447
  static inline bool of_device_is_big_endian(const struct device_node *device)
  {
  	return false;
d71956960   Rob Herring   OF: add empty of_...
448
  }
aba3dfff9   Stephen Warren   dt: add empty for...
449
450
451
452
453
454
  static inline struct property *of_find_property(const struct device_node *np,
  						const char *name,
  						int *lenp)
  {
  	return NULL;
  }
2261cc627   Shawn Guo   dt: add empty of_...
455
456
457
458
459
460
461
  static inline struct device_node *of_find_compatible_node(
  						struct device_node *from,
  						const char *type,
  						const char *compat)
  {
  	return NULL;
  }
ad54a0cfb   Heiko Stuebner   of: add functions...
462
463
464
465
466
  static inline int of_property_count_elems_of_size(const struct device_node *np,
  			const char *propname, int elem_size)
  {
  	return -ENOSYS;
  }
3daf37260   Tony Prisk   of: Add support f...
467
468
469
470
471
  static inline int of_property_read_u32_index(const struct device_node *np,
  			const char *propname, u32 index, u32 *out_value)
  {
  	return -ENOSYS;
  }
be193249b   Viresh Kumar   dt: add helper fu...
472
473
474
475
476
477
478
479
480
481
482
  static inline int of_property_read_u8_array(const struct device_node *np,
  			const char *propname, u8 *out_values, size_t sz)
  {
  	return -ENOSYS;
  }
  
  static inline int of_property_read_u16_array(const struct device_node *np,
  			const char *propname, u16 *out_values, size_t sz)
  {
  	return -ENOSYS;
  }
b98c02392   Shawn Guo   dt: add empty of_...
483
  static inline int of_property_read_u32_array(const struct device_node *np,
aac285c6c   Jamie Iles   of: constify prop...
484
485
  					     const char *propname,
  					     u32 *out_values, size_t sz)
b98c02392   Shawn Guo   dt: add empty of_...
486
487
488
  {
  	return -ENOSYS;
  }
b31384fa5   Rafael J. Wysocki   Driver core: Unif...
489
490
491
492
493
494
  static inline int of_property_read_u64_array(const struct device_node *np,
  					     const char *propname,
  					     u64 *out_values, size_t sz)
  {
  	return -ENOSYS;
  }
b98c02392   Shawn Guo   dt: add empty of_...
495
  static inline int of_property_read_string(struct device_node *np,
aac285c6c   Jamie Iles   of: constify prop...
496
497
  					  const char *propname,
  					  const char **out_string)
b98c02392   Shawn Guo   dt: add empty of_...
498
499
500
  {
  	return -ENOSYS;
  }
a87fa1d81   Grant Likely   of: Fix overflow ...
501
502
503
  static inline int of_property_read_string_helper(struct device_node *np,
  						 const char *propname,
  						 const char **out_strs, size_t sz, int index)
4fcd15a03   Benoit Cousson   of: Add helpers t...
504
505
506
  {
  	return -ENOSYS;
  }
89272b8c0   Stephen Warren   dt: add empty of_...
507
508
509
510
511
512
  static inline const void *of_get_property(const struct device_node *node,
  				const char *name,
  				int *lenp)
  {
  	return NULL;
  }
183912d35   Sudeep KarkadaNagesha   of: move of_get_c...
513
514
515
516
517
  static inline struct device_node *of_get_cpu_node(int cpu,
  					unsigned int *thread)
  {
  	return NULL;
  }
4cd7f7a31   Jamie Iles   dt: add helper to...
518
519
520
521
522
  static inline int of_property_read_u64(const struct device_node *np,
  				       const char *propname, u64 *out_value)
  {
  	return -ENOSYS;
  }
bd3d5500f   Thierry Reding   dt: Add empty of_...
523
524
525
526
527
528
  static inline int of_property_match_string(struct device_node *np,
  					   const char *propname,
  					   const char *string)
  {
  	return -ENOSYS;
  }
b8fbdc42c   Steffen Trumtrar   of: add 'const' f...
529
  static inline struct device_node *of_parse_phandle(const struct device_node *np,
36a0904ea   Rajendra Nayak   dt: add empty dt ...
530
531
532
533
534
  						   const char *phandle_name,
  						   int index)
  {
  	return NULL;
  }
e05e5070f   Thierry Reding   dt: Add empty of_...
535
536
537
538
539
540
541
542
  static inline int of_parse_phandle_with_args(struct device_node *np,
  					     const char *list_name,
  					     const char *cells_name,
  					     int index,
  					     struct of_phandle_args *out_args)
  {
  	return -ENOSYS;
  }
035fd9482   Stephen Warren   of: introduce of_...
543
544
545
546
547
548
  static inline int of_parse_phandle_with_fixed_args(const struct device_node *np,
  	const char *list_name, int cells_count, int index,
  	struct of_phandle_args *out_args)
  {
  	return -ENOSYS;
  }
bd69f73f2   Grant Likely   of: Create functi...
549
550
551
552
553
554
  static inline int of_count_phandle_with_args(struct device_node *np,
  					     const char *list_name,
  					     const char *cells_name)
  {
  	return -ENOSYS;
  }
ed5f886d1   Nicolas Ferre   dt: add empty of_...
555
556
557
558
  static inline int of_alias_get_id(struct device_node *np, const char *stem)
  {
  	return -ENOSYS;
  }
351d224f6   Wolfram Sang   of: base: add fun...
559
560
561
562
  static inline int of_alias_get_highest_id(const char *stem)
  {
  	return -ENOSYS;
  }
50e07f888   Stephen Warren   dt: add empty of_...
563
564
565
566
  static inline int of_machine_is_compatible(const char *compat)
  {
  	return 0;
  }
3482f2c52   Grant Likely   of: Create of_con...
567
  static inline bool of_console_check(const struct device_node *dn, const char *name, int index)
5c19e9521   Sascha Hauer   OF: Add helper fo...
568
  {
3482f2c52   Grant Likely   of: Create of_con...
569
  	return false;
5c19e9521   Sascha Hauer   OF: Add helper fo...
570
  }
2adfffa22   Sebastian Andrzej Siewior   OF: make of_prope...
571
572
573
574
575
576
577
578
579
580
581
  static inline const __be32 *of_prop_next_u32(struct property *prop,
  		const __be32 *cur, u32 *pu)
  {
  	return NULL;
  }
  
  static inline const char *of_prop_next_string(struct property *prop,
  		const char *cur)
  {
  	return NULL;
  }
0384e8c6c   Pantelis Antoniou   of: Empty node & ...
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
  static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
  {
  	return 0;
  }
  
  static inline int of_node_test_and_set_flag(struct device_node *n,
  					    unsigned long flag)
  {
  	return 0;
  }
  
  static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
  {
  }
  
  static inline void of_node_clear_flag(struct device_node *n, unsigned long flag)
  {
  }
  
  static inline int of_property_check_flag(struct property *p, unsigned long flag)
  {
  	return 0;
  }
  
  static inline void of_property_set_flag(struct property *p, unsigned long flag)
  {
  }
  
  static inline void of_property_clear_flag(struct property *p, unsigned long flag)
  {
  }
3a1e362e3   Ben Dooks   OF: Add of_match_...
613
  #define of_match_ptr(_ptr)	NULL
5762c2059   Nicolas Ferre   dt: Add empty of_...
614
  #define of_match_node(_matches, _node)	NULL
9dfbf2078   Jeremy Kerr   of: protect linux...
615
  #endif /* CONFIG_OF */
b98c02392   Shawn Guo   dt: add empty of_...
616

0c3f061c1   Rob Herring   of: implement of_...
617
618
619
  #if defined(CONFIG_OF) && defined(CONFIG_NUMA)
  extern int of_node_to_nid(struct device_node *np);
  #else
c8fff7bc5   Konstantin Khlebnikov   of: return NUMA_N...
620
621
622
623
  static inline int of_node_to_nid(struct device_node *device)
  {
  	return NUMA_NO_NODE;
  }
5ca4db61e   Paul Mundt   irqdomain: Simple...
624
  #endif
662372e42   Rob Herring   of: restructure f...
625
626
627
628
629
630
  static inline struct device_node *of_find_matching_node(
  	struct device_node *from,
  	const struct of_device_id *matches)
  {
  	return of_find_matching_node_and_match(from, matches, NULL);
  }
fa4d34ccd   Jean-Christophe PLAGNIOL-VILLARD   of: introduce hel...
631
  /**
ad54a0cfb   Heiko Stuebner   of: add functions...
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
   * of_property_count_u8_elems - Count the number of u8 elements in a property
   *
   * @np:		device node from which the property value is to be read.
   * @propname:	name of the property to be searched.
   *
   * Search for a property in a device node and count the number of u8 elements
   * in it. Returns number of elements on sucess, -EINVAL if the property does
   * not exist or its length does not match a multiple of u8 and -ENODATA if the
   * property does not have a value.
   */
  static inline int of_property_count_u8_elems(const struct device_node *np,
  				const char *propname)
  {
  	return of_property_count_elems_of_size(np, propname, sizeof(u8));
  }
  
  /**
   * of_property_count_u16_elems - Count the number of u16 elements in a property
   *
   * @np:		device node from which the property value is to be read.
   * @propname:	name of the property to be searched.
   *
   * Search for a property in a device node and count the number of u16 elements
   * in it. Returns number of elements on sucess, -EINVAL if the property does
   * not exist or its length does not match a multiple of u16 and -ENODATA if the
   * property does not have a value.
   */
  static inline int of_property_count_u16_elems(const struct device_node *np,
  				const char *propname)
  {
  	return of_property_count_elems_of_size(np, propname, sizeof(u16));
  }
  
  /**
   * of_property_count_u32_elems - Count the number of u32 elements in a property
   *
   * @np:		device node from which the property value is to be read.
   * @propname:	name of the property to be searched.
   *
   * Search for a property in a device node and count the number of u32 elements
   * in it. Returns number of elements on sucess, -EINVAL if the property does
   * not exist or its length does not match a multiple of u32 and -ENODATA if the
   * property does not have a value.
   */
  static inline int of_property_count_u32_elems(const struct device_node *np,
  				const char *propname)
  {
  	return of_property_count_elems_of_size(np, propname, sizeof(u32));
  }
  
  /**
   * of_property_count_u64_elems - Count the number of u64 elements in a property
   *
   * @np:		device node from which the property value is to be read.
   * @propname:	name of the property to be searched.
   *
   * Search for a property in a device node and count the number of u64 elements
   * in it. Returns number of elements on sucess, -EINVAL if the property does
   * not exist or its length does not match a multiple of u64 and -ENODATA if the
   * property does not have a value.
   */
  static inline int of_property_count_u64_elems(const struct device_node *np,
  				const char *propname)
  {
  	return of_property_count_elems_of_size(np, propname, sizeof(u64));
  }
fa4d34ccd   Jean-Christophe PLAGNIOL-VILLARD   of: introduce hel...
698
  /**
a87fa1d81   Grant Likely   of: Fix overflow ...
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
   * of_property_read_string_array() - Read an array of strings from a multiple
   * strings property.
   * @np:		device node from which the property value is to be read.
   * @propname:	name of the property to be searched.
   * @out_strs:	output array of string pointers.
   * @sz:		number of array elements to read.
   *
   * Search for a property in a device tree node and retrieve a list of
   * terminated string values (pointer to data, not a copy) in that property.
   *
   * If @out_strs is NULL, the number of strings in the property is returned.
   */
  static inline int of_property_read_string_array(struct device_node *np,
  						const char *propname, const char **out_strs,
  						size_t sz)
  {
  	return of_property_read_string_helper(np, propname, out_strs, sz, 0);
  }
  
  /**
   * of_property_count_strings() - Find and return the number of strings from a
   * multiple strings property.
   * @np:		device node from which the property value is to be read.
   * @propname:	name of the property to be searched.
   *
   * Search for a property in a device tree node and retrieve the number of null
   * terminated string contain in it. Returns the number of strings on
   * success, -EINVAL if the property does not exist, -ENODATA if property
   * does not have a value, and -EILSEQ if the string is not null-terminated
   * within the length of the property data.
   */
  static inline int of_property_count_strings(struct device_node *np,
  					    const char *propname)
  {
  	return of_property_read_string_helper(np, propname, NULL, 0, 0);
  }
  
  /**
   * of_property_read_string_index() - Find and read a string from a multiple
   * strings property.
   * @np:		device node from which the property value is to be read.
   * @propname:	name of the property to be searched.
   * @index:	index of the string in the list of strings
   * @out_string:	pointer to null terminated return string, modified only if
   *		return value is 0.
   *
   * Search for a property in a device tree node and retrieve a null
   * terminated string value (pointer to data, not a copy) in the list of strings
   * contained in that property.
   * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if
   * property does not have a value, and -EILSEQ if the string is not
   * null-terminated within the length of the property data.
   *
   * The out_string pointer is modified only if a valid string can be decoded.
   */
  static inline int of_property_read_string_index(struct device_node *np,
  						const char *propname,
  						int index, const char **output)
  {
  	int rc = of_property_read_string_helper(np, propname, output, 1, index);
  	return rc < 0 ? rc : 0;
  }
  
  /**
fa4d34ccd   Jean-Christophe PLAGNIOL-VILLARD   of: introduce hel...
763
764
765
766
767
   * of_property_read_bool - Findfrom a property
   * @np:		device node from which the property value is to be read.
   * @propname:	name of the property to be searched.
   *
   * Search for a property in a device node.
31712c98f   Geert Uytterhoeven   of: Grammar s/pro...
768
   * Returns true if the property exists false otherwise.
fa4d34ccd   Jean-Christophe PLAGNIOL-VILLARD   of: introduce hel...
769
770
771
772
773
774
775
776
   */
  static inline bool of_property_read_bool(const struct device_node *np,
  					 const char *propname)
  {
  	struct property *prop = of_find_property(np, propname, NULL);
  
  	return prop ? true : false;
  }
be193249b   Viresh Kumar   dt: add helper fu...
777
778
779
780
781
782
783
784
785
786
787
788
789
  static inline int of_property_read_u8(const struct device_node *np,
  				       const char *propname,
  				       u8 *out_value)
  {
  	return of_property_read_u8_array(np, propname, out_value, 1);
  }
  
  static inline int of_property_read_u16(const struct device_node *np,
  				       const char *propname,
  				       u16 *out_value)
  {
  	return of_property_read_u16_array(np, propname, out_value, 1);
  }
b98c02392   Shawn Guo   dt: add empty of_...
790
  static inline int of_property_read_u32(const struct device_node *np,
aac285c6c   Jamie Iles   of: constify prop...
791
  				       const char *propname,
b98c02392   Shawn Guo   dt: add empty of_...
792
793
794
795
  				       u32 *out_value)
  {
  	return of_property_read_u32_array(np, propname, out_value, 1);
  }
e7a00e421   Sebastian Reichel   of: introduce of_...
796
797
798
799
800
801
  static inline int of_property_read_s32(const struct device_node *np,
  				       const char *propname,
  				       s32 *out_value)
  {
  	return of_property_read_u32(np, propname, (u32*) out_value);
  }
2adfffa22   Sebastian Andrzej Siewior   OF: make of_prope...
802
803
804
805
806
807
808
809
810
811
812
  #define of_property_for_each_u32(np, propname, prop, p, u)	\
  	for (prop = of_find_property(np, propname, NULL),	\
  		p = of_prop_next_u32(prop, NULL, &u);		\
  		p;						\
  		p = of_prop_next_u32(prop, p, &u))
  
  #define of_property_for_each_string(np, propname, prop, s)	\
  	for (prop = of_find_property(np, propname, NULL),	\
  		s = of_prop_next_string(prop, NULL);		\
  		s;						\
  		s = of_prop_next_string(prop, s))
662372e42   Rob Herring   of: restructure f...
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
  #define for_each_node_by_name(dn, name) \
  	for (dn = of_find_node_by_name(NULL, name); dn; \
  	     dn = of_find_node_by_name(dn, name))
  #define for_each_node_by_type(dn, type) \
  	for (dn = of_find_node_by_type(NULL, type); dn; \
  	     dn = of_find_node_by_type(dn, type))
  #define for_each_compatible_node(dn, type, compatible) \
  	for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
  	     dn = of_find_compatible_node(dn, type, compatible))
  #define for_each_matching_node(dn, matches) \
  	for (dn = of_find_matching_node(NULL, matches); dn; \
  	     dn = of_find_matching_node(dn, matches))
  #define for_each_matching_node_and_match(dn, matches, match) \
  	for (dn = of_find_matching_node_and_match(NULL, matches, match); \
  	     dn; dn = of_find_matching_node_and_match(dn, matches, match))
  
  #define for_each_child_of_node(parent, child) \
  	for (child = of_get_next_child(parent, NULL); child != NULL; \
  	     child = of_get_next_child(parent, child))
  #define for_each_available_child_of_node(parent, child) \
  	for (child = of_get_next_available_child(parent, NULL); child != NULL; \
  	     child = of_get_next_available_child(parent, child))
  
  #define for_each_node_with_property(dn, prop_name) \
  	for (dn = of_find_node_with_property(NULL, prop_name); dn; \
  	     dn = of_find_node_with_property(dn, prop_name))
  
  static inline int of_get_child_count(const struct device_node *np)
  {
  	struct device_node *child;
  	int num = 0;
  
  	for_each_child_of_node(np, child)
  		num++;
  
  	return num;
  }
  
  static inline int of_get_available_child_count(const struct device_node *np)
  {
  	struct device_node *child;
  	int num = 0;
  
  	for_each_available_child_of_node(np, child)
  		num++;
  
  	return num;
  }
54196ccbe   Rob Herring   of: consolidate l...
861
862
863
864
865
866
867
  #ifdef CONFIG_OF
  #define _OF_DECLARE(table, name, compat, fn, fn_type)			\
  	static const struct of_device_id __of_table_##name		\
  		__used __section(__##table##_of_table)			\
  		 = { .compatible = compat,				\
  		     .data = (fn == (fn_type)NULL) ? fn : fn  }
  #else
5f563585a   Thierry Reding   of: Fix padding i...
868
  #define _OF_DECLARE(table, name, compat, fn, fn_type)			\
54196ccbe   Rob Herring   of: consolidate l...
869
870
871
872
873
874
875
876
877
878
879
880
881
  	static const struct of_device_id __of_table_##name		\
  		__attribute__((unused))					\
  		 = { .compatible = compat,				\
  		     .data = (fn == (fn_type)NULL) ? fn : fn }
  #endif
  
  typedef int (*of_init_fn_2)(struct device_node *, struct device_node *);
  typedef void (*of_init_fn_1)(struct device_node *);
  
  #define OF_DECLARE_1(table, name, compat, fn) \
  		_OF_DECLARE(table, name, compat, fn, of_init_fn_1)
  #define OF_DECLARE_2(table, name, compat, fn) \
  		_OF_DECLARE(table, name, compat, fn, of_init_fn_2)
201c910bd   Pantelis Antoniou   of: Transactional...
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
  /**
   * struct of_changeset_entry	- Holds a changeset entry
   *
   * @node:	list_head for the log list
   * @action:	notifier action
   * @np:		pointer to the device node affected
   * @prop:	pointer to the property affected
   * @old_prop:	hold a pointer to the original property
   *
   * Every modification of the device tree during a changeset
   * is held in a list of of_changeset_entry structures.
   * That way we can recover from a partial application, or we can
   * revert the changeset
   */
  struct of_changeset_entry {
  	struct list_head node;
  	unsigned long action;
  	struct device_node *np;
  	struct property *prop;
  	struct property *old_prop;
  };
  
  /**
   * struct of_changeset - changeset tracker structure
   *
   * @entries:	list_head for the changeset entries
   *
   * changesets are a convenient way to apply bulk changes to the
   * live tree. In case of an error, changes are rolled-back.
   * changesets live on after initial application, and if not
   * destroyed after use, they can be reverted in one single call.
   */
  struct of_changeset {
  	struct list_head entries;
  };
b53a2340d   Pantelis Antoniou   of/reconfig: Add ...
917
918
919
920
921
  enum of_reconfig_change {
  	OF_RECONFIG_NO_CHANGE = 0,
  	OF_RECONFIG_CHANGE_ADD,
  	OF_RECONFIG_CHANGE_REMOVE,
  };
201c910bd   Pantelis Antoniou   of: Transactional...
922
  #ifdef CONFIG_OF_DYNAMIC
f6892d193   Grant Likely   of/reconfig: Add ...
923
924
  extern int of_reconfig_notifier_register(struct notifier_block *);
  extern int of_reconfig_notifier_unregister(struct notifier_block *);
f5242e5a8   Grant Likely   of/reconfig: Alwa...
925
926
927
  extern int of_reconfig_notify(unsigned long, struct of_reconfig_data *rd);
  extern int of_reconfig_get_state_change(unsigned long action,
  					struct of_reconfig_data *arg);
f6892d193   Grant Likely   of/reconfig: Add ...
928

201c910bd   Pantelis Antoniou   of: Transactional...
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
  extern void of_changeset_init(struct of_changeset *ocs);
  extern void of_changeset_destroy(struct of_changeset *ocs);
  extern int of_changeset_apply(struct of_changeset *ocs);
  extern int of_changeset_revert(struct of_changeset *ocs);
  extern int of_changeset_action(struct of_changeset *ocs,
  		unsigned long action, struct device_node *np,
  		struct property *prop);
  
  static inline int of_changeset_attach_node(struct of_changeset *ocs,
  		struct device_node *np)
  {
  	return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
  }
  
  static inline int of_changeset_detach_node(struct of_changeset *ocs,
  		struct device_node *np)
  {
  	return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
  }
  
  static inline int of_changeset_add_property(struct of_changeset *ocs,
  		struct device_node *np, struct property *prop)
  {
  	return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
  }
  
  static inline int of_changeset_remove_property(struct of_changeset *ocs,
  		struct device_node *np, struct property *prop)
  {
  	return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
  }
  
  static inline int of_changeset_update_property(struct of_changeset *ocs,
  		struct device_node *np, struct property *prop)
  {
  	return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
  }
f6892d193   Grant Likely   of/reconfig: Add ...
966
967
968
969
970
971
972
973
974
  #else /* CONFIG_OF_DYNAMIC */
  static inline int of_reconfig_notifier_register(struct notifier_block *nb)
  {
  	return -EINVAL;
  }
  static inline int of_reconfig_notifier_unregister(struct notifier_block *nb)
  {
  	return -EINVAL;
  }
f5242e5a8   Grant Likely   of/reconfig: Alwa...
975
976
  static inline int of_reconfig_notify(unsigned long action,
  				     struct of_reconfig_data *arg)
f6892d193   Grant Likely   of/reconfig: Add ...
977
978
979
  {
  	return -EINVAL;
  }
f5242e5a8   Grant Likely   of/reconfig: Alwa...
980
981
  static inline int of_reconfig_get_state_change(unsigned long action,
  						struct of_reconfig_data *arg)
f6892d193   Grant Likely   of/reconfig: Add ...
982
983
984
985
  {
  	return -EINVAL;
  }
  #endif /* CONFIG_OF_DYNAMIC */
201c910bd   Pantelis Antoniou   of: Transactional...
986

7941b27b1   Pantelis Antoniou   of: Introduce Dev...
987
988
  /* CONFIG_OF_RESOLVE api */
  extern int of_resolve_phandles(struct device_node *tree);
a4b4e0461   Romain Perier   of: Add standard ...
989
  /**
8f73110f6   Romain Perier   of: Rename "power...
990
   * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node
a4b4e0461   Romain Perier   of: Add standard ...
991
992
993
994
   * @np: Pointer to the given device_node
   *
   * return true if present false otherwise
   */
8f73110f6   Romain Perier   of: Rename "power...
995
  static inline bool of_device_is_system_power_controller(const struct device_node *np)
a4b4e0461   Romain Perier   of: Add standard ...
996
  {
8f73110f6   Romain Perier   of: Rename "power...
997
  	return of_property_read_bool(np, "system-power-controller");
a4b4e0461   Romain Perier   of: Add standard ...
998
  }
7ef58b32f   Linus Torvalds   Merge tag 'device...
999
  /**
7518b5890   Pantelis Antoniou   of/overlay: Intro...
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
   * Overlay support
   */
  
  #ifdef CONFIG_OF_OVERLAY
  
  /* ID based overlays; the API for external users */
  int of_overlay_create(struct device_node *tree);
  int of_overlay_destroy(int id);
  int of_overlay_destroy_all(void);
  
  #else
  
  static inline int of_overlay_create(struct device_node *tree)
  {
  	return -ENOTSUPP;
  }
  
  static inline int of_overlay_destroy(int id)
  {
  	return -ENOTSUPP;
  }
  
  static inline int of_overlay_destroy_all(void)
  {
  	return -ENOTSUPP;
  }
  
  #endif
76c1ce787   Stephen Rothwell   Split out common ...
1028
  #endif /* _LINUX_OF_H */