From 3a39dbf87401c35ad6cba1709d3db5948b73aa0c Mon Sep 17 00:00:00 2001 From: Kever Yang Date: Thu, 22 Feb 2018 17:34:07 +0800 Subject: [PATCH] fdt_support: add fdt_update_reserved_memory() Add API for rockchip pass uboot logo memory info to kernel. Change-Id: Ib3bfadc381efae21359a43654493e8e0f4e67dd0 Signed-off-by: Kever Yang --- common/fdt_support.c | 30 ++++++++++++++++++++++++++++++ include/fdt_support.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/common/fdt_support.c b/common/fdt_support.c index 0e8e90481d..feb01d0b79 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -523,6 +523,36 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size) return fdt_fixup_memory_banks(blob, &start, &size, 1); } +int fdt_update_reserved_memory(void *blob, char *name, u64 start, u64 size) +{ + int nodeoffset, len, err; + u8 tmp[16]; /* Up to 64-bit address + 64-bit size */ + +#if 0 + /*name is rockchip_logo*/ + nodeoffset = fdt_find_or_add_subnode(blob, 0, "reserved-memory"); + if (nodeoffset < 0) + return nodeoffset; + printf("hjc>>reserved-memory>>%s, nodeoffset:%d\n", __func__, nodeoffset); + nodeoffset = fdt_find_or_add_subnode(blob, nodeoffset, name); + if (nodeoffset < 0) + return nodeoffset; +#else + nodeoffset = fdt_node_offset_by_compatible(blob, 0, name); + if (nodeoffset < 0) + debug("Can't find nodeoffset: %d\n", nodeoffset); +#endif + len = fdt_pack_reg(blob, tmp, &start, &size, 1); + err = fdt_setprop(blob, nodeoffset, "reg", tmp, len); + if (err < 0) { + printf("WARNING: could not set %s %s.\n", + "reg", fdt_strerror(err)); + return err; + } + + return nodeoffset; +} + void fdt_fixup_ethernet(void *fdt) { int i = 0, j, prop; diff --git a/include/fdt_support.h b/include/fdt_support.h index f00fadcddb..4f4b48ebb0 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -103,6 +103,8 @@ static inline int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], } #endif +int fdt_update_reserved_memory(void *blob, char *name, u64 start, u64 size); + void fdt_fixup_ethernet(void *fdt); int fdt_find_and_setprop(void *fdt, const char *node, const char *prop, const void *val, int len, int create);