aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-k3
diff options
context:
space:
mode:
authorFaiz Abbas <faiz_abbas@ti.com>2020-08-03 11:35:06 +0530
committerLokesh Vutla <lokeshvutla@ti.com>2020-08-11 20:34:46 +0530
commitf9916b6d3bdfa71bedd101a442656cc699c89719 (patch)
treec888bffd2fa3a1aaf9c5a794d796fceda62c0a50 /arch/arm/mach-k3
parent39388aebed67a64d1bac8cd6652e8f418c116252 (diff)
downloadu-boot-f9916b6d3bdfa71bedd101a442656cc699c89719.zip
u-boot-f9916b6d3bdfa71bedd101a442656cc699c89719.tar.gz
u-boot-f9916b6d3bdfa71bedd101a442656cc699c89719.tar.bz2
armv7R: K3: am654: Use full malloc in SPL both pre and post reloc
In order to be able to use things like file system drivers early on in SPL (before relocation) in a memory-constrained environment when DDR is not yet available we cannot use the simple malloc scheme which does not implement the freeing of previously allocated memory blocks. To address this issue go ahead and enable the use of the full malloc by manually initializing the required functionality inside board_init_f by creating a full malloc pool inside the pre-relocation malloc pool. Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Diffstat (limited to 'arch/arm/mach-k3')
-rw-r--r--arch/arm/mach-k3/am6_init.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
index 516a02e..74557c4 100644
--- a/arch/arm/mach-k3/am6_init.c
+++ b/arch/arm/mach-k3/am6_init.c
@@ -18,7 +18,9 @@
#include <dm/uclass-internal.h>
#include <dm/pinctrl.h>
#include <linux/soc/ti/ti_sci_protocol.h>
+#include <log.h>
#include <mmc.h>
+#include <stdlib.h>
#ifdef CONFIG_SPL_BUILD
#ifdef CONFIG_K3_LOAD_SYSFW
@@ -119,6 +121,8 @@ void board_init_f(ulong dummy)
{
#if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS)
struct udevice *dev;
+ size_t pool_size;
+ void *pool_addr;
int ret;
#endif
/*
@@ -150,6 +154,20 @@ void board_init_f(ulong dummy)
#ifdef CONFIG_K3_LOAD_SYSFW
/*
+ * Initialize an early full malloc environment. Do so by allocating a
+ * new malloc area inside the currently active pre-relocation "first"
+ * malloc pool of which we use all that's left.
+ */
+ pool_size = CONFIG_VAL(SYS_MALLOC_F_LEN) - gd->malloc_ptr;
+ pool_addr = malloc(pool_size);
+ if (!pool_addr)
+ panic("ERROR: Can't allocate full malloc pool!\n");
+
+ mem_malloc_init((ulong)pool_addr, (ulong)pool_size);
+ gd->flags |= GD_FLG_FULL_MALLOC_INIT;
+ debug("%s: initialized an early full malloc pool at 0x%08lx of 0x%lx bytes\n",
+ __func__, (unsigned long)pool_addr, (unsigned long)pool_size);
+ /*
* Process pinctrl for the serial0 a.k.a. WKUP_UART0 module and continue
* regardless of the result of pinctrl. Do this without probing the
* device, but instead by searching the device that would request the