summaryrefslogtreecommitdiff
path: root/board/aspeed
diff options
context:
space:
mode:
authorChia-Wei Wang <[email protected]>2024-09-10 17:39:18 +0800
committerLeo Yu-Chi Liang <[email protected]>2024-09-11 20:35:03 +0800
commit73f802ac95ede0324f54852088c1ea1f7cb9e55a (patch)
tree3f558330260d0d6b8fef2a0eecc193d63eea485a /board/aspeed
parent4b0129e8103dab9887d495d9c4dface8eeefb10b (diff)
board: ibex_ast2700: Add FMC header support
Define and parse the header of the First Mutable Code (FMC) of AST2700 SoCs at runtime phase. The FMC header contains the information to load prebuilt binaries required for device initialization such as DRAM and VGA. Signed-off-by: Chia-Wei Wang <[email protected]> Reviewed-by: Leo Yu-Chi Liang <[email protected]>
Diffstat (limited to 'board/aspeed')
-rw-r--r--board/aspeed/ibex_ast2700/Makefile1
-rw-r--r--board/aspeed/ibex_ast2700/fmc_hdr.c64
2 files changed, 65 insertions, 0 deletions
diff --git a/board/aspeed/ibex_ast2700/Makefile b/board/aspeed/ibex_ast2700/Makefile
index 162f46fd46a..3d8eea9166d 100644
--- a/board/aspeed/ibex_ast2700/Makefile
+++ b/board/aspeed/ibex_ast2700/Makefile
@@ -1,2 +1,3 @@
obj-y += ibex_ast2700.o
+obj-y += fmc_hdr.o
obj-y += sli.o
diff --git a/board/aspeed/ibex_ast2700/fmc_hdr.c b/board/aspeed/ibex_ast2700/fmc_hdr.c
new file mode 100644
index 00000000000..2068a906f60
--- /dev/null
+++ b/board/aspeed/ibex_ast2700/fmc_hdr.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) Aspeed Technology Inc.
+ */
+
+#include <asm/arch/fmc_hdr.h>
+#include <asm/io.h>
+#include <asm/sections.h>
+#include <errno.h>
+#include <spl.h>
+#include <string.h>
+
+int fmc_hdr_get_prebuilt(uint32_t type, uint32_t *ofst, uint32_t *size)
+{
+ struct fmc_hdr_preamble *preamble;
+ struct fmc_hdr_body *body;
+ struct fmc_hdr *hdr;
+ uint32_t t, s, o;
+ int i;
+
+ if (type >= PBT_NUM)
+ return -EINVAL;
+
+ if (!ofst || !size)
+ return -EINVAL;
+
+ hdr = (struct fmc_hdr *)(_start - sizeof(*hdr));
+ preamble = &hdr->preamble;
+ body = &hdr->body;
+
+ if (preamble->magic != HDR_MAGIC)
+ return -EIO;
+
+ for (i = 0, o = sizeof(*hdr) + body->fmc_size; i < HDR_PB_MAX; ++i) {
+ t = body->pbs[i].type;
+ s = body->pbs[i].size;
+
+ /* skip if unrecognized, yet */
+ if (t >= PBT_NUM) {
+ o += s;
+ continue;
+ }
+
+ /* prebuilt end mark */
+ if (t == 0 && s == 0)
+ break;
+
+ /* return the prebuilt info if found */
+ if (t == type) {
+ *ofst = o;
+ *size = s;
+
+ goto found;
+ }
+
+ /* update offset for next prebuilt */
+ o += s;
+ }
+
+ return -ENODATA;
+
+found:
+ return 0;
+}