• Home
  • Raw
  • Download

Lines Matching +full:int +full:- +full:property

1 // SPDX-License-Identifier: GPL-2.0+
6 * Copyright (C) 1996-2005 Paul Mackerras.
66 node_name = kbasename(np->full_name); in of_node_name_eq()
67 len = strchrnul(node_name, '@') - node_name; in of_node_name_eq()
78 return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0; in of_node_name_prefix()
89 int of_bus_n_addr_cells(struct device_node *np) in of_bus_n_addr_cells()
93 for (; np; np = np->parent) in of_bus_n_addr_cells()
94 if (!of_property_read_u32(np, "#address-cells", &cells)) in of_bus_n_addr_cells()
97 /* No #address-cells property for the root node */ in of_bus_n_addr_cells()
101 int of_n_addr_cells(struct device_node *np) in of_n_addr_cells()
103 if (np->parent) in of_n_addr_cells()
104 np = np->parent; in of_n_addr_cells()
110 int of_bus_n_size_cells(struct device_node *np) in of_bus_n_size_cells()
114 for (; np; np = np->parent) in of_bus_n_size_cells()
115 if (!of_property_read_u32(np, "#size-cells", &cells)) in of_bus_n_size_cells()
118 /* No #size-cells property for the root node */ in of_bus_n_size_cells()
122 int of_n_size_cells(struct device_node *np) in of_n_size_cells()
124 if (np->parent) in of_n_size_cells()
125 np = np->parent; in of_n_size_cells()
132 int __weak of_node_to_nid(struct device_node *np) in of_node_to_nid()
162 if (np && handle == np->phandle) in __of_phandle_cache_inv_entry()
181 if (np->phandle && !phandle_cache[of_phandle_cache_hash(np->phandle)]) in of_core_init()
182 phandle_cache[of_phandle_cache_hash(np->phandle)] = np; in of_core_init()
188 proc_symlink("device-tree", NULL, "/sys/firmware/devicetree/base"); in of_core_init()
191 static struct property *__of_find_property(const struct device_node *np, in __of_find_property()
192 const char *name, int *lenp) in __of_find_property()
194 struct property *pp; in __of_find_property()
199 for (pp = np->properties; pp; pp = pp->next) { in __of_find_property()
200 if (of_prop_cmp(pp->name, name) == 0) { in __of_find_property()
202 *lenp = pp->length; in __of_find_property()
210 struct property *of_find_property(const struct device_node *np, in of_find_property()
212 int *lenp) in of_find_property()
214 struct property *pp; in of_find_property()
230 } else if (prev->child) { in __of_find_all_nodes()
231 np = prev->child; in __of_find_all_nodes()
235 while (np->parent && !np->sibling) in __of_find_all_nodes()
236 np = np->parent; in __of_find_all_nodes()
237 np = np->sibling; /* Might be null at the end of the tree */ in __of_find_all_nodes()
243 * of_find_all_nodes - Get next node in global list
265 * Find a property with a given name for a given node
269 const char *name, int *lenp) in __of_get_property()
271 struct property *pp = __of_find_property(np, name, lenp); in __of_get_property()
273 return pp ? pp->value : NULL; in __of_get_property()
277 * Find a property with a given name for a given node
281 int *lenp) in of_get_property()
283 struct property *pp = of_find_property(np, name, lenp); in of_get_property()
285 return pp ? pp->value : NULL; in of_get_property()
290 * arch_match_cpu_phys_id - Match the given logical CPU and physical id
303 bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id) in arch_match_cpu_phys_id()
309 * Checks if the given "prop_name" property holds the physical id of the
314 const char *prop_name, int cpu, unsigned int *thread) in __of_find_n_match_cpu_property()
317 int ac, prop_len, tid; in __of_find_n_match_cpu_property()
340 * arch_find_n_match_cpu_physical_id - See if the given device node is
342 * else false. If 'thread' is non-NULL, the local thread number within the
346 int cpu, unsigned int *thread) in arch_find_n_match_cpu_physical_id()
348 /* Check for non-standard "ibm,ppc-interrupt-server#s" property in arch_find_n_match_cpu_physical_id()
350 * standard "reg" property. in arch_find_n_match_cpu_physical_id()
354 "ibm,ppc-interrupt-server#s", in arch_find_n_match_cpu_physical_id()
362 * of_get_cpu_node - Get device node associated with the given logical CPU
380 struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) in of_get_cpu_node()
398 * Returns -ENODEV if the CPU is not found.
400 int of_cpu_node_to_id(struct device_node *cpu_node) in of_cpu_node_to_id()
402 int cpu; in of_cpu_node_to_id()
414 return -ENODEV; in of_cpu_node_to_id()
419 * of_get_cpu_state_node - Get CPU's idle state node at the given index
425 * a flattened description through the "cpu-idle-states" binding or via the
426 * hierarchical layout, using the "power-domains" and the "domain-idle-states"
434 int index) in of_get_cpu_state_node()
437 int err; in of_get_cpu_state_node()
439 err = of_parse_phandle_with_args(cpu_node, "power-domains", in of_get_cpu_state_node()
440 "#power-domain-cells", 0, &args); in of_get_cpu_state_node()
443 of_parse_phandle(args.np, "domain-idle-states", index); in of_get_cpu_state_node()
450 return of_parse_phandle(cpu_node, "cpu-idle-states", index); in of_get_cpu_state_node()
455 * __of_device_is_compatible() - Check if the node matches given constraints
484 static int __of_device_is_compatible(const struct device_node *device, in __of_device_is_compatible()
487 struct property *prop; in __of_device_is_compatible()
489 int index = 0, score = 0; in __of_device_is_compatible()
497 score = INT_MAX/2 - (index << 2); in __of_device_is_compatible()
523 * the device's "compatible" property
525 int of_device_is_compatible(const struct device_node *device, in of_device_is_compatible()
529 int res; in of_device_is_compatible()
542 int of_device_compatible_match(struct device_node *device, in of_device_compatible_match()
545 unsigned int tmp, score = 0; in of_device_compatible_match()
561 * of_machine_is_compatible - Test root of device tree for a given compatible value
562 * @compat: compatible string to look for in root node's compatible property.
565 * compatible property.
567 int of_machine_is_compatible(const char *compat) in of_machine_is_compatible()
570 int rc = 0; in of_machine_is_compatible()
582 * __of_device_is_available - check if a device is available for use
586 * Returns true if the status property is absent or set to "okay" or "ok",
592 int statlen; in __of_device_is_available()
610 * of_device_is_available - check if a device is available for use
614 * Returns true if the status property is absent or set to "okay" or "ok",
631 * of_device_is_big_endian - check if a device has BE registers
635 * Returns true if the device has a "big-endian" property, or if the kernel
636 * was compiled for BE *and* the device has a "native-endian" property.
644 if (of_property_read_bool(device, "big-endian")) in of_device_is_big_endian()
647 of_property_read_bool(device, "native-endian")) in of_device_is_big_endian()
654 * of_get_parent - Get a node's parent if any
669 np = of_node_get(node->parent); in of_get_parent()
676 * of_get_next_parent - Iterate to a node's parent
695 parent = of_node_get(node->parent); in of_get_next_parent()
710 next = prev ? prev->sibling : node->child; in __of_get_next_child()
711 for (; next; next = next->sibling) in __of_get_next_child()
722 * of_get_next_child - Iterate a node childs
744 * of_get_next_available_child - Find the next available child node
761 next = prev ? prev->sibling : node->child; in of_get_next_available_child()
762 for (; next; next = next->sibling) { in of_get_next_available_child()
775 * of_get_next_cpu_node - Iterate on cpu nodes
793 next = prev->sibling; in of_get_next_cpu_node()
795 next = node->child; in of_get_next_cpu_node()
798 for (; next; next = next->sibling) { in of_get_next_cpu_node()
812 * of_get_compatible_child - Find compatible child node
816 * Lookup child node whose compatible property contains the given compatible
837 * of_get_child_by_name - Find the child node by name for a given parent
863 int len; in __of_find_node_by_path()
870 const char *name = kbasename(child->full_name); in __of_find_node_by_path()
896 * of_find_node_opts_by_path - Find a node matching a full OF path
898 * start with '/', the name of a property of the /aliases
916 struct property *pp; in of_find_node_opts_by_path()
928 int len; in of_find_node_opts_by_path()
933 len = p - path; in of_find_node_opts_by_path()
940 if (strlen(pp->name) == len && !strncmp(pp->name, path, len)) { in of_find_node_opts_by_path()
941 np = of_find_node_by_path(pp->value); in of_find_node_opts_by_path()
961 * of_find_node_by_name - Find a node by its "name" property
988 * of_find_node_by_type - Find a node by its "device_type" property
1016 * of_find_compatible_node - Find a node based on type and one of the
1017 * tokens in its "compatible" property
1047 * of_find_node_with_property - Find a node which has a property with
1053 * @prop_name: The name of the property to look for.
1062 struct property *pp; in of_find_node_with_property()
1067 for (pp = np->properties; pp; pp = pp->next) { in of_find_node_with_property()
1068 if (of_prop_cmp(pp->name, prop_name) == 0) { in of_find_node_with_property()
1086 int score, best_score = 0; in __of_match_node()
1091 for (; matches->name[0] || matches->type[0] || matches->compatible[0]; matches++) { in __of_match_node()
1092 score = __of_device_is_compatible(node, matches->compatible, in __of_match_node()
1093 matches->type, matches->name); in __of_match_node()
1104 * of_match_node - Tell if a device_node has a matching of_match structure
1124 * of_find_matching_node_and_match - Find a node based on an of_device_id
1163 * of_modalias_node - Lookup appropriate modalias for a device node
1168 * Based on the value of the compatible property, this routine will attempt
1171 * from the first entry in the compatible list property.
1175 int of_modalias_node(struct device_node *node, char *modalias, int len) in of_modalias_node()
1178 int cplen; in of_modalias_node()
1182 return -ENODEV; in of_modalias_node()
1190 * of_find_node_by_phandle - Find a node given a phandle
1210 handle == phandle_cache[handle_hash]->phandle) in of_find_node_by_phandle()
1215 if (np->phandle == handle && in of_find_node_by_phandle()
1230 int i; in of_print_phandle_args()
1231 printk("%s %pOF", msg, args->np); in of_print_phandle_args()
1232 for (i = 0; i < args->args_count; i++) { in of_print_phandle_args()
1235 pr_cont("%c%08x", delim, args->args[i]); in of_print_phandle_args()
1240 int of_phandle_iterator_init(struct of_phandle_iterator *it, in of_phandle_iterator_init()
1244 int cell_count) in of_phandle_iterator_init()
1247 int size; in of_phandle_iterator_init()
1256 return -EINVAL; in of_phandle_iterator_init()
1260 return -ENOENT; in of_phandle_iterator_init()
1262 it->cells_name = cells_name; in of_phandle_iterator_init()
1263 it->cell_count = cell_count; in of_phandle_iterator_init()
1264 it->parent = np; in of_phandle_iterator_init()
1265 it->list_end = list + size / sizeof(*list); in of_phandle_iterator_init()
1266 it->phandle_end = list; in of_phandle_iterator_init()
1267 it->cur = list; in of_phandle_iterator_init()
1273 int of_phandle_iterator_next(struct of_phandle_iterator *it) in of_phandle_iterator_next()
1277 if (it->node) { in of_phandle_iterator_next()
1278 of_node_put(it->node); in of_phandle_iterator_next()
1279 it->node = NULL; in of_phandle_iterator_next()
1282 if (!it->cur || it->phandle_end >= it->list_end) in of_phandle_iterator_next()
1283 return -ENOENT; in of_phandle_iterator_next()
1285 it->cur = it->phandle_end; in of_phandle_iterator_next()
1288 it->phandle = be32_to_cpup(it->cur++); in of_phandle_iterator_next()
1290 if (it->phandle) { in of_phandle_iterator_next()
1293 * Find the provider node and parse the #*-cells property to in of_phandle_iterator_next()
1296 it->node = of_find_node_by_phandle(it->phandle); in of_phandle_iterator_next()
1298 if (it->cells_name) { in of_phandle_iterator_next()
1299 if (!it->node) { in of_phandle_iterator_next()
1301 it->parent); in of_phandle_iterator_next()
1305 if (of_property_read_u32(it->node, it->cells_name, in of_phandle_iterator_next()
1310 * of the cells_name property in of_phandle_iterator_next()
1312 if (it->cell_count >= 0) { in of_phandle_iterator_next()
1313 count = it->cell_count; in of_phandle_iterator_next()
1316 it->parent, in of_phandle_iterator_next()
1317 it->cells_name, in of_phandle_iterator_next()
1318 it->node); in of_phandle_iterator_next()
1323 count = it->cell_count; in of_phandle_iterator_next()
1328 * property data length in of_phandle_iterator_next()
1330 if (it->cur + count > it->list_end) { in of_phandle_iterator_next()
1331 if (it->cells_name) in of_phandle_iterator_next()
1333 it->parent, it->cells_name, in of_phandle_iterator_next()
1334 count, it->list_end - it->cur); in of_phandle_iterator_next()
1337 it->parent, of_node_full_name(it->node), in of_phandle_iterator_next()
1338 count, it->list_end - it->cur); in of_phandle_iterator_next()
1343 it->phandle_end = it->cur + count; in of_phandle_iterator_next()
1344 it->cur_count = count; in of_phandle_iterator_next()
1349 if (it->node) { in of_phandle_iterator_next()
1350 of_node_put(it->node); in of_phandle_iterator_next()
1351 it->node = NULL; in of_phandle_iterator_next()
1354 return -EINVAL; in of_phandle_iterator_next()
1358 int of_phandle_iterator_args(struct of_phandle_iterator *it, in of_phandle_iterator_args()
1360 int size) in of_phandle_iterator_args()
1362 int i, count; in of_phandle_iterator_args()
1364 count = it->cur_count; in of_phandle_iterator_args()
1370 args[i] = be32_to_cpup(it->cur++); in of_phandle_iterator_args()
1375 static int __of_parse_phandle_with_args(const struct device_node *np, in __of_parse_phandle_with_args()
1378 int cell_count, int index, in __of_parse_phandle_with_args()
1382 int rc, cur_index = 0; in __of_parse_phandle_with_args()
1390 * or return -ENOENT for an empty entry. in __of_parse_phandle_with_args()
1392 rc = -ENOENT; in __of_parse_phandle_with_args()
1398 int c; in __of_parse_phandle_with_args()
1401 out_args->args, in __of_parse_phandle_with_args()
1403 out_args->np = it.node; in __of_parse_phandle_with_args()
1404 out_args->args_count = c; in __of_parse_phandle_with_args()
1418 * -ENOENT : index is for empty phandle in __of_parse_phandle_with_args()
1419 * -EINVAL : parsing error on data in __of_parse_phandle_with_args()
1428 * of_parse_phandle - Resolve a phandle property to a device_node pointer
1429 * @np: Pointer to device node holding phandle property
1430 * @phandle_name: Name of property holding a phandle value
1438 const char *phandle_name, int index) in of_parse_phandle()
1454 * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
1456 * @list_name: property name that contains a list
1457 * @cells_name: property name that specifies phandles' arguments count
1465 * Caller is responsible to call of_node_put() on the returned out_args->np
1471 * #list-cells = <2>;
1475 * #list-cells = <1>;
1483 * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
1485 int of_parse_phandle_with_args(const struct device_node *np, const char *list_name, in of_parse_phandle_with_args()
1486 const char *cells_name, int index, in of_parse_phandle_with_args()
1489 int cell_count = -1; in of_parse_phandle_with_args()
1492 return -EINVAL; in of_parse_phandle_with_args()
1504 * of_parse_phandle_with_args_map() - Find a node pointed by phandle in a list and remap it
1506 * @list_name: property name that contains a list
1507 * @stem_name: stem of property names that specify phandles' arguments count
1515 * a <@stem_name>-map property.
1517 * Caller is responsible to call of_node_put() on the returned out_args->np
1523 * #list-cells = <2>;
1527 * #list-cells = <1>;
1531 * #list-cells = <1>;
1532 * list-map = <0 &phandle2 3>,
1535 * list-map-mask = <0x3>;
1545 int of_parse_phandle_with_args_map(const struct device_node *np, in of_parse_phandle_with_args_map()
1548 int index, struct of_phandle_args *out_args) in of_parse_phandle_with_args_map()
1558 int i, ret, map_len, match; in of_parse_phandle_with_args_map()
1562 return -EINVAL; in of_parse_phandle_with_args_map()
1564 cells_name = kasprintf(GFP_KERNEL, "#%s-cells", stem_name); in of_parse_phandle_with_args_map()
1566 return -ENOMEM; in of_parse_phandle_with_args_map()
1568 ret = -ENOMEM; in of_parse_phandle_with_args_map()
1569 map_name = kasprintf(GFP_KERNEL, "%s-map", stem_name); in of_parse_phandle_with_args_map()
1573 mask_name = kasprintf(GFP_KERNEL, "%s-map-mask", stem_name); in of_parse_phandle_with_args_map()
1577 pass_name = kasprintf(GFP_KERNEL, "%s-map-pass-thru", stem_name); in of_parse_phandle_with_args_map()
1581 ret = __of_parse_phandle_with_args(np, list_name, cells_name, -1, index, in of_parse_phandle_with_args_map()
1586 /* Get the #<list>-cells property */ in of_parse_phandle_with_args_map()
1587 cur = out_args->np; in of_parse_phandle_with_args_map()
1592 /* Precalculate the match array - this simplifies match loop */ in of_parse_phandle_with_args_map()
1594 initial_match_array[i] = cpu_to_be32(out_args->args[i]); in of_parse_phandle_with_args_map()
1596 ret = -EINVAL; in of_parse_phandle_with_args_map()
1598 /* Get the <list>-map property */ in of_parse_phandle_with_args_map()
1606 /* Get the <list>-map-mask property (optional) */ in of_parse_phandle_with_args_map()
1610 /* Iterate through <list>-map property */ in of_parse_phandle_with_args_map()
1615 for (i = 0; i < list_size; i++, map_len--) in of_parse_phandle_with_args_map()
1621 map_len--; in of_parse_phandle_with_args_map()
1640 /* Move forward by new node's #<list>-cells amount */ in of_parse_phandle_with_args_map()
1642 map_len -= new_size; in of_parse_phandle_with_args_map()
1647 /* Get the <list>-map-pass-thru property (optional) */ in of_parse_phandle_with_args_map()
1653 * Successfully parsed a <list>-map translation; copy new in of_parse_phandle_with_args_map()
1655 * bits specified in <list>-map-pass-thru. in of_parse_phandle_with_args_map()
1657 match_array = map - new_size; in of_parse_phandle_with_args_map()
1659 __be32 val = *(map - new_size + i); in of_parse_phandle_with_args_map()
1663 val |= cpu_to_be32(out_args->args[i]) & pass[i]; in of_parse_phandle_with_args_map()
1666 out_args->args[i] = be32_to_cpu(val); in of_parse_phandle_with_args_map()
1668 out_args->args_count = list_size = new_size; in of_parse_phandle_with_args_map()
1670 out_args->np = new; in of_parse_phandle_with_args_map()
1688 * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
1690 * @list_name: property name that contains a list
1699 * Caller is responsible to call of_node_put() on the returned out_args->np
1717 int of_parse_phandle_with_fixed_args(const struct device_node *np, in of_parse_phandle_with_fixed_args()
1718 const char *list_name, int cell_count, in of_parse_phandle_with_fixed_args()
1719 int index, struct of_phandle_args *out_args) in of_parse_phandle_with_fixed_args()
1722 return -EINVAL; in of_parse_phandle_with_fixed_args()
1729 * of_count_phandle_with_args() - Find the number of phandles references in a property
1731 * @list_name: property name that contains a list
1732 * @cells_name: property name that specifies phandles' arguments count
1734 * Returns the number of phandle + argument tuples within a property. It
1736 * arguments into a single property. The number of arguments is encoded
1737 * by a property in the phandle-target node. For example, a gpios
1738 * property would contain a list of GPIO specifies consisting of a
1740 * determined by the #gpio-cells property in the node pointed to by the
1743 int of_count_phandle_with_args(const struct device_node *np, const char *list_name, in of_count_phandle_with_args()
1747 int rc, cur_index = 0; in of_count_phandle_with_args()
1757 int size; in of_count_phandle_with_args()
1761 return -ENOENT; in of_count_phandle_with_args()
1766 rc = of_phandle_iterator_init(&it, np, list_name, cells_name, -1); in of_count_phandle_with_args()
1773 if (rc != -ENOENT) in of_count_phandle_with_args()
1781 * __of_add_property - Add a property to a node without lock operations
1783 int __of_add_property(struct device_node *np, struct property *prop) in __of_add_property()
1785 struct property **next; in __of_add_property()
1787 prop->next = NULL; in __of_add_property()
1788 next = &np->properties; in __of_add_property()
1790 if (strcmp(prop->name, (*next)->name) == 0) in __of_add_property()
1792 return -EEXIST; in __of_add_property()
1794 next = &(*next)->next; in __of_add_property()
1802 * of_add_property - Add a property to a node
1804 int of_add_property(struct device_node *np, struct property *prop) in of_add_property()
1807 int rc; in of_add_property()
1826 int __of_remove_property(struct device_node *np, struct property *prop) in __of_remove_property()
1828 struct property **next; in __of_remove_property()
1830 for (next = &np->properties; *next; next = &(*next)->next) { in __of_remove_property()
1835 return -ENODEV; in __of_remove_property()
1838 *next = prop->next; in __of_remove_property()
1839 prop->next = np->deadprops; in __of_remove_property()
1840 np->deadprops = prop; in __of_remove_property()
1846 * of_remove_property - Remove a property from a node.
1849 * who-knows-how-many pointers to the data using get-property.
1850 * Instead we just move the property to the "dead properties"
1853 int of_remove_property(struct device_node *np, struct property *prop) in of_remove_property()
1856 int rc; in of_remove_property()
1859 return -ENODEV; in of_remove_property()
1879 int __of_update_property(struct device_node *np, struct property *newprop, in __of_update_property()
1880 struct property **oldpropp) in __of_update_property()
1882 struct property **next, *oldprop; in __of_update_property()
1884 for (next = &np->properties; *next; next = &(*next)->next) { in __of_update_property()
1885 if (of_prop_cmp((*next)->name, newprop->name) == 0) in __of_update_property()
1892 newprop->next = oldprop->next; in __of_update_property()
1894 oldprop->next = np->deadprops; in __of_update_property()
1895 np->deadprops = oldprop; in __of_update_property()
1898 newprop->next = NULL; in __of_update_property()
1906 * of_update_property - Update a property in a node, if the property does
1910 * who-knows-how-many pointers to the data using get-property.
1911 * Instead we just move the property to the "dead properties" list,
1912 * and add the new property to the property list
1914 int of_update_property(struct device_node *np, struct property *newprop) in of_update_property()
1916 struct property *oldprop; in of_update_property()
1918 int rc; in of_update_property()
1920 if (!newprop->name) in of_update_property()
1921 return -EINVAL; in of_update_property()
1941 int id, const char *stem, int stem_len) in of_alias_add()
1943 ap->np = np; in of_alias_add()
1944 ap->id = id; in of_alias_add()
1945 strncpy(ap->stem, stem, stem_len); in of_alias_add()
1946 ap->stem[stem_len] = 0; in of_alias_add()
1947 list_add_tail(&ap->link, &aliases_lookup); in of_alias_add()
1949 ap->alias, ap->stem, ap->id, np); in of_alias_add()
1953 * of_alias_scan - Scan all properties of the 'aliases' node
1964 struct property *pp; in of_alias_scan()
1972 /* linux,stdout-path and /aliases/stdout are for legacy compatibility */ in of_alias_scan()
1975 if (of_property_read_string(of_chosen, "stdout-path", &name)) in of_alias_scan()
1976 of_property_read_string(of_chosen, "linux,stdout-path", in of_alias_scan()
1988 const char *start = pp->name; in of_alias_scan()
1992 int id, len; in of_alias_scan()
1995 if (!strcmp(pp->name, "name") || in of_alias_scan()
1996 !strcmp(pp->name, "phandle") || in of_alias_scan()
1997 !strcmp(pp->name, "linux,phandle")) in of_alias_scan()
2000 np = of_find_node_by_path(pp->value); in of_alias_scan()
2006 while (isdigit(*(end-1)) && end > start) in of_alias_scan()
2007 end--; in of_alias_scan()
2008 len = end - start; in of_alias_scan()
2018 ap->alias = start; in of_alias_scan()
2024 * of_alias_get_id - Get alias id for the given device_node
2031 int of_alias_get_id(struct device_node *np, const char *stem) in of_alias_get_id()
2034 int id = -ENODEV; in of_alias_get_id()
2038 if (strcmp(app->stem, stem) != 0) in of_alias_get_id()
2041 if (np == app->np) { in of_alias_get_id()
2042 id = app->id; in of_alias_get_id()
2053 * of_alias_get_alias_list - Get alias list for the given device driver
2062 * Return: 0 or -ENOSYS when !CONFIG_OF or
2063 * -EOVERFLOW if alias ID is greater then allocated nbits
2065 int of_alias_get_alias_list(const struct of_device_id *matches, in of_alias_get_alias_list()
2067 unsigned int nbits) in of_alias_get_alias_list()
2070 int ret = 0; in of_alias_get_alias_list()
2079 __func__, app->stem, app->id); in of_alias_get_alias_list()
2081 if (strcmp(app->stem, stem) != 0) { in of_alias_get_alias_list()
2083 __func__, app->stem); in of_alias_get_alias_list()
2087 if (of_match_node(matches, app->np)) { in of_alias_get_alias_list()
2088 pr_debug("%s: Allocated ID %d\n", __func__, app->id); in of_alias_get_alias_list()
2090 if (app->id >= nbits) { in of_alias_get_alias_list()
2092 __func__, app->id, nbits); in of_alias_get_alias_list()
2093 ret = -EOVERFLOW; in of_alias_get_alias_list()
2095 set_bit(app->id, bitmap); in of_alias_get_alias_list()
2106 * of_alias_get_highest_id - Get highest alias id for the given stem
2112 int of_alias_get_highest_id(const char *stem) in of_alias_get_highest_id()
2115 int id = -ENODEV; in of_alias_get_highest_id()
2119 if (strcmp(app->stem, stem) != 0) in of_alias_get_highest_id()
2122 if (app->id > id) in of_alias_get_highest_id()
2123 id = app->id; in of_alias_get_highest_id()
2132 * of_console_check() - Test and setup console for DT setup
2133 * @dn - Pointer to device node
2134 * @name - Name to use for preferred console without index. ex. "ttyS"
2135 * @index - Index to use for preferred console.
2137 * Check if the given device node matches the stdout-path property in the
2141 bool of_console_check(struct device_node *dn, char *name, int index) in of_console_check()
2155 * of_find_next_cache_node - Find a node's subsidiary cache
2166 cache_node = of_parse_phandle(np, "l2-cache", 0); in of_find_next_cache_node()
2168 cache_node = of_parse_phandle(np, "next-level-cache", 0); in of_find_next_cache_node()
2173 /* OF on pmac has nodes instead of properties named "l2-cache" in of_find_next_cache_node()
2185 * of_find_last_cache_level - Find the level at which the last cache is
2193 int of_find_last_cache_level(unsigned int cpu) in of_find_last_cache_level()
2204 of_property_read_u32(prev, "cache-level", &cache_level); in of_find_last_cache_level()
2210 * of_map_id - Translate an ID through a downstream mapping.
2213 * @map_name: property name of the map to use.
2214 * @map_mask_name: optional property name of the mask to use.
2218 * Given a device ID, look up the appropriate implementation-defined
2220 * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or
2222 * a non-NULL device node pointer, only entries targeting that node will be
2228 int of_map_id(struct device_node *np, u32 id, in of_map_id()
2233 int map_len; in of_map_id()
2237 return -EINVAL; in of_map_id()
2242 return -ENODEV; in of_map_id()
2251 return -EINVAL; in of_map_id()
2258 * Can be overridden by "{iommu,msi}-map-mask" property. in of_map_id()
2265 for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) { in of_map_id()
2273 pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores id-base (0x%x)\n", in of_map_id()
2276 return -EFAULT; in of_map_id()
2284 return -ENODEV; in of_map_id()
2297 *id_out = masked_id - id_base + out_base; in of_map_id()
2299 …pr_debug("%pOF: %s, using mask %08x, id-base: %08x, out-base: %08x, length: %08x, id: %08x -> %08x… in of_map_id()
2301 id_len, id, masked_id - id_base + out_base); in of_map_id()