diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2010-07-04 12:48:21 -0500 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2010-07-20 04:40:06 -0500 |
commit | 75e73afd5784c0df6a5e35c5a5b2e2fce0296bc0 (patch) | |
tree | 06cbabb33e76153a7bbab9c15daa6f126e2c8968 /common/fdt_support.c | |
parent | a0342c0804251c84a7ec1a2c78ea3bb30b5b5058 (diff) | |
download | u-boot-imx-75e73afd5784c0df6a5e35c5a5b2e2fce0296bc0.zip u-boot-imx-75e73afd5784c0df6a5e35c5a5b2e2fce0296bc0.tar.gz u-boot-imx-75e73afd5784c0df6a5e35c5a5b2e2fce0296bc0.tar.bz2 |
fdt: Add fdt_node_offset_by_compat_reg helper
Given a compatible string and physical address try and find a node that
matches. This is useful when we want to find a specific device node to
update (for example if we have multiple PCI nodes we can use the
physical address to distinguish them when trying to update the device
tree).
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
Diffstat (limited to 'common/fdt_support.c')
-rw-r--r-- | common/fdt_support.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c index 70ad81d..718b635 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1125,3 +1125,30 @@ u64 fdt_translate_address(void *blob, int node_offset, const u32 *in_addr) { return __of_translate_address(blob, node_offset, in_addr, "ranges"); } + +/** + * fdt_node_offset_by_compat_reg: Find a node that matches compatiable and + * who's reg property matches a physical cpu address + * + * @blob: ptr to device tree + * @compat: compatiable string to match + * @compat_off: property name + * + */ +int fdt_node_offset_by_compat_reg(void *blob, const char *compat, + phys_addr_t compat_off) +{ + int len, off = fdt_node_offset_by_compatible(blob, -1, compat); + while (off != -FDT_ERR_NOTFOUND) { + u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", &len); + if (reg) { + if (compat_off == fdt_translate_address(blob, off, reg)) + return off; + } + off = fdt_node_offset_by_compatible(blob, off, compat); + } + + return -FDT_ERR_NOTFOUND; +} + + |