summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-15 17:25:38 +1300
committerSimon Glass <sjg@chromium.org>2021-03-26 17:03:09 +1300
commitbaf0371883b243fa793ba3f984704b027705d6a9 (patch)
tree28a07a8f9336d9b5b8aa202e271ae00e1f311949 /drivers/core
parent6f644efdd803e0718d39266f75c0535a534cc601 (diff)
dm: core: Allow storing priv/plat data separately
At present the device priv/data data allocated by dtoc is stored in the data section along with other variables. On some platforms it is better to allocate space for it separately, e.g. if SPL is running from read-only memory. Create a new space with the same size as that allocated by dtoc, ready for use. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/root.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 446ac2ff77..82b3c7de71 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -11,6 +11,7 @@
#include <fdtdec.h>
#include <log.h>
#include <malloc.h>
+#include <asm-generic/sections.h>
#include <asm/global_data.h>
#include <linux/libfdt.h>
#include <dm/acpi.h>
@@ -135,7 +136,9 @@ static int dm_setup_inst(void)
if (CONFIG_IS_ENABLED(OF_PLATDATA_RT)) {
struct udevice_rt *urt;
+ void *base;
int n_ents;
+ uint size;
/* Allocate the udevice_rt table */
n_ents = ll_entry_count(struct udevice, udevice);
@@ -143,6 +146,15 @@ static int dm_setup_inst(void)
if (!urt)
return log_msg_ret("urt", -ENOMEM);
gd_set_dm_udevice_rt(urt);
+
+ /* Now allocate space for the priv/plat data, and copy it in */
+ size = __priv_data_end - __priv_data_start;
+
+ base = calloc(1, size);
+ if (!base)
+ return log_msg_ret("priv", -ENOMEM);
+ memcpy(base, __priv_data_start, size);
+ gd_set_dm_priv_base(base);
}
return 0;