common: fdt_support: add support for setting usable memory
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> Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
This commit is contained in:
parent
1fae23899c
commit
949b5a969d
@ -467,6 +467,41 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
int fdt_fixup_memory(void *blob, u64 start, u64 size)
|
||||
|
@ -94,6 +94,7 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size);
|
||||
*/
|
||||
#ifdef CONFIG_ARCH_FIXUP_FDT_MEMORY
|
||||
int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks);
|
||||
int fdt_set_usable_memory(void *blob, u64 start[], u64 size[], int banks);
|
||||
#else
|
||||
static inline int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[],
|
||||
int banks)
|
||||
|
Loading…
Reference in New Issue
Block a user