aboutsummaryrefslogtreecommitdiff
path: root/drivers/core/ofnode.c
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@amd.com>2023-08-31 09:04:27 +0200
committerMichal Simek <michal.simek@amd.com>2023-09-21 13:20:11 +0200
commit44f35e1aca706e7625aa2989911b4bc938681158 (patch)
tree480bb2b88f4bc8ba5daf8208e54574f509a798cf /drivers/core/ofnode.c
parent771635f6b0f5bc71d85beb7d994b1c66bf36f6ff (diff)
downloadu-boot-44f35e1aca706e7625aa2989911b4bc938681158.zip
u-boot-44f35e1aca706e7625aa2989911b4bc938681158.tar.gz
u-boot-44f35e1aca706e7625aa2989911b4bc938681158.tar.bz2
dm: core: ofnode: Add ofnode_read_bootscript_flash()
ofnode_read_bootscript_flash() reads bootscript address from /options/u-boot DT node. bootscr-flash-offset and bootscr-flash-size properties are read and values are filled. When bootscr-flash-size is not defined, bootscr-flash-offset property is unusable that's why cleaned. Both of these properties should be defined to function properly. Also add test to cover this new function. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/08a3e6c09cce13287c69ad370e409e7f1766b406.1693465465.git.michal.simek@amd.com
Diffstat (limited to 'drivers/core/ofnode.c')
-rw-r--r--drivers/core/ofnode.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 5076054..fb4447c 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1618,6 +1618,40 @@ int ofnode_read_bootscript_address(u64 *bootscr_address, u64 *bootscr_offset)
return 0;
}
+int ofnode_read_bootscript_flash(u64 *bootscr_flash_offset,
+ u64 *bootscr_flash_size)
+{
+ int ret;
+ ofnode uboot;
+
+ *bootscr_flash_offset = 0;
+ *bootscr_flash_size = 0;
+
+ uboot = ofnode_path("/options/u-boot");
+ if (!ofnode_valid(uboot)) {
+ printf("%s: Missing /u-boot node\n", __func__);
+ return -EINVAL;
+ }
+
+ ret = ofnode_read_u64(uboot, "bootscr-flash-offset",
+ bootscr_flash_offset);
+ if (ret)
+ return -EINVAL;
+
+ ret = ofnode_read_u64(uboot, "bootscr-flash-size",
+ bootscr_flash_size);
+ if (ret)
+ return -EINVAL;
+
+ if (!bootscr_flash_size) {
+ debug("bootscr-flash-size is zero. Ignoring properties!\n");
+ *bootscr_flash_offset = 0;
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
ofnode ofnode_get_phy_node(ofnode node)
{
/* DT node properties that reference a PHY node */