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) in of_property_read_bool()
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; in of_property_count_elems_of_size()
101 if (!prop->value) in of_property_count_elems_of_size()
102 return -ENODATA; in of_property_count_elems_of_size()
104 if (prop->length % elem_size != 0) { in of_property_count_elems_of_size()
107 return -EINVAL; in of_property_count_elems_of_size()
110 return prop->length / elem_size; in of_property_count_elems_of_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); in of_find_property_value_of_size()
137 if (!prop->value) in of_find_property_value_of_size()
138 return ERR_PTR(-ENODATA); in of_find_property_value_of_size()
139 if (prop->length < min) in of_find_property_value_of_size()
140 return ERR_PTR(-EOVERFLOW); in of_find_property_value_of_size()
141 if (max && prop->length > max) in of_find_property_value_of_size()
142 return ERR_PTR(-EOVERFLOW); in of_find_property_value_of_size()
145 *len = prop->length; in of_find_property_value_of_size()
147 return prop->value; in of_find_property_value_of_size()
151 * of_property_read_u32_index - Find and read a u32 from a multi-value property.
158 * Search for a property in a device node and read nth 32-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
185 * of_property_read_u64_index - Find and read a u64 from a multi-value property.
192 * Search for a property in a device node and read nth 64-bit value from
195 * Return: 0 on success, -EINVAL if the property does not exist,
196 * -ENODATA if property does not have a value, and -EOVERFLOW if the
218 * of_property_read_variable_u8_array - Find and read an array of u8 from a
229 * Search for a property in a device node and read 8-bit value(s) from
235 * Return: The number of elements read on success, -EINVAL if the property
236 * does not exist, -ENODATA if property does not have a value, and -EOVERFLOW
260 while (count--) in of_property_read_variable_u8_array()
268 * of_property_read_variable_u16_array - Find and read an array of u16 from a
279 * Search for a property in a device node and read 16-bit value(s) from
285 * Return: The number of elements read on success, -EINVAL if the property
286 * does not exist, -ENODATA if property does not have a value, and -EOVERFLOW
310 while (count--) in of_property_read_variable_u16_array()
318 * of_property_read_variable_u32_array - Find and read an array of 32 bit
329 * Search for a property in a device node and read 32-bit value(s) from
332 * Return: The number of elements read on success, -EINVAL if the property
333 * does not exist, -ENODATA if property does not have a value, and -EOVERFLOW
357 while (count--) in of_property_read_variable_u32_array()
365 * of_property_read_u64 - Find and read a 64 bit integer from a property
370 * Search for a property in a device node and read a 64-bit value from
373 * Return: 0 on success, -EINVAL if the property does not exist,
374 * -ENODATA if property does not have a value, and -EOVERFLOW if the
396 * of_property_read_variable_u64_array - Find and read an array of 64 bit
407 * Search for a property in a device node and read 64-bit value(s) from
410 * Return: The number of elements read on success, -EINVAL if the property
411 * does not exist, -ENODATA if property does not have a value, and -EOVERFLOW
435 while (count--) { in of_property_read_variable_u64_array()
445 * of_property_read_string - Find and read a string from a property
454 * Return: 0 on success, -EINVAL if the property does not exist, -ENODATA if
455 * property does not have a value, and -EILSEQ if the string is not
456 * null-terminated within the length of the property data.
458 * Note that the empty string "" has length of 1, thus -ENODATA cannot
469 return -EINVAL; in of_property_read_string()
470 if (!prop->length) in of_property_read_string()
471 return -ENODATA; in of_property_read_string()
472 if (strnlen(prop->value, prop->length) >= prop->length) in of_property_read_string()
473 return -EILSEQ; in of_property_read_string()
474 *out_string = prop->value; in of_property_read_string()
480 * of_property_match_string() - Find string in a list and return index
488 * Return: the index of the first occurrence of the string on success, -EINVAL
489 * if the property does not exist, -ENODATA if the property does not have a
490 * value, and -EILSEQ if the string is not null-terminated within the length of
502 return -EINVAL; in of_property_match_string()
503 if (!prop->value) in of_property_match_string()
504 return -ENODATA; in of_property_match_string()
506 p = prop->value; in of_property_match_string()
507 end = p + prop->length; in of_property_match_string()
510 l = strnlen(p, end - p) + 1; in of_property_match_string()
512 return -EILSEQ; in of_property_match_string()
517 return -ENODATA; in of_property_match_string()
522 * of_property_read_string_helper() - Utility helper for parsing string properties
541 return -EINVAL; in of_property_read_string_helper()
542 if (!prop->value) in of_property_read_string_helper()
543 return -ENODATA; in of_property_read_string_helper()
544 p = prop->value; in of_property_read_string_helper()
545 end = p + prop->length; in of_property_read_string_helper()
548 l = strnlen(p, end - p) + 1; in of_property_read_string_helper()
550 return -EILSEQ; in of_property_read_string_helper()
554 i -= skip; in of_property_read_string_helper()
555 return i <= 0 ? -ENODATA : i; in of_property_read_string_helper()
568 curv = prop->value; in of_prop_next_u32()
573 if (curv >= prop->value + prop->length) in of_prop_next_u32()
590 return prop->value; in of_prop_next_string()
593 if (curv >= prop->value + prop->length) in of_prop_next_string()
601 * of_graph_parse_endpoint() - parse common endpoint node properties
618 endpoint->local_node = node; in of_graph_parse_endpoint()
623 of_property_read_u32(port_node, "reg", &endpoint->port); in of_graph_parse_endpoint()
624 of_property_read_u32(node, "reg", &endpoint->id); in of_graph_parse_endpoint()
631 * of_graph_get_port_by_id() - get the port matching a given id
660 * of_graph_get_next_port() - get next port node.
697 * of_graph_get_next_port_endpoint() - get next endpoint node in port.
724 * of_graph_get_next_endpoint() - get next endpoint node
781 * of_graph_get_endpoint_by_regs() - get endpoint node of specific identifiers
788 * ignored when they are -1. Use of_node_put() on the pointer when done.
798 if (((port_reg == -1) || (endpoint.port == port_reg)) && in of_graph_get_endpoint_by_regs()
799 ((reg == -1) || (endpoint.id == reg))) in of_graph_get_endpoint_by_regs()
808 * of_graph_get_remote_endpoint() - get remote endpoint node
817 return of_parse_phandle(node, "remote-endpoint", 0); in of_graph_get_remote_endpoint()
822 * of_graph_get_port_parent() - get port's parent node
842 for (depth = 3; depth && node; depth--) { in of_graph_get_port_parent()
845 !of_node_name_eq(node, "in-ports") && in of_graph_get_port_parent()
846 !of_node_name_eq(node, "out-ports")) in of_graph_get_port_parent()
854 * of_graph_get_remote_port_parent() - get remote port's parent node
872 * of_graph_get_remote_port() - get remote port node
891 * of_graph_get_endpoint_count() - get the number of endpoints in a device node
909 * of_graph_get_port_count() - get the number of port in a device or ports node
926 * of_graph_get_remote_node() - get remote parent device_node for given port/endpoint
1026 return -ENXIO; in of_fwnode_property_read_int_array()
1043 return kbasename(to_of_node(fwnode)->full_name); in of_fwnode_get_name()
1049 if (!to_of_node(fwnode)->parent) in of_fwnode_get_name_prefix()
1106 args->nargs = of_args.args_count; in of_fwnode_get_reference_args()
1107 args->fwnode = of_fwnode_handle(of_args.np); in of_fwnode_get_reference_args()
1110 args->args[i] = i < of_args.args_count ? of_args.args[i] : 0; in of_fwnode_get_reference_args()
1153 endpoint->local_fwnode = fwnode; in of_fwnode_graph_parse_endpoint()
1155 of_property_read_u32(port_node, "reg", &endpoint->port); in of_fwnode_graph_parse_endpoint()
1156 of_property_read_u32(node, "reg", &endpoint->id); in of_fwnode_graph_parse_endpoint()
1176 if (of_fwnode_handle(tmp_np)->dev) in of_link_to_phandle()
1189 * parse_prop_cells - Property parsing function for suppliers
1203 * - phandle node pointer with refcount incremented. Caller must of_node_put()
1205 * - NULL if no phandle found at index
1238 return -1; in strcmp_suffix()
1239 return strcmp(str + len - suffix_len, suffix); in strcmp_suffix()
1243 * parse_suffix_prop_cells - Suffix property parsing function for suppliers
1257 * - phandle node pointer with refcount incremented. Caller must of_node_put()
1259 * - NULL if no phandle found at index
1286 * struct supplier_bindings - Property parsing functions for suppliers
1303 * - phandle node pointer with refcount incremented. Caller must of_node_put()
1305 * - NULL if no phandle found at index
1315 DEFINE_SIMPLE_PROP(clocks, "clocks", "#clock-cells")
1316 DEFINE_SIMPLE_PROP(interconnects, "interconnects", "#interconnect-cells")
1317 DEFINE_SIMPLE_PROP(iommus, "iommus", "#iommu-cells")
1318 DEFINE_SIMPLE_PROP(mboxes, "mboxes", "#mbox-cells")
1319 DEFINE_SIMPLE_PROP(io_channels, "io-channels", "#io-channel-cells")
1320 DEFINE_SIMPLE_PROP(io_backends, "io-backends", "#io-backend-cells")
1321 DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells")
1322 DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells")
1323 DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells")
1325 DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", "#nvmem-cell-cells")
1326 DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells")
1327 DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL)
1328 DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL)
1329 DEFINE_SIMPLE_PROP(pinctrl1, "pinctrl-1", NULL)
1330 DEFINE_SIMPLE_PROP(pinctrl2, "pinctrl-2", NULL)
1331 DEFINE_SIMPLE_PROP(pinctrl3, "pinctrl-3", NULL)
1332 DEFINE_SIMPLE_PROP(pinctrl4, "pinctrl-4", NULL)
1333 DEFINE_SIMPLE_PROP(pinctrl5, "pinctrl-5", NULL)
1334 DEFINE_SIMPLE_PROP(pinctrl6, "pinctrl-6", NULL)
1335 DEFINE_SIMPLE_PROP(pinctrl7, "pinctrl-7", NULL)
1336 DEFINE_SIMPLE_PROP(pinctrl8, "pinctrl-8", NULL)
1337 DEFINE_SIMPLE_PROP(pwms, "pwms", "#pwm-cells")
1338 DEFINE_SIMPLE_PROP(resets, "resets", "#reset-cells")
1342 DEFINE_SIMPLE_PROP(msi_parent, "msi-parent", "#msi-cells")
1343 DEFINE_SIMPLE_PROP(post_init_providers, "post-init-providers", NULL)
1344 DEFINE_SIMPLE_PROP(access_controllers, "access-controllers", "#access-controller-cells")
1345 DEFINE_SIMPLE_PROP(pses, "pses", "#pse-cells")
1346 DEFINE_SIMPLE_PROP(power_supplies, "power-supplies", NULL)
1347 DEFINE_SUFFIX_PROP(regulators, "-supply", NULL)
1348 DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells")
1353 if (!strcmp_suffix(prop_name, ",nr-gpios")) in parse_gpios()
1356 return parse_suffix_prop_cells(np, prop_name, index, "-gpios", in parse_gpios()
1357 "#gpio-cells"); in parse_gpios()
1363 if (strcmp(prop_name, "iommu-map")) in parse_iommu_maps()
1378 * Ignore node with gpio-hog property since its gpios are all provided in parse_gpio_compat()
1381 if (of_property_read_bool(np, "gpio-hog")) in parse_gpio_compat()
1384 if (of_parse_phandle_with_args(np, prop_name, "#gpio-cells", index, in parse_gpio_compat()
1400 strcmp(prop_name, "interrupts-extended")) in parse_interrupts()
1417 if (strcmp(prop_name, "interrupt-map")) in parse_interrupt_map()
1420 if (of_property_read_u32(np, "#interrupt-cells", &intcells)) in parse_interrupt_map()
1424 imap = of_get_property(np, "interrupt-map", &imaplen); in parse_interrupt_map()
1434 imap = of_irq_parse_imap_parent(imap, imap_end - imap, &sup_args); in parse_interrupt_map()
1451 /* Return NULL for index > 0 to signify end of remote-endpoints. */ in parse_remote_endpoint()
1452 if (index > 0 || strcmp(prop_name, "remote-endpoint")) in parse_remote_endpoint()
1509 * of_link_property - Create device links to suppliers listed in a property
1535 while (!matched && s->parse_prop) { in of_link_property()
1536 if (s->optional && !fw_devlink_is_strict()) { in of_link_property()
1541 while ((phandle = s->parse_prop(con_np, prop_name, i))) { in of_link_property()
1543 s->get_con_dev ? s->get_con_dev(con_np) : of_node_get(con_np); in of_link_property()
1547 of_link_to_phandle(con_dev_np, phandle, s->fwlink_flags); in of_link_property()
1579 return -EINVAL; in of_fwnode_add_links()
1582 of_link_property(con_np, p->name); in of_fwnode_add_links()