Lines Matching +full:io +full:- +full:backends
1 // SPDX-License-Identifier: GPL-2.0+
3 * drivers/of/property.c - Procedures for accessing and interpreting
11 * Copyright (C) 1996-2005 Paul Mackerras.
35 * of_property_read_bool - Find a property
39 * Search for a boolean property in a device node. Usage on non-boolean
53 if (prop && prop->length)
61 * of_graph_is_present() - check graph's presence
64 * Return: True if @node has a port or ports (with a port) sub-node,
81 * of_property_count_elems_of_size - Count the number of elements in a property
90 * Return: The number of elements on sucess, -EINVAL if the property does not
91 * exist or its length does not match a multiple of elem_size and -ENODATA if
100 return -EINVAL;
101 if (!prop->value)
102 return -ENODATA;
104 if (prop->length % elem_size != 0) {
107 return -EINVAL;
110 return prop->length / elem_size;
125 * Return: The property value on success, -EINVAL if the property does not
126 * exist, -ENODATA if property does not have a value, and -EOVERFLOW if the
136 return ERR_PTR(-EINVAL);
137 if (!prop->value)
138 return ERR_PTR(-ENODATA);
139 if (prop->length < min)
140 return ERR_PTR(-EOVERFLOW);
141 if (max && prop->length > max)
142 return ERR_PTR(-EOVERFLOW);
145 *len = prop->length;
147 return prop->value;
151 * of_property_read_u16_index - Find and read a u16 from a multi-value property.
158 * Search for a property in a device node and read nth 16-bit value from
161 * Return: 0 on success, -EINVAL if the property does not exist,
162 * -ENODATA if property does not have a value, and -EOVERFLOW if the
184 * of_property_read_u32_index - Find and read a u32 from a multi-value property.
191 * Search for a property in a device node and read nth 32-bit value from
194 * Return: 0 on success, -EINVAL if the property does not exist,
195 * -ENODATA if property does not have a value, and -EOVERFLOW if the
218 * of_property_read_u64_index - Find and read a u64 from a multi-value property.
225 * Search for a property in a device node and read nth 64-bit value from
228 * Return: 0 on success, -EINVAL if the property does not exist,
229 * -ENODATA if property does not have a value, and -EOVERFLOW if the
251 * of_property_read_variable_u8_array - Find and read an array of u8 from a
262 * Search for a property in a device node and read 8-bit value(s) from
268 * Return: The number of elements read on success, -EINVAL if the property
269 * does not exist, -ENODATA if property does not have a value, and -EOVERFLOW
293 while (count--)
301 * of_property_read_variable_u16_array - Find and read an array of u16 from a
312 * Search for a property in a device node and read 16-bit value(s) from
318 * Return: The number of elements read on success, -EINVAL if the property
319 * does not exist, -ENODATA if property does not have a value, and -EOVERFLOW
343 while (count--)
351 * of_property_read_variable_u32_array - Find and read an array of 32 bit
362 * Search for a property in a device node and read 32-bit value(s) from
365 * Return: The number of elements read on success, -EINVAL if the property
366 * does not exist, -ENODATA if property does not have a value, and -EOVERFLOW
390 while (count--)
398 * of_property_read_u64 - Find and read a 64 bit integer from a property
403 * Search for a property in a device node and read a 64-bit value from
406 * Return: 0 on success, -EINVAL if the property does not exist,
407 * -ENODATA if property does not have a value, and -EOVERFLOW if the
429 * of_property_read_variable_u64_array - Find and read an array of 64 bit
440 * Search for a property in a device node and read 64-bit value(s) from
443 * Return: The number of elements read on success, -EINVAL if the property
444 * does not exist, -ENODATA if property does not have a value, and -EOVERFLOW
468 while (count--) {
478 * of_property_read_string - Find and read a string from a property
487 * Return: 0 on success, -EINVAL if the property does not exist, -ENODATA if
488 * property does not have a value, and -EILSEQ if the string is not
489 * null-terminated within the length of the property data.
491 * Note that the empty string "" has length of 1, thus -ENODATA cannot
502 return -EINVAL;
503 if (!prop->length)
504 return -ENODATA;
505 if (strnlen(prop->value, prop->length) >= prop->length)
506 return -EILSEQ;
507 *out_string = prop->value;
513 * of_property_match_string() - Find string in a list and return index
521 * Return: the index of the first occurrence of the string on success, -EINVAL
522 * if the property does not exist, -ENODATA if the property does not have a
523 * value, and -EILSEQ if the string is not null-terminated within the length of
535 return -EINVAL;
536 if (!prop->value)
537 return -ENODATA;
539 p = prop->value;
540 end = p + prop->length;
543 l = strnlen(p, end - p) + 1;
545 return -EILSEQ;
550 return -ENODATA;
555 * of_property_read_string_helper() - Utility helper for parsing string properties
574 return -EINVAL;
575 if (!prop->value)
576 return -ENODATA;
577 p = prop->value;
578 end = p + prop->length;
581 l = strnlen(p, end - p) + 1;
583 return -EILSEQ;
587 i -= skip;
588 return i <= 0 ? -ENODATA : i;
601 curv = prop->value;
606 if (curv >= prop->value + prop->length)
623 return prop->value;
626 if (curv >= prop->value + prop->length)
634 * of_graph_parse_endpoint() - parse common endpoint node properties
651 endpoint->local_node = node;
656 of_property_read_u32(port_node, "reg", &endpoint->port);
657 of_property_read_u32(node, "reg", &endpoint->id);
664 * of_graph_get_port_by_id() - get the port matching a given id
693 * of_graph_get_next_port() - get next port node.
730 * of_graph_get_next_port_endpoint() - get next endpoint node in port.
757 * of_graph_get_next_endpoint() - get next endpoint node
814 * of_graph_get_endpoint_by_regs() - get endpoint node of specific identifiers
821 * ignored when they are -1. Use of_node_put() on the pointer when done.
831 if (((port_reg == -1) || (endpoint.port == port_reg)) &&
832 ((reg == -1) || (endpoint.id == reg)))
841 * of_graph_get_remote_endpoint() - get remote endpoint node
850 return of_parse_phandle(node, "remote-endpoint", 0);
855 * of_graph_get_port_parent() - get port's parent node
875 for (depth = 3; depth && node; depth--) {
878 !of_node_name_eq(node, "in-ports") &&
879 !of_node_name_eq(node, "out-ports"))
887 * of_graph_get_remote_port_parent() - get remote port's parent node
905 * of_graph_get_remote_port() - get remote port node
924 * of_graph_get_endpoint_count() - get the number of endpoints in a device node
942 * of_graph_get_port_count() - get the number of port in a device or ports node
959 * of_graph_get_remote_node() - get remote parent device_node for given port/endpoint
1059 return -ENXIO;
1076 return kbasename(to_of_node(fwnode)->full_name);
1082 if (!to_of_node(fwnode)->parent)
1139 args->nargs = of_args.args_count;
1140 args->fwnode = of_fwnode_handle(of_args.np);
1143 args->args[i] = i < of_args.args_count ? of_args.args[i] : 0;
1186 endpoint->local_fwnode = fwnode;
1188 of_property_read_u32(port_node, "reg", &endpoint->port);
1189 of_property_read_u32(node, "reg", &endpoint->id);
1209 if (of_fwnode_handle(tmp_np)->dev)
1222 * parse_prop_cells - Property parsing function for suppliers
1236 * - phandle node pointer with refcount incremented. Caller must of_node_put()
1238 * - NULL if no phandle found at index
1271 return -1;
1272 return strcmp(str + len - suffix_len, suffix);
1276 * parse_suffix_prop_cells - Suffix property parsing function for suppliers
1290 * - phandle node pointer with refcount incremented. Caller must of_node_put()
1292 * - NULL if no phandle found at index
1319 * struct supplier_bindings - Property parsing functions for suppliers
1336 * - phandle node pointer with refcount incremented. Caller must of_node_put()
1338 * - NULL if no phandle found at index
1348 DEFINE_SIMPLE_PROP(clocks, "clocks", "#clock-cells")
1349 DEFINE_SIMPLE_PROP(interconnects, "interconnects", "#interconnect-cells")
1350 DEFINE_SIMPLE_PROP(iommus, "iommus", "#iommu-cells")
1351 DEFINE_SIMPLE_PROP(mboxes, "mboxes", "#mbox-cells")
1352 DEFINE_SIMPLE_PROP(io_channels, "io-channels", "#io-channel-cells")
1353 DEFINE_SIMPLE_PROP(io_backends, "io-backends", "#io-backend-cells")
1354 DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells")
1355 DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells")
1356 DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells")
1358 DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", "#nvmem-cell-cells")
1359 DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells")
1360 DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL)
1361 DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL)
1362 DEFINE_SIMPLE_PROP(pinctrl1, "pinctrl-1", NULL)
1363 DEFINE_SIMPLE_PROP(pinctrl2, "pinctrl-2", NULL)
1364 DEFINE_SIMPLE_PROP(pinctrl3, "pinctrl-3", NULL)
1365 DEFINE_SIMPLE_PROP(pinctrl4, "pinctrl-4", NULL)
1366 DEFINE_SIMPLE_PROP(pinctrl5, "pinctrl-5", NULL)
1367 DEFINE_SIMPLE_PROP(pinctrl6, "pinctrl-6", NULL)
1368 DEFINE_SIMPLE_PROP(pinctrl7, "pinctrl-7", NULL)
1369 DEFINE_SIMPLE_PROP(pinctrl8, "pinctrl-8", NULL)
1370 DEFINE_SIMPLE_PROP(pwms, "pwms", "#pwm-cells")
1371 DEFINE_SIMPLE_PROP(resets, "resets", "#reset-cells")
1375 DEFINE_SIMPLE_PROP(msi_parent, "msi-parent", "#msi-cells")
1376 DEFINE_SIMPLE_PROP(post_init_providers, "post-init-providers", NULL)
1377 DEFINE_SIMPLE_PROP(access_controllers, "access-controllers", "#access-controller-cells")
1378 DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells")
1379 DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL)
1380 DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)
1381 DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
1386 if (!strcmp_suffix(prop_name, ",nr-gpios"))
1389 return parse_suffix_prop_cells(np, prop_name, index, "-gpios",
1390 "#gpio-cells");
1396 if (strcmp(prop_name, "iommu-map"))
1411 * Ignore node with gpio-hog property since its gpios are all provided
1414 if (of_property_read_bool(np, "gpio-hog"))
1417 if (of_parse_phandle_with_args(np, prop_name, "#gpio-cells", index,
1433 strcmp(prop_name, "interrupts-extended"))
1450 if (strcmp(prop_name, "interrupt-map"))
1453 if (of_property_read_u32(np, "#interrupt-cells", &intcells))
1457 imap = of_get_property(np, "interrupt-map", &imaplen);
1467 imap = of_irq_parse_imap_parent(imap, imap_end - imap, &sup_args);
1484 /* Return NULL for index > 0 to signify end of remote-endpoints. */
1485 if (index > 0 || strcmp(prop_name, "remote-endpoint"))
1542 * of_link_property - Create device links to suppliers listed in a property
1568 while (!matched && s->parse_prop) {
1569 if (s->optional && !fw_devlink_is_strict()) {
1574 while ((phandle = s->parse_prop(con_np, prop_name, i))) {
1576 s->get_con_dev ? s->get_con_dev(con_np) : of_node_get(con_np);
1580 of_link_to_phandle(con_dev_np, phandle, s->fwlink_flags);
1612 return -EINVAL;
1615 of_link_property(con_np, p->name);