Commit | Line | Data |
---|---|---|
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 | ||
0fcc2bdc | 13 | #include <linux/bits.h> |
ce793486 | 14 | #include <linux/fwnode.h> |
b31384fa RW |
15 | #include <linux/types.h> |
16 | ||
17 | struct device; | |
18 | ||
19 | enum dev_prop_type { | |
20 | DEV_PROP_U8, | |
21 | DEV_PROP_U16, | |
22 | DEV_PROP_U32, | |
23 | DEV_PROP_U64, | |
24 | DEV_PROP_STRING, | |
e64b674b | 25 | DEV_PROP_REF, |
b31384fa RW |
26 | }; |
27 | ||
1b9863c6 SS |
28 | enum dev_dma_attr { |
29 | DEV_DMA_NOT_SUPPORTED, | |
30 | DEV_DMA_NON_COHERENT, | |
31 | DEV_DMA_COHERENT, | |
32 | }; | |
33 | ||
e44bb0cb SA |
34 | struct fwnode_handle *dev_fwnode(struct device *dev); |
35 | ||
b31384fa RW |
36 | bool device_property_present(struct device *dev, const char *propname); |
37 | int device_property_read_u8_array(struct device *dev, const char *propname, | |
38 | u8 *val, size_t nval); | |
39 | int device_property_read_u16_array(struct device *dev, const char *propname, | |
40 | u16 *val, size_t nval); | |
41 | int device_property_read_u32_array(struct device *dev, const char *propname, | |
42 | u32 *val, size_t nval); | |
43 | int device_property_read_u64_array(struct device *dev, const char *propname, | |
44 | u64 *val, size_t nval); | |
45 | int device_property_read_string_array(struct device *dev, const char *propname, | |
46 | const char **val, size_t nval); | |
47 | int device_property_read_string(struct device *dev, const char *propname, | |
48 | const char **val); | |
3f5c8d31 MW |
49 | int device_property_match_string(struct device *dev, |
50 | const char *propname, const char *string); | |
b31384fa | 51 | |
37ba983c SA |
52 | bool fwnode_device_is_available(const struct fwnode_handle *fwnode); |
53 | bool fwnode_property_present(const struct fwnode_handle *fwnode, | |
54 | const char *propname); | |
55 | int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode, | |
8a0662d9 RW |
56 | const char *propname, u8 *val, |
57 | size_t nval); | |
37ba983c | 58 | int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
59 | const char *propname, u16 *val, |
60 | size_t nval); | |
37ba983c | 61 | int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
62 | const char *propname, u32 *val, |
63 | size_t nval); | |
37ba983c | 64 | int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
65 | const char *propname, u64 *val, |
66 | size_t nval); | |
37ba983c | 67 | int fwnode_property_read_string_array(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
68 | const char *propname, const char **val, |
69 | size_t nval); | |
37ba983c | 70 | int fwnode_property_read_string(const struct fwnode_handle *fwnode, |
8a0662d9 | 71 | const char *propname, const char **val); |
37ba983c | 72 | int fwnode_property_match_string(const struct fwnode_handle *fwnode, |
3f5c8d31 | 73 | const char *propname, const char *string); |
3e3119d3 SA |
74 | int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode, |
75 | const char *prop, const char *nargs_prop, | |
76 | unsigned int nargs, unsigned int index, | |
77 | struct fwnode_reference_args *args); | |
8a0662d9 | 78 | |
83b34afb HK |
79 | struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, |
80 | const char *name, | |
81 | unsigned int index); | |
82 | ||
bc0500c1 | 83 | const char *fwnode_get_name(const struct fwnode_handle *fwnode); |
e7e242bc | 84 | const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode); |
37ba983c SA |
85 | struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode); |
86 | struct fwnode_handle *fwnode_get_next_parent( | |
87 | struct fwnode_handle *fwnode); | |
b5d3e2fb | 88 | struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode); |
87e5e95d SA |
89 | unsigned int fwnode_count_parents(const struct fwnode_handle *fwn); |
90 | struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn, | |
91 | unsigned int depth); | |
b5d3e2fb SK |
92 | bool fwnode_is_ancestor_of(struct fwnode_handle *test_ancestor, |
93 | struct fwnode_handle *test_child); | |
37ba983c SA |
94 | struct fwnode_handle *fwnode_get_next_child_node( |
95 | const struct fwnode_handle *fwnode, struct fwnode_handle *child); | |
3395de96 MW |
96 | struct fwnode_handle *fwnode_get_next_available_child_node( |
97 | const struct fwnode_handle *fwnode, struct fwnode_handle *child); | |
34055190 MW |
98 | |
99 | #define fwnode_for_each_child_node(fwnode, child) \ | |
100 | for (child = fwnode_get_next_child_node(fwnode, NULL); child; \ | |
101 | child = fwnode_get_next_child_node(fwnode, child)) | |
afaf26fd | 102 | |
3395de96 MW |
103 | #define fwnode_for_each_available_child_node(fwnode, child) \ |
104 | for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\ | |
105 | child = fwnode_get_next_available_child_node(fwnode, child)) | |
106 | ||
37ba983c SA |
107 | struct fwnode_handle *device_get_next_child_node( |
108 | struct device *dev, struct fwnode_handle *child); | |
8a0662d9 | 109 | |
1d656fb7 AS |
110 | #define device_for_each_child_node(dev, child) \ |
111 | for (child = device_get_next_child_node(dev, NULL); child; \ | |
8a0662d9 RW |
112 | child = device_get_next_child_node(dev, child)) |
113 | ||
37ba983c SA |
114 | struct fwnode_handle *fwnode_get_named_child_node( |
115 | const struct fwnode_handle *fwnode, const char *childname); | |
613e9721 AT |
116 | struct fwnode_handle *device_get_named_child_node(struct device *dev, |
117 | const char *childname); | |
118 | ||
cf89a31c | 119 | struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); |
8a0662d9 RW |
120 | void fwnode_handle_put(struct fwnode_handle *fwnode); |
121 | ||
fb38f314 | 122 | int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); |
7c6c57f2 | 123 | |
8a0662d9 RW |
124 | unsigned int device_get_child_node_count(struct device *dev); |
125 | ||
b31384fa RW |
126 | static inline bool device_property_read_bool(struct device *dev, |
127 | const char *propname) | |
128 | { | |
129 | return device_property_present(dev, propname); | |
130 | } | |
131 | ||
132 | static inline int device_property_read_u8(struct device *dev, | |
133 | const char *propname, u8 *val) | |
134 | { | |
135 | return device_property_read_u8_array(dev, propname, val, 1); | |
136 | } | |
137 | ||
138 | static inline int device_property_read_u16(struct device *dev, | |
139 | const char *propname, u16 *val) | |
140 | { | |
141 | return device_property_read_u16_array(dev, propname, val, 1); | |
142 | } | |
143 | ||
144 | static inline int device_property_read_u32(struct device *dev, | |
145 | const char *propname, u32 *val) | |
146 | { | |
147 | return device_property_read_u32_array(dev, propname, val, 1); | |
148 | } | |
149 | ||
150 | static inline int device_property_read_u64(struct device *dev, | |
151 | const char *propname, u64 *val) | |
152 | { | |
153 | return device_property_read_u64_array(dev, propname, val, 1); | |
154 | } | |
155 | ||
33ee09cd AS |
156 | static inline int device_property_count_u8(struct device *dev, const char *propname) |
157 | { | |
158 | return device_property_read_u8_array(dev, propname, NULL, 0); | |
159 | } | |
160 | ||
161 | static inline int device_property_count_u16(struct device *dev, const char *propname) | |
162 | { | |
163 | return device_property_read_u16_array(dev, propname, NULL, 0); | |
164 | } | |
165 | ||
166 | static inline int device_property_count_u32(struct device *dev, const char *propname) | |
167 | { | |
168 | return device_property_read_u32_array(dev, propname, NULL, 0); | |
169 | } | |
170 | ||
171 | static inline int device_property_count_u64(struct device *dev, const char *propname) | |
172 | { | |
173 | return device_property_read_u64_array(dev, propname, NULL, 0); | |
174 | } | |
175 | ||
6b6ff4ac BG |
176 | static inline int device_property_string_array_count(struct device *dev, |
177 | const char *propname) | |
178 | { | |
179 | return device_property_read_string_array(dev, propname, NULL, 0); | |
180 | } | |
181 | ||
37ba983c | 182 | static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
183 | const char *propname) |
184 | { | |
185 | return fwnode_property_present(fwnode, propname); | |
186 | } | |
187 | ||
37ba983c | 188 | static inline int fwnode_property_read_u8(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
189 | const char *propname, u8 *val) |
190 | { | |
191 | return fwnode_property_read_u8_array(fwnode, propname, val, 1); | |
192 | } | |
193 | ||
37ba983c | 194 | static inline int fwnode_property_read_u16(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
195 | const char *propname, u16 *val) |
196 | { | |
197 | return fwnode_property_read_u16_array(fwnode, propname, val, 1); | |
198 | } | |
199 | ||
37ba983c | 200 | static inline int fwnode_property_read_u32(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
201 | const char *propname, u32 *val) |
202 | { | |
203 | return fwnode_property_read_u32_array(fwnode, propname, val, 1); | |
204 | } | |
205 | ||
37ba983c | 206 | static inline int fwnode_property_read_u64(const struct fwnode_handle *fwnode, |
8a0662d9 RW |
207 | const char *propname, u64 *val) |
208 | { | |
209 | return fwnode_property_read_u64_array(fwnode, propname, val, 1); | |
210 | } | |
211 | ||
33ee09cd AS |
212 | static inline int fwnode_property_count_u8(const struct fwnode_handle *fwnode, |
213 | const char *propname) | |
214 | { | |
215 | return fwnode_property_read_u8_array(fwnode, propname, NULL, 0); | |
216 | } | |
217 | ||
218 | static inline int fwnode_property_count_u16(const struct fwnode_handle *fwnode, | |
219 | const char *propname) | |
220 | { | |
221 | return fwnode_property_read_u16_array(fwnode, propname, NULL, 0); | |
222 | } | |
223 | ||
224 | static inline int fwnode_property_count_u32(const struct fwnode_handle *fwnode, | |
225 | const char *propname) | |
226 | { | |
227 | return fwnode_property_read_u32_array(fwnode, propname, NULL, 0); | |
228 | } | |
229 | ||
230 | static inline int fwnode_property_count_u64(const struct fwnode_handle *fwnode, | |
231 | const char *propname) | |
232 | { | |
233 | return fwnode_property_read_u64_array(fwnode, propname, NULL, 0); | |
234 | } | |
235 | ||
6b6ff4ac BG |
236 | static inline int |
237 | fwnode_property_string_array_count(const struct fwnode_handle *fwnode, | |
238 | const char *propname) | |
239 | { | |
240 | return fwnode_property_read_string_array(fwnode, propname, NULL, 0); | |
241 | } | |
242 | ||
e64b674b DT |
243 | struct software_node; |
244 | ||
245 | /** | |
246 | * struct software_node_ref_args - Reference property with additional arguments | |
247 | * @node: Reference to a software node | |
248 | * @nargs: Number of elements in @args array | |
249 | * @args: Integer arguments | |
250 | */ | |
251 | struct software_node_ref_args { | |
252 | const struct software_node *node; | |
253 | unsigned int nargs; | |
254 | u64 args[NR_FWNODE_REFERENCE_ARGS]; | |
255 | }; | |
256 | ||
e588fead AS |
257 | #define SOFTWARE_NODE_REFERENCE(_ref_, ...) \ |
258 | (const struct software_node_ref_args) { \ | |
259 | .node = _ref_, \ | |
260 | .nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1, \ | |
261 | .args = { __VA_ARGS__ }, \ | |
262 | } | |
263 | ||
16ba08d5 RW |
264 | /** |
265 | * struct property_entry - "Built-in" device property representation. | |
266 | * @name: Name of the property. | |
318a1971 | 267 | * @length: Length of data making up the value. |
e6bff466 | 268 | * @is_inline: True when the property value is stored inline. |
63dcc709 | 269 | * @type: Type of the data in unions. |
e6bff466 DT |
270 | * @pointer: Pointer to the property when it is not stored inline. |
271 | * @value: Value of the property when it is stored inline. | |
16ba08d5 RW |
272 | */ |
273 | struct property_entry { | |
274 | const char *name; | |
318a1971 | 275 | size_t length; |
e6bff466 | 276 | bool is_inline; |
63dcc709 | 277 | enum dev_prop_type type; |
16ba08d5 | 278 | union { |
1f74d70f | 279 | const void *pointer; |
66586bab | 280 | union { |
996b0830 DT |
281 | u8 u8_data[sizeof(u64) / sizeof(u8)]; |
282 | u16 u16_data[sizeof(u64) / sizeof(u16)]; | |
283 | u32 u32_data[sizeof(u64) / sizeof(u32)]; | |
284 | u64 u64_data[sizeof(u64) / sizeof(u64)]; | |
285 | const char *str[sizeof(u64) / sizeof(char *)]; | |
66586bab AS |
286 | } value; |
287 | }; | |
16ba08d5 RW |
288 | }; |
289 | ||
d76eebfa | 290 | /* |
daeba9bf | 291 | * Note: the below initializers for the anonymous union are carefully |
d76eebfa AM |
292 | * crafted to avoid gcc-4.4.4's problems with initialization of anon unions |
293 | * and structs. | |
294 | */ | |
295 | ||
daeba9bf | 296 | #define __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_) \ |
996b0830 | 297 | sizeof(((struct property_entry *)NULL)->value._elem_[0]) |
daeba9bf | 298 | |
e64b674b DT |
299 | #define __PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, _elsize_, _Type_, \ |
300 | _val_, _len_) \ | |
63dcc709 AS |
301 | (struct property_entry) { \ |
302 | .name = _name_, \ | |
e64b674b | 303 | .length = (_len_) * (_elsize_), \ |
63dcc709 | 304 | .type = DEV_PROP_##_Type_, \ |
1f74d70f | 305 | { .pointer = _val_ }, \ |
a85f4204 HK |
306 | } |
307 | ||
e64b674b DT |
308 | #define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_)\ |
309 | __PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, \ | |
310 | __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_), \ | |
311 | _Type_, _val_, _len_) | |
312 | ||
1741cfac | 313 | #define PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, _len_) \ |
daeba9bf | 314 | __PROPERTY_ENTRY_ARRAY_LEN(_name_, u8_data, U8, _val_, _len_) |
1741cfac | 315 | #define PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, _len_) \ |
daeba9bf | 316 | __PROPERTY_ENTRY_ARRAY_LEN(_name_, u16_data, U16, _val_, _len_) |
1741cfac | 317 | #define PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, _len_) \ |
daeba9bf | 318 | __PROPERTY_ENTRY_ARRAY_LEN(_name_, u32_data, U32, _val_, _len_) |
1741cfac | 319 | #define PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, _len_) \ |
daeba9bf | 320 | __PROPERTY_ENTRY_ARRAY_LEN(_name_, u64_data, U64, _val_, _len_) |
1741cfac | 321 | #define PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, _len_) \ |
daeba9bf | 322 | __PROPERTY_ENTRY_ARRAY_LEN(_name_, str, STRING, _val_, _len_) |
e64b674b DT |
323 | #define PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, _len_) \ |
324 | __PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, \ | |
325 | sizeof(struct software_node_ref_args), \ | |
326 | REF, _val_, _len_) | |
a85f4204 | 327 | |
1741cfac DT |
328 | #define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_) \ |
329 | PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_)) | |
330 | #define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_) \ | |
331 | PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_)) | |
332 | #define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_) \ | |
333 | PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_)) | |
334 | #define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_) \ | |
335 | PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_)) | |
336 | #define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_) \ | |
337 | PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_)) | |
e64b674b DT |
338 | #define PROPERTY_ENTRY_REF_ARRAY(_name_, _val_) \ |
339 | PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_)) | |
1741cfac | 340 | |
daeba9bf DT |
341 | #define __PROPERTY_ENTRY_ELEMENT(_name_, _elem_, _Type_, _val_) \ |
342 | (struct property_entry) { \ | |
343 | .name = _name_, \ | |
344 | .length = __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_), \ | |
e6bff466 | 345 | .is_inline = true, \ |
daeba9bf | 346 | .type = DEV_PROP_##_Type_, \ |
996b0830 | 347 | { .value = { ._elem_[0] = _val_ } }, \ |
a85f4204 HK |
348 | } |
349 | ||
daeba9bf DT |
350 | #define PROPERTY_ENTRY_U8(_name_, _val_) \ |
351 | __PROPERTY_ENTRY_ELEMENT(_name_, u8_data, U8, _val_) | |
352 | #define PROPERTY_ENTRY_U16(_name_, _val_) \ | |
353 | __PROPERTY_ENTRY_ELEMENT(_name_, u16_data, U16, _val_) | |
354 | #define PROPERTY_ENTRY_U32(_name_, _val_) \ | |
355 | __PROPERTY_ENTRY_ELEMENT(_name_, u32_data, U32, _val_) | |
356 | #define PROPERTY_ENTRY_U64(_name_, _val_) \ | |
357 | __PROPERTY_ENTRY_ELEMENT(_name_, u64_data, U64, _val_) | |
358 | #define PROPERTY_ENTRY_STRING(_name_, _val_) \ | |
359 | __PROPERTY_ENTRY_ELEMENT(_name_, str, STRING, _val_) | |
a85f4204 HK |
360 | |
361 | #define PROPERTY_ENTRY_BOOL(_name_) \ | |
c505cbd4 | 362 | (struct property_entry) { \ |
a85f4204 | 363 | .name = _name_, \ |
e6bff466 | 364 | .is_inline = true, \ |
a85f4204 HK |
365 | } |
366 | ||
e64b674b DT |
367 | #define PROPERTY_ENTRY_REF(_name_, _ref_, ...) \ |
368 | (struct property_entry) { \ | |
369 | .name = _name_, \ | |
370 | .length = sizeof(struct software_node_ref_args), \ | |
371 | .type = DEV_PROP_REF, \ | |
e588fead | 372 | { .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), }, \ |
e64b674b DT |
373 | } |
374 | ||
2d479e1f DT |
375 | struct property_entry * |
376 | property_entries_dup(const struct property_entry *properties); | |
377 | ||
378 | void property_entries_free(const struct property_entry *properties); | |
379 | ||
f4d05266 | 380 | int device_add_properties(struct device *dev, |
bec84da8 | 381 | const struct property_entry *properties); |
f4d05266 | 382 | void device_remove_properties(struct device *dev); |
16ba08d5 | 383 | |
e5e55864 SS |
384 | bool device_dma_supported(struct device *dev); |
385 | ||
386 | enum dev_dma_attr device_get_dma_attr(struct device *dev); | |
b283f157 | 387 | |
67dcc26d | 388 | const void *device_get_match_data(struct device *dev); |
e5e55864 | 389 | |
4c96b7dc JL |
390 | int device_get_phy_mode(struct device *dev); |
391 | ||
b28f263b | 392 | int fwnode_get_phy_mode(struct fwnode_handle *fwnode); |
07bb80d4 | 393 | struct fwnode_handle *fwnode_graph_get_next_endpoint( |
37ba983c | 394 | const struct fwnode_handle *fwnode, struct fwnode_handle *prev); |
6a71d8d7 | 395 | struct fwnode_handle * |
37ba983c | 396 | fwnode_graph_get_port_parent(const struct fwnode_handle *fwnode); |
07bb80d4 | 397 | struct fwnode_handle *fwnode_graph_get_remote_port_parent( |
37ba983c | 398 | const struct fwnode_handle *fwnode); |
07bb80d4 | 399 | struct fwnode_handle *fwnode_graph_get_remote_port( |
37ba983c | 400 | const struct fwnode_handle *fwnode); |
07bb80d4 | 401 | struct fwnode_handle *fwnode_graph_get_remote_endpoint( |
37ba983c SA |
402 | const struct fwnode_handle *fwnode); |
403 | struct fwnode_handle * | |
404 | fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port, | |
405 | u32 endpoint); | |
07bb80d4 | 406 | |
35694afc LP |
407 | static inline bool fwnode_graph_is_endpoint(struct fwnode_handle *fwnode) |
408 | { | |
409 | return fwnode_property_present(fwnode, "remote-endpoint"); | |
410 | } | |
411 | ||
0fcc2bdc SA |
412 | /* |
413 | * Fwnode lookup flags | |
414 | * | |
415 | * @FWNODE_GRAPH_ENDPOINT_NEXT: In the case of no exact match, look for the | |
416 | * closest endpoint ID greater than the specified | |
417 | * one. | |
418 | * @FWNODE_GRAPH_DEVICE_DISABLED: That the device to which the remote | |
419 | * endpoint of the given endpoint belongs to, | |
420 | * may be disabled. | |
421 | */ | |
422 | #define FWNODE_GRAPH_ENDPOINT_NEXT BIT(0) | |
423 | #define FWNODE_GRAPH_DEVICE_DISABLED BIT(1) | |
424 | ||
425 | struct fwnode_handle * | |
426 | fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode, | |
427 | u32 port, u32 endpoint, unsigned long flags); | |
428 | ||
5e4b1b70 SA |
429 | #define fwnode_graph_for_each_endpoint(fwnode, child) \ |
430 | for (child = NULL; \ | |
431 | (child = fwnode_graph_get_next_endpoint(fwnode, child)); ) | |
432 | ||
37ba983c | 433 | int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, |
2bd5452d SA |
434 | struct fwnode_endpoint *endpoint); |
435 | ||
d7cf5590 HK |
436 | typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id, |
437 | void *data); | |
438 | ||
439 | void *fwnode_connection_find_match(struct fwnode_handle *fwnode, | |
440 | const char *con_id, void *data, | |
441 | devcon_match_fn_t match); | |
442 | ||
443 | static inline void *device_connection_find_match(struct device *dev, | |
444 | const char *con_id, void *data, | |
445 | devcon_match_fn_t match) | |
446 | { | |
447 | return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match); | |
448 | } | |
449 | ||
59abd836 HK |
450 | /* -------------------------------------------------------------------------- */ |
451 | /* Software fwnode support - when HW description is incomplete or missing */ | |
452 | ||
80488a6b HK |
453 | /** |
454 | * struct software_node - Software node description | |
455 | * @name: Name of the software node | |
456 | * @parent: Parent of the software node | |
457 | * @properties: Array of device properties | |
458 | */ | |
459 | struct software_node { | |
460 | const char *name; | |
461 | const struct software_node *parent; | |
462 | const struct property_entry *properties; | |
463 | }; | |
464 | ||
59abd836 | 465 | bool is_software_node(const struct fwnode_handle *fwnode); |
56c9aa07 SA |
466 | const struct software_node * |
467 | to_software_node(const struct fwnode_handle *fwnode); | |
80488a6b HK |
468 | struct fwnode_handle *software_node_fwnode(const struct software_node *node); |
469 | ||
1666faed HK |
470 | const struct software_node * |
471 | software_node_find_by_name(const struct software_node *parent, | |
472 | const char *name); | |
473 | ||
80488a6b HK |
474 | int software_node_register_nodes(const struct software_node *nodes); |
475 | void software_node_unregister_nodes(const struct software_node *nodes); | |
476 | ||
02094d54 AS |
477 | int software_node_register_node_group(const struct software_node **node_group); |
478 | void software_node_unregister_node_group(const struct software_node **node_group); | |
479 | ||
80488a6b | 480 | int software_node_register(const struct software_node *node); |
46d26819 | 481 | void software_node_unregister(const struct software_node *node); |
59abd836 | 482 | |
59abd836 HK |
483 | struct fwnode_handle * |
484 | fwnode_create_software_node(const struct property_entry *properties, | |
485 | const struct fwnode_handle *parent); | |
486 | void fwnode_remove_software_node(struct fwnode_handle *fwnode); | |
487 | ||
2a92c90f | 488 | int device_add_software_node(struct device *dev, const struct software_node *node); |
e68d0119 HK |
489 | void device_remove_software_node(struct device *dev); |
490 | ||
151f6ff7 HK |
491 | int device_create_managed_software_node(struct device *dev, |
492 | const struct property_entry *properties, | |
493 | const struct software_node *parent); | |
494 | ||
b31384fa | 495 | #endif /* _LINUX_PROPERTY_H_ */ |