summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-05-03 18:23:34 -0700
committerPatrick Georgi <pgeorgi@google.com>2019-06-04 11:23:12 +0000
commitf36d53c6539ec9e221a5005f00a56960f791a81f (patch)
tree4e0831fcfae86259f7dde3ef622fc7eb8f4e4e72 /src
parent6702b68a7966d584e310bf7a99f4a1dc57f2f56f (diff)
downloadcoreboot-f36d53c6539ec9e221a5005f00a56960f791a81f.tar.xz
device_tree: Drop sub-node path lookup from dt_find_node_by_path()
Besides looking up a node with an absolute path dt_find_node_by_path() currently also supports finding a sub-node of a non-root node. All callers of the function pass the root node though, so it seems there is no real need for this functionality. Also it is planned to support DT path names with aliases, which would become messy in combination with the lookup from a sub-node. Change the interface of dt_find_node_by_path() to receive the DT tree object instead of a parent node and adapt all callers accordingly. This patch was adapted from depthcharge's http://crosreview.com/1252769 Change-Id: Iff56be4da2461ae73a7301dcaa315758d2a8c999 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/32864 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r--src/include/device_tree.h6
-rw-r--r--src/lib/device_tree.c12
-rw-r--r--src/soc/cavium/cn81xx/soc.c10
3 files changed, 14 insertions, 14 deletions
diff --git a/src/include/device_tree.h b/src/include/device_tree.h
index 8280dad077..6eaeacd6f0 100644
--- a/src/include/device_tree.h
+++ b/src/include/device_tree.h
@@ -142,10 +142,10 @@ struct device_tree_node *dt_find_node(struct device_tree_node *parent, const cha
u32 *addrcp, u32 *sizecp, int create);
struct device_tree_node *dt_find_node_by_phandle(struct device_tree_node *root,
uint32_t phandle);
-// Look up or create a node relative to a parent node, through its path
+// Look up or create a node in the tree, through its path
// represented as a string of '/' separated node names.
-struct device_tree_node *dt_find_node_by_path(struct device_tree_node *parent, const char *path,
- u32 *addrcp, u32 *sizecp, int create);
+struct device_tree_node *dt_find_node_by_path(struct device_tree *tree,
+ const char *path, u32 *addrcp, u32 *sizecp, int create);
// Look up a node relative to a parent node, through its compatible string.
struct device_tree_node *dt_find_compat(struct device_tree_node *parent, const char *compatible);
// Look up the next child of a parent node, through its compatible string. It
diff --git a/src/lib/device_tree.c b/src/lib/device_tree.c
index 44eca4e2a8..3e1dd3580c 100644
--- a/src/lib/device_tree.c
+++ b/src/lib/device_tree.c
@@ -552,9 +552,9 @@ struct device_tree_node *dt_find_node(struct device_tree_node *parent,
}
/*
- * Find a node from a string device tree path, relative to a parent node.
+ * Find a node in the tree from a string device tree path.
*
- * @param parent The node from which to start the relative path lookup.
+ * @param tree The device tree to search.
* @param path A string representing a path in the device tree, with
* nodes separated by '/'. Example: "soc/firmware/coreboot"
* @param addrcp Pointer that will be updated with any #address-cells
@@ -567,7 +567,7 @@ struct device_tree_node *dt_find_node(struct device_tree_node *parent,
* It is the caller responsibility to provide the correct path string, namely
* not starting or ending with a '/', and not having "//" anywhere in it.
*/
-struct device_tree_node *dt_find_node_by_path(struct device_tree_node *parent,
+struct device_tree_node *dt_find_node_by_path(struct device_tree *tree,
const char *path, u32 *addrcp,
u32 *sizecp, int create)
{
@@ -595,7 +595,7 @@ struct device_tree_node *dt_find_node_by_path(struct device_tree_node *parent,
if (!next_slash) {
path_array[i] = NULL;
- node = dt_find_node(parent, path_array,
+ node = dt_find_node(tree->root, path_array,
addrcp, sizecp, create);
}
@@ -965,7 +965,7 @@ int dt_set_bin_prop_by_path(struct device_tree *tree, const char *path,
*prop_name++ = '\0'; /* Separate path from the property name. */
- dt_node = dt_find_node_by_path(tree->root, path_copy, NULL,
+ dt_node = dt_find_node_by_path(tree, path_copy, NULL,
NULL, create);
if (!dt_node) {
@@ -995,7 +995,7 @@ struct device_tree_node *dt_init_reserved_memory_node(struct device_tree *tree)
struct device_tree_node *reserved;
u32 addr = 0, size = 0;
- reserved = dt_find_node_by_path(tree->root, "reserved-memory", &addr,
+ reserved = dt_find_node_by_path(tree, "reserved-memory", &addr,
&size, 1);
if (!reserved)
return NULL;
diff --git a/src/soc/cavium/cn81xx/soc.c b/src/soc/cavium/cn81xx/soc.c
index 05007493df..20542e5fa2 100644
--- a/src/soc/cavium/cn81xx/soc.c
+++ b/src/soc/cavium/cn81xx/soc.c
@@ -185,7 +185,7 @@ static int dt_platform_fixup(struct device_tree_fixup *fixup,
size_t i;
/* Set the sclk clock rate. */
- dt_node = dt_find_node_by_path(tree->root, "soc@0/sclk", NULL, NULL, 0);
+ dt_node = dt_find_node_by_path(tree, "soc@0/sclk", NULL, NULL, 0);
if (dt_node) {
const u32 freq = thunderx_get_io_clock();
printk(BIOS_INFO, "%s: Set SCLK to %u Hz\n", __func__, freq);
@@ -195,7 +195,7 @@ static int dt_platform_fixup(struct device_tree_fixup *fixup,
__func__);
/* Set refclkuaa clock rate. */
- dt_node = dt_find_node_by_path(tree->root, "soc@0/refclkuaa", NULL,
+ dt_node = dt_find_node_by_path(tree, "soc@0/refclkuaa", NULL,
NULL, 0);
if (dt_node) {
const u32 freq = uart_platform_refclk();
@@ -212,7 +212,7 @@ static int dt_platform_fixup(struct device_tree_fixup *fixup,
const uint64_t addr = UAAx_PF_BAR0(i);
/* Remove the node */
snprintf(path, sizeof(path), "soc@0/serial@%llx", addr);
- dt_node = dt_find_node_by_path(tree->root, path, NULL, NULL, 0);
+ dt_node = dt_find_node_by_path(tree, path, NULL, NULL, 0);
if (!dt_node || uart_is_enabled(i)) {
printk(BIOS_INFO, "%s: ignoring %s\n", __func__, path);
continue;
@@ -228,7 +228,7 @@ static int dt_platform_fixup(struct device_tree_fixup *fixup,
const uint64_t addr = PEM_PEMX_PF_BAR0(i);
/* Remove the node */
snprintf(path, sizeof(path), "soc@0/pci@%llx", addr);
- dt_node = dt_find_node_by_path(tree->root, path, NULL, NULL, 0);
+ dt_node = dt_find_node_by_path(tree, path, NULL, NULL, 0);
if (!dt_node || bdk_pcie_is_running(0, i)) {
printk(BIOS_INFO, "%s: ignoring %s\n", __func__, path);
continue;
@@ -240,7 +240,7 @@ static int dt_platform_fixup(struct device_tree_fixup *fixup,
/* Remove phandle to non existing nodes */
snprintf(path, sizeof(path), "soc@0/smmu0@%llx", SMMU_PF_BAR0);
- dt_node = dt_find_node_by_path(tree->root, path, NULL, NULL, 0);
+ dt_node = dt_find_node_by_path(tree, path, NULL, NULL, 0);
if (!dt_node) {
printk(BIOS_ERR, "%s: SMMU entry not found\n",
__func__);