* controller is used, SYSCLK must meet the additional requirement
* of 100 MHz.
*/
- if (get_board_sys_clk() != 100000000) {
- off = fdt_node_offset_by_compatible(blob, -1, "snps,dwc3");
- while (off != -FDT_ERR_NOTFOUND) {
+ if (get_board_sys_clk() != 100000000)
+ fdt_for_each_node_by_compatible(off, blob, -1, "snps,dwc3")
fdt_status_disabled(blob, off);
- off = fdt_node_offset_by_compatible(blob, off,
- "snps,dwc3");
- }
- }
}
#ifdef CONFIG_HAS_FEATURE_GIC64K_ALIGN
int noff, len, icid;
const u32 *prop;
- noff = fdt_node_offset_by_compatible(blob, -1, compat);
- while (noff > 0) {
+ fdt_for_each_node_by_compatible(noff, blob, -1, compat) {
prop = fdt_getprop(blob, noff, "cell-index", &len);
if (!prop) {
printf("WARNING missing cell-index for fman port\n");
}
fdt_set_iommu_prop(blob, noff, smmu_ph, (u32 *)&icid, 1);
-
- noff = fdt_node_offset_by_compatible(blob, noff, compat);
}
}
if (!_configured)
return 0;
- offset = fdt_node_offset_by_compatible(blob, -1, compat);
- while (offset != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(offset, blob, -1, compat)
fdt_status_okay(blob, offset);
- offset = fdt_node_offset_by_compatible(blob, offset, compat);
- }
return 0;
}
}
/* Assign 78XX addresses in the order they appear in the device tree. */
- node = fdt_node_offset_by_compatible(working_fdt, -1, "cavium,octeon-7890-bgx-port");
- while (node != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(node, working_fdt, -1, "cavium,octeon-7890-bgx-port")
octeon_set_one_fdt_mac(node, &mac);
- node = fdt_node_offset_by_compatible(working_fdt, node,
- "cavium,octeon-7890-bgx-port");
- }
}
#endif
/* Device trees already have good values for fast simulator
* output, real boards need the correct value.
*/
- node = fdt_node_offset_by_compatible(working_fdt, -1, "cavium,octeon-3860-uart");
- while (node != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(node, working_fdt, -1, "cavium,octeon-3860-uart")
fdt_setprop_inplace_cell(working_fdt, node, "clock-frequency", clk);
- node = fdt_node_offset_by_compatible(working_fdt, node, "cavium,octeon-3860-uart");
- }
}
/**
* Count the number of pci nodes.
* It's needed later when the interleaved liodn offsets are generated.
*/
- off = fdt_node_offset_by_compatible(fdt, -1, compat);
- while (off != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(off, fdt, -1, compat)
pci_cnt++;
- off = fdt_node_offset_by_compatible(fdt, off, compat);
- }
- for (off = fdt_node_offset_by_compatible(fdt, -1, compat);
- off != -FDT_ERR_NOTFOUND;
- off = fdt_node_offset_by_compatible(fdt, off, compat)) {
+ fdt_for_each_node_by_compatible(off, fdt, -1, compat) {
base_liodn = fdt_getprop(fdt, off, "fsl,liodn", &rc);
if (!base_liodn) {
char path[64];
int parent;
/* Iterate through all bgx ports */
- node = -1;
- while ((node = fdt_node_offset_by_compatible((void *)fdt, node,
- compat)) >= 0) {
+ fdt_for_each_node_by_compatible(node, (void *)fdt, -1, compat) {
/* Get the node and bgx from the physical address */
parent = fdt_parent_offset(fdt, node);
reg = fdt_getprop(fdt, parent, "reg", &len);
int node;
/* Iterate through all the mix fdt nodes */
- node = -1;
- while ((node = fdt_node_offset_by_compatible((void *)fdt, node,
- "cavium,octeon-7890-mix")) >= 0) {
+ fdt_for_each_node_by_compatible(node, (void *)fdt, -1,
+ "cavium,octeon-7890-mix") {
int parent;
int len;
const char *name;
#include <common.h>
#include <dm.h>
+#include <fdt_support.h>
#include <init.h>
#include <log.h>
#include <spl.h>
continue;
}
- offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "nxp,imx8-pd");
- while (offset != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(offset, gd->fdt_blob, -1,
+ "nxp,imx8-pd")
lists_bind_fdt(gd->dm_root, offset_to_ofnode(offset),
NULL, NULL, true);
- offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
- "nxp,imx8-pd");
- }
uclass_find_first_device(UCLASS_POWER_DOMAIN, &dev);
if (IS_SVR_REV(get_svr(), 1, 0))
return 0;
- off = fdt_node_offset_by_compatible(fdt, -1, "fsl,lx2160a-pcie");
- while (off != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(off, fdt, -1, "fsl,lx2160a-pcie") {
fdt_setprop(fdt, off, "compatible", "fsl,ls-pcie",
strlen("fsl,ls-pcie") + 1);
}
fdt_setprop(fdt, off, "reg-names", reg_names, names_len);
- off = fdt_node_offset_by_compatible(fdt, off,
- "fsl,lx2160a-pcie");
}
return 0;
debug(" %.2x", *(u8*)(val+i));
debug("\n");
#endif
- off = fdt_node_offset_by_compatible(fdt, -1, compat);
- while (off != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(off, fdt, -1, compat)
if (create || (fdt_get_property(fdt, off, prop, NULL) != NULL))
fdt_setprop(fdt, off, prop, val, len);
- off = fdt_node_offset_by_compatible(fdt, off, compat);
- }
}
void do_fixup_by_compat_u32(void *fdt, const char *compat,
for (i = 0; i < node_info_size; i++) {
idx = 0;
- noff = -1;
- while ((noff = fdt_node_offset_by_compatible(blob, noff,
- node_info[i].compat)) >= 0) {
+ fdt_for_each_node_by_compatible(noff, blob, -1,
+ node_info[i].compat) {
const char *prop;
prop = fdt_getprop(blob, noff, "status", NULL);
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) {
+ int len, off;
+
+ fdt_for_each_node_by_compatible(off, blob, -1, compat) {
const fdt32_t *reg = 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);
+ if (reg && compat_off == fdt_translate_address(blob, off, reg))
+ return off;
}
return -FDT_ERR_NOTFOUND;
maj, min, ip_cfg) + 1;
compat_len += sprintf(compat + compat_len, "fsl,qman-portal") + 1;
- off = fdt_node_offset_by_compatible(blob, -1, "fsl,qman-portal");
- while (off != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(off, blob, -1, "fsl,qman-portal") {
#if defined(CONFIG_PPC) || defined(CONFIG_ARCH_LS1043A) || \
defined(CONFIG_ARCH_LS1046A)
#ifdef CONFIG_FSL_CORENET
fdt_strerror(err));
return;
}
-
- off = fdt_node_offset_by_compatible(blob, off,
- "fsl,qman-portal");
}
}
}
/* Find all other Fman nodes and point them to the firmware node. */
- while ((fmnode = fdt_node_offset_by_compatible(blob, fmnode,
- "fsl,fman")) > 0) {
+ fdt_for_each_node_by_compatible(fmnode, blob, fmnode, "fsl,fman") {
rc = fdt_setprop_cell(blob, fmnode, "fsl,firmware-phandle",
phandle);
if (rc < 0) {
const fdt32_t *prop;
u32 ob_wins, ib_wins;
- off = fdt_node_offset_by_compatible(fdt, -1, "fsl,lx2160a-pcie");
- while (off != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(off, fdt, -1, "fsl,lx2160a-pcie") {
fdt_setprop(fdt, off, "compatible", "fsl,ls2088a-pcie",
strlen("fsl,ls2088a-pcie") + 1);
fdt_setprop(fdt, off, "reg-names", reg_names, names_len);
fdt_delprop(fdt, off, "apio-wins");
fdt_delprop(fdt, off, "ppio-wins");
- off = fdt_node_offset_by_compatible(fdt, off,
- "fsl,lx2160a-pcie");
}
/* Fixup PCIe EP nodes */
- off = -1;
- off = fdt_node_offset_by_compatible(fdt, off, "fsl,lx2160a-pcie-ep");
- while (off != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(off, fdt, -1, "fsl,lx2160a-pcie-ep") {
fdt_setprop_string(fdt, off, "compatible",
"fsl,lx2160ar2-pcie-ep");
prop = fdt_getprop(fdt, off, "apio-wins", NULL);
fdt_setprop_u32(fdt, off, "num-ib-windows", ib_wins);
fdt_setprop_u32(fdt, off, "num-ob-windows", ob_wins);
fdt_delprop(fdt, off, "apio-wins");
-
- off = fdt_node_offset_by_compatible(fdt, off,
- "fsl,lx2160a-pcie-ep");
}
return 0;
*/
#include <common.h>
-#include <fdtdec.h>
+#include <fdt_support.h>
#include <log.h>
#include <asm/global_data.h>
#include <asm/io.h>
static int find_available_node_by_compatible(int offset, const char *compatible)
{
- do {
- offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
- compatible);
- } while (offset > 0 && !fdtdec_get_is_enabled(gd->fdt_blob, offset));
+ fdt_for_each_node_by_compatible(offset, gd->fdt_blob, offset,
+ compatible)
+ if (fdtdec_get_is_enabled(gd->fdt_blob, offset))
+ return offset;
- return offset;
+ return -1;
}
static bool comphy_a3700_find_lane(const int nodes[3], int node,
* (C) Copyright 2017 Icenowy Zheng <icenowy@aosc.io>
*/
-#include <fdtdec.h>
+#include <fdt_support.h>
int meson_simplefb_fdt_match(void *blob, const char *pipeline)
{
int offset, ret;
/* Find a prefilled simpefb node, matching out pipeline config */
- offset = fdt_node_offset_by_compatible(blob, -1,
- "amlogic,simple-framebuffer");
- while (offset >= 0) {
+ fdt_for_each_node_by_compatible(offset, blob, -1,
+ "amlogic,simple-framebuffer") {
ret = fdt_stringlist_search(blob, offset, "amlogic,pipeline",
pipeline);
if (ret == 0)
break;
- offset = fdt_node_offset_by_compatible(blob, offset,
- "amlogic,simple-framebuffer");
}
return offset;
* (C) Copyright 2017 Icenowy Zheng <icenowy@aosc.io>
*/
-#include <fdtdec.h>
+#include <fdt_support.h>
int sunxi_simplefb_fdt_match(void *blob, const char *pipeline)
{
/* Find a prefilled simpefb node, matching out pipeline config */
offset = fdt_node_offset_by_compatible(blob, -1,
"allwinner,simple-framebuffer");
- while (offset >= 0) {
+ fdt_for_each_node_by_compatible(offset, blob, -1,
+ "allwinner,simple-framebuffer") {
ret = fdt_stringlist_search(blob, offset, "allwinner,pipeline",
pipeline);
if (ret == 0)
break;
- offset = fdt_node_offset_by_compatible(blob, offset,
- "allwinner,simple-framebuffer");
}
return offset;
phys_addr_t compat_off);
int fdt_node_offset_by_pathf(void *blob, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
+
+#define fdt_for_each_node_by_compatible(node, fdt, start, compat) \
+ for (node = fdt_node_offset_by_compatible(fdt, start, compat); \
+ node >= 0; \
+ node = fdt_node_offset_by_compatible(fdt, node, compat))
+
int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle);
unsigned int fdt_create_phandle(void *fdt, int nodeoffset);
unsigned int fdt_create_phandle_by_compatible(void *fdt, const char *compat);