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