xref: /openbmc/linux/include/linux/property.h (revision 1006d1b5)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * property.h - Unified device property interface.
4  *
5  * Copyright (C) 2014, Intel Corporation
6  * Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7  *          Mika Westerberg <mika.westerberg@linux.intel.com>
8  */
9 
10 #ifndef _LINUX_PROPERTY_H_
11 #define _LINUX_PROPERTY_H_
12 
13 #include <linux/bits.h>
14 #include <linux/fwnode.h>
15 #include <linux/stddef.h>
16 #include <linux/types.h>
17 
18 struct device;
19 
20 enum dev_prop_type {
21 	DEV_PROP_U8,
22 	DEV_PROP_U16,
23 	DEV_PROP_U32,
24 	DEV_PROP_U64,
25 	DEV_PROP_STRING,
26 	DEV_PROP_REF,
27 };
28 
29 enum dev_dma_attr {
30 	DEV_DMA_NOT_SUPPORTED,
31 	DEV_DMA_NON_COHERENT,
32 	DEV_DMA_COHERENT,
33 };
34 
35 const struct fwnode_handle *__dev_fwnode_const(const struct device *dev);
36 struct fwnode_handle *__dev_fwnode(struct device *dev);
37 #define dev_fwnode(dev)							\
38 	_Generic((dev),							\
39 		 const struct device *: __dev_fwnode_const,	\
40 		 struct device *: __dev_fwnode)(dev)
41 
42 bool device_property_present(const struct device *dev, const char *propname);
43 int device_property_read_u8_array(const struct device *dev, const char *propname,
44 				  u8 *val, size_t nval);
45 int device_property_read_u16_array(const struct device *dev, const char *propname,
46 				   u16 *val, size_t nval);
47 int device_property_read_u32_array(const struct device *dev, const char *propname,
48 				   u32 *val, size_t nval);
49 int device_property_read_u64_array(const struct device *dev, const char *propname,
50 				   u64 *val, size_t nval);
51 int device_property_read_string_array(const struct device *dev, const char *propname,
52 				      const char **val, size_t nval);
53 int device_property_read_string(const struct device *dev, const char *propname,
54 				const char **val);
55 int device_property_match_string(const struct device *dev,
56 				 const char *propname, const char *string);
57 
58 bool fwnode_property_present(const struct fwnode_handle *fwnode,
59 			     const char *propname);
60 int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
61 				  const char *propname, u8 *val,
62 				  size_t nval);
63 int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode,
64 				   const char *propname, u16 *val,
65 				   size_t nval);
66 int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode,
67 				   const char *propname, u32 *val,
68 				   size_t nval);
69 int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode,
70 				   const char *propname, u64 *val,
71 				   size_t nval);
72 int fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
73 				      const char *propname, const char **val,
74 				      size_t nval);
75 int fwnode_property_read_string(const struct fwnode_handle *fwnode,
76 				const char *propname, const char **val);
77 int fwnode_property_match_string(const struct fwnode_handle *fwnode,
78 				 const char *propname, const char *string);
79 
80 bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
81 
fwnode_device_is_big_endian(const struct fwnode_handle * fwnode)82 static inline bool fwnode_device_is_big_endian(const struct fwnode_handle *fwnode)
83 {
84 	if (fwnode_property_present(fwnode, "big-endian"))
85 		return true;
86 	if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) &&
87 	    fwnode_property_present(fwnode, "native-endian"))
88 		return true;
89 	return false;
90 }
91 
92 static inline
fwnode_device_is_compatible(const struct fwnode_handle * fwnode,const char * compat)93 bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char *compat)
94 {
95 	return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;
96 }
97 
98 /**
99  * device_is_big_endian - check if a device has BE registers
100  * @dev: Pointer to the struct device
101  *
102  * Returns: true if the device has a "big-endian" property, or if the kernel
103  * was compiled for BE *and* the device has a "native-endian" property.
104  * Returns false otherwise.
105  *
106  * Callers would nominally use ioread32be/iowrite32be if
107  * device_is_big_endian() == true, or readl/writel otherwise.
108  */
device_is_big_endian(const struct device * dev)109 static inline bool device_is_big_endian(const struct device *dev)
110 {
111 	return fwnode_device_is_big_endian(dev_fwnode(dev));
112 }
113 
114 /**
115  * device_is_compatible - match 'compatible' property of the device with a given string
116  * @dev: Pointer to the struct device
117  * @compat: The string to match 'compatible' property with
118  *
119  * Returns: true if matches, otherwise false.
120  */
device_is_compatible(const struct device * dev,const char * compat)121 static inline bool device_is_compatible(const struct device *dev, const char *compat)
122 {
123 	return fwnode_device_is_compatible(dev_fwnode(dev), compat);
124 }
125 
126 int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
127 				       const char *prop, const char *nargs_prop,
128 				       unsigned int nargs, unsigned int index,
129 				       struct fwnode_reference_args *args);
130 
131 struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode,
132 					    const char *name,
133 					    unsigned int index);
134 
135 const char *fwnode_get_name(const struct fwnode_handle *fwnode);
136 const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode);
137 
138 struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode);
139 struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode);
140 
141 #define fwnode_for_each_parent_node(fwnode, parent)		\
142 	for (parent = fwnode_get_parent(fwnode); parent;	\
143 	     parent = fwnode_get_next_parent(parent))
144 
145 struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwnode);
146 unsigned int fwnode_count_parents(const struct fwnode_handle *fwn);
147 struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn,
148 					    unsigned int depth);
149 bool fwnode_is_ancestor_of(const struct fwnode_handle *ancestor, const struct fwnode_handle *child);
150 struct fwnode_handle *fwnode_get_next_child_node(
151 	const struct fwnode_handle *fwnode, struct fwnode_handle *child);
152 struct fwnode_handle *fwnode_get_next_available_child_node(
153 	const struct fwnode_handle *fwnode, struct fwnode_handle *child);
154 
155 #define fwnode_for_each_child_node(fwnode, child)			\
156 	for (child = fwnode_get_next_child_node(fwnode, NULL); child;	\
157 	     child = fwnode_get_next_child_node(fwnode, child))
158 
159 #define fwnode_for_each_available_child_node(fwnode, child)		       \
160 	for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
161 	     child = fwnode_get_next_available_child_node(fwnode, child))
162 
163 struct fwnode_handle *device_get_next_child_node(const struct device *dev,
164 						 struct fwnode_handle *child);
165 
166 #define device_for_each_child_node(dev, child)				\
167 	for (child = device_get_next_child_node(dev, NULL); child;	\
168 	     child = device_get_next_child_node(dev, child))
169 
170 struct fwnode_handle *fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
171 						  const char *childname);
172 struct fwnode_handle *device_get_named_child_node(const struct device *dev,
173 						  const char *childname);
174 
175 struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
176 void fwnode_handle_put(struct fwnode_handle *fwnode);
177 
178 int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
179 int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);
180 
181 unsigned int device_get_child_node_count(const struct device *dev);
182 
device_property_read_bool(const struct device * dev,const char * propname)183 static inline bool device_property_read_bool(const struct device *dev,
184 					     const char *propname)
185 {
186 	return device_property_present(dev, propname);
187 }
188 
device_property_read_u8(const struct device * dev,const char * propname,u8 * val)189 static inline int device_property_read_u8(const struct device *dev,
190 					  const char *propname, u8 *val)
191 {
192 	return device_property_read_u8_array(dev, propname, val, 1);
193 }
194 
device_property_read_u16(const struct device * dev,const char * propname,u16 * val)195 static inline int device_property_read_u16(const struct device *dev,
196 					   const char *propname, u16 *val)
197 {
198 	return device_property_read_u16_array(dev, propname, val, 1);
199 }
200 
device_property_read_u32(const struct device * dev,const char * propname,u32 * val)201 static inline int device_property_read_u32(const struct device *dev,
202 					   const char *propname, u32 *val)
203 {
204 	return device_property_read_u32_array(dev, propname, val, 1);
205 }
206 
device_property_read_u64(const struct device * dev,const char * propname,u64 * val)207 static inline int device_property_read_u64(const struct device *dev,
208 					   const char *propname, u64 *val)
209 {
210 	return device_property_read_u64_array(dev, propname, val, 1);
211 }
212 
device_property_count_u8(const struct device * dev,const char * propname)213 static inline int device_property_count_u8(const struct device *dev, const char *propname)
214 {
215 	return device_property_read_u8_array(dev, propname, NULL, 0);
216 }
217 
device_property_count_u16(const struct device * dev,const char * propname)218 static inline int device_property_count_u16(const struct device *dev, const char *propname)
219 {
220 	return device_property_read_u16_array(dev, propname, NULL, 0);
221 }
222 
device_property_count_u32(const struct device * dev,const char * propname)223 static inline int device_property_count_u32(const struct device *dev, const char *propname)
224 {
225 	return device_property_read_u32_array(dev, propname, NULL, 0);
226 }
227 
device_property_count_u64(const struct device * dev,const char * propname)228 static inline int device_property_count_u64(const struct device *dev, const char *propname)
229 {
230 	return device_property_read_u64_array(dev, propname, NULL, 0);
231 }
232 
device_property_string_array_count(const struct device * dev,const char * propname)233 static inline int device_property_string_array_count(const struct device *dev,
234 						     const char *propname)
235 {
236 	return device_property_read_string_array(dev, propname, NULL, 0);
237 }
238 
fwnode_property_read_bool(const struct fwnode_handle * fwnode,const char * propname)239 static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
240 					     const char *propname)
241 {
242 	return fwnode_property_present(fwnode, propname);
243 }
244 
fwnode_property_read_u8(const struct fwnode_handle * fwnode,const char * propname,u8 * val)245 static inline int fwnode_property_read_u8(const struct fwnode_handle *fwnode,
246 					  const char *propname, u8 *val)
247 {
248 	return fwnode_property_read_u8_array(fwnode, propname, val, 1);
249 }
250 
fwnode_property_read_u16(const struct fwnode_handle * fwnode,const char * propname,u16 * val)251 static inline int fwnode_property_read_u16(const struct fwnode_handle *fwnode,
252 					   const char *propname, u16 *val)
253 {
254 	return fwnode_property_read_u16_array(fwnode, propname, val, 1);
255 }
256 
fwnode_property_read_u32(const struct fwnode_handle * fwnode,const char * propname,u32 * val)257 static inline int fwnode_property_read_u32(const struct fwnode_handle *fwnode,
258 					   const char *propname, u32 *val)
259 {
260 	return fwnode_property_read_u32_array(fwnode, propname, val, 1);
261 }
262 
fwnode_property_read_u64(const struct fwnode_handle * fwnode,const char * propname,u64 * val)263 static inline int fwnode_property_read_u64(const struct fwnode_handle *fwnode,
264 					   const char *propname, u64 *val)
265 {
266 	return fwnode_property_read_u64_array(fwnode, propname, val, 1);
267 }
268 
fwnode_property_count_u8(const struct fwnode_handle * fwnode,const char * propname)269 static inline int fwnode_property_count_u8(const struct fwnode_handle *fwnode,
270 					   const char *propname)
271 {
272 	return fwnode_property_read_u8_array(fwnode, propname, NULL, 0);
273 }
274 
fwnode_property_count_u16(const struct fwnode_handle * fwnode,const char * propname)275 static inline int fwnode_property_count_u16(const struct fwnode_handle *fwnode,
276 					    const char *propname)
277 {
278 	return fwnode_property_read_u16_array(fwnode, propname, NULL, 0);
279 }
280 
fwnode_property_count_u32(const struct fwnode_handle * fwnode,const char * propname)281 static inline int fwnode_property_count_u32(const struct fwnode_handle *fwnode,
282 					    const char *propname)
283 {
284 	return fwnode_property_read_u32_array(fwnode, propname, NULL, 0);
285 }
286 
fwnode_property_count_u64(const struct fwnode_handle * fwnode,const char * propname)287 static inline int fwnode_property_count_u64(const struct fwnode_handle *fwnode,
288 					    const char *propname)
289 {
290 	return fwnode_property_read_u64_array(fwnode, propname, NULL, 0);
291 }
292 
293 static inline int
fwnode_property_string_array_count(const struct fwnode_handle * fwnode,const char * propname)294 fwnode_property_string_array_count(const struct fwnode_handle *fwnode,
295 				   const char *propname)
296 {
297 	return fwnode_property_read_string_array(fwnode, propname, NULL, 0);
298 }
299 
300 struct software_node;
301 
302 /**
303  * struct software_node_ref_args - Reference property with additional arguments
304  * @node: Reference to a software node
305  * @nargs: Number of elements in @args array
306  * @args: Integer arguments
307  */
308 struct software_node_ref_args {
309 	const struct software_node *node;
310 	unsigned int nargs;
311 	u64 args[NR_FWNODE_REFERENCE_ARGS];
312 };
313 
314 #define SOFTWARE_NODE_REFERENCE(_ref_, ...)			\
315 (const struct software_node_ref_args) {				\
316 	.node = _ref_,						\
317 	.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1,	\
318 	.args = { __VA_ARGS__ },				\
319 }
320 
321 /**
322  * struct property_entry - "Built-in" device property representation.
323  * @name: Name of the property.
324  * @length: Length of data making up the value.
325  * @is_inline: True when the property value is stored inline.
326  * @type: Type of the data in unions.
327  * @pointer: Pointer to the property when it is not stored inline.
328  * @value: Value of the property when it is stored inline.
329  */
330 struct property_entry {
331 	const char *name;
332 	size_t length;
333 	bool is_inline;
334 	enum dev_prop_type type;
335 	union {
336 		const void *pointer;
337 		union {
338 			u8 u8_data[sizeof(u64) / sizeof(u8)];
339 			u16 u16_data[sizeof(u64) / sizeof(u16)];
340 			u32 u32_data[sizeof(u64) / sizeof(u32)];
341 			u64 u64_data[sizeof(u64) / sizeof(u64)];
342 			const char *str[sizeof(u64) / sizeof(char *)];
343 		} value;
344 	};
345 };
346 
347 /*
348  * Note: the below initializers for the anonymous union are carefully
349  * crafted to avoid gcc-4.4.4's problems with initialization of anon unions
350  * and structs.
351  */
352 #define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_)		\
353 (struct property_entry) {								\
354 	.name = _name_,									\
355 	.length = (_len_) * sizeof_field(struct property_entry, value._elem_[0]),	\
356 	.type = DEV_PROP_##_Type_,							\
357 	{ .pointer = _val_ },								\
358 }
359 
360 #define PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, _len_)		\
361 	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u8_data, U8, _val_, _len_)
362 #define PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, _len_)		\
363 	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u16_data, U16, _val_, _len_)
364 #define PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, _len_)		\
365 	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u32_data, U32, _val_, _len_)
366 #define PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, _len_)		\
367 	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u64_data, U64, _val_, _len_)
368 #define PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, _len_)		\
369 	__PROPERTY_ENTRY_ARRAY_LEN(_name_, str, STRING, _val_, _len_)
370 
371 #define PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, _len_)		\
372 (struct property_entry) {						\
373 	.name = _name_,							\
374 	.length = (_len_) * sizeof(struct software_node_ref_args),	\
375 	.type = DEV_PROP_REF,						\
376 	{ .pointer = _val_ },						\
377 }
378 
379 #define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_)				\
380 	PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
381 #define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_)				\
382 	PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
383 #define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_)				\
384 	PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
385 #define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_)				\
386 	PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
387 #define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_)			\
388 	PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
389 #define PROPERTY_ENTRY_REF_ARRAY(_name_, _val_)				\
390 	PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
391 
392 #define __PROPERTY_ENTRY_ELEMENT(_name_, _elem_, _Type_, _val_)		\
393 (struct property_entry) {						\
394 	.name = _name_,							\
395 	.length = sizeof_field(struct property_entry, value._elem_[0]),	\
396 	.is_inline = true,						\
397 	.type = DEV_PROP_##_Type_,					\
398 	{ .value = { ._elem_[0] = _val_ } },				\
399 }
400 
401 #define PROPERTY_ENTRY_U8(_name_, _val_)				\
402 	__PROPERTY_ENTRY_ELEMENT(_name_, u8_data, U8, _val_)
403 #define PROPERTY_ENTRY_U16(_name_, _val_)				\
404 	__PROPERTY_ENTRY_ELEMENT(_name_, u16_data, U16, _val_)
405 #define PROPERTY_ENTRY_U32(_name_, _val_)				\
406 	__PROPERTY_ENTRY_ELEMENT(_name_, u32_data, U32, _val_)
407 #define PROPERTY_ENTRY_U64(_name_, _val_)				\
408 	__PROPERTY_ENTRY_ELEMENT(_name_, u64_data, U64, _val_)
409 #define PROPERTY_ENTRY_STRING(_name_, _val_)				\
410 	__PROPERTY_ENTRY_ELEMENT(_name_, str, STRING, _val_)
411 
412 #define PROPERTY_ENTRY_REF(_name_, _ref_, ...)				\
413 (struct property_entry) {						\
414 	.name = _name_,							\
415 	.length = sizeof(struct software_node_ref_args),		\
416 	.type = DEV_PROP_REF,						\
417 	{ .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), },	\
418 }
419 
420 #define PROPERTY_ENTRY_BOOL(_name_)		\
421 (struct property_entry) {			\
422 	.name = _name_,				\
423 	.is_inline = true,			\
424 }
425 
426 struct property_entry *
427 property_entries_dup(const struct property_entry *properties);
428 void property_entries_free(const struct property_entry *properties);
429 
430 bool device_dma_supported(const struct device *dev);
431 enum dev_dma_attr device_get_dma_attr(const struct device *dev);
432 
433 const void *device_get_match_data(const struct device *dev);
434 
435 int device_get_phy_mode(struct device *dev);
436 int fwnode_get_phy_mode(const struct fwnode_handle *fwnode);
437 
438 void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index);
439 
440 struct fwnode_handle *fwnode_graph_get_next_endpoint(
441 	const struct fwnode_handle *fwnode, struct fwnode_handle *prev);
442 struct fwnode_handle *
443 fwnode_graph_get_port_parent(const struct fwnode_handle *fwnode);
444 struct fwnode_handle *fwnode_graph_get_remote_port_parent(
445 	const struct fwnode_handle *fwnode);
446 struct fwnode_handle *fwnode_graph_get_remote_port(
447 	const struct fwnode_handle *fwnode);
448 struct fwnode_handle *fwnode_graph_get_remote_endpoint(
449 	const struct fwnode_handle *fwnode);
450 
fwnode_graph_is_endpoint(const struct fwnode_handle * fwnode)451 static inline bool fwnode_graph_is_endpoint(const struct fwnode_handle *fwnode)
452 {
453 	return fwnode_property_present(fwnode, "remote-endpoint");
454 }
455 
456 /*
457  * Fwnode lookup flags
458  *
459  * @FWNODE_GRAPH_ENDPOINT_NEXT: In the case of no exact match, look for the
460  *				closest endpoint ID greater than the specified
461  *				one.
462  * @FWNODE_GRAPH_DEVICE_DISABLED: That the device to which the remote
463  *				  endpoint of the given endpoint belongs to,
464  *				  may be disabled, or that the endpoint is not
465  *				  connected.
466  */
467 #define FWNODE_GRAPH_ENDPOINT_NEXT	BIT(0)
468 #define FWNODE_GRAPH_DEVICE_DISABLED	BIT(1)
469 
470 struct fwnode_handle *
471 fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode,
472 				u32 port, u32 endpoint, unsigned long flags);
473 unsigned int fwnode_graph_get_endpoint_count(const struct fwnode_handle *fwnode,
474 					     unsigned long flags);
475 
476 #define fwnode_graph_for_each_endpoint(fwnode, child)				\
477 	for (child = fwnode_graph_get_next_endpoint(fwnode, NULL); child;	\
478 	     child = fwnode_graph_get_next_endpoint(fwnode, child))
479 
480 int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
481 				struct fwnode_endpoint *endpoint);
482 
483 typedef void *(*devcon_match_fn_t)(const struct fwnode_handle *fwnode, const char *id,
484 				   void *data);
485 
486 void *fwnode_connection_find_match(const struct fwnode_handle *fwnode,
487 				   const char *con_id, void *data,
488 				   devcon_match_fn_t match);
489 
device_connection_find_match(const struct device * dev,const char * con_id,void * data,devcon_match_fn_t match)490 static inline void *device_connection_find_match(const struct device *dev,
491 						 const char *con_id, void *data,
492 						 devcon_match_fn_t match)
493 {
494 	return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match);
495 }
496 
497 int fwnode_connection_find_matches(const struct fwnode_handle *fwnode,
498 				   const char *con_id, void *data,
499 				   devcon_match_fn_t match,
500 				   void **matches, unsigned int matches_len);
501 
502 /* -------------------------------------------------------------------------- */
503 /* Software fwnode support - when HW description is incomplete or missing */
504 
505 /**
506  * struct software_node - Software node description
507  * @name: Name of the software node
508  * @parent: Parent of the software node
509  * @properties: Array of device properties
510  */
511 struct software_node {
512 	const char *name;
513 	const struct software_node *parent;
514 	const struct property_entry *properties;
515 };
516 
517 bool is_software_node(const struct fwnode_handle *fwnode);
518 const struct software_node *
519 to_software_node(const struct fwnode_handle *fwnode);
520 struct fwnode_handle *software_node_fwnode(const struct software_node *node);
521 
522 const struct software_node *
523 software_node_find_by_name(const struct software_node *parent,
524 			   const char *name);
525 
526 int software_node_register_node_group(const struct software_node **node_group);
527 void software_node_unregister_node_group(const struct software_node **node_group);
528 
529 int software_node_register(const struct software_node *node);
530 void software_node_unregister(const struct software_node *node);
531 
532 struct fwnode_handle *
533 fwnode_create_software_node(const struct property_entry *properties,
534 			    const struct fwnode_handle *parent);
535 void fwnode_remove_software_node(struct fwnode_handle *fwnode);
536 
537 int device_add_software_node(struct device *dev, const struct software_node *node);
538 void device_remove_software_node(struct device *dev);
539 
540 int device_create_managed_software_node(struct device *dev,
541 					const struct property_entry *properties,
542 					const struct software_node *parent);
543 
544 #endif /* _LINUX_PROPERTY_H_ */
545