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