From: Igor Opaniuk <igor.opaniuk@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 1/2] common: fdt_support: add support for setting usable memory
Date: Fri, 12 Jul 2019 13:50:30 +0300 [thread overview]
Message-ID: <20190712105031.11455-2-igor.opaniuk@gmail.com> (raw)
In-Reply-To: <20190712105031.11455-1-igor.opaniuk@gmail.com>
From: Igor Opaniuk <igor.opaniuk@toradex.com>
Add support for setting linux,usable-memory property in the memory
node of device tree for the kernel [1].
This property holds a base address and size, describing a
limited region in which memory may be considered available for use by
the kernel. Memory outside of this range is not available for use.
[1] https://www.kernel.org/doc/Documentation/devicetree/bindings/chosen.txt
Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Signed-off-by: Igor Opaniuk <igor.opaniuk@gmail.com>
---
common/fdt_support.c | 35 +++++++++++++++++++++++++++++++++++
include/fdt_support.h | 2 ++
2 files changed, 37 insertions(+)
diff --git a/common/fdt_support.c b/common/fdt_support.c
index f31e9b0cc5..57413c7a4d 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -473,6 +473,41 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
return fdt_fixup_memory_banks(blob, &start, &size, 1);
}
+int fdt_set_usable_memory(void *blob, u64 start[], u64 size[], int areas)
+{
+ int err, nodeoffset;
+ int len;
+ u8 tmp[8 * 16]; /* Up to 64-bit address + 64-bit size */
+
+ if (areas > 8) {
+ printf("%s: num areas %d exceeds hardcoded limit %d\n",
+ __func__, areas, 8);
+ return -1;
+ }
+
+ err = fdt_check_header(blob);
+ if (err < 0) {
+ printf("%s: %s\n", __func__, fdt_strerror(err));
+ return err;
+ }
+
+ /* find or create "/memory" node. */
+ nodeoffset = fdt_find_or_add_subnode(blob, 0, "memory");
+ if (nodeoffset < 0)
+ return nodeoffset;
+
+ len = fdt_pack_reg(blob, tmp, start, size, areas);
+
+ err = fdt_setprop(blob, nodeoffset, "linux,usable-memory", tmp, len);
+ if (err < 0) {
+ printf("WARNING: could not set %s %s.\n",
+ "reg", fdt_strerror(err));
+ return err;
+ }
+
+ return 0;
+}
+
void fdt_fixup_ethernet(void *fdt)
{
int i = 0, j, prop;
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 27fe564f0b..a868b6710e 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -102,6 +102,8 @@ static inline int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[],
}
#endif
+int fdt_set_usable_memory(void *blob, u64 start[], u64 size[], int banks);
+
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);
--
2.17.1
next prev parent reply other threads:[~2019-07-12 10:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-12 10:50 [U-Boot] [PATCH v1 0/2] android: colibri_imx7: reserve DDR memory for Cortex-M4 Igor Opaniuk
2019-07-12 10:50 ` Igor Opaniuk [this message]
2019-07-12 11:14 ` [U-Boot] [PATCH v1 1/2] common: fdt_support: add support for setting usable memory Oleksandr Suvorov
2019-10-14 12:40 ` sbabic at denx.de
[not found] ` <5da46cc1.1c69fb81.5f0ce.bea2SMTPIN_ADDED_MISSING@mx.google.com>
2019-11-28 15:23 ` Igor Opaniuk
2019-12-03 9:28 ` Stefano Babic
2019-12-04 8:39 ` Igor Opaniuk
2019-07-12 10:50 ` [U-Boot] [PATCH v1 2/2] board: colibri_imx7: reserve DDR memory for Cortex-M4 Igor Opaniuk
2019-07-12 11:23 ` Oleksandr Suvorov
2019-10-14 12:40 ` sbabic at denx.de
[not found] ` <5da46cd0.1c69fb81.5d82a.9621SMTPIN_ADDED_MISSING@mx.google.com>
2019-11-28 15:21 ` Igor Opaniuk
2019-07-12 10:55 ` [U-Boot] [PATCH v1 0/2] android: " Igor Opaniuk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190712105031.11455-2-igor.opaniuk@gmail.com \
--to=igor.opaniuk@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox